- It support create template.
- It support modify template.(not complete yet)
- Now, UI is fixed. This should be changed to load XML.
Change-Id: Ib81c3019ecc66660c23335fc60ecca4ce700c7b1
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
import org.tizen.emulator.manager.device.xml.template.DeviceItemValue;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.RESOLUTION;
public class DeviceTemplateValue implements Cloneable {
private int ramSize = 512;
private int cpuCount = 1;
+ public String getPrintValue() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("name : " + name + StringResources.NEW_LINE);
+ sb.append("profile : " + profile + StringResources.NEW_LINE);
+ sb.append("resolution : " + resolution.toString() + StringResources.NEW_LINE);
+ sb.append("width : " + displayWidth + StringResources.NEW_LINE);
+ sb.append("height : " + displayHeight + StringResources.NEW_LINE);
+ sb.append("size : " + displaySize + StringResources.NEW_LINE);
+ sb.append("ram : " + ramSize + StringResources.NEW_LINE);
+ sb.append("processor : " + cpuCount + StringResources.NEW_LINE);
+ sb.append(StringResources.NEW_LINE);
+ sb.append("======= sub devices ========");
+ sb.append(StringResources.NEW_LINE);
+ for (SubDevice subDev : additionalDevices) {
+ sb.append(" " + subDev.getName() + " : ");
+ for (SubDeviceItem item : subDev.getItems()) {
+ sb.append(item.getId() + "(" + item.isSupport() + ")" + ", ");
+ }
+ sb.append(StringResources.NEW_LINE);
+ }
+
+ return sb.toString();
+ }
private List<SubDevice> additionalDevices = new ArrayList<SubDevice>();
public DeviceTemplateValue(DeviceTemplate template) {
--- /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.dialoghandler.renewal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.devices.DeviceTemplateCreator;
+import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
+import org.tizen.emulator.manager.ui.renewal.dialog.DeviceTemplateModifyDialog;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.DeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProcessorItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.template.CameraItem;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DeviceTemplateDialogHandler {
+
+ public static final String TITLE_CREATE = "New Template";
+ public static final String TITLE_MODIFY = "Modify Template";
+ public static final String TITLE_CLONE = "Clone Template";
+
+
+ public static void create(DeviceTemplateValue value) {
+
+ if (value == null) {
+ value = new DeviceTemplateValue(null);
+ }
+
+ DeviceTemplateValue itemValue = value.clone();
+ DeviceTemplateModifyDialog dialog = createDialog(TITLE_CREATE, true, itemValue);
+
+ int retValue = dialog.open();
+
+ if (retValue == SWT.OK) {
+ dialog.saveDataInto(itemValue);
+ DeviceTemplateCreator.create(itemValue);
+
+ // TODO for test
+ System.out.println(itemValue.getPrintValue());
+ }
+ }
+
+
+ public static void clone(DeviceTemplateValue value) {
+ DeviceTemplateValue newValue = value.clone();
+ int retValue = createDialog(TITLE_CLONE, true, newValue).open();
+ if (retValue == SWT.OK) {
+ // TODO do clone
+ }
+ }
+
+
+ public static void modify(DeviceTemplateValue value) {
+ if (value == null) {
+ value = new DeviceTemplateValue(null);
+ }
+
+ DeviceTemplateValue itemValue = value.clone();
+ DeviceTemplateModifyDialog dialog = createDialog(TITLE_MODIFY, false, itemValue);
+
+ int retValue = dialog.open();
+
+ if (retValue == SWT.OK) {
+ dialog.saveDataInto(itemValue);
+
+ // TODO for test
+ System.out.println(itemValue.getPrintValue());
+
+ // TODO do modify
+ }
+ }
+
+
+
+ private static DeviceTemplateModifyDialog createDialog(
+ String dialogTitle, boolean isCreateMode, DeviceTemplateValue value) {
+
+ // open dialog
+ DeviceTemplateModifyDialog dialog =
+ new DeviceTemplateModifyDialog(MainDialog.getShell(), dialogTitle);
+ dialog.setCreateMode(isCreateMode);
+ dialog.create(value, getItemList(null));
+
+ return dialog;
+
+ }
+
+ private static List<ModifyDialogItem> getItemList(VMProperty property) {
+ // TODO make item list using Image's item-template
+ return getTmpItemList();
+
+ }
+
+
+ // FOR TES
+ public static List<ModifyDialogItem> getTmpItemList() {
+ List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
+
+ itemList.add(new NameItem("deviceTemplateName", "Device Name"));
+ itemList.add(new ProfileItem());
+ itemList.add(new DisplayItem());
+ itemList.add(new RamSizeItem());
+ itemList.add(new ProcessorItem());
+ itemList.add(new SensorItem());
+ itemList.add(new DeviceItem());
+ itemList.add(new CameraItem());
+
+
+
+ return itemList;
+ }
+
+}
*/
-package org.tizen.emulator.manager.handler.renewal;
+package org.tizen.emulator.manager.dialoghandler.renewal;
import java.util.ArrayList;
import java.util.List;
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.common.DeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ImageItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProcessorItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
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.vms.VMProperty;
public class VMModifyHandler {
// open modify dialog
VMModifyDialog dialog = new VMModifyDialog(MainDialog.getShell());
- dialog.create(property, getItemList(property));
+ dialog.setCreateMode(false);
+ dialog.create(property.getPropertyValue(), getItemList(property));
// TODO set display value to dialog
public static List<ModifyDialogItem> getTmpItemList() {
List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
- itemList.add(new VMNameItem());
+ itemList.add(new NameItem("vmName", "VM name"));
itemList.add(new ProfileItem());
itemList.add(new ImageItem());
DeviceTemplateItem deviceItem = new DeviceTemplateItem();
BTN_PROFILE_MOBILE_UNSELECTED_NML("btn_profile_mobile_unselected_nml"),
BTN_PROFILE_WEARABLE_SELECTED("btn_profile_wearable_selected"),
BTN_PROFILE_WEARABLE_UNSELECTED_HOVER("btn_profile_wearable_unselected_hover"),
- BTN_PROFILE_WEARABLEE_UNSELECTED_NML("btn_profile_wearable_unselected_nml"),
+ BTN_PROFILE_WEARABLE_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"),
--- /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.dialog;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DeviceTemplateModifyDialog extends ModifyDialog {
+
+ public final static int WIDTH = 484;
+ private final static int HEIGHT = 496;
+
+ public DeviceTemplateModifyDialog(Shell parent, String title) {
+ super(parent, title, WIDTH, HEIGHT);
+ }
+
+
+ public void create(DeviceTemplateValue value, List<ModifyDialogItem> itemList) {
+ // - create title, buttons
+ // - init body
+
+ super.create(new PropertyValue(value), itemList);
+
+
+ }
+
+
+ public void setItemValue(VMProperty property) {
+
+ }
+
+
+}
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.renewal.widgets.GrayButton;
public class Dialog {
private final Shell parent;
private final String title;
- private final int width;
+ protected final int width;
private final int height;
private final int buttonStyle;
private Composite bodyComp;
private int returnValue = SWT.CANCEL;
+ // create / modify mode
+ private boolean isCreateMode = true;
+
+ private GrayButton okButton;
+
protected static final int BORDER_WIDTH = 1;
+ public void setOkButton(GrayButton okButton) {
+ this.okButton = okButton;
+ }
+
+ public void setOKButtonEnable(boolean enable) {
+ okButton.setEnabled(enable);
+ }
+
public Dialog(Shell parent, String title, int width, int height, int buttonStyle) {
this.parent = parent;
this.title = title;
}
-
private void makeDialog() {
DialogTitle.create(shell, childShell, title);
initBody();
bodyComp.setLayoutData(gridData);
}
+ public boolean isCreateMode() {
+ return isCreateMode;
+ }
+
+ public void setCreateMode(boolean isCreateMode) {
+ this.isCreateMode = isCreateMode;
+ }
+
}
data.verticalAlignment = SWT.CENTER;
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
- makeButton(CONFIRM, SWT.OK, data, buttonComp, dialog);
+ GrayButton okButton = makeButton(CONFIRM, SWT.OK, data, buttonComp, dialog);
+ dialog.setOkButton(okButton);
// Cancel button
data = new GridData(BUTTON_WIDTH, BUTTON_HEIGHT);
makeButton(CANCEL, SWT.CANCEL, data, buttonComp, dialog);
}
- private static void makeButton(final String text, final int type, GridData data, Composite buttonComp, final Dialog dialog) {
+ private static GrayButton makeButton(final String text, final int type, GridData data, Composite buttonComp, final Dialog dialog) {
GrayButton button = new GrayButton(buttonComp, SWT.PUSH);
button.setText(text);
button.setLayoutData(data);
}
}
});
+ return button;
}
}
--- /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.dialog;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+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.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+
+public class ModifyDialog extends Dialog {
+
+ private Composite scrolledContent;
+ private List<ModifyDialogItem> itemList;
+
+ private final static int BUTTON_STYLE = SWT.OK | SWT.CANCEL;
+
+ private PropertyValue propertyValue;
+
+ public ModifyDialog(Shell parent, String title, int width, int height) {
+ super(parent, title, width, height, BUTTON_STYLE);
+ // TODO Auto-generated constructor stub
+ }
+
+
+ public void create(PropertyValue value, List<ModifyDialogItem> itemList) {
+ super.create();
+ this.itemList = itemList;
+ this.propertyValue = value;
+ createDialogBody();
+ checkValid();
+ }
+
+ private void createDialogBody() {
+ initScrolledComposite();
+ makeModifyItem();
+ }
+
+ private void makeModifyItem() {
+ for (ModifyDialogItem item : itemList) {
+ item.setDialog(this);
+
+ // TODO we need default value for dialog
+ item.setInitialValue(propertyValue);
+
+ item.create(scrolledContent);
+ }
+
+ // set scrolled-content size
+ computeScrolledContentSize();
+ }
+
+ private void computeScrolledContentSize() {
+ int height = 0;
+ 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
+ Composite bodyComp = getBodyComposite();
+ bodyComp.setLayout(new FillLayout());
+ ScrolledComposite sc = new ScrolledComposite(bodyComp, SWT.V_SCROLL);
+ scrolledContent = new Composite(sc, SWT.NONE);
+
+ // add content
+ sc.setContent(scrolledContent);
+ scrolledContent.setBackground(ColorResources.BLACK.getColor());
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.verticalSpacing = 0;
+ scrolledContent.setLayout(layout);
+ }
+
+
+ public PropertyValue getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ public void checkValid() {
+ boolean isOKButtonEnable = true;
+ for (ModifyDialogItem dialogItem : itemList) {
+ if (!dialogItem.isValid()) {
+ isOKButtonEnable = false;
+ break;
+ }
+ }
+
+ if (!isCreateMode()) {
+ // TODO check change
+ }
+
+ setOKButtonEnable(isOKButtonEnable);
+ }
+
+ public void saveDataInto(Object obj) {
+ PropertyValue value = new PropertyValue(obj);
+
+ for(ModifyDialogItem item : itemList) {
+ item.setValue(value);
+ }
+ }
+
+
+
+}
import java.util.List;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridLayout;
-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.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
-public class VMModifyDialog extends Dialog {
+public class VMModifyDialog extends ModifyDialog {
private final static String TITLE = "VM Modify";
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<ModifyDialogItem> itemList;
- private VMProperty property;
public VMModifyDialog(Shell parent) {
- super(parent, TITLE, WIDTH, HEIGHT, BUTTON_STYLE);
+ super(parent, TITLE, WIDTH, HEIGHT);
}
- public void create(VMProperty property, List<ModifyDialogItem> itemList) {
+ public void create(VMPropertyValue value, List<ModifyDialogItem> itemList) {
// - create title, buttons
// - init body
- super.create();
-
- // make body contents
- this.property = property;
- this.itemList = itemList;
- createScrolledComposite();
- }
+ super.create(new PropertyValue(value), itemList);
- public void setItemValue(VMProperty property) {
-
}
- private void createScrolledComposite() {
- initScrolledComposite();
- makeModifyItem();
- }
-
- private void makeModifyItem() {
- for (ModifyDialogItem item : itemList) {
- item.setParentDialog(this);
- item.setInitialValue(property);
- item.create(scrolledContent);
- }
+ public void setItemValue(VMProperty property) {
- // set scrolled-content size
- computeScrolledContentSize();
}
- private void computeScrolledContentSize() {
- int height = 0;
- 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
- Composite bodyComp = getBodyComposite();
- bodyComp.setLayout(new FillLayout());
- ScrolledComposite sc = new ScrolledComposite(bodyComp, SWT.V_SCROLL);
- scrolledContent = new Composite(sc, SWT.NONE);
-
- // add content
- sc.setContent(scrolledContent);
- scrolledContent.setBackground(ColorResources.BLACK.getColor());
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.verticalSpacing = 0;
- scrolledContent.setLayout(layout);
- }
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
+
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.swt.layout.GridData;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
public abstract class CheckBoxItem extends ModifyDialogItem {
private int rowNum;
private final int numColumns;
+ List<CheckBoxSubItem> subItemList = new ArrayList<CheckBoxSubItem>();
+
+ public List<CheckBoxSubItem> getSubItemList() {
+ return subItemList;
+ }
+
// TODO should be structures that have name, title
- private final String[] checkBoxList;
+ private List<CheckItemData> dataList;
- public CheckBoxItem(int numColomn, String[] checkBoxList) {
+ public CheckBoxItem(String name, String title, int numColomn) {
+ super(name, title);
this.numColumns = numColomn;
- this.checkBoxList = checkBoxList;
+ }
+
+ public void setDataList(List<CheckItemData> dataList) {
+ this.dataList = dataList;
initRowNum();
}
private void initRowNum() {
- rowNum = checkBoxList.length / numColumns;
- if (checkBoxList.length % numColumns != 0) {
+ rowNum = dataList.size() / numColumns;
+ if (dataList.size() % numColumns != 0) {
rowNum++;
}
}
item.setBodyLayoutGrid(numColumns);
CheckBoxSubItem checkBoxItem;
- for (int i=0 ; i < checkBoxList.length ; i++) {
- String sensor = checkBoxList[i];
- checkBoxItem = new CheckBoxSubItem(item.getBody(), sensor, sensor);
+ for (int i=0 ; i < dataList.size() ; i++) {
+ CheckItemData checkItemData = dataList.get(i);
+ checkBoxItem = new CheckBoxSubItem(this, item.getBody(),
+ checkItemData.getName(), checkItemData.getTitle(), checkItemData.isChecked());
// set checkbox item layout
GridData data = new GridData();
data.heightHint = ROW_HEIGHT;
data.widthHint = ModifyItem.BODY_CONTENT_WIDTH / numColumns;
checkBoxItem.create(data);
+
+ subItemList.add(checkBoxItem);
+ }
+ }
+
+ public void checkBoxSelected() {
+ getDialog().checkValid();
+ }
+
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ List<CheckItemData> dataList = value.getCheckOptions(getName());
+ for (CheckItemData data : dataList) {
+ String name = data.getName();
+ boolean isChecked = data.isChecked();
+ for (CheckItemData ownData : dataList) {
+ if (ownData.getName().equals(name)) {
+ ownData.setChecked(isChecked);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void setValue(PropertyValue value) {
+
+ List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+ for (CheckBoxSubItem subItem : getSubItemList()) {
+ dataList.add(new CheckItemData(
+ subItem.getName(),
+ subItem.getTitle(), subItem.isChecked()));
}
+ value.setCheckOptions(getName(), dataList);
+
}
+
}
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
+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.FontResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
import org.tizen.emulator.manager.ui.renewal.widgets.CheckBoxButton;
public class CheckBoxSubItem {
+
+ private final CheckBoxItem parentItem;
private final Composite parentComp;
private final String name;
private final String title;
private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
- public CheckBoxSubItem(Composite parentComp, String name, String title) {
+ public CheckBoxSubItem(CheckBoxItem parentItem, Composite parentComp,
+ String name, String title, boolean isChecked) {
+ this.parentItem = parentItem;
this.parentComp = parentComp;
this.name = name;
this.title = title;
+ this.isChecked = isChecked;
}
public void create(Object layoutData) {
createCheckBox();
drawTitle();
+ addSelectionListener();
}
// TODO change to checkBoxWidget
checkBox = new CheckBoxButton(comp, SWT.NONE);
checkBox.setLayoutData(data);
+ checkBox.setSelection(isChecked);
+
+ }
+
+
+ private void addSelectionListener() {
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ switch(e.type) {
+ case SWT.Selection:
+ isChecked = ((CheckBoxButton)e.widget).isSelection();
+ parentItem.checkBoxSelected();
+ default:
+ break;
+ }
+ }
+ };
+ checkBox.addListener(SWT.Selection, listener);
}
});
}
+
+ public String getName() {
+ return name;
+ }
+
+
+ public String getTitle() {
+ return title;
+ }
+
+
+ public boolean isChecked() {
+ return isChecked;
+ }
+
+
+ public void setChecked(boolean isChecked) {
+ this.isChecked = isChecked;
+ }
+
+// public
}
--- /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.common;
+
+public class CheckItemData {
+ private String name;
+ private String title;
+ private boolean isChecked;
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isChecked() {
+ return isChecked;
+ }
+
+ public void setChecked(boolean isChecked) {
+ this.isChecked = isChecked;
+ }
+
+ public CheckItemData(String name, String title) {
+ this(name, title, false);
+ }
+
+ public CheckItemData(String name, String title, boolean isChecked) {
+ this.name = name;
+ this.title = title;
+ this.isChecked = isChecked;
+ }
+
+
+}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
+
+import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
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.item.modify.comp.ModifyItem;
import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
private ComboBox comboBox;
+ public ComboItem(String name, String title) {
+ super(name, title);
+ }
+
+
+ protected void addComboItem(String item) {
+ comboBox.addItem(item);
+ }
+
+ protected List<String> getComboItemList() {
+ return comboBox.getItemList();
+ }
+
+ protected String getComboItem(int index) {
+ return comboBox.getItemList().get(index);
+ }
+
+
+ protected void selectComboItem(int index) {
+ comboBox.select(index);
+ }
+
+ protected String getSelectedItem() {
+ return comboBox.getSelectedItem();
+ }
+
+
protected void createCombo(ModifyItem item, int width) {
// item.setBodyLayoutDefault();
//
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 = new ComboBox(getDialog().getShell(), item.getBody(), SWT.NONE);
comboBox.setLayoutData(data);
addSelectionListener();
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
+
+import java.util.ArrayList;
+import java.util.List;
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;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
public class DeviceItem extends CheckBoxItem {
- private final SubTreeModifyItem item;
+ private final ModifyItem item;
- private final String TITLE = "Device";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE;
+ private static final String TITLE = "Device";
+ private static final String NAME = "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"};
+ // TODO load from xml
+ private final List<CheckItemData> dataList =
+ new ArrayList<CheckItemData>();
+
+ private void initDataList() {
+ dataList.add(new CheckItemData("nfc", "NFC"));
+ }
+ /** constructor for tree sub item */
public DeviceItem(TreeModifyItem treeRoot) {
- super(NUM_COLUMN, sensorList);
+ super(NAME, TITLE, NUM_COLUMN);
+ initDataList();
+ setDataList(dataList);
item = new SubTreeModifyItem();
item.setItemHeight(getContentHeight());
- treeRoot.addSubItem(item);
+ treeRoot.addSubItem((SubTreeModifyItem)item);
+ }
+
+ public DeviceItem() {
+ super(NAME, TITLE, NUM_COLUMN);
+ initDataList();
+ setDataList(dataList);
+ item = new ModifyItem();
+ item.setItemHeight(getContentHeight());
}
@Override
public void create(Composite parent) {
item.init(parent);
- item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.setItemTitle(createIconTitle(item, null));
item.create();
createCheckBoxItems(item);
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.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.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.RESOLUTION;
+
+public class DisplayItem extends ModifyDialogItem {
+
+ private final ModifyItem item;
+
+ private static final String TITLE = "Display";
+ private static final String NAME = "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; // TODO
+
+
+ /** constructor for tree sub item */
+ public DisplayItem(TreeModifyItem treeRoot) {
+ super(NAME, TITLE);
+ item = new SubTreeModifyItem();
+ item.setItemHeight(ROW_HEIGHT * ROW_NUM);
+ treeRoot.addSubItem((SubTreeModifyItem)item);
+ }
+
+
+ public DisplayItem() {
+ super(NAME, TITLE);
+ item = new ModifyItem();
+ item.setItemHeight(ROW_HEIGHT * ROW_NUM);
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(createIconTitle(item, TITLE_ICON_RESOURCE));
+ item.create();
+
+ item.setBodyLayoutDefault();
+ createResolutionComboItem();
+ createResolutionTextItem();
+ createSizeItem();
+ createSkinItem();
+
+ initResolutionCombo();
+ }
+
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ resolution = value.getResolution();
+ displaySize = String.valueOf(value.getDisplaySize());
+ displayWidth = String.valueOf(value.getDisplayWidth());
+ displayHeight = String.valueOf(value.getDisplayHeight());
+ }
+
+
+ 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;
+
+ List<RESOLUTION> resList;
+ private RESOLUTION resolution;
+ private String displayWidth = "";
+ private String displayHeight = "";
+ private String displaySize = "";
+
+
+ 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(getDialog().getShell(), comp, SWT.NONE);
+ resolutionCombo.setLayoutData(data);
+
+ }
+
+ private void initResolutionCombo() {
+ // init resolution list
+ // TODO from XML
+ resList = new ArrayList<RESOLUTION>();
+ resList.add(RESOLUTION.HD);
+ resList.add(RESOLUTION.HD1080);
+ resList.add(RESOLUTION.HVGA);
+ resList.add(RESOLUTION.QHD);
+ resList.add(RESOLUTION.R_360_480);
+ resList.add(RESOLUTION.WQXGA);
+
+ // add combo list
+ for (RESOLUTION res : resList) {
+ resolutionCombo.addItem(res.toString());
+ }
+
+ // select resolution
+ // TODO default resolution
+ String re = null;
+ if (resolution != null) {
+ re = resolution.toString();
+ } else {
+ re = resList.get(0).toString();
+ }
+
+ // select combobox
+ for (int i=0 ; i < resolutionCombo.getItemList().size() ; i++) {
+ String str = resolutionCombo.getItemList().get(i);
+ if (str.equals(re)) {
+ resolutionCombo.select(i);
+ break;
+ }
+ }
+ resolutionComboSelected(re);
+
+ addResolutionComboListener();
+ }
+
+
+ private void addResolutionComboListener() {
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.Selection:
+ resolutionComboSelected(resolutionCombo.getSelectedItem());
+
+ default:
+ break;
+ }
+
+ }
+ };
+ resolutionCombo.addListener(SWT.Selection, listener);
+ }
+
+
+
+ private void resolutionComboSelected(String re) {
+ resolutionCombo.setToolTipText(re);
+
+ // find resolution
+ RESOLUTION d = null;
+ for (RESOLUTION r : resList) {
+ if (re.equals(r.toString())) {
+ d = r;
+ }
+ }
+
+ if (d != null) {
+ resolution = d;
+ setResolutionTextBox();
+ }
+
+
+ // TODO checkValid is needed?
+ getDialog().checkValid();
+
+// if (d == null) {
+// if (re.equals(oldResolution.toString())) {
+// d = oldResolution;
+// }
+// }
+
+// if (d != null) {
+// EMLogger.getLogger().fine("Change Resolution -> " + d.getStrTypeValue()); //$NON-NLS-1$
+// resolution = d;
+// // TODO
+// displayItem.changeResolution(d);
+// }
+
+
+ }
+
+
+ private void setResolutionTextBox() {
+ if (resolution != null) {
+ displayWidth = String.valueOf(resolution.getResolution().getWidth());
+ displayHeight = String.valueOf(resolution.getResolution().getHeight());
+ widthTextBox.setText(displayWidth);
+ heightTextBox.setText(displayHeight);
+ }
+ }
+
+
+ private void createResolutionTextItem() {
+ Composite comp = createSubComp(1, "");
+
+ // text box for 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);
+
+
+ // text box for 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);
+
+ addWidthHeightListener();
+ }
+
+
+ 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);
+
+ selectSize();
+ addSizeListener();
+ }
+
+ private void selectSize() {
+ // TODO default value
+ sizeTextBox.setText("5.0");
+
+ displaySize = sizeTextBox.getValue();
+ getDialog().checkValid();
+ }
+
+
+ private void addSizeListener() {
+ sizeTextBox.getTextWidget().addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ displaySize = sizeTextBox.getValue();
+ getDialog().checkValid();
+ }
+ });
+ }
+
+ private void addWidthHeightListener() {
+ // TODO what should we do width custom widdth/height
+
+ widthTextBox.getTextWidget().addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ displayWidth = widthTextBox.getValue();
+ getDialog().checkValid();
+ }
+ });
+
+ heightTextBox.getTextWidget().addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ displayHeight = heightTextBox.getValue();
+ getDialog().checkValid();
+ }
+ });
+ }
+
+
+
+ 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(getDialog().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;
+ }
+
+
+ @Override
+ public void setValue(PropertyValue value) {
+ // set resolution
+ value.setResolution(resolution);
+
+ try {
+ // set display size (inch)
+ value.setDisplaySize(Double.parseDouble(displaySize));
+
+ // TODO set displayWidth, displayHeight
+ value.setDisplayWidth(Integer.parseInt(displayWidth));
+ value.setDisplayHeight(Integer.parseInt(displayHeight));
+
+
+ } catch (NumberFormatException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+ }
+
+
+ @Override
+ public boolean isValid() {
+
+ // check Size text box
+ if (displaySize.isEmpty()) {
+ return false;
+ }
+ try {
+ Double.parseDouble(displaySize);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+
+ // TODO check display width/height
+ if (displayWidth.isEmpty() || displayHeight.isEmpty()) {
+ return false;
+ }
+ try {
+ Integer.parseInt(displayWidth);
+ Integer.parseInt(displayHeight);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+
+}
* - S-Core Co., Ltd
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
public interface IModifyDialogItem {
/** To decide modify dialog */
public int getHeight();
- public void setInitialValue(VMProperty property);
+ public void setInitialValue(PropertyValue value);
+
+ public boolean isValid();
+
+ /** set dialog data to property value */
+ public void setValue(PropertyValue value);
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
public class ImageItem extends TextLabelItem {
- private final String TITLE = "Image";
+ private final static String TITLE = "Image";
+ private static final String NAME = "image";
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_IMAGE;
+ public ImageItem() {
+ super(NAME, TITLE);
+ }
+
@Override
public void create(Composite parent) {
- create(parent, TITLE, TITLE_ICON_RESOURCE);
+ create(parent, getTitle(), TITLE_ICON_RESOURCE);
}
@Override
- public void setInitialValue(VMProperty property) {
- if (property == null) {
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
return;
}
- value = property.getBaseImageName();
+ this.value = value.getImageName();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ // 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.common;
+
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.dialog.ModifyDialog;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+
+public abstract class ModifyDialogItem implements IModifyDialogItem {
+
+ private String title;
+ private String name;
+ private ModifyDialog dialog;
+
+ public ModifyDialogItem(String name, String title) {
+
+ this.title = title;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public ModifyDialog getDialog() {
+ return dialog;
+ }
+
+ public void setDialog(ModifyDialog dialog) {
+ this.dialog = dialog;
+ }
+
+ protected ItemTitle createIconTitle(ModifyItem item, ImageResources icon) {
+ if (item instanceof SubTreeModifyItem) {
+ return new SubTreeItemTitle(item.getItemComp(), title, icon);
+ }
+ return new IconItemTitle(item.getItemComp(),title, icon);
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+}
*
*/
-
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
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;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
-public class ProcessorItem extends ComboItem {
+public class NameItem extends TextInputBoxItem {
- private final SubTreeModifyItem item;
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_VMNAME;
+ private final int INPUT_BOX_WIDTH = 236;
- 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);
+ public NameItem(String name, String title) {
+ super(name, title);
}
+
@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);
-
+ create(parent, getTitle(), TITLE_ICON_RESOURCE, INPUT_BOX_WIDTH);
}
+
@Override
- public int getHeight() {
- return item.getHeight();
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
+ return;
+ }
+ this.value = value.getName();
}
+
@Override
- public void setInitialValue(VMProperty property) {
- // TODO Auto-generated method stub
+ public void textModified() {
+ getDialog().checkValid();
+ // TODO check validation
+ // TODO check confirm button enable/disable
}
@Override
- public void itemSelected(ComboBox comboBox) {
- // TODO change item list for selected template.
- System.out.println("item selected:" + comboBox.getSelectedItem());
+ public boolean isValid() {
+ if (value == null || value.isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setName(this.value);
}
+
}
--- /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.common;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.job.CheckVT;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+import org.tizen.emulator.manager.vms.CPU;
+
+public class ProcessorItem extends ComboItem {
+
+ private final ModifyItem item;
+
+ private static final String TITLE = "Processor";
+ private static final String NAME = "processor";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROCESSOR;
+ private final int COMBO_WIDTH = 124;
+
+ private int cpuNum;
+
+
+ /** constructor for tree sub item */
+ public ProcessorItem(TreeModifyItem treeRoot) {
+ super(NAME, TITLE);
+ item = new SubTreeModifyItem();
+ treeRoot.addSubItem((SubTreeModifyItem)item);
+ }
+
+ public ProcessorItem() {
+ super(NAME, TITLE);
+ item = new ModifyItem();
+
+
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(createIconTitle(item, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCombo(item, COMBO_WIDTH);
+ initProcessorCombo();
+
+ }
+
+ private void initProcessorCombo() {
+
+ // init combo list
+ for (CPU r : CPU.values()) {
+ addComboItem(r.toString());
+ }
+
+ // select item
+ int index = 0;
+ for (int i=0 ; i < getComboItemList().size() ; i++) {
+ if (getComboItemList().get(i).equals(String.valueOf(cpuNum))) {
+ index = i;
+ break;
+ }
+ }
+ selectComboItem(index);
+ comboSelected();
+ }
+
+
+
+ private void comboSelected() {
+ // get selected value
+ String value = getSelectedItem();
+ try {
+ cpuNum = Integer.valueOf(value);
+
+ } catch (NumberFormatException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+
+ getDialog().checkValid();
+ }
+
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
+ return;
+ }
+
+ if (getDialog().isCreateMode()) {
+ if (CheckVT.isNonUG()) {
+ cpuNum = 1;
+
+ } else {
+ // set MAX cpu value.
+ int maxNum = CPU.getMaxCpuNum();
+ if (maxNum > 4) {
+ cpuNum = 4; // 4 : target max cpu.
+ } else {
+ cpuNum = maxNum;
+ }
+ }
+
+ } else {
+ cpuNum = value.getCpuNum();
+ }
+
+ }
+
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ comboSelected();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setCpuNum(cpuNum);
+
+ }
+}
--- /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.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.Rectangle;
+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.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.widgets.ImageRadioButton;
+import org.tizen.emulator.manager.ui.renewal.widgets.WSTATE;
+
+public class ProfileItem extends ModifyDialogItem {
+
+
+ private ModifyItem item;
+ private Canvas imageCanvas;
+ private String currentProfile = "mobile"; // TODO this is temp default.
+
+ private final static String TITLE = "Profile";
+ private static final String NAME = "profile";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROFILE;
+ private final String MOBILE = "mobile";
+ private final String WEARABLE = "wearable";
+ private final String TV = "tv";
+ private final int PROFILE_IMAGE_WIDTH = 34;
+ private final int PROFILE_IMAGE_HEIGHT = 25;
+ private final int IMAGE_SPACING = 4;
+
+ // TODO profileList from XML ?
+ private final String[] profileList = new String[]{MOBILE,WEARABLE,TV};
+
+
+ private final Map<String, ImageRadioButton> buttonMap =
+ new HashMap<String, ImageRadioButton>();
+
+ public ProfileItem() {
+ super(NAME, TITLE);
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
+ return;
+ }
+ this.currentProfile = value.getProfile();
+ }
+
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item = new ModifyItem();
+ item.init(parent);
+ item.setItemTitle(createIconTitle(item, TITLE_ICON_RESOURCE));
+ item.create();
+
+ if (getDialog().isCreateMode()) {
+ createProfileButton();
+
+ } else {
+ createProfileImage();
+ }
+ }
+
+
+ private void createProfileImage() {
+ item.setBodyLayoutDefault();
+
+ // init canvas
+ GridData data = new GridData(PROFILE_IMAGE_WIDTH, PROFILE_IMAGE_HEIGHT);
+ data.verticalAlignment = SWT.CENTER;
+ data.grabExcessVerticalSpace = true;
+ imageCanvas = new Canvas(item.getBody(), SWT.NONE);
+ imageCanvas.setLayoutData(data);
+
+ // set image
+ drawProfileImage();
+ }
+
+
+ private void drawProfileImage() {
+ imageCanvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Image image = null;
+ if (currentProfile.equals(MOBILE)) {
+ image = ImageResources.BTN_PROFILE_MOBILE_SELECTED.getImage();
+
+ } else if (currentProfile.equals(WEARABLE)) {
+ image = ImageResources.BTN_PROFILE_WEARABLE_SELECTED.getImage();
+
+ } else if (currentProfile.equals(TV)) {
+ image = ImageResources.BTN_PROFILE_TV_SELECTED.getImage();
+ }
+
+ if (image != null) {
+ GC gc = e.gc;
+ Rectangle imgRect = image.getBounds();
+ gc.drawImage(image, imgRect.x, imgRect.y);
+ }
+ }
+ });
+ }
+
+
+
+ private void createProfileButton() {
+ item.getBody().setLayout(new FormLayout());
+ ImageRadioButton mobileButton = new ImageRadioButton(item.getBody());
+ mobileButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_MOBILE_UNSELECTED_NML);
+ mobileButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_MOBILE_UNSELECTED_HOVER);
+ mobileButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_MOBILE_SELECTED);
+ mobileButton.setToolTipText(MOBILE);
+
+ ImageRadioButton wearableButton = new ImageRadioButton(item.getBody());
+ wearableButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_WEARABLE_UNSELECTED_NML);
+ wearableButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_WEARABLE_UNSELECTED_HOVER);
+ wearableButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_WEARABLE_SELECTED);
+ wearableButton.setToolTipText(WEARABLE);
+
+ ImageRadioButton tvButton = new ImageRadioButton(item.getBody());
+ tvButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_TV_UNSELECTED_NML);
+ tvButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_TV_UNSELECTED_HOVER);
+ tvButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_TV_SELECTED);
+ tvButton.setToolTipText(TV);
+
+
+ int top = (ModifyItem.ITEM_HEIGHT - PROFILE_IMAGE_HEIGHT) / 2;
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, top);
+ data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT);
+ data.width = PROFILE_IMAGE_WIDTH;
+ data.height = PROFILE_IMAGE_HEIGHT;
+ mobileButton.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(0, top);
+ data.left = new FormAttachment(mobileButton, IMAGE_SPACING);
+ data.width = PROFILE_IMAGE_WIDTH;
+ data.height = PROFILE_IMAGE_HEIGHT;
+ wearableButton.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(0, top);
+ data.left = new FormAttachment(wearableButton, IMAGE_SPACING);
+ data.width = PROFILE_IMAGE_WIDTH;
+ data.height = PROFILE_IMAGE_HEIGHT;
+ tvButton.setLayoutData(data);
+
+ buttonMap.put(MOBILE, mobileButton);
+ buttonMap.put(WEARABLE, wearableButton);
+ buttonMap.put(TV, tvButton);
+
+ addSelectListener();
+ selectButton();
+
+ }
+
+
+ private void addSelectListener() {
+ for (final String profile : buttonMap.keySet()) {
+
+ buttonMap.get(profile).addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ if (e.type == SWT.Selection) {
+ currentProfile = profile;
+ }
+ }
+ });
+ }
+ }
+
+
+ private void selectButton() {
+ // TODO default
+ buttonMap.get(MOBILE).selectRadio();
+ if (currentProfile.isEmpty()) {
+ currentProfile = MOBILE;
+ }
+
+ for (String profile : buttonMap.keySet()) {
+ if (profile.equals(currentProfile)) {
+ buttonMap.get(profile).selectRadio();
+ }
+ }
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setProfile(currentProfile);
+
+ }
+
+}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
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.logging.EMLogger;
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.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
-import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.RAM_SIZE;
public class RamSizeItem extends ComboItem {
- private final SubTreeModifyItem item;
+ private final ModifyItem item;
+
+ private static final String TITLE = "Ram";
+ private static final String NAME = "ram";
- private final String TITLE = "Ram";
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_RAM;
private final int COMBO_WIDTH = 124;
+ private int ramSize = 512;
+
+ /** constructor for tree sub item */
public RamSizeItem(TreeModifyItem treeRoot) {
+ super(NAME, TITLE);
item = new SubTreeModifyItem();
- treeRoot.addSubItem(item);
+ treeRoot.addSubItem((SubTreeModifyItem)item);
}
+ public RamSizeItem() {
+ super(NAME, TITLE);
+ item = new ModifyItem();
+ }
+
+
@Override
public void create(Composite parent) {
item.init(parent);
- item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
+ item.setItemTitle(createIconTitle(item, TITLE_ICON_RESOURCE));
item.create();
createCombo(item, COMBO_WIDTH);
+ initRamSizeCombo();
addLabel();
}
+ private void initRamSizeCombo() {
+ // init combo list
+ for (RAM_SIZE r : RAM_SIZE.values()) {
+ addComboItem(r.toString());
+ }
+
+ // select item
+ int index = 0;
+ for (int i=0 ; i < getComboItemList().size() ; i++) {
+ if (getComboItemList().get(i).equals(String.valueOf(ramSize))) {
+ index = i;
+ break;
+ }
+ }
+ selectComboItem(index);
+ comboSelected();
+ }
+
+ private void comboSelected() {
+ // get selected value
+ String value = getSelectedItem();
+ try {
+ ramSize = Integer.valueOf(value);
+
+ } catch (NumberFormatException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+
+ getDialog().checkValid();
+ }
+
private void addLabel() {
FormData data = new FormData();
int left = ModifyItem.BODY_MARGIN_LEFT + COMBO_WIDTH + 6;
}
@Override
- public void setInitialValue(VMProperty property) {
- // TODO Auto-generated method stub
+ public void setInitialValue(PropertyValue value) {
+ ramSize = value.getRamSize();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setRamSize(ramSize);
}
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ // This is called when combo item is selected
+ // TODO override this.
+ comboSelected();
+ }
}
--- /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.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
+
+public class SensorItem extends CheckBoxItem {
+
+ private final ModifyItem item;
+
+ private static final String TITLE = "Sensor";
+ private static final String NAME = "sensor";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR;
+
+ private static final int NUM_COLUMN = 3;
+
+
+ // TODO load from xml
+ private final List<CheckItemData> dataList =
+ new ArrayList<CheckItemData>();
+
+ private void initDataList() {
+ dataList.add(new CheckItemData("accel", "Accelerometer"));
+ dataList.add(new CheckItemData("gyro", "Gyroscope"));
+ dataList.add(new CheckItemData("proxi", "Proximity"));
+ dataList.add(new CheckItemData("geo-magnetic", "Geo-magnetic"));
+ dataList.add(new CheckItemData("light", "Light"));
+ dataList.add(new CheckItemData("haptic", "Haptic"));
+ dataList.add(new CheckItemData("pressure", "Pressure"));
+
+ }
+
+ /** constructor for tree sub item */
+ public SensorItem(TreeModifyItem treeRoot) {
+ super(NAME, TITLE, NUM_COLUMN);
+ item = new SubTreeModifyItem();
+ initDataList();
+ setDataList(dataList);
+
+ item.setItemHeight(getContentHeight());
+ treeRoot.addSubItem((SubTreeModifyItem)item);
+ }
+
+
+ public SensorItem() {
+ super(NAME, TITLE, NUM_COLUMN);
+ initDataList();
+ setDataList(dataList);
+ item = new ModifyItem();
+ item.setItemHeight(getContentHeight());
+
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(createIconTitle(item, TITLE_ICON_RESOURCE));
+ item.create();
+
+ createCheckBoxItems(item);
+
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ List<CheckItemData> dataList = value.getCheckOptions(getName());
+ for (CheckItemData data : dataList) {
+ String name = data.getName();
+ boolean isChecked = data.isChecked();
+ for (CheckItemData ownData : this.dataList) {
+ if (ownData.getName().equals(name)) {
+ ownData.setChecked(isChecked);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void setValue(PropertyValue value) {
+
+ List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+ for (CheckBoxSubItem subItem : getSubItemList()) {
+ dataList.add(new CheckItemData(
+ subItem.getName(),
+ subItem.getTitle(), subItem.isChecked()));
+ }
+ value.setCheckOptions(getName(), dataList);
+
+ }
+
+
+
+
+}
--- /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.common;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox;
+import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
+
+public abstract class TextInputBoxItem extends ModifyDialogItem {
+
+ private ModifyItem item;
+ private TextInputBox textBox;
+
+ protected String value = "";
+
+ /** This is called when text is modified */
+ public abstract void textModified();
+
+ public TextInputBoxItem(String name, String title) {
+ super(name, title);
+ }
+
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ protected void create(Composite parent, String title,
+ ImageResources iconResource, int textBoxWidth) {
+ item = new ModifyItem();
+ item.init(parent);
+ item.setItemTitle(new IconItemTitle(item.getItemComp(), title, iconResource));
+ item.create();
+
+ makeBody(textBoxWidth);
+
+ }
+
+
+ protected void makeBody(int textBoxWidth) {
+ item.setBodyLayoutDefault();
+
+ if (getDialog().isCreateMode()) {
+ createTextBox(textBoxWidth);
+
+ } else {
+ createTextLabel();
+ }
+ }
+
+
+ // for create mode
+ private void createTextBox(int textBoxWidth) {
+ GridData data = new GridData();
+ data.heightHint = ModifyItem.WIDGET_HEIGHT;
+ data.widthHint = textBoxWidth;
+ data.grabExcessVerticalSpace = true;
+ data.verticalAlignment = SWT.CENTER;
+ textBox = new TextInputBox(item.getBody(), SWT.NONE);
+ textBox.setLayoutData(data);
+
+ addTextListener();
+ }
+
+ private void addTextListener() {
+ textBox.getTextWidget().addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ value = ((Text)e.widget).getText();
+ textModified();
+ }
+ });
+ }
+
+
+ private void createTextLabel() {
+ // init canvas;
+ GridData data = new GridData();
+ data.heightHint = getHeight() - ModifyItem.LINE_WIDTH;
+ data.horizontalAlignment = SWT.FILL;
+ data.grabExcessHorizontalSpace = true;
+ Canvas canvas = new Canvas(item.getBody(), SWT.NONE);
+ canvas.setLayoutData(data);
+
+ WidgetHelper.drawText(canvas, value, SWT.NONE);
+ }
+}
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.common;
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;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
public abstract class TextLabelItem extends ModifyDialogItem {
protected String value = "";
+
+ public TextLabelItem(String name, String title) {
+ super(name, title);
+ }
+
+
@Override
public int getHeight() {
return item.getHeight();
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+/*
+ * 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.comp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
iconCanvas.setLayoutData(data);
// draw icon
+ if (iconResource == null) {
+ return;
+ }
iconCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+/*
+ * 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.comp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
--- /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.comp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.devices.SubDevice;
+import org.tizen.emulator.manager.devices.SubDeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
+import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class PropertyValue {
+
+ // VMPropertyValue or DeviceTemplateValue
+ private VMPropertyValue vmValue;
+ private DeviceTemplateValue templateValue;
+
+
+ public PropertyValue(Object value) {
+ if (value instanceof VMPropertyValue) {
+ vmValue = (VMPropertyValue)value;
+
+ } else if (value instanceof DeviceTemplateValue) {
+ templateValue = (DeviceTemplateValue)value;
+ }
+ }
+
+
+ private boolean isVMValue() {
+ return vmValue != null;
+ }
+
+
+ private boolean isTemplateValue() {
+ return templateValue != null;
+ }
+
+
+ public String getName() {
+ if (isVMValue()) {
+ return vmValue.vmsName;
+
+ } else if (isTemplateValue()){
+ return templateValue.getName();
+ }
+
+ return "";
+ }
+
+
+ public void setName(String name) {
+ if (isVMValue()) {
+ vmValue.vmsName = name;
+
+ } else if (isTemplateValue()) {
+ templateValue.setName(name);
+ }
+ }
+
+
+ public String getImageName() {
+ if (isVMValue()) {
+ return vmValue.baseImage.getName();
+ }
+ return "";
+ }
+
+
+ public String getProfile() {
+ if (isVMValue()) {
+ return vmValue.baseImage.getProfile();
+ } else if (isTemplateValue()) {
+ return templateValue.getProfile();
+ }
+ return "";
+ }
+
+
+ public void setProfile(String profile) {
+ if (isVMValue()) {
+ // do nothing
+ } else if (isTemplateValue()) {
+ templateValue.setProfile(profile);
+ }
+ }
+
+ public void setResolution(RESOLUTION r) {
+ if (isVMValue()) {
+ vmValue.resolution = r;
+
+ } else if (isTemplateValue()) {
+ templateValue.setResolution(r);
+// templateValue.setDisplayWidth(r.getResolution().getWidth());
+// templateValue.setDisplayHeight(r.getResolution().getHeight());
+ }
+ }
+
+
+ public RESOLUTION getResolution() {
+ if (isVMValue()) {
+ return vmValue.resolution;
+
+ } else if (isTemplateValue()) {
+ return templateValue.getResolution();
+ }
+ return null;
+ }
+
+
+ public void setDisplaySize(double displaySize) {
+ if (isVMValue()) {
+ // nothing
+
+ } else if (isTemplateValue()) {
+ templateValue.setDisplaySize(displaySize);
+ }
+ }
+
+ public double getDisplaySize() {
+ if (isVMValue()) {
+
+
+ } else if (isTemplateValue()) {
+ return templateValue.getDisplaySize();
+ }
+ return 0.0;
+ }
+
+ public void setDisplayWidth(int displayWidth) {
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ templateValue.setDisplayWidth(displayWidth);
+ }
+ }
+
+ public int getDisplayWidth() {
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ return templateValue.getDisplayWidth();
+ }
+ return 0;
+ }
+
+
+ public void setDisplayHeight(int displayHeight) {
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ templateValue.setDisplayHeight(displayHeight);
+ }
+ }
+
+ public int getDisplayHeight() {
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ return templateValue.getDisplayHeight();
+ }
+ return 0;
+ }
+
+
+ public int getRamSize() {
+ if (isVMValue()) {
+ return vmValue.ramSize;
+
+ } else if (isTemplateValue()) {
+ return templateValue.getRamSize();
+ }
+ return 0;
+ }
+
+ public void setRamSize(int ramSize) {
+ if (isVMValue()) {
+ vmValue.ramSize = ramSize;
+
+ } else if (isTemplateValue()) {
+ templateValue.setRamSize(ramSize);
+ }
+ }
+
+ public void setCpuNum(int cpuNum) {
+ if (isVMValue()) {
+ vmValue.cpu = cpuNum;
+
+ } else if (isTemplateValue()) {
+ templateValue.setCpuCount(cpuNum);
+ }
+ }
+
+ public int getCpuNum() {
+ if (isVMValue()) {
+ return vmValue.cpu;
+
+ } else if (isTemplateValue()) {
+ return templateValue.getCpuCount();
+ }
+ return 1;
+ }
+
+
+ public void setCheckOptions(String name,
+ List<CheckItemData> dataList) {
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ SubDevice subDevice = new SubDevice(name);
+ for (CheckItemData data : dataList) {
+ SubDeviceItem subDeviceItem = new SubDeviceItem(data.getName());
+ subDeviceItem.setSupport(data.isChecked());
+ subDevice.addSubDeviceItem(subDeviceItem);
+ }
+ // TODO add is OK?
+ templateValue.getAdditionalDevices().add(subDevice);
+ }
+ }
+
+
+ public List<CheckItemData> getCheckOptions(String name) {
+ List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+ // TODO
+ if (isVMValue()) {
+ // TODO
+
+ } else if (isTemplateValue()) {
+ for (SubDevice subDevice : templateValue.getAdditionalDevices()) {
+ if (subDevice.getName().equals(name)) {
+ for (SubDeviceItem subDeviceItem : subDevice.getItems()) {
+ CheckItemData data = new CheckItemData(
+ subDeviceItem.getId(), "", subDeviceItem.isSupport());
+ dataList.add(data);
+ }
+ }
+ }
+ }
+ return dataList;
+ }
+
+
+// public
+/*
+ public RESOLUTION getResolution() {
+ if (isVMValue()) {
+ vmValue.
+
+ } else if (isTemplateValue()) {
+ templateValue.
+ }
+ }
+ */
+}
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+/*
+ * 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.comp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
iconCanvas.setLayoutData(data);
// draw icon
+ if (iconResource == null) {
+ return;
+ }
+
iconCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.vms.VMProperty;
+import org.eclipse.swt.layout.GridData;
-public class VMNameItem extends TextLabelItem {
- private final String TITLE = "VM Name";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_VMNAME;
+public class SubTreeModifyItem extends ModifyItem{
- @Override
- public void create(Composite parent) {
- create(parent, TITLE, TITLE_ICON_RESOURCE);
- }
-
- @Override
- public void setInitialValue(VMProperty property) {
- if (property == null) {
- return;
+ 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;
}
- value = property.getName();
- }
+ comp.setLayoutData(data);
+ }
+// @Override
+// @Override
+// public int getHeight() {
+// System.out.println(comp.getSize().y);
+// if (comp.isVisible()) {
+// return super.getHeight();
+// }
+// return 0;
+//
+// }
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
*/
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
+package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
import java.util.ArrayList;
import java.util.List;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
public class TreeModifyItem extends ModifyItem{
for (SubTreeModifyItem subItem : subItemList) {
subItem.changeExpanding(isExpand);
}
- modifyDialogItem.getParentDialog().layoutScrolledComposite();
+ modifyDialogItem.getDialog().layoutScrolledComposite();
}
public void setModifyDialogItem(ModifyDialogItem modifyDialogItem) {
*
*/
+package org.tizen.emulator.manager.ui.renewal.item.modify.template;
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+import java.util.ArrayList;
+import java.util.List;
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;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
-public class SensorItem extends CheckBoxItem {
+public class CameraItem extends CheckBoxItem {
- private final SubTreeModifyItem item;
+ private final ModifyItem item;
- private final String TITLE = "Sensor";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR;
+ private static final String TITLE = "Camera";
+ private static final String NAME = "camera";
+// private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR;
- private static final int NUM_COLUMN = 3;
+ private static final int NUM_COLUMN = 2;
+
+ // TODO load from xml
+ private static final List<CheckItemData> dataList =
+ new ArrayList<CheckItemData>();
+ private void initDataList() {
+ dataList.add(new CheckItemData("rear", "Rear"));
+ dataList.add(new CheckItemData("front", "Front"));
+ }
- // 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();
+ public CameraItem() {
+ super(NAME, TITLE, NUM_COLUMN);
+ initDataList();
+ setDataList(dataList);
+ item = new ModifyItem();
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.setItemTitle(createIconTitle(item, null));
item.create();
createCheckBoxItems(item);
return item.getHeight();
}
- @Override
- public void setInitialValue(VMProperty property) {
- // TODO Auto-generated method stub
-
- }
-
-
-
}
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.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.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 static final String TITLE = "Device";
+ private static final String NAME = "deviceTemplate";
private final TreeModifyItem item;
private final int COMBO_WIDTH = 200;
}
public DeviceTemplateItem() {
+ super(NAME, TITLE);
item = new TreeModifyItem();
}
@Override
public void create(Composite parent) {
item.init(parent);
- item.setItemTitle(new TreeItemTitle(item, TITLE));
+ item.setItemTitle(new TreeItemTitle(item, getTitle()));
item.create();
item.setModifyDialogItem(this);
}
@Override
- public void setInitialValue(VMProperty property) {
+ public void setInitialValue(PropertyValue value) {
// TODO Auto-generated method stub
}
System.out.println("item selected:" + comboBox.getSelectedItem());
}
+
+ @Override
+ public void setValue(PropertyValue value) {
+ // 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.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;
- }
-
-
-
-}
+++ /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.graphics.Image;
-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.IconItemTitle;
-import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
-import org.tizen.emulator.manager.vms.VMProperty;
-
-public class ProfileItem extends ModifyDialogItem {
-
- private ModifyItem item;
- private Canvas canvas;
- private String profile = "";
-
- private final String TITLE = "Profile";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROFILE;
- private final String MOBILE = "mobile";
- private final String WEARABLE = "wearable";
- private final String TV = "tv";
- private final int PROFILE_IMAGE_WIDTH = 34;
- private final int PROFILE_IMAGE_HEIGHT = 25;
-
-
- private void addProfileImage() {
- item.setBodyLayoutDefault();
-
- // init canvas
- GridData data = new GridData(PROFILE_IMAGE_WIDTH, PROFILE_IMAGE_HEIGHT);
- data.verticalAlignment = SWT.CENTER;
- data.grabExcessVerticalSpace = true;
- canvas = new Canvas(item.getBody(), SWT.NONE);
- canvas.setLayoutData(data);
-
- // set image
- Image profileImage = getProfileImage(profile);
- if (profileImage != null) {
- canvas.setBackgroundImage(profileImage);
- }
- }
-
- private Image getProfileImage(String profile) {
- if (profile.equals(MOBILE)) {
- return ImageResources.BTN_PROFILE_MOBILE_SELECTED.getImage();
-
- } else if (profile.equals(WEARABLE)) {
- return ImageResources.BTN_PROFILE_WEARABLE_SELECTED.getImage();
-
- } else if (profile.equals(TV)) {
- return ImageResources.BTN_PROFILE_TV_SELECTED.getImage();
- }
-
- return null;
- }
-
- @Override
- public void setInitialValue(VMProperty property) {
- if (property == null) {
- return;
- }
- this.profile = property.getImageProfile();
-
- }
-
- @Override
- public int getHeight() {
- return item.getHeight();
- }
-
- @Override
- public void create(Composite parent) {
- item = new ModifyItem();
- item.init(parent);
- item.setItemTitle(new IconItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE));
- item.create();
-
- addProfileImage();
- }
-}
+++ /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;
-//
-// }
-}
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.devices.DeviceTemplate;
import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.dialoghandler.renewal.DeviceTemplateDialogHandler;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.platform.Profile;
import org.tizen.emulator.manager.platform.ProfileList;
});
}
- private String[] titles = {"Type", "Name", "Resolution", "Display Size", "Ram", "Processor"};
+ private final String[] titles = {"Type", "Name", "Resolution", "Display Size", "Ram", "Processor"};
private void makeTable() {
table = new Table(comp, SWT.BORDER);
public void handleEvent(Event event) {
if (event.type == SWT.Selection) {
// TODO
+ DeviceTemplateDialogHandler.create(null);
}
}
});
@Override
public void handleEvent(Event event) {
if (event.type == SWT.Selection) {
- // TODO
+
+ // TODO check please
+ TableItem[] items = table.getSelection();
+ DeviceTemplate deviceTemplate = (DeviceTemplate)items[0].getData();
+ DeviceTemplateDialogHandler.modify(deviceTemplate.getValue());
+
}
}
});
table.setLayoutData(workerButtonData);
}
- private NinePatchResourceInfo normalInfo = new NinePatchResourceInfo(ColorResources.TABLE_VIEWER_BG,
+ private final NinePatchResourceInfo normalInfo = new NinePatchResourceInfo(ColorResources.TABLE_VIEWER_BG,
ColorResources.TABLE_VIEWER_BG,
null, //left top
ImageResources.BACK_BTN_NORMAL_C, // top -> center
null, // left bottom
ImageResources.BACK_BTN_NORMAL_L); // left
- private NinePatchResourceInfo hoverInfo = new NinePatchResourceInfo(ColorResources.TABLE_VIEWER_BG,
+ private final NinePatchResourceInfo hoverInfo = new NinePatchResourceInfo(ColorResources.TABLE_VIEWER_BG,
ColorResources.TABLE_VIEWER_BG,
null, //left top
ImageResources.BACK_BTN_HOVER_C, // top -> center
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import org.tizen.emulator.manager.handler.renewal.VMModifyHandler;
+import org.tizen.emulator.manager.dialoghandler.renewal.VMModifyHandler;
import org.tizen.emulator.manager.platform.Profile;
import org.tizen.emulator.manager.platform.ProfileList;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
public void setSelection(boolean selected) {
checkWidget();
isSelected = selected;
+ redraw();
}
public boolean isSelection() {
createText();
addMouseListener();
- // TODO for test
- items.add("combo 1");
- items.add("combo 2");
- items.add("combo 3");
}
popupCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
- System.out.println("popup disposing");
if (popupImage != null) {
popupImage.dispose();
popupImage = null;
redraw();
}
+
public boolean isSelection() {
return selected;
}
+
private void selectRadio() {
Control[] children = parent.getChildren();
for (int i = 0; i < children.length; i++) {
--- /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.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class ImageRadioButton extends Canvas {
+
+ WStateImageMap images = new WStateImageMap();
+ WSTATE state = WSTATE.NORMAL;
+
+ private final boolean isSelected = false;
+
+ public ImageRadioButton(Composite parent) {
+ super(parent, SWT.DOUBLE_BUFFERED | SWT.RADIO);
+ addMouseListener();
+ addPaintListener();
+ }
+
+ public void setImage(WSTATE state, ImageResources imageResource) {
+ images.put(state, imageResource);
+ }
+
+
+ private void addPaintListener() {
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Image image = images.get(state);
+
+ if (image != null) {
+ GC gc = e.gc;
+ Rectangle imgRect = image.getBounds();
+ gc.drawImage(image, imgRect.x, imgRect.y);
+ }
+ }
+ });
+ }
+
+
+ private void addMouseListener() {
+ Listener mouseListener = new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ if (e.type == SWT.MouseEnter) {
+ if (state == WSTATE.SELECTED) {
+ return;
+ }
+ state = WSTATE.HOVER;
+ redraw();
+
+ } else if (e.type == SWT.MouseExit) {
+ if (state == WSTATE.SELECTED) {
+ return;
+ }
+ state = WSTATE.NORMAL;
+ redraw();
+
+
+ } if (e.type == SWT.MouseUp) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ if (rect.contains(e.x, e.y)) {
+ selectRadio();
+ notifyListeners(SWT.Selection, new Event());
+ }
+ }
+ }
+ };
+ this.addListener(SWT.MouseEnter, mouseListener);
+ this.addListener(SWT.MouseExit, mouseListener);
+ this.addListener(SWT.MouseUp, mouseListener);
+ }
+
+
+ public void setState(WSTATE state) {
+ this.state = state;
+ }
+
+
+ public void selectRadio() {
+ Control[] children = this.getParent().getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof ImageRadioButton && child != this) {
+ ((ImageRadioButton) child).setState(WSTATE.NORMAL);
+ child.redraw();
+ }
+ }
+ setState(WSTATE.SELECTED);
+ redraw();
+ }
+
+// public void setSelection(boolean selected) {
+// state = WSTATE
+// if (selected) {
+// state = WSTATE.SELECTED;
+// }
+// }
+
+// private void setSelection(boolean selected) {
+// if (selected) {
+// state = (state == WSTATE.DISABLE_OFF) ? state : WSTATE.SELECTED;
+// this.selected = true;
+// } else {
+// state = state != WSTATE.DISABLE_ON ? WSTATE.NORMAL : WSTATE.DISABLE_ON;
+// this.selected = false;
+// }
+// }
+
+}
*
*/
+package org.tizen.emulator.manager.ui.renewal.widgets;
-package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
+public class ProfileImageButton extends ImageButton {
-public abstract class ModifyDialogItem implements IModifyDialogItem {
- private VMModifyDialog parentDialog;
+ private String profile;
- public VMModifyDialog getParentDialog() {
- return parentDialog;
+ public ProfileImageButton(Composite parent, int style) {
+ super(parent, style);
+ // TODO Auto-generated constructor stub
}
- public void setParentDialog(VMModifyDialog parentDialog) {
- this.parentDialog = parentDialog;
+ public void setProfile(String profile) {
+ this.profile = profile;
}
+
}
return ninePatchResourceMap;
}
+ public Text getTextWidget() {
+ return text;
+ }
+
public void setText(String value) {
text.setText(value);
}
+ public String getValue() {
+ return text.getText();
+ }
+
private void initBox() {
GridLayout layout = new GridLayout();
layout.marginHeight = TEXT_MARGIN_HEIGHT;
--- /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.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Image;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class WStateImageMap {
+
+ Map<WSTATE, ImageResources> resources = new HashMap<WSTATE, ImageResources>();
+ Map<WSTATE, Image> images = new HashMap<WSTATE, Image>();
+
+ public void put(WSTATE state, ImageResources imageResource) {
+ resources.put(state, imageResource);
+ }
+
+
+ public Image get(WSTATE state) {
+ Image img = images.get(state);
+ if (img == null) {
+ ImageResources imageResource = resources.get(state);
+ if (imageResource == null) {
+ return null;
+ }
+
+ img = imageResource.getImage();
+ images.put(state, img);
+ }
+
+ return img; // can be null
+ }
+}