prop.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue());
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "Child Disk Image", //$NON-NLS-1$ //$NON-NLS-2$
prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue());
-
+
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "Resolution", //$NON-NLS-1$ //$NON-NLS-2$
(prop.getConfiguration().getDevice().getDisplay().getResolution().getWidth()
+ "x" + prop.getConfiguration().getDevice().getDisplay().getResolution().getHeight())); //$NON-NLS-1$
-
+
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "DPI", //$NON-NLS-1$ //$NON-NLS-2$
prop.getConfiguration().getDevice().getDisplay().getDensity().getValue());
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "Skin Path", //$NON-NLS-1$ //$NON-NLS-2$
prop.getConfiguration().getDevice().getDisplay().getSkinPath().getPath());
-
+
if (prop.getConfiguration().getDevice().getTouch() != null) {
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "Max Touch Point", //$NON-NLS-1$ //$NON-NLS-2$
prop.getConfiguration().getDevice().getTouch().getMaxTouchPoint());
}
-
+
str+= String.format("\t%-17s : %s" + StringResources.NEW_LINE, "RAM Size", //$NON-NLS-1$ //$NON-NLS-2$
prop.getConfiguration().getDevice().getRAM().getSize().getValue());
// error
message.add(Messages.getString("ConsoleProcessor.VMList.0")); //$NON-NLS-1$
} else {
-
+
if (!isDetail) {
for (VMProperty prop : properties) {
message.add(prop.getName());
try {
if (f.isDirectory()) {
- path = path + File.separator + "emulimg-" + name + "." + prop.getArch().toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ path = path + File.separator + "emulimg-" + name + "." + prop.getArchInternal().toString(); //$NON-NLS-1$ //$NON-NLS-2$
}
prop.getWorker().createNewBaseImage(prop, path);
} catch (VMWorkerException e) {
import java.util.Properties;
import java.util.logging.Level;
-
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePathResources;
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.SKIN_SHAPE;
import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMProperty.Architecture;
import org.tizen.emulator.manager.vms.option.IOption;
import org.tizen.emulator.manager.vms.xml.template.ItemList;
protected String version;
protected String profile;
protected String type;
- protected String cpu;
+ protected Architecture cpu;
protected SKIN_SHAPE skinShape;
protected String binaryVersion;
}
public String getCpu() {
+ if (cpu == null) {
+ return "";
+ }
+ return cpu.toString();
+ }
+
+ public Architecture getCpuType() {
return cpu;
}
version = prop.getProperty(StringResources.IMAGE_VERSION, "2.4"); //$NON-NLS-1$
profile = prop.getProperty(StringResources.PRODUCT_PROFILE, PlatformStringResources.MOBILE_PROFILE).toLowerCase();
type = prop.getProperty(StringResources.IMAGE_TYPE, "default"); //$NON-NLS-1$
- cpu = prop.getProperty(StringResources.TARGET_CPU, "x86"); //$NON-NLS-1$
- cpu = cpu.toLowerCase();
+ String cpuValue = prop.getProperty(StringResources.TARGET_CPU, "i386"); //$NON-NLS-1$
+ cpu = Architecture.getType(cpuValue);
skinShape = SKIN_SHAPE.find(prop.getProperty(StringResources.SKIN_SHAPE, "square")); //$NON-NLS-1$
binaryVersion = prop.getProperty(StringResources.BINARY_VERSION, "1.0.0"); //$NON-NLS-1$
checkBaseImage();
version = platform.getVersion();
profile = platform.getProfile();
type = "custom"; // TODO //$NON-NLS-1$
- cpu = "x86"; //$NON-NLS-1$
+ cpu = findCpuTypeFromPath(); //$NON-NLS-1$
skinShape = SKIN_SHAPE.NONE; // TODO
binaryVersion = ""; //$NON-NLS-1$
}
+ private Architecture findCpuTypeFromPath() {
+ String ext = FilePathResources.getFileExtention(this.path);
+ return Architecture.getType(ext);
+ }
+
private void settingImagePath(File path) throws IOException {
for (File f : path.listFiles()) {
- if (f.isFile() && f.getName().endsWith(cpu.toLowerCase())) {
+ if (f.isFile() && f.getName().endsWith(getCpu().toLowerCase())) {
this.path = f.getCanonicalPath();
this.pathName = f.getName();
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.detail.item.template.loader;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.tizen.emulator.manager.ui.detail.item.OptionType;
+import org.tizen.emulator.manager.vms.xml.template.DeviceList;
+import org.tizen.emulator.manager.vms.xml.template.Item;
+import org.tizen.emulator.manager.vms.xml.template.ItemList;
+import org.tizen.emulator.manager.vms.xml.template.ObjectFactory;
+import org.tizen.emulator.manager.vms.xml.template.Option;
+import org.tizen.emulator.manager.vms.xml.template.PropertyList;
+
+public class CustomPropertyTemplateLoader {
+ public static ObjectFactory factory = new ObjectFactory();
+
+ public static ItemList makeCustomPropertyTemplate(List<ItemList> templateList) {
+ if (templateList.size() == 0) {
+ return null;
+
+ } else if (templateList.size() == 1) {
+ ItemList template = cloneTemplate(templateList.get(0));
+ template.setImage(null);
+ return template;
+
+ } else { // Make union set
+ ItemList base = cloneTemplate(templateList.get(0));
+ for (int i=1 ; i < templateList.size() ; i++) {
+ addToBase(base,templateList.get(i));
+ }
+ return base;
+ }
+ }
+
+ private static void addToBase(ItemList base, ItemList newOne) {
+ // Property list add
+ PropertyList newPropertyList = newOne.getPropertyList();
+ PropertyList basePropertyList = base.getPropertyList();
+ if (newPropertyList != null) {
+ if (basePropertyList == null) {
+ basePropertyList = factory.createPropertyList();
+ base.setPropertyList(basePropertyList);
+ }
+ for (Item newItem : newPropertyList.getItem()) {
+ boolean itemExistInBase = false;
+ for (Item baseItem : basePropertyList.getItem()) {
+ if (baseItem.getName().equals(newItem.getName())) {
+ itemExistInBase = true;
+ joinItem(baseItem, newItem);
+ }
+ }
+ if (!itemExistInBase) {
+ basePropertyList.getItem().add(cloneItem(newItem));
+ }
+ }
+ }
+
+ // Device list add
+ DeviceList newDeviceList = newOne.getDeviceList();
+ DeviceList baseDeviceList = base.getDeviceList();
+ if (newDeviceList != null) {
+ if (baseDeviceList == null) {
+ baseDeviceList = factory.createDeviceList();
+ base.setDeviceList(baseDeviceList);
+ }
+ for (Item newItem : newDeviceList.getItem()) {
+ boolean itemExistInBase = false;
+ for (Item baseItem : baseDeviceList.getItem()) {
+ if (baseItem.getName().equals(newItem.getName())) {
+ itemExistInBase = true;
+ joinItem(baseItem, newItem);
+ }
+ }
+ if (!itemExistInBase) {
+ baseDeviceList.getItem().add(cloneItem(newItem));
+ }
+ }
+ }
+ }
+
+ private static void joinItem(Item baseItem, Item newItem) {
+ // join sub items
+ for (Item newSub : newItem.getItem()) {
+ boolean itemExistInBase = false;
+ for (Item baseSub : baseItem.getItem()) {
+ if (baseSub.getName().equals(newSub.getName())) {
+ itemExistInBase = true;
+ joinItem(baseSub, newSub);
+ }
+ }
+ if (!itemExistInBase) {
+ baseItem.getItem().add(cloneItem(newSub));
+ }
+ }
+ // join options
+ for (Option newOption : newItem.getOption()) {
+ boolean optionExistInBase = false;
+ for (Option baseOption : baseItem.getOption()) {
+ if (baseOption.getName().equals(newOption.getName())) {
+ optionExistInBase = true;
+ if (isListOption(baseOption, newOption)) {
+ joinOption(baseOption, newOption);
+ }
+ }
+ }
+
+ if (!optionExistInBase) {
+ baseItem.getOption().add(cloneOption(newOption));
+ }
+ }
+
+ }
+
+ private static void joinOption(Option baseOption, Option newOption) {
+ baseOption.setValue(joinCommaString(baseOption.getValue(), newOption.getValue()));
+ }
+
+ private static String joinCommaString(String base, String newOne) {
+ List<String> optionList = new ArrayList<String>();
+ if (base != null) {
+ String[] split = base.split(","); //$NON-NLS-1$
+ for (String str : split) {
+ optionList.add(str.trim());
+ }
+ }
+ if (newOne != null) {
+ String[] split = newOne.split(","); //$NON-NLS-1$
+ for (String str : split) {
+ optionList.add(str.trim());
+ }
+ }
+
+ if (optionList.size() > 0) {
+ Set<String> optionSet = new HashSet<String>();
+ optionSet.addAll(optionList);
+ optionList.clear();
+ optionList.addAll(optionSet);
+// Collections.sort(optionList);
+ StringBuilder sb = new StringBuilder();
+
+ for (int i=0 ; i<optionList.size() ; i++) {
+ sb.append(optionList.get(i));
+ if (i < optionList.size()-1) {
+ sb.append(","); //$NON-NLS-1$
+ }
+ }
+
+ return sb.toString();
+ }
+
+ return null;
+ }
+
+ private static ItemList cloneTemplate(ItemList template) {
+ ItemList newTemplate = factory.createItemList();
+ newTemplate.setProfile(template.getProfile());
+ newTemplate.setImage(template.getImage());
+
+ // clone property list
+ PropertyList propertyList = template.getPropertyList();
+ if (propertyList != null) {
+ PropertyList newPropertyList = factory.createPropertyList();
+ newTemplate.setPropertyList(newPropertyList);
+
+ for (Item item : propertyList.getItem()) {
+ newPropertyList.getItem().add(cloneItem(item));
+ }
+ }
+
+ // clone device list.
+ DeviceList deviceList = template.getDeviceList();
+ if (deviceList != null) {
+ DeviceList newDeviceList = factory.createDeviceList();
+ newTemplate.setDeviceList(newDeviceList);
+
+ for (Item item : deviceList.getItem()) {
+ newDeviceList.getItem().add(cloneItem(item));
+ }
+ }
+
+ return newTemplate;
+ }
+
+ private static Item cloneItem(Item item) {
+ Item newItem = factory.createItem();
+ newItem.setType(item.getType());
+ newItem.setName(item.getName());
+ newItem.setTitle(item.getTitle());
+
+ for (Option option : item.getOption()) {
+ newItem.getOption().add(cloneOption(option));
+ }
+
+ for (Item subItem : item.getItem()) {
+ newItem.getItem().add(cloneItem(subItem));
+ }
+
+ return newItem;
+ }
+
+ private static Option cloneOption(Option option) {
+ Option newOption = factory.createOption();
+ newOption.setName(option.getName());
+ newOption.setValue(option.getValue());
+ return newOption;
+ }
+
+ private static boolean isListOption(Option baseOption, Option newOption) {
+ if (baseOption.getName().equals(OptionType.COMBO_LIST.getName())
+ && newOption.getName().equals(OptionType.COMBO_LIST.getName())) {
+ return true;
+ }
+
+ return false;
+ }
+}