vm-modify: add camera item
authorminkee.lee <minkee.lee@samsung.com>
Mon, 23 Nov 2015 07:32:24 +0000 (16:32 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Mon, 23 Nov 2015 08:05:09 +0000 (17:05 +0900)
Change-Id: I48565d120a3444a172ffea0d6c5425fb191818d9
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
36 files changed:
resource/renewal/res/icon_title_camera.png [new file with mode: 0644]
resource/renewal/res/icon_title_connectivity.png [new file with mode: 0644]
src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java
src/org/tizen/emulator/manager/platform/BaseImage.java
src/org/tizen/emulator/manager/renewal/resources/ImageResources.java
src/org/tizen/emulator/manager/template/renewal/VMTemplateUtil.java
src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListComp.java
src/org/tizen/emulator/manager/ui/renewal/dialog/VMModifyDialog.java
src/org/tizen/emulator/manager/ui/renewal/item/CommonItemListFactory.java
src/org/tizen/emulator/manager/ui/renewal/item/CommonOptionFactory.java
src/org/tizen/emulator/manager/ui/renewal/item/ItemName.java
src/org/tizen/emulator/manager/ui/renewal/item/OptionName.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/FileDialogItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/AdvancedPropertyViewer.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraImageItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraLegacyItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraTypeItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CategoryItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/FileSharingItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetConnectTypeItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetworkItem.java
src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java
src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java
src/org/tizen/emulator/manager/vms/VMPropertyValue.java
src/org/tizen/emulator/manager/vms/option/CameraLegacyOption.java [new file with mode: 0644]
xsd/x86-standard-template-v2.xml

diff --git a/resource/renewal/res/icon_title_camera.png b/resource/renewal/res/icon_title_camera.png
new file mode 100644 (file)
index 0000000..f5026b3
Binary files /dev/null and b/resource/renewal/res/icon_title_camera.png differ
diff --git a/resource/renewal/res/icon_title_connectivity.png b/resource/renewal/res/icon_title_connectivity.png
new file mode 100644 (file)
index 0000000..f0448cf
Binary files /dev/null and b/resource/renewal/res/icon_title_connectivity.png differ
index 12b448a..5b10d60 100644 (file)
@@ -35,6 +35,7 @@ import java.util.List;
 
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.vms.RESOLUTION;
 import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 
@@ -428,4 +429,17 @@ public class DeviceTemplateValue implements Cloneable {
 
                return true;
        }
+
+       public boolean isRearCameraSupport() {
+               SubDevice camera = findSubDevice(ItemName.CAMERA);
+               if (camera == null) {
+                       return false;
+               }
+               SubDeviceItem rearCameraItem = findSubDeviceItem(camera, ItemName.CAMERA_REAR);
+               if (rearCameraItem == null) {
+                       return false;
+               }
+
+               return rearCameraItem.isSupport();
+       }
 }
index c53345f..752a490 100644 (file)
@@ -515,7 +515,7 @@ public class BaseImage {
                }
                if (f == null) {
                        f = new CommonItemListFactory();
-                       EMLogger.getLogger().warning("Fail to load ItemListFactory.");
+                       EMLogger.getLogger().warning("Fail to load ItemListFactory. Image : " + imageName);
                        EMLogger.getLogger().info("Use CommonItemListFactory.");
                }
                defaultItemList = f.makeDefaultItemList(template);
index 7b0a5f5..20934fb 100644 (file)
@@ -275,6 +275,8 @@ public enum ImageResources {
        ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"),
        ICON_TITLE_TREE_CLOSED("icon_title_tree_closed"),
        ICON_TITILE_DESCRIPTION("icon_title_description"),
+       ICON_TITLE_CAMERA("icon_title_camera"),
+       ICON_TITLE_CONNECTIVITY("icon_title_connectivity"),
        ICON_BLUE_BUTTON_OPEN("icon_blue_btn_open"),
        ICON_BLUE_BUTTON_PLUS("icon_blue_btn_plus"),
        ICON_BLUE_BUTTON_CLOSE("icon_blue_btn_close"),
index 7a8320c..e3a3a42 100644 (file)
@@ -39,11 +39,8 @@ import java.util.Map;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.ui.detail.item.OptionType;
 import org.tizen.emulator.manager.ui.renewal.item.ItemName;
-import org.tizen.emulator.manager.ui.renewal.item.ItemType;
 import org.tizen.emulator.manager.ui.renewal.item.OptionName;
-import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ConnectivityItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
@@ -75,6 +72,21 @@ public class VMTemplateUtil {
                return itemList;
        }
 
+       public static int getNumColomnOption(VMItem item) {
+               int numColumn = 3; // default;
+               for (VMItemOption opt : item.getOptions()) {
+                       if (opt.getName().equals(OptionName.NUM_COLUMN)) {
+                               try {
+                                       numColumn = Integer.parseInt(opt.getValue());
+                               } catch (NumberFormatException e) {
+                                       EMLogger.getLogger().warning(e.getMessage());
+                               }
+                               break;
+                       }
+               }
+               return numColumn;
+       }
+
 
        public static VMItemGroup getDefaultItemGroup(VMTemplate template) {
                for (VMItemGroup group : template.getVmItemGroups()) {
@@ -142,13 +154,13 @@ public class VMTemplateUtil {
                        }
 
                        // check item type
-                       if (type.equals(ItemType.CHECK_LABEL)) {
-                               dialogItem = new CheckBoxItem(name, title, getCheckBoxNumColumn(item),
-                                               null, getCheckBoxDataList(item));
-                       }
-                       if (dialogItem != null) {
-                               itemList.add(dialogItem);
-                       }
+//                     if (type.equals(ItemType.CHECK_LABEL)) {
+//                             dialogItem = new CheckBoxItem(name, title, getCheckBoxNumColumn(item),
+//                                             null, getCheckBoxDataList(item));
+//                     }
+//                     if (dialogItem != null) {
+//                             itemList.add(dialogItem);
+//                     }
                }
        }
 
@@ -271,8 +283,8 @@ public class VMTemplateUtil {
        public static boolean checkExperimentalItem(VMItem item) {
                boolean isExperimentalItem = false;
                for (VMItemOption opt : item.getOptions()) {
-                       if (opt.getName().equals(OptionType.EXPERIMENTAL.getName())) {
-                               if (opt.getValue().equals(OptionType.VALUE_TRUE)) {
+                       if (opt.getName().equals(OptionName.EXPERIMENTAL)) {
+                               if (opt.getValue().equals(OptionName.VALUE_TRUE)) {
                                        isExperimentalItem = true;
                                }
                        }
@@ -284,17 +296,17 @@ public class VMTemplateUtil {
        public static boolean isSupportOS(VMItem item) {
                boolean isSupportOS = true;
                for (VMItemOption opt : item.getOptions()) {
-                       if (opt.getName().equals(OptionType.SUPPORT_OS.getName())) {
+                       if (opt.getName().equals(OptionName.SUPPORT_OS)) {
                                List<String> osList = Arrays.asList(opt.getValue().trim().
                                                split(StringResources.REG_EXP_SPLIT_COMMA));
 
-                               if (EmulatorManager.isWin() && !osList.contains(OptionType.WIN)) {
+                               if (EmulatorManager.isWin() && !osList.contains(OptionName.WIN)) {
                                        isSupportOS = false;
                                }
-                               if (EmulatorManager.isLinux() && !osList.contains(OptionType.LINUX)) {
+                               if (EmulatorManager.isLinux() && !osList.contains(OptionName.LINUX)) {
                                        isSupportOS = false;
                                }
-                               if (EmulatorManager.isMac() && !osList.contains(OptionType.MAC)) {
+                               if (EmulatorManager.isMac() && !osList.contains(OptionName.MAC)) {
                                        isSupportOS = false;
                                }
                        }
index ad10be7..ab63cbe 100644 (file)
@@ -191,6 +191,9 @@ public class ItemListComp {
                boolean isOKButtonEnable = true;
 
                for (ModifyDialogItem dialogItem : itemList) {
+                       if (!dialogItem.isUse()) {
+                               continue;
+                       }
                        if (!dialogItem.isValid()) {
                                isOKButtonEnable = false;
                        }
@@ -293,6 +296,8 @@ public class ItemListComp {
                        item.setInitialValue(propertyValue);
                }
                changeItemList(itemList, imageItems);
+               checkValid();
+
                layoutScrolledComposite();
 
 
index f7f8c86..6ffe6ff 100644 (file)
@@ -42,8 +42,8 @@ import org.tizen.emulator.manager.vms.VMPropertyValue;
 public class VMModifyDialog extends ModifyDialog {
 
        private final static String TITLE = "VM Modify";
-       public final static int WIDTH = 484;
-//     private final static int WIDTH = 500;
+//     public final static int WIDTH = 484;
+       public final static int WIDTH = 494;
 //     private final static int HEIGHT = 496;
        private final static int HEIGHT = 497;
 
index 462d936..1c3333f 100644 (file)
@@ -48,6 +48,10 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraImageItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraLegacyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraTypeItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CategoryItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceTemplateItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.FileSharingItem;
@@ -98,43 +102,55 @@ public class CommonItemListFactory implements IItemListFactory{
        }
 
 
-       public void addSubItems(List<VMItem> items, CategoryItem dialogItem) {
+       public void addSubItems(List<VMItem> items, CategoryItem categoryItem) {
                for (VMItem item : items) {
                        if (!VMTemplateUtil.checkItemAvailable(item)) {
                                continue;
                        }
-                       addSubItem(item, dialogItem);
+                       addSubItem(item, categoryItem);
                }
        }
 
 
-       public void addSubItem(VMItem item, CategoryItem dialogItem) {
+       public void addSubItem(VMItem item, CategoryItem categoryItem) {
                String name = item.getName();
                String title = item.getTitle();
 
                if (name.equals(ItemName.NET_PROXY)) {
-                       dialogItem.addSubItems(new NetProxyItem(VMTemplateUtil.getProxyItemMap(item.getOptions())));
+                       categoryItem.addSubItems(new NetProxyItem(VMTemplateUtil.getProxyItemMap(item.getOptions())));
 
                } else if (name.equals(ItemName.NET_CONNECT_TYPE)) {
-                       dialogItem.addSubItems(new NetConnectTypeItem(title,
+                       categoryItem.addSubItems(new NetConnectTypeItem(title,
                                        VMTemplateUtil.getOptionList(item.getOptions())));
 
                } else if (name.equals(ItemName.NET_TAP_DEVICE)) {
                        if (EmulatorManager.isWin()) {
-                               dialogItem.addSubItems(new NetTapDeviceItemForWin(title));
+                               categoryItem.addSubItems(new NetTapDeviceItemForWin(title));
 
                        } else {
-                               dialogItem.addSubItems(new NetTapDeviceItem(title));
+                               categoryItem.addSubItems(new NetTapDeviceItem(title));
                        }
 
                } else if (name.equals(ItemName.NET_IP_INFO)) {
-                       dialogItem.addSubItems(new NetIPInfoItem(title));
+                       categoryItem.addSubItems(new NetIPInfoItem(title));
 
                } else if (name.equals(ItemName.NET_DNS)) {
-                       dialogItem.addSubItems(new NetDnsItem(title));
+                       categoryItem.addSubItems(new NetDnsItem(title));
 
                } else if (name.equals(ItemName.NET_MAC)) {
-                       dialogItem.addSubItems(new NetMacItem(title));
+                       categoryItem.addSubItems(new NetMacItem(title));
+
+               } else if (name.equals(ItemName.CAMERA_TYPE_FRONT)) {
+                       categoryItem.addSubItems(new CameraTypeItem(name, title));
+
+               } else if (name.equals(ItemName.CAMERA_TYPE_REAR)) {
+                       categoryItem.addSubItems(new CameraTypeItem(name, title));
+
+               } else if (name.equals(ItemName.CAMERA_IMAGE_FRONT)) {
+                       categoryItem.addSubItems(new CameraImageItem(name, title));
+
+               } else if (name.equals(ItemName.CAMERA_IMAGE_REAR)) {
+                       categoryItem.addSubItems(new CameraImageItem(name, title));
                }
        }
 
@@ -152,6 +168,7 @@ public class CommonItemListFactory implements IItemListFactory{
 
                String name = item.getName();
                String title = item.getTitle();
+               String type = item.getType();
 
 
                if (name.equals(ItemName.NAME)) {
@@ -192,11 +209,19 @@ public class CommonItemListFactory implements IItemListFactory{
                        itemList.add(new HWSupportItem());
 
                } else if (name.equals(ItemName.NETWORK)) {
-                       CategoryItem categoryItem = new NetworkItem();
-                       itemList.add(categoryItem);
-                       addSubItems(item.getSubItems(), categoryItem);
+                       CategoryItem networkItem = new NetworkItem();
+                       itemList.add(networkItem);
+                       addSubItems(item.getSubItems(), networkItem);
+
+               } else if (name.equals(ItemName.CAMERA)) {
+                       CategoryItem cameraItem = new CameraItem(null, title);
+                       itemList.add(cameraItem);
+                       addSubItems(item.getSubItems(), cameraItem);
+
+               } else if (name.equals(ItemName.CAMERA_LEGACY)) {
+                       itemList.add(new CameraLegacyItem(name, title, VMTemplateUtil.getNumColomnOption(item),
+                                       treeRoot, VMTemplateUtil.getCheckBoxDataList(item)));
                }
-
        }
 
 
index 233ee5a..965b380 100644 (file)
@@ -37,6 +37,7 @@ import java.util.List;
 import org.tizen.emulator.manager.template.renewal.VMItem;
 import org.tizen.emulator.manager.vms.option.BaseImageOption;
 import org.tizen.emulator.manager.vms.option.CPUSupportOption;
+import org.tizen.emulator.manager.vms.option.CameraLegacyOption;
 import org.tizen.emulator.manager.vms.option.CommonOption;
 import org.tizen.emulator.manager.vms.option.ConnectivityOption;
 import org.tizen.emulator.manager.vms.option.DisplayModeOption;
@@ -132,16 +133,19 @@ public class CommonOptionFactory implements IOptionFactory {
                } else if (name.equals(ItemName.NET_PROXY)) {
                        optionList.add(Option.getInstance(NetProxyOption.class));
 
+               } else if (name.equals(ItemName.CAMERA_LEGACY)) {
+                       optionList.add(Option.getInstance(CameraLegacyOption.class));
+
                } else if (name.equals(ItemName.CAMERA)) {
                        // add sub options (rear camera, front camera)
                        if (item.getSubItems() != null) {
                                makeCommonOptionList(optionList, item.getSubItems());
                        }
 
-               } else if (name.equals(ItemName.CAMERA_REAR)) {
+               } else if (name.equals(ItemName.CAMERA_TYPE_REAR)) {
                        optionList.add(Option.getInstance(RearCameraOption.class));
 
-               } else if (name.equals(ItemName.CAMERA_FRONT)) {
+               } else if (name.equals(ItemName.CAMERA_TYPE_FRONT)) {
                        optionList.add(Option.getInstance(FrontCameraOption.class));
 
                } else if (name.equals(ItemName.SENSOR)) {
index 8bc0a51..c1e92d9 100644 (file)
@@ -50,11 +50,15 @@ public class ItemName {
 
        public static final String CONNECTIVITY = "connectivity";
        public static final String SENSOR = "sensor"; //$NON-NLS-1$
-       public static final String DEVICE = "device"; //$NON-NLS-1$
+       public static final String DEVICES = "devices"; //$NON-NLS-1$
        public static final String JACK = "jack"; //$NON-NLS-1$
+       public static final String CAMERA_LEGACY = "cameraLegacy";
+       public static final String CAMERA_REAR = "rear";
        public static final String CAMERA = "camera"; //$NON-NLS-1$
-       public static final String CAMERA_REAR = "rearType";
-       public static final String CAMERA_FRONT = "frontType";
+       public static final String CAMERA_TYPE_REAR = "rearType";
+       public static final String CAMERA_TYPE_FRONT = "frontType";
+       public static final String CAMERA_IMAGE_REAR = "rearImage"; //$NON-NLS-1$
+       public static final String CAMERA_IMAGE_FRONT = "frontImage"; //$NON-NLS-1$
 
        public static final String NET_CONFIG = "netConfig"; //$NON-NLS-1$
        public static final String NET_PROXY = "proxy"; //$NON-NLS-1$
index 4459be7..2acaf65 100644 (file)
@@ -36,5 +36,16 @@ public class OptionName {
        public static final String NUM_COLUMN = "numColumn";
        public static final String EXPERIMENTAL = "experimental";
        public static final String LIST = "list";
+       public static final String SUPPORT_OS = "supportOS";
+
+       public static final String VALUE_TRUE = "true";
+       public static final String VALUE_FALSE = "false";
+
+       public static final String VALUE_ON = "on"; //$NON-NLS-1$
+       public static final String VALUE_OFF = "off"; //$NON-NLS-1$
+
+       public static final String LINUX = "linux"; //$NON-NLS-1$
+       public static final String WIN = "win"; //$NON-NLS-1$
+       public static final String MAC = "mac"; //$NON-NLS-1$
 
 }
index 79837f1..25e66ae 100644 (file)
@@ -162,7 +162,7 @@ public class CheckBoxItem extends ModifyDialogItem {
        }
 
 
-       private void updateCheckBoxSubItems() {
+       protected void updateCheckBoxSubItems() {
                for (CheckBoxSubItem subItem : subItemList) {
                        boolean isDataExist = false;
                        for (CheckItemData data : dataList) {
@@ -186,7 +186,7 @@ public class CheckBoxItem extends ModifyDialogItem {
        }
 
 
-       private void layoutCheckBoxSubItems() {
+       protected void layoutCheckBoxSubItems() {
 
                // layout subitems
                int top = 0;
@@ -310,7 +310,6 @@ public class CheckBoxItem extends ModifyDialogItem {
                        valueMap.put(subItem.getName(), subItem.isChecked());
                }
                value.setCheckBoxOptions(getName(), valueMap);
-
        }
 
        @Override
index f5c0d31..66092bc 100644 (file)
@@ -87,7 +87,6 @@ public abstract class ComboItem extends ModifyDialogItem {
        }
 
 
-
        protected String getSelectedItem() {
                return comboBox.getSelectedItem();
        }
index 16c3f5d..4ea2507 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.common;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 
 public class ConnectivityItem extends CheckBoxItem {
@@ -58,11 +60,18 @@ public class ConnectivityItem extends CheckBoxItem {
        @Override
        public void create(Composite parent) {
                item.init(parent);
-               item.setItemTitle(createIconTitle(item, null));
+               item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_CONNECTIVITY));
                item.create();
 
                createCheckBoxItems(item);
 
        }
 
+       @Override
+       public ModifyDialogItem cloneItem() {
+               List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+               dataList.addAll(this.dataList);
+               return new ConnectivityItem(null, dataList);
+       }
+
 }
index d2bcdfd..32768d5 100644 (file)
@@ -72,6 +72,11 @@ public abstract class FileDialogItem extends ModifyDialogItem {
                lastPath = path;
        }
 
+
+       public int getContentRight(int boxWidth) {
+               return boxWidth + BUTTON_SPACE + BUTTON_WIDTH;
+       }
+
        public static String getLastDirectoryPath() {
                return lastPath;
        }
@@ -91,7 +96,7 @@ public abstract class FileDialogItem extends ModifyDialogItem {
                makeBody(textBoxWidth);
        }
 
-       private void makeBody(int textBoxWidth) {
+       protected void makeBody(int textBoxWidth) {
 
                item.setBodyLayoutForm();
 
@@ -178,4 +183,20 @@ public abstract class FileDialogItem extends ModifyDialogItem {
        }
 
        public abstract void fileSelected();
+
+
+       public void setItemEnable(boolean enable) {
+               textBox.setEnabled(enable);
+               fileDialogButton.setShowImage(enable);
+               item.setTitleEnable(enable);
+       }
+
+
+
+       @Override
+       public void changeWidgetState(boolean isError) {
+               if (!getItemListComp().isDetailMode()) {
+                       textBox.setError(isError);
+               }
+       }
 }
index 76728f2..89afef2 100644 (file)
@@ -67,7 +67,7 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
        public static final int ERROR_ICON_SPACING_INNER = 3;
 
        // decide item's visibility in dialog
-       private final boolean isUse = true;
+       private boolean isUse = true;
 
        // This decide whether draw bottom line or not.
        private boolean isDrawBottomLine = true;
@@ -79,6 +79,14 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
                }
        }
 
+       public boolean isUse() {
+               return isUse;
+       }
+
+       public void setUse(boolean isUse) {
+               this.isUse = isUse;
+       }
+
        public void redrawBottomLine() {
                item.getBody().redraw();
                item.getItemTitle().redrawBottomLine(isDrawBottomLine);
@@ -181,6 +189,8 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
                } else {
                        data.heightHint = 0;
                }
+
+               setUse(isVisible);
        }
 
        public void setVisible() {
index dc049e7..2288766 100644 (file)
@@ -31,6 +31,7 @@
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.common;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
@@ -75,4 +76,12 @@ public class SensorItem extends CheckBoxItem {
        }
 
 
+       @Override
+       public ModifyDialogItem cloneItem() {
+               List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+               dataList.addAll(this.dataList);
+               return new SensorItem(null, dataList);
+       }
+
+
 }
index 0abd21a..259c06a 100644 (file)
@@ -53,7 +53,9 @@ import org.tizen.emulator.manager.ui.renewal.MainDialog;
 import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
 import org.tizen.emulator.manager.ui.renewal.dialog.ItemListComp;
 import org.tizen.emulator.manager.ui.renewal.dialog.ValidationListener;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraItem;
 import org.tizen.emulator.manager.ui.renewal.tableviewer.CreateVMTableViewer;
 
 
@@ -227,4 +229,17 @@ public class AdvancedPropertyViewer {
        public void saveDataInto(Object value) {
                itemListComp.saveDataInto(value);
        }
+
+       // return if item is showing in advanced option.
+       public CameraItem getCameraItem() {
+               for (ModifyDialogItem item :itemListComp.getItemList()) {
+                       if (item.getName().equals(ItemName.CAMERA)) {
+                               if (item.isUse()) {
+                                       return (CameraItem)item;
+                               }
+                               break;
+                       }
+               }
+               return null;
+       }
 }
index 2c7f9f4..b3506ac 100644 (file)
@@ -45,8 +45,8 @@ import org.tizen.emulator.manager.renewal.resources.FontResources;
 public class ItemTitle extends Canvas{
 
        public static final int TITLE_SPACING = 8;
-//     private final int TITLE_CANVAS_WIDTH = 144;
-       public static final int TITLE_CANVAS_WIDTH = 130;
+       public static final int TITLE_CANVAS_WIDTH = 140;
+//     public static final int TITLE_CANVAS_WIDTH = 130;
        private final int LINE_INDENT = 5;
 
        protected int ICON_WIDTH = 18;
index c502eed..9bda608 100644 (file)
@@ -44,6 +44,7 @@ import org.tizen.emulator.manager.devices.SubDeviceItem;
 import org.tizen.emulator.manager.platform.Platform;
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.platform.baseimage.CustomBaseImageValue;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.vms.RESOLUTION;
 import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.VMOption;
@@ -417,6 +418,15 @@ public class PropertyValue {
                return valueMap;
        }
 
+       public Map<String, Boolean> getCameraCheckOptions() {
+               if (isVMValue()) {
+                       return getCheckBoxOptions(ItemName.CAMERA_LEGACY);
+
+               } else {
+                       return getCheckBoxOptions(ItemName.CAMERA);
+               }
+       }
+
 
        public void setCPUVirtualization(boolean isOn) {
                if (isVMValue()) {
@@ -525,6 +535,18 @@ public class PropertyValue {
        public boolean getCheckBoxValue(String name, String subName) {
                if (isVMValue()) {
                        return checkOn(getSubOptionValue(name, subName));
+
+               } else if (isTemplateValue()) {
+                       for (SubDevice subDevice : templateValue.getAdditionalDevices()) {
+                               if (subDevice.getName().equals(name)) {
+                                       for (SubDeviceItem subDeviceItem : subDevice.getItems()) {
+                                               if (subDeviceItem.getId().equals(subName)) {
+                                                       return subDeviceItem.isSupport();
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
                }
                return true;
        }
index 15a6b41..274aefc 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.template;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 
 public class CameraItem extends CheckBoxItem {
 
@@ -59,7 +62,7 @@ public class CameraItem extends CheckBoxItem {
        @Override
        public void create(Composite parent) {
                item.init(parent);
-               item.setItemTitle(createIconTitle(item, null));
+               item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_CAMERA));
                item.create();
 
                createCheckBoxItems(item);
@@ -67,4 +70,11 @@ public class CameraItem extends CheckBoxItem {
        }
 
 
+       @Override
+       public ModifyDialogItem cloneItem() {
+               List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+               dataList.addAll(this.dataList);
+               return new CameraItem(dataList);
+       }
+
 }
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraImageItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraImageItem.java
new file mode 100644 (file)
index 0000000..3ee8e5a
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.pk@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.ui.renewal.item.modify.vm;
+
+import java.io.File;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.ui.Messages;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubModifyItem;
+
+public class CameraImageItem extends FileDialogItem {
+
+       private String imagePath; // directory
+       private CameraItem cameraItem;
+
+       private static final String DEFAULT_FRONT_IMG = "default-image1.gif";
+       private static final String DEFAULT_REAR_IMG = "default-image2.gif";
+
+
+       public CameraImageItem(String name, String title) {
+               super(name, title);
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new SubModifyItem(this);
+               item.setItemHeight(SubModifyItem.ITEM_HEIGHT);
+               item.init(parent);
+               item.setItemTitle(new SubItemTitle(item.getItemComp(), getTitle(),
+                               ColorResources.WHITE));
+               item.create();
+
+               makeBody(SubModifyItem.BOX_WIDTH);
+
+               setTextBox(imagePath);
+       }
+
+
+       @Override
+       public void setParentItem(ModifyDialogItem parentItem) {
+               super.setParentItem(parentItem);
+               cameraItem = (CameraItem)parentItem;
+       }
+
+       private void updateUI() {
+               if (imagePath == null || imagePath.isEmpty()) {
+                       setTextBox("(select sharing path...)");
+
+               } else {
+                       setTextBox(imagePath);
+               }
+
+       }
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               imagePath = value.getSubOptionValue(getParentItem().getName(), getName());
+               settingImagePath();
+//             setTextBox(imagePath);
+
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(getParentItem().getName(), getName(), imagePath);
+
+       }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new CameraImageItem(getName(), getTitle());
+       }
+
+
+       @Override
+       public void fileSelected() {
+               imagePath = filePath;
+               getItemListComp().checkValid();
+       }
+
+
+       public void reset(String cameraType) {
+               if (CameraItem.TYPE_VIRTUAL.equals(cameraType)) {
+                       activate();
+               } else {
+                       deactivate();
+               }
+       }
+
+       private void settingImagePath() {
+               if (imagePath == null || imagePath.isEmpty()) {
+                       imagePath = FilePathResources.getToolEmulatorImagesPath()
+                                       + File.separator
+                                       + (ItemName.CAMERA_IMAGE_FRONT.equals(getName()) ? DEFAULT_FRONT_IMG
+                                                       : DEFAULT_REAR_IMG);
+               }
+       }
+
+       public void activate() {
+               setItemEnable(true);
+               settingImagePath();
+               setTextBox(imagePath);
+       }
+
+       public void deactivate() {
+               imagePath = ""; //$NON-NLS-1$
+               setTextBox(imagePath);
+               setItemEnable(false);
+       }
+
+       @Override
+       public boolean isValid() {
+               boolean isValid = true;
+               String msg = "";
+               CameraTypeItem cameraType = cameraItem.getCameraTypeItem(getName());
+               if (cameraType.isVirtualSelected()) {
+                       if (imagePath == null || imagePath.isEmpty()) {
+                               msg = Messages.getString("CameraImageSubViewItem.ImageFileError.0"); //$NON-NLS-1$
+
+                       } else {
+                               File f = new File(imagePath);
+                               if (!f.exists()) {
+                                       msg = Messages.getString("CameraImageSubViewItem.ImageFileError.1"); //$NON-NLS-1$
+                               }
+                       }
+               }
+
+               if (!msg.isEmpty()) {
+                       isValid = false;
+               }
+
+               changeItemState(!isValid, getContentRight(SubModifyItem.BOX_WIDTH), msg);
+
+               return isValid;
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraItem.java
new file mode 100644 (file)
index 0000000..e0863a2
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.pk@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.ui.renewal.item.modify.vm;
+
+import java.util.Arrays;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+import org.tizen.emulator.manager.vms.helper.ProcessResult;
+
+public class CameraItem extends CategoryItem {
+
+       public static final String NAME = "camera";
+
+       public static final String TYPE_NONE = "(none)"; //$NON-NLS-1$
+       public static final String TYPE_WEBCAM = "Webcam"; //$NON-NLS-1$
+       public static final String TYPE_VIRTUAL = "Virtual"; //$NON-NLS-1$
+
+       public static Boolean webcamSupport = null;
+
+       public CameraItem(TreeModifyItem treeRoot, String title) {
+               super(NAME, title);
+               if (treeRoot == null) {
+                       item = new ModifyItem(this);
+
+               }  else {
+                       item = new SubTreeModifyItem(this,treeRoot);
+                       treeRoot.addSubItem((SubTreeModifyItem)item);
+               }
+       }
+
+
+       @Override
+       public void create(Composite parent) {
+               int itemHeight = 0;
+               if (subItems.size() == 0) {
+                       itemHeight = ModifyItem.ITEM_HEIGHT;
+
+               } else {
+                       for (ModifyDialogItem subItem : subItems) {
+                               subItem.setDrawBottomLine(false);
+                       }
+                       itemHeight = getItemHeight();
+               }
+
+//             item = new ModifyItem(this);
+               item.setItemHeight(itemHeight);
+               item.init(parent);
+
+               // TODO set camera icon
+               item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_CAMERA));
+               item.create();
+
+               makeBody();
+       }
+
+
+       private void makeBody() {
+               item.setBodyLayoutGrid(1, 0);
+               createSubItems();
+       }
+
+
+       private void createSubItems() {
+               for (ModifyDialogItem item : subItems) {
+                       item.setParentItem(this);
+                       item.setItemListComp(this.getItemListComp());
+                       item.setInitialValue(this.getItemListComp().getPropertyValue());
+                       item.create(this.item.getBody());
+                       item.setVisible();
+               }
+
+               CameraTypeItem rearTypeItem = getRearTypeItem();
+               CameraTypeItem frontTypeItem = getFrontTypeItem();
+               String rearType = rearTypeItem == null ? TYPE_NONE :  rearTypeItem.getCameraType();
+               String frontType = frontTypeItem == null ? TYPE_NONE : frontTypeItem.getCameraType();
+               if (rearTypeItem != null) {
+                       rearTypeItem.reset(frontType);
+                       getRearImageItem().reset(rearType);
+               }
+               if (frontTypeItem != null) {
+                       frontTypeItem.reset(rearType);
+                       getFrontImageItem().reset(frontType);
+               }
+       }
+
+
+       public void setRearCameraCheck(boolean isCheck) {
+               CameraTypeItem rearTypeItem = getRearTypeItem();
+               if (rearTypeItem == null) {
+                       return;
+               }
+
+               String cameraType = isCheck ? "" : TYPE_NONE;
+               rearTypeItem.setCameraTypeAndSelect(cameraType);
+       }
+
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               CameraItem item = new CameraItem(null, getTitle());
+               for (ModifyDialogItem subItem : subItems) {
+                       item.addSubItems(subItem.cloneItem());
+               }
+
+               return item;
+       }
+
+
+       private static boolean checkWebcam() {
+               ProcessResult res = HelperClass.runProcess(Arrays
+                               .asList(FilePathResources.getCheckCamPath()));
+               int result = res.getExitValue();
+               if (result == 1) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public static boolean isWebcamSupport() {
+               if (webcamSupport == null) {
+                       webcamSupport = checkWebcam();
+               }
+               return webcamSupport;
+       }
+
+
+       private CameraTypeItem getRearTypeItem() {
+               return (CameraTypeItem)getSubItemByName(ItemName.CAMERA_TYPE_REAR);
+       }
+
+       private CameraTypeItem getFrontTypeItem() {
+               return (CameraTypeItem)getSubItemByName(ItemName.CAMERA_TYPE_FRONT);
+       }
+
+       private CameraImageItem getRearImageItem() {
+               return (CameraImageItem)getSubItemByName(ItemName.CAMERA_IMAGE_REAR);
+       }
+
+       private CameraImageItem getFrontImageItem() {
+               return (CameraImageItem)getSubItemByName(ItemName.CAMERA_IMAGE_FRONT);
+       }
+
+
+       public CameraImageItem getCameraImageItem(String typeItemName) {
+               if (typeItemName.equals(ItemName.CAMERA_TYPE_FRONT)) {
+                       return getFrontImageItem();
+               } else {
+                       return getRearImageItem();
+               }
+       }
+
+       public CameraTypeItem getCameraTypeItem(String imageItemName) {
+               if (imageItemName.equals(ItemName.CAMERA_IMAGE_FRONT)) {
+                       return getFrontTypeItem();
+               } else {
+                       return getRearTypeItem();
+               }
+       }
+
+       public CameraTypeItem getAnotherCameraTypeItem(String typeItemName) {
+               if (typeItemName.equals(ItemName.CAMERA_TYPE_FRONT)) {
+                       return getRearTypeItem();
+               } else {
+                       return getFrontTypeItem();
+               }
+       }
+
+       @Override
+       public boolean isValid() {
+               boolean isValid = true;
+               for (ModifyDialogItem item : subItems) {
+                       if(!item.isValid()) {
+                               isValid = false;
+                       }
+               }
+               return isValid;
+       }
+
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               boolean useRear = value.getCheckBoxValue(ItemName.CAMERA, ItemName.CAMERA_REAR);
+               setRearCameraCheck(useRear);
+       }
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraLegacyItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraLegacyItem.java
new file mode 100644 (file)
index 0000000..face322
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@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.ui.renewal.item.modify.vm;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxSubItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+
+public class CameraLegacyItem extends CheckBoxItem {
+
+       public CameraLegacyItem(String name, String title, int numColomn,
+                       TreeModifyItem treeRoot, List<CheckItemData> dataList) {
+               super(name, title, numColomn, treeRoot, dataList);
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item.init(parent);
+               item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_CAMERA));
+               item.create();
+
+               createCheckBoxItems(item);
+       }
+
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               setInitialValue(value);
+               updateCheckBoxSubItems();
+               layoutCheckBoxSubItems();
+       }
+
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               Map<String, Boolean> valueMap = value.getCameraCheckOptions();
+               this.valueMap = valueMap;
+       }
+
+
+       @Override
+       public void setValue(PropertyValue value) {
+               valueMap.clear();
+               for (CheckBoxSubItem subItem : getSubItemList()) {
+                       valueMap.put(subItem.getName(), subItem.isChecked());
+               }
+               value.setCheckBoxOptions(getName(), valueMap);
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraTypeItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraTypeItem.java
new file mode 100644 (file)
index 0000000..20e0f35
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.pk@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.ui.renewal.item.modify.vm;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.detail.item.property.CameraViewItem;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+public class CameraTypeItem extends ComboItem {
+
+       String cameraType = "";
+
+       private CameraItem cameraItem;
+
+       public CameraTypeItem(String name, String title) {
+               super(name, title);
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new SubModifyItem(this);
+               item.setItemHeight(SubModifyItem.ITEM_HEIGHT);
+               item.init(parent);
+               item.setItemTitle(new SubItemTitle(item.getItemComp(), getTitle(),
+                               ColorResources.WHITE));
+               item.create();
+
+               makeBody();
+       }
+
+       protected void makeBody() {
+               // create combo
+               createCombo(item, SubModifyItem.BOX_WIDTH);
+
+               // init combo list
+               addItem(CameraItem.TYPE_WEBCAM);
+               addItem(CameraItem.TYPE_VIRTUAL);
+               addItem(CameraItem.TYPE_NONE);
+
+               // select combo
+               selectItem(false);
+       }
+
+       @Override
+       public void setParentItem(ModifyDialogItem parentItem) {
+               super.setParentItem(parentItem);
+               cameraItem = (CameraItem)parentItem;
+       }
+
+       private boolean addItem(String type) {
+               if (CameraItem.TYPE_WEBCAM.equals(type)
+                               && !CameraViewItem.isWebcamSupport()) {
+                       return false;
+               }
+               addComboItem(type);
+               return true;
+       }
+
+
+       private void selectItem(boolean notifySelect) {
+               if (comboBox == null || comboBox.isDisposed()) {
+                       return;
+               }
+
+               // Set default if first create.
+               if (getItemListComp().isCreateMode()) {
+                       if (!isInComboOptions(cameraType)) {
+                               // Rear : webcam (if webcam available)
+                               if (isRear() && CameraItem.isWebcamSupport()) {
+                                       cameraType = CameraItem.TYPE_WEBCAM;
+
+                                       // Front : virtual
+                               } else {
+                                       cameraType = CameraItem.TYPE_VIRTUAL;
+                               }
+                       }
+               }
+
+
+               // select item
+               int index = -1;
+               for (int i=0 ; i < getComboItemList().size() ; i++) {
+                       if (getComboItemList().get(i).equals(cameraType)) {
+                               index = i;
+                               break;
+                       }
+               }
+
+               if (index == -1) {
+                       index = 0;
+                       cameraType = getComboItem(index);
+               }
+
+               selectComboItem(index, notifySelect);
+
+               if (notifySelect) {
+                       comboSelected();
+               }
+       }
+
+       private void comboSelected() {
+               // reset image item
+               CameraImageItem imageItem = cameraItem.getCameraImageItem(getName());
+               if (imageItem != null) {
+                       imageItem.reset(cameraType);
+               }
+
+               // reset another camera type item
+               CameraTypeItem anotherCameraItem = cameraItem.getAnotherCameraTypeItem(getName());
+               if (anotherCameraItem != null) {
+                       anotherCameraItem.reset(cameraType);
+               }
+
+               getItemListComp().checkValid();
+       }
+
+
+       @Override
+       public void itemSelected(ComboBox comboBox) {
+               // This is called when combo item is selected
+               cameraType = comboBox.getSelectedItem();
+               comboSelected();
+       }
+
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               cameraType = value.getSubOptionValue(ItemName.CAMERA, getName());
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(ItemName.CAMERA, getName(), cameraType);
+
+       }
+
+       public String getCameraType() {
+               return cameraType;
+       }
+
+
+       public void setCameraTypeAndSelect(String cameraType) {
+               this.cameraType = cameraType;
+               selectItem(true);
+       }
+
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new CameraTypeItem(getName(), getTitle());
+       }
+
+       public void reset(String anotherCameraType) {
+               if (CameraItem.TYPE_WEBCAM.equals(anotherCameraType)) {
+                       // remove webcam if exist.
+                       int index = -1;
+                       for (int i = 0; i < comboBox.getItemCount(); i++) {
+                               if (comboBox.getItem(i).equals(CameraItem.TYPE_WEBCAM)) {
+                                       index = i;
+                               }
+                       }
+                       if (index > -1) {
+                               comboBox.remove(index);
+                               selectItem(false); // false ?
+                       }
+
+               } else {
+                       // Add webcam if not exist.
+                       if (CameraItem.isWebcamSupport()) {
+                               boolean addWebcam = true;
+                               for (int i = 0; i < comboBox.getItemCount(); i++) {
+                                       if (comboBox.getItem(i).equals(CameraItem.TYPE_WEBCAM)) {
+                                               addWebcam = false;
+                                               break;
+                                       }
+                               }
+                               if (addWebcam) {
+                                       comboBox.addItem(CameraItem.TYPE_WEBCAM, 0);
+                                       selectItem(false); // false ?
+                               }
+                       }
+               }
+       }
+
+
+       private boolean isInComboOptions(String value) {
+               for (String str : comboBox.getItemList()) {
+                       if (str.equals(value)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private boolean isRear() {
+               return ItemName.CAMERA_TYPE_REAR.equals(getName());
+       }
+
+
+
+       public boolean isVirtualSelected() {
+               if (CameraViewItem.VALUE_VIRTUAL.equals(cameraType)) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+}
index e9da702..a14b717 100644 (file)
@@ -34,6 +34,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
 
 public abstract class CategoryItem extends ModifyDialogItem {
 
@@ -61,5 +62,26 @@ public abstract class CategoryItem extends ModifyDialogItem {
                return height;
        }
 
+       @Override
+       public void setValue(PropertyValue value) {
+               for (ModifyDialogItem item : subItems) {
+                       item.setValue(value);
+               }
+       }
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               // override this if you want.
+       }
+
+       protected ModifyDialogItem getSubItemByName(String itemName) {
+               for (ModifyDialogItem subItem : subItems) {
+                       if (subItem.getName().equals(itemName)) {
+                               return subItem;
+                       }
+               }
+               return null;
+       }
+
 
 }
index 92b18f4..faebfed 100644 (file)
@@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.devices.DeviceTemplate;
 import org.tizen.emulator.manager.platform.Profile;
 import org.tizen.emulator.manager.platform.ProfileList;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
@@ -108,12 +109,26 @@ public class DeviceTemplateItem extends ComboItem {
        public void itemSelected(ComboBox comboBox) {
 
                template = (DeviceTemplate)comboBox.getSelectedData();
+               PropertyValue propertyValue = new PropertyValue(template.getValue());
 
                // - change item list value
                for (SubTreeModifyItem subTree : treeModifyItem.getSubItemList()) {
                        ModifyDialogItem dialogItem = subTree.getDialogItem();
-                       dialogItem.changeItemValue(new PropertyValue(template.getValue()));
+                       dialogItem.changeItemValue(propertyValue);
                }
+
+               // change new camera item value
+               changeCameraItemValue(propertyValue);
+       }
+
+
+       private void changeCameraItemValue(PropertyValue value) {
+               CameraItem cameraItem = (CameraItem)getItemListComp().getItem(ItemName.CAMERA);
+               if (cameraItem == null) {
+                       return;
+               }
+
+               cameraItem.changeItemValue(value);
        }
 
        @Override
index 0e194d2..b6576d2 100644 (file)
@@ -88,6 +88,7 @@ public class FileSharingItem extends FileDialogItem {
                return new FileSharingItem();
        }
 
+
        @Override
        public void fileSelected() {
                sharingPath = filePath;
@@ -98,4 +99,6 @@ public class FileSharingItem extends FileDialogItem {
                setFilePath(sharingPath);
                updateUI();
        }
+
+
 }
index 92869a1..2bc2770 100644 (file)
@@ -85,7 +85,6 @@ public class NetConnectTypeItem extends ComboItem{
                        } else if (str.equals(TYPE_BRIDGE)) {
                                addComboItem(TYPE_BRIDGE);
                        }
-
                }
 
                // select combo
index 4e327ba..f742077 100644 (file)
@@ -49,11 +49,18 @@ public class NetworkItem extends CategoryItem {
 
        @Override
        public void create(Composite parent) {
-               subItems.get(subItems.size()-1).setDrawBottomLine(false);
+               int itemHeight = 0;
+               if (subItems.size() == 0) {
+                       itemHeight = ModifyItem.ITEM_HEIGHT;
+
+               } else {
+                       subItems.get(subItems.size()-1).setDrawBottomLine(false);
+                       itemHeight = getItemHeight();
+               }
 
                item = new ModifyItem(this);
 //             item.setItemHeight(ModifyItem.ITEM_HEIGHT * subItems.size());
-               item.setItemHeight(getItemHeight());
+               item.setItemHeight(itemHeight);
                item.init(parent);
                item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_NETWORK));
                item.create();
@@ -85,13 +92,6 @@ public class NetworkItem extends CategoryItem {
        }
 
 
-       @Override
-       public void setValue(PropertyValue value) {
-               for (ModifyDialogItem item : subItems) {
-                       item.setValue(value);
-               }
-       }
-
 
        @Override
        public boolean isValid() {
@@ -162,16 +162,6 @@ public class NetworkItem extends CategoryItem {
                item.resetItem();
        }
 
-
-       private ModifyDialogItem getSubItemByName(String itemName) {
-               for (ModifyDialogItem subItem : subItems) {
-                       if (subItem.getName().equals(itemName)) {
-                               return subItem;
-                       }
-               }
-               return null;
-       }
-
        public void setSubnet(String subnet) {
                NetIPInfoItem item = (NetIPInfoItem)getSubItemByName(ItemName.NET_IP_INFO);
                item.setSubnet(subnet);
index 9c8eb75..be658fb 100644 (file)
@@ -55,8 +55,11 @@ import org.tizen.emulator.manager.renewal.resources.PatchImageResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.ui.Messages;
 import org.tizen.emulator.manager.ui.renewal.MainDialog;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.OptionName;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.AdvancedPropertyViewer;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CameraItem;
 import org.tizen.emulator.manager.ui.renewal.widgets.GrayButton;
 import org.tizen.emulator.manager.ui.renewal.widgets.ImageButton;
 import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchResourceInfo;
@@ -241,16 +244,18 @@ public class CreateVMTableViewer extends AbstractTableViewer {
                }
 
                this.baseImage = baseImage;
-               if (needRedrawingTable) {
-                       System.out.println("need redrawing");
-                       table.showTable();
-               }
 
                // change advanced item-list
                settingVMPropertyValue();
                PropertyValue value = new PropertyValue(newValue.clone());
                advancedViewer.changeItemList(baseImage, value);
 
+               if (needRedrawingTable) {
+                       System.out.println("need redrawing");
+                       table.showTable();
+               }
+
+
 
                checkValid();
        }
@@ -259,11 +264,39 @@ public class CreateVMTableViewer extends AbstractTableViewer {
                return template;
        }
 
+
        public void setTemplate(DeviceTemplate template) {
                this.template = template;
+
+               // check camera
+               resetCameraOption();
+
+               // TODO check skin list
+
                checkValid();
        }
 
+
+       private void resetCameraOption() {
+               if (newValue == null) {
+                       settingVMPropertyValue();
+               }
+
+               boolean isRearCameraSupport = template.getValue().isRearCameraSupport();
+
+               CameraItem advancedCameraItem = advancedViewer.getCameraItem();
+               if (advancedCameraItem == null) {
+                       // setting legacy camera option
+                       newValue.setAdvancedOptionSub(ItemName.CAMERA_LEGACY, ItemName.CAMERA_REAR,
+                                       isRearCameraSupport ? OptionName.VALUE_ON : OptionName.VALUE_OFF);
+
+               } else {
+                       // change camera value in advanced option
+                       advancedCameraItem.setRearCameraCheck(isRearCameraSupport);
+               }
+       }
+
+
        public VMPropertyValue getNewValue() {
                return newValue;
        }
index f34739c..93a638d 100644 (file)
@@ -96,6 +96,20 @@ public class ComboBox extends NinePatchBox {
                }
        }
 
+       public int getItemCount() {
+               return items.size();
+       }
+
+       public String getItem(int index) {
+               return items.get(index);
+       }
+
+       public void remove(int index) {
+               items.remove(index);
+               datas.remove(index);
+       }
+
+
        public Shell getParentShell() {
                return parentShell;
        }
index 844c82e..0a8112f 100644 (file)
@@ -485,7 +485,7 @@ public class VMPropertyValue implements Cloneable {
                VMOption option = getVMAdvancedOption(name);
                if (option == null) {
                        option = new VMOption(name);
-                       option.setValue(value);
+                       option.setValue(null);
                        advancedVMOptionList.add(option);
                }
 
diff --git a/src/org/tizen/emulator/manager/vms/option/CameraLegacyOption.java b/src/org/tizen/emulator/manager/vms/option/CameraLegacyOption.java
new file mode 100644 (file)
index 0000000..585ebb0
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@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.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+
+public class CameraLegacyOption  extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMWorkerException {
+
+               if (checkOn(property.getPropertyValue().getAdvancedOptionSubValue(
+                               ItemName.CAMERA_LEGACY, ItemName.CAMERA_REAR))) {
+                       config.addQemuOption("-device", "maru-camera");
+               }
+       }
+
+}
index a1b4c41..8706987 100644 (file)
                                <item name="hrm" title="Heartbeat Rate" type="checkbox"/>
                                <option name="numColumn">2</option>
                        </item>
+<!--                   <item name="cameraLegacy" title="Camera" type="checkLabel"> -->
+<!--                           <option name="numColumn">2</option> -->
+<!--                           <item name="rear" title="Rear" type="checkBox"/> -->
+<!--                   </item> -->
                        <item name="connectivity" title="Connectivity" type="checkLabel">
                                <item name="nfc" title="NFC" type="checkbox" />
                                <option name="numColumn">2</option>
                        </item>
-                       <item name="camera" title="Camera" type="label" >
-<!--                                   <item type="combo" name="frontType" title="Front"/> -->
-<!--                                   <item type="file" name="frontImage" title="(image)"/> -->
-                                       <item type="combo" name="rearType" title="Rear"/>
-                                       <item type="file" name="rearImage" title="(image)"/>
-                       </item>
                </item>
        </itemGroup>
-<!--                   <item type="label" name="camera" title="Camera"> -->
-<!--                   <item type="combo" name="frontType" title="Front"/> -->
-<!--                   <item type="file" name="frontImage" title="(image)"/> -->
-<!--                   <item type="combo" name="rearType" title="Rear"/> -->
-<!--                   <item type="file" name="rearImage" title="(image)"/> -->
-
 
        <itemGroup name="advanced">
                <item name="suspendSupport" title="Suspend" type="toggle" >
                <item name="fileShare" title="File Sharing" type="file">
                                <option name="dialogType">directory</option>
                </item>
+               <item name="camera" title="Camera" type="label" >
+<!--                                   <item type="combo" name="frontType" title="Front"/> -->
+<!--                                   <item type="file" name="frontImage" title="(image)"/> -->
+                       <item type="combo" name="rearType" title="Rear"/>
+                       <item type="file" name="rearImage" title="(image)"/>
+               </item>
                <item name="network" title="Network" type="label">
                        <item name="proxy" title="Proxy" type="combo" >
                                <option name="none">No proxy</option>