Base Image : add checking profile, version routine
authorjihye424.kim <jihye424.kim@samsung.com>
Tue, 2 Jun 2015 04:53:02 +0000 (13:53 +0900)
committerjihye424.kim <jihye424.kim@samsung.com>
Fri, 5 Jun 2015 01:33:14 +0000 (10:33 +0900)
- compare profile and version of base image with platform
- delete 'IOException' when create custom base image
- delete 'BaseImage' variable in row item of tree view

Change-Id: I17000a6882d013ed59a7460599f2942a37abdc9f
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/platform/BaseImage.java
src/org/tizen/emulator/manager/platform/Platform.java
src/org/tizen/emulator/manager/platform/Profile.java
src/org/tizen/emulator/manager/platform/ProfileList.java
src/org/tizen/emulator/manager/plugin/PluginImageResources.java
src/org/tizen/emulator/manager/ui/VMsMainView.java
src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java
src/org/tizen/emulator/manager/ui/list/ItemListVew.java
src/org/tizen/emulator/manager/ui/list/RowItem.java

index f712b58..32cacfb 100644 (file)
@@ -42,7 +42,6 @@ import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.option.IOption;
-import org.tizen.emulator.manager.vms.option.LaunchConfig;
 import org.tizen.emulator.manager.vms.xml.template.ItemList;
 
 public class BaseImage {
@@ -68,7 +67,7 @@ public class BaseImage {
        protected ItemList itemList;
 
        protected List<IOption> optionList;
-       private LaunchConfig launchTemplate; // TODO replace xDefaultOption.java
+       //private LaunchConfig launchTemplate; // TODO replace xDefaultOption.java
 
        protected BaseImage() {
        }
@@ -94,10 +93,9 @@ public class BaseImage {
         * @param path base image path
         * @throws IOException
         */
-       public BaseImage(Platform platform, String path) throws IOException {
+       public BaseImage(Platform platform, String path) {
                if (platform == null) {
-                       throw new IOException("Failed to create custom base image "
-                               + StringResources.NEW_LINE + "because platform is null.");
+                       return;
                }
                this.platform = platform;
                isStandard = false;
@@ -179,7 +177,7 @@ public class BaseImage {
                return skinShape;
        }
 
-       private void checkBaseImageName() throws IOException {
+       private void checkBaseImage() throws IOException {
                if (imageName == null) {
                        throw new IOException("Image name is null. This image can not add.");
                }
@@ -191,6 +189,16 @@ public class BaseImage {
                                                + "(name: " + imageName + ")");
                        }
                }
+
+               if (!profile.equals(platform.getProfile())) {
+                       throw new IOException("Profile of base image(" + profile
+                               + ") does not equal profile of platform(" + platform.getProfile() + ").");
+               }
+
+               if (!version.equals(platform.getVersion())) {
+                       throw new IOException("Version of base image(" + version
+                                       + ") does not equal version of platform(" + platform.getVersion() + ").");
+               }
        }
 
        /**
@@ -207,7 +215,6 @@ public class BaseImage {
                                Properties prop = new Properties();
                                prop.load(inputStream);
                                imageName = prop.getProperty(StringResources.IMAGE_NAME, "");
-                               checkBaseImageName();
                                version = prop.getProperty(StringResources.IMAGE_VERSION, "2.4");
                                profile = prop.getProperty(StringResources.PRODUCT_PROFILE, PlatformStringResources.MOBILE_PROFILE).toLowerCase();
                                type = prop.getProperty(StringResources.IMAGE_TYPE, "default");
@@ -215,6 +222,7 @@ public class BaseImage {
                                cpu = cpu.toLowerCase();
                                skinShape = SKIN_SHAPE.find(prop.getProperty(StringResources.SKIN_SHAPE, "square"));
                                binaryVersion = prop.getProperty(StringResources.BINARY_VERSION, "1.0.0");
+                               checkBaseImage();
                        } else {
                                throw new IOException(StringResources.IMAGE_INFO_FILENAME + " file does not exist.");
                        }
index 9334d0c..f581e53 100644 (file)
@@ -250,7 +250,10 @@ public class Platform {
                        }
                } else {
                        EMLogger.getLogger().warning("Plug-in file does not exist." +
-                                       StringResources.NEW_LINE + "Plug-in file: " + pluginJar.getAbsolutePath());
+                                       StringResources.NEW_LINE + "Plug-in file: " + pluginDir.getAbsolutePath()
+                                       + File.separator + PlatformStringResources.PLUGIN_PREFIX
+                                       + "-" + profile
+                                       + "." + PlatformStringResources.PLUGIN_EXTENSION);
                }
        }
 
index 573aba5..a9eca64 100644 (file)
@@ -31,7 +31,6 @@
 package org.tizen.emulator.manager.platform;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -93,12 +92,10 @@ public class Profile {
                // return custom base image
                Platform platform = ProfileList.getProfile(createProperty.getImageProfile()).
                                getPlatformByVersion(createProperty.getImageVersion());
-               try {
+               if (platform != null) {
                        return new BaseImage(platform, createProperty.getBaseImagePath());
-               } catch (IOException e) {
-                       EMLogger.getLogger().warning("Failed to find baseimage. No platform");
-                       return null;
                }
+               return null;
        }
 
        public VMProperty getLastCreatedProperty() {
@@ -181,13 +178,8 @@ public class Profile {
                        } else {
                                for (Platform p : platformList) {
                                        if (vm.getImagePlatform().equals(p.getName())) {
-                                               try {
-                                                       vm.getPropertyValue().baseImage
-                                                               = new BaseImage(p,
-                                                                               vm.getBaseImagePath());
-                                               } catch (IOException e) {
-                                                       EMLogger.getLogger().warning(e.getMessage());
-                                               }
+                                               vm.getPropertyValue().baseImage
+                                                       = new BaseImage(p, vm.getBaseImagePath());
                                        }
                                }
                        }
index ddc38ea..fc0f8d7 100644 (file)
@@ -118,7 +118,7 @@ public class ProfileList {
 
        private static boolean isProfileDir(File profile) {
                for (File f : profile.listFiles()) {
-                       if (f.isDirectory() && f.getName().equalsIgnoreCase("emulator-images")) {
+                       if (f.isDirectory() && f.getName().equalsIgnoreCase("emulator-resources")) {
                                // this is profile directory
                                return true;
                        }
index 8a476cd..11f2d99 100644 (file)
@@ -153,7 +153,9 @@ class ImageRegistry {
                for (Profile p : ProfileList.getProfileList()) {
                        for (Platform pl : p.getPlatformList()) {
                                if (pl.getName().equals(platformName)) {
-                                       return pl.getPlugin().getLoader();
+                                       if (pl.getPlugin() != null) {
+                                               return pl.getPlugin().getLoader();
+                                       }
                                }
                        }
                }
index 9f9e931..dfffb59 100644 (file)
@@ -293,18 +293,30 @@ public class VMsMainView {
 
                if (!isCreateMode || currentProfile != profile) {
                        isCreateMode = true;
-                       VMProperty lastCreatedProperty = profile.getLastCreatedProperty();
-                       BaseImage findImage = null;
-                       if (lastCreatedProperty != null) {
-                               findImage = profile.findBaseImage(lastCreatedProperty);
-                       }
-
-                       if (findImage == null) {
-                               detailView.drawCreateVM(
-                                               new VMPropertyValue(profile.getImageList().get(0)));
+                       if (profile.getImageList().isEmpty()) {
+                               detailView.drawCreateVM(new VMPropertyValue(
+                                               new BaseImage(profile.getPlatformByLatestVersion(),""),
+                                               profile.getPlatformByLatestVersion().getCustomDefaultProperty()));
                        } else {
-                               detailView.drawCreateVM(
-                                               new VMPropertyValue(findImage, lastCreatedProperty));
+                               VMProperty lastCreatedProperty = profile.getLastCreatedProperty();
+                               BaseImage findImage = null;
+                               if (lastCreatedProperty != null) {
+                                       findImage = profile.findBaseImage(lastCreatedProperty);
+                               }
+
+                               if (findImage == null
+                                               || findImage.getItemList() == null
+                                               || findImage.getPlatform().getPlugin() == null) {
+                                       for (BaseImage image : profile.getImageList()) {
+                                               if (image.getItemList() != null && image.getPlatform().getPlugin() != null) {
+                                                       detailView.drawCreateVM(
+                                                                       new VMPropertyValue(image));
+                                               }
+                                       }
+                               } else {
+                                       detailView.drawCreateVM(
+                                                       new VMPropertyValue(findImage, lastCreatedProperty));
+                               }
                        }
                }
        }
index 77f7d0e..101c252 100644 (file)
@@ -356,25 +356,29 @@ public class PModifyViewPage extends DetailViewPage
                DetailViewItem errorItem = null;
 
                // Check Item state
-               for (IModifyViewItem item : topViewList.itemList) {
-                       if (item instanceof DetailViewItem) {
-                               DetailViewItem viewItem = (DetailViewItem)item;
-                               viewItem.checkValue();
-                               viewItem.updateItemUI(); // normal / warning / error
-
-                               if (viewItem.getItemState().isError()) {
-                                       if (errorItem == null || !errorItem.getItemState().isError()) {
-                                               errorItem = viewItem;
-                                       }
+               if (topViewList == null || topViewList.itemList == null) {
+                       isValid = false;
+               } else {
+                       for (IModifyViewItem item : topViewList.itemList) {
+                               if (item instanceof DetailViewItem) {
+                                       DetailViewItem viewItem = (DetailViewItem)item;
+                                       viewItem.checkValue();
+                                       viewItem.updateItemUI(); // normal / warning / error
+
+                                       if (viewItem.getItemState().isError()) {
+                                               if (errorItem == null || !errorItem.getItemState().isError()) {
+                                                       errorItem = viewItem;
+                                               }
 
-                               } else if (viewItem.getItemState().isWarning()) {
-                                       if (errorItem == null || errorItem.getItemState().isNormal()) {
-                                               errorItem = viewItem;
+                                       } else if (viewItem.getItemState().isWarning()) {
+                                               if (errorItem == null || errorItem.getItemState().isNormal()) {
+                                                       errorItem = viewItem;
+                                               }
                                        }
-                               }
 
-                               if (viewItem.getItemState().isError()) {
-                                       isValid = false;
+                                       if (viewItem.getItemState().isError()) {
+                                               isValid = false;
+                                       }
                                }
                        }
                }
index 6befc35..d94a64b 100644 (file)
@@ -44,7 +44,6 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Text;
-import org.tizen.emulator.manager.platform.Platform;
 import org.tizen.emulator.manager.platform.Profile;
 import org.tizen.emulator.manager.platform.SortBy;
 import org.tizen.emulator.manager.resources.ColorResources;
index ebad3ac..78ebb3a 100644 (file)
@@ -33,7 +33,6 @@ package org.tizen.emulator.manager.ui.list;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.widgets.TreeItem;
 import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.platform.BaseImage;
 import org.tizen.emulator.manager.platform.Profile;
 import org.tizen.emulator.manager.resources.FontResources;
 import org.tizen.emulator.manager.resources.ImageResources;
@@ -98,7 +97,6 @@ class PropertyContent implements TreeContent {
 }
 
 class CreateMarker implements TreeMarker {
-       private BaseImage image = null;
        private Profile profile = null;
        TreeItem item;
 
@@ -110,14 +108,9 @@ class CreateMarker implements TreeMarker {
                item.setFont(font);
 
                this.profile = profile;
-               this.image =profile.getImageList().get(0);
                this.item = item;
        }
 
-       public BaseImage getBaseImage() {
-               return image;
-       }
-
        public TreeItem getItem() {
                return item;
        }