vm property: not make profile list
authorjihye424.kim <jihye424.kim@samsung.com>
Sat, 13 Feb 2016 04:01:13 +0000 (13:01 +0900)
committerJiHye Kim <jihye424.kim@samsung.com>
Tue, 16 Feb 2016 04:53:18 +0000 (13:53 +0900)
- use platform list
- file watcher wait until job of making platform list is complete
- change to 'Platform' class from 'BaseImage' class

Change-Id: Iacbe04e50b61a7000c69ce89adeca3e912a37bd5
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
16 files changed:
src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/platform/Platform.java
src/org/tizen/emulator/manager/platform/StandardPlatform.java
src/org/tizen/emulator/manager/platform/custom/CustomPlatform.java
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/AdvancedPropertyViewer.java
src/org/tizen/emulator/manager/vms/VMLauncher.java
src/org/tizen/emulator/manager/vms/VMProperty.java
src/org/tizen/emulator/manager/vms/VMPropertyValue.java
src/org/tizen/emulator/manager/vms/VMPropertyValueCreator.java
src/org/tizen/emulator/manager/vms/VMWorkerCommon.java
src/org/tizen/emulator/manager/vms/monitor/FileWatcher.java
src/org/tizen/emulator/manager/vms/option/BaseImageOption.java
src/org/tizen/emulator/manager/vms/option/CommonOption.java
src/org/tizen/emulator/manager/vms/option/DisplayModeOption.java
src/org/tizen/emulator/manager/vms/option/LaunchConfig.java

index 3ebd788..2e7e512 100755 (executable)
@@ -380,7 +380,7 @@ public class EmulatorManager {
                                EmulatorManager.setVMKeeper(new ManagedVMKeeper());
 
                                // initializing profiles
-                               ProfileList.initialize();
+                               //ProfileList.initialize();
 
                                // print system and emulator manager information to log file
                                // initialize about contents
index d888d9b..8814d3f 100644 (file)
@@ -138,6 +138,7 @@ public abstract class Platform {
        private String platformName;
 
        // base image information
+       private String imageName;
        private String imagePath;
        private String imagePathName;
        // default, add-on, custom
@@ -157,6 +158,14 @@ public abstract class Platform {
                return platformName;
        }
 
+       public String getImageName() {
+               return imageName;
+       }
+
+       public void setImageName(String imageName) {
+               this.imageName = imageName;
+       }
+
        protected void setImagePath(String path) {
                imagePath = path;
                if (!imagePath.isEmpty()) {
@@ -209,6 +218,15 @@ public abstract class Platform {
                this.data = data;
        }
 
+       public boolean isItemExist(String name) {
+               for (VMItem item : getVmItemList()) {
+                       if (item.getName().equals(name)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
        public abstract Architecture getImageArch();
        public abstract SKIN_SHAPE getImageSkinShape();
        public abstract String getImageBinaryVersion();
@@ -220,7 +238,7 @@ public abstract class Platform {
        public abstract String getExtension();
        public abstract String getEmulatorDirPath();
        // TODO
-       public abstract String getPluginPackageVersion();
+       public abstract EMPlugin getPlugin();
 
        public abstract List<Skin> getSkinList();
        public abstract Skin findSkinUsePath(String path);
index 3fefd14..57ddeff 100644 (file)
@@ -58,7 +58,6 @@ import org.tizen.emulator.manager.vms.option.IOption;
 
 public class StandardPlatform extends Platform {
        // standard base image information
-       private String imageName;
        private Architecture cpu;
        private SKIN_SHAPE skinShape;
        private String binaryVersion;
@@ -82,7 +81,7 @@ public class StandardPlatform extends Platform {
        }
 
        private void setValue(StandardPlatformImageValue value) {
-               imageName = value.getName();
+               setImageName(value.getName());
 
                // set path, path name, file state
                setImagePath(value.getPath());
@@ -145,10 +144,9 @@ public class StandardPlatform extends Platform {
                return binaryVersion;
        }
 
-       // TODO
        @Override
-       public String getPluginPackageVersion() {
-               return plugin.getPackageVersion();
+       public EMPlugin getPlugin() {
+               return plugin;
        }
 
        @Override
@@ -189,7 +187,7 @@ public class StandardPlatform extends Platform {
        @Override
        public VMProperty getDefaultProperty() {
                if (defaultProperty == null) {
-                       defaultProperty = TemplateLoader.loadProperty(imageName, this);
+                       defaultProperty = TemplateLoader.loadProperty(getImageName(), this);
                        if (defaultProperty == null) {
                                // TODO
                        }
@@ -200,7 +198,7 @@ public class StandardPlatform extends Platform {
        @Override
        public VMTemplate getUITemplate() {
                if (vmTemplate == null) {
-                       vmTemplate = TemplateLoader.loadTemplate(imageName, this);
+                       vmTemplate = TemplateLoader.loadTemplate(getImageName(), this);
                        if (vmTemplate == null) {
                                // TODO
                        }
@@ -267,7 +265,7 @@ public class StandardPlatform extends Platform {
        private void makeItemList() {
                VMTemplate template = getUITemplate();
                if (template == null) {
-                       EMLogger.getLogger().warning("Fail to find template. Image : " + imageName);
+                       EMLogger.getLogger().warning("Fail to find template. Image : " + getImageName());
                        EMLogger.getLogger().info("Use temp template.");
                }
 
@@ -279,7 +277,7 @@ public class StandardPlatform extends Platform {
 
                if (f == null) {
                        f = new CommonItemListFactory();
-                       EMLogger.getLogger().warning("Fail to load ItemListFactory. Image : " + imageName);
+                       EMLogger.getLogger().warning("Fail to load ItemListFactory. Image : " + getImageName());
                        EMLogger.getLogger().info("Use CommonItemListFactory.");
                }
 
index 2b8ba9b..a628d4b 100644 (file)
@@ -36,6 +36,7 @@ import org.tizen.emulator.manager.platform.Platform;
 import org.tizen.emulator.manager.platform.Profile;
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.platform.Version;
+import org.tizen.emulator.manager.plugin.EMPlugin;
 import org.tizen.emulator.manager.template.renewal.VMItem;
 import org.tizen.emulator.manager.template.renewal.VMTemplate;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
@@ -59,6 +60,7 @@ public class CustomPlatform extends Platform {
                // set base platform name
                setName(value.getName());
                setImagePath(value.getImageFilePath());
+               setImageName(getImagePathName());
                setImageType(value.getType());
                setImageDescription(value.getDescription());
        }
@@ -104,10 +106,9 @@ public class CustomPlatform extends Platform {
                return basePlatform.getImageSkinShape();
        }
 
-       // TODO
        @Override
-       public String getPluginPackageVersion() {
-               return basePlatform.getPluginPackageVersion();
+       public EMPlugin getPlugin() {
+               return basePlatform.getPlugin();
        }
 
        @Override
index d358781..5b9368a 100644 (file)
@@ -36,7 +36,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.SWT;
-import org.tizen.emulator.manager.platform.backup.BaseImage;
+import org.tizen.emulator.manager.platform.Platform;
 import org.tizen.emulator.manager.template.renewal.TemplateLoader;
 import org.tizen.emulator.manager.template.renewal.VMTemplate;
 import org.tizen.emulator.manager.ui.renewal.MainDialog;
@@ -87,17 +87,17 @@ public class VMModifyHandler {
        }
 
        private static List<ModifyDialogItem> getItemList(VMProperty property) {
-               BaseImage baseImage = property.getPropertyValue().getBaseImage();
-               if (baseImage == null) {
+               Platform platform = property.getPropertyValue().getPlatform();
+               if (platform == null) {
                        return getTmpItemList();
                }
 
                List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
-               if (baseImage.getDefaultItemList() != null) {
-                       itemList.addAll(baseImage.getDefaultItemList());
+               if (platform.getDefaultItemList() != null) {
+                       itemList.addAll(platform.getDefaultItemList());
                }
-               if (baseImage.getAdvancedItemList() != null) {
-                       itemList.addAll(baseImage.getAdvancedItemList());
+               if (platform.getAdvancedItemList() != null) {
+                       itemList.addAll(platform.getAdvancedItemList());
                }
 
                return itemList;
index b2a6639..d283157 100644 (file)
@@ -46,9 +46,7 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.platform.Platform;
-import org.tizen.emulator.manager.platform.backup.BaseImage;
-import org.tizen.emulator.manager.platform.backup.Profile;
-import org.tizen.emulator.manager.platform.backup.ProfileList;
+import org.tizen.emulator.manager.platform.StandardPlatform;
 import org.tizen.emulator.manager.renewal.resources.ColorKind;
 import org.tizen.emulator.manager.renewal.resources.Colors;
 import org.tizen.emulator.manager.ui.renewal.MainDialog;
@@ -160,14 +158,15 @@ public class AdvancedPropertyViewer {
        private List<ModifyDialogItem> makeProfileItems(String profileName) {
                List<ModifyDialogItem> profileItems = new ArrayList<ModifyDialogItem>();
 
-               Profile profile = ProfileList.getProfile(profileName);
-               if (profile == null) {
-                       return profileItems;
-               }
+               for (Platform platform : Platform.getPlatformList()) {
+                       if (!platform.getProfile().getName().equals(profileName)) {
+                               continue;
+                       }
+                       if (!(platform instanceof StandardPlatform)) {
+                               continue;
+                       }
 
-               // Added each baseimage's item-list
-               for (BaseImage image : profile.getImageList()) {
-                       addItems(profileItems, image.getAdvancedItemList());
+                       addItems(profileItems, platform.getAdvancedItemList());
                }
 
                // add skin item
index 7f6a17e..d7ebbef 100644 (file)
@@ -62,7 +62,7 @@ public class VMLauncher {
 
                List<String> cmd = getCommand(property);
 
-               String emulatorPath = property.getPropertyValue().getBaseImage().getPlatform().getEmulatorPath();
+               String emulatorPath = property.getPropertyValue().getPlatform().getEmulatorDirPath();
 
                Process process = launchInternal(property.getPropertyValue().vmsName, emulatorPath, cmd, path);
                if (process == null) {
@@ -91,7 +91,7 @@ public class VMLauncher {
 
        private static List<String> getCommand(VMProperty property)
                        throws VMLauncherException {
-               String emulatorPath = property.getPropertyValue().getBaseImage().getPlatform().getEmulatorPath();
+               String emulatorPath = property.getPropertyValue().getPlatform().getEmulatorDirPath();
                String binaryPath = FilePathResources.getEmulatorBinPath(emulatorPath)
                                + File.separator + getBinary();
                String configPath = LaunchConfig
index 1d19615..a5de631 100644 (file)
@@ -43,7 +43,7 @@ import java.util.List;
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
 import org.tizen.emulator.manager.platform.backup.BaseImage;
-import org.tizen.emulator.manager.plugin.BackupEMPlugin;
+import org.tizen.emulator.manager.plugin.EMPlugin;
 import org.tizen.emulator.manager.plugin.PluginStringResources;
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
@@ -128,11 +128,13 @@ public final class VMProperty {
        private VMProperty(Path propertyFile) {
                this.propertyFile = propertyFile;
                refresh();
+               initVMWorker();
        }
 
        private VMProperty(Path propertyFile, VMPropertyValue value) {
                this.propertyFile = propertyFile;
                setPropertyValue(value);
+               initVMWorker();
        }
 
        public VMProperty modify(VMPropertyValue value) {
@@ -194,11 +196,11 @@ public final class VMProperty {
        // FIXME: called from Profile class
        public void initVMWorker() {
 
-               if (getPropertyValue().getBaseImage() == null) {
+               if (getPropertyValue().getPlatform() == null) {
                        return;
                }
 
-               BackupEMPlugin plugin = getPropertyValue().getBaseImage().getPlatform().getPlugin();
+               EMPlugin plugin = getPropertyValue().getPlatform().getPlugin();
 
                if (plugin != null) {
                        worker = (VMWorkerCommon)plugin.newInstance(PluginStringResources.VMWorker);
index 67e3a10..51b6535 100644 (file)
@@ -113,6 +113,7 @@ public class VMPropertyValue implements Cloneable {
         * This is used for creating new emulator.
         * @param image base image of emulator
         */
+       @Deprecated
        public static VMPropertyValue createValueForNewVM(BaseImage image) {
                return createValueForNewVM(image, image.getDefaultProperty());
        }
@@ -123,6 +124,7 @@ public class VMPropertyValue implements Cloneable {
         * @param image base image of emulator
         * @param template default property of emulator
         */
+       @Deprecated
        public static VMPropertyValue createValueForNewVM(BaseImage image, VMProperty property) {
                VMPropertyValue newValue = property.getPropertyValue().clone();
                newValue.template = property;
@@ -167,10 +169,12 @@ public class VMPropertyValue implements Cloneable {
                settingSkin();
        }
 
+       @Deprecated
        public BaseImage getBaseImage() {
                return baseImage;
        }
 
+       @Deprecated
        public void setBaseImage(BaseImage image) {
                this.baseImage = image;
        }
@@ -237,7 +241,7 @@ public class VMPropertyValue implements Cloneable {
 
        public String getImageName() {
                if (platform != null) {
-                       return platform.getName();
+                       return platform.getImageName();
                } else {
                        return baseImage.getName();
                }
@@ -511,14 +515,14 @@ public class VMPropertyValue implements Cloneable {
 
                // find device-template sub item.
                List<VMItem> deviceTemplateItems = null;
-               for (VMItem vmItem : baseImage.getVmItemList()) {
+               for (VMItem vmItem : platform.getVmItemList()) {
                        if (vmItem.getName().equals(ItemName.DEVICE_TEMPLATE)) {
                                deviceTemplateItems = vmItem.getSubItems();
                        }
                }
                if (deviceTemplateItems == null) {
                        // if device-template sub items not exist..?
-                       deviceTemplateItems = baseImage.getVmItemList();
+                       deviceTemplateItems = platform.getVmItemList();
                }
 
                // Set addtional VMOptions
index 4cd4cce..1315588 100644 (file)
@@ -38,12 +38,8 @@ import java.util.List;
 import org.tizen.emulator.manager.devices.DeviceTemplateList;
 import org.tizen.emulator.manager.platform.Platform;
 import org.tizen.emulator.manager.platform.StandardPlatform;
-import org.tizen.emulator.manager.platform.backup.BaseImage;
-import org.tizen.emulator.manager.platform.backup.Profile;
-import org.tizen.emulator.manager.platform.backup.ProfileList;
 import org.tizen.emulator.manager.platform.custom.CustomPlatformImageValue;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 import org.tizen.emulator.manager.vms.xml.OptionType;
 import org.tizen.emulator.manager.vms.xml.SubOptionType;
@@ -61,7 +57,6 @@ public class VMPropertyValueCreator {
                VMPropertyValueCreator creator = new VMPropertyValueCreator(configuration);
                VMPropertyValue value = new VMPropertyValue(property);
                creator.settingConfigure(value);
-               //creator.settingBaseImage(value);
                creator.settingPlatform(value);
                return value;
        }
@@ -138,19 +133,6 @@ public class VMPropertyValueCreator {
                value.advancedVMOptionList = getAdvancedOptionList();
        }
 
-       private void settingBaseImage(VMPropertyValue value) {
-               if (configuration == null) {
-                       return;
-               }
-
-               // XXX Remove null check. Image should not be null..
-               // But now, image is null when creating default property.
-               BaseImage image = findBaseImage();
-               if (image != null) {
-                       value.settingBaseImage(image);
-               }
-       }
-
        private void settingPlatform(VMPropertyValue value) {
                if (configuration == null) {
                        return;
@@ -206,15 +188,6 @@ public class VMPropertyValueCreator {
                return configuration.getBaseInformation().getPlatform();
        }
 
-       private String getBaseImageName() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getBase();
-       }
-
        private String getDeviceTemplatePath() {
                if (configuration == null
                                || configuration.getBaseInformation() == null
@@ -240,47 +213,6 @@ public class VMPropertyValueCreator {
                return configuration.getBaseInformation().getDeviceTemplate().getVersion();
        }
 
-       private FSImageType getBaseImageType() {
-               if(isDiskImageNone()) {
-                       return null;
-               }
-
-               return FSImageType.standard.toString().equals(configuration.getBaseInformation().getDiskImage().getType()) ?
-                               FSImageType.standard : FSImageType.custom;
-       }
-
-       private String getBaseImageVersion() {
-               if(isDiskImageNone()) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getVersion();
-       }
-
-       private String getBaseImageProfile() {
-               if(isDiskImageNone()) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getProfile();
-       }
-
-       private String getBaseImagePlatform() {
-               if (configuration != null && configuration.getBaseInformation() != null
-                               && configuration.getBaseInformation().getPlatform() != null) {
-                       return configuration.getBaseInformation().getPlatform();
-               } else {
-                       String version = getBaseImageVersion();
-                       String profile = getBaseImageProfile();
-                       if (version == null || profile == null) {
-                               return ""; //$NON-NLS-1$
-                       }
-                       return profile + "-" + version; //$NON-NLS-1$
-               }
-       }
-
-
-
        private String getBaseImagePath() {
                if (isBaseDiskImageNone()) {
                        return ""; //$NON-NLS-1$
@@ -307,8 +239,6 @@ public class VMPropertyValueCreator {
                return configuration.getBaseInformation().getDiskImage().getSwapDiskImage().getValue();
        }
 
-
-
        private String getFileSharingPath() {
                if (configuration == null
                                || configuration.getUsability() == null
@@ -471,16 +401,4 @@ public class VMPropertyValueCreator {
                                || configuration.getBaseInformation() == null
                                || configuration.getBaseInformation().getDeviceTemplate() == null);
        }
-
-
-       private BaseImage findBaseImage() {
-               Profile profile = ProfileList.getProfile(getBaseImageProfile());
-               if (profile == null) {
-                       return null;
-               }
-               return profile.findBaseImage(getBaseImageType(),
-                               getBaseImagePath(),
-                               getBaseImageName(),
-                               getBaseImagePlatform());
-       }
 }
index b5fd7b0..31bd197 100644 (file)
@@ -115,7 +115,7 @@ public class VMWorkerCommon implements IVMWorker {
                        }
 
                        // Do argument validation.
-                       List<IOption> optList = property.getPropertyValue().getBaseImage().getOptionList();
+                       List<IOption> optList = property.getPropertyValue().getPlatform().getOptionList();
                        if (optList == null) {
                                throw new VMLauncherException(Messages.getString("VMWorkerCommon.LaunchError.1")); //$NON-NLS-1$
                        }
index 0c86fc4..a06647e 100644 (file)
@@ -48,7 +48,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.tizen.emulator.manager.platform.backup.ProfileList;
+import org.tizen.emulator.manager.platform.Preparer;
 import org.tizen.emulator.manager.resources.FilePathResources;
 
 public final class FileWatcher implements Runnable {
@@ -207,10 +207,10 @@ public final class FileWatcher implements Runnable {
        @Override
        public void run() {
                try {
-                       Object obj = ProfileList.getProfileList();
+                       Object obj = Preparer.getObject();
                        synchronized (obj) {
                                // Wait until all profiles are ready
-                               if (!ProfileList.initialized) {
+                               if (!Preparer.initialized) {
                                        obj.wait();
                                }
                        }
index f252622..c482f12 100644 (file)
@@ -36,7 +36,7 @@ public class BaseImageOption extends Option {
 
        @Override
        public void getLaunchArgument(LaunchConfig config, VMProperty property) {
-               if (property.getPropertyValue().getBaseImage() != null) {
+               if (property.getPropertyValue().getPlatform() != null) {
                        config.addVariable(OPTION_KEY.VAR_IMAGE_VER, property.getPropertyValue().getImageBinaryVersion());
                }
                config.addVariableWithSpace(OPTION_KEY.VAR_DRIVE, "file=${vms_path}" + File.separator + "${vm_name}" //$NON-NLS-1$ //$NON-NLS-2$
index 5179362..1174aec 100644 (file)
@@ -77,7 +77,7 @@ public class CommonOption extends Option {
                        config.addQemuOption("#-device virtconsole,chardev=virtcon1"); //$NON-NLS-1$
                }
 
-               String emulatorPath = property.getPropertyValue().getBaseImage().getPlatform().getEmulatorPath();
+               String emulatorPath = property.getPropertyValue().getPlatform().getEmulatorDirPath();
                // bios
                config.addVariableWithSpace(OPTION_KEY.VAR_BIOS_PATH, FilePathResources.getEmulatorBiosPath(emulatorPath));
                config.addQemuOption("-L", varForm(OPTION_KEY.VAR_BIOS_PATH)); //$NON-NLS-1$
index ee33bc7..b369ca8 100644 (file)
@@ -48,7 +48,7 @@ public class DisplayModeOption extends Option {
                }
 
                boolean useDirectRendering;
-               if (property.getPropertyValue().getBaseImage().isItemExist("displayMode")) {
+               if (property.getPropertyValue().getPlatform().isItemExist("displayMode")) {
                        if (checkOnOrEmpty(property.getPropertyValue().getAdvancedOptionSubValue(
                                "displayMode", "qtEnable"))) { //$NON-NLS-1$ //$NON-NLS-2$
                                useDirectRendering = true;
index be038b8..0758684 100644 (file)
@@ -122,7 +122,7 @@ public class LaunchConfig {
        public static void createLaunchConfig(VMProperty property)
                        throws VMWorkerException {
                // 1. Get option list which is matched with base-image.
-               List<IOption> optList = property.getPropertyValue().getBaseImage().getOptionList();
+               List<IOption> optList = property.getPropertyValue().getPlatform().getOptionList();
                if (optList == null) {
                        throw new VMWorkerException("Failed to get option list."); //$NON-NLS-1$
                }