import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.FileDialog;
import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
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.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.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 ComboViewItem {
- Button addButton;
protected static int BUTTON_WIDTH = 38;
protected static int BUTTON_HEIGHT = 20;
protected static int COMBOBOX_WIDTH_MODIFY = 133;
+ protected Button addButton;
protected FileDialog fd;
protected List<String> filters = new ArrayList<String>();
- private BaseImageItem currentBaseImageItem = new BaseImageItem();
-
+ // For base image combo
private boolean isSelected;
-
- private List<BaseImageItem> baseImageItemList = new ArrayList<BaseImageItem>();
-
+ private BaseImage currentBaseImage = null;
+ private List<BaseImage> baseImageList = new ArrayList<BaseImage>();
// Remember custom image list while emulator manager life-cycle.
- private static List<BaseImageItem> customImageItemList = new ArrayList<BaseImageItem>();
+ //private static List<BaseImage> customBaseImageList = new ArrayList<BaseImage>();
// For disable state.
protected ImageLabel filePathLabel;
private Image IMAGE_INPUTBOX_IMAGE = null;
protected int DIR_INPUTBOX_ON_WIDTH = 133;
-
- // For itemlist change
+ // For item list change
private VMPropertyValue value;
- // For custom image add.
- private String profile;
-
public BaseImageViewItem(Item template,
LineLabelViewItem lineLabelViewItem) {
super(template, lineLabelViewItem);
@Override
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();
+ value.baseImage = currentBaseImage;
+ value.baseImagePath = currentBaseImage.getPath();
}
@Override
public boolean settingDetailItem(VMPropertyValue value) {
if (valueLabel != null) {
- valueLabel.setText(value.baseName);
- if (!value.isStandard) {
- valueLabel.setToolTipText(value.baseImagePath);
+ valueLabel.setText(value.baseImage.getName());
+ if (!value.baseImage.isStandard()) {
+ valueLabel.setToolTipText(value.baseImage.getPath());
}
}
return true;
@Override
public void drawModify() {
-
// Disable label
if (IMAGE_INPUTBOX_IMAGE == null) {
IMAGE_INPUTBOX_IMAGE = PatchImageResources.getInputBoxON(DIR_INPUTBOX_ON_WIDTH);
data.height = BUTTON_HEIGHT;
addButton.setLayoutData(data);
-
- // make combobox list
+ // make combo box list
addWidgetListener();
}
combo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
-// newValue = combo.getText();
-
// Select image.
int index = combo.getSelectionIndex();
- changePropertyView(baseImageItemList.get(index));
+ changePropertyView(baseImageList.get(index));
if(isCreateMode()) {
getListener().changeCreateConfirmButton();
}
return;
}
String newPath = path;
- String newPathName = path.substring(
- path.lastIndexOf(File.separator) + 1, path.length());
-
- BaseImageItem newItem = new BaseImageItem(newPathName,
- newPathName, newPath, profile, "", false, SKIN_SHAPE.NONE);
- addToBaseImageItemList(newItem);
- storeCustomImage(newItem);
- resetComboList();
- changePropertyView(newItem);
-
- isSelected = true;
- getListener().changeCreateConfirmButton();
+ BaseImage newItem;
+ newItem = new BaseImage(ProfileList.getProfile(currentBaseImage.getProfile()).getPlatformByLatestVersion(), newPath);
+ if (storeCustomImage(newItem)) {
+ baseImageList.add(newItem);
+ resetComboList();
+ changePropertyView(newItem);
+ isSelected = true;
+ getListener().changeCreateConfirmButton();
+ } else {
+ EMLogger.getLogger().warning("Failed to store 'Custom Base Image'");
+ new MessageDialog()
+ .openWarningDialog("Failed to store 'Custom Base Image'");
+ return;
+ }
}
}
@Override
public boolean settingModifyItem(VMPropertyValue value) {
this.value = value;
- this.profile = value.profile;
- currentBaseImageItem.setValue(value);
- if (!value.isStandard) {
- storeCustomImage(currentBaseImageItem);
- }
+ currentBaseImage = value.baseImage;
isSelected = false;
filePathLabel.setVisible(false);
combo.setVisible(true);
addButton.setEnabled(true);
- loadBaseImageItemList(value.profile);
- loadCustomImageItemList(value.profile);
+ loadBaseImageList(value.baseImage.getProfile());
+ //loadCustomBaseImageList(value.baseImage.getProfile());
resetComboList();
-
} else {
combo.removeAll();
- combo.add(value.baseName);
+ combo.add(value.baseImage.getName());
combo.select(0);
- combo.setText(value.baseName);
+ combo.setText(value.baseImage.getName());
combo.setEnabled(false);
addButton.setEnabled(false);
isSelected = true;
combo.setVisible(false);
- filePathLabel.setText(value.baseName);
- filePathLabel.setToolTipText(currentBaseImageItem.getFileName());
+ filePathLabel.setText(value.baseImage.getName());
+ filePathLabel.setToolTipText(currentBaseImage.getPath());
filePathLabel.setVisible(true);
filePathLabel.setEnabled(false);
filePathLabel.redraw();
return false;
}
- public static String getLatestVersion(String profileName) {
- Profile profile = ProfileList.getProfile(profileName);
- if (profile != null) {
- return profile.getLatestPlatformVersion();
- }
- return "";
- }
-
- private void changePropertyView(BaseImageItem item) {
- currentBaseImageItem = item;
+ private void changePropertyView(BaseImage item) {
+ currentBaseImage = item;
+ value.baseImage = item;
+ value.baseImagePath = item.getPath();
setValue(value);
getListener().changePropertyView(value, isCreateMode());
}
- private void loadBaseImageItemList(String profileName) {
- baseImageItemList.clear();
+ private void loadBaseImageList(String profileName) {
+ baseImageList.clear();
Profile profile = ProfileList.getProfile(profileName);
if (profile != null) {
for (BaseImage img : profile.getImageList()) {
- addToBaseImageItemList(new BaseImageItem(img.getName(), img
- .getPathName(), img.getPath(), img.getProfile(), img.getVersion(),
- true, img.getSkinShape()));
- }
- }
- }
-
- private void loadCustomImageItemList(String profile) {
- for (BaseImageItem customImageItem : customImageItemList) {
- if (customImageItem.getProfile().equals(profile)) {
- addToBaseImageItemList(new BaseImageItem(customImageItem));
+ if (img.getPlatform().getPlugin() != null
+ && img.getItemList() != null) {
+ baseImageList.add(img);
+ }
}
}
}
-
- private void addToBaseImageItemList(BaseImageItem baseImageItem) {
- // Check duplicated custom image.
- int index = -1;
- for (int i = 0; i < baseImageItemList.size(); i++) {
- BaseImageItem item = baseImageItemList.get(i);
- if (item.equals(baseImageItem)) {
- index = i;
- break;
- }
- }
-
- if (index == -1) {
- // Add to image list
- if (checkBaseImageFile(baseImageItem.getFilePath())) {
- baseImageItemList.add(baseImageItem);
+/*
+ private void loadCustomBaseImageList(String profile) {
+ for (BaseImage custom : customBaseImageList) {
+ if (custom.getProfile().equals(profile)) {
+ baseImageList.add(custom);
}
}
}
-
- private void storeCustomImage(BaseImageItem customImageItem) {
+*/
+ private boolean storeCustomImage(BaseImage customImageItem) {
int index = -1;
- for (int i = 0; i < customImageItemList.size(); i++) {
- BaseImageItem item = customImageItemList.get(i);
+ for (int i = 0; i < customImageItem.getPlatform().getProfileClass().getImageList().size(); i++) {
+ BaseImage item = customImageItem.getPlatform().getProfileClass().getImageList().get(i);
if (item.equals(customImageItem)) {
index = i;
break;
}
if (index == -1) {
- if (checkBaseImageFile(customImageItem.getFilePath())) {
- customImageItemList.add(new BaseImageItem(customImageItem));
+ if (checkBaseImageFile(customImageItem.getPath())) {
+ customImageItem.getPlatform().getProfileClass().addBaseImage(customImageItem);
+ } else {
+ return false;
}
}
+ return true;
}
private void resetComboList() {
}
// make combo box list
- for (BaseImageItem item : baseImageItemList) {
- combo.add(item.getImageName());
+ for (BaseImage item : baseImageList) {
+ combo.add(item.getName());
}
// Select combo-box item.
int index = -1;
- for (int i = 0; i < baseImageItemList.size(); i++) {
- if (baseImageItemList.get(i).equals(currentBaseImageItem)) {
+ for (int i = 0; i < baseImageList.size(); i++) {
+ if (baseImageList.get(i).getPath().equals(currentBaseImage.getPath())) {
index = i;
break;
}
}
- if (baseImageItemList.size() > 0) {
+ if (baseImageList.size() > 0) {
if (index == -1) { // if value not matches..
index = 0;
}
combo.select(index);
- currentBaseImageItem = baseImageItemList.get(index);
+ currentBaseImage = baseImageList.get(index);
isSelected = true;
}
combo.setEnabled(true);
itemState.setNormal();
if (isSelected) {
- File f = new File(currentBaseImageItem.getFilePath());
+ File f = new File(currentBaseImage.getPath());
if (!f.exists()) {
itemState.setError("Base image file is not exist.");
}
+ Platform platform = currentBaseImage.getPlatform();
+ if (platform != null && platform.getPlugin() == null) {
+ itemState.setError("Failed to load plugin");
+ }
} else {
itemState.setError("Please select base image file.");
}
return true;
}
-}
-
-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 setValue(VMPropertyValue value) {
- setFileName(value.baseImagePathName);
- setFilePath(value.baseImagePath);
- setStandard(value.isStandard);
- setImageName(value.baseName);
- setProfile(value.profile);
- setSkinShape(value.skinShape);
- setVersion(value.version);
- }
-
- 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;
- }
-
-}
+}
\ No newline at end of file
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.platform.BaseImage;
-import org.tizen.emulator.manager.platform.PlatformStringResources;
import org.tizen.emulator.manager.platform.Skin;
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.tool.CheckVirtualization;
public class VMPropertyValue implements Cloneable {
public BaseImage baseImage;
public VMProperty template;
- public String vmsName;
+ public String vmsName = "";
- public String archType;
- public String profile;
- public String version; // BaseImage version(=platform)
- public String baseName; // BaseImage name
- public boolean isStandard;
public String baseImagePath;
- public String baseImagePathName;
- public SKIN_SHAPE skinShape = SKIN_SHAPE.SQUARE;
- public RESOLUTION resolution;
- public int dpi;
+ public RESOLUTION resolution = RESOLUTION.HD;
+ public int dpi = RESOLUTION.HD.getDPI();
public int keyType;
public Skin skin;
- public String skinPath;
+ public String skinPath = "";
- public int ramSize;
- public int cpu;
+ public int ramSize = 512;
+ public int cpu = 1;
public boolean isFileShareSupport;
- public String fileSharePath;
- public String fileSharePathName;
+ public String fileSharePath = "";
+ public String fileSharePathName = "";
public boolean isHWVirtualization;
public boolean isGLAcceleration;
- public static int maxTouch = 10;
- public int maxTouchCount;
+ public static int MAX_TOUCH = 10;
+ public int maxTouchCount = MAX_TOUCH;
public OCI ociDevice;
public String addOptions;
this.baseImage = image;
this.template = template;
- vmsName = "";
-
- baseImagePath = image.getPath();
- baseImagePathName = image.getPathName();
- archType = image.getCpu();
- profile = image.getProfile();
- version = image.getVersion();
- baseName = image.getName();
- skinShape = image.getSkinShape();
-
- isStandard = image.isStandard();
+ baseImagePath = image.getPath();
settingConfigure(template);
}
this.template = property;
vmsName = property.getName();
- archType = property.getArch().toString();
-
- if (property.getImageProfile() != null) {
- profile = property.getImageProfile();
- } else {
- profile = PlatformStringResources.MOBILE_PROFILE;
- }
-
- version = property.getConfiguration().getBaseInformation().getDiskImage().getVersion();
- baseName = property.getConfiguration().getBaseInformation().getDiskImage().getBase();
- isStandard = property.getConfiguration().getBaseInformation().getDiskImage().getType()
- .equals("standard") ? true : false;
baseImagePath = property.getConfiguration().getBaseInformation().getDiskImage()
.getBaseDiskImage().getValue();
- baseImagePathName = baseImagePath.substring
- (baseImagePath.lastIndexOf(File.separator) + 1, baseImagePath.length());
+
settingConfigure(property);
} else {
dest.template = this.template;
dest.vmsName = this.vmsName;
- dest.archType = this.archType;
- dest.profile = this.profile;
- dest.version = this.version;
- dest.baseName = this.baseName;
- dest.isStandard = this.isStandard;
dest.baseImagePath = this.baseImagePath;
- dest.baseImagePathName = this.baseImagePathName;
dest.resolution = this.resolution;
dest.dpi = this.dpi;
return false;
}
- if (this.baseName != null) {
- if (dest.baseName == null
- || (dest.baseName != null && !this.baseName.equals(dest.baseName))) {
+ if (this.baseImage != null) {
+ if (dest.baseImage == null
+ || (dest.baseImage != null
+ && this.baseImage.getName().equals(dest.baseImage.getName()))) {
return false;
}
} else {
- if (dest.baseName != null) {
+ if (dest.baseImage.getName() != null) {
return false;
}
}