[Title] add emulator-manager.exe(for windows), modify delete function
authorjihye kim <jihye1128.kim@samsung.com>
Sun, 18 Mar 2012 14:39:08 +0000 (23:39 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Sun, 18 Mar 2012 14:39:08 +0000 (23:39 +0900)
[Type] Enhancement
[Module] major
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

emulator-manager.c
emulator-manager.exe [new file with mode: 0755]
package/build.windows
src/org/tizen/emulator/manager/tool/FileIO.java
src/org/tizen/emulator/manager/ui/MainDialog.java
src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java
src/org/tizen/emulator/manager/ui/vmstree/VMsTable.java
src/org/tizen/emulator/manager/vm/VMProcess.java
src/org/tizen/emulator/manager/vm/VMPropertyValue.java
src/org/tizen/emulator/manager/vms/EmulatorVMs.java

index 1cbb812..81bedb9 100755 (executable)
@@ -12,18 +12,21 @@ int main() {
     char* strInstalledPath;\r
     char strLocalAppDataPath[MAX] = {0};\r
 \r
+     // Get a "tizensdkpath" file path\r
+    //strLocalAppDataPath = getenv("LOCALAPPDATA");\r
+\r
     DWORD dwBufLen = MAX;\r
     RegOpenKeyEx(HKEY_CURRENT_USER, \r
     "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",\r
     0, KEY_QUERY_VALUE, &hKey);\r
     RegQueryValueEx(hKey, "Local AppData", NULL, NULL, (LPBYTE)strLocalAppDataPath, &dwBufLen);\r
     RegCloseKey(hKey);\r
-    printf("%s\n", strLocalAppDataPath);\r
-    // Get a "tizensdkpath" file path\r
-    //strLocalAppDataPath = getenv("LOCALAPPDATA");\r
+    //printf("%s\n", strLocalAppDataPath);\r
+   \r
     strcpy(strPropertyFilePath, strLocalAppDataPath);\r
     strcat(strPropertyFilePath, "\\.TizenSDK\\tizensdkpath");\r
-    printf("%s\n", strPropertyFilePath);\r
+    //printf("%s\n", strPropertyFilePath);\r
+\r
     // get a line of installed path\r
     if ((propertyFile = fopen(strPropertyFilePath, "rt")) == NULL) {\r
       fputs("Cannot open input file...\n", stderr);\r
diff --git a/emulator-manager.exe b/emulator-manager.exe
new file mode 100755 (executable)
index 0000000..65d1763
Binary files /dev/null and b/emulator-manager.exe differ
index e1591d2..3cdb8a2 100755 (executable)
@@ -14,14 +14,12 @@ build()
 {
        cd $SRCDIR
        ant -buildfile build.xml windows-jar
-       gcc emulator-manager.c -o emulator-manager.exe
 }
 
 # install
 install() 
 {
        BIN_DIR=$SRCDIR/package/emulator-manager.package.windows/data/Emulator
-       VTM_DIR=$BIN_DIR/Emulator/bin/emulator-manager.exe
        mkdir -p $BIN_DIR/bin
 
 #      editbin.exe /SUBSYSTEM:WINDOWS $VTM_DIR
index 2811399..00e6311 100644 (file)
@@ -11,7 +11,6 @@ public class FileIO {
        private final static String icon_suffix = File.separator +"skins"+ File.separator +"icons" + File.separator +"vtm.ico";
        private final static String data_suffix = File.separator +"data";
        private final static String conf_suffix = File.separator +"conf";
-       private final static String vms_suffix = File.separator +".tizen_vms";
        private final static String baseimg_suffix = File.separator +"emulimg-1.0.x86";
        private final static String bios_suffix = File.separator + "pc-bios";
        private final static String etc_suffix = File.separator +"etc";
index f9c6dc2..b640102 100644 (file)
@@ -14,6 +14,7 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.tool.Launcher;
@@ -131,7 +132,7 @@ public class MainDialog {
                                        @Override
                                        public void widgetDefaultSelected(SelectionEvent e) {}
                                });
-                                       
+
                                deleteButton = new Button(buttonComposite, SWT.PUSH);
                                deleteButton.setText("Delete");
                                deleteButton.addSelectionListener(new SelectionListener() {
@@ -221,8 +222,8 @@ public class MainDialog {
                                        public void widgetDefaultSelected(SelectionEvent e) {
                                        }
                                });
-                               
-                       }       
+
+                       }
 
                        sashForm.setWeights(new int[] { 100, 0 });
                }
@@ -231,28 +232,38 @@ public class MainDialog {
        // TOOD : error checking
        public void deleteVirtualTarget() {
                ArrayList<VMsProperty> list = imageListTable.getSelectionItem();
-               for (VMsProperty property : list) {
-                       String path = EmulatorVMs.getInstance().getVMsBaseDirectory()
-                                             + File.separator + property.getArch().toString()
-                                             + File.separator + property.getName();
-                       File vtFolder = new File(path);
-                       if (vtFolder.exists()) {
-                               for (File dir : vtFolder.listFiles()) {
-                                       if (dir.isFile()) {
-                                               dir.delete();
-                                       } else { // directory
-                                               for (File sub : dir.listFiles()) {
-                                                       if (sub.isFile()) {
-                                                               sub.delete();
+               MessageBox msg = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.CANCEL);
+               msg.setText("INFO");
+               msg.setMessage("Are you sure delete selected virtual machines?");       
+               int response = msg.open();
+               if (response == SWT.OK) {
+                       for (VMsProperty property : list) {
+                               String path = EmulatorVMs.getInstance().getVMsBaseDirectory()
+                                                     + File.separator + property.getArch().toString()
+                                                     + File.separator + property.getName();
+                               File vtFolder = new File(path);
+                               if (vtFolder.exists()) {
+                                       for (File dir : vtFolder.listFiles()) {
+                                               if (dir.isFile()) {
+                                                       dir.delete();
+                                               } else { // directory
+                                                       for (File sub : dir.listFiles()) {
+                                                               if (sub.isFile()) {
+                                                                       sub.delete();
+                                                               }
                                                        }
+                                                       dir.delete();
                                                }
-                                               dir.delete();
                                        }
+                                       vtFolder.delete();
                                }
-                               vtFolder.delete();
                        }
+                       refreshProperties();
+                       msg = new MessageBox(shell, SWT.ICON_INFORMATION);
+                       msg.setText("INFO");
+                       msg.setMessage("Delete completed!");
+                       msg.open();
                }
-               refreshProperties();
        }
 
        public void refreshProperties() {
@@ -268,7 +279,7 @@ public class MainDialog {
                deleteButton.setEnabled(true);
                // TODO
                //resetButton.setEnabled(true);
-               
+
                leftButton.setText(Launch);
                rightButton.setText(Modify);
                leftButton.setEnabled(true);
@@ -278,7 +289,11 @@ public class MainDialog {
        }
 
        public void closeDetailView() {
-               deleteButton.setEnabled(false);
+               if (imageListTable.getCountSelectionItem() > 1) {
+                       deleteButton.setEnabled(true);
+               } else {
+                       deleteButton.setEnabled(false);
+               }
                // TODO
                //resetButton.setEnabled(false);
                detailView.closeDetailView();
@@ -299,7 +314,7 @@ public class MainDialog {
                deleteButton.setEnabled(false);
                // TODO
                //resetButton.setEnabled(false);
-               
+
                leftButton.setText(Launch);
                rightButton.setText(Create);
                leftButton.setEnabled(false);
@@ -313,7 +328,7 @@ public class MainDialog {
                deleteButton.setEnabled(false);
                // TODO
                //resetButton.setEnabled(false);
-               
+
                leftButton.setText(Launch);
                rightButton.setText(Create);
 
@@ -324,7 +339,7 @@ public class MainDialog {
                deleteButton.setEnabled(false);
                // TODO
                //resetButton.setEnabled(false);
-               
+
                leftButton.setText(Confirm);
                rightButton.setText(Cancel);
 
index 3320046..fb1cf66 100644 (file)
@@ -29,7 +29,7 @@ import org.tizen.emulator.manager.vm.VMViewWidget;
 import org.tizen.emulator.manager.vms.VMsProperty;
 
 enum CItem{
-       ImageName("Image Name"), ImageNameInfo(""), BaseImage("BaseImage"), 
+       ImageName("Name"), ImageNameInfo(""), BaseImage("BaseImage"), 
        Resolution("Display Resolution"), Density("Display Density"),
        SDType("SDCard"), SDPath("SDCard Path"), RAMSize("RAM Size"),
        ShareType("File Sharing"), SharePath("File Sharing Path");
@@ -310,7 +310,7 @@ public class VMPropertyView {
                if (isCreateMode) {
                        // add Image Name Info
                        widget.nameinfoLabel = new Label(table, SWT.WRAP);
-                       widget.nameinfoLabel.setText("Input image name");
+                       widget.nameinfoLabel.setText("Input name");
                        createNameListener();
                }
        }
@@ -345,7 +345,7 @@ public class VMPropertyView {
                        return;
                }
 
-               widget.nameinfoLabel.setText("Input image name");
+               widget.nameinfoLabel.setText("Input name");
                if (newValue.imageName.isEmpty()) {
                        widget.confirmButton.setEnabled(false);
                } else {
@@ -488,12 +488,14 @@ public class VMPropertyView {
                                        String path = widget.SDImageFD.open();
                                        if(path != null) {
                                                newValue.SDCardPath = path;
+                                               newValue.SDCardPathName = path.substring(path.lastIndexOf(SEFARATOR) + 1, path.length());
                                                widget.SDCardPathCombo.remove(0);
-                                               widget.SDCardPathCombo.add(path.substring(path.lastIndexOf(SEFARATOR) + 1, path.length()), 0);
+                                               widget.SDCardPathCombo.add(newValue.SDCardPathName, 0);
                                                widget.SDCardPathCombo.select(0);
                                        }
                                } else if (i != 0) {
                                        newValue.SDCardPath = widget.SDCardPathCombo.getItem(i);
+                                       newValue.SDCardPathName = widget.SDCardPathCombo.getItem(i);
                                }
                        }
                        @Override
index 73f5774..ad44fa4 100644 (file)
@@ -187,6 +187,23 @@ public class VMsTable {
                
        }
 
+       public int getCountSelectionItem() {
+               int count = 0;
+               Object data;
+               for (int i = 0; i < vmsTree.getSelectionCount(); i++) {
+                        data = vmsTree.getSelection()[i].getData();
+                       if(!(data instanceof RowItem))
+                               continue;
+                       
+                       if (data instanceof CreateMarker || data instanceof TreeMarker) {
+                               return 0;
+                       }
+                       
+                       count++;
+               }
+               return count;
+       }
+
        public ArrayList<VMsProperty> getSelectionItem() {
                ArrayList<VMsProperty> list = new ArrayList<VMsProperty>();
 
index 021bfca..e5b879f 100644 (file)
@@ -12,6 +12,7 @@ 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;
 import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
@@ -57,7 +58,7 @@ public class VMProcess {
                        } else {
                                property.getConfiguration().getDevice().getStorage().getSDCard().setDiskImage(null);
                        }
-               } else if (newVM.isSDCardSupport && !newVM.SDCardPath.equals(oldVM.SDCardPath)) {
+               } else if (newVM.isSDCardSupport && !newVM.SDCardPathName.equals(oldVM.SDCardPathName)) {
                        if (!modifySDCard(newVM)) {
                                return null;
                        }
@@ -72,7 +73,7 @@ public class VMProcess {
                
                if (newVM.isFileShareSupport != oldVM.isFileShareSupport) {
                        isModify = true;
-                       if (newVM.isFileShareSupport || !newVM.fileSharePath.isEmpty()) {
+                       if (newVM.isFileShareSupport && !newVM.fileSharePath.isEmpty()) {
                                property.getConfiguration().getUsability().getFileSharing().setPath(newVM.fileSharePath);
                        } else {
                                property.getConfiguration().getUsability().getFileSharing().setPath(null);
@@ -88,6 +89,7 @@ public class VMProcess {
 
                return property;
        }
+
        public VMsProperty create(VMsProperty property, VMPropertyValue oldVM, VMPropertyValue newVM) {
                this.newVM = newVM;
                this.property = EmulatorVMs.getInstance().getNewProperty
@@ -103,7 +105,6 @@ public class VMProcess {
                folderPath = folder.getAbsolutePath() + SEFARATOR;
 
                File log = new File(filePath.getVirtualTargetLogPath(newVM.imageName));
-               settingProperty();
                
                folder.mkdirs();
 
@@ -133,6 +134,8 @@ public class VMProcess {
                }
 
                log.mkdir();
+
+               settingProperty();
                EmulatorVMs.getInstance().storeXML(this.property);
                return this.property;
        }
@@ -166,9 +169,7 @@ public class VMProcess {
                
                ec.getBaseInformation().setName(newVM.imageName);
                ec.getBaseInformation().setArchitecture(Architecture.x86.toString());
-       }
-
-       private boolean createDiskImage() {
+               
                ec.getBaseInformation().setDiskImage(factory.createBaseInformationTypeDiskImage());
                if (newVM.isDefaultImage) {
                        ec.getBaseInformation().getDiskImage().setType("standard");
@@ -181,18 +182,55 @@ public class VMProcess {
                //
                ec.getBaseInformation().getDiskImage().setBaseDiskImage(factory.createDiskImageFormatType());
                ec.getBaseInformation().getDiskImage().setCurrentDiskImage(factory.createDiskImageFormatType());
+               
+               // TODO :
+               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2");
+               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setValue(newVM.baseImagePath);
+               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) {
+                       ec.getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
+               }
+       }
 
+       private boolean createDiskImage() {
                if (newVM.baseImagePath == null || newVM.baseImagePath.isEmpty()) {
                        newVM.baseImagePath = filePath.getBaseimgPath();
                }
-               
+
                if (!new File(newVM.baseImagePath).exists()) {
                        setErrorMessage("Base image does not exist.");
                        return false;
                }
-               
+
                String exe_path = filePath.getBinPath() + SEFARATOR + "qemu-img";
-               
 
                List<String> cmd = new ArrayList<String>();
                cmd.add(exe_path);
@@ -210,70 +248,40 @@ public class VMProcess {
                        return false;
                }
 
-               // TODO :
-               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2");
-               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setValue(newVM.baseImagePath);
-               ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setFormat("qcow2");
-               ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(
-                               String.format("%semulimg-%s.%s", folderPath, newVM.imageName, Architecture.x86.toString()));
                return true;
        }
 
        // usability
        private boolean createFileShare() {
-               ec.getUsability().setLogging(factory.createUsabilityTypeLogging());
-               ec.getUsability().getLogging().setLevel("NONE");
-               ec.getUsability().setHwVirtualization(true);
-
                if (newVM.isFileShareSupport) {
                        if (newVM.fileSharePath == null || newVM.fileSharePath.isEmpty()) {
                                setErrorMessage("Select sharing file path");
                                return false;
                        }
                }
-               ec.getUsability().setFileSharing(factory.createUsabilityTypeFileSharing());
-               if (!newVM.fileSharePath.isEmpty()) {
-                       ec.getUsability().getFileSharing().setPath(newVM.fileSharePath);
-               }
                return true;
        }
 
        // Device
        private boolean createDisplay() {
-               ec.getDevice().setDisplay(factory.createDisplayType());
-
                int i = newVM.resolution.indexOf('x');
-               ec.getDevice().getDisplay().setResolution(factory.createDisplayTypeResolution());
-               ec.getDevice().getDisplay().getResolution().setWidth(Integer.valueOf(newVM.resolution.substring(0,i)));
-               ec.getDevice().getDisplay().getResolution().setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length())));
-               
-               ec.getDevice().getDisplay().setDensity(factory.createDisplayTypeDensity());
-               ec.getDevice().getDisplay().getDensity().setUnit("dpi");
-               ec.getDevice().getDisplay().getDensity().setValue(newVM.dpi);
+               newVM.resolutionType = new Resolution();
+               newVM.resolutionType.setWidth(Integer.valueOf(newVM.resolution.substring(0,i)));
+               newVM.resolutionType.setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length())));
+
                return true;
        }
 
        private boolean createRam() {
-               ec.getDevice().setRAM(factory.createRamType());
-               ec.getDevice().getRAM().setSize(factory.createRamTypeSize());
-               ec.getDevice().getRAM().getSize().setUnit("MiB");
-               ec.getDevice().getRAM().getSize().setValue(newVM.ramSize);
                return true;
        }
 
        private boolean createSDCard() {
-               ec.getDevice().setStorage(factory.createStorageType());
-               
                if (newVM.isSDCardSupport) {
                        if (! modifySDCard(newVM)) {
                                return false;
                        }
                }
-
-               ec.getDevice().getStorage().setSDCard(factory.createStorageTypeSDCard());
-               if (newVM.isSDCardSupport) {
-                       ec.getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
-               }
                return true;
        }
 
index 46cc877..47085c3 100644 (file)
@@ -45,7 +45,7 @@ public class VMPropertyValue {
 
                isSDCardSupport         = oldTarget.isSDCardSupport;
                SDCardPath                      = oldTarget.SDCardPath;
-               SDCardPath                      = oldTarget.SDCardPathName;
+               SDCardPathName          = oldTarget.SDCardPathName;
                
                ramSize                         = oldTarget.ramSize;
                
index d0a9c9d..2a84b0c 100644 (file)
@@ -28,12 +28,12 @@ public class EmulatorVMs {
                }
        }
        
-       String vmsBaseDirectoryName = System.getProperty("user.dir") + 
-                       File.separator + "test" + File.separator + "tizen_vms";
+       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;
        }
@@ -47,7 +47,7 @@ public class EmulatorVMs {
        }       
        
        public String getVMsBaseDirectory() {
-               return this.vmsBaseDirectoryName;
+               return vmsBaseDirectoryName;
        }
        
        public ObjectFactory getObjectFactory() {