CreateVMCombo: create 'CreateVMCombo' class
authorjihye424.kim <jihye424.kim@samsung.com>
Wed, 2 Sep 2015 06:26:29 +0000 (15:26 +0900)
committerjihye424.kim <jihye424.kim@samsung.com>
Wed, 2 Sep 2015 06:26:29 +0000 (15:26 +0900)
Change-Id: Ic773b386682dfd2df7d7f78e48ffa9161b02ccd7
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMCombo.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java [new file with mode: 0644]

diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMCombo.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMCombo.java
new file mode 100644 (file)
index 0000000..a47ebd2
--- /dev/null
@@ -0,0 +1,460 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@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.widgets;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.renewal.resources.PatchImageResources;
+import org.tizen.emulator.manager.ui.renewal.tableviewer.ProfileButton;
+
+public class CreateVMCombo extends Canvas {
+       private static int COMBO_WIDTH = 170; // for wearable text length
+       private static int COMBO_HEIGHT = 26;
+       private static int ARROW_WIDTH = 18;
+
+       private Composite parent;
+
+       private int width = COMBO_WIDTH;
+       private int height = COMBO_HEIGHT;
+
+       private WSTATE state = WSTATE.NORMAL;
+       private ArrayList<Image> images = null;
+
+       private ArrayList<ProfileButton> items;
+       private int selectedIndex = 0;
+       private ProfileButton selectedItem = null;
+
+       private CreateVMComboPopup popup = null;
+       private int itemHeight = 0;
+
+       private Image arrowButtonImage = null;
+
+       public CreateVMCombo(Composite parent, int style) {
+               super(parent, style);
+               this.parent = parent;
+               popup = new CreateVMComboPopup(this);
+
+               initCombo();
+               addListeners();
+       }
+
+       private void initCombo() {
+               items = new ArrayList<ProfileButton>();
+
+               images = new ArrayList<Image>();
+
+               images.add(WSTATE.NORMAL.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+               images.add(WSTATE.HOVER.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, hoverInfo));
+               images.add(WSTATE.PUSH.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+               images.add(WSTATE.SELECTED.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+               images.add(WSTATE.SELECTED_HOVER.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+               images.add(WSTATE.SELECTED_PUSH.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+               images.add(WSTATE.DISABLE_ON.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+               images.add(WSTATE.DISABLE_OFF.getId(),
+                               PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+
+               arrowButtonImage = ImageResources.DROP_DOWN_ARROW_HOVER.getImage();
+
+               this.setBackground(ColorResources.WHITE.getColor());
+               this.setForeground(ColorResources.CREATE_VM_COMBO_FONT.getColor());
+               this.setFont(FontResources.COMBO_BUTTON.getFont());
+       }
+
+       public void addListeners() {
+               addPaintListener(comboPaintListener);
+               addDisposeListener(disposeListener);
+
+               addListener(SWT.MouseEnter, comboMouseListener);
+               addListener(SWT.MouseExit, comboMouseListener);
+               addListener(SWT.MouseDown, comboMouseListener);
+               addListener(SWT.MouseUp, comboMouseListener);
+       }
+
+       private SelectionListener selectionListener = null;
+
+       public void addSelectionListener(SelectionListener listener) {
+               selectionListener = listener;
+       }
+
+       public void removeSelectionListener(SelectionListener listener) {
+               selectionListener = null;
+       }
+
+       public void add(ProfileButton item) {
+               add(item, items.size());
+       }
+
+       public void add(ProfileButton item, int index) {
+               assert item == null;
+               if (index < 0 || index > items.size()) {
+                       // TODO
+                       return;
+               }
+               items.add(index, item);
+       }
+
+       public ProfileButton getItem (int index) {
+               if (index < 0 || index >= items.size()) {
+                       // TODO
+                       return null;
+               }
+
+               return items.get(index);
+       }
+
+       public int getItemCount() {
+               return items.size();
+       }
+
+       public ProfileButton[] getItems() {
+               ProfileButton[] ar = new ProfileButton[items.size()];
+               for (int i = 0; i < items.size(); i++) {
+                       ar[i] = items.get(i);
+               }
+               return ar;
+       }
+
+       public ArrayList<ProfileButton> getItemArray() {
+               return items;
+       }
+
+       public int getSelectionIndex() {
+               return selectedIndex;
+       }
+
+       public ProfileButton getItem() {
+               return selectedItem;
+       }
+
+       public void remove(int index) {
+               if (items != null) {
+                       items.remove(index);
+               }
+       }
+
+       public void removeAll() {
+               if (items != null) {
+                       items.clear();
+               }
+               selectedIndex = -1;
+               selectedItem = null;
+
+               if (!popup.isDispose()) {
+                       popup.dispose();
+               }
+       }
+
+       // for CreateVMComboPopup
+       void setIndex(int index) {
+               if (index < 0 || index >= items.size()) {
+                       return;
+               }
+               selectedIndex = index;
+       }
+
+       public void select(int index) {
+               if (index < 0 || index >= items.size()) {
+                       return;
+               }
+
+               selectedIndex = index;
+               selectedItem = items.get(index);
+
+               if (selectionListener != null) {
+                       Event event = new Event();
+                       event.widget = this;
+                       event.data = selectedItem;
+                       selectionListener.widgetSelected(new SelectionEvent(event));
+               }
+
+               changeComboState(WSTATE.NORMAL);
+       }
+
+       public int getItemHeight() {
+               checkWidget();
+
+               return itemHeight;
+       }
+
+       public void setItemHeight(int itemHeight) {
+               checkWidget();
+
+               this.itemHeight = itemHeight;
+       }
+
+       // for ImageComboPopup
+       Shell getParentShell() {
+               if (parent == null) {
+                       return null;
+               } else {
+                       return parent.getShell();
+               }
+       }
+
+       @Override
+       public void setEnabled(boolean enabled) {
+               checkWidget();
+
+               super.setEnabled(enabled);
+               if (!enabled) {
+                       state = WSTATE.DISABLE_ON;
+               } else {
+                       state = WSTATE.NORMAL;
+               }
+               redraw();
+       }
+
+       @Override
+       public Point computeSize(int wHint, int hHint, boolean changes) {
+               checkWidget();
+
+               if (wHint != SWT.DEFAULT && wHint < 0) {
+                       wHint = 0;
+               }
+
+               if (hHint != SWT.DEFAULT && hHint < 0) {
+                       hHint = 0;
+               }
+
+               int popupWidth = popup.computeWidth();
+               popupWidth += 80;
+               Point size = new Point (0, 0);
+               size.x = Math.max(wHint, COMBO_WIDTH);
+               size.x = Math.max(size.x, popupWidth);
+               size.y = Math.max(hHint, COMBO_HEIGHT);
+
+               if (size.x != width || size.y != height) {
+                       width = size.x;
+                       height = size.y;
+
+                       disposeImages();
+
+                       images.set(WSTATE.NORMAL.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+                       images.set(WSTATE.HOVER.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, hoverInfo));
+                       images.set(WSTATE.PUSH.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+                       images.set(WSTATE.SELECTED.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+                       images.set(WSTATE.SELECTED_HOVER.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+                       images.set(WSTATE.SELECTED_PUSH.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, selectedInfo));
+                       images.set(WSTATE.DISABLE_ON.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+                       images.set(WSTATE.DISABLE_OFF.getId(),
+                                       PatchImageResources.getNinePatchButtonImage(width, height, nomalInfo));
+               }
+               return size;
+       }
+
+       private void disposeImages() {
+               int i = 0;
+               for (WSTATE s : WSTATE.values()) {
+                       i = s.getId();
+                       WidgetHelper.tryDispose(images.get(i));
+               }
+       }
+
+       private Listener comboMouseListener = new Listener() {
+               @Override
+               public void handleEvent(Event event) {
+                       if (isEnabled()) {
+                               switch (event.type) {
+                               case SWT.MouseEnter:
+                                       changeComboState(WSTATE.HOVER);
+                                       break;
+                               case SWT.MouseDown:
+                                       if (!isOutOfBounds(event.x, event.y)) {
+                                               changeComboState(WSTATE.PUSH);
+                                       }
+                                       break;
+                               case SWT.MouseUp:
+                                       if (popup.isDispose()) {
+                                               changeComboState(WSTATE.SELECTED);
+                                               if (selectComboButton && selectedItem != null) {
+                                                       select(selectedIndex);
+                                               } else {
+                                                       popup.open();
+                                               }
+                                       } else {
+                                               changeComboState(WSTATE.HOVER);
+                                               popup.dispose();
+                                       }
+                                       break;
+                               case SWT.MouseExit:
+                                       if (popup.isDispose()) {
+                                               changeComboState(WSTATE.NORMAL);
+                                       }
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+       };
+
+       private boolean selectComboButton;
+       protected boolean isOutOfBounds(int x, int y) {
+               Rectangle rect = this.getBounds();
+
+               if (x < 0 || x > rect.width || y < 0 || y > rect.height) {
+                       return true;
+               } else {
+                       if (x > (rect.width - ARROW_WIDTH)) {
+                               selectComboButton = false;
+                       } else {
+                               selectComboButton = true;
+                       }
+                       return false;
+               }
+       }
+
+       private void changeComboState(WSTATE s) {
+               state = s;
+               redraw();
+       }
+
+       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() {
+               @Override
+               public void paintControl(PaintEvent e) {
+                       Rectangle rect = ((Canvas) e.widget).getClientArea();
+
+                       Image img = images.get(state.getId());
+
+                       int x = rect.x;
+                       int y = rect.y;
+                       if (img != null) {
+                               e.gc.drawImage(img, x, y);
+                       }
+
+                       if (arrowButtonImage != null && state != WSTATE.DISABLE_ON) {
+                               int w = arrowButtonImage.getImageData().width;
+                               int h = arrowButtonImage.getImageData().height;
+                               x += rect.width - w - ARROW_OFFSET;
+                               y += (rect.height - h) / 2;
+                               e.gc.drawImage(arrowButtonImage, x, y);
+                               Rectangle clipping = new Rectangle(rect.x, rect.y,
+                                               rect.width - w - ARROW_OFFSET - 2, rect.height);
+                               e.gc.setClipping(clipping);
+                       }
+
+                       x = rect.x + LEFT_IMAGE_OFFSET;
+                       int fontHeight = e.gc.getFontMetrics().getHeight();
+                       y = rect.y + (rect.height - fontHeight) / 2;
+
+                       if (selectedItem != null) {
+                               e.gc.drawImage(selectedItem.getCreateIcon(), x, y);
+                               e.gc.drawText("Create " + selectedItem.getProfileName() + " VM", x + LEFT_TEXT_OFFSET, y, true);
+                       } else {
+                               e.gc.drawImage(ImageResources.ICON_CREATE_NEW_VM.getImage(), x, y);
+                               e.gc.drawText("Create New VM", x + LEFT_TEXT_OFFSET, y, true);
+                       }
+
+                       if (state == WSTATE.DISABLE_ON) {
+                               // draw transparent layer
+                               e.gc.setAlpha(150);
+                               e.gc.fillRectangle(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
+                       }
+               }
+       };
+
+       private DisposeListener disposeListener = new DisposeListener() {
+               @Override
+               public void widgetDisposed(DisposeEvent arg0) {
+                       disposeImages();
+               }
+       };
+
+       //
+       private NinePatchResourceInfo hoverInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+                       ColorResources.TABLE_VIEWER_BG,
+                       ImageResources.DROP_DOWN_BOX_HOVER_LT,
+                       ImageResources.DROP_DOWN_BOX_HOVER_T,
+                       ImageResources.DROP_DOWN_BOX_HOVER_RT,
+                       ImageResources.DROP_DOWN_BOX_HOVER_R,
+                       ImageResources.DROP_DOWN_BOX_HOVER_RB,
+                       ImageResources.DROP_DOWN_BOX_HOVER_B,
+                       ImageResources.DROP_DOWN_BOX_HOVER_LB,
+                       ImageResources.DROP_DOWN_BOX_HOVER_L);
+
+       private NinePatchResourceInfo nomalInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+                       ColorResources.TABLE_VIEWER_BG,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_LT,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_T,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_RT,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_R,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_RB,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_B,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_LB,
+                       ImageResources.DROP_DOWN_BOX_NORMAL_L);
+
+       private NinePatchResourceInfo selectedInfo = new NinePatchResourceInfo(ColorResources.WHITE,
+                       ColorResources.TABLE_VIEWER_BG,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_LT,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_T,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_RT,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_R,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_RB,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_B,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_LB,
+                       ImageResources.DROP_DOWN_BOX_SELECTED_L);
+       //
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java
new file mode 100644 (file)
index 0000000..851a558
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@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.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.ui.renewal.tableviewer.ProfileButton;
+
+class CreateVMComboPopup {
+       private static int SPCAING = 10;
+       private static int LINE_OFFSET = 2;
+       private static int LIEN_WIDTH = 1;
+       private Shell popupShell = null;
+       private Canvas popupCanvas = null;
+
+       private List<Rectangle> itemRects;
+
+       CreateVMCombo parent = null;
+
+       int itemHeight = 0;
+
+       public CreateVMComboPopup(CreateVMCombo parent) {
+               this.parent = parent;
+               initPopup();
+       }
+
+       private void initPopup() {
+               itemRects = new ArrayList<Rectangle>();
+       }
+
+       int computeWidth() {
+               ArrayList<ProfileButton> items = parent.getItemArray();
+               if (items.isEmpty()) {
+                       return 0;
+               }
+
+               int width = 0;
+               GC gc = new GC(parent.getDisplay(), SWT.NONE);
+               for (ProfileButton pButon : items) {
+                       Point p = gc.textExtent(pButon.getProfileName(), SWT.DRAW_MNEMONIC);
+                       p.x += pButon.getCreateIcon().getImageData().width;
+                       if (p.x > width) {
+                               width = p.x;
+                       }
+               }
+
+               width += SPCAING;
+               gc.dispose();
+
+               return width;
+       }
+
+       public void open() {
+               popupShell = new Shell(parent.getParentShell(), SWT.ON_TOP | SWT.NO_TRIM);
+               popupShell.setLayout(new FillLayout());
+
+               ArrayList<ProfileButton>items = parent.getItemArray();
+               Rectangle parentRect = parent.getBounds();
+               Point parentPoint = parent.toDisplay(0, 0);
+
+               int itemWidth   = computeWidth();
+               if (parent.getItemHeight() == 0) {
+                       itemHeight = parentRect.height;
+               } else {
+                       itemHeight = parent.getItemHeight();
+               }
+
+               int shellWidth = ((itemWidth > parentRect.width) ? itemWidth : parentRect.width);
+               int shellHeight = (itemHeight) * items.size() + LINE_OFFSET * 2;
+               popupShell.setSize(shellWidth, shellHeight);
+               popupShell.setLocation(parentPoint.x, parentPoint.y + parentRect.height);
+
+               popupCanvas = new Canvas(popupShell, SWT.DOUBLE_BUFFERED);
+               popupCanvas.setForeground(ColorResources.CREATE_VM_COMBO_FONT.getColor());
+               popupCanvas.setFont(FontResources.COMBO_BUTTON.getFont());
+
+               popupCanvas.addPaintListener(paintListener);
+               popupCanvas.addDisposeListener(disposeListener);
+
+               popupCanvas.addListener(SWT.MouseUp, popupMouseEventListener);
+               popupCanvas.addListener(SWT.MouseMove, popupMouseEventListener);
+               popupCanvas.addListener(SWT.FocusOut, popupMouseEventListener);;
+
+               itemRects.clear();
+               Rectangle itemRect;
+               for (int i = 0; i < items.size(); i++) {
+                       itemRect = new Rectangle(LINE_OFFSET, LINE_OFFSET + i * itemHeight,
+                                                                               shellWidth - LINE_OFFSET * 2, itemHeight);
+                       itemRects.add(itemRect);
+               }
+
+               popupShell.open();
+       }
+
+       private Listener popupMouseEventListener = new Listener() {
+               @Override
+               public void handleEvent(Event event) {
+                       switch(event.type) {
+                       case SWT.MouseMove:
+                               Rectangle rect;
+                               for (int i = 0; i < itemRects.size(); i++) {
+                                       rect = itemRects.get(i);
+                                       if (rect.contains(event.x, event.y)) {
+                                               parent.setIndex(i);
+                                               popupCanvas.redraw();
+                                               break;
+                                       }
+                               }
+                               break;
+                       case SWT.MouseUp:
+                               parent.select(parent.getSelectionIndex());
+                               parent.redraw();
+                               dispose();
+                               break;
+                       case SWT.FocusOut:
+                               dispose();
+                               break;
+                       default:
+                                       break;
+                       }
+
+               }
+       };
+
+
+       public boolean isDispose() {
+               if (popupShell == null || popupShell.isDisposed()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public void dispose() {
+               if (popupShell == null) {
+                       return;
+               }
+               popupShell.close();
+               popupShell = null;
+       }
+
+       private PaintListener paintListener = new PaintListener() {
+
+               @Override
+               public void paintControl(PaintEvent e) {
+                       GC gc = e.gc;
+
+                       int selectedIndex = parent.getSelectionIndex();
+                       int fontHeight = gc.getFontMetrics().getHeight();
+                       int yOffset = (itemHeight - fontHeight)/2 + LINE_OFFSET;
+                       int totalHeight = 0;
+
+                       ArrayList<ProfileButton> items = parent.getItemArray();
+
+                       // drawing combo item
+                       for (int i = 0; i < itemRects.size(); i++) {
+                               if (selectedIndex == i) {
+                                       gc.setBackground(ColorResources.CREATE_VM_COMBO_POPUP_SELECT_ITEM.getColor());
+                               } else {
+                                       gc.setBackground(ColorResources.WHITE.getColor());
+                               }
+                               gc.fillRectangle(itemRects.get(i));
+
+                               ProfileButton item = items.get(i);;
+                               gc.drawImage(item.getCreateIcon(), 6,  totalHeight + yOffset);
+                               gc.drawText(item.getProfileName(), 28, totalHeight + yOffset, true);
+
+                               totalHeight += itemHeight;
+                       }
+
+                       // drawing line
+                       Rectangle clientRect= popupShell.getClientArea();
+                       gc.setForeground(ColorResources.CREATE_VM_COMBO_POPUP_OUTER_LINE.getColor());
+                       gc.drawRectangle(clientRect.x, clientRect.y, clientRect.width - LIEN_WIDTH, clientRect.height - LIEN_WIDTH);
+                       gc.setForeground(ColorResources.CREATE_VM_COMBO_POPUP_INNER_LINE.getColor());
+                       gc.drawRectangle(clientRect.x + LIEN_WIDTH,
+                                               clientRect.y + LIEN_WIDTH,
+                                               clientRect.width - LIEN_WIDTH - LINE_OFFSET,
+                                               clientRect.height - LIEN_WIDTH - LINE_OFFSET);
+               }
+       };
+
+       private DisposeListener disposeListener = new DisposeListener() {
+               @Override
+               public void widgetDisposed(DisposeEvent arg0) {
+                       WidgetHelper.tryDispose(popupCanvas, popupShell);
+                       for (Rectangle rect : itemRects) {
+                               WidgetHelper.tryDispose(rect);
+                       }
+               }
+       };
+}