VMButton: Changed VMButton
authorminkee.lee <minkee.lee@samsung.com>
Wed, 13 May 2015 09:41:14 +0000 (18:41 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Wed, 13 May 2015 10:02:34 +0000 (19:02 +0900)
- Added custom VMButton.
- Added skin shape factor for VMButton.

Change-Id: Ibb3e36865590ce22ff2d88300bf661ccccece2ae
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
common-project/src/org/tizen/emulator/manager/plugin/PluginImageResources.java
common-project/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java
common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/ui/widgets/VMButton.java
common-project/src/org/tizen/emulator/manager/ui/widgets/VMCreateButton.java

index 1c391ac..ae81d15 100644 (file)
@@ -56,7 +56,10 @@ public enum PluginImageResources {
        BUTTON_LAUNCH_DISABLE("button_launch_dis"),
        BUTTON_LAUNCH_NOMAL("button_launch_nml"),
        BUTTON_LAUNCH_HOVER("button_launch_hover"),
-       BUTTON_LAUNCH_PUSH("button_launch_pushed");
+       BUTTON_LAUNCH_PUSH("button_launch_pushed"),
+
+       VM_IMAGE_CUSTOM_HOVER("emulator_list_custom_image_hover"),
+       VM_IMAGE_CUSTOM_NORMAL("emulator_list_custom_image_nml");
 
        String name;
        Map<String,Image> image;
@@ -74,6 +77,14 @@ public enum PluginImageResources {
                this.frames = new HashMap<String, ImageData[]>();
        }
 
+       public Image getImage(String platformName, String shape) {
+               String group = platformName;
+               if (shape != null && !shape.isEmpty()) {
+                       group += "-" + shape;
+               }
+               return getImage(group);
+       }
+
        // TODO
        public Image getImage(String platformName) {
                Image i = image.get(platformName);
index 0736e4a..bdde3a7 100644 (file)
@@ -40,13 +40,14 @@ import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.platform.BaseImage;
 import org.tizen.emulator.manager.ui.widgets.VMButton;
 import org.tizen.emulator.manager.ui.widgets.VMCreateButton;
+import org.tizen.emulator.manager.vms.VMProperty;
 
 public class VMButtonFactory {
        private static ArrayList<VMButton> buttons = new ArrayList<VMButton> ();
        private static int selectedIndex = 0;
 
-       public static VMButton getButton(Composite parent, BaseImage base) {
-               VMButton b = new VMButton(parent, SWT.NONE, base);
+       public static VMButton getButton(Composite parent, BaseImage base, VMProperty property) {
+               VMButton b = new VMButton(parent, SWT.NONE, base, property);
                b.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
diff --git a/common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java b/common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java
new file mode 100644 (file)
index 0000000..1903260
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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 <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.widgets;
+
+public interface IVMButtonPainter {
+
+       // Offset in VMButton.
+       public int getLaunchButtonBottomOffset();
+       public int getLaunchButtonLeftOffset();
+}
index 1ed8f04..8d28be8 100644 (file)
@@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.plugin.ExtensionItem;
 import org.tizen.emulator.manager.plugin.PluginImageResources;
 import org.tizen.emulator.manager.plugin.PluginStringResources;
@@ -59,6 +60,7 @@ import org.tizen.emulator.manager.resources.FontResources;
 import org.tizen.emulator.manager.ui.MainDialog;
 import org.tizen.emulator.manager.ui.VMsMainView;
 import org.tizen.emulator.manager.ui.list.VMButtonFactory;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
 import org.tizen.emulator.manager.vms.helper.HelperClass;
@@ -75,9 +77,13 @@ public class VMButton extends ImageButton {
        private int LAUNCH_BUTTON_WIDTH = 40;
        private int LAUNCH_BUTTON_HEIGHT =14;
 
-       public VMButton(Composite parent, int style, BaseImage base) {
+       private int launchButtonLeftOffset;
+       private int launchButtonBottomOffset;
+
+       public VMButton(Composite parent, int style, BaseImage base, VMProperty property) {
                super(parent, style);
                this.baseImage = base;
+               this.property = property;
                button = this;
 
                this.setLayout(new FormLayout());
@@ -87,10 +93,15 @@ public class VMButton extends ImageButton {
                        item = base.getPlatform().getPlugin()
                                                .getExtensionItem(PluginStringResources.VMButtonPainter);
                }
+
                if (item != null) {
                        this.setPainListener((PaintListener)item.createClass());
+                       launchButtonLeftOffset = ((IVMButtonPainter)item.createClass()).getLaunchButtonLeftOffset();
+                       launchButtonBottomOffset = ((IVMButtonPainter)item.createClass()).getLaunchButtonBottomOffset();
                } else {
                        this.setPainListener(VMButtonPaintListener);
+                       launchButtonLeftOffset = 13;
+                       launchButtonBottomOffset = 13;
                }
 
                settingImage();
@@ -100,15 +111,23 @@ public class VMButton extends ImageButton {
        }
 
        private void settingImage() {
+               String shape="";
+               if (button.getProperty() != null) {
+                       Skin skin = button.getProperty().getPropertyValue().skin;
+                       if (skin != null && skin.getSkinShape() == SKIN_SHAPE.CIRCLE) {
+                               shape = skin.getSkinShape().toString();
+                       }
+               }
+
                for (WSTATE s : WSTATE.values()) {
-                       images.add(s.getId(), PluginImageResources.VM_IMAGE_NOMAL.getImage(baseImage.getPlatform().getPluginPlatformName()));
+                       images.add(s.getId(), PluginImageResources.VM_IMAGE_NOMAL.getImage(baseImage.getPlatform().getPluginPlatformName(), shape));
                }
 
                BUTTON_WIDTH = images.get(0).getImageData().width;
                BUTTON_HEIGHT = images.get(0).getImageData().height;
 
-               images.set(WSTATE.HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName()));
-               images.set(WSTATE.SELECTED_HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName()));
+               images.set(WSTATE.HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName(), shape));
+               images.set(WSTATE.SELECTED_HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName(), shape));
        }
 
        @Override
@@ -146,8 +165,8 @@ public class VMButton extends ImageButton {
 
                FormData data = new FormData();
                //data.top      = new FormAttachment(0, 119 + H_OFFSET);
-               data.bottom = new FormAttachment(100, -10 - 3);
-               data.left       = new FormAttachment(0, 10 + 3);
+               data.bottom = new FormAttachment(100, - launchButtonBottomOffset);
+               data.left       = new FormAttachment(0, + launchButtonLeftOffset);
                data.width      = LAUNCH_BUTTON_WIDTH;
                data.height     = LAUNCH_BUTTON_HEIGHT;
 
@@ -200,12 +219,12 @@ public class VMButton extends ImageButton {
                }
        }
 
-       public void setProperty(VMProperty property) {
-               this.property = property;
+       public void setProperty() {
                this.setToolTipText(property.getName());
                settingTitleWidth();
        }
 
+
        public VMProperty getProperty() {
                return property;
        }
index c5a0962..50428d7 100644 (file)
@@ -19,7 +19,7 @@ public class VMCreateButton extends VMButton {
        private VMCreateButton button;
 
        public VMCreateButton(Composite parent, int style, BaseImage base) {
-               super(parent, style, base);
+               super(parent, style, base, null);
                // delete launchButton
                launchButton.dispose();
                launchButton = null;