- User can select skin.
- Skin-list is depend on resolution.
- Only general skin is available if user use custom resolution.
Change-Id: Icf7660ecf7941ee29835a2f5ebcc4b78aea47d47
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
RESOLUTION r = checkResolution(resolutionCommand.getCurrentValue());
prop.resolution = r;
prop.dpi = r.getDPI();
- ArrayList<Skin> list = null;
+ List<Skin> list = null;
if (prop.baseImage != null) {
list = prop.baseImage.getPlatform().findSkinList(prop.resolution);
}
}
} else {
if (skinCommand != null) {
- ArrayList<Skin> list = null;
+ List<Skin> list = null;
int i = 0;
i = Integer.parseInt(skinCommand.getCurrentValue());
if (prop.baseImage != null) {
prop.skinPath = null;
}
} else { // resolutionCommon == null and skinComman == null
- ArrayList<Skin> list = null;
+ List<Skin> list = null;
list = prop.baseImage.getPlatform().findGeneralSkinList();
if (list != null && !list.isEmpty()) {
prop.skin = list.get(0);
private String version = null;
private Platform parentPlatform = null;
- private ArrayList<Skin>skinList = new ArrayList<Skin>();
+ private List<Skin>skinList = new ArrayList<Skin>();
private EMPlugin plugin;
// for standard base images
skinList = SkinList.sortForPriority(skinList);
}
- public ArrayList<Skin> getSkins() {
+ public List<Skin> getSkins() {
return skinList;
}
return SkinList.findSkinUseName(name, skinList);
}
- public ArrayList<Skin> findSkinList(RESOLUTION resolution) {
+ public List<Skin> findSkinList(RESOLUTION resolution) {
return SkinList.findSkinList(resolution, skinList);
}
- public ArrayList<Skin> findSkinList(RESOLUTION resolution, SKIN_SHAPE skinShape) {
+ public List<Skin> findSkinList(RESOLUTION resolution, SKIN_SHAPE skinShape) {
return SkinList.findSkinList(resolution, skinShape, skinList);
}
- public ArrayList<Skin> findGeneralSkinList() {
+ public List<Skin> findGeneralSkinList() {
return SkinList.findGeneralSkinList(skinList);
}
package org.tizen.emulator.manager.platform;
import java.util.ArrayList;
+import java.util.List;
import org.tizen.emulator.manager.vms.RESOLUTION;
import org.tizen.emulator.manager.vms.SKIN_SHAPE;
import org.tizen.emulator.manager.vms.SKIN_TYPE;
public class SkinList {
- public static Skin findSkinUsePath(String path, ArrayList<Skin> list) {
+ public static Skin findSkinUsePath(String path, List<Skin> list) {
if (list != null) {
for (Skin skin : list) {
if (skin.getPath().equals(path)) {
return null;
}
- public static Skin findSkinUseName(String name, ArrayList<Skin> list) {
+ public static Skin findSkinUseName(String name, List<Skin> list) {
if (list != null) {
for (Skin skin : list) {
if (skin.getName().equals(name)) {
return null;
}
- private static ArrayList<Skin> returnSkins = new ArrayList<Skin>();
- public static ArrayList<Skin> findSkinList(RESOLUTION resolution, ArrayList<Skin> list) {
+ private static List<Skin> returnSkins = new ArrayList<Skin>();
+ public static List<Skin> findSkinList(RESOLUTION resolution, List<Skin> list) {
returnSkins.clear();
if (list != null) {
for (Skin skin : list) {
return sortForPriority(returnSkins);
}
- public static ArrayList<Skin> findSkinList(RESOLUTION resolution, SKIN_SHAPE skinShape,
- ArrayList<Skin> list) {
+ public static List<Skin> findSkinList(RESOLUTION resolution, SKIN_SHAPE skinShape,
+ List<Skin> list) {
returnSkins.clear();
if (list != null) {
for (Skin skin : list) {
return sortForPriority(returnSkins);
}
- public static ArrayList<Skin> findGeneralSkinList( ArrayList<Skin> list) {
+
+ public static List<Skin> findGeneralSkinList( List<Skin> list) {
returnSkins.clear();
if (list != null) {
for (Skin skin : list) {
return sortForPriority(returnSkins);
}
- public static ArrayList<Skin> sortForPriority(ArrayList<Skin> list) {
+ public static List<Skin> sortForPriority(List<Skin> list) {
// sort using priority
- ArrayList<Skin> tempList = new ArrayList<Skin>();
+ List<Skin> tempList = new ArrayList<Skin>();
for (Skin s : list) {
tempList.add(s);
for (int j = tempList.size() - 1; j > 0; j--) {
package org.tizen.emulator.manager.ui.detail.item.property;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.events.SelectionEvent;
private Skin oldSkin;
private Skin newSkin;
- private ArrayList<Skin> skinList;
- private DisplayViewItem displayItem;
+ private List<Skin> skinList;
+ private final DisplayViewItem displayItem;
private SKIN_SHAPE imageSkinShape;
public SkinSubViewItem(LabelViewItem parentItem, Composite comp,
combo.removeAll();
int find = -1;
- ArrayList<Skin> skins = null;
+ List<Skin> skins = null;
if (!parentItem.isCreateMode()
&& !displayItem.isResolutionExist(re)
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.platform.Skin;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
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.item.modify.vm.DeviceTemplateItem;
-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;
private static final String NAME = "display";
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DISPLAY;
- private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT;
+ private static final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT;
+ public static final int BODY_MARGIN_LEFT = 66;
+ public static final int WIDGET_TOP = (ROW_HEIGHT - ModifyItem.WIDGET_HEIGHT) / 2;
+ public static final int TEXT_BOX_WIDTH = 58;
+ public static final int COMBO_WIDTH = 134;
private final int ROW_NUM = 4; // TODO
+ private final String TITLE_SIZE = "Size";
+
+ private final ResolutionSubItem resolutionItem;
+ private TextInputBox sizeTextBox = null;
+ private String displayDPI = "";
+ private String displaySize = "";
+ private final SkinSubItem skinItem;
+
/** constructor for tree sub item */
item = new SubTreeModifyItem(this, treeRoot);
item.setItemHeight(ROW_HEIGHT * ROW_NUM + ModifyItem.LINE_WIDTH);
treeRoot.addSubItem((SubTreeModifyItem)item);
- this.resList = resList;
+
+ resolutionItem = new ResolutionSubItem(this, resList);
+ skinItem = new SkinSubItem(this);
+
}
super(NAME, TITLE);
item = new ModifyItem();
item.setItemHeight(ROW_HEIGHT * ROW_NUM);
- this.resList = resList;
+
+ resolutionItem = new ResolutionSubItem(this, resList);
+ skinItem = new SkinSubItem(this);
}
@Override
public ModifyDialogItem cloneItem() {
List<RESOLUTION> resList = new ArrayList<RESOLUTION>();
- if (this.resList != null) {
- resList.addAll(this.resList);
+ if (resolutionItem.getResolutionList() != null) {
+ resList.addAll(resolutionItem.getResolutionList());
}
return new DisplayItem(resList);
}
if (getDialog().getDialogMode() == DIALOG_MODE.DETAIL) {
createDisplayInfomation();
} else {
- createResolutionComboItem();
- createResolutionTextItem();
+
+ resolutionItem.create();
+
createSizeItem();
- createSkinItem();
+ skinItem.create();
+
- initResolutionCombo();
}
// set widget disable if template is selected.
if (deviceTemplateItem.getDeviceTemplate() != null) {
setWidgetEnabled(false);
}
-
}
@Override
public void setInitialValue(PropertyValue value) {
- resolution = value.getResolution();
+ resolutionItem.setResolution(value.getResolution());
+ resolutionItem.setDisplayHeight(String.valueOf(value.getDisplayHeight()));
+ resolutionItem.setDisplayWidth(String.valueOf(value.getDisplayWidth()));
+
displaySize = String.valueOf(value.getDisplaySize());
- displayWidth = String.valueOf(value.getDisplayWidth());
- displayHeight = String.valueOf(value.getDisplayHeight());
- // for detail information
- displayDPI = String.valueOf(value.getDisplayDPI());
if (value.getSkin() != null) {
- skin = value.getSkin();
+ skinItem.setSkin(value.getSkin());
}
- }
-
-
- 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;
+ // for detail information
+ displayDPI = String.valueOf(value.getDisplayDPI());
+ }
- 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 String displayDPI = "";
- private Skin skin = null;
- boolean isCustomResolution = false;
private void createDisplayInfomation() {
- Composite comp = createSubComp(1, TITLE_RESOLUTION);
+ Composite comp = createSubComp(1, ResolutionSubItem.TITLE_RESOLUTION);
// resolution label
FormData data = new FormData();
data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
data.height = ModifyItem.WIDGET_HEIGHT;
Canvas canvas = new Canvas(comp, SWT.NONE);
canvas.setLayoutData(data);
- WidgetHelper.drawText(canvas, resolution.getStrTypeValue(), SWT.NONE);
+ WidgetHelper.drawText(canvas, resolutionItem.getResolution().getStrTypeValue(), SWT.NONE);
comp = createSubComp(1, TITLE_SIZE);
// "inch" label
canvas.setLayoutData(data);
WidgetHelper.drawText(canvas, displaySize + " inch" + " (DPI: " + displayDPI + ")" , SWT.NONE);
- comp = createSubComp(1, TITLE_SKIN);
+ comp = createSubComp(1, SkinSubItem.TITLE_SKIN);
// "inch" label
data = new FormData();
data.left = new FormAttachment(0, BODY_MARGIN_LEFT);
data.height = ModifyItem.WIDGET_HEIGHT;
canvas = new Canvas(comp, SWT.NONE);
canvas.setLayoutData(data);
+ Skin skin = skinItem.getSkin();
WidgetHelper.drawText(canvas, skin == null ? "" : skin.getName(), SWT.NONE);
comp = createSubComp(1, "Skin Path");
WidgetHelper.drawText(canvas, skin == null ? "" : skin.getPath(), SWT.NONE);
}
- 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);
- addResolutionComboListener();
-
- }
-
- private void initResolutionCombo() {
- if (resolutionCombo == null || resolutionCombo.isDisposed() ) {
- return;
- }
-
- resolutionCombo.clear();
-
- // default.
- if (resList == null) {
- resList = new ArrayList<RESOLUTION>();
- resList.add(RESOLUTION.MINI);
- resList.add(RESOLUTION.R_360_480);
- resList.add(RESOLUTION.WQXGA);
- resList.add(RESOLUTION.WVGA);
- resList.add(RESOLUTION.WXGA);
- resList.add(RESOLUTION.HD);
- resList.add(RESOLUTION.HD1080);
- resList.add(RESOLUTION.HVGA);
- resList.add(RESOLUTION.QHD);
- }
-
- if (resList.size() == 0) {
- return;
- }
-
- // add combo list
- for (RESOLUTION res : resList) {
- resolutionCombo.addItem(res.toString());
- }
-
- selectResolutionCombo();
- setResolutionTextBox();
-
-
- // close popup if it is opened.
- resolutionCombo.closeComboBox();
- }
-
- private void selectResolutionCombo() {
-
-
- String re = null;
- if (resolution != null) {
- re = resolution.toString();
- } else {
- re = resList.get(0).toString();
- }
-
- // select combobox
- int index = -1;
- for (int i=0 ; i < resolutionCombo.getItemList().size() ; i++) {
- String str = resolutionCombo.getItemList().get(i);
- if (str.equals(re)) {
- index = i;
- break;
- }
- }
- if (index == -1) {
- // add resolution
- resList.add(0, resolution);
- resolutionCombo.addItem(0, resolution.toString());
- resolutionCombo.select(0);
-
- } else {
- resolutionCombo.select(index);
- resolutionCombo.redraw();
- }
- }
-
-
- private void addResolutionComboListener() {
- Listener listener = new Listener() {
- @Override
- public void handleEvent(Event event) {
- switch(event.type) {
- case SWT.Selection:
- resolutionComboSelected(resolutionCombo.getSelectedItem());
- isCustomResolution = false;
-
- 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() {
});
}
- 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();
- setCustomResolution();
- getDialog().checkValid();
- }
- });
-
- heightTextBox.getTextWidget().addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- displayHeight = heightTextBox.getValue();
- setCustomResolution();
- getDialog().checkValid();
- }
- });
- }
-
- private void setCustomResolution() {
- if (!checkDisplayWidthHeight()) {
- return;
- }
- int width = Integer.parseInt(displayWidth);
- int height = Integer.parseInt(displayHeight);
- if (width == resolution.getResolution().getWidth()
- && height == resolution.getResolution().getHeight()) {
- if (isCustomResolution) {
- isCustomResolution = false;
- selectResolutionCombo();
- }
- return;
- }
-
- // is in res list ?
- for (RESOLUTION res : resList) {
- if (width == res.getResolution().getWidth()
- && height == res.getResolution().getHeight()) {
- if (!isCustomResolution) {
- return;
- }
- resolution = res;
- selectResolutionCombo();
- isCustomResolution = false;
- return;
- }
- }
- // set "custom" in combobox
- resolutionCombo.setText("(custom)");
- resolutionCombo.setToolTipText("(custom)");
- isCustomResolution = true;
- }
-
-
-
- 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) {
+ public Composite createSubComp(int rowNum, String title) {
GridData data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = SWT.FILL;
@Override
public void setValue(PropertyValue value) {
// set resolution
- if (isCustomResolution) {
- resolution = new RESOLUTION(
- Integer.parseInt(displayWidth),
- Integer.parseInt(displayHeight),
- "custom", 0);
- }
-
- value.setResolution(resolution);
+ resolutionItem.setValue(value);
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());
}
+
+ // TODO skin
+ skinItem.setValue(value);
}
return false;
}
- if (!checkDisplayWidthHeight()) {
+ if (!resolutionItem.isValid()) {
return false;
}
}
- private boolean checkDisplayWidthHeight() {
- // 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;
- }
public List<RESOLUTION> getResolutionList() {
- return resList;
+ return resolutionItem.getResolutionList();
}
+
@Override
public void changeItem(ModifyDialogItem srcDialogItem) {
return;
}
- // change size
+
DisplayItem srcItem = (DisplayItem)srcDialogItem;
- resList.clear();
- for (RESOLUTION res : srcItem.getResolutionList()) {
- resList.add(res);
- }
- initResolutionCombo();
+
+ // change resolution
+ resolutionItem.changeItem(srcItem.getResolutionList());
+
// change size
selectSize();
@Override
public void changeItemValue(PropertyValue value) {
// display resolution
- resolution = value.getResolution();
- selectResolutionCombo();
+ resolutionItem.changeValue(value.getResolution());
// size
displaySize = String.valueOf(value.getDisplaySize());
}
private void setWidgetEnabled(boolean enabled) {
- resolutionCombo.setEnabled(enabled);
- widthTextBox.setEnabled(enabled);
- heightTextBox.setEnabled(enabled);
+ resolutionItem.setWidgetEnabled(enabled);
+
sizeTextBox.setEnabled(enabled);
// skinCombo.setEnabled(enabled);
}
+ public ResolutionSubItem getResolutionItem() {
+ return resolutionItem;
+ }
+
+
+ public boolean isResolutionExist(RESOLUTION re) {
+ if (resolutionItem == null) {
+ return false;
+ }
+ return resolutionItem.isResolutionExist(re);
+ }
+
+
+ public void changeSkinList(RESOLUTION re) {
+ // change skin list
+ if (skinItem != null) {
+ skinItem.settingSkinList(re);
+ }
+ }
}
--- /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.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.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;
+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 ResolutionSubItem {
+
+
+ private ComboBox resolutionCombo = null;
+ private TextInputBox widthTextBox = null;
+ private TextInputBox heightTextBox = null;
+
+ public static final String TITLE_RESOLUTION = "Resolution";
+ private final int RESOLUTION_TEXT_BOX_SPACING = 18;
+
+ private RESOLUTION resolution;
+ private final DisplayItem displayItem;
+
+ boolean isCustomResolution = false;
+
+
+ List<RESOLUTION> resList;
+ private String displayWidth = "";
+ private String displayHeight = "";
+
+
+ public ResolutionSubItem(DisplayItem displayItem, List<RESOLUTION> resList) {
+ this.displayItem = displayItem;
+ this.resList = resList;
+ }
+
+
+
+ public void create() {
+ createResolutionComboItem();
+ createResolutionTextItem();
+
+ initResolutionCombo(false);
+ setResolutionTextBox();
+ }
+
+
+
+ private void createResolutionComboItem() {
+ Composite comp = displayItem.createSubComp(1, TITLE_RESOLUTION);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, DisplayItem.BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, DisplayItem.WIDGET_TOP);
+ data.width = DisplayItem.COMBO_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ resolutionCombo = new ComboBox(displayItem.getDialog().getShell(), comp, SWT.NONE);
+ resolutionCombo.setLayoutData(data);
+ addResolutionComboListener();
+
+ }
+
+ private void initResolutionCombo(boolean notifySelect) {
+ if (resolutionCombo == null || resolutionCombo.isDisposed() ) {
+ return;
+ }
+
+ resolutionCombo.clear();
+
+ // default.
+ if (resList == null) {
+ resList = new ArrayList<RESOLUTION>();
+ resList.add(RESOLUTION.MINI);
+ resList.add(RESOLUTION.R_360_480);
+ resList.add(RESOLUTION.WQXGA);
+ resList.add(RESOLUTION.WVGA);
+ resList.add(RESOLUTION.WXGA);
+ resList.add(RESOLUTION.HD);
+ resList.add(RESOLUTION.HD1080);
+ resList.add(RESOLUTION.HVGA);
+ resList.add(RESOLUTION.QHD);
+ }
+
+ if (resList.size() == 0) {
+ return;
+ }
+
+ // add combo list
+ for (RESOLUTION res : resList) {
+ resolutionCombo.addItem(res.toString());
+ }
+
+ selectResolutionCombo(notifySelect);
+// setResolutionTextBox();
+
+
+ // close popup if it is opened.
+ resolutionCombo.closeComboBox();
+ }
+ private void initResolutionCombo() {
+ initResolutionCombo(true);
+ }
+
+ private void selectResolutionCombo(boolean notifySelect) {
+
+
+ String re = null;
+ if (resolution != null) {
+ re = resolution.toString();
+ } else {
+ re = resList.get(0).toString();
+ }
+
+ // select combobox
+ int index = -1;
+ for (int i=0 ; i < resolutionCombo.getItemList().size() ; i++) {
+ String str = resolutionCombo.getItemList().get(i);
+ if (str.equals(re)) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ // add resolution
+ resList.add(0, resolution);
+ resolutionCombo.addItem(0, resolution.toString());
+ resolutionCombo.select(0, notifySelect);
+
+ } else {
+ resolutionCombo.select(index, notifySelect);
+ resolutionCombo.redraw();
+ }
+ }
+
+
+ private void addResolutionComboListener() {
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.Selection:
+ resolutionComboSelected(resolutionCombo.getSelectedItem());
+ isCustomResolution = false;
+
+ displayItem.getDialog().checkValid();
+ 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?
+ displayItem.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.changeSkinList(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 = displayItem.createSubComp(1, "");
+
+ // text box for width
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, DisplayItem.BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, DisplayItem.WIDGET_TOP);
+ data.width = DisplayItem.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, DisplayItem.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, DisplayItem.WIDGET_TOP);
+ data.width = DisplayItem.TEXT_BOX_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ heightTextBox = new TextInputBox(comp, SWT.NONE);
+ heightTextBox.setLayoutData(data);
+
+ addWidthHeightListener();
+ }
+
+
+ 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();
+ setCustomResolution();
+ displayItem.getDialog().checkValid();
+ }
+ });
+
+ heightTextBox.getTextWidget().addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ displayHeight = heightTextBox.getValue();
+ setCustomResolution();
+ displayItem.getDialog().checkValid();
+ }
+ });
+ }
+
+ private void setCustomResolution() {
+ if (!checkDisplayWidthHeight()) {
+ return;
+ }
+ int width = Integer.parseInt(displayWidth);
+ int height = Integer.parseInt(displayHeight);
+ if (width == resolution.getResolution().getWidth()
+ && height == resolution.getResolution().getHeight()) {
+ if (isCustomResolution) {
+ isCustomResolution = false;
+ selectResolutionCombo(true);
+ }
+ return;
+ }
+
+ // is in res list ?
+ for (RESOLUTION res : resList) {
+ if (width == res.getResolution().getWidth()
+ && height == res.getResolution().getHeight()) {
+ if (!isCustomResolution) {
+ return;
+ }
+ resolution = res;
+ selectResolutionCombo(true);
+ isCustomResolution = false;
+ return;
+ }
+ }
+
+ // set "custom" in combobox
+ resolutionCombo.setText("(custom)");
+ resolutionCombo.setToolTipText("(custom)");
+ isCustomResolution = true;
+ // change skin list (Only general skin is available)
+ displayItem.changeSkinList(null);
+
+ }
+
+
+ private boolean checkDisplayWidthHeight() {
+ // 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;
+ }
+
+
+ public void setValue(PropertyValue value) {
+ if (isCustomResolution) {
+ resolution = new RESOLUTION(
+ Integer.parseInt(displayWidth),
+ Integer.parseInt(displayHeight),
+ "custom", 0);
+ }
+ value.setResolution(resolution);
+
+ try {
+ // displayWidth, displayHeight
+ value.setDisplayWidth(Integer.parseInt(displayWidth));
+ value.setDisplayHeight(Integer.parseInt(displayHeight));
+
+
+ } catch (NumberFormatException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+
+ }
+
+
+ public void setWidgetEnabled(boolean enabled) {
+ resolutionCombo.setEnabled(enabled);
+ widthTextBox.setEnabled(enabled);
+ heightTextBox.setEnabled(enabled);
+ }
+
+
+ public void changeItem(List<RESOLUTION> resList) {
+ this.resList.clear();
+ for (RESOLUTION res : resList) {
+ this.resList.add(res);
+ }
+ initResolutionCombo();
+ }
+
+
+ public boolean isResolutionExist(RESOLUTION re) {
+ for (RESOLUTION r : resList) {
+ if (r.getStrValue().equals(re.getStrValue())) {
+ return true;
+ }
+ }
+ if (resolution != null) {
+ if (resolution.getStrValue().equals(re.getStrValue())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public void changeValue(RESOLUTION res) {
+ resolution = res;
+ selectResolutionCombo(true);
+ }
+
+
+ public boolean isValid() {
+ return checkDisplayWidthHeight();
+ }
+
+ public List<RESOLUTION> getResolutionList() {
+ return resList;
+ }
+
+ public void setResolution(RESOLUTION r) {
+ this.resolution = r;
+ }
+
+ public void setDisplayWidth(String width) {
+ displayWidth = width;
+ }
+
+ public void setDisplayHeight(String height) {
+ displayHeight = height;
+ }
+
+ public RESOLUTION getResolution() {
+ return resolution;
+ }
+}
--- /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.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+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.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
+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;
+import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
+import org.tizen.emulator.manager.vms.SKIN_TYPE;
+
+public class SkinSubItem {
+
+ private final DisplayItem displayItem;
+
+ private ComboBox skinCombo = null;
+ private Skin skin = null;
+ private List<Skin> skinList;
+ private SKIN_SHAPE imageSkinShape;
+
+ public static final String TITLE_SKIN = "Skin";
+
+ public SkinSubItem(DisplayItem displayItem) {
+ this.displayItem = displayItem;
+ }
+
+ public void setSkin(Skin skin) {
+ this.skin = skin;
+ }
+
+ public Skin getSkin() {
+ return skin;
+ }
+
+ public void create() {
+ createSkinItem();
+ initSkinCombo();
+ }
+
+
+ public void setValue(PropertyValue value) {
+ // set skin
+ value.setSkin(skin);
+
+ // set skin path
+ String skinPath = null;
+ if (skin != null) {
+ skinPath = skin.getPath();
+ }
+ value.setSkinPath(skinPath);
+
+ }
+
+
+ private void settingGeneralSkinList() {
+ skinCombo.clear();
+ List<Skin> skins = null;
+ skins = SkinList.findGeneralSkinList(skinList);
+ if (skins.size() == 0) {
+ skin = null;
+ skinCombo.setToolTipText("No skins are available");
+ return;
+ }
+
+ for (Skin s : skins) {
+ skinCombo.addItem(s.toString());
+ }
+ skinCombo.select(0);
+ skinCombo.setToolTipText(skinCombo.getSelectedItem());
+ skin = skins.get(0);
+
+ }
+
+ // init skin combo list, select combo.
+ public void settingSkinList(RESOLUTION re) {
+ if (re == null) {
+ // setting general skin only.
+ settingGeneralSkinList();
+ return;
+ }
+
+ skinCombo.clear();
+ List<Skin> skins = null;
+
+
+ int find = -1;
+
+ if (!displayItem.getDialog().isCreateMode()
+ && !displayItem.isResolutionExist(re) ) {
+ if (skin != null) {
+ EMLogger.getLogger().fine("Add old skin: " + skin.toString()); //$NON-NLS-1$
+ skinCombo.addItem(skin.toString());
+ find = 0;
+ }
+
+ } else {
+ skins = SkinList.findSkinList(re, imageSkinShape, skinList);
+ Skin s = null;
+ for (int i = 0; i < skins.size(); i++) {
+ s = skins.get(i);
+ if (skin != null && skin.equals(s)) {
+ find = i;
+ }
+ skinCombo.addItem(s.toString());
+ }
+
+ if (find == -1) {
+ if (skin != null
+ && skin.getType() == SKIN_TYPE.GENERAL) {
+ skins.add(0, skin);
+ skinCombo.addItem(skin.toString(), 0);
+ }
+ if (skins.size() > 0) {
+ find = 0;
+ }
+ }
+ }
+
+ if (find >= 0) {
+ skinCombo.select(find);
+ skinCombo.setToolTipText(skinCombo.getSelectedItem());
+// newSkin = skins == null ? oldSkin : skins.get(find);
+ skin = skins == null ? skin : skins.get(find);
+ } else {
+ EMLogger.getLogger().warning("To initial Skin Combo has been failed."); //$NON-NLS-1$
+ }
+ }
+
+ private void createSkinItem() {
+ Composite comp = displayItem.createSubComp(1, TITLE_SKIN);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, DisplayItem.BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, DisplayItem.WIDGET_TOP);
+ data.width = DisplayItem.COMBO_WIDTH;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ skinCombo = new ComboBox(displayItem.getDialog().getShell(), comp, SWT.NONE);
+ skinCombo.setLayoutData(data);
+
+ if (displayItem.getDialog().getPropertyValue().isTemplateValue()) {
+ return;
+ }
+ initSkinCombo();
+
+ }
+
+
+ private void initSkinCombo() {
+ imageSkinShape = displayItem.getDialog().getPropertyValue().getImageSkinShape();
+ skinList = displayItem.getDialog().getPropertyValue().getImageSkinList();
+
+ settingSkinList(displayItem.getResolutionItem().getResolution());
+ addSkinComboListener();
+ }
+
+
+
+ private void addSkinComboListener() {
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.Selection:
+ String name = skinCombo.getSelectedItem();
+ skinCombo.setToolTipText(name);
+
+ skin = SkinList.findSkinUseName(name, skinList);
+
+ displayItem.getDialog().checkValid();
+
+ default:
+ break;
+ }
+
+ }
+ };
+ skinCombo.addListener(SWT.Selection, listener);
+ }
+}
+
import java.io.File;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.tizen.emulator.manager.devices.DeviceTemplate;
}
- private boolean isVMValue() {
+ public boolean isVMValue() {
return vmValue != null;
}
- private boolean isTemplateValue() {
+ public boolean isTemplateValue() {
return templateValue != null;
}
return 0;
}
+ public void setSkin(Skin skin) {
+ if (isVMValue()) {
+ vmValue.skin = skin;
+ }
+ }
+
+ public void setSkinPath(String path) {
+ if (isVMValue()) {
+ vmValue.skinPath = path;
+ }
+ }
+
public String getSkinShape() {
if (isVMValue()) {
public Skin getSkin() {
if (isVMValue()) {
-
+ return vmValue.skin;
} else if (isTemplateValue()) {
return templateValue.getSkin();
}
return null;
}
+
+ public List<Skin> getImageSkinList() {
+ if (isVMValue()) {
+ return vmValue.baseImage.getPlatform().getSkins();
+ }
+
+ return null;
+ }
+
+
+ public SKIN_SHAPE getImageSkinShape() {
+ if (isVMValue()) {
+ return vmValue.baseImage.getSkinShape();
+ }
+ return null;
+ }
+
public int getRamSize() {
if (isVMValue()) {
return vmValue.ramSize;
public void select(int index) {
select(index, true);
+ redraw();
}
private void initBox() {
if (newVM.skin == null && newVM.skinPath == null) {
if (newVM.baseImage != null) {
- ArrayList<Skin> list = newVM.baseImage.getPlatform().findSkinList(newVM.resolution);
+ List<Skin> list = newVM.baseImage.getPlatform().findSkinList(newVM.resolution);
if (!list.isEmpty()) {
newVM.skin = list.get(0);
}