--- /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 <sangho.p@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.devices;
+
+import org.tizen.emulator.manager.device.xml.template.Device;
+import org.tizen.emulator.manager.device.xml.template.DeviceConfiguration;
+import org.tizen.emulator.manager.device.xml.template.DeviceItem;
+import org.tizen.emulator.manager.device.xml.template.ObjectFactory;
+
+
+public class DeviceTemplateCreator {
+ private DeviceTemplate template;
+
+ public static DeviceTemplate create(DeviceTemplateValue value) {
+ return new DeviceTemplateCreator().createInternal(value);
+ }
+
+ private DeviceTemplateCreator() {
+ }
+
+ private DeviceTemplate createInternal(DeviceTemplateValue value) {
+ // lock.acquire
+ this.template = DeviceTemplateList.createNewDeviceTemplate(value.getName());
+ if (template.getTemplateFile().exists()) {
+ // TODO
+ }
+
+ settingConfiguration(value);
+
+ DeviceTemplateList.saveDeviceConfiguration(template);
+
+ // lock.release
+ return template;
+ }
+
+ private void settingConfiguration(DeviceTemplateValue value) {
+ ObjectFactory factory = new ObjectFactory();
+ DeviceConfiguration conf = template.getConf();
+ conf.setBaseInformation(factory.createBaseInformation());
+ conf.setDisplay(factory.createDisplay());
+ conf.setRam(factory.createRam());
+ conf.setCpu(factory.createCpu());
+
+ // base information
+ conf.getBaseInformation().setName(value.getName());
+ conf.getBaseInformation().setType(value.getType());
+ conf.getBaseInformation().setProfile(value.getProfile());
+ if (value.getExtenstion() != null && !value.getExtenstion().isEmpty()) {
+ conf.getBaseInformation().setExtension(value.getExtenstion());
+ }
+
+ conf.getBaseInformation().setVersion(value.getVersion());
+ conf.getBaseInformation().setPriority(value.getPriority());
+ if (value.getManufacturer() != null && !value.getManufacturer().isEmpty()) {
+ conf.getBaseInformation().setManufacturer(value.getManufacturer());
+ }
+
+ // display
+ conf.getDisplay().setResolution(factory.createDisplayResolution());
+ conf.getDisplay().getResolution().setWidth(value.getDisplayWidth());
+ conf.getDisplay().getResolution().setHeight(value.getDisplayHeight());
+
+ conf.getDisplay().setScreenSize(factory.createDisplayScreenSize());
+ conf.getDisplay().getScreenSize().setUnit(value.getDisplaySizeUnit());
+ conf.getDisplay().getScreenSize().setValue(value.getDisplaySize());
+
+ if (value.getSkin() != null) {
+ conf.getDisplay().setSkin(factory.createDisplaySkin());
+ conf.getDisplay().getSkin().setName(value.getSkinName());
+ conf.getDisplay().getSkin().setPath(value.getSkinPath());
+ }
+
+ // ram
+ conf.getRam().setSize(factory.createRamSize());
+ conf.getRam().getSize().setUnit(value.getRamSizeUnit());
+ conf.getRam().getSize().setValue(value.getRamSize());
+
+ // cpu count
+ conf.getCpu().setCount(value.getCpuCount());
+
+ // additionalDevices
+ if (value.getAdditionalDevices().size() > 0) {
+ conf.setAdditionalDevices(factory.createAdditionalDevices());
+ conf.getAdditionalDevices().getDevice().clear();
+ for (SubDevice device : value.getAdditionalDevices()) {
+ Device d = new Device();
+ d.setName(device.getName());
+ for (SubDeviceItem item : device.getItems()) {
+ DeviceItem i = new DeviceItem();
+ if (item.getValues() != null && item.getValues().size() > 0) {
+ // TODO
+ }
+
+ i.setId(item.getId());
+ i.setSupport(item.isSupport());
+ if (item.getName() != null && !item.getName().isEmpty()) {
+ i.setName(item.getName());
+ }
+ d.getDeviceItem().add(i);
+ }
+ conf.getAdditionalDevices().getDevice().add(d);
+ }
+ }
+ }
+}
import javax.xml.transform.stream.StreamSource;
import org.tizen.emulator.manager.device.xml.template.DeviceConfiguration;
+import org.tizen.emulator.manager.device.xml.template.ObjectFactory;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.resources.FilePathResources;
import org.tizen.emulator.manager.resources.StringResources;
template.setConf(conf);
}
+ public static DeviceTemplate createNewDeviceTemplate(String name) {
+ String templateFilePath = FilePathResources.getTizenSdkDataDevicePath()
+ + File.separator + name + ".xml";
+ File templateFile = new File(templateFilePath);
+ DeviceConfiguration conf = new ObjectFactory().createDeviceConfiguration();
+
+ return new DeviceTemplate(templateFile, conf);
+ }
+
public static boolean saveDeviceConfiguration(DeviceTemplate template) {
return saveDeviceConfiguration(template, null);
}
private DeviceTemplate template;
private boolean isStandard = false;
private String name = "";
- private String type;
- private String profile;
- private String extenstion;
- private int priority;
- private String manufacturer;
+ private String type = "";
+ private String profile = "";
+ private String extenstion = "";
+ // standard = 1, custom = 3 (1 > 3)
+ private int priority = 3;
+ private String version = "1.0.0";
+ private String manufacturer = "";
private RESOLUTION resolution;
}
profile = conf.getBaseInformation().getProfile();
extenstion = conf.getBaseInformation().getExtension();
- priority = conf.getBaseInformation().getPriority().intValue();
+ priority = conf.getBaseInformation().getPriority();
+ version = conf.getBaseInformation().getVersion();
manufacturer = conf.getBaseInformation().getManufacturer();
}
skinPath = conf.getDisplay().getSkin().getPath();
}
- if (skinPath != null) {
+ if (skinPath != null && !skinPath.isEmpty()) {
try {
skin = new Skin(new File(skinPath));
} catch (IOException e) {
this.priority = priority;
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
public String getManufacturer() {
return manufacturer;
}
import org.tizen.emulator.manager.vms.helper.VMWorkerException;
public class DeviceTemplateTableViewer extends AbstractTableViewer {
- private static final int BACK_BUTTON_WIDTH = 124;
- private static final int BACK_BUTTON_HEIGHT = 26;
- private static final int BUTTON_WIDTH = 32;
- private static final int BUTTON_HEIGHT = 26;
+ private static final int BACK_BUTTON_WIDTH = 124;
+ private static final int BACK_BUTTON_HEIGHT = 26;
+ private static final int BUTTON_WIDTH = 32;
+ private static final int BUTTON_HEIGHT = 26;
private Hyperlink baseImageList;
private ImageButton refreshButton;
if (event.type == SWT.Selection) {
if (event.type == SWT.Selection) {
MessageBox dialog = new MessageBox(MainDialog.getShell());
- dialog.setMessage("Click BaseImages menu");
+ dialog.setMessage("Click Base Images menu");
dialog.open();
}
}
int dir = table.getSortDirection();
ItemProfilePair[] pairs = new ItemProfilePair[table.getItemCount()];
for (int i = 0; i < table.getItemCount(); i++) {
- pairs[i] = new ItemProfilePair(table.getItem(i), 1, dir);
+ DeviceTemplate t = (DeviceTemplate)table.getItem(i).getData();
+ Profile p = ProfileList.getProfile(t.getValue().getProfile());
+ pairs[i] = new ItemProfilePair(table.getItem(i), 1, dir, p.getPriority());
}
column.setTableItemPairs(pairs);
// sort table item
package org.tizen.emulator.manager.ui.renewal.tableviewer;
import org.eclipse.swt.SWT;
-import org.tizen.emulator.manager.platform.Profile;
import org.tizen.emulator.manager.ui.table.TableItem;
import org.tizen.emulator.manager.ui.table.TableItemComparable;
-import org.tizen.emulator.manager.vms.VMProperty;
public class ItemProfilePair extends TableItemComparable {
private int priority;
- public ItemProfilePair(TableItem item, int index, int direction) {
+ public ItemProfilePair(TableItem item, int index, int direction, int priority) {
super(item, index, direction);
- Profile profile = ((VMProperty)item.getData()).getPropertyValue().baseImage.getPlatform().getProfileClass();
- priority = profile.getPriority();
+ this.priority = priority;
}
@Override
int dir = table.getSortDirection();
ItemProfilePair[] pairs = new ItemProfilePair[table.getItemCount()];
for (int i = 0; i < table.getItemCount(); i++) {
- pairs[i] = new ItemProfilePair(table.getItem(i), 1, dir);
+ Profile profile = ((VMProperty)table.getItem(i).getData()).getPropertyValue().baseImage.getPlatform().getProfileClass();
+ pairs[i] = new ItemProfilePair(table.getItem(i), 1, dir, profile.getPriority());
}
column.setTableItemPairs(pairs);
// sort table item