vm-modify: check device-template item.
authorminkee.lee <minkee.lee@samsung.com>
Thu, 22 Oct 2015 05:46:15 +0000 (14:46 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Thu, 22 Oct 2015 06:12:23 +0000 (15:12 +0900)
- Show error if device-template is not selected.
  (use default tooltip)

Change-Id: Ie24b234e5a9a5b3c9ec3c68530dd4f71aec0ac9b
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
26 files changed:
resource/renewal/res/9p_error_box_b.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_l.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_lb.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_lt.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_r.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_rb.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_rt.png [new file with mode: 0644]
resource/renewal/res/9p_error_box_t.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_b.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_l.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_lb.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_lt.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_r.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_rb.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_rt.png [new file with mode: 0644]
resource/renewal/res/9p_text_input_box_error_t.png [new file with mode: 0644]
resource/renewal/res/icon_state_error.png [new file with mode: 0644]
resource/renewal/res/icon_state_ok.png [new file with mode: 0644]
src/org/tizen/emulator/manager/renewal/resources/ImageResources.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.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/ComboBoxPopup.java
src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMCombo.java
src/org/tizen/emulator/manager/ui/renewal/widgets/WSTATE.java

diff --git a/resource/renewal/res/9p_error_box_b.png b/resource/renewal/res/9p_error_box_b.png
new file mode 100644 (file)
index 0000000..08cf360
Binary files /dev/null and b/resource/renewal/res/9p_error_box_b.png differ
diff --git a/resource/renewal/res/9p_error_box_l.png b/resource/renewal/res/9p_error_box_l.png
new file mode 100644 (file)
index 0000000..6bba734
Binary files /dev/null and b/resource/renewal/res/9p_error_box_l.png differ
diff --git a/resource/renewal/res/9p_error_box_lb.png b/resource/renewal/res/9p_error_box_lb.png
new file mode 100644 (file)
index 0000000..a50ba19
Binary files /dev/null and b/resource/renewal/res/9p_error_box_lb.png differ
diff --git a/resource/renewal/res/9p_error_box_lt.png b/resource/renewal/res/9p_error_box_lt.png
new file mode 100644 (file)
index 0000000..33694f6
Binary files /dev/null and b/resource/renewal/res/9p_error_box_lt.png differ
diff --git a/resource/renewal/res/9p_error_box_r.png b/resource/renewal/res/9p_error_box_r.png
new file mode 100644 (file)
index 0000000..217679f
Binary files /dev/null and b/resource/renewal/res/9p_error_box_r.png differ
diff --git a/resource/renewal/res/9p_error_box_rb.png b/resource/renewal/res/9p_error_box_rb.png
new file mode 100644 (file)
index 0000000..eb6a9a1
Binary files /dev/null and b/resource/renewal/res/9p_error_box_rb.png differ
diff --git a/resource/renewal/res/9p_error_box_rt.png b/resource/renewal/res/9p_error_box_rt.png
new file mode 100644 (file)
index 0000000..f680c63
Binary files /dev/null and b/resource/renewal/res/9p_error_box_rt.png differ
diff --git a/resource/renewal/res/9p_error_box_t.png b/resource/renewal/res/9p_error_box_t.png
new file mode 100644 (file)
index 0000000..6993669
Binary files /dev/null and b/resource/renewal/res/9p_error_box_t.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_b.png b/resource/renewal/res/9p_text_input_box_error_b.png
new file mode 100644 (file)
index 0000000..ce2bcc4
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_b.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_l.png b/resource/renewal/res/9p_text_input_box_error_l.png
new file mode 100644 (file)
index 0000000..75a1459
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_l.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_lb.png b/resource/renewal/res/9p_text_input_box_error_lb.png
new file mode 100644 (file)
index 0000000..fd79016
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_lb.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_lt.png b/resource/renewal/res/9p_text_input_box_error_lt.png
new file mode 100644 (file)
index 0000000..9a21b8d
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_lt.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_r.png b/resource/renewal/res/9p_text_input_box_error_r.png
new file mode 100644 (file)
index 0000000..bf600a4
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_r.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_rb.png b/resource/renewal/res/9p_text_input_box_error_rb.png
new file mode 100644 (file)
index 0000000..7892482
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_rb.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_rt.png b/resource/renewal/res/9p_text_input_box_error_rt.png
new file mode 100644 (file)
index 0000000..6d31199
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_rt.png differ
diff --git a/resource/renewal/res/9p_text_input_box_error_t.png b/resource/renewal/res/9p_text_input_box_error_t.png
new file mode 100644 (file)
index 0000000..888b173
Binary files /dev/null and b/resource/renewal/res/9p_text_input_box_error_t.png differ
diff --git a/resource/renewal/res/icon_state_error.png b/resource/renewal/res/icon_state_error.png
new file mode 100644 (file)
index 0000000..e33056d
Binary files /dev/null and b/resource/renewal/res/icon_state_error.png differ
diff --git a/resource/renewal/res/icon_state_ok.png b/resource/renewal/res/icon_state_ok.png
new file mode 100644 (file)
index 0000000..9f85936
Binary files /dev/null and b/resource/renewal/res/icon_state_ok.png differ
index e09a39d..6281dde 100644 (file)
@@ -100,6 +100,31 @@ public enum ImageResources {
        BLUE_BTN_NORMAL_RT("9p_blue_btn_normal_rt"),
        BLUE_BTN_NORMAL_T("9p_blue_btn_normal_t"),
 
+       // 9 patch error box
+       INPUT_BOX_ERROR_B("9p_text_input_box_error_b"),
+       INPUT_BOX_ERROR_L("9p_text_input_box_error_l"),
+       INPUT_BOX_ERROR_LB("9p_text_input_box_error_lb"),
+       INPUT_BOX_ERROR_LT("9p_text_input_box_error_lt"),
+       INPUT_BOX_ERROR_R("9p_text_input_box_error_r"),
+       INPUT_BOX_ERROR_RB("9p_text_input_box_error_rb"),
+       INPUT_BOX_ERROR_RT("9p_text_input_box_error_rt"),
+       INPUT_BOX_ERROR_T("9p_text_input_box_error_t"),
+
+
+       // 9 patch error msg box
+       ERROR_MSG_BOX_B("9p_error_box_b"),
+       ERROR_MSG_BOX_L("9p_error_box_l"),
+       ERROR_MSG_BOX_LB("9p_error_box_lb"),
+       ERROR_MSG_BOX_LT("9p_error_box_lt"),
+       ERROR_MSG_BOX_R("9p_error_box_r"),
+       ERROR_MSG_BOX_RB("9p_error_box_rb"),
+       ERROR_MSG_BOX_RT("9p_error_box_rt"),
+       ERROR_MSG_BOX_T("9p_error_box_t"),
+
+       // state icon
+       ICON_STATE_OK("icon_state_ok"),
+       ICON_STATE_ERROR("icon_state_error"),
+
        // text input box
        TEXT_INPUT_BOX_HOVER_B("9p_text_input_box_hover_b"),
        TEXT_INPUT_BOX_HOVER_L("9p_text_input_box_hover_l"),
index 0c7c309..25d6572 100644 (file)
@@ -36,8 +36,10 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
 import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
 
@@ -46,6 +48,7 @@ public abstract class ComboItem extends ModifyDialogItem {
 
        protected ComboBox comboBox;
 
+
        public ComboItem(String name, String title) {
                super(name, title);
        }
@@ -96,6 +99,39 @@ public abstract class ComboItem extends ModifyDialogItem {
                return comboBox.getSelectedData();
        }
 
+       public void setItemState(boolean isError, int contentRight, String msg) {
+               // change combobox border
+               comboBox.setError(isError);
+
+               if (isError) {
+                       // show error icon
+                       if (stateIconCanvas == null || stateIconCanvas.isDisposed()) {
+                               stateIconCanvas = new Canvas(item.getBody(), SWT.NONE);
+                               stateIconCanvas.setBackgroundImage(ImageResources.ICON_STATE_ERROR.getImage());
+                       }
+                       int width = ERROR_ICON_SIZE, height = ERROR_ICON_SIZE;
+                       FormData data = new FormData(width, height);
+                       int left = contentRight + ERROR_ICON_SPACING;
+                       data.left = new FormAttachment(0, left);
+                       data.top = new FormAttachment(0, (item.getItemHeight() - height) / 2);
+                       stateIconCanvas.setLayoutData(data);
+                       stateIconCanvas.setToolTipText(msg);
+                       stateIconCanvas.moveAbove(null);
+
+               } else {
+                       if (stateIconCanvas == null || stateIconCanvas.isDisposed()) {
+                               return;
+                       }
+                       // hide error icon
+                       FormData data = new FormData(0, 0);
+                       stateIconCanvas.setLayoutData(data);
+                       item.getBody().layout(true,true);
+
+               }
+
+       }
+
+
        protected void createCombo(ModifyItem item, int width) {
 //             item.setBodyLayoutDefault();
 //
index 72b6894..abc8b21 100644 (file)
@@ -32,6 +32,7 @@
 package org.tizen.emulator.manager.ui.renewal.item.modify.common;
 
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.ui.renewal.dialog.ModifyDialog;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
@@ -51,6 +52,12 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
 
        private ModifyDialog dialog;
 
+       protected Canvas stateIconCanvas;
+
+       public static final int ERROR_ICON_SIZE = 16;
+       public static final int ERROR_ICON_SPACING = 6;
+       public static final int ERROR_ICON_SPACING_INNER = 3;
+
        // decide item's visibility in dialog
        private final boolean isUse = true;
 
@@ -119,6 +126,8 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
 
        @Override
        public boolean isValid() {
+               // Override this for item validation.
+               // If this return false, confirm button is disabled.
                return true;
        }
 
index c7e2352..395092e 100644 (file)
@@ -37,6 +37,7 @@ import org.tizen.emulator.manager.platform.Profile;
 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.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.TreeItemTitle;
@@ -148,4 +149,21 @@ public class DeviceTemplateItem extends ComboItem {
 
                selectComboItem(index, notifySelect);
        }
+
+
+
+       @Override
+       public boolean isValid() {
+               String msg = "";
+               boolean isValid = true;
+               if (template == null) {
+                       isValid = false;
+                       msg = "Please select device-template.";
+               }
+               setItemState(!isValid, ModifyItem.BODY_MARGIN_LEFT + COMBO_WIDTH, msg);
+
+               return isValid;
+
+
+       }
 }
index db6b81d..efe1471 100644 (file)
@@ -229,6 +229,7 @@ public class ComboBox extends NinePatchBox {
                redraw();
        }
 
+
        @Override
        protected void draw(PaintEvent e) {
                drawArrow(e);
@@ -277,19 +278,34 @@ public class ComboBox extends NinePatchBox {
 
        }
 
+
+       public void setError(boolean isError) {
+               if (isError) {
+                       setState(WSTATE.ERROR);
+
+               } else {
+                       // TODO is enough ?
+                       setState(WSTATE.NORMAL);
+               }
+               redraw();
+       }
+
+
+
+
        private void addMouseListener() {
                Listener mouseListener = new Listener() {
 
                        @Override
                        public void handleEvent(Event e) {
                                if (e.type == SWT.MouseEnter) {
-                                       if (popup.isClosed()) {
+                                       if (popup.isClosed() && getState() != WSTATE.ERROR ) {
                                                setState(WSTATE.HOVER);
                                                redraw();
                                        }
 
                                } else if (e.type == SWT.MouseExit) {
-                                       if (popup.isClosed()) {
+                                       if (popup.isClosed() && getState() != WSTATE.ERROR ) {
                                                setState(WSTATE.NORMAL);
                                                redraw();
                                        }
@@ -300,9 +316,11 @@ public class ComboBox extends NinePatchBox {
                                        // }
                                        Rectangle rect = ((Canvas) e.widget).getClientArea();
                                        if (rect.contains(e.x, e.y)) {
-                                               setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER
-                                                               : WSTATE.SELECTED);
-                                               redraw();
+                                               if (getState() != WSTATE.ERROR) {
+                                                       setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER
+                                                                       : WSTATE.SELECTED);
+                                                       redraw();
+                                               }
                                                ((Composite)e.widget).setFocus();
                                                popup.changePopup();
                                        }
@@ -327,7 +345,8 @@ public class ComboBox extends NinePatchBox {
        private static void initNinePatchResourceMap() {
                ninePatchResourceMap = new NinePatchResourceMap();
                ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE,
-                               ColorResources.WHITE, 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,
@@ -337,7 +356,8 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_NORMAL_L);
 
                ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.WHITE,
-                               ColorResources.WHITE, 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,
@@ -347,7 +367,8 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_HOVER_L);
 
                ninePatchResourceMap.setImages(WSTATE.SELECTED, ColorResources.WHITE,
-                               ColorResources.WHITE, 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,
@@ -357,7 +378,8 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.DROP_DOWN_BOX_SELECTED_L);
 
                ninePatchResourceMap.setImages(WSTATE.DISABLE_ON, ColorResources.WHITE,
-                               ColorResources.WHITE, ImageResources.TEXT_INPUT_BOX_NORMAL_LT,
+                               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,
@@ -365,5 +387,16 @@ public class ComboBox extends NinePatchBox {
                                ImageResources.TEXT_INPUT_BOX_NORMAL_B,
                                ImageResources.TEXT_INPUT_BOX_NORMAL_LB,
                                ImageResources.TEXT_INPUT_BOX_NORMAL_L);
+
+               ninePatchResourceMap.setImages(WSTATE.ERROR, ColorResources.WHITE,
+                               ColorResources.WHITE,
+                               ImageResources.INPUT_BOX_ERROR_LT,
+                               ImageResources.INPUT_BOX_ERROR_T,
+                               ImageResources.INPUT_BOX_ERROR_RT,
+                               ImageResources.INPUT_BOX_ERROR_R,
+                               ImageResources.INPUT_BOX_ERROR_RB,
+                               ImageResources.INPUT_BOX_ERROR_B,
+                               ImageResources.INPUT_BOX_ERROR_LB,
+                               ImageResources.INPUT_BOX_ERROR_L);
        }
 }
index 0477ef5..a4084d8 100644 (file)
@@ -227,8 +227,8 @@ public class ComboBoxPopup {
                if (popupShell == null) {
                        return;
                }
-               parentComboBox.setState(WSTATE.NORMAL);
-               parentComboBox.redraw();
+//             parentComboBox.setState(WSTATE.NORMAL);
+//             parentComboBox.redraw();
                popupShell.close();
        }
 
index 1c7c7d4..a3c0c5e 100644 (file)
@@ -58,7 +58,7 @@ public class CreateVMCombo extends Canvas {
        private static int COMBO_HEIGHT = 26;
        private static int ARROW_WIDTH = 18;
 
-       private Composite parent;
+       private final Composite parent;
 
        private int width = COMBO_WIDTH;
        private int height = COMBO_HEIGHT;
@@ -315,11 +315,14 @@ public class CreateVMCombo extends Canvas {
                int i = 0;
                for (WSTATE s : WSTATE.values()) {
                        i = s.getId();
+                       if (i >= images.size()) {
+                               break;
+                       }
                        WidgetHelper.tryDispose(images.get(i));
                }
        }
 
-       private Listener comboMouseListener = new Listener() {
+       private final Listener comboMouseListener = new Listener() {
                @Override
                public void handleEvent(Event event) {
                        if (isEnabled()) {
@@ -381,7 +384,7 @@ public class CreateVMCombo extends Canvas {
        private static int ARROW_OFFSET = 4;
        private static int LEFT_IMAGE_OFFSET = 6;
        private static int LEFT_TEXT_OFFSET = 20;
-       private PaintListener comboPaintListener = new PaintListener() {
+       private final PaintListener comboPaintListener = new PaintListener() {
                @Override
                public void paintControl(PaintEvent e) {
                        Rectangle rect = ((Canvas) e.widget).getClientArea();
@@ -425,7 +428,7 @@ public class CreateVMCombo extends Canvas {
                }
        };
 
-       private DisposeListener disposeListener = new DisposeListener() {
+       private final DisposeListener disposeListener = new DisposeListener() {
                @Override
                public void widgetDisposed(DisposeEvent arg0) {
                        disposeImages();
@@ -433,7 +436,7 @@ public class CreateVMCombo extends Canvas {
        };
 
        //
-       private NinePatchResourceInfo hoverInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+       private final NinePatchResourceInfo hoverInfo = new NinePatchResourceInfo(ColorResources.WHITE,
                        ColorResources.TABLE_VIEWER_BG,
                        ImageResources.DROP_DOWN_BOX_HOVER_LT,
                        ImageResources.DROP_DOWN_BOX_HOVER_T,
@@ -444,7 +447,7 @@ public class CreateVMCombo extends Canvas {
                        ImageResources.DROP_DOWN_BOX_HOVER_LB,
                        ImageResources.DROP_DOWN_BOX_HOVER_L);
 
-       private NinePatchResourceInfo nomalInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+       private final NinePatchResourceInfo nomalInfo = new NinePatchResourceInfo(ColorResources.WHITE,
                        ColorResources.TABLE_VIEWER_BG,
                        ImageResources.DROP_DOWN_BOX_NORMAL_LT,
                        ImageResources.DROP_DOWN_BOX_NORMAL_T,
@@ -455,7 +458,7 @@ public class CreateVMCombo extends Canvas {
                        ImageResources.DROP_DOWN_BOX_NORMAL_LB,
                        ImageResources.DROP_DOWN_BOX_NORMAL_L);
 
-       private NinePatchResourceInfo selectedInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+       private final NinePatchResourceInfo selectedInfo = new NinePatchResourceInfo(ColorResources.WHITE,
                        ColorResources.TABLE_VIEWER_BG,
                        ImageResources.DROP_DOWN_BOX_SELECTED_LT,
                        ImageResources.DROP_DOWN_BOX_SELECTED_T,
index 8c5e67f..c0ad098 100644 (file)
@@ -38,7 +38,8 @@ public enum WSTATE {
        SELECTED_HOVER(4),
        SELECTED_PUSH(5),
        DISABLE_ON(6),
-       DISABLE_OFF(7);
+       DISABLE_OFF(7),
+       ERROR(8);
 
        private int id;
        WSTATE(int id) {