[Title] add 'reset function' and modfiy 'modfiy function' and delete tab
authorjihye kim <jihye1128.kim@samsung.com>
Thu, 22 Mar 2012 03:10:08 +0000 (12:10 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Thu, 22 Mar 2012 03:10:08 +0000 (12:10 +0900)
[Type] Enhancement
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

19 files changed:
dist/linux/emulator-manager.jar
src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/tool/FileIO.java
src/org/tizen/emulator/manager/tool/Launcher.java
src/org/tizen/emulator/manager/ui/MainDialog.java
src/org/tizen/emulator/manager/ui/ResourceRegistry.java
src/org/tizen/emulator/manager/ui/detail/DetailTableView.java
src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java
src/org/tizen/emulator/manager/ui/detail/VMResource.java
src/org/tizen/emulator/manager/ui/vmstree/ContentProvider.java
src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java
src/org/tizen/emulator/manager/ui/vmstree/RowItem.java
src/org/tizen/emulator/manager/ui/vmstree/VMsTable.java
src/org/tizen/emulator/manager/vms/EmulatorVMs.java
src/org/tizen/emulator/manager/vms/VMCreateHelper.java [moved from src/org/tizen/emulator/manager/vm/VMCreateHelper.java with 92% similarity]
src/org/tizen/emulator/manager/vms/VMProcess.java [moved from src/org/tizen/emulator/manager/vm/VMProcess.java with 96% similarity]
src/org/tizen/emulator/manager/vms/VMPropertyValue.java [moved from src/org/tizen/emulator/manager/vm/VMPropertyValue.java with 96% similarity]
src/org/tizen/emulator/manager/vms/VMViewWidget.java [moved from src/org/tizen/emulator/manager/vm/VMViewWidget.java with 96% similarity]
src/org/tizen/emulator/manager/vms/VMsProperty.java

index d8109af..3440bf3 100644 (file)
Binary files a/dist/linux/emulator-manager.jar and b/dist/linux/emulator-manager.jar differ
index cb0c95c..cbf0163 100644 (file)
@@ -14,31 +14,31 @@ import org.tizen.emulator.manager.vms.VMsProperty;
 
 public class EmulatorManager {
        private static EmulatorManager instance;
-       
+
        Display display;
        Shell shell;
-       
+
        Image icon;
 
        private MainDialog mainDialog;
        private Launcher launcher;
-       
+
        public EmulatorManager() {
                this.display = new Display();
-               
+
                shell = new Shell(display);
 
                shell.setSize(700, 500);
                shell.setText("Emulator Manager");
                shell.setLayout(new FillLayout());
-               
+
                InputStream is = this.getClass().getClassLoader().getResourceAsStream("res/em.ico");
                if(is != null) {
                        icon = new Image(display, is);
                        shell.setImage(icon);
                }
        }
-       
+
        public static EmulatorManager getInstance() {
                return instance;
        }
@@ -46,19 +46,19 @@ public class EmulatorManager {
        public Display getDisplay() {
                return display;
        }
-       
+
        public Shell getShell() {
                return shell;
        }
-               
+
        public MainDialog getMainDialog() {
                return mainDialog;
        }
-       
+
        public Launcher getLauncher() {
                return launcher;
        }
-       
+
        private void preare() {
                
                mainDialog = new MainDialog();
@@ -66,16 +66,16 @@ public class EmulatorManager {
 
        private void DrawUI() {
                mainDialog.draw();
-               
+
                shell.open();
-               
+
                while(!shell.isDisposed()) {
                        if(!display.readAndDispatch()) display.sleep();
                }
 
                display.dispose();
        }
-       
+
        public void launchVM(VMsProperty property) {
                Launcher.launch(property);
        }
@@ -94,17 +94,17 @@ public class EmulatorManager {
                else {
                        EmulatorVMs.getInstance().setVMsBaseDirectory(FileIO.getInstance().getTizenVmsPath());
                }
-               
+
                try {
                        EmulatorVMs.getInstance().loadProperties();
                } catch (Exception e) {
                        e.printStackTrace();
                }
-               
+
                instance = new EmulatorManager();
                instance.preare();
                instance.DrawUI();
-               
+
                instance.dispose();
        }
 }
index 00e6311..4e59562 100644 (file)
@@ -16,11 +16,11 @@ public class FileIO {
        private final static String etc_suffix = File.separator +"etc";
        private final static String log_suffix = File.separator +"logs";
        private final static String x86_kernel_suffix = File.separator +"kernel-img";
-       
+
        private static String currentPath;
        private static String emulatorPath;
        private static String sdkPath;
-       
+
        private static String sdbPath;
        // Emulator
        private static String binPath;
@@ -38,7 +38,7 @@ public class FileIO {
 
        static {
                // emulator-manager.jar file path
-               {
+                {
                        File jar = null;
                        try {
                                jar = new File(EmulatorManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
@@ -51,7 +51,7 @@ public class FileIO {
  
                emulatorPath = currentPath + File.separator + "..";
                sdkPath = emulatorPath + File.separator + "..";
-               
+
                // SDB path
                {
                        String sdb_suffix;
@@ -59,7 +59,7 @@ public class FileIO {
                                sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb.exe";
                        else
                                sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb";
-                       
+
                        sdbPath = sdkPath + sdb_suffix;
                }
 
@@ -67,11 +67,11 @@ public class FileIO {
                arcPath = emulatorPath + arch_suffix;
                etcPath = emulatorPath + etc_suffix;
                iconPath = emulatorPath + icon_suffix;
-               
+
                dataPath = arcPath + data_suffix;
                confPath = arcPath + conf_suffix;
                baseImagePath = arcPath + baseimg_suffix;
-               
+
                x86KernelPath = dataPath + x86_kernel_suffix;
                biosPath = dataPath + bios_suffix;
                vmsPath = EmulatorVMs.getInstance().getVMsBaseDirectory();
@@ -107,7 +107,7 @@ public class FileIO {
        public static FileIO getInstance() {
                return instance;
        }
-       
+
        public String getSdkRoot(){
                return sdkPath;
        }
@@ -119,16 +119,16 @@ public class FileIO {
        public String getBinPath(){
                return binPath;
        }
-       
+
        public String getArchPath(){
                return arcPath;
        }
 
-       // ~/tizen_sdk/Emulator/skins/icons/vtm.ico
-    public String getIconPath(){
+        // ~/tizen_sdk/Emulator/skins/icons/vtm.ico
+       public String getIconPath(){
                return iconPath;
        }
-       
+
        public String getDataPath(){
                return dataPath;
        }
@@ -136,26 +136,26 @@ public class FileIO {
        public String getConfPath(){
                return confPath;
        }
-       
+
        public String getTizenVmsPath() {
                return vmsPath;
        }
-       
+
        public String getTizenVmsArchPath() {
                return vmsArchPath;
        }
-       
+
        public String getBaseimgPath(){
                return baseImagePath;
        }
-       
+
        public String getEtcPath(){
                return etcPath;
        }
        public String getKernelPath(){
                return x86KernelPath;
        }
-       
+
        // ~/tizen_sdk/Emulator/x86/data/pc-bios/bios.bin
        public String getBiosPath() {
                return biosPath;
@@ -164,7 +164,7 @@ public class FileIO {
        public String getVirtualTargetPath(String name) {
                return getTizenVmsArchPath() + File.separator + name;
        }
-       
+
        public String getVirtualTargetLogPath(String name) {
                return getVirtualTargetPath(name) + log_suffix;
        }
index 2cfa66d..e869524 100644 (file)
@@ -27,7 +27,7 @@ public class Launcher {
                int portNo; 
                String  StrPortNo = "";
                int c;
-               
+
                //check if there is another Emulator instance with the same name
                String PortPath = new FileIO().getTizenVmsArchPath() + File.separator + property.getName() + File.separator + ".port";
                File file = new File(PortPath);
@@ -42,13 +42,13 @@ public class Launcher {
                        } catch(Exception e1) {
                                e1.printStackTrace();
                        }
-     
+
                        //FIXME
                        /*
                        Socket so = null;
                        try {
                                Socket so = new Socket("localhost", Integer.parseInt(StrPortNo) +1 );
-                so.close();
+                               so.close();
                        } catch (UnknownHostException e) {
                                // TODO Auto-generated catch block
                        //      e.printStackTrace();
@@ -136,12 +136,12 @@ public class Launcher {
                                                + " root=/dev/vda rw"
                                                + " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5");
                        }
-                       
+
                        if(isLinux > -1 && isFileshare) { //linux and use fileshare [non-kernel option]
                                cmd.add("-virtfs");
                                cmd.add("local,path=" + property.getConfiguration().getUsability().getFileSharing().getPath() +",security_model=none,mount_tag=fileshare");
                        }
-                       
+
                        if(isSDcard) {
                                cmd.add("-drive");
                                cmd.add("file=" + sdcard + ",if=virtio");
@@ -208,7 +208,7 @@ public class Launcher {
                        cmd.add("base=utc");
                        cmd.add(kvm);
                        /*
-               if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1 && property.getConfiguration().getUsability().isHwVirtualization()) {
+                       if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1 && property.getConfiguration().getUsability().isHwVirtualization()) {
                                File fi = new File("/dev/kvm");
                                exists = fi.exists();
                                if(exists) {
@@ -216,12 +216,12 @@ public class Launcher {
                                }
                        }
                        */
-            // cmd.add("-redir");
-               //      cmd.add("tcp:1202:10.0.2.16:22");
+                       //      cmd.add("-redir");
+                       //      cmd.add("tcp:1202:10.0.2.16:22");
                        //System.out.println(cmd);
                        ProcessBuilder pb = new ProcessBuilder(cmd);
                        pb.directory(new File(fio.getBinPath()));
-                       
+
                        Process process = pb.start();
 
                        final InputStream in1 = new BufferedInputStream(process.getInputStream());
index 995d1d6..c1f509d 100644 (file)
@@ -22,6 +22,7 @@ import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
 import org.tizen.emulator.manager.ui.detail.DetailTableView;
 import org.tizen.emulator.manager.ui.vmstree.VMsTable;
 import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.VMProcess;
 import org.tizen.emulator.manager.vms.VMsProperty;
 import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
 
@@ -50,12 +51,12 @@ public class MainDialog {
        private Button rightButton;
 
        private Shell shell;
-       
+
        public MainDialog() {
                this.shell = EmulatorManager.getInstance().getShell();
        }
-       
-       public void draw() {    
+
+       public void draw() {
                Composite mainComposite = new Composite(shell, SWT.NONE);
                mainComposite.setLayout(new GridLayout(1, false));
 
@@ -125,6 +126,7 @@ public class MainDialog {
 
                                Button refreshButton = new Button(buttonComposite, SWT.PUSH);
                                refreshButton.setText("Refresh");
+                               refreshButton.setToolTipText("refresh list of virtual machine");
                                refreshButton.setImage(ResourceRegistry.getImage(ImageName.REFRESH));
                                refreshButton.addSelectionListener(new SelectionListener() {
                                        @Override
@@ -137,11 +139,12 @@ public class MainDialog {
 
                                deleteButton = new Button(buttonComposite, SWT.PUSH);
                                deleteButton.setText("Delete");
+                               deleteButton.setToolTipText("delete selected virtual machine");
                                deleteButton.setImage(ResourceRegistry.getImage(ImageName.DELETE));
                                deleteButton.addSelectionListener(new SelectionListener() {
                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
-                                               deleteVirtualTarget();
+                                               deleteVirtualMachine();
                                                detailView.closeDetailView();
                                                refreshProperties();
                                        }
@@ -152,9 +155,19 @@ public class MainDialog {
 
                                resetButton = new Button(buttonComposite, SWT.PUSH);
                                resetButton.setText("Reset");
+                               resetButton.setToolTipText("format os of virtual machine");
                                resetButton.setImage(ResourceRegistry.getImage(ImageName.RESET));
-                               //TODO
-                               resetButton.setEnabled(false);
+                               resetButton.addSelectionListener(new SelectionListener() {
+                                       @Override
+                                       public void widgetDefaultSelected(SelectionEvent arg0) {
+                                       }
+
+                                       @Override
+                                       public void widgetSelected(SelectionEvent arg0) {
+                                               resetVirtualMachine();
+                                       }
+                                       
+                               });
                        }
 
                        // LEFT : detail table
@@ -233,8 +246,42 @@ public class MainDialog {
                }
        }
 
+       public void resetVirtualMachine() {
+               ArrayList<VMsProperty> list = imageListTable.getSelectionItem();
+               MessageBox msg = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
+               msg.setText("Warning");
+               msg.setMessage("This virtual machine will be formatting.\nAre you sure to conitnue?");
+               int response = msg.open();
+               if (response == SWT.OK) {
+               VMProcess process = new VMProcess();
+                       for (VMsProperty property : list) {
+                               String basePath = property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
+                               String targetPath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
+                               if (basePath == null || basePath.isEmpty() || targetPath == null || targetPath.isEmpty()) {
+                                       msg = new MessageBox(shell, SWT.ICON_INFORMATION);
+                                       msg.setText("INFO");
+                                       msg.setMessage("Fail reset virtual machine : " + property.getName());
+                                       msg.open();
+                                       return;
+                               }
+
+                               if(!process.createBaseImage(basePath, targetPath)) {
+                                       msg = new MessageBox(shell, SWT.ICON_INFORMATION);
+                                       msg.setText("INFO");
+                                       msg.setMessage(process.getErrorMessage());
+                                       msg.open();
+                                       return;
+                               }
+                       }
+                       msg = new MessageBox(shell, SWT.ICON_INFORMATION);
+                       msg.setText("INFO");
+                       msg.setMessage("Reset completed!");
+                       msg.open();
+               }
+       }
+
        // TOOD : error checking
-       public void deleteVirtualTarget() {
+       public void deleteVirtualMachine() {
                ArrayList<VMsProperty> list = imageListTable.getSelectionItem();
                MessageBox msg = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.CANCEL);
                msg.setText("INFO");
@@ -243,8 +290,8 @@ public class MainDialog {
                if (response == SWT.OK) {
                        for (VMsProperty property : list) {
                                String path = EmulatorVMs.getInstance().getVMsBaseDirectory()
-                                                     + File.separator + property.getArch().toString()
-                                                     + File.separator + property.getName();
+                                                         + File.separator + property.getArch().toString()
+                                                         + File.separator + property.getName();
                                File vtFolder = new File(path);
                                if (vtFolder.exists()) {
                                        for (File dir : vtFolder.listFiles()) {
@@ -281,8 +328,7 @@ public class MainDialog {
 
        public void openDetailView(VMsProperty property) {
                deleteButton.setEnabled(true);
-               // TODO
-               //resetButton.setEnabled(true);
+               resetButton.setEnabled(true);
 
                leftButton.setText(Launch);
                leftButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
@@ -300,29 +346,28 @@ public class MainDialog {
                } else {
                        deleteButton.setEnabled(false);
                }
-               // TODO
-               //resetButton.setEnabled(false);
+               resetButton.setEnabled(false);
                detailView.closeDetailView();
        }
 
        public void openModifyView(VMsProperty property) {
                deleteButton.setEnabled(false);
-               // TODO
-               //resetButton.setEnabled(false);
+               resetButton.setEnabled(false);
 
                leftButton.setText(Confirm);
                leftButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
-
                rightButton.setText(Cancel);
                rightButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
 
-               detailView.openModifyView(property);
+               leftButton.setEnabled(false);
+               rightButton.setEnabled(true);
+
+               detailView.openModifyView(property, leftButton);
        }
 
        public void openCreateDetailView(boolean isDefault) {
                deleteButton.setEnabled(false);
-               // TODO
-               //resetButton.setEnabled(false);
+               resetButton.setEnabled(false);
 
                leftButton.setText(Launch);
                leftButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
@@ -338,8 +383,7 @@ public class MainDialog {
 
        public void openCreateDetailView() {
                deleteButton.setEnabled(false);
-               // TODO
-               //resetButton.setEnabled(false);
+               resetButton.setEnabled(false);
 
                leftButton.setText(Launch);
                leftButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
@@ -351,15 +395,14 @@ public class MainDialog {
 
        public void openCreateView() {
                deleteButton.setEnabled(false);
-               // TODO
-               //resetButton.setEnabled(false);
+               resetButton.setEnabled(false);
 
                leftButton.setText(Confirm);
                leftButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
                rightButton.setText(Cancel);
                rightButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
 
-               detailView.openCreateView(rightButton, leftButton);
+               detailView.openCreateView(leftButton);
        }
 
        public void dispose() {
index fdaf1f0..440ec8b 100644 (file)
@@ -11,21 +11,21 @@ public class ResourceRegistry {
        public enum ImageName {
                CANCEL("cancel"), CONFIRM("confirm"), CREATE("create"), DELETE("delete"), DETAILS("details"),
                FOLDER("folder"), MODIFY("modify"), REFRESH("refresh"), RESET("reset"), LAUNCH("launch");
-               
+
                String name;
-               
+
                ImageName(String name) {
                        this.name = name;
                }
-               
+
                @Override
                public String toString() {
                        return name;
                }
        }
-       
+
        private static ResourceRegistry instance;
-       
+
        Map<ImageName, Image> imagesMap = new HashMap<ImageName, Image>();
 
        static {
@@ -43,16 +43,16 @@ public class ResourceRegistry {
                        }
                }
        }
-       
+
        public static Image getImage(ImageName imageName) {
                return instance.imagesMap.get(imageName);
        }
-       
+
        public static void dispose() {
                for(Image image : instance.imagesMap.values()) {
                        image.dispose();
                }
        }
-       
+
        private ResourceRegistry() {}
 }
index 3301259..951a59e 100644 (file)
@@ -18,7 +18,7 @@ public class DetailTableView {
        private static String Detail  = "Datail";
 
        private MainDialog  mainDialog;
-       private Table           detailTable;
+       private Table            detailTable;
        private TableColumn tableColumn;
 
        private boolean isDetailOpened = false;
@@ -26,7 +26,7 @@ public class DetailTableView {
        private boolean isCreateState  = false;
        private boolean isModifyState  = false;
        private boolean isDefaultCreate;
-       
+
        private VMsProperty currentProperty;
        private VMPropertyView vmView = null;
 
@@ -105,7 +105,7 @@ public class DetailTableView {
                isDetailOpened = false;
        }
 
-       public void openModifyView(VMsProperty property)
+       public void openModifyView(VMsProperty property, Button confirmButton)
        {
                isModifyState = true;
                tableColumn.setText(Modify);
@@ -114,9 +114,9 @@ public class DetailTableView {
                if (vmView == null) {
                        return;
                }
-               vmView.modifyView();
+               vmView.modifyView(confirmButton);
        }
-       
+
        public void closeModifyView()
        {
                isModifyState = false;
@@ -153,7 +153,7 @@ public class DetailTableView {
                }
        }
 
-       public void openCreateView(Button rightButton, Button leftButton) {
+       public void openCreateView( Button confirmButton) {
                isCreateState = true;
 
                tableColumn.setText(Create);
@@ -164,7 +164,7 @@ public class DetailTableView {
                                return;
                }
 
-               vmView.createView(rightButton, leftButton);
+               vmView.createView(confirmButton);
        }
 
        public void closeCreateView()
index fef0dd1..f6d9a1c 100644 (file)
@@ -22,10 +22,11 @@ import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.emulator.manager.ui.ResourceRegistry;
 import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.vm.VMCreateHelper;
-import org.tizen.emulator.manager.vm.VMProcess;
-import org.tizen.emulator.manager.vm.VMPropertyValue;
-import org.tizen.emulator.manager.vm.VMViewWidget;
+import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.VMCreateHelper;
+import org.tizen.emulator.manager.vms.VMProcess;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.VMViewWidget;
 import org.tizen.emulator.manager.vms.VMsProperty;
 
 enum CItem{
@@ -50,21 +51,21 @@ enum DItem{
 
 public class VMPropertyView {
        private static String   SEFARATOR = File.separator;
-       private VMCreateHelper  helper;
-       private VMViewWidget    widget;
-       private VMProcess               process;
-       private VMsProperty     property;
+       private VMCreateHelper   helper;
+       private VMViewWidget     widget;
+       private VMProcess                process;
+       private VMsProperty      property;
        private Table                   table;
-       private Image                   image           = null;
+       private Image                    image            = null;
        private VMPropertyValue oldValue        = null;
-       private VMPropertyValue newValue        = null;
+       private VMPropertyValue newValue         = null;
 
        private boolean isCreateMode = true;
 
        public VMPropertyView(Table table) {
-               this.helper     = new VMCreateHelper();
-               this.process    = new VMProcess();
-               this.widget     = new VMViewWidget();
+               this.helper      = new VMCreateHelper();
+               this.process     = new VMProcess();
+               this.widget      = new VMViewWidget();
                this.table              = table;
 
 //             InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("res/folder.png");
@@ -124,7 +125,7 @@ public class VMPropertyView {
                widget.itemList.get(CItem.ShareType.ordinal()).setText(0, CItem.ShareType.toString());
                widget.itemList.get(CItem.SharePath.ordinal()).setText(0, CItem.SharePath.toString());
        }
-       
+
        private void settingDetailColumn() {
                table.clearAll();
                widget.itemList.get(DItem.ImageName.ordinal()).setText(0, CItem.ImageName.toString());
@@ -148,7 +149,7 @@ public class VMPropertyView {
                        settingDetailColumn();
                }
 
-               this.property   = property;
+               this.property    = property;
                oldValue = new VMPropertyValue();
                oldValue.settingValue(property);
 
@@ -194,8 +195,10 @@ public class VMPropertyView {
                widget.itemList.get(CItem.SharePath.ordinal()).setText(1, oldValue.fileSharePathName);
        }
 
-       public void modifyView() {
+       public void modifyView(Button confirm) {
                newValue = new VMPropertyValue(oldValue);
+               widget.confirmButton = confirm;
+
                createNameArea(table);
                createBaseImageArea(table);
                createDisplayArea(table);
@@ -206,9 +209,8 @@ public class VMPropertyView {
                settingModifyTableEditor();
        }
 
-       public void createView(Button cancle, Button confirm) {
+       public void createView(Button confirm) {
                newValue = new VMPropertyValue(oldValue);
-               widget.cancelButton = cancle;
                widget.confirmButton = confirm;
 
                createNameArea(table);
@@ -222,8 +224,8 @@ public class VMPropertyView {
        }
 
        private void settingModifyTableEditor() {
-               TableEditor editor              = new TableEditor(table);
-               editor.grabHorizontal   = true;
+               TableEditor editor               = new TableEditor(table);
+               editor.grabHorizontal    = true;
                editor.setEditor(widget.imageNameText, widget.itemList.get(DItem.ImageName.ordinal()), 1);
 
                editor = new TableEditor(table);
@@ -260,8 +262,8 @@ public class VMPropertyView {
        }
 
        private void settingCreateTableEditor() {
-               TableEditor editor              = new TableEditor(table);
-               editor.grabHorizontal   = true;
+               TableEditor editor               = new TableEditor(table);
+               editor.grabHorizontal    = true;
                editor.setEditor(widget.imageNameText, widget.itemList.get(CItem.ImageName.ordinal()), 1);
 
                editor = new TableEditor(table);
@@ -341,7 +343,7 @@ public class VMPropertyView {
                }
                
                if (!oldValue.imageName.equals(newValue.imageName)
-                   && helper.checkDupulicateName(newValue.imageName)) {
+                       && helper.checkDupulicateName(newValue.imageName)) {
                        widget.nameinfoLabel.setText("The same name exists!");
                        widget.confirmButton.setEnabled(false);
                        return;
@@ -381,7 +383,7 @@ public class VMPropertyView {
                        widget.selectBaseImageButton.setEnabled(false);
                }
        }
-       
+
        private void createBaseImageListener() {
                widget.selectBaseImageButton.addSelectionListener(new SelectionListener() {
                        @Override
@@ -425,6 +427,9 @@ public class VMPropertyView {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                newValue.resolution = widget.resolutionCombo.getItem(widget.resolutionCombo.getSelectionIndex());
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -436,6 +441,9 @@ public class VMPropertyView {
                        @Override
                        public void modifyText(ModifyEvent e) {
                                newValue.dpi = widget.DIPspinner.getSelection();
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                });
        }
@@ -455,7 +463,7 @@ public class VMPropertyView {
 
                createSDCardListener();
        }
-       
+
        private void createSDCardListener() {
                widget.SDCardTypeCombo.addSelectionListener(new SelectionListener() {
                        @Override
@@ -468,11 +476,15 @@ public class VMPropertyView {
                                        newValue.isSDCardSupport = false;
                                        widget.SDCardPathCombo.setEnabled(false);
                                }
+
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
-        });
+               });
 
                widget.SDCardPathCombo.addSelectionListener(new SelectionListener() {
                        @Override
@@ -499,6 +511,10 @@ public class VMPropertyView {
                                        newValue.SDCardPath = widget.SDCardPathCombo.getItem(i);
                                        newValue.SDCardPathName = widget.SDCardPathCombo.getItem(i);
                                }
+
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -520,6 +536,10 @@ public class VMPropertyView {
                        public void widgetSelected(SelectionEvent e) {
                                String str = widget.ramSizeCombo.getItem(widget.ramSizeCombo.getSelectionIndex());
                                newValue.ramSize = Integer.valueOf(str.substring(0, str.length()-3));
+
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -552,11 +572,15 @@ public class VMPropertyView {
                                        newValue.isFileShareSupport = false;
                                        widget.selectShareFolderButton.setEnabled(false);
                                }
+
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
-        });
+               });
 
                widget.selectShareFolderButton.addSelectionListener(new SelectionListener() {
                        @Override
@@ -570,6 +594,10 @@ public class VMPropertyView {
                                        newValue.fileSharePath = path;
                                        widget.selectShareFolderButton.setText(path.substring(path.lastIndexOf(SEFARATOR) + 1, path.length()));
                                }
+
+                               if (!isCreateMode) {
+                                       checkModifyState();
+                               }
                        }
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {   
@@ -577,6 +605,38 @@ public class VMPropertyView {
                });
        }
 
+       private void checkModifyState() {
+               boolean isModify =false;
+               if (!newValue.resolution.equals(oldValue.resolution)) {
+                       isModify = true;
+               }
+               if (newValue.dpi != oldValue.dpi) {
+                       isModify = true;
+               }
+
+               if (newValue.isSDCardSupport != oldValue.isSDCardSupport) {
+                       isModify = true;
+               } else if (newValue.isSDCardSupport && !newValue.SDCardPath.equals(oldValue.SDCardPath)) {
+                       isModify = true;
+               }
+
+               if (newValue.ramSize != oldValue.ramSize) {
+                       isModify = true;
+               }
+
+               if (newValue.isFileShareSupport != oldValue.isFileShareSupport) {
+                       isModify = true;
+               } else if (newValue.isFileShareSupport && !newValue.fileSharePath.equals(oldValue.fileSharePath)) {
+                       isModify = true;
+               }
+
+               if (isModify) {
+                       widget.confirmButton.setEnabled(true);
+               } else {
+                       widget.confirmButton.setEnabled(false);
+               }
+       }
+
        public void close() {
                widget.close();
        }
index 10a85b9..781726e 100644 (file)
@@ -83,11 +83,11 @@ class DisplayResoultion extends StringArrayResource
                add(0, "320x480");
                add(1, "480x800");
                add(2, "600x1024");
-               add(3, "720X1280");
+               add(3, "720x1280");
                
                setDefaultIndex(3);
        }
-       
+
        public int findIndex(String r) {
                String[] strArray = getList();
                String s = null;
@@ -148,7 +148,7 @@ class RamSize extends StringArrayResource
                
                setDefaultIndex(0);
        }
-       
+
        public int findIndex(String size) {
                String[] strArray = getList();
                String s = null;
index 071dd09..b35082a 100644 (file)
@@ -8,7 +8,7 @@ import org.tizen.emulator.manager.vms.xml.DisplayType;
 // TODO: Support dynamic column editing...
 public class ContentProvider {
        static final int numberOfColumns = 4;
-       
+
        String[] columnTitles = new String[] { "Name", "Resolution", "Density", "RAM size" };
        
        public String[] getColumnTitles() {
@@ -21,17 +21,17 @@ public class ContentProvider {
        
        public String[] getColumnContents(VMsProperty property) {
                String[] texts = new String[numberOfColumns];
-               
+
                texts[0] = property.getName();
                
                DeviceType deviceType = property.getConfiguration().getDevice();
                DisplayType displayType = deviceType.getDisplay();
                texts[1] = displayType.getResolution().getWidth()
                                + " x " + displayType.getResolution().getHeight();
-               
+
                texts[2] = displayType.getDensity().getValue() + "";
                texts[3] = deviceType.getRAM().getSize().getValue() + "";
-                               
+
                return texts;
        }
 
index 2e9180d..17a9e46 100644 (file)
@@ -21,7 +21,7 @@ public class ContextMenu {
 
        public void prepare(final Tree vmsTree) {
                treeMenu = new Menu(vmsTree);
-               
+
                final MenuItem launchItem = new MenuItem(treeMenu, SWT.NONE);
                launchItem.setText("Launch");
                launchItem.addSelectionListener(new SelectionListener() {
@@ -29,7 +29,7 @@ public class ContextMenu {
                        public void widgetSelected(SelectionEvent e) {
                                if(vmsTree.getSelectionCount() > 1)
                                        return;
-                               
+
                                VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property;
                                EmulatorManager.getInstance().launchVM(property);
                        }
@@ -57,29 +57,38 @@ public class ContextMenu {
                        }
                        @Override
                        public void widgetSelected(SelectionEvent arg0) {
-                               EmulatorManager.getInstance().getMainDialog().deleteVirtualTarget();
+                               EmulatorManager.getInstance().getMainDialog().deleteVirtualMachine();
                        }
                });
                final MenuItem resetItem = new MenuItem(treeMenu, SWT.NONE);
                resetItem.setText("Reset");
-               resetItem.setEnabled(false);
-               
+               resetItem.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent arg0) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent arg0) {
+                               EmulatorManager.getInstance().getMainDialog().resetVirtualMachine();
+                       }
+                       
+               });
+
                new MenuItem(treeMenu, SWT.SEPARATOR);
-               
-               final MenuItem createItem = new MenuItem(treeMenu, SWT.NONE);
-               createItem.setText("Clone");
-               createItem.setEnabled(false);
-               
+
+               final MenuItem cloneItem = new MenuItem(treeMenu, SWT.NONE);
+               cloneItem.setText("Clone");
+               cloneItem.setEnabled(false);
+
                treeMenu.addMenuListener(new MenuListener() {
                        @Override
                        public void menuShown(MenuEvent e) {
                                if(vmsTree.getSelectionCount() == 0)
                                        return;
-                               
+
                                for(MenuItem menuItem : treeMenu.getItems()) {
                                        menuItem.setEnabled(true);
                                }
-                               
+
                                if(vmsTree.getSelectionCount() > 1) {
                                        for(TreeItem treeItem : vmsTree.getSelection()) {
                                                RowItem rowItem = (RowItem)treeItem.getData();
@@ -89,7 +98,7 @@ public class ContextMenu {
                                                        break;
                                                }
                                        }
-                                       createItem.setEnabled(false);
+                                       cloneItem.setEnabled(false);
                                        launchItem.setEnabled(false);
                                        modifyItem.setEnabled(false);
                                }
@@ -99,15 +108,14 @@ public class ContextMenu {
                                                deleteItem.setEnabled(false);
                                                resetItem.setEnabled(false);
                                                modifyItem.setEnabled(false);
-                                               createItem.setEnabled(false);
+                                               cloneItem.setEnabled(false);
                                                return;
                                        } else {
-                                               resetItem.setEnabled(false);
-                                               createItem.setEnabled(false);
+                                               cloneItem.setEnabled(false);
                                        }
                                }
                        }
-                       
+
                        @Override
                        public void menuHidden(MenuEvent e) {}
                });
index 68d7636..e1120d3 100644 (file)
@@ -11,7 +11,7 @@ public abstract class RowItem {}
 
 class PropertyContent extends RowItem {
        VMsProperty property;
-       
+
        public PropertyContent(VMsProperty property, ContentProvider provider, TreeItem item) {
                this.property = property;
                item.setText(provider.getColumnContents(property));
@@ -21,7 +21,7 @@ class PropertyContent extends RowItem {
 abstract class TreeMarker extends RowItem {
        public TreeMarker(String text, TreeItem item) {
                item.setText(text);
-       }       
+       }
 }
 
 class CreateMarker extends TreeMarker {
index ad44fa4..cec6286 100644 (file)
@@ -22,50 +22,49 @@ import org.tizen.emulator.manager.vms.VMsProperty.FSImageType;
 
 public class VMsTable {
        MainDialog mainDialog;
-       
+
        Tree vmsTree;
        ContentProvider contentProvider = new ContentProvider();
        ContextMenu contextMenu = new ContextMenu();
-       
+
        EmulatorVMs fsImage = EmulatorVMs.getInstance();
-       
+
        public VMsTable(MainDialog mainDialog, Composite parent) {
                this.mainDialog = mainDialog;
-               
+
                this.vmsTree = new Tree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-               
+
                vmsTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               
+
                vmsTree.setHeaderVisible(true);
                vmsTree.setLinesVisible(true);
-               
+
                for(String columnTitle : contentProvider.getColumnTitles()) {
                        TreeColumn treeColumn = new TreeColumn(vmsTree, SWT.NONE);
                        treeColumn.setText(columnTitle);
                }
-                               
+
                refreshTableList();
                pack();
 
                contextMenu.prepare(vmsTree);
                Menu tableMenu = contextMenu.getMenu();
                vmsTree.setMenu(tableMenu);
-               
+
                vmsTree.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                if(vmsTree.getSelectionCount() == 0)
                                        return;
-                               
+
                                if(vmsTree.getSelectionCount() > 1) {
                                        VMsTable.this.mainDialog.closeDetailView();
                                }
                                else {
                                        Object data = vmsTree.getSelection()[0].getData();
-                                       
+
                                        if(!(data instanceof RowItem))
-                                               return;
-                                       
+
                                        if (vmsTree.getSelection()[0].getData() instanceof CreateMarker) {
                                                if (vmsTree.getSelection()[0].getParentItem().getText().equals("Custom")) {
                                                        VMsTable.this.mainDialog.openCreateDetailView(false);
@@ -79,12 +78,12 @@ public class VMsTable {
                                                VMsTable.this.mainDialog.closeDetailView();
                                                return;
                                        }
-                                                                               
+
                                        PropertyContent content = (PropertyContent)data;
                                        VMsTable.this.mainDialog.openDetailView(content.property);
                                }
                        }
-                       
+
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
                                if(vmsTree.getSelectionCount() > 1) {
@@ -98,7 +97,7 @@ public class VMsTable {
                        }
                });
        }
-       
+
        private void pack() {
                for(TreeColumn column : vmsTree.getColumns()) {
                        column.pack();
@@ -109,35 +108,35 @@ public class VMsTable {
        public void refreshTableList() {
                refreshTableList(null);
        }
-       
+
        private void refreshTableList(String text) {
                boolean x86Selected = mainDialog.x86RadioButton.getSelection();
-               boolean armSelected = mainDialog.armRadioButton.getSelection();         
-               
+               boolean armSelected = mainDialog.armRadioButton.getSelection();
+
                vmsTree.removeAll();
-               
+
                VMsProperty[] properties = (VMsProperty[])fsImage.getProperties();
 
                RowItem rowItem = null;
-               
+
                TreeItem customItem = new TreeItem(vmsTree, SWT.NONE);
                rowItem = new CustomVMsMarker(customItem);
                customItem.setData(rowItem);
-               
+
                TreeItem createItem = new TreeItem(customItem, SWT.NONE);
                rowItem = new CreateMarker(createItem);
                createItem.setData(rowItem);
                
                Map<String, TreeItem> itemsMap = new HashMap<String, TreeItem>();
-               
+
                // FIXME !!
                // TODO: We insert "1.0" now...
                TreeItem tempItem = new TreeItem(vmsTree, SWT.NONE);
                rowItem = new StandardVMsMarker("1.0", tempItem);
                tempItem.setData(rowItem);
-               
+
                itemsMap.put("1.0", tempItem);
-               
+
                createItem = new TreeItem(tempItem, SWT.NONE);
                rowItem = new CreateMarker(createItem);
                createItem.setData(rowItem);
@@ -150,8 +149,8 @@ public class VMsTable {
                                        continue;
                                }
 
-                               TreeItem propertyItem = null;                           
-                               
+                               TreeItem propertyItem = null;
+
                                if(FSImageType.standard == properties[i].getImageType()) {
                                        String version = properties[i].getConfiguration().getBaseInformation().getDiskImage().getVersion();
                                        propertyItem = itemsMap.get(version);
@@ -166,19 +165,17 @@ public class VMsTable {
                                                rowItem = new CreateMarker(createItem);
                                                createItem.setData(rowItem);
                                        }
-                                               
                                        propertyItem = new TreeItem(propertyItem, SWT.NONE);
                                }
                                else {
-                                       propertyItem = new TreeItem(customItem, SWT.NONE);                                      
+                                       propertyItem = new TreeItem(customItem, SWT.NONE);
                                }
-                               
+
                                rowItem = new PropertyContent(properties[i], contentProvider, propertyItem);
                                propertyItem.setData(rowItem);
                        }
                }
-               
-               
+
                createItem.setExpanded(true);
                customItem.setExpanded(true);
                for(TreeItem item : itemsMap.values()) {
@@ -194,11 +191,11 @@ public class VMsTable {
                         data = vmsTree.getSelection()[i].getData();
                        if(!(data instanceof RowItem))
                                continue;
-                       
+
                        if (data instanceof CreateMarker || data instanceof TreeMarker) {
                                return 0;
                        }
-                       
+
                        count++;
                }
                return count;
@@ -214,5 +211,5 @@ public class VMsTable {
                }
 
                return list;
-       }       
+       }
 }
\ No newline at end of file
index 2a84b0c..f9485ea 100644 (file)
@@ -27,33 +27,33 @@ public class EmulatorVMs {
                        instance = new EmulatorVMs();
                }
        }
-       
+
        static String vmsBaseDirectoryName = System.getProperty("user.home")
                                                                                + File.separator + ".tizen_vms";
        List<VMsProperty> propertiesList = new ArrayList<VMsProperty>();
-       
+
        ObjectFactory objectFactory = new ObjectFactory();
 
        public static EmulatorVMs getInstance() {
                return instance;
        }
-       
+
        public void setVMsBaseDirectory(String baseVMsDir) {
                vmsBaseDirectoryName = baseVMsDir;
-               
+
                File fi = new File(vmsBaseDirectoryName);
                if(!fi.exists())
                        fi.mkdirs();
-       }       
-       
+       }
+
        public String getVMsBaseDirectory() {
                return vmsBaseDirectoryName;
        }
-       
+
        public ObjectFactory getObjectFactory() {
                return objectFactory;
        }
-       
+
        public void refreshProperties() {
                try {
                        loadProperties();
@@ -61,44 +61,37 @@ public class EmulatorVMs {
                        e.printStackTrace();
                }
        }
-       
+
        public void loadProperties() throws Exception {
                propertiesList.clear();
                // traverse VMs...
                File vmsBaseDirectory = new File(vmsBaseDirectoryName);
-               
+
                for(File archDir : vmsBaseDirectory.listFiles(new FileFilter() {
-                       
                        @Override
                        public boolean accept(File pathname) {
                                if(!pathname.isDirectory())
                                        return false;
-                               
+
                                if("x86".equals(pathname.getName()) || "arm".equals(pathname.getName()))
                                        return true;
-                               
+
                                return false;
                        }
                })) {
-                       
                        for(File vmsDir : archDir.listFiles(new FileFilter() {
-                               
                                @Override
                                public boolean accept(File pathname) {
                                        if(!pathname.isDirectory())
                                                return false;
-                                       
                                        return true;
                                }
                        })) {
-                               
                                String configFilename = vmsDir.getName() + ".xml";
                                File configFile = new File(vmsDir, configFilename);
                                if(!configFile.exists())
                                        continue ; // FIXME
-                               
                                VMsProperty property = parseXML(configFile);
-                               
                                propertiesList.add(property);
                        }
                }
@@ -107,7 +100,7 @@ public class EmulatorVMs {
        private VMsProperty parseXML(File configFile) {
                JAXBContext context = null;
                JAXBElement<EmulatorConfiguration> element = null;
-               
+
                try {
                        context = JAXBContext.newInstance(EmulatorConfiguration.class);
                        
@@ -116,61 +109,60 @@ public class EmulatorVMs {
                } catch (JAXBException e) {
                        e.printStackTrace();
                }
-               
                return new VMsProperty(configFile, element.getValue());
        }
-       
+
        public VMsProperty getProperty(String name) {
                if(name == null) return null;
-               
+
                for(VMsProperty property : propertiesList) {
                        if(name.equals(property.getName()))
                                        return property;
                }
-               
+
                return null;
        }
-       
+
        public VMsProperty[] getProperties() {
                return propertiesList.toArray(new VMsProperty[propertiesList.size()]);
-       }       
+       }
 
        public boolean storeXML(VMsProperty property) {
                JAXBContext context = null;
-               
+
                try {
                        context = JAXBContext.newInstance(EmulatorConfiguration.class);
                        Marshaller marshaller = context.createMarshaller();
                        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
                        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                       
+
                        if(!property.configFile.exists()) {
                                property.configFile.getParentFile().mkdirs();
                        }
-                               
+
                        marshaller.marshal(property.getConfiguration(), new FileOutputStream(property.configFile));
                } catch (JAXBException e) {
                        e.printStackTrace();
-                       
+
                        return false;
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
-                       
+
                        return false;
                }
-               
+
                return true;
        }
-       
+
        public VMsProperty getNewProperty(String name, Architecture arch) {
                String configDirectoryName = vmsBaseDirectoryName + File.separator + 
                                arch.toString() + File.separator + name;
                String configFilename = configDirectoryName + File.separator + name + ".xml";
-       
+
                File configFile = new File(configFilename);
-               
+
                EmulatorConfiguration ec = objectFactory.createEmulatorConfiguration();
-               
+
 //             ec.setBaseInformation(objectFactory.createBaseInformationType());
 //             ec.setUsability(objectFactory.createUsabilityType());
 //             ec.setSkin(objectFactory.createSkinType());
@@ -184,10 +176,10 @@ public class EmulatorVMs {
 //             .
 //             .
 //             .
-               
+
                return new VMsProperty(configFile, ec);
        }
-       
+
        public static void main(String[] args) {
                EmulatorVMs fsImage = EmulatorVMs.getInstance();
                try {
@@ -195,11 +187,11 @@ public class EmulatorVMs {
                } catch (Exception e) {
                        e.printStackTrace();
                }
-               
+
                for(VMsProperty property : fsImage.getProperties()) {
                        System.out.println(property.getName());
                }
-               
+
                VMsProperty property = fsImage.getNewProperty("test6", Architecture.x86);
                fsImage.storeXML(property);
        }
@@ -1,4 +1,4 @@
-package org.tizen.emulator.manager.vm;
+package org.tizen.emulator.manager.vms;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -6,8 +6,6 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-import org.tizen.emulator.manager.vms.VMsProperty;
 import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
 
 public class VMCreateHelper {
@@ -30,7 +28,7 @@ public class VMCreateHelper {
                // TODO: default x86
                return checkDupulicateName(t, Architecture.x86.toString());
        }
-       
+
        public boolean checkDupulicateName(String t, String arc) {
                VMsProperty[] properties = (VMsProperty[])EmulatorVMs.getInstance().getProperties();
                for (VMsProperty p : properties) {
@@ -51,15 +49,14 @@ public class VMCreateHelper {
                        @Override
                        public void handleEvent(Event event) {
                                event.doit = false;
-                               
                        }
                });
-               
+
                GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
                combo.setLayoutData(gd);
                return combo;
        }
-       
+
        public void addComboItem(Combo combo, Object[] items) {
                addComboItem(combo, items, 0);
        }
@@ -1,4 +1,4 @@
-package org.tizen.emulator.manager.vm;
+package org.tizen.emulator.manager.vms;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -9,8 +9,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.emulator.manager.tool.FileIO;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-import org.tizen.emulator.manager.vms.VMsProperty;
 import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
 import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
@@ -20,7 +18,7 @@ public class VMProcess {
        private static String SEFARATOR = File.separator;
        private FileIO filePath;
        private String errorMessage;
-       
+
        // for modify
        private boolean isModify = false;
 
@@ -42,7 +40,7 @@ public class VMProcess {
                        oldVM.resolutionType.setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length())));
                        property.getConfiguration().getDevice().getDisplay().setResolution(oldVM.resolutionType);
                }
-               
+
                if (newVM.dpi != oldVM.dpi) {
                        isModify = true;
                        property.getConfiguration().getDevice().getDisplay().getDensity().setValue(newVM.dpi);
@@ -65,12 +63,12 @@ public class VMProcess {
                        isModify = true;
                        property.getConfiguration().getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
                }
-               
+
                if (newVM.ramSize != oldVM.ramSize) {
                        isModify = true;
                        property.getConfiguration().getDevice().getRAM().getSize().setValue(newVM.ramSize);
                }
-               
+
                if (newVM.isFileShareSupport != oldVM.isFileShareSupport) {
                        isModify = true;
                        if (newVM.isFileShareSupport && !newVM.fileSharePath.isEmpty()) {
@@ -105,7 +103,7 @@ public class VMProcess {
                folderPath = folder.getAbsolutePath() + SEFARATOR;
 
                File log = new File(filePath.getVirtualTargetLogPath(newVM.imageName));
-               
+
                folder.mkdirs();
 
                if (!createDiskImage()) {
@@ -122,7 +120,7 @@ public class VMProcess {
                        deleteFolder(folder);
                        return null;
                }
-               
+
                if (!createRam()) {
                        deleteFolder(folder);
                        return null;
@@ -166,10 +164,10 @@ public class VMProcess {
                ec.setBaseInformation(factory.createBaseInformationType());
                ec.setUsability(factory.createUsabilityType());
                ec.setDevice(factory.createDeviceType());
-               
+
                ec.getBaseInformation().setName(newVM.imageName);
                ec.getBaseInformation().setArchitecture(Architecture.x86.toString());
-               
+
                ec.getBaseInformation().setDiskImage(factory.createBaseInformationTypeDiskImage());
                if (newVM.isDefaultImage) {
                        ec.getBaseInformation().getDiskImage().setType("standard");
@@ -189,30 +187,30 @@ public class VMProcess {
                ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setFormat("qcow2");
                ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(
                                String.format("%semulimg-%s.%s", folderPath, newVM.imageName, Architecture.x86.toString()));
-               
+
                ec.getUsability().setLogging(factory.createUsabilityTypeLogging());
                ec.getUsability().getLogging().setLevel("NONE");
                ec.getUsability().setHwVirtualization(true);
-               
+
                ec.getUsability().setFileSharing(factory.createUsabilityTypeFileSharing());
                if (!newVM.fileSharePath.isEmpty()) {
                        ec.getUsability().getFileSharing().setPath(newVM.fileSharePath);
                }
-               
+
                ec.getDevice().setDisplay(factory.createDisplayType());
                ec.getDevice().getDisplay().setResolution(factory.createDisplayTypeResolution());
                ec.getDevice().getDisplay().getResolution().setWidth(newVM.resolutionType.getWidth());
                ec.getDevice().getDisplay().getResolution().setHeight(newVM.resolutionType.getHeight());
-               
+
                ec.getDevice().getDisplay().setDensity(factory.createDisplayTypeDensity());
                ec.getDevice().getDisplay().getDensity().setUnit("dpi");
                ec.getDevice().getDisplay().getDensity().setValue(newVM.dpi);
-               
+
                ec.getDevice().setRAM(factory.createRamType());
                ec.getDevice().getRAM().setSize(factory.createRamTypeSize());
                ec.getDevice().getRAM().getSize().setUnit("MiB");
                ec.getDevice().getRAM().getSize().setValue(newVM.ramSize);
-               
+
                ec.getDevice().setStorage(factory.createStorageType());
                ec.getDevice().getStorage().setSDCard(factory.createStorageTypeSDCard());
                if (newVM.isSDCardSupport) {
@@ -230,16 +228,25 @@ public class VMProcess {
                        return false;
                }
 
+               String targetPath = String.format("%semulimg-%s.%s", folderPath, newVM.imageName, Architecture.x86.toString());
+               if (!createBaseImage(newVM.baseImagePath, targetPath)) {
+                       return false;
+               }
+
+               return true;
+       }
+
+       public boolean createBaseImage(String baseImagePath, String targetImagePath) {
                String exe_path = filePath.getBinPath() + SEFARATOR + "qemu-img";
 
                List<String> cmd = new ArrayList<String>();
                cmd.add(exe_path);
                cmd.add("create");
                cmd.add("-b");
-               cmd.add(newVM.baseImagePath);
+               cmd.add(baseImagePath);
                cmd.add("-f");
                cmd.add("qcow2");
-               cmd.add(String.format("%semulimg-%s.%s", folderPath, newVM.imageName, Architecture.x86.toString()));
+               cmd.add(targetImagePath);
                ProcessBuilder pb = new ProcessBuilder(cmd);
                try {
                        pb.start();
@@ -247,7 +254,6 @@ public class VMProcess {
                        setErrorMessage("Emulator image create failed!\n" + e.getMessage());
                        return false;
                }
-
                return true;
        }
 
@@ -304,13 +310,13 @@ public class VMProcess {
                                setErrorMessage("Create new image path is failed!");
                                return false;
                        }
-                       
+
                        FileReader in  = null;
                        FileWriter out = null;
                        try {
                                in  = new FileReader(src);
                                out = new FileWriter(dest);
-                               
+
                                int c;
                                while((c = in.read()) != -1) {
                                        out.write(c);
@@ -1,15 +1,14 @@
-package org.tizen.emulator.manager.vm;
+package org.tizen.emulator.manager.vms;
 
 import java.io.File;
 
-import org.tizen.emulator.manager.vms.VMsProperty;
 import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution;
 
 public class VMPropertyValue {
        public String arcType;
 
        public String imageName;
-       
+
        public boolean isDefaultImage;
        public String baseImagePath;
        public String baseImagePathName;
@@ -21,9 +20,9 @@ public class VMPropertyValue {
        public boolean isSDCardSupport;
        public String SDCardPath;
        public String SDCardPathName;
-       
+
        public int ramSize;
-       
+
        public boolean isFileShareSupport; 
        public String fileSharePath;
        public String fileSharePathName;
@@ -46,9 +45,9 @@ public class VMPropertyValue {
                isSDCardSupport         = oldTarget.isSDCardSupport;
                SDCardPath                      = oldTarget.SDCardPath;
                SDCardPathName          = oldTarget.SDCardPathName;
-               
+
                ramSize                         = oldTarget.ramSize;
-               
+
                isFileShareSupport      = oldTarget.isFileShareSupport; 
                fileSharePath           = oldTarget.fileSharePath;
                fileSharePathName   = oldTarget.fileSharePathName;
@@ -57,7 +56,7 @@ public class VMPropertyValue {
        public void defaultSetting(boolean isDefault) {
                arcType                         = "x86"; // TODO
                imageName                       = "";
-               
+
                isDefaultImage          = isDefault;
                baseImagePath           = "";
                baseImagePathName   = isDefault ? "( emulimg-1.0.x86 )" : " ( None )";
@@ -73,18 +72,18 @@ public class VMPropertyValue {
                isSDCardSupport         = false;
                SDCardPath                      = "";
                SDCardPathName      = "( None )";
-               
+
                ramSize                         = 512;
-               
+
                isFileShareSupport      = false; 
                fileSharePath           = "";
                fileSharePathName   = "( None )";
        }
-       
+
        public void settingValue(VMsProperty property) {
                arcType   = property.getArch().toString();
                imageName = property.getName();
-               
+
                isDefaultImage = property.getConfiguration().getBaseInformation().getDiskImage().getType().equals("standard") ? true : false;
                baseImagePath = property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
                baseImagePathName = baseImagePath.substring
@@ -103,7 +102,7 @@ public class VMPropertyValue {
                        SDCardPath = "";
                        SDCardPathName = "( None )";
                }
-               
+
                fileSharePath = property.getConfiguration().getUsability().getFileSharing().getPath();
                if (fileSharePath  != null) {
                        isFileShareSupport = true;
@@ -1,4 +1,4 @@
-package org.tizen.emulator.manager.vm;
+package org.tizen.emulator.manager.vms;
 
 import java.util.ArrayList;
 
@@ -12,8 +12,6 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.TableItem;
 
-
-
 public class VMViewWidget {
        public Table table;
 
@@ -55,4 +53,3 @@ public class VMViewWidget {
                selectShareFolderButton.dispose();
        }
 }
-
index 273d54b..d3e6610 100644 (file)
@@ -6,18 +6,18 @@ import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 
 public class VMsProperty {
        File configFile;
-       
+
        EmulatorConfiguration rootElement;
-       
+
        public VMsProperty(File configFile, EmulatorConfiguration element) {
                this.configFile = configFile;
                this.rootElement = element;
-       }       
+       }
 
        public String getName() {
                if(rootElement.getBaseInformation() == null)
                        return null;
-               
+
                return rootElement.getBaseInformation().getName();
        }
        public Architecture getArch() {
@@ -34,16 +34,16 @@ public class VMsProperty {
                return FSImageType.standard.toString().equals(rootElement.getBaseInformation().getDiskImage().getType()) ?
                                FSImageType.standard : FSImageType.custom;
        }
-       
+
        public EmulatorConfiguration getConfiguration() {
                return rootElement;
        }
-       
+
        public enum Architecture {
                x86("x86"), ARM("ARM");
-               
+
                private String arch;
-               
+
                Architecture(String arch) {
                        this.arch = arch;
                }
@@ -55,15 +55,15 @@ public class VMsProperty {
 
        public enum FSImageType {
                standard("standard"), custom("custom");
-               
+
                private String type;
-               
+
                FSImageType(String type) {
                        this.type = type;
                }
 
                public String toString() {
                        return type;
-               }       
+               }
        };
 }
\ No newline at end of file