GL-option: add GL-version option
authorminkee.lee <minkee.lee@samsung.com>
Wed, 2 Dec 2015 05:43:24 +0000 (14:43 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 3 Dec 2015 06:51:55 +0000 (15:51 +0900)
- Add GL-version option for Mac OS and
  change ItemTitle for no-icon title.
- GL-version is available when GPU acceleration is ON.

Change-Id: I3ef0912e99bab9fa4528b1d93c3caa3627c102a1
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
17 files changed:
src/org/tizen/emulator/manager/template/renewal/VMTemplateUtil.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/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/common/SkinItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/IconItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/SubItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/SubTreeItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/TreeItemTitle.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/AdvancedSkinItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/FileSharingItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/GLVersionItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/HWSupportItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/OnOffSubItemComp.java

index e3a3a42..65f45dd 100644 (file)
@@ -211,6 +211,15 @@ public class VMTemplateUtil {
        }
 
 
+       public static Map<String, String> getOptionMap(List<VMItemOption> optionList) {
+               Map<String, String> optionMap = new HashMap<String, String>();
+               for (VMItemOption option : optionList) {
+                       optionMap.put(option.getName(), option.getValue());
+               }
+               return optionMap;
+       }
+
+
        public static List<String> getOptionList(List<VMItemOption> optionList) {
                List<String> resultList = new ArrayList<String>();
                for (VMItemOption option : optionList) {
index 1c3333f..b7645e1 100644 (file)
@@ -55,6 +55,7 @@ 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;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.GLVersionItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.HWSupportItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetConnectTypeItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetDnsItem;
@@ -221,6 +222,10 @@ public class CommonItemListFactory implements IItemListFactory{
                } else if (name.equals(ItemName.CAMERA_LEGACY)) {
                        itemList.add(new CameraLegacyItem(name, title, VMTemplateUtil.getNumColomnOption(item),
                                        treeRoot, VMTemplateUtil.getCheckBoxDataList(item)));
+
+               } else if (name.equals(ItemName.GL_VERSION)) {
+                       itemList.add(new GLVersionItem(name, title,
+                                       VMTemplateUtil.getOptionMap(item.getOptions())));
                }
        }
 
index 4b7f946..f0b8b00 100644 (file)
@@ -120,7 +120,7 @@ public class CommonOptionFactory implements IOptionFactory {
                        optionList.add(Option.getInstance(CPUSupportOption.class));
                        optionList.add(Option.getInstance(GPUSupportOption.class));
 
-               } else if (name.equals(ItemName.GL_VERSION)) { // TODO
+               } else if (name.equals(ItemName.GL_VERSION)) {
                        optionList.add(Option.getInstance(GLVersionOption.class));
 
                } else if (name.equals(ItemName.NETWORK)) {
index 831ce7e..7957df1 100644 (file)
@@ -136,6 +136,10 @@ public abstract class ComboItem extends ModifyDialogItem {
                comboBox.setEnabled(enable);
        }
 
+       protected void setItemEnable(boolean enable) {
+               comboBox.setEnabled(enable);
+               item.setTitleEnable(enable);
+       }
 
 
 }
index ae11857..e7b0cc0 100644 (file)
@@ -165,10 +165,12 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
                this.itemListComp = itemlistComp;
        }
 
+
        public ItemListComp getItemListComp() {
                return itemListComp;
        }
 
+
        protected ItemTitle createIconTitle(ModifyItem item, ImageResources icon) {
                if (item instanceof SubTreeModifyItem) {
                        return new SubTreeItemTitle(item.getItemComp(), title, icon);
@@ -177,6 +179,12 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
        }
 
 
+       protected ItemTitle createItemTitle(ModifyItem item) {
+               return new ItemTitle(item.getItemComp(), title, ItemTitle.TITLE_MARGIN_LEFT,
+                               ItemTitle.TITLE_MARGIN_LEFT, ItemTitle.TITLE_BACKGROUND);
+       }
+
+
        @Override
        public boolean isValid() {
                // Override this for item validation.
index 13efab2..b6804f8 100644 (file)
@@ -55,6 +55,10 @@ public class SkinItem extends ComboItem {
        protected List<Skin> skinList;
        protected SKIN_SHAPE imageSkinShape;
 
+       public SkinItem(String title) {
+               super(NAME, title);
+       }
+
        public SkinItem() {
                super(NAME, TITLE);
                // TODO Auto-generated constructor stub
index d4e4f61..2d2f5a8 100644 (file)
@@ -45,18 +45,33 @@ public class IconItemTitle extends ItemTitle {
        private Canvas iconCanvas;
        private final ImageResources iconResource;
 
+       public static final int ICON_WIDTH = 18;
+       public static final int ICON_HEIGHT = 18;
+       private static final int TITLE_SPACING = 8;
        private static int TITLE_MARGIN_LEFT = 15;
        private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
 
        public IconItemTitle(Composite parent, String title, ImageResources iconResource) {
-               super(parent, title, TITLE_MARGIN_LEFT, background);
+               this(parent, title, TITLE_MARGIN_LEFT, iconResource, background);
+       }
+
+       public IconItemTitle(Composite parent, String title, int marginLeft,
+                       ImageResources iconResource, ColorResources background) {
+               super(parent, title, marginLeft,
+                               marginLeft + ICON_WIDTH + TITLE_SPACING, background);
                this.iconResource = iconResource;
        }
 
        @Override
        public void create(boolean drawLine) {
                super.create(drawLine);
-               makeIcon();
+
+               if (iconResource == null) {
+                       return;
+
+               } else {
+                       makeIcon();
+               }
        }
 
        private void makeIcon() {
@@ -67,10 +82,6 @@ public class IconItemTitle extends ItemTitle {
                iconCanvas = new Canvas(this, SWT.NONE);
                iconCanvas.setLayoutData(data);
 
-               // draw icon
-               if (iconResource == null) {
-                       return;
-               }
                iconCanvas.addPaintListener(new PaintListener() {
                        @Override
                        public void paintControl(PaintEvent e) {
index b3506ac..04626a9 100644 (file)
@@ -44,26 +44,27 @@ import org.tizen.emulator.manager.renewal.resources.FontResources;
 
 public class ItemTitle extends Canvas{
 
-       public static final int TITLE_SPACING = 8;
        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;
-       protected final int ICON_HEIGHT = 18;
+       public static int TITLE_MARGIN_LEFT = 15;
+       public static ColorResources TITLE_BACKGROUND =
+                       ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
 
        protected final String title;
        private int marginLeft = 0;
+       private int titleIndent = 0;
        protected final ColorResources background;
 
        boolean isDrawBottomLine = true;
 
        protected boolean isTitleEnable = true;
 
-       public ItemTitle(Composite parent, String title, int marginLeft, ColorResources background) {
+       public ItemTitle(Composite parent, String title, int marginLeft, int titleIndent, ColorResources background) {
                super(parent, SWT.NONE);
                this.title = title;
                this.marginLeft = marginLeft;
+               this.titleIndent = titleIndent;
                this.background = background;
        }
 
@@ -83,7 +84,7 @@ public class ItemTitle extends Canvas{
                redraw();
        }
 
-       private void init() {
+       protected void init() {
                GridData data = new GridData();
                data.grabExcessVerticalSpace = true;
                data.verticalAlignment = SWT.FILL;
@@ -121,7 +122,7 @@ public class ItemTitle extends Canvas{
                                Point textExt = gc.textExtent(title);
                                int titleY = (itemHeight - textExt.y) / 2;
                                gc.drawText(title,
-                                               marginLeft + ICON_WIDTH + TITLE_SPACING, titleY);
+                                               titleIndent, titleY);
 
                                // draw under line
                                if (isDrawBottomLine) {
index f61eb92..109ab3b 100644 (file)
@@ -52,7 +52,7 @@ public class SubItemTitle extends ItemTitle{
 
        public SubItemTitle(Composite parent, String title,
                        ColorResources background, boolean drawVerticalLine, int titleWidth ) {
-               super(parent, title, MARGIN_LEFT, background);
+               super(parent, title, MARGIN_LEFT, MARGIN_LEFT, background);
                this.drawVerticalLine = drawVerticalLine;
                this.titleWidth = titleWidth;
        }
@@ -69,7 +69,8 @@ public class SubItemTitle extends ItemTitle{
                makeTitle(drawBottomLine);
        }
 
-       private void init() {
+       @Override
+       protected void init() {
                GridData data = new GridData();
                data.grabExcessVerticalSpace = true;
                data.verticalAlignment = SWT.FILL;
index 96a0e59..eb6d5a9 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
 
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.renewal.resources.ColorResources;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
 
-public class SubTreeItemTitle extends ItemTitle {
-
-       private Canvas iconCanvas;
-       private final ImageResources iconResource;
+public class SubTreeItemTitle extends IconItemTitle {
 
        private static int TITLE_MARGIN_LEFT = 23;
        private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_SUB_BACKGROUDN;
 
        public SubTreeItemTitle(Composite parent, String title, ImageResources iconResource) {
-               super(parent, title, TITLE_MARGIN_LEFT, background);
-               this.iconResource = iconResource;
-       }
-
-
-       @Override
-       public void create(boolean drawLine) {
-               super.create(drawLine);
-               makeIcon();
-       }
-
-       private void makeIcon() {
-               // init
-               GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT);
-               data.verticalAlignment = SWT.CENTER;
-               data.grabExcessVerticalSpace = true;
-               iconCanvas = new Canvas(this, SWT.NONE);
-               iconCanvas.setLayoutData(data);
-
-               // draw icon
-               if (iconResource == null) {
-                       return;
-               }
-
-               iconCanvas.addPaintListener(new PaintListener() {
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               GC gc = e.gc;
-                               gc.drawImage(iconResource.getImage(), 0, 0);
-                       }
-               });
+               super(parent, title, TITLE_MARGIN_LEFT, iconResource, background);
        }
 }
index 6c1e718..a623fec 100644 (file)
@@ -43,21 +43,21 @@ import org.eclipse.swt.widgets.Listener;
 import org.tizen.emulator.manager.renewal.resources.ColorResources;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
 
-public class TreeItemTitle extends ItemTitle {
+public class TreeItemTitle extends IconItemTitle {
 
        private Canvas arrowCanvas;
        private boolean isExpanded = true;
 
        private final TreeModifyItem treeRoot;
 
-       private static int TITLE_MARGIN_LEFT = 15;
        private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
        private static ImageResources ARROW_EXPANDED = ImageResources.ICON_TITLE_TREE_EXPANDED;
        private static ImageResources ARROW_CLOSED = ImageResources.ICON_TITLE_TREE_CLOSED;
 
 
        public TreeItemTitle(TreeModifyItem treeRoot, String title) {
-               super(treeRoot.getItemComp(), title, TITLE_MARGIN_LEFT, background);
+               super(treeRoot.getItemComp(), title, ItemTitle.TITLE_MARGIN_LEFT,
+                               null, background);
                this.treeRoot = treeRoot;
        }
 
@@ -69,7 +69,7 @@ public class TreeItemTitle extends ItemTitle {
 
        private void makeArrow() {
                // init
-               GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT);
+               GridData data = new GridData(IconItemTitle.ICON_WIDTH, IconItemTitle.ICON_HEIGHT);
                data.verticalAlignment = SWT.CENTER;
                data.grabExcessVerticalSpace = true;
                arrowCanvas = new Canvas(this, SWT.NONE);
index 0d3b040..a47bfd6 100644 (file)
@@ -38,10 +38,11 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
 
 public class AdvancedSkinItem extends SkinItem {
 
-       public static final int COMBO_WIDTH = 233;
+       public static final int COMBO_WIDTH = 232;
+       public static final String TITLE = "Emulator Skin";
 
        public AdvancedSkinItem() {
-               super();
+               super(TITLE);
                // TODO Auto-generated constructor stub
        }
 
@@ -49,7 +50,8 @@ public class AdvancedSkinItem extends SkinItem {
        public void create(Composite parent) {
                item = new ModifyItem(this);
                item.init(parent);
-               item.setItemTitle(createIconTitle(item, null));
+//             item.setItemTitle(createIconTitle(item, null));
+               item.setItemTitle(createItemTitle(item));
                item.create();
 
                createCombo(item, COMBO_WIDTH);
index b274692..3ee4f66 100644 (file)
@@ -43,7 +43,7 @@ public class FileSharingItem extends FileDialogItem {
        private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_FILESHARING;
        private static final String NAME="fileSharing";
        private static final String TITLE="File Sharing";
-       private final int TEXT_BOX_WIDTH = 233;
+       private final int TEXT_BOX_WIDTH = 232;
 
        private String sharingPath;
 
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/GLVersionItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/GLVersionItem.java
new file mode 100644 (file)
index 0000000..e6bbff4
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * 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.renewal.item.modify.vm;
+
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.job.CheckGPU;
+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.widgets.ComboBox;
+
+public class GLVersionItem extends ComboItem {
+
+       private final int COMBO_WIDTH = 232;
+       public static final String VER1_VER2 = "v1.1_v2.0"; //$NON-NLS-1$
+       public static final String VER2_VER3 = "v2.0_v3.0"; //$NON-NLS-1$
+
+       private final Map<String, String> optionMap;
+       String glVersion = "";
+
+       public GLVersionItem(String name, String title, Map<String, String> optionMap) {
+               super(name, title);
+               this.optionMap = optionMap;
+
+       }
+
+
+       @Override
+       public void create(Composite parent) {
+               item = new ModifyItem(this);
+               item.init(parent);
+               item.setItemTitle(createItemTitle(item));
+               item.create();
+
+               makeBody();
+
+       }
+
+       private void createDetailItem() {
+               createDetailItem(glVersion);
+       }
+
+       protected void makeBody() {
+               if (getItemListComp().isDetailMode()) {
+                       createDetailItem();
+                       return;
+               }
+
+               // create combo
+               createCombo(item, COMBO_WIDTH);
+               resetCombo();
+
+       }
+
+       // reset combo according to connect type (NAT / Bridge)
+       public void resetCombo() {
+
+               comboBox.clear();
+               if (checkActivate()) {
+                       // enable & init combo
+                       setItemEnable(true);
+                       makeComboList();
+
+                       // select item
+                       selectItem();
+
+               } else {
+                       // disable
+                       comboBox.setText("");
+                       setItemEnable(false);
+               }
+       }
+
+
+       private boolean checkActivate() {
+               boolean isActivate = true;
+               if (!CheckGPU.isGPUSupported()) {
+                       isActivate = false;
+
+               } else {
+                       isActivate = getItemListComp().getPropertyValue().getGPUAcceleration();
+               }
+
+               return isActivate;
+       }
+
+       private void makeComboList() {
+               // init list
+               if (optionMap.get(VER1_VER2) != null) {
+                       addComboItem(optionMap.get(VER1_VER2), VER1_VER2);
+               }
+               if (optionMap.get(VER2_VER3) != null) {
+                       addComboItem(optionMap.get(VER2_VER3), VER2_VER3);
+               }
+
+               // select item
+               selectItem();
+       }
+
+       private void selectItem() {
+               if (comboBox == null || comboBox.isDisposed()) {
+                       return;
+               }
+
+               int index = -1;
+               for (int i=0 ; i < getComboItemList().size() ; i++) {
+                       if (getComboItemList().get(i).equals(optionMap.get(glVersion))) {
+                               index = i;
+                               break;
+                       }
+               }
+
+               if (index == -1) {
+                       index = 0;
+                       glVersion = (String)getCobmoData(0);
+               }
+               selectComboItem(index, false);
+               comboSelected();
+       }
+
+       @Override
+       public void itemSelected(ComboBox comboBox) {
+               // This is called when combo item is selected
+               // TODO override this.
+               glVersion = (String)comboBox.getSelectedData();
+               comboSelected();
+       }
+
+       private void comboSelected() {
+               getItemListComp().checkValid();
+       }
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               glVersion = value.getSubOptionValue(getName());
+
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(getName(), glVersion);
+
+       }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new GLVersionItem(getName(), getTitle(), optionMap);
+       }
+
+}
index e7958f9..73d62cf 100644 (file)
@@ -34,15 +34,19 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
 import org.tizen.emulator.manager.job.CheckGPU;
 import org.tizen.emulator.manager.job.CheckVT;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.ui.Messages;
 import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
+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.widgets.ImageButton;
 
 public class HWSupportItem extends ModifyDialogItem {
 
@@ -129,6 +133,33 @@ public class HWSupportItem extends ModifyDialogItem {
                        gpuItem.setToolTipText(GPUToolTipText);
                }
 
+               gpuItem.addSelectionListener(new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               if (event.type == SWT.Selection) {
+                                       // change button
+                                       ImageButton button = (ImageButton)event.widget;
+                                       button.setSelection(!button.isSelection());
+
+                                       // set on off value
+                                       gpuItem.setOnOffLabel();
+
+                                       // reset GLVersion item
+                                       setValue(getItemListComp().getPropertyValue());
+                                       setEnableGLVersion();
+                               }
+                       }
+               });
+       }
+
+
+       private void setEnableGLVersion() {
+               GLVersionItem item = (GLVersionItem)getItemListComp().getItem(ItemName.GL_VERSION);
+               if (item == null) {
+                       return;
+               }
+
+               item.resetCombo();
        }
 
 
index 7d5fe4f..9b1c2e9 100644 (file)
@@ -91,10 +91,6 @@ public class NetTapDeviceItem extends ComboItem{
                resetCombo(false);
        }
 
-       protected void setItemEnable(boolean enable) {
-               comboBox.setEnabled(enable);
-               item.setTitleEnable(enable);
-       }
 
        public String getInterfaceName() {
                return interfaceName;
index 6584d2f..63ab312 100644 (file)
@@ -106,6 +106,25 @@ public class OnOffSubItemComp extends Composite {
                return isOn;
        }
 
+       private final Listener listener = new Listener() {
+               @Override
+               public void handleEvent(Event event) {
+                       if (event.type == SWT.Selection) {
+                               // change button
+                               ImageButton button = (ImageButton)event.widget;
+                               button.setSelection(!button.isSelection());
+
+                               // set on off value
+                               setOnOffLabel();
+                       }
+               }
+       };
+
+       public void setOnOffLabel() {
+               isOn = button.isSelection();
+               labelText = getLabelText(isOn);
+               textCanvas.redraw();
+       }
 
        public void create(DIALOG_MODE mode, boolean onOff) {
                // create comp
@@ -135,21 +154,7 @@ public class OnOffSubItemComp extends Composite {
                formData.width = BUTTON_WIDTH;
                formData.height = BUTTON_HEIGHT;
                button.setLayoutData(formData);
-               button.addListener(SWT.Selection, new Listener() {
-                       @Override
-                       public void handleEvent(Event event) {
-                               if (event.type == SWT.Selection) {
-                                       // change button
-                                       ImageButton button = (ImageButton)event.widget;
-                                       button.setSelection(!button.isSelection());
-
-                                       // set on off value
-                                       isOn = button.isSelection();
-                                       labelText = getLabelText(isOn);
-                                       textCanvas.redraw();
-                               }
-                       }
-               });
+               button.addListener(SWT.Selection, listener);
 
                // create canvas
                textCanvas = new Canvas(this, SWT.NONE);
@@ -178,6 +183,11 @@ public class OnOffSubItemComp extends Composite {
 
        }
 
+       public void addSelectionListener(Listener listener) {
+               button.removeListener(SWT.Selection, this.listener);
+               button.addListener(SWT.Selection, listener);
+       }
+
        private void drawTitle(final String title) {
                drawItem(title, null);
        }