}
+ public static Map<String, String> getOptionMap(List<VMItemOption> optionList) {
+ Map<String, String> optionMap = new HashMap<String, String>();
+ for (VMItemOption option : optionList) {
+ optionMap.put(option.getName(), option.getValue());
+ }
+ return optionMap;
+ }
+
+
public static List<String> getOptionList(List<VMItemOption> optionList) {
List<String> resultList = new ArrayList<String>();
for (VMItemOption option : optionList) {
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.CategoryItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceTemplateItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.FileSharingItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.GLVersionItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.HWSupportItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetConnectTypeItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetDnsItem;
} else if (name.equals(ItemName.CAMERA_LEGACY)) {
itemList.add(new CameraLegacyItem(name, title, VMTemplateUtil.getNumColomnOption(item),
treeRoot, VMTemplateUtil.getCheckBoxDataList(item)));
+
+ } else if (name.equals(ItemName.GL_VERSION)) {
+ itemList.add(new GLVersionItem(name, title,
+ VMTemplateUtil.getOptionMap(item.getOptions())));
}
}
optionList.add(Option.getInstance(CPUSupportOption.class));
optionList.add(Option.getInstance(GPUSupportOption.class));
- } else if (name.equals(ItemName.GL_VERSION)) { // TODO
+ } else if (name.equals(ItemName.GL_VERSION)) {
optionList.add(Option.getInstance(GLVersionOption.class));
} else if (name.equals(ItemName.NETWORK)) {
comboBox.setEnabled(enable);
}
+ protected void setItemEnable(boolean enable) {
+ comboBox.setEnabled(enable);
+ item.setTitleEnable(enable);
+ }
}
this.itemListComp = itemlistComp;
}
+
public ItemListComp getItemListComp() {
return itemListComp;
}
+
protected ItemTitle createIconTitle(ModifyItem item, ImageResources icon) {
if (item instanceof SubTreeModifyItem) {
return new SubTreeItemTitle(item.getItemComp(), title, icon);
}
+ protected ItemTitle createItemTitle(ModifyItem item) {
+ return new ItemTitle(item.getItemComp(), title, ItemTitle.TITLE_MARGIN_LEFT,
+ ItemTitle.TITLE_MARGIN_LEFT, ItemTitle.TITLE_BACKGROUND);
+ }
+
+
@Override
public boolean isValid() {
// Override this for item validation.
protected List<Skin> skinList;
protected SKIN_SHAPE imageSkinShape;
+ public SkinItem(String title) {
+ super(NAME, title);
+ }
+
public SkinItem() {
super(NAME, TITLE);
// TODO Auto-generated constructor stub
private Canvas iconCanvas;
private final ImageResources iconResource;
+ public static final int ICON_WIDTH = 18;
+ public static final int ICON_HEIGHT = 18;
+ private static final int TITLE_SPACING = 8;
private static int TITLE_MARGIN_LEFT = 15;
private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
public IconItemTitle(Composite parent, String title, ImageResources iconResource) {
- super(parent, title, TITLE_MARGIN_LEFT, background);
+ this(parent, title, TITLE_MARGIN_LEFT, iconResource, background);
+ }
+
+ public IconItemTitle(Composite parent, String title, int marginLeft,
+ ImageResources iconResource, ColorResources background) {
+ super(parent, title, marginLeft,
+ marginLeft + ICON_WIDTH + TITLE_SPACING, background);
this.iconResource = iconResource;
}
@Override
public void create(boolean drawLine) {
super.create(drawLine);
- makeIcon();
+
+ if (iconResource == null) {
+ return;
+
+ } else {
+ makeIcon();
+ }
}
private void makeIcon() {
iconCanvas = new Canvas(this, SWT.NONE);
iconCanvas.setLayoutData(data);
- // draw icon
- if (iconResource == null) {
- return;
- }
iconCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
public class ItemTitle extends Canvas{
- public static final int TITLE_SPACING = 8;
public static final int TITLE_CANVAS_WIDTH = 140;
// public static final int TITLE_CANVAS_WIDTH = 130;
private final int LINE_INDENT = 5;
-
- protected int ICON_WIDTH = 18;
- protected final int ICON_HEIGHT = 18;
+ public static int TITLE_MARGIN_LEFT = 15;
+ public static ColorResources TITLE_BACKGROUND =
+ ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
protected final String title;
private int marginLeft = 0;
+ private int titleIndent = 0;
protected final ColorResources background;
boolean isDrawBottomLine = true;
protected boolean isTitleEnable = true;
- public ItemTitle(Composite parent, String title, int marginLeft, ColorResources background) {
+ public ItemTitle(Composite parent, String title, int marginLeft, int titleIndent, ColorResources background) {
super(parent, SWT.NONE);
this.title = title;
this.marginLeft = marginLeft;
+ this.titleIndent = titleIndent;
this.background = background;
}
redraw();
}
- private void init() {
+ protected void init() {
GridData data = new GridData();
data.grabExcessVerticalSpace = true;
data.verticalAlignment = SWT.FILL;
Point textExt = gc.textExtent(title);
int titleY = (itemHeight - textExt.y) / 2;
gc.drawText(title,
- marginLeft + ICON_WIDTH + TITLE_SPACING, titleY);
+ titleIndent, titleY);
// draw under line
if (isDrawBottomLine) {
public SubItemTitle(Composite parent, String title,
ColorResources background, boolean drawVerticalLine, int titleWidth ) {
- super(parent, title, MARGIN_LEFT, background);
+ super(parent, title, MARGIN_LEFT, MARGIN_LEFT, background);
this.drawVerticalLine = drawVerticalLine;
this.titleWidth = titleWidth;
}
makeTitle(drawBottomLine);
}
- private void init() {
+ @Override
+ protected void init() {
GridData data = new GridData();
data.grabExcessVerticalSpace = true;
data.verticalAlignment = SWT.FILL;
package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-public class SubTreeItemTitle extends ItemTitle {
-
- private Canvas iconCanvas;
- private final ImageResources iconResource;
+public class SubTreeItemTitle extends IconItemTitle {
private static int TITLE_MARGIN_LEFT = 23;
private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_SUB_BACKGROUDN;
public SubTreeItemTitle(Composite parent, String title, ImageResources iconResource) {
- super(parent, title, TITLE_MARGIN_LEFT, background);
- this.iconResource = iconResource;
- }
-
-
- @Override
- public void create(boolean drawLine) {
- super.create(drawLine);
- makeIcon();
- }
-
- private void makeIcon() {
- // init
- GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT);
- data.verticalAlignment = SWT.CENTER;
- data.grabExcessVerticalSpace = true;
- iconCanvas = new Canvas(this, SWT.NONE);
- iconCanvas.setLayoutData(data);
-
- // draw icon
- if (iconResource == null) {
- return;
- }
-
- iconCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- GC gc = e.gc;
- gc.drawImage(iconResource.getImage(), 0, 0);
- }
- });
+ super(parent, title, TITLE_MARGIN_LEFT, iconResource, background);
}
}
import org.tizen.emulator.manager.renewal.resources.ColorResources;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-public class TreeItemTitle extends ItemTitle {
+public class TreeItemTitle extends IconItemTitle {
private Canvas arrowCanvas;
private boolean isExpanded = true;
private final TreeModifyItem treeRoot;
- private static int TITLE_MARGIN_LEFT = 15;
private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND;
private static ImageResources ARROW_EXPANDED = ImageResources.ICON_TITLE_TREE_EXPANDED;
private static ImageResources ARROW_CLOSED = ImageResources.ICON_TITLE_TREE_CLOSED;
public TreeItemTitle(TreeModifyItem treeRoot, String title) {
- super(treeRoot.getItemComp(), title, TITLE_MARGIN_LEFT, background);
+ super(treeRoot.getItemComp(), title, ItemTitle.TITLE_MARGIN_LEFT,
+ null, background);
this.treeRoot = treeRoot;
}
private void makeArrow() {
// init
- GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT);
+ GridData data = new GridData(IconItemTitle.ICON_WIDTH, IconItemTitle.ICON_HEIGHT);
data.verticalAlignment = SWT.CENTER;
data.grabExcessVerticalSpace = true;
arrowCanvas = new Canvas(this, SWT.NONE);
public class AdvancedSkinItem extends SkinItem {
- public static final int COMBO_WIDTH = 233;
+ public static final int COMBO_WIDTH = 232;
+ public static final String TITLE = "Emulator Skin";
public AdvancedSkinItem() {
- super();
+ super(TITLE);
// TODO Auto-generated constructor stub
}
public void create(Composite parent) {
item = new ModifyItem(this);
item.init(parent);
- item.setItemTitle(createIconTitle(item, null));
+// item.setItemTitle(createIconTitle(item, null));
+ item.setItemTitle(createItemTitle(item));
item.create();
createCombo(item, COMBO_WIDTH);
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_FILESHARING;
private static final String NAME="fileSharing";
private static final String TITLE="File Sharing";
- private final int TEXT_BOX_WIDTH = 233;
+ private final int TEXT_BOX_WIDTH = 232;
private String sharingPath;
--- /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 java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.job.CheckGPU;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+public class GLVersionItem extends ComboItem {
+
+ private final int COMBO_WIDTH = 232;
+ public static final String VER1_VER2 = "v1.1_v2.0"; //$NON-NLS-1$
+ public static final String VER2_VER3 = "v2.0_v3.0"; //$NON-NLS-1$
+
+ private final Map<String, String> optionMap;
+ String glVersion = "";
+
+ public GLVersionItem(String name, String title, Map<String, String> optionMap) {
+ super(name, title);
+ this.optionMap = optionMap;
+
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ item = new ModifyItem(this);
+ item.init(parent);
+ item.setItemTitle(createItemTitle(item));
+ item.create();
+
+ makeBody();
+
+ }
+
+ private void createDetailItem() {
+ createDetailItem(glVersion);
+ }
+
+ protected void makeBody() {
+ if (getItemListComp().isDetailMode()) {
+ createDetailItem();
+ return;
+ }
+
+ // create combo
+ createCombo(item, COMBO_WIDTH);
+ resetCombo();
+
+ }
+
+ // reset combo according to connect type (NAT / Bridge)
+ public void resetCombo() {
+
+ comboBox.clear();
+ if (checkActivate()) {
+ // enable & init combo
+ setItemEnable(true);
+ makeComboList();
+
+ // select item
+ selectItem();
+
+ } else {
+ // disable
+ comboBox.setText("");
+ setItemEnable(false);
+ }
+ }
+
+
+ private boolean checkActivate() {
+ boolean isActivate = true;
+ if (!CheckGPU.isGPUSupported()) {
+ isActivate = false;
+
+ } else {
+ isActivate = getItemListComp().getPropertyValue().getGPUAcceleration();
+ }
+
+ return isActivate;
+ }
+
+ private void makeComboList() {
+ // init list
+ if (optionMap.get(VER1_VER2) != null) {
+ addComboItem(optionMap.get(VER1_VER2), VER1_VER2);
+ }
+ if (optionMap.get(VER2_VER3) != null) {
+ addComboItem(optionMap.get(VER2_VER3), VER2_VER3);
+ }
+
+ // select item
+ selectItem();
+ }
+
+ private void selectItem() {
+ if (comboBox == null || comboBox.isDisposed()) {
+ return;
+ }
+
+ int index = -1;
+ for (int i=0 ; i < getComboItemList().size() ; i++) {
+ if (getComboItemList().get(i).equals(optionMap.get(glVersion))) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index == -1) {
+ index = 0;
+ glVersion = (String)getCobmoData(0);
+ }
+ selectComboItem(index, false);
+ comboSelected();
+ }
+
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ // This is called when combo item is selected
+ // TODO override this.
+ glVersion = (String)comboBox.getSelectedData();
+ comboSelected();
+ }
+
+ private void comboSelected() {
+ getItemListComp().checkValid();
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ glVersion = value.getSubOptionValue(getName());
+
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setSubOptionValue(getName(), glVersion);
+
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ return new GLVersionItem(getName(), getTitle(), optionMap);
+ }
+
+}
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.tizen.emulator.manager.job.CheckGPU;
import org.tizen.emulator.manager.job.CheckVT;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.Messages;
import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.widgets.ImageButton;
public class HWSupportItem extends ModifyDialogItem {
gpuItem.setToolTipText(GPUToolTipText);
}
+ gpuItem.addSelectionListener(new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Selection) {
+ // change button
+ ImageButton button = (ImageButton)event.widget;
+ button.setSelection(!button.isSelection());
+
+ // set on off value
+ gpuItem.setOnOffLabel();
+
+ // reset GLVersion item
+ setValue(getItemListComp().getPropertyValue());
+ setEnableGLVersion();
+ }
+ }
+ });
+ }
+
+
+ private void setEnableGLVersion() {
+ GLVersionItem item = (GLVersionItem)getItemListComp().getItem(ItemName.GL_VERSION);
+ if (item == null) {
+ return;
+ }
+
+ item.resetCombo();
}
resetCombo(false);
}
- protected void setItemEnable(boolean enable) {
- comboBox.setEnabled(enable);
- item.setTitleEnable(enable);
- }
public String getInterfaceName() {
return interfaceName;
return isOn;
}
+ private final Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Selection) {
+ // change button
+ ImageButton button = (ImageButton)event.widget;
+ button.setSelection(!button.isSelection());
+
+ // set on off value
+ setOnOffLabel();
+ }
+ }
+ };
+
+ public void setOnOffLabel() {
+ isOn = button.isSelection();
+ labelText = getLabelText(isOn);
+ textCanvas.redraw();
+ }
public void create(DIALOG_MODE mode, boolean onOff) {
// create comp
formData.width = BUTTON_WIDTH;
formData.height = BUTTON_HEIGHT;
button.setLayoutData(formData);
- button.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- if (event.type == SWT.Selection) {
- // change button
- ImageButton button = (ImageButton)event.widget;
- button.setSelection(!button.isSelection());
-
- // set on off value
- isOn = button.isSelection();
- labelText = getLabelText(isOn);
- textCanvas.redraw();
- }
- }
- });
+ button.addListener(SWT.Selection, listener);
// create canvas
textCanvas = new Canvas(this, SWT.NONE);
}
+ public void addSelectionListener(Listener listener) {
+ button.removeListener(SWT.Selection, this.listener);
+ button.addListener(SWT.Selection, listener);
+ }
+
private void drawTitle(final String title) {
drawItem(title, null);
}