- Add Display, Ram, Processor, Sensor, Device item.
(UI only)
Change-Id: Id290c477165b9a1f6f5e3687f7cc1cc082e831bc
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.tool.CocoaUtil;
import org.tizen.emulator.manager.tool.SettingInfoFile;
-import org.tizen.emulator.manager.ui.MainDialog;
import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
import org.tizen.emulator.manager.vms.helper.WorkerLock;
import com.sun.jna.Native;
private static void preare() {
EmulatorManager.display = Display.getCurrent();
- mainDialog = new MainDialog(mode);
+// mainDialog = new MainDialog(mode);
+ mainDialog = new MainDialog();
}
private static void draw() {
import org.eclipse.swt.SWT;
import org.tizen.emulator.manager.ui.renewal.MainDialog;
import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceTemplateItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DisplayItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ImageItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ProcessorItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ProfileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.RamSizeItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.SensorItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.VMNameItem;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class VMModifyHandler {
}
}
- private static List<IModifyDialogItem> getItemList(VMProperty property) {
+ private static List<ModifyDialogItem> getItemList(VMProperty property) {
// TODO make item list using Image's item-template
return getTmpItemList();
}
- // FOR TEST
- public static List<IModifyDialogItem> getTmpItemList() {
- List<IModifyDialogItem> itemList = new ArrayList<IModifyDialogItem>();
+ // FOR TES
+ public static List<ModifyDialogItem> getTmpItemList() {
+ List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
itemList.add(new VMNameItem());
itemList.add(new ProfileItem());
itemList.add(new ImageItem());
+ DeviceTemplateItem deviceItem = new DeviceTemplateItem();
+ itemList.add(deviceItem);
+ itemList.add(new DisplayItem(deviceItem.getTreeRoot()));
+ itemList.add(new RamSizeItem(deviceItem.getTreeRoot()));
+ itemList.add(new ProcessorItem(deviceItem.getTreeRoot()));
+ itemList.add(new SensorItem(deviceItem.getTreeRoot()));
+ itemList.add(new DeviceItem(deviceItem.getTreeRoot()));
+
+
+
return itemList;
}
WHITE(255, 255, 255),
BLACK(0, 0, 0),
RED(255, 0, 0),
+ BLUE(0, 0, 255),
+ GREEN(0, 255, 0),
// nine patch button
GRAY_BTN_NORMAL(149, 159, 164),
MESSAGE_BOX_CONTENTS("msg_box_contents", resizeDefaultFont(9)),
DEFAULT_FONT_10("default_font_10", resizeDefaultFont(10)),
- DEFAULT_FONT_9("default_font_9", resizeDefaultFont(9));
+ DEFAULT_FONT_9("default_font_9", resizeDefaultFont(9)),
+ DEFAULT_FONT_8("default_font_8", resizeDefaultFont(8));
public static FontResources MODIFY_ITEM_TITLE = DEFAULT_FONT_9;
public static FontResources CONTENT = DEFAULT_FONT_9;
ICON_TITLE_VMNAME("icon_title_vmname"),
ICON_TITLE_IMAGE("icon_title_image"),
ICON_TITLE_PROFILE("icon_title_profile"),
+ ICON_TITLE_DISPLAY("icon_title_display"),
+ ICON_TITLE_RAM("icon_title_ram"),
+ ICON_TITLE_DEVICE("icon_title_device"),
+ ICON_TITLE_EXTERNAL_INPUT("icon_title_externalinput"),
+ ICON_TITLE_FILESHARING("icon_title_filesharing"),
+ ICON_TITLE_HWSUPPORT("icon_title_hwsupport"),
+ ICON_TITLE_IMAGE_FILE("icon_title_imagefile"),
+ ICON_TITLE_JACK("icon_title_jack"),
+ ICON_TITLE_NETWORK("icon_title_network"),
+ ICON_TITLE_OCI_DEVICE("icon_title_ocidevice"),
+ ICON_TITLE_SENSOR("icon_title_sensor"),
+ ICON_TITLE_TUNER("icon_title_tuner"),
+ ICON_TITLE_VERSION("icon_title_version"),
+ ICON_TITLE_PROCESSOR("icon_title_processor"),
+ ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"),
+ ICON_TITLE_TREE_CLOSED("icon_title_tree_closed"),
// profile select button
BTN_PROFILE_MOBILE_SELECTED("btn_profile_mobile_selected"),
BTN_PROFILE_WEARABLEE_UNSELECTED_NML("btn_profile_wearable_unselected_nml"),
BTN_PROFILE_TV_SELECTED("btn_profile_tv_selected"),
BTN_PROFILE_TV_UNSELECTED_HOVER("btn_profile_tv_unselected_hover"),
- BTN_PROFILE_TV_UNSELECTED_NML("btn_profile_tv_unselected_nml");
+ BTN_PROFILE_TV_UNSELECTED_NML("btn_profile_tv_unselected_nml"),
+ // checkbox
+ CHECKBOX_UNCHECKED_NML("btn_checkbox_unchecked_nml"),
+ CHECKBOX_UNCHECKED_HOVER("btn_checkbox_unchecked_hover"),
+ CHECKBOX_CHECKED_NML("btn_checkbox_checked_nml"),
+ CHECKBOX_CHECKED_HOVER("btn_checkbox_checked_hover");
String name;
Image image;
return image;
}
+ /** Image should be disposed by caller */
public static Image getNinePatchButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
- Image lt = ninePatchImagesInfo.getLeftTopImage().getImage();
- Image t = ninePatchImagesInfo.getTopImage().getImage();
- Image rt = ninePatchImagesInfo.getRightTopImage().getImage();
- Image r = ninePatchImagesInfo.getRightImage().getImage();
- Image rb = ninePatchImagesInfo.getRightBottomImage().getImage();
- Image b = ninePatchImagesInfo.getBottomImage().getImage();
- Image lb = ninePatchImagesInfo.getLeftBottomImage().getImage();
- Image l = ninePatchImagesInfo.getLeftImage().getImage();
Image image = new Image(Display.getCurrent(), width, height);
-
GC gc = new GC(image);
gc.setInterpolation(SWT.NONE);
gc.setBackground(transparentColor);
gc.fillRectangle(0, 0, width, height);
- // draw background
+ drawNinePatchImage(gc, width, height, ninePatchImagesInfo);
+ gc.dispose();
+
+ // Make corner transparent
+ ImageData data = image.getImageData();
+ int cornerPixel = data.palette.getPixel(transparentColor.getRGB());
+ data.transparentPixel = cornerPixel;
+ Image cornerTransparentedImage = new Image(Display.getCurrent(), data);
+
+ // dispose original image
+ image.dispose();
+
+ return cornerTransparentedImage;
+ }
+
+
+ /** Image should be disposed by caller */
+ public static Image getComboPopupImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+ Image image = new Image(Display.getCurrent(), width, height);
+ GC gc = new GC(image);
+ gc.setInterpolation(SWT.NONE);
+
+ // Draw background
+ gc.setBackground(ColorResources.WHITE.getColor());
+ gc.fillRectangle(0, 0, width, height);
+
+ drawNinePatchImage(gc, width, height, ninePatchImagesInfo);
+
+ gc.dispose();
+
+ return image;
+ }
+
+ private static void drawNinePatchImage(GC gc, int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+ Image lt = ninePatchImagesInfo.getLeftTopImage().getImage();
+ Image t = ninePatchImagesInfo.getTopImage().getImage();
+ Image rt = ninePatchImagesInfo.getRightTopImage().getImage();
+ Image r = ninePatchImagesInfo.getRightImage().getImage();
+ Image rb = ninePatchImagesInfo.getRightBottomImage().getImage();
+ Image b = ninePatchImagesInfo.getBottomImage().getImage();
+ Image lb = ninePatchImagesInfo.getLeftBottomImage().getImage();
+ Image l = ninePatchImagesInfo.getLeftImage().getImage();
+
+ // draw center
gc.setBackground(ninePatchImagesInfo.getBackground().getColor());
gc.fillRectangle(l.getImageData().width, t.getImageData().height,
width - l.getImageData().width - r.getImageData().width,
width - lb.getImageData().width - rb.getImageData().width,
b.getImageData().height);
gc.drawImage(rb, width - rb.getImageData().width, height - rb.getImageData().height);
- gc.dispose();
-
- // Make corner transparent
- ImageData data = image.getImageData();
- int cornerPixel = data.palette.getPixel(transparentColor.getRGB());
- data.transparentPixel = cornerPixel;
- Image cornerTransparentedImage = new Image(Display.getCurrent(), data);
-
- // dispose original image
- image.dispose();
-
- return cornerTransparentedImage;
}
-
}
package org.tizen.emulator.manager.ui.renewal.dialog;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
private final int height;
private final int buttonStyle;
+ private final List<Shell> childShell = new ArrayList<Shell>();
private Composite bodyComp;
private int returnValue = SWT.CANCEL;
return shell;
}
+ public void addChildShell(Shell shell) {
+ childShell.add(shell);
+ }
public void setReturnValue(int returnValue) {
this.returnValue = returnValue;
private void makeDialog() {
- DialogTitle.create(shell, title);
+ DialogTitle.create(shell, childShell, title);
initBody();
DialogButtons.create(this, buttonStyle);
}
package org.tizen.emulator.manager.ui.renewal.dialog;
+import java.util.List;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
private static final int TITLE_MARGIN_TOP = 7;
private static final int TITLE_MARGIN_LEFT = 15;
- public static void create(Shell parentDialog, String title) {
+ public static void create(Shell parentDialog, List<Shell> childShell, String title) {
Composite titleComp = new Composite(parentDialog, SWT.NONE);
initTitleComp(parentDialog, titleComp);
- makeTitle(parentDialog, titleComp, title);
+ makeTitle(parentDialog, childShell, titleComp, title);
}
}
- private static void makeTitle(Shell parentDialog, Composite titleComp, String title) {
+ private static void makeTitle(Shell parentDialog,
+ List<Shell> childShell, Composite titleComp, String title) {
// add title
FormData data = new FormData();
data.top = new FormAttachment(0, TITLE_MARGIN_TOP);
titleLabel.setLayoutData(data);
// make title drag-able
- DragHandler.set(parentDialog, titleLabel, titleComp);
+ DragHandler.set(parentDialog, childShell, titleLabel, titleComp);
}
}
package org.tizen.emulator.manager.ui.renewal.dialog;
+import java.util.List;
+
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
* @param shell
* @param controls to receive drag event.
*/
- public static void set(Shell shell, Control... controls) {
+ public static void set(Shell shell, List<Shell> childShell, Control... controls) {
DragHandler controller = new DragHandler();
- controller.setTargetShell(shell);
+ controller.setTargetShell(shell, childShell);
controller.setControls(controls);
}
// set dialog (shell)
- private void setTargetShell(Shell shell) {
+ private void setTargetShell(Shell shell, List<Shell> childShell) {
this.dialog = shell;
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class VMModifyDialog extends Dialog {
private final static String TITLE = "VM Modify";
- private final static int WIDTH = 484;
+ public final static int WIDTH = 484;
+// private final static int WIDTH = 500;
private final static int HEIGHT = 496;
private final static int BUTTON_STYLE = SWT.OK | SWT.CANCEL;
private Composite scrolledContent;
- private List<IModifyDialogItem> itemList;
+ private List<ModifyDialogItem> itemList;
private VMProperty property;
public VMModifyDialog(Shell parent) {
}
- public void create(VMProperty property, List<IModifyDialogItem> itemList) {
+ public void create(VMProperty property, List<ModifyDialogItem> itemList) {
// - create title, buttons
// - init body
super.create();
}
private void makeModifyItem() {
- for (IModifyDialogItem item : itemList) {
- item.setItemData(property);
+ for (ModifyDialogItem item : itemList) {
+ item.setParentDialog(this);
+ item.setInitialValue(property);
item.create(scrolledContent);
}
private void computeScrolledContentSize() {
int height = 0;
- for (IModifyDialogItem item : itemList) {
+ for (ModifyDialogItem item : itemList) {
height += item.getHeight();
}
scrolledContent.setSize(WIDTH - Dialog.BORDER_WIDTH * 2, height);
}
+ public void layoutScrolledComposite() {
+ computeScrolledContentSize();
+ scrolledContent.layout();
+ }
private void initScrolledComposite() {
// add scrolled-composite
--- /dev/null
+/*
+ * 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 org.eclipse.swt.layout.GridData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+
+public abstract class CheckBoxItem extends ModifyDialogItem {
+
+ private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
+ private int rowNum;
+ private final int numColumns;
+
+ // TODO should be structures that have name, title
+ private final String[] checkBoxList;
+
+ public CheckBoxItem(int numColomn, String[] checkBoxList) {
+ this.numColumns = numColomn;
+ this.checkBoxList = checkBoxList;
+ initRowNum();
+ }
+
+
+ private void initRowNum() {
+ rowNum = checkBoxList.length / numColumns;
+ if (checkBoxList.length % numColumns != 0) {
+ rowNum++;
+ }
+ }
+
+
+ protected int getContentHeight() {
+ return ROW_HEIGHT * rowNum;
+ }
+
+
+ protected void createCheckBoxItems(ModifyItem item) {
+ item.setBodyLayoutGrid(numColumns);
+
+ CheckBoxSubItem checkBoxItem;
+ for (int i=0 ; i < checkBoxList.length ; i++) {
+ String sensor = checkBoxList[i];
+ checkBoxItem = new CheckBoxSubItem(item.getBody(), sensor, sensor);
+
+ // set checkbox item layout
+ GridData data = new GridData();
+ data.heightHint = ROW_HEIGHT;
+ data.widthHint = ModifyItem.BODY_CONTENT_WIDTH / numColumns;
+ checkBoxItem.create(data);
+ }
+ }
+}
--- /dev/null
+/*
+ * 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 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.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.CheckBoxButton;
+
+public class CheckBoxSubItem {
+ private final Composite parentComp;
+ private final String name;
+ private final String title;
+ private boolean isChecked;
+ private Composite comp;
+ private CheckBoxButton checkBox; // TODO
+
+ public static final int CHECK_BOX_WIDTH = 15;
+ private final int CHECK_BOX_HEIGHT = 14;
+ public static final int SPACING = 2;
+
+ private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
+
+ public CheckBoxSubItem(Composite parentComp, String name, String title) {
+ this.parentComp = parentComp;
+ this.name = name;
+ this.title = title;
+ }
+
+ public void create(Object layoutData) {
+ // init comp
+ comp = new Composite(parentComp, SWT.NONE);
+ comp.setLayoutData(layoutData);
+ comp.setLayout(new FormLayout());
+
+ createCheckBox();
+ drawTitle();
+ }
+
+
+ private void createCheckBox() {
+
+ FormData data = new FormData(CHECK_BOX_WIDTH, CHECK_BOX_HEIGHT);
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, (ROW_HEIGHT - CHECK_BOX_HEIGHT) / 2 );
+
+ // TODO change to checkBoxWidget
+ checkBox = new CheckBoxButton(comp, SWT.NONE);
+ checkBox.setLayoutData(data);
+
+ }
+
+
+ private void drawTitle() {
+ comp.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+ gc.setFont(FontResources.CONTENT.getFont());
+
+ int itemHeight = ((Composite)e.widget).getBounds().height;
+ Point textExt = gc.textExtent(title);
+ int posY = (itemHeight - textExt.y) / 2;
+
+ gc.drawText(title, CHECK_BOX_WIDTH + SPACING, posY);
+ }
+ });
+
+ }
+}
--- /dev/null
+/*
+ * 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 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.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+
+public abstract class ComboItem extends ModifyDialogItem {
+
+ private ComboBox comboBox;
+
+ protected void createCombo(ModifyItem item, int width) {
+// item.setBodyLayoutDefault();
+//
+// // create combo widget
+// GridData data = new GridData(width, COMBO_HEIGHT);
+// data.grabExcessVerticalSpace = true;
+// data.verticalAlignment = SWT.CENTER;
+
+ item.getBody().setLayout(new FormLayout());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP);
+ data.width = width;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ comboBox = new ComboBox(getParentDialog().getShell(), item.getBody(), SWT.NONE);
+ comboBox.setLayoutData(data);
+ addSelectionListener();
+ }
+
+
+ private void addSelectionListener() {
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.Selection:
+ itemSelected(comboBox);
+
+ default:
+ break;
+ }
+
+ }
+ };
+ comboBox.addListener(SWT.Selection, listener);
+ }
+
+ public void itemSelected(ComboBox comboBox) {
+ // This is called when combo item is selected
+ // TODO override this.
+ }
+}
--- /dev/null
+/*
+ * 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 org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DeviceItem extends CheckBoxItem {
+
+ private final SubTreeModifyItem item;
+
+ private final String TITLE = "Device";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE;
+
+ private static final int NUM_COLUMN = 3;
+
+ // TODO load sensor list
+ private static final String[] sensorList = new String[]{"NFC", "Camera"};
+
+ public DeviceItem(TreeModifyItem treeRoot) {
+ super(NUM_COLUMN, sensorList);
+ item = new SubTreeModifyItem();
+ item.setItemHeight(getContentHeight());
+ treeRoot.addSubItem(item);
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCheckBoxItems(item);
+
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/*
+ * 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 org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DeviceTemplateItem extends ComboItem {
+
+ private final String TITLE = "Device";
+ private final TreeModifyItem item;
+
+ private final int COMBO_WIDTH = 200;
+
+ public TreeModifyItem getTreeRoot() {
+ return item;
+ }
+
+ public DeviceTemplateItem() {
+ item = new TreeModifyItem();
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new TreeItemTitle(item, TITLE));
+ item.create();
+
+ item.setModifyDialogItem(this);
+
+ createCombo(item, COMBO_WIDTH);
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ // TODO change item list for selected template.
+ System.out.println("item selected:" + comboBox.getSelectedItem());
+
+ }
+}
--- /dev/null
+/*
+ * 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 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.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+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;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DisplayItem extends ModifyDialogItem {
+
+ private final SubTreeModifyItem item;
+
+ private final String TITLE = "Display";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DISPLAY;
+
+ private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
+ private final int ROW_NUM = 4;
+
+ public DisplayItem(TreeModifyItem treeRoot) {
+ item = new SubTreeModifyItem();
+ item.setItemHeight(ROW_HEIGHT * ROW_NUM);
+ treeRoot.addSubItem(item);
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
+ item.setBodyLayoutDefault();
+ createResolutionComboItem();
+ createResolutionTextItem();
+ createSizeItem();
+ createSkinItem();
+ }
+
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+
+ }
+
+
+ private final String TITLE_RESOLUTION = "Resolution";
+ private final String TITLE_SIZE = "Size";
+ private final String TITLE_SKIN = "Skin";
+
+ private final int BODY_MARGIN_LEFT = 66;
+
+ private final int COMBO_WIDTH = 134;
+ private final int TEXT_BOX_WIDTH = 58;
+ private final int RESOLUTION_TEXT_BOX_SPACING = 18;
+ private final int WIDGET_TOP = (ROW_HEIGHT - ModifyItem.WIDGET_HEIGHT) / 2;
+
+
+ private ComboBox resolutionCombo = null;
+ private TextInputBox widthTextBox = null;
+ private TextInputBox heightTextBox = null;
+ private TextInputBox sizeTextBox = null;
+ private ComboBox skinCombo = null;
+
+
+ private void createResolutionComboItem() {
+ Composite comp = createSubComp(1, TITLE_RESOLUTION);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = COMBO_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ resolutionCombo = new ComboBox(getParentDialog().getShell(), comp, SWT.NONE);
+ resolutionCombo.setLayoutData(data);
+
+ }
+
+ private void createResolutionTextItem() {
+ Composite comp = createSubComp(1, "");
+
+ // width
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = TEXT_BOX_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ widthTextBox = new TextInputBox(comp, SWT.NONE);
+ widthTextBox.setLayoutData(data);
+
+ // "x" label
+ data = new FormData();
+ data.left = new FormAttachment(widthTextBox, 0);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = RESOLUTION_TEXT_BOX_SPACING;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ Canvas canvas = new Canvas(comp, SWT.NONE);
+ canvas.setLayoutData(data);
+ WidgetHelper.drawText(canvas, "x", SWT.CENTER);
+
+
+ // height
+ data = new FormData();
+ data.left = new FormAttachment(widthTextBox, RESOLUTION_TEXT_BOX_SPACING);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = TEXT_BOX_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ heightTextBox = new TextInputBox(comp, SWT.NONE);
+ heightTextBox.setLayoutData(data);
+
+ }
+
+
+ private void createSizeItem() {
+ Composite comp = createSubComp(1, TITLE_SIZE);
+
+ // text box
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = TEXT_BOX_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ sizeTextBox = new TextInputBox(comp, SWT.NONE);
+ sizeTextBox.setLayoutData(data);
+
+ // "inch" label
+ data = new FormData();
+ data.left = new FormAttachment(sizeTextBox, 6);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = 30; // rough guess
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ Canvas canvas = new Canvas(comp, SWT.NONE);
+ canvas.setLayoutData(data);
+ WidgetHelper.drawText(canvas, "inch", SWT.NONE);
+ }
+
+
+ private void createSkinItem() {
+ Composite comp = createSubComp(1, TITLE_SKIN);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, WIDGET_TOP);
+ data.width = COMBO_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ skinCombo = new ComboBox(getParentDialog().getShell(), comp, SWT.NONE);
+ skinCombo.setLayoutData(data);
+ }
+
+
+ private Composite createSubComp(int rowNum, String title) {
+ GridData data = new GridData();
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = SWT.FILL;
+ data.heightHint = ROW_HEIGHT * rowNum;
+
+ Composite comp = new Composite(item.getBody(), SWT.NONE);
+ comp.setLayoutData(data);
+ comp.setLayout(new FormLayout());
+
+ WidgetHelper.drawText(comp, title, SWT.NONE);
+ return comp;
+ }
+
+
+
+}
* - S-Core Co., Ltd
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.vms.VMProperty;
/** To decide modify dialog */
public int getHeight();
- public void setItemData(VMProperty property);
+ public void setInitialValue(VMProperty property);
}
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TextLabelItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class ImageItem extends TextLabelItem {
}
@Override
- public void setItemData(VMProperty property) {
+ public void setInitialValue(VMProperty property) {
if (property == null) {
return;
}
--- /dev/null
+/*
+ * 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 org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
+
+public abstract class ModifyDialogItem implements IModifyDialogItem {
+ private VMModifyDialog parentDialog;
+
+ public VMModifyDialog getParentDialog() {
+ return parentDialog;
+ }
+
+ public void setParentDialog(VMModifyDialog parentDialog) {
+ this.parentDialog = parentDialog;
+ }
+
+}
--- /dev/null
+/*
+ * 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 org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class ProcessorItem extends ComboItem {
+
+ private final SubTreeModifyItem item;
+
+ private final String TITLE = "Processor";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROCESSOR;
+ private final int COMBO_WIDTH = 124;
+
+ public ProcessorItem(TreeModifyItem treeRoot) {
+ item = new SubTreeModifyItem();
+ treeRoot.addSubItem(item);
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCombo(item, COMBO_WIDTH);
+
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ // TODO change item list for selected template.
+ System.out.println("item selected:" + comboBox.getSelectedItem());
+
+ }
+}
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IconItemTitle;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
import org.tizen.emulator.manager.vms.VMProperty;
-public class ProfileItem implements IModifyDialogItem {
+public class ProfileItem extends ModifyDialogItem {
private ModifyItem item;
private Canvas canvas;
}
@Override
- public void setItemData(VMProperty property) {
+ public void setInitialValue(VMProperty property) {
if (property == null) {
return;
}
@Override
public void create(Composite parent) {
- item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE);
+ item = new ModifyItem();
+ item.init(parent);
+ item.setItemTitle(new IconItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
addProfileImage();
}
}
--- /dev/null
+/*
+ * 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 org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class RamSizeItem extends ComboItem {
+
+ private final SubTreeModifyItem item;
+
+ private final String TITLE = "Ram";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_RAM;
+ private final int COMBO_WIDTH = 124;
+
+ public RamSizeItem(TreeModifyItem treeRoot) {
+ item = new SubTreeModifyItem();
+ treeRoot.addSubItem(item);
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCombo(item, COMBO_WIDTH);
+ addLabel();
+ }
+
+ private void addLabel() {
+ FormData data = new FormData();
+ int left = ModifyItem.BODY_MARGIN_LEFT + COMBO_WIDTH + 6;
+ data.left = new FormAttachment(0, left);
+ data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP);
+ data.width = 30; // rough guess
+ data.height = ModifyItem.WIDGET_HEIGHT;
+
+ Canvas canvas = new Canvas(item.getBody(), SWT.NONE);
+ canvas.setLayoutData(data);
+ WidgetHelper.drawText(canvas, "MB", SWT.NONE);
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/*
+ * 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 org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class SensorItem extends CheckBoxItem {
+
+ private final SubTreeModifyItem item;
+
+ private final String TITLE = "Sensor";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR;
+
+ private static final int NUM_COLUMN = 3;
+
+ // TODO load sensor list
+ private static final String[] sensorList = new String[]{"Accelerometer", "Gyroscope", "Geo-magnetic",
+ "Proximity", "Light", "Haptic", "Pressure"};
+
+ public SensorItem(TreeModifyItem treeRoot) {
+ super(NUM_COLUMN, sensorList);
+ item = new SubTreeModifyItem();
+ item.setItemHeight(getContentHeight());
+ treeRoot.addSubItem(item);
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCheckBoxItems(item);
+
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(VMProperty property) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+}
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
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.ui.renewal.item.modify.vm.common.IconItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
-public abstract class TextLabelItem implements IModifyDialogItem {
+public abstract class TextLabelItem extends ModifyDialogItem {
private ModifyItem item;
private Canvas canvas;
return item.getHeight();
}
- protected void create(Composite parent, String title, ImageResources iconResources) {
- item = new ModifyItem(parent, title, iconResources);
+ protected void create(Composite parent, String title, ImageResources iconResource) {
+ item = new ModifyItem();
+ item.init(parent);
+ item.setItemTitle(new IconItemTitle(item.getItemComp(), title, iconResource));
+ item.create();
+
makeBody();
}
// init canvas;
GridData data = new GridData();
- data.heightHint = ModifyItem.ITEM_HEIGHT;
+ data.heightHint = getHeight() - ModifyItem.LINE_WIDTH;
data.horizontalAlignment = SWT.FILL;
data.grabExcessHorizontalSpace = true;
canvas = new Canvas(item.getBody(), SWT.NONE);
canvas.setLayoutData(data);
- drawImageName();
+ drawText();
}
- private void drawImageName() {
+ private void drawText() {
canvas.addPaintListener(new PaintListener() {
@Override
gc.setForeground(ColorResources.CONTENT_FONT.getColor());
gc.setFont(FontResources.CONTENT.getFont());
Point textExt = gc.textExtent(value);
- int poxY = (ModifyItem.ITEM_HEIGHT - textExt.y) / 2;
+ int poxY = (getHeight() - textExt.y) / 2;
gc.drawText(value, 0, poxY);
}
});
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TextLabelItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class VMNameItem extends TextLabelItem {
}
@Override
- public void setItemData(VMProperty property) {
+ public void setInitialValue(VMProperty property) {
if (property == null) {
return;
}
--- /dev/null
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+
+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 IconItemTitle extends ItemTitle {
+
+ private Canvas iconCanvas;
+ private final ImageResources iconResource;
+
+ 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.iconResource = iconResource;
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ 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
+ iconCanvas.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ gc.drawImage(iconResource.getImage(), 0, 0);
+ }
+ });
+ }
+}
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
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.FontResources;
-import org.tizen.emulator.manager.renewal.resources.ImageResources;
public class ItemTitle extends Canvas{
- private final int TITLE_MARGIN_LEFT = 15;
private final int TITLE_SPACING = 8;
- private final int TITLE_CANVAS_WIDTH = 144;
+// private final int TITLE_CANVAS_WIDTH = 144;
+ public static final int TITLE_CANVAS_WIDTH = 130;
private final int LINE_INDENT = 5;
- private final String title;
- private Image titleIcon;
- private final ImageResources titleIconResource;
+ protected int ICON_WIDTH = 18;
+ protected final int ICON_HEIGHT = 18;
+ private final String title;
+ private int marginLeft = 0;
+ private final ColorResources background;
- public ItemTitle(Composite parent, String title, ImageResources titleIconResources) {
+ public ItemTitle(Composite parent, String title, int marginLeft, ColorResources background) {
super(parent, SWT.NONE);
this.title = title;
- this.titleIconResource = titleIconResources;
-
+ this.marginLeft = marginLeft;
+ this.background = background;
}
- public void create() {
- initTitle();
+ protected void create() {
+ init();
makeTitle();
}
- private void initTitle() {
+ private void init() {
GridData data = new GridData();
data.grabExcessVerticalSpace = true;
- data.verticalAlignment = GridData.FILL;
+ data.verticalAlignment = SWT.FILL;
data.widthHint = TITLE_CANVAS_WIDTH;
this.setLayoutData(data);
- this.setBackground(ColorResources.MODIFY_ITEM_TITLE_BACKGROUND.getColor());
+ this.setBackground(background.getColor());
+ this.setBackgroundMode(SWT.INHERIT_FORCE);
+
+ // layout
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = marginLeft;
+ this.setLayout(layout);
}
+
private void makeTitle() {
- // draw icon, title
+ // draw title, under line
this.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
- int itemHeight = ModifyItem.ITEM_HEIGHT;
-
- // draw icon
- if (titleIcon == null) {
- titleIcon = titleIconResource.getImage();
- }
- ImageData imageData = titleIcon.getImageData();
- int iconY = (itemHeight - imageData.height) / 2;
- gc.drawImage(titleIcon, TITLE_MARGIN_LEFT, iconY);
+ int itemHeight = ((Canvas)e.widget).getBounds().height - ModifyItem.LINE_WIDTH;
// draw text
gc.setForeground(ColorResources.MODIFY_ITEM_TITLE.getColor());
Point textExt = gc.textExtent(title);
int titleY = (itemHeight - textExt.y) / 2;
gc.drawText(title,
- TITLE_MARGIN_LEFT + imageData.width + TITLE_SPACING, titleY);
+ marginLeft + ICON_WIDTH + TITLE_SPACING, titleY);
// draw under line
int lineWidth = ModifyItem.LINE_WIDTH;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
-import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
public class ModifyItem {
public static final int LINE_WIDTH = 1;
public static final int LINE_INDENT = 7;
public static final int BODY_MARGIN_LEFT = 10;
+ public static final int BODY_CONTENT_WIDTH =
+ VMModifyDialog.WIDTH - ItemTitle.TITLE_CANVAS_WIDTH - BODY_MARGIN_LEFT * 2;
- private Composite comp;
+ public static final int WIDGET_HEIGHT = 23;
+
+ public static final int WIDGET_TOP = (ITEM_HEIGHT - WIDGET_HEIGHT) / 2;
+
+ protected Composite comp;
private ItemTitle itemTitle;
private Composite bodyComp;
- public ModifyItem(Composite parent, String title, ImageResources iconResource) {
- create(parent);
- createTitle(title, iconResource);
- createEmptyBody();
+ private int itemHeight = ITEM_HEIGHT;
+
+ protected int getItemHeight() {
+ return itemHeight;
}
- private void createTitle(String title, ImageResources iconResource) {
- itemTitle = new ItemTitle(comp, title, iconResource);
+
+ public void setItemHeight(int itemHeight) {
+ this.itemHeight = itemHeight;
+ }
+
+
+ public void init(Composite parent) {
+ createComp(parent);
+ }
+
+ public void setItemTitle(ItemTitle itemTitle) {
+ this.itemTitle = itemTitle;
+ }
+
+ public Composite getItemComp() {
+ return comp;
+ }
+
+ public void create() {
itemTitle.create();
+ createEmptyBody();
}
private void createEmptyBody() {
// draw under line
gc.setForeground(ColorResources.MODIFY_ITEM_LINE.getColor());
gc.setLineWidth(ModifyItem.LINE_WIDTH);
- gc.drawLine(-1, ModifyItem.ITEM_HEIGHT,
- rect.width, ModifyItem.ITEM_HEIGHT);
+ gc.drawLine(-1, getItemHeight(),
+ rect.width, getItemHeight());
}
});
}
}
public int getHeight() {
- return ITEM_HEIGHT + LINE_WIDTH;
+ return ((GridData)comp.getLayoutData()).heightHint;
+
}
- /** For item which has single widget. */
public void setBodyLayoutDefault() {
+ setBodyLayoutGrid(1);
+ }
+
+ public void setBodyLayoutGrid(int numColumns) {
GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = ModifyItem.BODY_MARGIN_LEFT;
+ layout.numColumns = numColumns;
+ layout.marginWidth = BODY_MARGIN_LEFT;
layout.marginHeight = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
bodyComp.setLayout(layout);
}
- private void create(Composite parent) {
+
+
+ private void createComp(Composite parent) {
initComp(parent);
makeComp();
}
GridData data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
- data.heightHint = ITEM_HEIGHT + LINE_WIDTH;
+ data.heightHint = getItemHeight() + LINE_WIDTH;
comp.setLayoutData(data);
}
--- /dev/null
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+
+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;
+
+ 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() {
+ super.create();
+ 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
+ iconCanvas.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ gc.drawImage(iconResource.getImage(), 0, 0);
+ }
+ });
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+
+import org.eclipse.swt.layout.GridData;
+
+
+public class SubTreeModifyItem extends ModifyItem{
+
+ public void changeExpanding(boolean isExpand) {
+ GridData data = new GridData();
+ if (isExpand) {
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.heightHint = getItemHeight() + LINE_WIDTH;
+ } else {
+ data.heightHint = 0;
+ }
+ comp.setLayoutData(data);
+
+ }
+
+// @Override
+// @Override
+// public int getHeight() {
+// System.out.println(comp.getSize().y);
+// if (comp.isVisible()) {
+// return super.getHeight();
+// }
+// return 0;
+//
+// }
+}
--- /dev/null
+
+/*
+ * 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.common;
+
+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.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+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.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class TreeItemTitle extends ItemTitle {
+
+ 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);
+ this.treeRoot = treeRoot;
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ makeArrow();
+ }
+
+ private void makeArrow() {
+ // init
+ GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT);
+ data.verticalAlignment = SWT.CENTER;
+ data.grabExcessVerticalSpace = true;
+ arrowCanvas = new Canvas(this, SWT.NONE);
+ arrowCanvas.setLayoutData(data);
+
+ // draw icon
+ drawArrow();
+ addArrowListener();
+ }
+
+ private void drawArrow() {
+ arrowCanvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ if (isExpanded) {
+ gc.drawImage(ARROW_EXPANDED.getImage(), 0,0);
+
+ } else {
+ gc.drawImage(ARROW_CLOSED.getImage(), 0,0);
+ }
+
+ }
+ });
+ }
+
+
+ private void addArrowListener() {
+
+ Listener mouseListener = new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+
+ if (e.type == SWT.MouseUp) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ if (rect.contains(e.x, e.y)) {
+ isExpanded = !isExpanded;
+ treeRoot.changeTreeExpanding(isExpanded);
+ arrowCanvas.redraw();
+ }
+ }
+ }
+ };
+ arrowCanvas.addListener(SWT.MouseUp, mouseListener);
+ }
+}
--- /dev/null
+/*
+ * 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.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem;
+
+public class TreeModifyItem extends ModifyItem{
+
+ private ModifyDialogItem modifyDialogItem;
+ private final List<SubTreeModifyItem> subItemList = new ArrayList<SubTreeModifyItem>();
+
+ public void addSubItem(SubTreeModifyItem subItem) {
+ subItemList.add(subItem);
+ }
+
+ public void changeTreeExpanding(boolean isExpand) {
+ for (SubTreeModifyItem subItem : subItemList) {
+ subItem.changeExpanding(isExpand);
+ }
+ modifyDialogItem.getParentDialog().layoutScrolledComposite();
+ }
+
+ public void setModifyDialogItem(ModifyDialogItem modifyDialogItem) {
+ this.modifyDialogItem = modifyDialogItem;
+ }
+
+
+}
--- /dev/null
+/*
+ * 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.widgets;
+
+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.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+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.TypedListener;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.table.Helper;
+
+public class CheckBoxButton extends Canvas {
+ private Image image = null;
+ private Image imageHover = null;
+ private Image checkedImage = null;
+ private Image checkedImageHover = null;
+ private boolean isSelected = false;
+ private boolean isHover = false;
+
+ private Color checkedBackground = null;
+
+ public CheckBoxButton(Composite parent, int style) {
+ super(parent, SWT.DOUBLE_BUFFERED | style);
+
+ initButton();
+ addListeners();
+ }
+
+ protected void initButton() {
+ image = ImageResources.CHECKBOX_UNCHECKED_NML.getImage();
+ imageHover = ImageResources.CHECKBOX_UNCHECKED_HOVER.getImage();
+ checkedImage = ImageResources.CHECKBOX_CHECKED_NML.getImage();
+ checkedImageHover = ImageResources.CHECKBOX_CHECKED_HOVER.getImage();
+ }
+
+ private void addListeners() {
+ addPaintListener(paintListener);
+ addListener(SWT.MouseDown, mouseListener);
+ addListener(SWT.MouseUp, mouseListener);
+ addListener(SWT.MouseEnter, mouseListener);
+ addListener(SWT.MouseExit, mouseListener);
+ addDisposeListener(disposeListener);
+ }
+
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int width = 0, height = 0;
+
+ Rectangle bounds = image.getBounds();
+ width = bounds.width;
+ height = bounds.height;
+
+ if (wHint != SWT.DEFAULT)
+ width = wHint;
+
+ if (hHint != SWT.DEFAULT)
+ height = hHint;
+
+ return new Point(width, height);
+ }
+
+ private final DisposeListener disposeListener = new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent arg0) {
+ Helper.tryDispose(image, imageHover, checkedImage, checkedImageHover, checkedBackground);
+ }
+ };
+
+ private final PaintListener paintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle rect = ((Canvas) e.widget).getClientArea();
+
+ if (isSelected && checkedBackground != null) {
+ e.gc.setBackground(checkedBackground);
+ } else {
+ e.gc.setBackground(getBackground());
+ }
+ e.gc.fillRectangle(rect);
+
+ Image img = image;
+ if (isSelected) {
+ img = isHover ? checkedImageHover : checkedImage;
+ } else {
+ img = isHover ? imageHover : image;
+ }
+
+ Rectangle bounds = img.getBounds();
+ int x = rect.x + (rect.width - bounds.width) / 2;
+ int y = rect.y + (rect.height - bounds.height) / 2;
+
+ if (null != img) {
+ e.gc.drawImage(img, x, y);
+ }
+ }
+ };
+
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ addListener(SWT.Selection, new TypedListener(listener));
+ addListener(SWT.DefaultSelection, new TypedListener(listener));
+ }
+
+ public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+ }
+
+ protected Listener mouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event e) {
+ if (!isEnabled()) {
+ return;
+ }
+
+ CheckBoxButton button = (CheckBoxButton) e.widget;
+ if (e.type == SWT.MouseUp) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ if (rect.contains(e.x, e.y)) {
+ setSelection(!isSelection());
+ redraw();
+ button.notifyListeners(SWT.Selection, new Event());
+ }
+
+ } else if (e.type == SWT.MouseEnter) {
+ isHover = true;
+ redraw();
+
+ } else if (e.type == SWT.MouseExit) {
+ isHover = false;
+ redraw();
+ }
+ }
+ };
+
+ public void setSelection(boolean selected) {
+ checkWidget();
+ isSelected = selected;
+ }
+
+ public boolean isSelection() {
+ checkWidget();
+ return isSelected;
+ }
+
+ public void setSelectedBackground(Color color) {
+ checkWidget();
+ if (color == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ this.checkedBackground = color;
+ }
+}
--- /dev/null
+/*
+ * 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.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.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;
+
+public class ComboBox extends NinePatchBox {
+
+ private static NinePatchResourceMap ninePatchResourceMap;
+
+ private final Shell parentShell;
+ private Canvas textCanvas;
+
+ private final int ARROW_AREA_WIDTH = 19;
+ public static final int TEXT_MARGIN_LEFT = 3;
+
+ private Image arrowImageNormal;
+ private Image arrowImageHover;
+
+ private final List<String> items;
+ private final ComboBoxPopup popup;
+ private int selectedIndex = 0;
+ private String selectedItem = "";
+
+ public ComboBox(Shell parentShell, Composite parent, int style) {
+ super(parent, style);
+ this.parentShell = parentShell;
+ popup = new ComboBoxPopup(this);
+ items = new ArrayList<String>();
+ initNinePatchResourceMap();
+ initBox();
+ createText();
+ addMouseListener();
+
+ // TODO for test
+ items.add("combo 1");
+ items.add("combo 2");
+ items.add("combo 3");
+ }
+
+
+ public Shell getParentShell() {
+ return parentShell;
+ }
+
+ public void addItem(String item) {
+ items.add(item);
+ }
+
+
+ @Override
+ public void redraw() {
+ textCanvas.redraw();
+ super.redraw();
+ }
+
+ public String getSelectedItem() {
+ return selectedItem;
+ }
+
+ public List<String> getItemList() {
+ return items;
+ }
+
+
+ public void setIndex(int index) {
+ if (index < 0 || index >= items.size()) {
+ return;
+ }
+ selectedIndex = index;
+ }
+
+
+ public int getSelectionIndex() {
+ return selectedIndex;
+ }
+
+
+ public void select(int index) {
+ if (index < 0 || index >= items.size()) {
+ return;
+ }
+
+ selectedIndex = index;
+ selectedItem = items.get(index);
+
+ notifyListeners(SWT.Selection, new Event());
+ }
+
+
+ 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);
+
+ textCanvas = new Canvas(this, SWT.NONE);
+ textCanvas.setLayoutData(data);
+
+ drawText();
+ }
+
+
+ private void drawText() {
+ textCanvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ Rectangle rect = ((Canvas)e.widget).getBounds();
+ gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+ gc.setFont(FontResources.CONTENT.getFont());
+ Point textExt = gc.textExtent(selectedItem);
+ int poxY = (rect.height - textExt.y) / 2;
+ gc.drawText(selectedItem, TEXT_MARGIN_LEFT, poxY);
+ }
+ });
+ }
+
+
+ @Override
+ protected void draw(PaintEvent e) {
+ drawArrow(e);
+ }
+
+
+ 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);
+
+ }
+
+ private Image getArrowImage() {
+ if (getState() == WSTATE.HOVER || getState() == WSTATE.SELECTED) {
+ if (arrowImageHover == null) {
+ arrowImageHover = ImageResources.DROP_DOWN_ARROW_HOVER.getImage();
+ }
+ return arrowImageHover;
+ }
+
+ if (arrowImageNormal == null) {
+ arrowImageNormal = ImageResources.DROP_DOWN_ARROW_NORMAL.getImage();
+ }
+ return arrowImageNormal;
+
+ }
+
+
+ private void addMouseListener() {
+ Listener mouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event e) {
+ if (e.type == SWT.MouseEnter) {
+ if (popup.isClosed()) {
+ setState(WSTATE.HOVER);
+ redraw();
+ }
+
+ } 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();
+ if (rect.contains(e.x, e.y)) {
+ setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER : WSTATE.SELECTED);
+ redraw();
+ popup.changePopup();
+ }
+ }
+ }
+ };
+ textCanvas.addListener(SWT.MouseEnter, mouseListener);
+ textCanvas.addListener(SWT.MouseExit, mouseListener);
+ textCanvas.addListener(SWT.MouseUp, mouseListener);
+
+ this.addListener(SWT.MouseEnter, mouseListener);
+ this.addListener(SWT.MouseExit, mouseListener);
+ this.addListener(SWT.MouseUp, mouseListener);
+
+ }
+
+ @Override
+ public NinePatchResourceMap getNinePatchResourceMap() {
+ return ninePatchResourceMap;
+ }
+
+ private static void initNinePatchResourceMap() {
+ ninePatchResourceMap = new NinePatchResourceMap();
+ ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE,
+ ColorResources.BLACK,
+ 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);
+
+ ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.WHITE,
+ ColorResources.BLACK,
+ 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);
+
+ ninePatchResourceMap.setImages(WSTATE.SELECTED, ColorResources.WHITE,
+ ColorResources.BLACK,
+ 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);
+
+ }
+}
--- /dev/null
+/*
+ * 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.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.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+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;
+
+public class ComboBoxPopup {
+
+ private final ComboBox parentComboBox;
+
+ private Shell popupShell;
+ private Canvas popupCanvas;
+ private Image popupImage = null;
+ private final List<Rectangle> itemRects;
+
+ private static final int ITEM_HEIGHT = 23;
+ private static final int MARGIN_WIDTH = 6;
+ private static int LINE_OFFSET = 1;
+ private static int SHADOW_WIDTH_RIGHT = 4;
+ private static int SHADOW_WIDTH_BOTTOM = 5;
+
+
+ private int shellWidth;
+ private int shellHeight;
+
+ public ComboBoxPopup(ComboBox parentComboBox) {
+ this.parentComboBox = parentComboBox;
+ itemRects = new ArrayList<Rectangle>();
+ }
+
+ private void open() {
+ initShell();
+ initCanvas();
+
+ popupShell.open();
+ }
+
+ public void changePopup() {
+ if (popupShell == null || popupShell.isDisposed()) {
+ open();
+
+ } else {
+ dispose();
+ }
+ }
+
+ public boolean isClosed() {
+ if (popupShell == null || popupShell.isDisposed()) {
+ return true;
+ }
+ return false;
+ }
+
+ private void initCanvas() {
+ popupCanvas = new Canvas(popupShell, SWT.DOUBLE_BUFFERED);
+ popupCanvas.setForeground(ColorResources.CONTENT_FONT.getColor());
+ popupCanvas.setFont(FontResources.CONTENT.getFont());
+
+ List<String> items = parentComboBox.getItemList();
+ Rectangle itemRect;
+ for (int i = 0; i < items.size(); i++) {
+ itemRect = new Rectangle(LINE_OFFSET, LINE_OFFSET + i * ITEM_HEIGHT,
+ shellWidth - LINE_OFFSET * 2, ITEM_HEIGHT);
+ itemRects.add(itemRect);
+ }
+
+ addPaintListener();
+ addDisposeListener();
+ addMouseListener();
+ addFocusListener();
+
+ }
+
+
+ private void addMouseListener() {
+ 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)) {
+ parentComboBox.setIndex(i);
+ popupCanvas.redraw();
+ break;
+ }
+ }
+ break;
+ case SWT.MouseUp:
+ parentComboBox.select(parentComboBox.getSelectionIndex());
+ parentComboBox.redraw();
+ dispose();
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ popupCanvas.addListener(SWT.MouseUp, popupMouseEventListener);
+ popupCanvas.addListener(SWT.MouseMove, popupMouseEventListener);
+
+ }
+
+
+ private void addFocusListener() {
+ popupCanvas.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent arg0) {
+ dispose();
+ }
+
+ @Override
+ public void focusGained(FocusEvent arg0) {
+ }
+ });
+
+ }
+ private void initShell() {
+ popupShell = new Shell(parentComboBox.getParentShell(), SWT.ON_TOP | SWT.NO_TRIM);
+ popupShell.setLayout(new FillLayout());
+
+ List<String> items = parentComboBox.getItemList();
+
+ Rectangle parentRect = parentComboBox.getBounds();
+ Point parentPoint = parentComboBox.toDisplay(0, 0);
+
+ int itemWidth = getMaxTextWidth(items) + MARGIN_WIDTH * 2;
+ shellWidth = ((itemWidth > parentRect.width) ? itemWidth : parentRect.width);
+
+ // insures minimum popup height
+ int shellItemSize = items.size() == 0 ? 1 : items.size();
+ shellHeight = (ITEM_HEIGHT) * shellItemSize + LINE_OFFSET * 2;
+
+ Region region = new Region();
+ region.add(0, 0, shellWidth + SHADOW_WIDTH_RIGHT,
+ shellHeight + SHADOW_WIDTH_BOTTOM);
+ region.subtract(0, shellHeight - 1, 1, 1);
+ popupShell.setRegion(region);
+
+ Rectangle size = region.getBounds();
+ popupShell.setSize(size.width, size.height);
+ popupShell.setLocation(parentPoint.x, parentPoint.y + parentRect.height);
+ }
+
+
+ private int getMaxTextWidth(List<String> items) {
+ if (items.isEmpty()) {
+ return 0;
+ }
+ int width = 0;
+ GC gc = new GC(Display.getCurrent(), SWT.NONE);
+ for (String item : items) {
+ Point p = gc.textExtent(item);
+ if (p.x > width) {
+ width = p.x;
+ }
+ }
+ gc.dispose();
+ return width;
+ }
+
+ public void dispose() {
+ if (popupShell == null) {
+ return;
+ }
+ parentComboBox.setState(WSTATE.NORMAL);
+ parentComboBox.redraw();
+ popupShell.close();
+ }
+
+
+ private void addPaintListener() {
+ popupCanvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ // draw border
+ drawBorder(e);
+
+ // draw item text
+ GC gc = e.gc;
+ int selectedIndex = parentComboBox.getSelectionIndex();
+ int fontHeight = gc.getFontMetrics().getHeight();
+ int yOffset = (ComboBoxPopup.ITEM_HEIGHT - fontHeight)/2 + LINE_OFFSET;
+ int totalHeight = 0;
+
+ List<String> items = parentComboBox.getItemList();
+ 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));
+
+ String text = items.get(i);
+ gc.drawText(text, MARGIN_WIDTH, totalHeight + yOffset, true);
+ totalHeight += ITEM_HEIGHT;
+ }
+ }
+ });
+ }
+
+ private void drawBorder(PaintEvent e) {
+ if (popupImage == null) {
+ NinePatchResourceInfo ninePatchImagesInfo =
+ new NinePatchResourceInfo(ColorResources.WHITE,
+ ColorResources.WHITE,
+ ImageResources.CONTEXT_MENU_LT,
+ ImageResources.CONTEXT_MENU_T,
+ ImageResources.CONTEXT_MENU_RT,
+ ImageResources.CONTEXT_MENU_R,
+ ImageResources.CONTEXT_MENU_RB,
+ ImageResources.CONTEXT_MENU_B,
+ ImageResources.CONTEXT_MENU_LB,
+ ImageResources.CONTEXT_MENU_L);
+ Rectangle rect = ((Canvas) e.widget).getClientArea();
+ popupImage = PatchImageResources.getComboPopupImage(
+ rect.width, rect.height, ninePatchImagesInfo);
+ }
+ e.gc.drawImage(popupImage, 0, 0);
+ }
+
+
+ private void addDisposeListener() {
+ popupCanvas.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ System.out.println("popup disposing");
+ if (popupImage != null) {
+ popupImage.dispose();
+ popupImage = null;
+ }
+ itemRects.clear();
+ }
+ });
+ }
+}
popupShell.open();
}
- private Listener popupMouseEventListener = new Listener() {
+ private final Listener popupMouseEventListener = new Listener() {
@Override
public void handleEvent(Event event) {
switch(event.type) {
popupShell = null;
}
- private PaintListener paintListener = new PaintListener() {
+ private final PaintListener paintListener = new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
}
};
- private DisposeListener disposeListener = new DisposeListener() {
+ private final DisposeListener disposeListener = new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
WidgetHelper.tryDispose(popupCanvas, popupShell);
private final Map<WSTATE, Image> imageMap = new HashMap<WSTATE, Image>();
private WSTATE state = WSTATE.NORMAL;
+
+ protected void draw(PaintEvent e) {
+ // This is for sub-class
+ }
+
+ protected boolean isSelected() {
+ return state == WSTATE.SELECTED;
+ }
+
protected void setState(WSTATE state) {
this.state = state;
}
@Override
public void paintControl(PaintEvent e) {
drawBox(e);
+ draw(e);
}
});
}
+
private void drawBox(PaintEvent e) {
// get box image
Image image = imageMap.get(state);
private static NinePatchResourceMap ninePatchResourceMap;
private Text text;
- private final ColorResources TEXT_BACKGROUND = ColorResources.WHITE;
private final int TEXT_MARGIN_WIDTH = 2;
private final int TEXT_MARGIN_HEIGHT = 2;
public TextInputBox(Composite parent, int style) {
super(parent, style);
initNinePatchResourceMap();
- init();
+ initBox();
+ createText();
}
text.setText(value);
}
-
- private void init() {
- initBox();
- initText();
- }
-
-
private void initBox() {
GridLayout layout = new GridLayout();
layout.marginHeight = TEXT_MARGIN_HEIGHT;
}
- private void initText() {
+ private void createText() {
GridData data = new GridData();
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = SWT.FILL;
- data.verticalAlignment = SWT.FILL;
+ data.verticalAlignment = SWT.CENTER;
text = new Text(this, SWT.NONE);
text.setFont(FontResources.CONTENT.getFont());
text.setForeground(ColorResources.CONTENT_FONT.getColor());
- text.setBackground(TEXT_BACKGROUND.getColor());
+ text.setBackground(ColorResources.WHITE.getColor());
text.setLayoutData(data);
removeTextBorder();
@Override
public void paintControl(PaintEvent e) {
// remove by overwriting border with background's color
- e.gc.setForeground(TEXT_BACKGROUND.getColor());
+ e.gc.setForeground(ColorResources.WHITE.getColor());
e.gc.setLineWidth(TEXT_BORDER_WIDTH);
Rectangle rect = ((Text)e.widget).getBounds();
package org.tizen.emulator.manager.ui.renewal.widgets;
+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.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Widget;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
-class WidgetHelper {
+public class WidgetHelper {
public static void tryDispose(final Object... Disposables) {
if (null == Disposables) {
return;
}
}
}
+
+
+ // draw text
+ // - valign : center
+ // - horizontal left: default 0
+ public static void drawText(Composite comp, final String text, final int horizentalAlign) {
+ comp.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+
+ GC gc = e.gc;
+ gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+ gc.setFont(FontResources.CONTENT.getFont());
+
+ int itemHeight = ((Composite)e.widget).getBounds().height;
+ Point textExt = gc.textExtent(text);
+ int posY = (itemHeight - textExt.y) / 2;
+
+ int posX = 0;
+ if (horizentalAlign == SWT.CENTER) {
+ int itemWidth = ((Composite)e.widget).getBounds().width;
+ posX = (itemWidth - textExt.x)/ 2;
+ }
+ gc.drawText(text, posX, posY);
+ }
+
+ });
+ }
}