[Title] checking creating base image beacause working time is 60 seconds..
authorjihye kim <jihye1128.kim@samsung.com>
Fri, 31 Aug 2012 04:03:15 +0000 (13:03 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Fri, 31 Aug 2012 04:19:58 +0000 (13:19 +0900)
and --vms option apply to liunx..
[Type] work
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/ui/MainDialog.java
src/org/tizen/emulator/manager/ui/MenuHandling.java
src/org/tizen/emulator/manager/ui/detail/TableWidget.java
src/org/tizen/emulator/manager/vms/EmulatorVMs.java
src/org/tizen/emulator/manager/vms/VMsWorker.java

index 63b2a22..3c021b8 100755 (executable)
@@ -298,6 +298,8 @@ public class EmulatorManager {
 
                }
                } catch (Exception e) {
+                       e.printStackTrace();
+
                        if (EMLogger.getLogger() != null) {
                                EMLogger.getLogger().log(Level.WARNING, e.getMessage());
                        }
index 131d9bb..707e2c3 100644 (file)
@@ -265,8 +265,7 @@ public class MainDialog {
        }
 
        public void cloneVM() {
-               CloneDialog cloneDialog = new CloneDialog(this, detailView.getCurrentPoperty());
-               cloneDialog.open();
+               handling.cloneVirtualMachine(detailView.getCurrentPoperty());
        }
 
        // TOOD : error checking
index 6029eb3..709bbe7 100644 (file)
 
 package org.tizen.emulator.manager.ui;
 
+import java.util.ArrayList;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.tool.FilePath;
 import org.tizen.emulator.manager.ui.vmstree.VMsTree;
 import org.tizen.emulator.manager.vms.VMsProperty;
@@ -41,6 +44,7 @@ import org.tizen.emulator.manager.vms.VMsWorkerException;
 public class MenuHandling {
        private Shell shell;
        private VMsTree vmsTree;
+       private static ArrayList<String> baseImagePaths = new ArrayList<String>();
 
        public MenuHandling(Shell shell, VMsTree vmsTree) {
                this.shell              = shell;
@@ -116,10 +120,10 @@ public class MenuHandling {
                MessageDialog msg = new MessageDialog();
                VMsProperty property = prop;
                if(prop.getWorker().isRunningNow()) {
-                       msg.openWarningDialog("Can not 'Create Base Image' while source VM is running.");
+                       msg.openWarningDialog("Not allowed to 'Create Base Image' while source VM is running.");
                        return ;
                }
-                       
+
                FileDialog fd = new FileDialog(shell, SWT.SAVE);
                fd.setText("Create 'Base Image' As");
                String[] filter = {"*."+ property.getArch().toString()};
@@ -137,6 +141,7 @@ public class MenuHandling {
 
                String returnMSG = "";
                try {
+                       MenuHandling.addBaseImagePath(path);
                        property.getWorker().createNewBaseImage(property, path);
                        //returnMSG = "Succeeded to create 'Base Image'!\nPath: " + path;
                } catch (VMsWorkerException e) {
@@ -144,4 +149,38 @@ public class MenuHandling {
                        msg.openInfoDialog(returnMSG);
                }
        }
+
+       public void cloneVirtualMachine(VMsProperty currentPoperty) {
+               MessageDialog msg = new MessageDialog();
+               if(currentPoperty.getWorker().isRunningNow()) {
+                       msg.openWarningDialog("Not allowed to 'Clone' while source VM is running.");
+                       return ;
+               }
+
+               CloneDialog cloneDialog = new CloneDialog(EmulatorManager.getInstance().getMainDialog(), currentPoperty);
+               cloneDialog.open();
+       }
+
+       public static boolean isPathAvaliable(String path) {
+               if (path != null) {
+                       for(String p : baseImagePaths) {
+                               if (p.equals(path)) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       public static void addBaseImagePath(String path) {
+               if (path != null) {
+                       baseImagePaths.add(path);
+               }
+       }
+
+       public static void removeBaseImagePath(String path) {
+               if (path != null) {
+                       baseImagePaths.remove(path);
+               }
+       }
 }
index ff7fefd..573ebdb 100644 (file)
@@ -50,6 +50,8 @@ import org.eclipse.swt.widgets.Text;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MenuHandling;
+import org.tizen.emulator.manager.ui.MessageDialog;
 import org.tizen.emulator.manager.ui.ResourceRegistry;
 import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
 import org.tizen.emulator.manager.vms.RESOLUTION;
@@ -325,6 +327,11 @@ class BaseImageButton extends TableWidget {
 
                                String path = baseImageFD.open();
                                if(path != null) {
+                                       if (!MenuHandling.isPathAvaliable(path)) {
+                                               new MessageDialog().openWarningDialog("This base image not ready yet.\n" +
+                                                               "Please select again in a few seconds.");
+                                               return;
+                                       }
                                        newPath = path;
                                        newPathName = path.substring(path.lastIndexOf(File.separator) + 1, path.length());
                                        baseImageButton.setText(newPathName);
index 24526dd..4d52922 100644 (file)
@@ -44,10 +44,13 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.FilePath;
 import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MessageDialog;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
@@ -65,17 +68,22 @@ public class EmulatorVMs {
        static String vmsBaseDirectoryName = "";
        static String vmsConfigDirectory   = "";
        static {
-               if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
-                       if (EmulatorManager.getEmulatorVMsPath() != null
-                                       && !EmulatorManager.getEmulatorVMsPath().isEmpty()) {
-                               tizenSdkDataPath =  EmulatorManager.getEmulatorVMsPath()
-                                                               + File.separator + "tizen-sdk-data";
-                       } else {
-                               tizenSdkDataPath = "tizen-sdk-data";
-                       }
+               if (EmulatorManager.getEmulatorVMsPath() != null
+                               && !EmulatorManager.getEmulatorVMsPath().isEmpty()) {
+                       tizenSdkDataPath =  EmulatorManager.getEmulatorVMsPath()
+                                                       + File.separator + "tizen-sdk-data";
                } else {
+                       if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+                               String error = "Start EmulatorManager without emulator-manager.exe\n" +
+                                               "EmulatorManager's workspace be changed. Please check workspace path.\n";
+                               if (!EmulatorManager.isConsoleMode()) {
+                                       new MessageDialog(new Shell(Display.getCurrent()))
+                                       .openInfoDialog(error + "Click about menu!");
+                               }
+                               EMLogger.getLogger().warning(error);
+                       }
                        tizenSdkDataPath = System.getProperty("user.home")
-                                                               + File.separator + "tizen-sdk-data";
+                                       + File.separator + "tizen-sdk-data";
                }
 
                vmsBaseDirectoryName = tizenSdkDataPath
index 76387a7..e596fea 100644 (file)
@@ -45,12 +45,16 @@ import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.FilePath;
 import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MenuHandling;
 import org.tizen.emulator.manager.ui.MessageDialog;
 
 
 public class VMsWorker {
        VMsProperty property;
        Launcher launcher;
+       WorkerThread worker = null;
+       String baseImagePath = null;
+
        public VMsWorker(VMsProperty property) {
                this.property = property;
                launcher = new Launcher();
@@ -75,6 +79,7 @@ public class VMsWorker {
        }
 
        public void createNewBaseImage(VMsProperty property, String dest) throws VMsWorkerException {
+               baseImagePath = dest;
                File childImage = new File(property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue());
                File baseImage  = new File(property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue()); 
                if(!childImage.exists()) {
@@ -107,7 +112,7 @@ public class VMsWorker {
                */
 
 
-               workerThread worker = new workerThread(proc);
+               worker = new WorkerThread(proc);
                worker.start();
                if (EmulatorManager.isConsoleMode()) {
                        System.out.println("Wait....while creating base image.\n"
@@ -128,7 +133,7 @@ public class VMsWorker {
                } else {
                        synchronized(worker) {
                                try {
-                                       worker.wait(3000);
+                                       worker.wait(2000);
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                } finally {
@@ -151,10 +156,10 @@ public class VMsWorker {
                 */
        }
 
-       class workerThread extends Thread {
+       class WorkerThread extends Thread {
                QemuImgProc proc;
                boolean isError;
-               public workerThread(QemuImgProc proc) {
+               public WorkerThread(QemuImgProc proc) {
                        this.proc = proc;
                        isError = false;
                }
@@ -164,6 +169,7 @@ public class VMsWorker {
                                isError = true;
                        }
                        synchronized(this) {
+                               MenuHandling.removeBaseImagePath(baseImagePath);
                                notifyAll();
                        }
                }
@@ -244,6 +250,11 @@ public class VMsWorker {
        // check if the emulator instance with the same name is running now.
        public boolean isRunningNow()
        {
+               if (worker != null) {
+                       if (worker.isAlive()) {
+                               return true;
+                       }
+               }
                Logger logger = EMLogger.getLogger();
                boolean result = false;
                MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));