Option: Added base-image select option.
authorminkee.lee <minkee.lee@samsung.com>
Wed, 13 May 2015 09:36:51 +0000 (18:36 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Wed, 13 May 2015 09:58:24 +0000 (18:58 +0900)
Change-Id: Id5b06e80bfa2be04b39d8b1f3e81f25ba56158f9
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
14 files changed:
common-project/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java
common-project/src/org/tizen/emulator/manager/platform/BaseImage.java
common-project/src/org/tizen/emulator/manager/platform/Profile.java
common-project/src/org/tizen/emulator/manager/platform/ProfileList.java
common-project/src/org/tizen/emulator/manager/platform/Skin.java
common-project/src/org/tizen/emulator/manager/platform/SkinList.java
common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java
common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/DetailViewItemChangeListener.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/property/BaseImageViewItem.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/property/ResolutionSubViewItem.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/property/SkinSubViewItem.java
common-project/src/org/tizen/emulator/manager/ui/list/ItemListVew.java
common-project/src/org/tizen/emulator/manager/vms/VMPropertyValue.java

index c58638d..bbd08e9 100644 (file)
@@ -133,7 +133,7 @@ public class ConsoleCreateVM {
                                        image = ProfileList.getProfileList().get(0).getImageList().get(0);
                                } else {
                                        // default profile is mobile profile
-                                       Profile profile = ProfileList.findProfile(PlatformStringResources.MobileProfile);
+                                       Profile profile = ProfileList.getProfile(PlatformStringResources.MobileProfile);
                                        if (profile != null) {
                                                image = profile.getImageList().get(0);
                                        }
index 46a95f8..9d3dcfa 100644 (file)
@@ -120,6 +120,10 @@ public class BaseImage {
                return lastCreatedPropertyPath;
        }
 
+       public SKIN_SHAPE getSkinShape() {
+               return skinShape;
+       }
+
        protected void initLastCreatedPropertyPath() {
                StringBuilder sb = new StringBuilder();
                sb.append(FilePathResources.getTizenVmsPath()).append(File.separator)
index 47ab516..bc1a0ca 100644 (file)
@@ -82,6 +82,7 @@ public class Profile {
                return getPlatformByName(name + "-" + version);
        }
 
+
        public Platform getPlatformByLatestVersion() {
                Platform latest = null;
                for (Platform platform :platformList){
@@ -94,6 +95,23 @@ public class Profile {
                return latest;
        }
 
+       public String getLatestPlatformVersion() {
+               float latest = 0;
+               float version;
+               for (Platform plt : platformList) {
+                       try {
+                               version = Float.parseFloat(plt.getVersion());
+                               if (version >= latest) {
+                                       latest = version;
+                               }
+                       } catch (NumberFormatException e) {
+                               EMLogger.getLogger().warning(e.getMessage());
+                               EMLogger.getLogger().warning("Wrong platform version : " + plt.getVersion());
+                       }
+               }
+               return String.valueOf(latest);
+       }
+
        public void addEmulator(VMProperty vm) {
                //setting BaseImage
                if (vm.getPropertyValue().baseImage == null) {
index 4b02239..9f641f6 100644 (file)
@@ -60,7 +60,7 @@ public class ProfileList {
                return totalProfile;
        }
 
-       public static Profile findProfile(String profileName) {
+       public static Profile getProfile(String profileName) {
                if (profileList == null) {
                        initProfileList();
                }
index 276c0b7..205c208 100644 (file)
@@ -38,6 +38,7 @@ import java.util.logging.Level;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.SKIN_TYPE;
 
 public class Skin {
@@ -48,6 +49,7 @@ public class Skin {
 //     private SKIN_BUTTON_TYPE buttonType;
        private int priorty = 5;
        private String profile;
+       private SKIN_SHAPE skinShape;
 
        public Skin(File path) throws IOException {
                loadProperty(path);
@@ -67,6 +69,7 @@ public class Skin {
                                String height = prop.getProperty(StringResources.SKIN_HEIGHT);
                                priorty = Integer.valueOf(prop.getProperty(StringResources.SKIN_PRIORITY, "5"));
                                profile = prop.getProperty(StringResources.SKIN_PROFILE, StringResources.SKIN_GENERAL);
+                               skinShape = SKIN_SHAPE.find(prop.getProperty(StringResources.SKIN_SHAPE, "square"));
 
                                String re = "";
                                if(width.equals(StringResources.SKIN_GENERAL) && height.equals(StringResources.SKIN_GENERAL)) {
@@ -138,6 +141,10 @@ public class Skin {
                this.path = path;
        }
 
+       public SKIN_SHAPE getSkinShape() {
+               return skinShape;
+       }
+
        @ Override
        public String toString() {
                return name;
index e7c0d95..ddc31bf 100644 (file)
@@ -38,6 +38,7 @@ 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.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.SKIN_TYPE;
 
 public class SkinList {
@@ -198,6 +199,25 @@ public class SkinList {
                return sortForPriority(returnSkins);
        }
 
+       public ArrayList<Skin> findImageSkinList(RESOLUTION resolution,ArrayList<Skin> list,
+                       SKIN_SHAPE imageSkinShape) {
+               returnSkins.clear();
+               ArrayList<Skin> sourceSkinList = (list != null) ? list : skinList;
+               if (sourceSkinList != null) {
+                       for (Skin skin : sourceSkinList) {
+                               if (skin.getType() == SKIN_TYPE.GENERAL) {
+                                       returnSkins.add(skin);
+
+                               } else if (skin.getResolution().equals(resolution)) {
+                                       if (imageSkinShape == SKIN_SHAPE.NONE || imageSkinShape == skin.getSkinShape()){
+                                               returnSkins.add(skin);
+                                       }
+                               }
+                       }
+               }
+               return sortForPriority(returnSkins);
+       }
+
        public ArrayList<Skin> findGeneralSkinList( ArrayList<Skin> list) {
                returnSkins.clear();
                if (list != null) {
index 5262f63..482ecfb 100644 (file)
@@ -316,14 +316,14 @@ class ViewItemList {
                if (platform != propertyValue.baseImage.getPlatform()) {
                        return false;
                } else {
-                       if (imageName != null && !imageName.equals(propertyValue.baseImage.getName())) {
+                       if (imageName != null && !imageName.equals(propertyValue.baseName)) {
                                return false;
                        }
                }
-               if (isCustom &&  !(propertyValue.baseImage instanceof CustomBaseImage)) {
+               if (isCustom &&  propertyValue.isStandard) {
                        return false;
                }
-               if (!isCustom && propertyValue.baseImage instanceof CustomBaseImage) {
+               if (!isCustom && !propertyValue.isStandard) {
                        return false;
                }
 
index 224cf42..744452f 100644 (file)
@@ -246,6 +246,34 @@ public class PModifyViewPage extends DetailViewPage
                MainDialog.refreshVMPropertyList(false);
        }
 
+       @Override
+       public void changePropertyView(VMPropertyValue value, boolean isCreate) {
+
+               confirmButton.setEnabled(false);
+               buttonComp.layout(true, true);
+
+               isCreateMode = isCreate;
+               oldValue = value;
+               newValue = oldValue.clone();
+
+//             if (needChangeItemList(propertyValue)) {
+               if (needChangeItemList(topViewList, value)) {
+                       changeItemList(value);
+               } else {
+                       reset();
+               }
+
+               if (topViewList != null) {
+                       for (IModifyViewItem i : topViewList.itemList) {
+                               i.setCreateMode(isCreate);
+                               i.settingModifyItem(value);
+                       }
+               } else {
+                       // draw empty view
+               }
+       }
+
+
        VMPropertyValue oldValue;
        VMPropertyValue newValue;
        @Override
index 8bfbfe5..d6da16d 100644 (file)
@@ -29,6 +29,8 @@
 
 package org.tizen.emulator.manager.ui.detail.item;
 
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
 // TODO: need new name
 enum State {
        CREATE, MODIFY, CANCEL;
@@ -40,4 +42,5 @@ public interface DetailViewItemChangeListener {
        public void ChangeState(ItemChangeState state);
        public void changeCreateConfirmButton();
        public void changeModifyConfirmButton(DetailViewItem item);
+       public void changePropertyView(VMPropertyValue value, boolean isCreate);
 }
index 257e02d..94b7399 100644 (file)
@@ -1,14 +1,13 @@
 /*
  * Emulator Manager
  *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * MunKyu Im <munkyu.im@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
  * Minkee Lee <minkee.lee@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  *
  */
 
+
 package org.tizen.emulator.manager.ui.detail.item.property;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+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.Platform;
+import org.tizen.emulator.manager.platform.Profile;
+import org.tizen.emulator.manager.platform.ProfileList;
+import org.tizen.emulator.manager.resources.FontResources;
 import org.tizen.emulator.manager.resources.ImageResources;
 import org.tizen.emulator.manager.resources.PatchImageResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.ui.MainDialog;
 import org.tizen.emulator.manager.ui.detail.item.ItemState;
 import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.FileViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.ComboViewItem;
 import org.tizen.emulator.manager.ui.dialog.MessageDialog;
-import org.tizen.emulator.manager.ui.widgets.ImageButton;
+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;
 import org.tizen.emulator.manager.vms.xml.template.Item;
 
-public class BaseImageViewItem extends FileViewItem {
+public class BaseImageViewItem extends ComboViewItem {
+
+       Button addButton;
+       protected static int BUTTON_WIDTH = 38;
+       protected static int BUTTON_HEIGHT = 20;
+       protected static int COMBOBOX_WIDTH_MODIFY = 133;
+
+       protected FileDialog fd;
+       protected List<String> filters = new ArrayList<String>();
 
-       private String newPath;
-       private String newPathName;
+       private BaseImageItem currentBaseImageItem = new BaseImageItem();
 
        private boolean isSelected;
-       private boolean isStandard;
+
+       private List<BaseImageItem> baseImageItemList = new ArrayList<BaseImageItem>();
+
+       // Remember custom image list while emulator manager life-cycle.
+       private static List<BaseImageItem> customImageItemList = new ArrayList<BaseImageItem>();
+
+       // For disable state.
+       protected ImageLabel filePathLabel;
        private Image IMAGE_INPUTBOX_IMAGE = null;
+       protected int DIR_INPUTBOX_ON_WIDTH     = 133;
+
 
-       public BaseImageViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
+       // For itemlist change
+       private VMPropertyValue value;
+
+       // For custom image add.
+       private String profile;
+
+       public BaseImageViewItem(Item template,
+                       LineLabelViewItem lineLabelViewItem) {
                super(template, lineLabelViewItem);
        }
 
        @Override
-       public void makeModifyWidget() {
+       public void setValue(VMPropertyValue value) {
+               value.baseImagePath = currentBaseImageItem.getFilePath();
+               value.baseImagePathName = currentBaseImageItem.getFileName();
+               value.isStandard = currentBaseImageItem.isStandard();
+               value.baseName = currentBaseImageItem.getImageName();
+               value.version = value.isStandard ?
+                               currentBaseImageItem.getVersion() : getLatestVersion(value.profile);
+               value.skinShape = currentBaseImageItem.getSkinShape();
+       }
 
+       @Override
+       public boolean settingDetailItem(VMPropertyValue value) {
+               if (valueLabel != null) {
+                       valueLabel.setText(value.baseName);
+                       if (!value.isStandard) {
+                               valueLabel.setToolTipText(value.baseImagePath);
+                       }
+               }
+               return true;
+       }
+
+       @Override
+       public void drawModify() {
+
+               // Disable label
                if (IMAGE_INPUTBOX_IMAGE == null) {
                        IMAGE_INPUTBOX_IMAGE = PatchImageResources.getInputBoxON(DIR_INPUTBOX_ON_WIDTH);
                }
-
                filePathLabel = new ImageLabel(compList.get(0), SWT.NONE);
                filePathLabel.setEnableImage(IMAGE_INPUTBOX_IMAGE);
                filePathLabel.setDisableImage(IMAGE_INPUTBOX_IMAGE);
 
-               selectFileButton = new ImageButton(compList.get(0), SWT.PUSH);
-               selectFileButton.setImages(
-                               ImageResources.BUTTON_FILE_NOMAL.getImage(),
-                               ImageResources.BUTTON_FILE_HOVER.getImage(),
-                               ImageResources.BUTTON_FILE_PUSH.getImage(),
-                               ImageResources.BUTTON_FILE_DISABLE.getImage());
+               // Combo
+               if (INPUTBOX_ON_IMAGE == null) {
+                       INPUTBOX_ON_IMAGE = PatchImageResources
+                                       .getInputBoxON(COMBOBOX_WIDTH_MODIFY);
+               }
+
+               if (INPUTBOX_OFF_IMAGE == null) {
+                       INPUTBOX_OFF_IMAGE = PatchImageResources
+                                       .getInputBoxOff(COMBOBOX_WIDTH_MODIFY);
+               }
 
-               selectFileButton.addSelectionListener(new SelectionListener() {
+               combo = new ImageCombo(compList.get(0), SWT.NONE);
+               combo.setImage(WSTATE.NORMAL, INPUTBOX_ON_IMAGE);
+               combo.setImage(WSTATE.PUSH, INPUTBOX_ON_IMAGE);
+               combo.setImage(WSTATE.HOVER, INPUTBOX_ON_IMAGE);
+               combo.setImage(WSTATE.DISABLE_ON, INPUTBOX_ON_IMAGE);
+
+               combo.setArrowButtonImage(ImageResources.ARROW_DROPDOWN.getImage());
+               combo.setEnabled(true);
+               combo.setItemHeight(INPUTBOX_ON_IMAGE.getImageData().height);
+               combo.setLayout(new FormLayout());
+
+               // Button
+               addButton = new Button(compList.get(0), SWT.NORMAL);
+               addButton.setText("...");
+               addButton.setFont(FontResources.COMBO_BUTTON_FONT.getFont());
+               addButton.setToolTipText("Add custom base image");
+
+               FormData data = new FormData();
+               data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+               data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+               data.width = INPUTBOX_ON_IMAGE.getImageData().width;
+               data.height = INPUTBOX_ON_IMAGE.getImageData().height;
+               combo.setLayoutData(data);
+
+               data = new FormData();
+               data.left       = new FormAttachment(0,INPUTBOX_OFFSET);
+               data.top        = new FormAttachment(0, INPUTBOX_TOP_GAP);
+               data.width      = filePathLabel.getSize().x;
+               data.height = filePathLabel.getSize().y;
+               filePathLabel.setLayoutData(data);
+
+               data = new FormData();
+               data.left = new FormAttachment(combo, 5);
+               data.top = new FormAttachment(0, 3);
+               data.width = BUTTON_WIDTH;
+               data.height = BUTTON_HEIGHT;
+               addButton.setLayoutData(data);
+
+
+               // make combobox list
+               addWidgetListener();
+
+       }
+
+       @Override
+       protected void addWidgetListener() {
+               combo.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
+//                             newValue = combo.getText();
+
+                               // Select image.
+                               int index = combo.getSelectionIndex();
+                               setCurrentBaseImage(index);
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+
+               addButton.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetSelected(SelectionEvent arg0) {
                                if (fd == null) {
                                        fd = new FileDialog(MainDialog.getShell(), SWT.OPEN);
                                        fd.setText(String.format("Select existing Base Image"));
-                                       String[] filter         = null;
+                                       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)"};
+                                               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);
@@ -108,107 +232,182 @@ public class BaseImageViewItem extends FileViewItem {
                                String path = fd.open();
                                if (path != null) {
                                        if (!HelperClass.isPathAvaliable(path)) {
-                                               new MessageDialog().openWarningDialog("This base image not ready yet."
-                                                               + StringResources.NEW_LINE
-                                                               + "Please select again in a few seconds.");
+                                               new MessageDialog()
+                                                               .openWarningDialog("This base image not ready yet."
+                                                                               + StringResources.NEW_LINE
+                                                                               + "Please select again in a few seconds.");
                                                return;
                                        }
-                                       newPath = path;
-                                       newPathName = path.substring(path.lastIndexOf(File.separator) + 1, path.length());
+                                       String newPath = path;
+                                       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";
+                                       EmulatorVMList.getInstance().CustomArch = !isArm ? "x86"
+                                                       : "arm";
+
+                                       addCustomImageItem(new BaseImageItem(newPathName,
+                                                       newPathName, newPath, profile, "", false, SKIN_SHAPE.NONE));
 
-                                       filePathLabel.setText(newPathName);
-                                       filePathLabel.redraw();
+                                       // filePathLabel.setText(newPathName);
+                                       // filePathLabel.redraw();
                                        isSelected = true;
                                        getListener().changeCreateConfirmButton();
 
-                                       // TODO
-                                       //arm image
-                                       //false hw virtualization
-                                       //false gl accelertaion
                                }
                        }
 
                        @Override
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                               // TODO Auto-generated method stub
+                       public void widgetDefaultSelected(SelectionEvent arg0) {
                        }
+
                });
        }
 
        @Override
-       public void closeItem() {
-               super.closeItem();
-               if (IMAGE_INPUTBOX_IMAGE != null) {
-                       IMAGE_INPUTBOX_IMAGE.dispose();
+       public boolean settingModifyItem(VMPropertyValue value) {
+               this.value = value;
+               this.profile = value.profile;
+
+               currentBaseImageItem.setFileName(value.baseImagePathName);
+               currentBaseImageItem.setFilePath(value.baseImagePath);
+               currentBaseImageItem.setStandard(value.isStandard);
+               currentBaseImageItem.setImageName(value.baseName);
+               currentBaseImageItem.setProfile(value.profile);
+               currentBaseImageItem.setSkinShape(value.skinShape);
+               isSelected = false;
+
+               if (isCreateMode()) {
+                       // List base image.
+                       filePathLabel.setVisible(false);
+                       combo.setVisible(true);
+                       addButton.setEnabled(true);
+                       loadBaseImageItemList(value.profile);
+                       loadCustomImageItemList(value.profile);
+                       resetComboList();
+
+               } else {
+                       combo.removeAll();
+                       combo.add(value.baseName);
+                       combo.select(0);
+                       combo.setText(value.baseName);
+                       combo.setEnabled(false);
+                       addButton.setEnabled(false);
+                       isSelected = true;
+                       combo.setVisible(false);
+
+                       filePathLabel.setText(value.baseName);
+                       filePathLabel.setToolTipText(currentBaseImageItem.getFileName());
+                       filePathLabel.setVisible(true);
+                       filePathLabel.setEnabled(false);
+                       filePathLabel.redraw();
+               }
+
+               if (isCreateMode()) {
+                       getListener().changeCreateConfirmButton();
                }
+
+               return false;
        }
 
-       @Override
-       public void setValue(VMPropertyValue value) {
-               value.baseImagePath     = newPath;
-               value.baseImagePathName = newPathName;
+       public static String getLatestVersion(String profileName) {
+               Profile profile = ProfileList.getProfile(profileName);
+               if (profile != null) {
+                       return profile.getLatestPlatformVersion();
+               }
+               return "";
        }
 
-       @Override
-       public boolean settingDetailItem(VMPropertyValue value) {
-               if (valueLabel != null) {
-                       valueLabel.setText(value.baseImagePathName);
-                       if (!value.isStandard) {
-                               valueLabel.setToolTipText(value.baseImagePath);
+       private void loadBaseImageItemList(String profileName) {
+               baseImageItemList.clear();
+               Profile profile = ProfileList.getProfile(profileName);
+               if (profile != null) {
+                       for (BaseImage img : profile.getImageList()) {
+                               baseImageItemList.add(new BaseImageItem(img.getName(), img
+                                               .getPathName(), img.getPath(), img.getProfile(), img.getVersion(),
+                                               true, img.getSkinShape()));
                        }
                }
-               return true;
        }
 
-       @Override
-       public boolean settingModifyItem(VMPropertyValue value) {
+       private void loadCustomImageItemList(String profile) {
+               for (BaseImageItem customImageItem : customImageItemList) {
+                       if (customImageItem.getProfile().equals(profile)) {
+                               baseImageItemList.add(new BaseImageItem(customImageItem));
+                       }
+               }
+       }
 
-               isStandard      = value.isStandard;
+       private void addCustomImageItem(BaseImageItem customImageItem) {
+               // Check duplicated custom image.
+               int index = -1;
+               for (int i = 0; i < baseImageItemList.size(); i++) {
+                       BaseImageItem item = baseImageItemList.get(i);
+                       if (item.equals(customImageItem)) {
+                               index = i;
+                               break;
+                       }
+               }
 
-               newPath         = value.baseImagePath;
-               newPathName = value.baseImagePathName;
-               isSelected      = false;
+               if (index == -1) {
+                       // Add to image list
+                       baseImageItemList.add(customImageItem);
+                       // Setting combo list.
+                       combo.add(customImageItem.getImageName());
+                       index = baseImageItemList.size() -1;
 
-               if (isCreateMode()) {
-                       if (isStandard) {
-                               filePathLabel.setText(value.baseImage == null
-                                               ? value.baseImagePathName
-                                               : value.baseImage.getPathName());
-                               filePathLabel.setEnabled(false);
-                               selectFileButton.setEnabled(false);
-                               isSelected = true;
-                       } else {
-                               filePathLabel.setEnabled(true);
-                               if (checkBaseImageFile(value.baseImagePath)) {
-                                       filePathLabel.setText(value.baseImagePathName);
-                                       filePathLabel.setToolTipText(value.baseImagePath);
-                                       isSelected = true;
-                               } else {
-                                       filePathLabel.setText("");
-                               }
-                               selectFileButton.setEnabled(true);
-                       }
-               } else {
-                       isSelected = true;
-                       filePathLabel.setText(value.baseImagePathName);
-                       filePathLabel.setEnabled(false);
-                       selectFileButton.setEnabled(false);
+                       customImageItemList.add(new BaseImageItem(customImageItem));
                }
+
+               combo.select(index);
+               setCurrentBaseImage(index);
+       }
+
+       private void setCurrentBaseImage(int index) {
+               currentBaseImageItem = baseImageItemList.get(index);
+
+//             if (currentBaseImageItem.isStandard()) {
+//                     currentCustomImageItem = null;
+//             } else {
+//                     currentCustomImageItem = currentBaseImageItem;
+//             }
+
+               setValue(value);
+               getListener().changePropertyView(value, isCreateMode());
+
                if(isCreateMode()) {
                        getListener().changeCreateConfirmButton();
                }
-
-               return false;
        }
 
+       private void resetComboList() {
+               if (combo != null) {
+                       combo.removeAll();
+               }
 
-       @Override
-       public void settingStatus(boolean isRefresh) {
+               // make combo box list
+               for (BaseImageItem item : baseImageItemList) {
+                       combo.add(item.getImageName());
+               }
 
+               // Select combo-box item.
+               int index = -1;
+               for (int i = 0; i < baseImageItemList.size(); i++) {
+                       if (baseImageItemList.get(i).equals(currentBaseImageItem)) {
+                               index = i;
+                               break;
+                       }
+               }
+               if (baseImageItemList.size() > 0) {
+                       if (index == -1) { // if value not matches..
+                               index = 0;
+                       }
+                       combo.select(index);
+                       currentBaseImageItem = baseImageItemList.get(index);
+                       isSelected = true;
+               }
+               combo.setEnabled(true);
        }
 
        @Override
@@ -216,7 +415,7 @@ public class BaseImageViewItem extends FileViewItem {
                itemState.setNormal();
 
                if (isSelected) {
-                       File f = new File(newPath);
+                       File f = new File(currentBaseImageItem.getFilePath());
                        if (!f.exists()) {
                                itemState.setError("Base image file is not exist.");
                        }
@@ -228,8 +427,7 @@ public class BaseImageViewItem extends FileViewItem {
                return itemState;
        }
 
-
-       public static boolean checkBaseImageFile(String baseImagePath){
+       public static boolean checkBaseImageFile(String baseImagePath) {
                if (baseImagePath == null || baseImagePath.isEmpty()) {
                        return false;
                }
@@ -240,8 +438,8 @@ public class BaseImageViewItem extends FileViewItem {
                } else {
                        pathSplit = baseImagePath.split(File.separator);
                }
-               String fileSplit[] = pathSplit[pathSplit.length-1].split("\\.");
-               String extension = fileSplit[fileSplit.length-1];
+               String fileSplit[] = pathSplit[pathSplit.length - 1].split("\\.");
+               String extension = fileSplit[fileSplit.length - 1];
                if (!extension.equals("x86")) {
                        return false;
                }
@@ -255,3 +453,112 @@ public class BaseImageViewItem extends FileViewItem {
        }
 
 }
+
+class BaseImageItem {
+
+       private String imageName;
+       private String fileName;
+       private String filePath;
+       private String profile;
+       private String version;
+       private boolean isStandard;
+       private SKIN_SHAPE skinShape;
+
+       public BaseImageItem() {
+       }
+
+       public BaseImageItem(String imageName, String fileName, String path,
+                       String profile, String version, boolean isStandard, SKIN_SHAPE skinShape) {
+               this.imageName = imageName;
+               this.fileName = fileName;
+               this.filePath = path;
+               this.profile = profile;
+               this.version = version;
+               this.isStandard = isStandard;
+               this.skinShape = skinShape;
+       }
+
+       public BaseImageItem(BaseImageItem item) {
+               this(item.getImageName(), item.getFileName(), item.getFilePath(),
+                               item.getProfile(), item.getVersion(), item.isStandard(), item.getSkinShape());
+       }
+
+       public String getImageName() {
+               return imageName;
+       }
+
+       public void setImageName(String imageName) {
+               this.imageName = imageName;
+       }
+
+       public String getFileName() {
+               return fileName;
+       }
+
+       public void setFileName(String fileName) {
+               this.fileName = fileName;
+       }
+
+       public String getFilePath() {
+               return filePath;
+       }
+
+       public void setFilePath(String path) {
+               this.filePath = path;
+       }
+
+       public String getProfile() {
+               return profile;
+       }
+
+       public void setProfile(String profile) {
+               this.profile = profile;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       public boolean isStandard() {
+               return isStandard;
+       }
+
+       public void setStandard(boolean isStandard) {
+               this.isStandard = isStandard;
+       }
+
+       public SKIN_SHAPE getSkinShape() {
+               return skinShape;
+       }
+
+       public void setSkinShape(SKIN_SHAPE skinShape) {
+               this.skinShape = skinShape;
+       }
+
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof BaseImageItem)) {
+                       return false;
+               }
+               BaseImageItem item = (BaseImageItem)object;
+
+               if (!item.getFilePath().equals(filePath)) {
+                       return false;
+               }
+
+               if (!item.getProfile().equals(profile)) {
+                       return false;
+               }
+
+               if (!item.getImageName().equals(imageName)) {
+                       return false;
+               }
+
+               return true;
+       }
+
+}
index 687d7ea..aab5e66 100644 (file)
@@ -163,15 +163,16 @@ public class ResolutionSubViewItem extends ComboSubViewItem {
                                        break;
                                }
                        }
-                       if (index == -1) {
-                               combo.add(oldResolution.toString(), 0);
-                       }
+//                     if (index == -1) {
+//                             combo.add(oldResolution.toString(), 0);
+//                     }
                }
                // select item
                if (index == -1) {
                        index = 0;
                }
                combo.select(index);
+               oldResolution = newResolution = value.resolution = resList.get(index);
                return true;
        }
 
index 4ef0017..0b5ffe6 100644 (file)
@@ -43,6 +43,7 @@ import org.tizen.emulator.manager.platform.SkinList;
 import org.tizen.emulator.manager.ui.detail.item.template.ComboSubViewItem;
 import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
 import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.SKIN_TYPE;
 import org.tizen.emulator.manager.vms.VMPropertyValue;
 import org.tizen.emulator.manager.vms.xml.template.Item;
@@ -55,6 +56,7 @@ public class SkinSubViewItem extends ComboSubViewItem {
 
        private ArrayList<Skin> skinList;
        private DisplayViewItem displayItem;
+       private SKIN_SHAPE imageSkinShape;
 
        public SkinSubViewItem(LabelViewItem parentItem, Composite comp,
                        Item template) {
@@ -124,6 +126,7 @@ public class SkinSubViewItem extends ComboSubViewItem {
 
        @Override
        public boolean settingModifyItem(VMPropertyValue value) {
+               imageSkinShape = value.skinShape;
                newSkin = oldSkin = value.skin;
                skinList = value.baseImage.getPlatform().getSkins();
 
@@ -148,7 +151,8 @@ public class SkinSubViewItem extends ComboSubViewItem {
                                find = 0;
                        }
                } else {
-                       skins = SkinList.getInstance().findSkinList(re, skinList);
+//                     skins = SkinList.getInstance().findSkinList(re, skinList);
+                       skins = SkinList.getInstance().findImageSkinList(re, skinList, imageSkinShape);
 
                        Skin s = null;
                        for (int i = 0; i < skins.size(); i++) {
index 8dd9de9..999e1d5 100644 (file)
@@ -229,8 +229,9 @@ public class ItemListVew extends AbstractListView {
                        VMButton button = null;
                        for (int i = 0; i < profile.getEmulatorList().size(); i++) {
                                // TODO
-                               button = VMButtonFactory.getButton(vmList, profile.getImageList().get(0));
-                               button.setProperty(profile.getEmulatorList().get(i));
+                               button = VMButtonFactory.getButton(vmList, profile.getImageList().get(0),
+                                               profile.getEmulatorList().get(i));
+                               button.setProperty();
                                if (i == select) {
                                        VMButtonFactory.clickVMButton(button);
                                }
@@ -264,7 +265,6 @@ public class ItemListVew extends AbstractListView {
                dumyText.setFocus();
        }
 
-       @Override
        public void drawEmptyVMList() {
                if (createButton != null) {
                        createButton.dispose();
index d20c6f3..a938ab9 100644 (file)
@@ -31,6 +31,7 @@
 package org.tizen.emulator.manager.vms;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -61,6 +62,7 @@ public class VMPropertyValue implements Cloneable {
        public boolean isStandard;
        public String baseImagePath;
        public String baseImagePathName;
+       public SKIN_SHAPE skinShape = SKIN_SHAPE.SQUARE;
 
        public RESOLUTION resolution;
        public int dpi;
@@ -112,6 +114,7 @@ public class VMPropertyValue implements Cloneable {
                        profile = image.getProfile();
                        version         = image.getVersion();
                        baseName        = image.getName();
+                       skinShape = image.getSkinShape();
 
                        if (image instanceof CustomBaseImage) {
                                isStandard      = false;
@@ -359,14 +362,14 @@ public class VMPropertyValue implements Cloneable {
                        skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath();
                }
 
-//             if (skinPath != null) {
-//                     try {
-//                             skin = new Skin(new File(skinPath));
-//                     } catch (IOException e) {
-//                             skin = null;
-//                             EMLogger.getLogger().warning("Failed to create skin." + e.getMessage());
-//                     }
-//             }
+               if (skinPath != null) {
+                       try {
+                               skin = new Skin(new File(skinPath));
+                       } catch (IOException e) {
+                               skin = null;
+                               EMLogger.getLogger().warning("Failed to create skin." + e.getMessage());
+                       }
+               }
 
                keyType = 1; // TODO
                if (skin != null) {