vm-modify: apply device-template value.
authorminkee.lee <minkee.lee@samsung.com>
Wed, 21 Oct 2015 05:10:12 +0000 (14:10 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 22 Oct 2015 02:26:31 +0000 (11:26 +0900)
If user select device-template,
- some vm-property values are changed according to template.
- user cannot modify display resolution & size.

Change-Id: Id8a6bc0f880ba686e739009f408f10dc656b4fad
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
18 files changed:
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.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/DisplayItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/IModifyDialogItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProcessorItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/RamSizeItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ModifyItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/SubTreeModifyItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/TreeModifyItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java
src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java
src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java
src/org/tizen/emulator/manager/vms/Modifier.java

index 5aaae86..e817dca 100644 (file)
@@ -48,6 +48,7 @@ import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
 import org.tizen.emulator.manager.ui.renewal.dialog.DeviceTemplateModifyDialog;
 import org.tizen.emulator.manager.ui.renewal.dialog.ItemListUtil;
 import org.tizen.emulator.manager.ui.renewal.item.ItemType;
+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;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
@@ -58,6 +59,7 @@ 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.PropertyValue;
 import org.tizen.emulator.manager.ui.renewal.item.modify.template.CameraItem;
+import org.tizen.emulator.manager.vms.RESOLUTION;
 import org.tizen.emulator.manager.vms.xml.template2.ItemList2;
 
 public class DeviceTemplateDialogHandler {
@@ -360,12 +362,12 @@ public class DeviceTemplateDialogHandler {
 
                itemList.add(new NameItem("name", "Device Name"));
                itemList.add(new ProfileItem());
-               itemList.add(new DisplayItem(null));
+               itemList.add(new DisplayItem(new ArrayList<RESOLUTION>()));
                itemList.add(new RamSizeItem());
                itemList.add(new ProcessorItem());
-               itemList.add(new SensorItem(null));
-               itemList.add(new ConnectivityItem(null));
-               itemList.add(new CameraItem(null));
+               itemList.add(new SensorItem(new ArrayList<CheckItemData>()));
+               itemList.add(new ConnectivityItem(new ArrayList<CheckItemData>()));
+               itemList.add(new CameraItem(new ArrayList<CheckItemData>()));
 
                return itemList;
        }
index 5418aaf..95e61b5 100644 (file)
@@ -64,7 +64,6 @@ public class VMModifyHandler {
                dialog.create(newValue, getItemList(property));
 
                // TODO set display value to dialog
-
                int retValue = dialog.open();
 
                if (retValue == SWT.OK) {
index fba1887..6ee7721 100644 (file)
@@ -82,7 +82,7 @@ public class CheckBoxItem extends ModifyDialogItem {
 
        private void initSubTreeItem(TreeModifyItem treeRoot) {
                initDataList();
-               item = new SubTreeModifyItem();
+               item = new SubTreeModifyItem(this,treeRoot);
                item.setItemHeight(getContentHeight());
                treeRoot.addSubItem((SubTreeModifyItem)item);
        }
@@ -156,6 +156,15 @@ public class CheckBoxItem extends ModifyDialogItem {
                }
 
                // 2. set isUse()
+               updateCheckBoxSubItems();
+
+               // 3. layout subitems.
+               layoutCheckBoxSubItems();
+
+       }
+
+
+       private void updateCheckBoxSubItems() {
                for (CheckBoxSubItem subItem : subItemList) {
                        boolean isDataExist = false;
                        for (CheckItemData data : dataList) {
@@ -167,10 +176,6 @@ public class CheckBoxItem extends ModifyDialogItem {
                        }
                        subItem.setUse(isDataExist);
                }
-
-               // 3. layout subitems.
-               layoutCheckBoxSubItems();
-
        }
 
 
@@ -323,4 +328,11 @@ public class CheckBoxItem extends ModifyDialogItem {
 
        }
 
+
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               setInitialValue(value);
+               updateCheckBoxSubItems();
+               layoutCheckBoxSubItems();
+       }
 }
index 02a59c9..0c7c309 100644 (file)
@@ -63,6 +63,12 @@ public abstract class ComboItem extends ModifyDialogItem {
                return comboBox.getItemList();
        }
 
+
+       protected List<Object> getComboDataList() {
+               return comboBox.getDataList();
+       }
+
+
        protected String getComboItem(int index) {
                return comboBox.getItemList().get(index);
        }
@@ -72,9 +78,16 @@ public abstract class ComboItem extends ModifyDialogItem {
        }
 
        protected void selectComboItem(int index) {
-               comboBox.select(index);
+               selectComboItem(index, true);
+       }
+
+       protected void selectComboItem(int index, boolean notifySelect) {
+               comboBox.select(index, notifySelect);
+               comboBox.redraw();
        }
 
+
+
        protected String getSelectedItem() {
                return comboBox.getSelectedItem();
        }
@@ -125,4 +138,7 @@ public abstract class ComboItem extends ModifyDialogItem {
                // TODO override this.
        }
 
+
+
+
 }
index 8c64b7d..0f3411a 100644 (file)
@@ -53,6 +53,7 @@ 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.ui.renewal.item.modify.vm.DeviceTemplateItem;
 import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
 import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox;
 import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
@@ -71,7 +72,7 @@ public class DisplayItem extends ModifyDialogItem {
        /** constructor for tree sub item */
        public DisplayItem(TreeModifyItem treeRoot, List<RESOLUTION> resList) {
                super(NAME, TITLE);
-               item = new SubTreeModifyItem();
+               item = new SubTreeModifyItem(this, treeRoot);
                item.setItemHeight(ROW_HEIGHT * ROW_NUM + ModifyItem.LINE_WIDTH);
                treeRoot.addSubItem((SubTreeModifyItem)item);
                this.resList = resList;
@@ -112,6 +113,20 @@ public class DisplayItem extends ModifyDialogItem {
 
                        initResolutionCombo();
                }
+
+               // set widget disable if template is selected.
+               if (!(item instanceof SubTreeModifyItem)) {
+                       return;
+               }
+               ModifyDialogItem parentDialogItem = ((SubTreeModifyItem)item).getTreeRoot().getDialogItem();
+               if (!(parentDialogItem instanceof DeviceTemplateItem)) {
+                       return;
+               }
+               DeviceTemplateItem deviceTemplateItem = (DeviceTemplateItem)parentDialogItem;
+               if (deviceTemplateItem.getDeviceTemplate() != null) {
+                       setWidgetEnabled(false);
+               }
+
        }
 
 
@@ -621,7 +636,29 @@ public class DisplayItem extends ModifyDialogItem {
 
        }
 
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               // display resolution
+               resolution = value.getResolution();
+               selectResolutionCombo();
+
+               // size
+               displaySize = String.valueOf(value.getDisplaySize());
+               selectSize();
 
+               // skin ?
+
+               // TODO disable ?
+               setWidgetEnabled(false);
+       }
+
+       private void setWidgetEnabled(boolean enabled) {
+               resolutionCombo.setEnabled(enabled);
+               widthTextBox.setEnabled(enabled);
+               heightTextBox.setEnabled(enabled);
+               sizeTextBox.setEnabled(enabled);
+//             skinCombo.setEnabled(enabled);
+       }
 
 
 }
index 9dac2a0..72b6894 100644 (file)
@@ -37,6 +37,7 @@ import org.tizen.emulator.manager.ui.renewal.dialog.ModifyDialog;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ItemTitle;
 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.SubTreeItemTitle;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
 
@@ -61,6 +62,12 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
        }
 
 
+       /** change item value and redraw */
+       public void changeItemValue(PropertyValue value) {
+               // sub tree Dialog-item have to override
+       }
+
+
        public void mergeUIData(ModifyDialogItem srcDialogItem) {
                // override this.
        }
index 0765eb1..c939424 100644 (file)
@@ -62,7 +62,7 @@ public class ProcessorItem extends ComboItem {
        /** constructor for tree sub item */
        public ProcessorItem(TreeModifyItem treeRoot) {
                super(NAME, TITLE);
-               item = new SubTreeModifyItem();
+               item = new SubTreeModifyItem(this,treeRoot);
                treeRoot.addSubItem((SubTreeModifyItem)item);
        }
 
@@ -184,4 +184,11 @@ public class ProcessorItem extends ComboItem {
                // TODO ProcessorItem(TreeModifyItem treeRoot) ??
                return new ProcessorItem();
        }
+
+
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               setInitialValue(value);
+               selectItem();
+       }
 }
index 1992ffa..dcc6384 100644 (file)
@@ -60,7 +60,7 @@ public class RamSizeItem extends ComboItem {
        /** constructor for tree sub item */
        public RamSizeItem(TreeModifyItem treeRoot) {
                super(NAME, TITLE);
-               item = new SubTreeModifyItem();
+               item = new SubTreeModifyItem(this,treeRoot);
                treeRoot.addSubItem((SubTreeModifyItem)item);
        }
 
@@ -122,8 +122,10 @@ public class RamSizeItem extends ComboItem {
                                break;
                        }
                }
+
                selectComboItem(index);
                comboSelected();
+
        }
 
        private void comboSelected() {
@@ -186,4 +188,11 @@ public class RamSizeItem extends ComboItem {
                // TODO RamSizeItem(TreeModifyItem treeRoot) ??
                return new RamSizeItem();
        }
+
+
+       @Override
+       public void changeItemValue(PropertyValue value) {
+               setInitialValue(value);
+               selectItem();
+       }
 }
index 9986d7c..1053413 100644 (file)
@@ -53,7 +53,11 @@ public class SensorItem extends CheckBoxItem {
                dataList.add(new CheckItemData("geo", "Geo-magnetic"));
                dataList.add(new CheckItemData("light", "Light"));
                dataList.add(new CheckItemData("haptic", "Haptic"));
-               dataList.add(new CheckItemData("pressure", "Pressure"));
+               dataList.add(new CheckItemData("press", "Pressure"));
+               dataList.add(new CheckItemData("uv", "Ultraviolet"));
+               dataList.add(new CheckItemData("hrm", "Heartbeat Rate"));
+               dataList.add(new CheckItemData("test-mob", "test mobile"));
+
 
        }
 
index 6a3b704..0cd5365 100644 (file)
@@ -42,9 +42,12 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Layout;
 import org.tizen.emulator.manager.renewal.resources.ColorResources;
 import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 
 public class ModifyItem {
 
+       private ModifyDialogItem modifyDialogItem;
+
        public static final int ITEM_HEIGHT = 31;
        public static final int LINE_WIDTH = 1;
        public static final int LINE_INDENT = 7;
@@ -62,6 +65,14 @@ public class ModifyItem {
 
        private int itemHeight = ITEM_HEIGHT;
 
+       public void setModifyDialogItem(ModifyDialogItem modifyDialogItem) {
+               this.modifyDialogItem = modifyDialogItem;
+       }
+
+       public ModifyDialogItem getDialogItem() {
+               return modifyDialogItem;
+       }
+
        public int getItemHeight() {
                return itemHeight;
        }
index d83bb3b..4e97544 100644 (file)
@@ -44,9 +44,15 @@ import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.vms.RESOLUTION;
 import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.xml.OptionType;
+import org.tizen.emulator.manager.vms.xml.SubOptionType;
 
 public class PropertyValue {
 
+       private static String VALUE_ON = "on";
+       private static String VALUE_OFF = "off";
+
+
        // VMPropertyValue or DeviceTemplateValue
        private VMPropertyValue vmValue;
        private DeviceTemplateValue templateValue;
@@ -181,7 +187,7 @@ public class PropertyValue {
 
        public void setDisplaySize(double displaySize) {
                if (isVMValue()) {
-                       // nothing
+                       vmValue.screenSize = displaySize;
 
                } else if (isTemplateValue()) {
                        templateValue.setDisplaySize(displaySize);
@@ -190,7 +196,7 @@ public class PropertyValue {
 
        public double getDisplaySize() {
                if (isVMValue()) {
-
+                       return vmValue.screenSize;
 
                } else if (isTemplateValue()) {
                        return templateValue.getDisplaySize();
@@ -308,7 +314,9 @@ public class PropertyValue {
        public void setCheckBoxOptions(String name,
                        Map<String, Boolean> valueMap) {
                if (isVMValue()) {
-                       // TODO
+                       for (String key : valueMap.keySet()) {
+                               vmValue.setAdvancedOptionSub(name,  key, valueMap.get(key) ? VALUE_ON : VALUE_OFF);
+                       }
 
                } else if (isTemplateValue()) {
                        SubDevice subDevice = new SubDevice(name);
@@ -324,9 +332,14 @@ public class PropertyValue {
 
        public Map<String, Boolean> getCheckBoxOptions(String name) {
                Map<String, Boolean> valueMap = new HashMap<String, Boolean>();
-               // TODO
                if (isVMValue()) {
-                       // TODO
+                       OptionType options = vmValue.getAdvancedOption(name);
+                       if (options == null) {
+                               return valueMap;
+                       }
+                       for (SubOptionType subOption : options.getSubOption()) {
+                               valueMap.put(subOption.getName(), checkOn(subOption.getValue()));
+                       }
 
                } else if (isTemplateValue()) {
                        for (SubDevice subDevice : templateValue.getAdditionalDevices()) {
@@ -372,7 +385,14 @@ public class PropertyValue {
        }
 
 
+       private static boolean checkOn(String onOffVal) {
+               if (onOffVal.equals(VALUE_ON)) {
+                       return true;
 
+               } else {
+                       return false;
+               }
+       }
 
 //     public
 /*
index dd062e9..47e73bd 100644 (file)
 package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
 
 import org.eclipse.swt.layout.GridData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 
 
 public class SubTreeModifyItem extends ModifyItem{
 
+       private final ModifyDialogItem dialogItem;
+       private final TreeModifyItem treeRoot;
+
+       public SubTreeModifyItem(ModifyDialogItem parentItem, TreeModifyItem treeRoot) {
+               this.dialogItem = parentItem;
+               this.treeRoot = treeRoot;
+       }
+
+       public ModifyDialogItem getDialogItem() {
+               return dialogItem;
+       }
+
+       public TreeModifyItem getTreeRoot() {
+               return treeRoot;
+       }
+
        public void changeExpanding(boolean isExpand) {
                GridData data = new GridData();
                if (isExpand) {
index b25779c..7221e3b 100644 (file)
@@ -34,13 +34,14 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
-
 public class TreeModifyItem extends ModifyItem{
 
-       private ModifyDialogItem modifyDialogItem;
        private final List<SubTreeModifyItem> subItemList = new ArrayList<SubTreeModifyItem>();
 
+       public List<SubTreeModifyItem> getSubItemList() {
+               return subItemList;
+       }
+
        public void addSubItem(SubTreeModifyItem subItem) {
                subItemList.add(subItem);
        }
@@ -49,12 +50,9 @@ public class TreeModifyItem extends ModifyItem{
                for (SubTreeModifyItem subItem : subItemList) {
                        subItem.changeExpanding(isExpand);
                }
-               modifyDialogItem.getDialog().layoutScrolledComposite();
+               getDialogItem().getDialog().layoutScrolledComposite();
        }
 
-       public void setModifyDialogItem(ModifyDialogItem modifyDialogItem) {
-               this.modifyDialogItem = modifyDialogItem;
-       }
 
 
 }
index 9eb0b51..c7e2352 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.emulator.manager.platform.ProfileList;
 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.SubTreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeItemTitle;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
@@ -63,6 +64,11 @@ public class DeviceTemplateItem extends ComboItem {
                item = treeModifyItem;
        }
 
+
+       public DeviceTemplate getDeviceTemplate() {
+               return template;
+       }
+
        @Override
        public void create(Composite parent) {
                treeModifyItem.init(parent);
@@ -79,6 +85,9 @@ public class DeviceTemplateItem extends ComboItem {
                                comboBox.addItem(temp.getValue().getName(), temp);
                        }
                }
+
+               selectItem(false);
+//             comboSelected();
        }
 
        @Override
@@ -89,16 +98,20 @@ public class DeviceTemplateItem extends ComboItem {
        @Override
        public void setInitialValue(PropertyValue value) {
                // TODO
-               template = null;
+               template = value.getDeivceTemplate();
                profile = ProfileList.getProfile(value.getProfile());
        }
 
        @Override
        public void itemSelected(ComboBox comboBox) {
-               // TODO change item list for selected template.
-               System.out.println("item selected:" + comboBox.getSelectedItem());
+
                template = (DeviceTemplate)comboBox.getSelectedData();
 
+               // - change item list value
+               for (SubTreeModifyItem subTree : treeModifyItem.getSubItemList()) {
+                       ModifyDialogItem dialogItem = subTree.getDialogItem();
+                       dialogItem.changeItemValue(new PropertyValue(template.getValue()));
+               }
        }
 
        @Override
@@ -110,4 +123,29 @@ public class DeviceTemplateItem extends ComboItem {
        public ModifyDialogItem cloneItem() {
                return new DeviceTemplateItem();
        }
+
+
+       private void selectItem(boolean notifySelect) {
+               if (comboBox == null || comboBox.isDisposed()) {
+                       return;
+               }
+
+               // select item
+               int index = -1;
+               for (int i=0 ; i < getComboDataList().size() ; i++) {
+                       if (getComboDataList().get(i).equals(template)) {
+                               index = i;
+                               System.out.println("template: " + template.getValue().getName());
+                               System.out.println("index: " + i);
+                               break;
+                       }
+               }
+
+               if (index == -1) {
+                       return; // TODO is return right? need custom template ?
+
+               }
+
+               selectComboItem(index, notifySelect);
+       }
 }
index 8651b64..e3b1401 100644 (file)
@@ -28,7 +28,6 @@
  *
  */
 
-
 package org.tizen.emulator.manager.ui.renewal.widgets;
 
 import java.util.ArrayList;
@@ -97,7 +96,6 @@ public class ComboBox extends NinePatchBox {
                }
        }
 
-
        public Shell getParentShell() {
                return parentShell;
        }
@@ -106,21 +104,18 @@ public class ComboBox extends NinePatchBox {
                addItem(items.size(), item);
        }
 
-
        public void addItem(int index, String item) {
                addItem(index, item, null);
        }
 
-
        public void addItem(String item, Object data) {
                addItem(items.size(), item, data);
        }
 
-
        public void addItem(int index, String item, Object data) {
                try {
                        items.add(index, item);
-               }  catch (IndexOutOfBoundsException e) {
+               } catch (IndexOutOfBoundsException e) {
                        items.add(item);
                }
 
@@ -131,7 +126,6 @@ public class ComboBox extends NinePatchBox {
                }
        }
 
-
        @Override
        public void redraw() {
                textCanvas.redraw();
@@ -161,13 +155,11 @@ public class ComboBox extends NinePatchBox {
                selectedIndex = index;
        }
 
-
        public int getSelectionIndex() {
                return selectedIndex;
        }
 
-
-       public void select(int index) {
+       public void select(int index, boolean notifySelect) {
                if (index < 0 || index >= items.size()) {
                        return;
                }
@@ -176,21 +168,25 @@ public class ComboBox extends NinePatchBox {
                selectedItem = items.get(index);
                selectedData = datas.get(index);
 
-               notifyListeners(SWT.Selection, new Event());
+               if (notifySelect) {
+                       notifyListeners(SWT.Selection, new Event());
+               }
        }
 
+       public void select(int index) {
+               select(index, true);
+       }
 
        private void initBox() {
                this.setLayout(new FormLayout());
        }
 
-
        private void createText() {
                FormData data = new FormData();
                data.left = new FormAttachment(0, TEXT_MARGIN_LEFT);
                data.right = new FormAttachment(100, ARROW_AREA_WIDTH * -1);
                data.top = new FormAttachment(0, 1);
-               data.bottom = new FormAttachment(100,-1);
+               data.bottom = new FormAttachment(100, -1);
 
                textCanvas = new Canvas(this, SWT.NONE);
                textCanvas.setLayoutData(data);
@@ -198,7 +194,6 @@ public class ComboBox extends NinePatchBox {
                drawText();
        }
 
-
        public void closeComboBox() {
                popup.close();
        }
@@ -209,8 +204,13 @@ public class ComboBox extends NinePatchBox {
                        @Override
                        public void paintControl(PaintEvent e) {
                                GC gc = e.gc;
-                               Rectangle rect = ((Canvas)e.widget).getBounds();
-                               gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+                               Rectangle rect = ((Canvas) e.widget).getBounds();
+                               if (isDisabled()) {
+                                       gc.setForeground(ColorResources.TEXTBOX_DISABLE.getColor());
+
+                               } else {
+                                       gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+                               }
                                gc.setFont(FontResources.CONTENT.getFont());
                                Point textExt = gc.textExtent(selectedItem);
                                int poxY = (rect.height - textExt.y) / 2;
@@ -219,35 +219,52 @@ public class ComboBox extends NinePatchBox {
                });
        }
 
+       public boolean isDisabled() {
+               return getState() == WSTATE.DISABLE_ON || getState() == WSTATE.DISABLE_OFF;
+       }
+
        public void setText(String text) {
                selectedItem = text;
                redraw();
        }
 
-
        @Override
        protected void draw(PaintEvent e) {
                drawArrow(e);
        }
 
+       @Override
+       public void setEnabled(boolean enabled) {
+               if (enabled) {
+                       setState(WSTATE.NORMAL);
+               } else {
+                       setState(WSTATE.DISABLE_ON);
+               }
+
+               super.setEnabled(enabled);
+
+       }
 
        private void drawArrow(PaintEvent e) {
-               // drawArrow
-               Image image = getArrowImage();
-               ImageData imageData = image.getImageData();
-               GC gc = e.gc;
-               Rectangle rect = ((Canvas)e.widget).getBounds();
-               int posX = (rect.width - ARROW_AREA_WIDTH +
-                               (ARROW_AREA_WIDTH - imageData.width) /2 );
-               int posY = (rect.height - imageData.height) / 2;
-               gc.drawImage(image, posX, posY);
+
+               // draw only when enabled
+               if (!isDisabled()) {
+                       Image image = getArrowImage();
+                       ImageData imageData = image.getImageData();
+                       GC gc = e.gc;
+                       Rectangle rect = ((Canvas) e.widget).getBounds();
+                       int posX = (rect.width - ARROW_AREA_WIDTH + (ARROW_AREA_WIDTH - imageData.width) / 2);
+                       int posY = (rect.height - imageData.height) / 2;
+                       gc.drawImage(image, posX, posY);
+               }
 
        }
 
        private Image getArrowImage() {
                if (getState() == WSTATE.HOVER || getState() == WSTATE.SELECTED) {
                        if (arrowImageHover == null) {
-                               arrowImageHover = ImageResources.DROP_DOWN_ARROW_HOVER.getImage();
+                               arrowImageHover = ImageResources.DROP_DOWN_ARROW_HOVER
+                                               .getImage();
                        }
                        return arrowImageHover;
                }
@@ -259,7 +276,6 @@ public class ComboBox extends NinePatchBox {
 
        }
 
-
        private void addMouseListener() {
                Listener mouseListener = new Listener() {
 
@@ -271,20 +287,22 @@ public class ComboBox extends NinePatchBox {
                                                redraw();
                                        }
 
-                               } else  if (e.type == SWT.MouseExit) {
+                               } else if (e.type == SWT.MouseExit) {
                                        if (popup.isClosed()) {
                                                setState(WSTATE.NORMAL);
                                                redraw();
                                        }
 
-                               } if (e.type == SWT.MouseUp) {
-//                                     if (items.size() == 0) {
-//                                             return;
-//                                     }
-                                       Rectangle rect = ((Canvas)e.widget).getClientArea();
+                               } else if (e.type == SWT.MouseUp) {
+                                       // if (items.size() == 0) {
+                                       // return;
+                                       // }
+                                       Rectangle rect = ((Canvas) e.widget).getClientArea();
                                        if (rect.contains(e.x, e.y)) {
-                                               setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER : WSTATE.SELECTED);
+                                               setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER
+                                                               : WSTATE.SELECTED);
                                                redraw();
+                                               ((Composite)e.widget).setFocus();
                                                popup.changePopup();
                                        }
                                }
@@ -308,8 +326,7 @@ public class ComboBox extends NinePatchBox {
        private static void initNinePatchResourceMap() {
                ninePatchResourceMap = new NinePatchResourceMap();
                ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE,
-                               ColorResources.BLACK,
-                               ImageResources.DROP_DOWN_BOX_NORMAL_LT,
+                               ColorResources.WHITE, ImageResources.DROP_DOWN_BOX_NORMAL_LT,
                                ImageResources.DROP_DOWN_BOX_NORMAL_T,
                                ImageResources.DROP_DOWN_BOX_NORMAL_RT,
                                ImageResources.DROP_DOWN_BOX_NORMAL_R,
@@ -319,8 +336,7 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_NORMAL_L);
 
                ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.WHITE,
-                               ColorResources.BLACK,
-                               ImageResources.DROP_DOWN_BOX_HOVER_LT,
+                               ColorResources.WHITE, ImageResources.DROP_DOWN_BOX_HOVER_LT,
                                ImageResources.DROP_DOWN_BOX_HOVER_T,
                                ImageResources.DROP_DOWN_BOX_HOVER_RT,
                                ImageResources.DROP_DOWN_BOX_HOVER_R,
@@ -330,8 +346,7 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_HOVER_L);
 
                ninePatchResourceMap.setImages(WSTATE.SELECTED, ColorResources.WHITE,
-                               ColorResources.BLACK,
-                               ImageResources.DROP_DOWN_BOX_SELECTED_LT,
+                               ColorResources.WHITE, ImageResources.DROP_DOWN_BOX_SELECTED_LT,
                                ImageResources.DROP_DOWN_BOX_SELECTED_T,
                                ImageResources.DROP_DOWN_BOX_SELECTED_RT,
                                ImageResources.DROP_DOWN_BOX_SELECTED_R,
@@ -340,5 +355,14 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_SELECTED_LB,
                                ImageResources.DROP_DOWN_BOX_SELECTED_L);
 
+               ninePatchResourceMap.setImages(WSTATE.DISABLE_ON, ColorResources.WHITE,
+                               ColorResources.WHITE, ImageResources.TEXT_INPUT_BOX_NORMAL_LT,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_T,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_RT,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_R,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_RB,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_B,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_LB,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_L);
        }
 }
index d2bddee..6d69b42 100644 (file)
@@ -65,6 +65,24 @@ public class TextInputBox extends NinePatchBox{
                createText();
        }
 
+       @Override
+       public void setEnabled(boolean enabled) {
+               if (enabled) {
+                       setState(WSTATE.NORMAL);
+                       text.setForeground(ColorResources.CONTENT_FONT.getColor());
+               } else {
+                       setState(WSTATE.DISABLE_ON);
+                       text.setForeground(ColorResources.TEXTBOX_DISABLE.getColor());
+               }
+               super.setEnabled(enabled);
+
+       }
+
+       @Override
+       public void redraw() {
+               super.redraw();
+               text.redraw();
+       }
 
        @Override
        public NinePatchResourceMap getNinePatchResourceMap() {
@@ -211,6 +229,15 @@ public class TextInputBox extends NinePatchBox{
                                ImageResources.TEXT_INPUT_BOX_SELECT_LB,
                                ImageResources.TEXT_INPUT_BOX_SELECT_L);
 
+               ninePatchResourceMap.setImages(WSTATE.DISABLE_ON, ColorResources.WHITE,
+                               ColorResources.BLACK, ImageResources.TEXT_INPUT_BOX_NORMAL_LT,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_T,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_RT,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_R,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_RB,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_B,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_LB,
+                               ImageResources.TEXT_INPUT_BOX_NORMAL_L);
        }
 
 
index de7f7cf..78dbaf1 100644 (file)
@@ -90,6 +90,10 @@ public class Modifier {
                }
 
                if (newVM.screenSize != oldVM.screenSize) {
+                       if (property.getConfiguration().getDevice().getDisplay().getScreenSize() == null) {
+                               property.getConfiguration().getDevice().getDisplay().setScreenSize(
+                                               EmulatorVMList.getInstance().getObjectFactory().createDisplayTypeScreenSize());
+                       }
                        property.getConfiguration().getDevice().getDisplay().getScreenSize().setValue(newVM.screenSize);
                }