option: Refactoring option list
authorminkee.lee <minkee.lee@samsung.com>
Mon, 22 Jun 2015 14:11:37 +0000 (23:11 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Mon, 22 Jun 2015 14:43:29 +0000 (23:43 +0900)
- add option to list instead of return option.
- HWSupport option is devided to gpu, cpu option.

Change-Id: If4709b8df21c502253da891bb579e9544d04aeb4
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
src/org/tizen/emulator/manager/vms/option/CPUSupportOption.java [new file with mode: 0644]
src/org/tizen/emulator/manager/vms/option/CommonOptionFactroy.java
src/org/tizen/emulator/manager/vms/option/GPUSupportOption.java [moved from src/org/tizen/emulator/manager/vms/option/HWSupportOption.java with 86% similarity]

diff --git a/src/org/tizen/emulator/manager/vms/option/CPUSupportOption.java b/src/org/tizen/emulator/manager/vms/option/CPUSupportOption.java
new file mode 100644 (file)
index 0000000..b341c7f
--- /dev/null
@@ -0,0 +1,51 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@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.option;
+
+import org.tizen.emulator.manager.job.CheckVT;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public class CPUSupportOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMLauncherException {
+               String hwVirtualization = "";
+               if (property.getConfiguration().getUsability().isHwVirtualization()) {
+                       hwVirtualization = CheckVT.getVTEnablingCommand();
+               } else {
+                       // do nothing...
+               }
+               if (hwVirtualization != null) {
+                       config.addQemuOption(hwVirtualization);
+               }
+       }
+}
index c57e352..1a2f0fa 100644 (file)
@@ -40,27 +40,72 @@ import org.tizen.emulator.manager.vms.xml.template.PropertyList;
 
 public abstract class CommonOptionFactroy implements IOptionFactory {
        // Override if need.
-       public void makeCommonOptionList(List<IOption> list, ItemList itemTemplate) {
+       public void makeCommonOptionList(List<IOption> optionList, ItemList itemTemplate) {
                PropertyList propertyList = itemTemplate.getPropertyList();
                DeviceList deviceList = itemTemplate.getDeviceList();
 
-               IOption option;
                for (Item item : propertyList.getItem()) {
-                       option = findProeprtyOption(item);
-                       if (option != null) {
-                               list.add(option);
-                       }
+                       addPropertyOption(item, optionList);
                }
 
                for (Item item : deviceList.getItem()) {
-                       option = findDeviceOption(item);
-                       if (option != null) {
-                               list.add(option);
-                       }
+                       addDeviceOption(item, optionList);
+               }
+       }
+
+       // Plugin developer can override this if needed
+       public void addPropertyOption(Item item, List<IOption> list) {
+               if (item == null) {
+                       return;
+               }
+               String name = item.getName();
+               if (name.equals(ItemName.VM_NAME)) {
+                       list.add(Option.getInstance(VMNameOption.class));
+
+               } else if (name.equals(ItemName.BASE_IMAGE)) {
+                       list.add(Option.getInstance(BaseImageOption.class));
+
+               } else if (name.equals(ItemName.DISPLAY)) {
+                       list.add(Option.getInstance(DisplayOption.class));
+
+               } else if (name.equals(ItemName.PROCESSORS)) {
+                       list.add(Option.getInstance(ProcessorOption.class));
+
+               } else if (name.equals(ItemName.RAM_SIZE)) {
+                       list.add(Option.getInstance(RamSizeOption.class));;
+
+               } else if (name.equals(ItemName.SUSPEND_SUPPORT)) {
+                       list.add(Option.getInstance(SuspendSupportOption.class));
+
+               } else if (name.equals(ItemName.FILE_SHARE)) {
+                       list.add(Option.getInstance(FileShareOption.class));
+
+               } else if (name.equals(ItemName.HW_SUPPORT)) {
+                       list.add(Option.getInstance(CPUSupportOption.class));
+                       list.add(Option.getInstance(GPUSupportOption.class));
+               }
+       }
+
+       // Plugin developer can override this if needed
+       public void addDeviceOption(Item item, List<IOption> list) {
+               if (item == null) {
+                       return;
+               }
+               String name = item.getName();
+
+               if (name.equals(ItemName.NET_CONFIG)) {
+                       list.add(Option.getInstance(NetworkOption.class));
+
+               } else if (name.equals(ItemName.NET_PROXY)) {
+                       list.add(Option.getInstance(NetProxyOption.class));
+
+               } else if (name.equals(ItemName.CAMERA)) {
+                       list.add(Option.getInstance(CameraOption.class));
                }
        }
 
        // Override if need
+       @Deprecated
        public IOption findProeprtyOption(Item item) {
                if (item == null) {
                        return null;
@@ -88,7 +133,7 @@ public abstract class CommonOptionFactroy implements IOptionFactory {
                        return Option.getInstance(FileShareOption.class);
 
                } else if (name.equals(ItemName.HW_SUPPORT)) {
-                       return Option.getInstance(HWSupportOption.class);
+//                     return Option.getInstance(HWSupportOption.class);
 
                }
 
@@ -96,6 +141,7 @@ public abstract class CommonOptionFactroy implements IOptionFactory {
        }
 
        // Override if need
+       @Deprecated
        public IOption findDeviceOption(Item item) {
                if (item == null) {
                        return null;
  *
  */
 
+
 package org.tizen.emulator.manager.vms.option;
 
 import org.eclipse.swt.SWT;
 import org.tizen.emulator.manager.job.CheckGPU;
-import org.tizen.emulator.manager.job.CheckVT;
 import org.tizen.emulator.manager.ui.dialog.MessageDialog;
 import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.helper.VMLauncherException;
 
-public class HWSupportOption extends Option {
+public class GPUSupportOption extends Option {
 
        @Override
        public void getLaunchArgument(LaunchConfig config, VMProperty property)
                        throws VMLauncherException {
-               // Set CPU option
-               String hwVirtualization = "";
-               if (property.getConfiguration().getUsability().isHwVirtualization()) {
-                       hwVirtualization = CheckVT.getVTEnablingCommand();
-               } else {
-                       // do nothing...
-               }
-               if (hwVirtualization != null) {
-                       config.addQemuOption(hwVirtualization);
-               }
-
-               // Set GPU option
                if (property.getConfiguration().getUsability().isHwGLAcceleration()) {
                        config.addQemuOption("-device", "vigs,backend=gl,wsi=vigs_wsi");
                        config.addQemuOption("-device", "yagl,wsi=vigs_wsi");
@@ -83,5 +71,4 @@ public class HWSupportOption extends Option {
                        }
                }
        }
-
-}
+}
\ No newline at end of file