From: jihye424.kim Date: Fri, 16 Oct 2015 10:33:39 +0000 (+0900) Subject: DeviceTemplate: add priority and type class X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7633b647092f258dd4a0733013226695eb5a6b23;p=sdk%2Femulator%2Femulator-manager.git DeviceTemplate: add priority and type class - priority: default, standard, custom - type: standard, custom Change-Id: I1867cfec8a4c3abc70b0e492dcbbb2479a1601fb Signed-off-by: jihye424.kim --- diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplate.java b/src/org/tizen/emulator/manager/devices/DeviceTemplate.java index a9e20a9..f228d49 100644 --- a/src/org/tizen/emulator/manager/devices/DeviceTemplate.java +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplate.java @@ -191,14 +191,14 @@ public class DeviceTemplate { // base information conf.getBaseInformation().setName(value.getName()); - conf.getBaseInformation().setType(value.getType()); + conf.getBaseInformation().setType(value.getType().toString()); 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()); + conf.getBaseInformation().setPriority(value.getPriority().getValue()); if (value.getManufacturer() != null && !value.getManufacturer().isEmpty()) { conf.getBaseInformation().setManufacturer(value.getManufacturer()); } diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplatePriority.java b/src/org/tizen/emulator/manager/devices/DeviceTemplatePriority.java new file mode 100644 index 0000000..4a734f9 --- /dev/null +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplatePriority.java @@ -0,0 +1,94 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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 java.util.ArrayList; +import java.util.List; + +public class DeviceTemplatePriority implements Comparable { + public static DeviceTemplatePriority DEFAULT = + new DeviceTemplatePriority(0); + public static DeviceTemplatePriority STANDARD = + new DeviceTemplatePriority(1); + public static DeviceTemplatePriority CUSTOM = + new DeviceTemplatePriority(3); + + private static List priorityList = + new ArrayList(); + static { + priorityList.add(DEFAULT); + priorityList.add(STANDARD); + priorityList.add(CUSTOM); + } + + public static void addPriority(DeviceTemplatePriority priority) { + if (priority == null) { + return; + } + + for (DeviceTemplatePriority p : priorityList) { + if (p.getValue() == priority.getValue()) { + return; + } + } + + priorityList.add(priority); + } + + public static DeviceTemplatePriority findPriority(int priority) { + for (DeviceTemplatePriority p : priorityList) { + if (p.getValue() == priority) { + return p; + } + } + return null; + } + + private int priority = 0; + public DeviceTemplatePriority(int priority) { + this.priority = priority; + } + + public int getValue() { + return priority; + } + + public void setValue(int priority) { + this.priority = priority; + } + + @Override + public int compareTo(Object o) { + int targetPriority = ((DeviceTemplatePriority)o).priority; + + return priority > targetPriority ? -1 : 1; + } + +} diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplateType.java b/src/org/tizen/emulator/manager/devices/DeviceTemplateType.java new file mode 100644 index 0000000..e5aa550 --- /dev/null +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplateType.java @@ -0,0 +1,56 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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; + +public class DeviceTemplateType { + public static DeviceTemplateType STANDARD = + new DeviceTemplateType("standard"); + public static DeviceTemplateType CUSTOM = + new DeviceTemplateType("custom"); + + private String type = ""; + + public DeviceTemplateType(String type) { + this.setType(type); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return type; + } +} diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java b/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java index 0fd1b01..011326c 100644 --- a/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java @@ -49,11 +49,12 @@ public class DeviceTemplateValue implements Cloneable { private DeviceTemplate template; private boolean isStandard = false; private String name = ""; - private String type = "custom"; + private DeviceTemplateType type = DeviceTemplateType.CUSTOM; private String profile = ""; private String extenstion = ""; // standard = 1, custom = 3 (1 > 3) - private int priority = 3; + //private int priority = 3; + private DeviceTemplatePriority priority = DeviceTemplatePriority.CUSTOM; private double version = 1.0; private String manufacturer = ""; @@ -119,13 +120,17 @@ public class DeviceTemplateValue implements Cloneable { if (conf.getBaseInformation() != null) { name = conf.getBaseInformation().getName(); - type = conf.getBaseInformation().getType(); - if (type.equals("standard")) { - isStandard = true; - } + String type = conf.getBaseInformation().getType(); + setType(type); + profile = conf.getBaseInformation().getProfile(); extenstion = conf.getBaseInformation().getExtension(); - priority = conf.getBaseInformation().getPriority(); + int p = conf.getBaseInformation().getPriority(); + priority = DeviceTemplatePriority.findPriority(p); + if (priority == null) { + priority = DeviceTemplatePriority.CUSTOM; + } + version = conf.getBaseInformation().getVersion(); manufacturer = conf.getBaseInformation().getManufacturer(); } @@ -238,13 +243,23 @@ public class DeviceTemplateValue implements Cloneable { this.name = name; } - public String getType() { + public DeviceTemplateType getType() { return type; } public void setType(String type) { + if (type.equals(DeviceTemplateType.STANDARD.getType())) { + this.type = DeviceTemplateType.STANDARD; + isStandard = true; + } else { + this.type = DeviceTemplateType.CUSTOM; + isStandard = false; + } + } + + public void setType(DeviceTemplateType type) { this.type = type; - if (type.equals("standard")) { + if (type == DeviceTemplateType.STANDARD) { isStandard = true; } else { isStandard = false; @@ -267,11 +282,11 @@ public class DeviceTemplateValue implements Cloneable { this.profile = profile; } - public int getPriority() { + public DeviceTemplatePriority getPriority() { return priority; } - public void setPriority(int priority) { + public void setPriority(DeviceTemplatePriority priority) { this.priority = priority; } diff --git a/src/org/tizen/emulator/manager/platform/Profile.java b/src/org/tizen/emulator/manager/platform/Profile.java index a88895c..62e823c 100644 --- a/src/org/tizen/emulator/manager/platform/Profile.java +++ b/src/org/tizen/emulator/manager/platform/Profile.java @@ -37,6 +37,7 @@ import java.util.List; import org.tizen.emulator.manager.devices.DeviceTemplate; import org.tizen.emulator.manager.devices.DeviceTemplateList; +import org.tizen.emulator.manager.devices.DeviceTemplatePriority; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.vms.EmulatorVMList; @@ -282,7 +283,8 @@ public class Profile { for (int i = 0; i < templateList.size(); i++) { pairs[i] = new TemplatePair(templateList.get(i)); // setting default template - if (templateList.get(i).getValue().getPriority() == 0) { + if (templateList.get(i).getValue().getPriority() == + DeviceTemplatePriority.DEFAULT) { defaultTemplate = templateList.get(i); } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java index 3ad7004..ea85814 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java @@ -49,6 +49,8 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.manager.EmulatorManager; import org.tizen.emulator.manager.devices.DeviceTemplate; +import org.tizen.emulator.manager.devices.DeviceTemplatePriority; +import org.tizen.emulator.manager.devices.DeviceTemplateType; import org.tizen.emulator.manager.devices.DeviceTemplateValue; import org.tizen.emulator.manager.devices.DeviceWorkerException; import org.tizen.emulator.manager.logging.EMLogger; @@ -649,7 +651,8 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { if (newValue == null) { return; } else { - newValue.setType("custom"); + newValue.setType(DeviceTemplateType.CUSTOM); + newValue.setPriority(DeviceTemplatePriority.CUSTOM); } ProfileButton pButton = null;