[Title] added mode feature
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 2 Apr 2012 08:11:46 +0000 (17:11 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Mon, 2 Apr 2012 08:11:46 +0000 (17:11 +0900)
[Type]
[Module] Emulator Manager
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/ui/MainDialog.java

index 30b32d6..b8d162f 100644 (file)
@@ -3,6 +3,7 @@ package org.tizen.emulator.manager;
 import java.io.File;
 import java.io.RandomAccessFile;
 import java.nio.channels.FileLock;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.MessageBox;
@@ -14,13 +15,44 @@ import org.tizen.emulator.manager.vms.EmulatorVMs;
 public class EmulatorManager {
        private static EmulatorManager instance;
 
+       public enum ManagerModeType {
+               PUBLIC_MODE("public"),
+               INHOUSE_MODE("inhouse");
+
+               private final String value;
+
+               ManagerModeType(String v) {
+                       value = v;
+               }
+
+               public String value() {
+                       return value;
+               }
+
+               public static ManagerModeType fromValue(String v) {
+                       for (ManagerModeType c : ManagerModeType.values()) {
+                               if (c.value.equals(v)) {
+                                       return c;
+                               }
+                       }
+                       throw new IllegalArgumentException(v);
+               }
+
+       }
+
+       private ManagerModeType mode;
        Display display;
        private MainDialog mainDialog;
 
-       public EmulatorManager() {
+       public EmulatorManager(ManagerModeType mode) {
+               this.mode = mode;
                this.display = new Display();
        }
 
+       public ManagerModeType getManagerMode() {
+               return mode;
+       }
+
        public static EmulatorManager getInstance() {
                return instance;
        }
@@ -31,7 +63,7 @@ public class EmulatorManager {
 
        private void preare() {
                
-               mainDialog = new MainDialog();
+               mainDialog = new MainDialog(mode);
        }
 
        private void DrawUI() {
@@ -46,23 +78,18 @@ public class EmulatorManager {
        }
        
        public static void main(String[] args) {
-               instance = new EmulatorManager();
+               int result = 0; //TODO: enum
+               ManagerModeType mode = ManagerModeType.PUBLIC_MODE;
                
                if(args.length > 0) {
                        for(int i = 0; i < args.length; i++) {
                                if(args[i].equals("--workspace") || args[i].equals("-w")) {
                                        if(args.length == i + 1) {
-                                               Shell shell = new Shell(instance.display);
-                                               MessageBox msg = new MessageBox(shell, SWT.ICON_INFORMATION);
-                                               msg.setText("INFO");
-                                               msg.setMessage("You did not input workspace path after\n" +
-                                                               "command line option --workspace or -w\n" +
-                                                               "Emulator Manager sets in default workspace.");
-                                               msg.open();
-                                               break;
+                                               result = -1; //TODO: enum
                                        }
                                        EmulatorVMs.getInstance().setVMsBaseDirectory(args[i+1]);
-                                       break;
+                               } else if (args[i].equals("--inhouse")) {
+                                       mode = ManagerModeType.INHOUSE_MODE;
                                }
                        }
                }
@@ -70,6 +97,18 @@ public class EmulatorManager {
                        EmulatorVMs.getInstance().setVMsBaseDirectory(FileIO.getInstance().getTizenVmsPath());
                }
 
+               instance = new EmulatorManager(mode);
+
+               if (result == -1) {
+                       Shell shell = new Shell(instance.display);
+                       MessageBox msg = new MessageBox(shell, SWT.ICON_INFORMATION);
+                       msg.setText("INFO");
+                       msg.setMessage("You did not input workspace path after\n" +
+                                       "command line option --workspace or -w\n" +
+                                       "Emulator Manager sets in default workspace.");
+                       msg.open();
+               }
+
                try {
                        EmulatorVMs.getInstance().loadProperties();
                } catch (Exception e) {
index 9c736e0..b3417ed 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
 import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
 import org.tizen.emulator.manager.ui.detail.DetailTableView;
 import org.tizen.emulator.manager.ui.vmstree.VMsTree;
@@ -52,11 +53,15 @@ public class MainDialog {
        Shell shell;
        Image icon;
 
-       public MainDialog() {
+       public MainDialog(ManagerModeType mode) {
                shell = new Shell(Display.getCurrent());
 
                shell.setSize(700, 500);
-               shell.setText("Emulator Manager");
+               if (mode.equals(ManagerModeType.INHOUSE_MODE)) {
+                       shell.setText("Emulator Manager (Inhouse)");
+               } else {
+                       shell.setText("Emulator Manager");
+               }
                shell.setLayout(new FillLayout());
 
                InputStream is = this.getClass().getClassLoader().getResourceAsStream(ICON_FILE_NAME);