From: minkee.lee Date: Mon, 2 Nov 2015 12:04:55 +0000 (+0900) Subject: template: load XML and draw VM-modify dialog. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f530b51146ce2ed8b3a8c40a671b9ba43a1a3a4e;p=sdk%2Femulator%2Femulator-manager.git template: load XML and draw VM-modify dialog. Change-Id: I51aba4508c5c84765676b925f9e9b80f43d4430e Signed-off-by: minkee.lee --- diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Information.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Information.java similarity index 96% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Information.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Information.java index 617ea95..50b0f72 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Information.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Information.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Item.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Item.java similarity index 97% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Item.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Item.java index e4d1ca1..3baf598 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Item.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Item.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import java.util.ArrayList; import java.util.List; diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemGroup.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemGroup.java similarity index 96% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemGroup.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemGroup.java index 3a026b5..0290775 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemGroup.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemGroup.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import java.util.ArrayList; import java.util.List; diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemList2.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemList.java similarity index 95% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemList2.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemList.java index 532b731..a3e0de3 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ItemList2.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ItemList.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import java.util.ArrayList; import java.util.List; @@ -43,8 +43,8 @@ import javax.xml.bind.annotation.XmlType; "information", "itemGroup" }) -@XmlRootElement(name = "ItemList2") -public class ItemList2 { +@XmlRootElement(name = "ItemList") +public class ItemList { protected Information information; protected List itemGroup; diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ObjectFactory.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ObjectFactory.java similarity index 83% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ObjectFactory.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ObjectFactory.java index 7caa089..a375acb 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/ObjectFactory.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/ObjectFactory.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import javax.xml.bind.annotation.XmlRegistry; @@ -14,7 +14,7 @@ import javax.xml.bind.annotation.XmlRegistry; /** * This object contains factory methods for each * Java content interface and Java element interface - * generated in the org.tizen.emulator.manager.vms.xml.template2 package. + * generated in the org.tizen.emulator.manager.vms.xml.template.v2 package. *

An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML @@ -30,18 +30,18 @@ public class ObjectFactory { /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.tizen.emulator.manager.vms.xml.template2 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.tizen.emulator.manager.vms.xml.template.v2 * */ public ObjectFactory() { } /** - * Create an instance of {@link ItemList2 } + * Create an instance of {@link ItemList } * */ - public ItemList2 createItemList2() { - return new ItemList2(); + public ItemList createItemList() { + return new ItemList(); } /** diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Option.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Option.java similarity index 96% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Option.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Option.java index e973825..a0b5dcd 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/Option.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/Option.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/package-info.java b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/package-info.java similarity index 80% rename from jaxb_src/org/tizen/emulator/manager/vms/xml/template2/package-info.java rename to jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/package-info.java index 7af938e..545ba18 100644 --- a/jaxb_src/org/tizen/emulator/manager/vms/xml/template2/package-info.java +++ b/jaxb_src/org/tizen/emulator/manager/vms/xml/template/v2/package-info.java @@ -2,8 +2,8 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.08.03 at 02:50:57 PM KST +// Generated on: 2015.11.02 at 07:56:31 PM KST // @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.tizen.org/em/template", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package org.tizen.emulator.manager.vms.xml.template2; +package org.tizen.emulator.manager.vms.xml.template.v2; diff --git a/src/org/tizen/emulator/manager/platform/BaseImage.java b/src/org/tizen/emulator/manager/platform/BaseImage.java index 3fdfae3..ac5cae7 100644 --- a/src/org/tizen/emulator/manager/platform/BaseImage.java +++ b/src/org/tizen/emulator/manager/platform/BaseImage.java @@ -39,15 +39,21 @@ import java.util.logging.Level; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.baseimage.CustomBaseImageWorker; +import org.tizen.emulator.manager.plugin.ExtensionItem; import org.tizen.emulator.manager.plugin.PluginStringResources; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.template.ITemplate; +import org.tizen.emulator.manager.ui.renewal.dialoghandler.VMModifyHandler; +import org.tizen.emulator.manager.ui.renewal.item.CommonItemListFactory; +import org.tizen.emulator.manager.ui.renewal.item.IItemListFactory; +import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem; 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.helper.HelperClass; import org.tizen.emulator.manager.vms.option.IOption; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemList; public class BaseImage { public static BaseImage createCustomBaseImage(Platform platform, String path, String name) { @@ -88,7 +94,12 @@ public class BaseImage { private VMProperty defaultProperty; private ITemplate itemTemplate; - private List optionList; + protected List defaultItemList; + protected List advancedItemList; + + + + protected List optionList; //private LaunchConfig launchTemplate; // TODO replace xDefaultOption.java // for custom base image @@ -252,6 +263,7 @@ public class BaseImage { return optionList; } + public VMProperty getDefaultProperty() { return defaultProperty; } @@ -451,4 +463,49 @@ public class BaseImage { public void setWorker(CustomBaseImageWorker worker) { this.worker = worker; } + + public List getDefaultItemList() { + if (defaultItemList == null) { + makeItemList(); + } + + return defaultItemList; + } + + + public List getAdvancedItemList() { + if (advancedItemList == null) { + makeItemList(); + } + + return advancedItemList; + } + + + private void makeItemList() { + + ItemList template = platform.findTemplate(imageName); + if (template == null) { + // load template in {SRC_DIR}/xsd + template = VMModifyHandler.getTmpItemList(profile); + EMLogger.getLogger().warning("Fail to find template. Image : " + imageName); + EMLogger.getLogger().info("Use temp template."); + } + + IItemListFactory f = null; + ExtensionItem exItem = getPlatform().getPlugin().getExtensionItem(PluginStringResources.ItemFactoryV2); + if (exItem != null) { + f = (IItemListFactory)(exItem.getInstance()); + } + if (f == null) { + f = new CommonItemListFactory(); + EMLogger.getLogger().warning("Fail to load ItemListFactory2."); + EMLogger.getLogger().info("Use CommonItemListFactory2."); + } + defaultItemList = f.makeDefaultItemList(template); + advancedItemList = f.makeAdvancedItemList(template); + + } + + } diff --git a/src/org/tizen/emulator/manager/platform/Platform.java b/src/org/tizen/emulator/manager/platform/Platform.java index b0d507f..0c08e50 100644 --- a/src/org/tizen/emulator/manager/platform/Platform.java +++ b/src/org/tizen/emulator/manager/platform/Platform.java @@ -41,10 +41,11 @@ import org.tizen.emulator.manager.plugin.PluginStringResources; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.template.ITemplate; -import org.tizen.emulator.manager.template.TemplateLoader; +import org.tizen.emulator.manager.template.renewal.TemplateLoader; import org.tizen.emulator.manager.vms.RESOLUTION; import org.tizen.emulator.manager.vms.SKIN_SHAPE; import org.tizen.emulator.manager.vms.VMProperty; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemList; public class Platform { public static Platform createInstance(Profile profile, EMPlugin plugin) { @@ -85,6 +86,10 @@ public class Platform { private VMProperty defaultProperty; private ITemplate defaultItemTemplate; + // for new template + private final List templateList = new ArrayList(); + private ItemList defaultTemplate; + // for custom base image private ITemplate customItemTemplate; @@ -108,7 +113,6 @@ public class Platform { loadSkins(); loadPlugin(); - TemplateLoader.load(this); } private String makingEmulatorDir() { @@ -291,4 +295,25 @@ public class Platform { public void setCustomItemTemplate(ITemplate customItemTemplate) { this.customItemTemplate = customItemTemplate; } + + public List getTemplateList() { + return templateList; + } + + public void setDefaultTemplate(ItemList defaultTemplate) { + this.defaultTemplate = defaultTemplate; + } + + public ItemList findTemplate(String imageName) { + if (templateList.size() == 0) { + TemplateLoader.load(this); + } + + for (ItemList template : templateList) { + if (template.getInformation().getImage().equals(imageName)) { + return template; + } + } + return defaultTemplate; + } } diff --git a/src/org/tizen/emulator/manager/plugin/PluginStringResources.java b/src/org/tizen/emulator/manager/plugin/PluginStringResources.java index 6ee24c5..861f983 100644 --- a/src/org/tizen/emulator/manager/plugin/PluginStringResources.java +++ b/src/org/tizen/emulator/manager/plugin/PluginStringResources.java @@ -35,6 +35,7 @@ public class PluginStringResources { // extension point // org.tizen.emulator.manager.ui.detail.IItemListFactory public final static String ItemFactory = "Item-Factory"; //$NON-NLS-1$ + public final static String ItemFactoryV2 = "Item-Factory-v2"; //$NON-NLS-1$ // org.tizen.emulator.manager.ui.widgets.IVMButtonPainter public final static String VMButtonPainter = "VMButton-Painter"; //$NON-NLS-1$ // org.tizen.emulator.manager.vms.IVMWorker diff --git a/src/org/tizen/emulator/manager/resources/FilePathResources.java b/src/org/tizen/emulator/manager/resources/FilePathResources.java index ffb275f..0910c0b 100644 --- a/src/org/tizen/emulator/manager/resources/FilePathResources.java +++ b/src/org/tizen/emulator/manager/resources/FilePathResources.java @@ -81,7 +81,6 @@ public class FilePathResources { private final static String sdcard_suffix = File.separator + "sdcard"; //$NON-NLS-1$ private final static String skins_suffix = File.separator + "skins"; //$NON-NLS-1$ private final static String template_suffix = File.separator + "template"; //$NON-NLS-1$ - private final static String template2_suffix = File.separator + "template2"; //$NON-NLS-1$ private final static String plugins_suffix = File.separator + "plugins"; //$NON-NLS-1$ private final static String sdkdata_new_emulator_suffix = File.separator @@ -109,7 +108,6 @@ public class FilePathResources { // Platform private static String platformSkinsPath; private static String platformTemplatePath; - private static String platformTemplate2Path; private static String platformPluginsPath; private static String platformImagesPath; @@ -175,7 +173,6 @@ public class FilePathResources { platformSkinsPath = resource_suffix + skins_suffix; platformTemplatePath = resource_suffix + template_suffix; - platformTemplate2Path = resource_suffix + template2_suffix; platformPluginsPath = resource_suffix + plugins_suffix; // SDB path @@ -497,10 +494,6 @@ public class FilePathResources { return platformTemplatePath; } - public static String getPlatformTemplate2Path() { - return platformTemplate2Path; - } - public static String getPlatformPluginsPath() { return platformPluginsPath; } diff --git a/src/org/tizen/emulator/manager/resources/StringResources.java b/src/org/tizen/emulator/manager/resources/StringResources.java index 77adac4..878ddf5 100644 --- a/src/org/tizen/emulator/manager/resources/StringResources.java +++ b/src/org/tizen/emulator/manager/resources/StringResources.java @@ -121,4 +121,6 @@ public class StringResources { public static final String TOTAL_PROFILE = "all"; //$NON-NLS-1$ public static final String REG_EXP_SPLIT_COMMA = "\\s{0,},\\s{0,}"; //$NON-NLS-1$ + + public static final String XML_EXTENSION = ".xml"; } diff --git a/src/org/tizen/emulator/manager/template/Template2.java b/src/org/tizen/emulator/manager/template/Template2.java index 2b7b92b..f2fcb95 100644 --- a/src/org/tizen/emulator/manager/template/Template2.java +++ b/src/org/tizen/emulator/manager/template/Template2.java @@ -36,11 +36,11 @@ import java.util.List; import org.tizen.emulator.manager.plugin.EMPlugin; import org.tizen.emulator.manager.ui.detail.item.IViewItem; import org.tizen.emulator.manager.vms.option.IOption; -import org.tizen.emulator.manager.vms.xml.template2.ItemList2; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemList; public class Template2 implements ITemplate { - private ItemList2 template; + private ItemList template; @Override public String getImageName() { @@ -81,13 +81,13 @@ public class Template2 implements ITemplate { @Override public Class getXMLObjectType() { - return ItemList2.class; + return ItemList.class; } @Override public void setXMLObject(Object obj) { - if (obj instanceof ItemList2) { - template = (ItemList2)obj; + if (obj instanceof ItemList) { + template = (ItemList)obj; } } diff --git a/src/org/tizen/emulator/manager/template/TemplateLoader.java b/src/org/tizen/emulator/manager/template/TemplateLoader.java index 6acff28..7cfcf14 100644 --- a/src/org/tizen/emulator/manager/template/TemplateLoader.java +++ b/src/org/tizen/emulator/manager/template/TemplateLoader.java @@ -85,7 +85,7 @@ public class TemplateLoader { private static boolean loadTemplateV2(Platform platform) { File templateDir = new File(platform.getPlatformPath() + File.separator - + FilePathResources.getPlatformTemplate2Path()); + + FilePathResources.getPlatformTemplatePath()); if (!templateExist(templateDir)) { return false; } diff --git a/src/org/tizen/emulator/manager/template/renewal/TemplateLoader.java b/src/org/tizen/emulator/manager/template/renewal/TemplateLoader.java new file mode 100644 index 0000000..6222d2d --- /dev/null +++ b/src/org/tizen/emulator/manager/template/renewal/TemplateLoader.java @@ -0,0 +1,151 @@ +/* + * Emulator Manager + * + * Copyright (C) 2012 - 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.template.renewal; + +import java.io.File; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; + +import org.tizen.emulator.manager.logging.EMLogger; +import org.tizen.emulator.manager.platform.Platform; +import org.tizen.emulator.manager.platform.PlatformStringResources; +import org.tizen.emulator.manager.resources.FilePathResources; +import org.tizen.emulator.manager.resources.StringResources; +import org.tizen.emulator.manager.vms.EmulatorVMList; +import org.tizen.emulator.manager.vms.VMProperty; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemList; + +public class TemplateLoader { + + private static JAXBContext context; + + /** load template for new-ui */ + public static void load(Platform platform) { + // get template dir + File templateDir = new File(platform.getPlatformPath() + File.separator + + FilePathResources.getPlatformTemplatePath()); + if (!templateExist(templateDir)) { + return; + } + + // load template file, default file + for (File f : templateDir.listFiles()) { + if (!f.getName().endsWith(StringResources.XML_EXTENSION)) { + continue; + } + if (f.getName().contains(PlatformStringResources.TEMPLATE)) { // ui template file for detail view + ItemList template = loadTemplate(f); + if (template != null) { + if (!checkTemplate(template)) { + continue; + } + platform.getTemplateList().add(template); + + // setting default item list + if (f.getName().contains(PlatformStringResources.STANDARD)) { + platform.setDefaultTemplate(template); + } + + } + + } else { // property file + EmulatorVMList vmList = EmulatorVMList.getInstance(); + VMProperty defaultProperty = vmList.parseXML(f); + if (defaultProperty != null) { + platform.getPropertyList().add(defaultProperty); + + // setting default property + if (f.getName().contains(PlatformStringResources.STANDARD)) { + platform.setDefaultProperty(defaultProperty); + } + } + } + } + } + + private static boolean checkTemplate(ItemList template) { + if (template.getInformation() == null) { + return false; + } + if (template.getItemGroup() == null) { + return false; + } + if (template.getVersion() == null) { + return false; + } + return true; + } + + private static boolean templateExist(File template) { + if (template == null || !template.exists() || !template.isDirectory()) { + return false; + } + return true; + } + + public static ItemList loadTemplate (File f) { + @SuppressWarnings("rawtypes") + JAXBElement element = null; + JAXBContext context = getContext(); + if (context != null) { + try { + Unmarshaller unmarshaller = context.createUnmarshaller(); + element = unmarshaller.unmarshal(new StreamSource(f), ItemList.class); + } catch (JAXBException e) { + e.printStackTrace(); + EMLogger.getLogger().warning("Can not load config file( " //$NON-NLS-1$ + + f.getName() + ")" + StringResources.NEW_LINE + e.getMessage()); //$NON-NLS-1$ + element = null; + } + if (element != null) { + return (ItemList)element.getValue(); + } + } + return null; + + } + + + private static JAXBContext getContext() { + if (context == null) { + try { + context = JAXBContext.newInstance(ItemList.class); + } catch (JAXBException e){ + EMLogger.getLogger().warning(e.getMessage()); + } + } + return context; + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java index 470c1f0..a48c74f 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java @@ -33,6 +33,7 @@ package org.tizen.emulator.manager.ui.renewal.dialog; import java.util.ArrayList; import java.util.List; +import org.tizen.emulator.manager.EmulatorManager; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.ui.renewal.item.ItemName; import org.tizen.emulator.manager.ui.renewal.item.ItemType; @@ -49,15 +50,15 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem; import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem; import org.tizen.emulator.manager.ui.renewal.item.modify.template.CameraItem; import org.tizen.emulator.manager.vms.RESOLUTION; -import org.tizen.emulator.manager.vms.xml.template2.Item; -import org.tizen.emulator.manager.vms.xml.template2.ItemGroup; -import org.tizen.emulator.manager.vms.xml.template2.ItemList2; -import org.tizen.emulator.manager.vms.xml.template2.Option; +import org.tizen.emulator.manager.vms.xml.template.v2.Item; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemGroup; +import org.tizen.emulator.manager.vms.xml.template.v2.ItemList; +import org.tizen.emulator.manager.vms.xml.template.v2.Option; public class ItemListUtil { /** Get UI item for device-template dialog. */ - public static List getDeviceTemplateItemList(ItemList2 itemList2) { + public static List getDeviceTemplateItemList(ItemList itemList2) { if (itemList2 == null) { return null; } @@ -72,6 +73,13 @@ public class ItemListUtil { return itemList; } + + public static List getVMTemplateItemList(ItemList itemList2) { + List itemList = new ArrayList(); + // TODO get plugin, getItemListFactory, makeItemList + return itemList; + } + private static void addItemList(ItemGroup group, List itemList) { String name; String title; @@ -90,19 +98,19 @@ public class ItemListUtil { dialogItem = new ProfileItem(); } else if (name.equals(ItemName.DISPLAY)) { - dialogItem = new DisplayItem(getResolutionList(item)); + dialogItem = new DisplayItem(null, getResolutionList(item)); } else if (name.equals(ItemName.PROCESSORS)) { - dialogItem = new ProcessorItem(); + dialogItem = new ProcessorItem(null); } else if (name.equals(ItemName.RAM_SIZE)) { - dialogItem = new RamSizeItem(); + dialogItem = new RamSizeItem(null); } else if (name.equals(ItemName.SENSOR)) { - dialogItem = new SensorItem(getCheckBoxDataList(item)); + dialogItem = new SensorItem(null, getCheckBoxDataList(item)); } else if (name.equals(ItemName.CONNECTIVITY)) { - dialogItem = new ConnectivityItem(getCheckBoxDataList(item)); + dialogItem = new ConnectivityItem(null, getCheckBoxDataList(item)); } else if (name.equals(ItemName.CAMERA)) { dialogItem = new CameraItem(getCheckBoxDataList(item)); @@ -115,7 +123,7 @@ public class ItemListUtil { // check item type if (type.equals(ItemType.CHECK_LABEL)) { dialogItem = new CheckBoxItem(name, title, getCheckBoxNumColumn(item), - getCheckBoxDataList(item)); + null, getCheckBoxDataList(item)); } if (dialogItem != null) { itemList.add(dialogItem); @@ -123,8 +131,8 @@ public class ItemListUtil { } } - private static final int DEFAULT_NUM_COLUMN = 3; - private static int getCheckBoxNumColumn(Item item) { + public static final int DEFAULT_NUM_COLUMN = 3; + public static int getCheckBoxNumColumn(Item item) { int numColumn = DEFAULT_NUM_COLUMN; String str = getOption(item.getOption(), OptionName.NUM_COLUMN); if (str != null) { @@ -137,7 +145,7 @@ public class ItemListUtil { return numColumn; } - private static List getCheckBoxDataList(Item item) { + public static List getCheckBoxDataList(Item item) { List dataList = new ArrayList(); for (Item subItem : item.getItem()) { dataList.add(new CheckItemData(subItem.getName(), subItem.getTitle())); @@ -146,7 +154,7 @@ public class ItemListUtil { } - private static String getOption(List