From f8476afea631163e24a901b1b39ea30232f58643 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Thu, 21 May 2015 16:44:07 +0900 Subject: [PATCH] Emulator List: change variable type to private from package - delete arm arch type Change-Id: Ia4cc773dacaf6d55b3b85299715598de87a7967b Signed-off-by: jihye424.kim --- .../emulator/manager/console/ConsoleCreateVM.java | 5 - .../ui/detail/item/property/BaseImageViewItem.java | 17 +--- src/org/tizen/emulator/manager/vms/Creator.java | 5 +- .../tizen/emulator/manager/vms/EmulatorVMList.java | 103 ++++++--------------- .../tizen/emulator/manager/vms/VMWorkerCommon.java | 1 - 5 files changed, 31 insertions(+), 100 deletions(-) diff --git a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java index bbd08e9..96f1f67 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java @@ -44,7 +44,6 @@ import org.tizen.emulator.manager.platform.Skin; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.tool.CheckVirtualization; import org.tizen.emulator.manager.vms.Creator; -import org.tizen.emulator.manager.vms.EmulatorVMList; import org.tizen.emulator.manager.vms.RAM_SIZE; import org.tizen.emulator.manager.vms.RESOLUTION; import org.tizen.emulator.manager.vms.SKIN_TYPE; @@ -160,10 +159,6 @@ public class ConsoleCreateVM { property.baseImagePath = checkImagePath(c.getCurrentValue()); if (property.baseImagePath.endsWith(".x86")) { property.archType = "x86"; - EmulatorVMList.getInstance().CustomArch = "x86"; - } else if (property.baseImagePath.endsWith(".arm")) { - property.archType = "arm"; - EmulatorVMList.getInstance().CustomArch = "arm"; } else { throw new ConsoleException("Avaliable format of base image is .x86 or .arm."); } diff --git a/src/org/tizen/emulator/manager/ui/detail/item/property/BaseImageViewItem.java b/src/org/tizen/emulator/manager/ui/detail/item/property/BaseImageViewItem.java index 6e4170f..cf82ce2 100644 --- a/src/org/tizen/emulator/manager/ui/detail/item/property/BaseImageViewItem.java +++ b/src/org/tizen/emulator/manager/ui/detail/item/property/BaseImageViewItem.java @@ -45,7 +45,6 @@ import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.FileDialog; import org.tizen.emulator.manager.EmulatorManager; -import org.tizen.emulator.manager.EmulatorManager.ManagerModeType; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.platform.Profile; import org.tizen.emulator.manager.platform.ProfileList; @@ -61,7 +60,6 @@ import org.tizen.emulator.manager.ui.dialog.MessageDialog; import org.tizen.emulator.manager.ui.widgets.ImageCombo; import org.tizen.emulator.manager.ui.widgets.ImageLabel; import org.tizen.emulator.manager.ui.widgets.WSTATE; -import org.tizen.emulator.manager.vms.EmulatorVMList; import org.tizen.emulator.manager.vms.SKIN_SHAPE; import org.tizen.emulator.manager.vms.VMPropertyValue; import org.tizen.emulator.manager.vms.helper.HelperClass; @@ -219,14 +217,8 @@ public class BaseImageViewItem extends ComboViewItem { fd.setText(String.format("Select existing Base Image")); String[] filter = null; String[] filterName = null; - if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) { - filter = new String[] { "*.x86", "*.arm" }; - filterName = new String[] { "Disk Image Files(*.x86)", - "Disk Image Files(*.arm)" }; - } else { - filter = new String[] { "*.x86" }; - filterName = new String[] { "Disk Image Files(*.x86)" }; - } + filter = new String[] { "*.x86" }; + filterName = new String[] { "Disk Image Files(*.x86)" }; fd.setFilterExtensions(filter); fd.setFilterNames(filterName); } @@ -244,11 +236,6 @@ public class BaseImageViewItem extends ComboViewItem { String newPathName = path.substring( path.lastIndexOf(File.separator) + 1, path.length()); - // for arm emulator - boolean isArm = newPathName.endsWith("arm"); - EmulatorVMList.getInstance().CustomArch = !isArm ? "x86" - : "arm"; - BaseImageItem newItem = new BaseImageItem(newPathName, newPathName, newPath, profile, "", false, SKIN_SHAPE.NONE); addToBaseImageItemList(newItem); diff --git a/src/org/tizen/emulator/manager/vms/Creator.java b/src/org/tizen/emulator/manager/vms/Creator.java index b4e45b1..866a46b 100644 --- a/src/org/tizen/emulator/manager/vms/Creator.java +++ b/src/org/tizen/emulator/manager/vms/Creator.java @@ -169,8 +169,8 @@ public class Creator { } checkCustomBaseImage(newVM.baseImagePath); - customPath = folder.getAbsolutePath() + File.separator + "emulimg-" + - newVM.vmsName + "." + (newVM.isStandard ? newVM.archType.toString() : EmulatorVMList.getInstance().CustomArch.toString()); + customPath = folder.getAbsolutePath() + File.separator + "emulimg-" + + newVM.vmsName + "." + newVM.archType.toString(); createInitialVMImageInternal(newVM.baseImagePath, customPath); @@ -289,7 +289,6 @@ public class Creator { ec.getBaseInformation().getDiskImage().setType("standard"); } else { ec.getBaseInformation().getDiskImage().setType("custom"); - ec.getBaseInformation().setArchitecture(EmulatorVMList.getInstance().CustomArch); } // TODO : get version diff --git a/src/org/tizen/emulator/manager/vms/EmulatorVMList.java b/src/org/tizen/emulator/manager/vms/EmulatorVMList.java index 170e425..7c98041 100644 --- a/src/org/tizen/emulator/manager/vms/EmulatorVMList.java +++ b/src/org/tizen/emulator/manager/vms/EmulatorVMList.java @@ -48,14 +48,16 @@ import javax.xml.transform.stream.StreamSource; 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.tool.CheckEmulatorDir; import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration; import org.tizen.emulator.manager.vms.xml.ObjectFactory; - public class EmulatorVMList { - static EmulatorVMList instance = null; - static JAXBContext context = null; + static private EmulatorVMList instance = null; + static private JAXBContext context = null; + static private String vmsConfigDirectory = ""; + + private List propertiesList = new ArrayList(); + private ObjectFactory objectFactory = new ObjectFactory(); static { synchronized(EmulatorVMList.class) { @@ -68,10 +70,6 @@ public class EmulatorVMList { } } - static String vmsConfigDirectory = ""; - - public String CustomArch = "x86"; - public static void makeSDKDataPath(String vmsPath) { vmsConfigDirectory = vmsPath; File vmsFolder = new File (vmsPath); @@ -80,10 +78,6 @@ public class EmulatorVMList { } } - List propertiesList = new ArrayList(); - - ObjectFactory objectFactory = new ObjectFactory(); - public static EmulatorVMList getInstance() { return instance; } @@ -130,57 +124,27 @@ public class EmulatorVMList { } } } - loadOldVersionProperties(); } - private void loadOldVersionProperties() { - if (CheckEmulatorDir.CheckOldEmulatorVmsDir()) { - // traverse VMs... - File vmsDirectory = new File(FilePathResources.getOldSdkDataVmsPath()); - String configFilename = null; - File configFile = null; - VMProperty property = null; - File[] files = vmsDirectory.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - if(!pathname.isDirectory()) { - return false; - } - return true; - } - }); - - for(File vm : files) { - configFilename = StringResources.PROPERTY_XML_NAME; - configFile = new File(vm, configFilename); - if(!configFile.exists()) { - EMLogger.getLogger().info(StringResources.PROPERTY_XML_NAME + " file dose not exist." - + StringResources.NEW_LINE + "VM Path: " + configFile.getAbsolutePath()); - continue ; // FIXME - } + public VMProperty parseXML(File configFile) { + JAXBElement element = null; - property = parseXML(configFile); - if (property != null) { - // check duplicate name - boolean isDuplicated = false; - for (VMProperty prop : propertiesList) { - if (prop.getName().equals(property.getName())) { - EMLogger.getLogger().warning(property.getName() + " is exist already." - + StringResources.NEW_LINE + "Check vms path: " + FilePathResources.getOldSdkDataVmsPath()); - isDuplicated = true; - break; - } - } - if (!isDuplicated) { - propertiesList.add(property); - } - } - } + try { + Unmarshaller unmarshaller = context.createUnmarshaller(); + element = unmarshaller.unmarshal(new StreamSource(configFile), EmulatorConfiguration.class); + } catch (JAXBException e) { + e.printStackTrace(); + EMLogger.getLogger().warning("Can not load config file( " + + configFile.getName() + ")" + StringResources.NEW_LINE + e.getMessage()); + return null; } + + return new VMProperty(configFile, element.getValue()); } - public VMProperty parseXML(File configFile) { + public EmulatorConfiguration parseXML(VMProperty prop) { JAXBElement element = null; + File configFile = prop.getPropertyFile(); try { Unmarshaller unmarshaller = context.createUnmarshaller(); @@ -192,7 +156,7 @@ public class EmulatorVMList { return null; } - return new VMProperty(configFile, element.getValue()); + return element.getValue(); } public VMProperty getProperty(String name) { @@ -213,6 +177,12 @@ public class EmulatorVMList { return propertiesList.toArray(new VMProperty[propertiesList.size()]); } + public void addProperty(VMProperty prop) { + if (prop != null) { + propertiesList.add(prop); + } + } + public boolean storeXML(VMProperty property) { return storeXML(property, null); } @@ -280,23 +250,4 @@ public class EmulatorVMList { return new VMProperty(configFile, ec); } - - // for testing "load properties"... - /* - public static void main(String[] args) { - EmulatorVMs fsImage = EmulatorVMs.getInstance(); - try { - fsImage.loadProperties(); - } catch (Exception e) { - e.printStackTrace(); - } - - for(VMsProperty property : fsImage.getProperties()) { - System.out.println(property.getName()); - } - - VMsProperty property = fsImage.getNewProperty("test6"); - fsImage.storeXML(property); - } - */ } diff --git a/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java b/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java index b91faec..c5e0008 100644 --- a/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java +++ b/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java @@ -460,7 +460,6 @@ public class VMWorkerCommon { } public void cloneVM(String newVMName) throws VMWorkerException { - EmulatorVMList.getInstance().CustomArch = property.getArch().toString(); VMPropertyValue newValue = property.getPropertyValue(); newValue.vmsName = newVMName; // TODO -- 2.7.4