[Title] add usage at console interface
authorjihye kim <jihye1128.kim@samsung.com>
Thu, 5 Jul 2012 09:28:52 +0000 (18:28 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Thu, 5 Jul 2012 09:28:52 +0000 (18:28 +0900)
[Type] work
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/pkginfo.manifest
src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/console/ActionList.java
src/org/tizen/emulator/manager/console/CommandLineParser.java [moved from src/org/tizen/emulator/manager/console/CommandLineProcessor.java with 98% similarity]
src/org/tizen/emulator/manager/console/ConsoleProcessor.java
src/org/tizen/emulator/manager/vms/QemuImgProc.java
src/org/tizen/emulator/manager/vms/VMsWorker.java

index 4629a1f..4d01505 100644 (file)
@@ -1,5 +1,5 @@
 Package: emulator-manager
-Version: 1.0.66
+Version: 1.0.67
 OS: linux
 Build-host-os: linux
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
@@ -7,7 +7,7 @@ Source: emulator-manager
 Description: Tizen Emulator Manager
 
 Package: emulator-manager
-Version: 1.0.66
+Version: 1.0.67
 OS: windows
 Build-host-os: windows
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
index e247409..d4f34e1 100644 (file)
@@ -38,7 +38,7 @@ import java.util.logging.Level;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.manager.console.Action;
-import org.tizen.emulator.manager.console.CommandLineProcessor;
+import org.tizen.emulator.manager.console.CommandLineParser;
 import org.tizen.emulator.manager.image.EmulatorImages;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.CheckSDCard;
@@ -56,7 +56,7 @@ public class EmulatorManager {
        private Display display;
        private MainDialog mainDialog;
 
-       private static CommandLineProcessor processor = null;
+       private static CommandLineParser processor = null;
        private static boolean isConsoleMode = true;
        private static boolean isInhoseMode  = true; // for multi touch
 
@@ -192,7 +192,7 @@ public class EmulatorManager {
                                exitEmulatorManager(-1);
                        }
 
-                       processor = new CommandLineProcessor();
+                       processor = new CommandLineParser();
                        processor.parseArgs(args);
                        if (!SelectWorkspace.getWorkspace(isConsoleMode)) {
                                exitEmulatorManager(-1);
index 23efb48..aa705a2 100644 (file)
@@ -32,20 +32,15 @@ package org.tizen.emulator.manager.console;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.FileIO;
 import org.tizen.emulator.manager.tool.SelectWorkspace;
-import org.tizen.emulator.manager.vms.Launcher;
 import org.tizen.emulator.manager.vms.RAM_SIZE;
 import org.tizen.emulator.manager.vms.RESOLUTION;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
 import org.tizen.emulator.manager.vms.VMPropertyValue;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
 
 public class ActionList {
        private Global globalAction = null;
@@ -114,9 +109,11 @@ public class ActionList {
        }
 
        public void printAction(Action action) {
-               System.out.println("\n-------------------------------------------------------------");
+               System.out.println("\n--------------------------------------------------------------------------");
                System.out.println("Action: \"" + (action.getAction()) +"\"");
                System.out.println("    -> " + action.getDescription());
+               System.out.println("Usage: ");
+               System.out.println("    " + action.getUsage());
                System.out.println();
                System.out.println("Options: ");
                for(Command c : action.getCommandList()) {
@@ -138,12 +135,13 @@ class Global extends Action {
        public Global() {
                this.action = Actions.AC_GLOBAL;
                this.description = "Global Options";
-               this.usage      = "[[-h | --help] | [-v | --verbose]] action [action options]";
+               //this.usage    = "[[-h | --help] | [-v | --verbose]] action [action options]";
+               this.usage ="";
 
                commandList.add(new Command("h", Actions.OP_HELP,
                                "Display information of specific command.", "", false, false));
                commandList.add(new Command("v", Actions.OP_VERBOSE,
-                               "Display information running state", "", false ,false));
+                               "Display information running emulator-manager's state", "", false ,false));
        }
 
        public boolean process() {
@@ -154,11 +152,11 @@ class Global extends Action {
 class ListVM extends Action {
        public ListVM() {
                this.action     = Actions.AC_LIST_VM;
-               this.description = "Print list of existing 'Virtual Machine'";
-               this.usage = "[-d | " + Actions.OP_DETAIL + "]";
+               this.description = "Display list of existing 'Virtual Machine'";
+               this.usage = "list-vm [options]";
 
                commandList.add(new Command("d", Actions.OP_DETAIL,
-                               "Print more information of VM.","", false, false));
+                               "Display more information of VMs.","", false, false));
                /*
                commandList.add(new Command("c", Actions.AC_COMPACT,
                                "Compact output(Print list of vm's name).", "", false, false));
@@ -189,8 +187,8 @@ class ListVM extends Action {
 class ListImage extends Action {
        public ListImage() {
                this.action             = Actions.AC_LIST_IMAGE;
-               this.description = "Print list of existing base disk image";;
-               this.usage = "[action options]";
+               this.description = "Display list of existing base disk image";;
+               this.usage = "list-image";
        }
 
        @Override
@@ -209,10 +207,11 @@ class Detail extends Action {
        public Detail() {
                this.action     = Actions.AC_DETAIL;
                this.description = "Display more information of selected 'Virtual Target'.";
-               this.usage = "[-n | "+ Actions.OP_NAME + "] test";
+               this.usage = "detail -n test";
 
                commandList.add(new Command("n", Actions.OP_NAME,
-                               "Name of vertual target.\nIf you do not enter a name, emulator manager's information is printed.","", false, true));
+                               "Name of vertual target.\n" +
+                               "                       If you do not enter a name, emulator manager's information is printed.","", false, true));
        }
 
        @Override
@@ -247,13 +246,14 @@ class Workspace extends Action {
                this.action     = Actions.AC_WORKSPACE;
                this.description = "Set(Get) workspace of emulator manager."; 
                                        //+ "Workspace is directory that stores the generated 'Virtual Target'";
-               this.usage = String.format("[-s | %s] path\n\t\t\t\t[-g | %s]", Actions.OP_SET, Actions.OP_GET);
+               this.usage = String.format("Set worksapce : workspace -s path\n" +
+                                                               "       Get workspace : workspace -g");
 
                commandList.add(new Command("s", Actions.OP_SET,
                                "Set path of workspace.", FileIO.getInstance().getTizenVmsPath(),
                                false, true));
                commandList.add(new Command("g", Actions.OP_GET,
-                               "Get current workspace", FileIO.getInstance().getTizenVmsPath(),
+                               "Get current workspace path.", FileIO.getInstance().getTizenVmsPath(),
                                false, false));
        }
 
@@ -311,7 +311,9 @@ class Create extends Action {
        public Create() {
                this.action     = Actions.AC_CREATE;
                this.description = "Create new 'Virtual Machine'.";
-               this.usage = "[-n | --name] test <[-b | --base] 1 | [-p | --path] path>";
+               this.usage = "Standard Image: create -n test -b 1 [options]\n" +
+                               "       Custom Image: create -n test -p path [options]\n" +
+                               "       You can not use both '-b' and '-p' at the same time.";
 
                property = VMPropertyValue.getDefault(true);
                commandList.add(new Command("n", Actions.OP_NAME,
@@ -358,7 +360,7 @@ class Create extends Action {
                                "Select enable or disable hardware GL acceleration.(yes | no)",
                                property.isGLAcceleration ? "yes" : "no", false, true));
                commandList.add(new Command("t", Actions.OP_MAXTOUCH,
-                               "Set count of multi touch point.(1 or 2)", Integer.toString(property.maxTouchCount), false, true));
+                               "Set count of multi touch point.(1 ~ 3)", Integer.toString(property.maxTouchCount), false, true));
                commandList.add(new AddOptions("a", Actions.OP_ADDOPTION,
                                "Add other qemu's options.", "", false, true));
        }
@@ -374,7 +376,7 @@ class Modify extends Action {
        public Modify() {
                this.action     = Actions.AC_MODIFY;
                this.description = "Modify configuration of selected 'Virtual Machine'.";
-               this.usage = "[-n | --name] test <options>";
+               this.usage = "modify -n test [options]";
 
                property = VMPropertyValue.getDefault(true);
                commandList.add(new Command("n", Actions.OP_NAME,
@@ -430,7 +432,7 @@ class Launch extends Action {
        public Launch() {
                this.action     = Actions.AC_LAUNCH;
                this.description = "Start emulator using selected VM.";
-               this.usage = "[-n | --name] test";
+               this.usage = "launch -n test [options]";
 
                commandList.add(new Command("n", Actions.OP_NAME,
                                "Name of VM to start.","", true, true)); 
@@ -476,56 +478,7 @@ class Launch extends Action {
                }
 
                ConsoleProcessor processor = new ConsoleProcessor();
-               VMsProperty prop = processor.getProperty(name);
-
-               if(prop == null) {
-                       System.out.println("Error: There is no Virtual Machine named " + name);
-                       return false;
-               }
-
-               if (path != null) {
-                       try {
-                               File f = new File(path).getCanonicalFile();
-                               if (!f.exists()) {
-                                       System.out.println("Error : \""+ f.getAbsolutePath() + "\" is not exists.");
-                                       return false;
-                               }
-                               path = f.getAbsolutePath();
-                       } catch (IOException e) {
-                               System.out.println("Error: " + e.getMessage());
-                               return false;
-                       }
-               }
-
-               Launcher launcher = new Launcher();
-               List<String> cmd = launcher.getLaunchCommand(prop, path);
-
-               if (isTest && EMLogger.getLogger().getLevel() == Level.WARNING) {
-                       System.out.println("Arguments of emulator : ");
-                       String temp = cmd.get(0) + " ";
-                       for (String s : cmd.subList(1, cmd.size())) {
-                               temp += ("\"" + s + "\" ");
-                       }
-                       System.out.println(temp);
-                       System.out.println();
-               }
-
-               if (!isTest) {
-                       if(prop.getWorker().isRunningNow()) {
-                               System.out.println("Error: Can not execute this VM.\n" +
-                                               "The same name is running now.");
-                               return false;
-                       }
-
-                       if (launcher.launch(cmd)) {
-                               System.out.println("Success to start emulator.");
-                       } else {
-                               System.out.println("Error: Faile to start emulator.");
-                               return false;
-                       }
-               }
-
-               return true;
+               return processor.launchEmulator(name, path, isTest);
        }
 }
 
@@ -533,7 +486,7 @@ class Delete extends Action {
        public Delete() {
                this.action     = Actions.AC_DELETE;
                this.description = "Delete selected VM.";
-               this.usage = "[-n | --name] test";
+               this.usage = "delete -n test";
 
                commandList.add(new Command("n", Actions.OP_NAME,
                                "Name of VM to delete.","", true, true)); 
@@ -553,28 +506,7 @@ class Delete extends Action {
                }
 
                ConsoleProcessor processor = new ConsoleProcessor();
-               VMsProperty prop = processor.getProperty(name);
-
-               if(prop == null) {
-                       System.out.println("Error: There is no Virtual Machine named " + name);
-                       return false;
-               }
-
-               if(prop.getWorker().isRunningNow()) {
-                       System.out.println("Error: Canceled delete process!\n"
-                                       + "[" + name + "] is running now...");
-                       return false;
-               }
-
-               try {
-                       prop.getWorker().deleteVM();
-               } catch (VMsWorkerException e) {
-                       System.out.println("Error: " + e.getMessage());
-                       return false;
-               }
-
-               System.out.println("Completed delete process!");
-               return true;
+               return processor.deleteVM(name);
        }
 }
 
@@ -582,7 +514,7 @@ class Reset extends Action {
        public Reset() {
                this.action     = Actions.AC_RESET;
                this.description = "Reset selected VM. VM's child image will be formatted.";
-               this.usage = "[-n | --name] test";
+               this.usage = "reset -n test";
 
                commandList.add(new Command("n", Actions.OP_NAME,
                                "Name of VM to reset image.","", true, true)); 
@@ -602,28 +534,7 @@ class Reset extends Action {
                }
 
                ConsoleProcessor processor = new ConsoleProcessor();
-               VMsProperty prop = processor.getProperty(name);
-
-               if(prop == null) {
-                       System.out.println("Error: There is no Virtual Machine named " + name);
-                       return false;
-               }
-
-               if(prop.getWorker().isRunningNow()) {
-                       System.out.println("Error: Canceled reset process!\n"
-                                       + "[" + name + "] is running now...");
-                       return false;
-               }
-
-               try {
-                       prop.getWorker().resetVM();
-               } catch (VMsWorkerException e) {
-                       System.out.println("Error: " + e.getMessage());
-                       return false;
-               }
-
-               System.out.println("Completed reset process!");
-               return true;
+               return processor.resetVM(name);
        }
 }
 
@@ -631,7 +542,7 @@ class CreateBaseImage extends Action {
        public CreateBaseImage() {
                this.action     = Actions.AC_CREATE_IMAGE;
                this.description = "Create base target image using VM's child image.";
-               this.usage = "[-n | --name] test";
+               this.usage = "create-image -n test [options]";
 
                commandList.add(new Command("n", Actions.OP_NAME,
                                "Name of VM to create base target image.","", true, true));
@@ -661,33 +572,7 @@ class CreateBaseImage extends Action {
                }
 
                ConsoleProcessor processor = new ConsoleProcessor();
-               VMsProperty prop = processor.getProperty(name);
-
-               if(prop == null) {
-                       System.out.println("Error: There is no Virtual Machine named " + name);
-                       return false;
-               }
-
-               if(prop.getWorker().isRunningNow()) {
-                       System.out.println("Error: Canceled 'Create Base Image' process!\n"
-                                       + "[" + name + "] is running now...");
-                       return false;
-               }
-
-               // Check path
-               if (new File(path).exists()) {
-                       System.out.println("Error: This directory does not exist. (Path : " + path + ")");
-               }
-
-               try {
-                       prop.getWorker().createNewBaseImage(prop, path);
-               } catch (VMsWorkerException e) {
-                       System.out.println("Error: " + e.getMessage());
-                       return false;
-               }
-
-               System.out.println("Succeeded to create 'Base Image'!\nPath: " + path);
-               return true;
+               return processor.createBaseIamge(name, path);
        }
 }
 
@@ -695,7 +580,7 @@ class Clone extends Action {
        public Clone() {
                this.action     = Actions.AC_COLONE;
                this.description = "Clone new VM which has the same configurations ad you selected..";
-               this.usage = "[-n | --name] test [-t | --target-name] target";
+               this.usage = "clone -n test -t target";
 
                commandList.add(new Command("n", Actions.OP_NAME,
                                "Name of VM to create base target image.","", true, true));
@@ -720,27 +605,6 @@ class Clone extends Action {
                }
 
                ConsoleProcessor processor = new ConsoleProcessor();
-               VMsProperty prop = processor.getProperty(name);
-
-               if(prop == null) {
-                       System.out.println("Error: There is no Virtual Machine named " + name);
-                       return false;
-               }
-
-               VMCreateHelper helper = new VMCreateHelper();
-               if (helper.checkDupulicateName(target)) {
-                       System.out.println("Error: The target name (" + target + ") already exists!");
-                       return false;
-               }
-
-               try {
-                       prop.getWorker().cloneVM(target);
-               } catch (VMsWorkerException e) {
-                       System.out.println("Error: " + e.getMessage());
-                       return false;
-               }
-
-               System.out.println("Emulator cloning completed!");
-               return true;
+               return processor.cloneVM(name, target);
        }
 }
\ No newline at end of file
@@ -34,11 +34,11 @@ import java.util.logging.Level;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
 
-public class CommandLineProcessor {
+public class CommandLineParser {
        private ActionList actionList = null;
        private Action mAction = null;
 
-       public CommandLineProcessor() {
+       public CommandLineParser() {
                actionList = new ActionList();
        }
 
index 779b67b..748e42a 100644 (file)
 
 package org.tizen.emulator.manager.console;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
 
 import org.tizen.emulator.manager.image.BaseImage;
 import org.tizen.emulator.manager.image.EmulatorImages;
+import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.About;
 import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.Launcher;
+import org.tizen.emulator.manager.vms.VMCreateHelper;
 import org.tizen.emulator.manager.vms.VMsProperty;
+import org.tizen.emulator.manager.vms.VMsWorkerException;
 import org.tizen.emulator.manager.vms.VMsProperty.FSImageType;
 
 public class ConsoleProcessor {
        private EmulatorVMs vms = EmulatorVMs.getInstance();
 
+       public VMsProperty getProperty(String value) {
+               return vms.getProperty(value);
+       }
+
        public String getAboutInfo() {
                return "Emulator Manager\n"+
                                About.getInstance().getContents();
@@ -94,31 +106,6 @@ public class ConsoleProcessor {
                }
        }
 
-       @SuppressWarnings("finally")
-       public String getInfoOfVM(VMsProperty prop) {
-               String str = new String();
-               try {
-                       str += String.format("%s\n", prop.getName());
-                       str+= String.format("\t%-17s : %s\n", "ImageType",prop.getImageType());
-                       if (prop.getImageType() == FSImageType.standard) {
-                               str+= String.format("\t%-17s : %s\n", "Version" ,
-                                                                       prop.getConfiguration().getBaseInformation().getDiskImage().getVersion());
-                       }
-
-                       str+= String.format("\t%-17s : %s\n", "Resolution",
-                                       (prop.getConfiguration().getDevice().getDisplay().getResolution().getWidth()
-                                       + "x" + prop.getConfiguration().getDevice().getDisplay().getResolution().getHeight()));
-                       
-                       str+= String.format("\t%-17s : %s\n", "DPI",
-                                       prop.getConfiguration().getDevice().getDisplay().getDensity().getValue());
-                       str+= String.format("\t%-17s : %s\n", "RAM Size",
-                                       prop.getConfiguration().getDevice().getRAM().getSize().getValue());
-               } catch (Exception e) { 
-               } finally {
-                       return str;
-               }
-       }
-
        public String getDetailInfoOfVM(String value) {
                VMsProperty prop = vms.getProperty(value);
                if (prop == null) {
@@ -129,10 +116,6 @@ public class ConsoleProcessor {
                }
        }
 
-       public VMsProperty getProperty(String value) {
-               return vms.getProperty(value);
-       }
-
        public ArrayList<String> getInfoOfVMList(boolean isDetail) {
                ArrayList<String> message = new ArrayList<String>();
                VMsProperty[] properties = (VMsProperty[])vms.getProperties();
@@ -168,5 +151,163 @@ public class ConsoleProcessor {
                }
                return list;
        }
+
+       public boolean launchEmulator(String name, String path, boolean isTest) {
+               VMsProperty prop = getProperty(name);
+
+               if(prop == null) {
+                       System.out.println("Error: There is no Virtual Machine named " + name);
+                       return false;
+               }
+
+               if (path != null) {
+                       try {
+                               File f = new File(path).getCanonicalFile();
+                               if (!f.exists()) {
+                                       System.out.println("Error : \""+ f.getAbsolutePath() + "\" is not exists.");
+                                       return false;
+                               }
+                               path = f.getAbsolutePath();
+                       } catch (IOException e) {
+                               System.out.println("Error: " + e.getMessage());
+                               return false;
+                       }
+               }
+
+               Launcher launcher = new Launcher();
+               List<String> cmd = launcher.getLaunchCommand(prop, path);
+
+               if (isTest && EMLogger.getLogger().getLevel() == Level.WARNING) {
+                       System.out.println("Arguments of emulator : ");
+                       String temp = cmd.get(0) + " ";
+                       for (String s : cmd.subList(1, cmd.size())) {
+                               temp += ("\"" + s + "\" ");
+                       }
+                       System.out.println(temp);
+                       System.out.println();
+               }
+
+               if (!isTest) {
+                       if(prop.getWorker().isRunningNow()) {
+                               System.out.println("Error: Can not execute this VM.\n" +
+                                               "The same name is running now.");
+                               return false;
+                       }
+
+                       if (launcher.launch(cmd)) {
+                               System.out.println("Success to start emulator.");
+                       } else {
+                               System.out.println("Error: Faile to start emulator.");
+                               return false;
+                       }
+               }
+
+               return true;
+       }
+
+       public boolean deleteVM(String name) {
+               VMsProperty prop = getProperty(name);
+
+               if(prop == null) {
+                       System.out.println("Error: There is no Virtual Machine named " + name);
+                       return false;
+               }
+
+               if(prop.getWorker().isRunningNow()) {
+                       System.out.println("Error: Canceled delete process!\n"
+                                       + "[" + name + "] is running now...");
+                       return false;
+               }
+
+               try {
+                       prop.getWorker().deleteVM();
+               } catch (VMsWorkerException e) {
+                       System.out.println("Error: " + e.getMessage());
+                       return false;
+               }
+
+               System.out.println("Completed delete process!");
+               return true;
+       }
+
+       public boolean resetVM(String name) {
+               VMsProperty prop = getProperty(name);
+
+               if(prop == null) {
+                       System.out.println("Error: There is no Virtual Machine named " + name);
+                       return false;
+               }
+
+               if(prop.getWorker().isRunningNow()) {
+                       System.out.println("Error: Canceled reset process!\n"
+                                       + "[" + name + "] is running now...");
+                       return false;
+               }
+
+               try {
+                       prop.getWorker().resetVM();
+               } catch (VMsWorkerException e) {
+                       System.out.println("Error: " + e.getMessage());
+                       return false;
+               }
+
+               System.out.println("Completed reset process!");
+               return true;
+       }
+
+       public boolean createBaseIamge(String name, String path) {
+               VMsProperty prop = getProperty(name);
+
+               if(prop == null) {
+                       System.out.println("Error: There is no Virtual Machine named " + name);
+                       return false;
+               }
+
+               if(prop.getWorker().isRunningNow()) {
+                       System.out.println("Error: Canceled 'Create Base Image' process!\n"
+                                       + "[" + name + "] is running now...");
+                       return false;
+               }
+
+               // Check path
+               if (new File(path).exists()) {
+                       System.out.println("Error: This directory does not exist. (Path : " + path + ")");
+               }
+
+               try {
+                       prop.getWorker().createNewBaseImage(prop, path);
+               } catch (VMsWorkerException e) {
+                       System.out.println("Error: " + e.getMessage());
+                       return false;
+               }
+
+               System.out.println("Succeeded to create 'Base Image'!\nPath: " + path);
+               return true;
+       }
+
+       public boolean cloneVM(String name, String target) {
+               VMsProperty prop = getProperty(name);
+
+               if(prop == null) {
+                       System.out.println("Error: There is no Virtual Machine named " + name);
+                       return false;
+               }
+
+               VMCreateHelper helper = new VMCreateHelper();
+               if (helper.checkDupulicateName(target)) {
+                       System.out.println("Error: The target name (" + target + ") already exists!");
+                       return false;
+               }
+
+               try {
+                       prop.getWorker().cloneVM(target);
+               } catch (VMsWorkerException e) {
+                       System.out.println("Error: " + e.getMessage());
+                       return false;
+               }
+
+               System.out.println("Emulator cloning completed!");
+               return true;
+       }
 }
 
index e33ce60..ae4bc3d 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.vms;
 
 import java.io.BufferedReader;
index 1ddd2d6..e95a5ef 100644 (file)
@@ -82,10 +82,6 @@ public class VMsWorker {
                        throw new VMsWorkerException("Failed to create base image!\nFile does not exist :" + childImage);
                }
 
-               //long childSize = childImage.length();
-               //long baseSize = baseImage.length();
-               //final long maxSize = childSize + baseSize;
-
                String exe_path = FileIO.getInstance().getBinPath() + File.separator + "qemu-img";
 
                List<String> cmd = new ArrayList<String>();
@@ -98,28 +94,31 @@ public class VMsWorker {
                final QemuImgProc proc = new QemuImgProc(cmd);
 
                /*
+               long childSize = childImage.length();
+               long baseSize = baseImage.length();
+               final long maxSize = childSize + baseSize;
                final File destFile = new File(dest);
                final CreateBaseImageDialog dialog
-                       = new CreateBaseImageDialog(EmulatorManager.getInstance().getMainDialog().getShell());
+               = new CreateBaseImageDialog(EmulatorManager.getInstance().getMainDialog().getShell());
                dialog.Open(destFile, maxSize);
                */
 
-               
+
                workerThread worker = new workerThread(proc);
                worker.start();
                synchronized(worker) {
-               try {
-                       worker.wait(2000);
-               } catch (InterruptedException e) {
-                       e.printStackTrace();
-               } finally {
-                       if (worker.isError()) {
-                               throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n"
-                                               + "You can get more information in log file ("
-                                               + FileIO.getInstance().getTizenVmsArchPath() +  File.separator + "emulator-manager)");
+                       try {
+                               worker.wait(3000);
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       } finally {
+                               if (worker.isError()) {
+                                       throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n"
+                                                       + "You can get more information in log file ("
+                                                       + FileIO.getInstance().getTizenVmsArchPath() +  File.separator + "emulator-manager)");
+                               }
                        }
                }
-               }
 
                /*
                if (! proc.Running()) {
@@ -280,7 +279,7 @@ class CreateBaseImageDialog {
                info.setText("Wait....while creating base image.\n"
                                        + "This task can take about 30 ~ 60 seconds");
                info.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
-               
+
                bar = new ProgressBar(dialog, SWT.SMOOTH);
                bar.setBounds(10, 10, 200, 32);
                bar.setMaximum(100);
@@ -290,28 +289,24 @@ class CreateBaseImageDialog {
                        public void handleEvent(Event event) {
                                // Empty
                        }
-                       
+
                });
                dialog.addMouseListener(new MouseListener(){
 
                        @Override
                        public void mouseDoubleClick(MouseEvent e) {
                                // TODO Auto-generated method stub
-                               
                        }
 
                        @Override
                        public void mouseDown(MouseEvent e) {
                                // TODO Auto-generated method stub
-                               
                        }
 
                        @Override
                        public void mouseUp(MouseEvent e) {
                                // TODO Auto-generated method stub
-                               
                        }
-                       
                });
        }
 
@@ -320,23 +315,6 @@ class CreateBaseImageDialog {
        }
        public void Open(final File destFile, final long maxSize) {
                dialog.open();
-
-               new Thread(new Runnable() {
-                       public void run() {
-                               int i = 0;
-                               while(i != 100 && !dialog.isDisposed()) {
-                                       try {
-                                               Thread.sleep(500);
-                                       } catch (InterruptedException e) {
-                                               e.printStackTrace();
-                                               break;
-                                       }
-                                       i = (int)((destFile.length() / maxSize) * 100.0);
-                                       setSelection(i);
-                               }
-                       }
-               }).start();
-
        }
 
        public void Close() {