private String profile = "";
private String platformName = "";
private Platform platform = null;
- // default value is i386
- private Architecture cpu = Architecture.i386;
+ // default value is x86
+ private Architecture cpu = Architecture.default32Bit;
private String filePath = "";
private String description = "";
private boolean isAmendable = false;
// init body
super.create(new PropertyValue(imageValue), itemList, dialogMode);
}
-
}
isAllItemCreated = true;
+ // for check initial value
+ checkValid();
+
// sort composite
// sortItem(propertyValue.getProfile());
return false;
}
+ public boolean isDetailMode() {
+ if (dialogMode == DIALOG_MODE.DETAIL) {
+ return true;
+ }
+ return false;
+ }
public DIALOG_MODE getDialogMode() {
return dialogMode;
}
private void createDialogBody() {
-
itemListComp.create();
}
import org.tizen.emulator.manager.ui.renewal.dialog.BaseImageCreateDialog;
import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
import org.tizen.emulator.manager.ui.renewal.item.modify.baseimage.BaseImageFileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.baseimage.BaseImageNameItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.baseimage.DescriptionItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.baseimage.PlatformItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
-import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
public class BaseImageDialogHandler {
CustomBaseImageValue value = new CustomBaseImageValue(image);
if (value.isAmendable()) {
- value = openDialog("Modify Base Image", DIALOG_MODE.CLONE, value);
- } else {
value = openDialog("Modify Base Image", DIALOG_MODE.MODIFY, value);
+ } else {
+ // can not modify base image information except description
+ value = openDialog("Modify Base Image", DIALOG_MODE.DETAIL, value);
}
return value;
public static List<ModifyDialogItem> getDefaultItemList() {
List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
- itemList.add(new NameItem("name", "Image Name"));
+ itemList.add(new BaseImageNameItem());
itemList.add(new ProfileItem());
itemList.add(new PlatformItem());
itemList.add(new BaseImageFileItem());
setTextBox(imageFilePath);
}
// you can not modify if emulator using base image exist.
- if (getItemListComp().isModifyMode()) {
+ if (getItemListComp().isDetailMode()) {
fileDialogButton.setEnabled(false);
}
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.item.modify.baseimage;
+
+import java.io.File;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.TextInputBoxItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+
+public class BaseImageNameItem extends TextInputBoxItem {
+ private final int INPUT_BOX_WIDTH = 236;
+ private String imageName = "";
+
+ public BaseImageNameItem() {
+ super("name", "Image Name");
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
+ return;
+ }
+
+ if (getItemListComp().isCreateMode()) {
+ this.value = value.getDefaultName();
+
+ } else if (getItemListComp().isCloneMode()){
+ this.value = value.getCloneName();
+
+ } else {
+ this.value = value.getName();
+ }
+
+ imageName = this.value;
+ }
+
+ @Override
+ public void create(Composite parent) {
+ // modify dialog item: setItemListComp() -> setInitialValue() -> create() -> setVisible()
+ create(parent, ImageResources.ICON_TITLE_VMNAME, INPUT_BOX_WIDTH, true);
+ // call 'makeBody' function
+ }
+
+ @Override
+ protected void makeBody(int textBoxWidth, boolean needClearButton) {
+ item.setBodyLayoutForm();
+
+ if (getItemListComp().isDetailMode()) {
+ createTextLabel();
+ } else {
+ createTextBox(textBoxWidth, needClearButton);
+ }
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setName(this.value);
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ return new NameItem(getName(), getTitle());
+ }
+
+ @Override
+ public void textModified() {
+ // check validation
+ // check confirm button enable/disable
+ getItemListComp().checkValid();
+ }
+
+ @Override
+ public boolean isValid() {
+ // item list composite's checkValid() -> item's isValid()
+ boolean isValid = true;
+
+ if (getItemListComp().isDetailMode()) {
+ return true;
+ }
+
+
+ if (!getItemListComp().isCreateMode()) {
+ if (!value.isEmpty() && value.equals(imageName)) {
+ return true;
+ }
+ }
+
+ String msg = "";
+ // create(clone), modify mode
+ msg = checkBaseImageName(value);
+
+ if (!msg.isEmpty()) {
+ isValid = false;
+ }
+
+ // changeItemState() -> changeWidgetState()
+ changeItemState(!isValid, INPUT_BOX_WIDTH, msg);
+
+ return isValid;
+ }
+
+ public static String checkBaseImageName(String newName) {
+ String errorMsg = "";
+
+ if (newName.length() > 30) {
+ errorMsg = "Max length of name is 30";
+ } else if (newName.isEmpty()) {
+ errorMsg = "Please, input base image name";
+ } else {
+ BaseImage image = HelperClass.checkDuplicateBaseImageName(newName);
+ if (image != null) {
+ errorMsg = "Same name already exist!"
+ + StringResources.NEW_LINE
+ + newName + " ( " + image.getPlatformName() + " )"
+ + StringResources.NEW_LINE
+ + "Path: " + image.getPath();
+ }
+ }
+ return errorMsg;
+ }
+
+ @Override
+ public void changeItemValue(PropertyValue property) {
+ // item list comp's changeItemListForBaseImageDialog() -> chnageItemValue()
+ if (property.isBaseImageValue()) {
+ if (value != null && !value.isEmpty()) {
+ return;
+ }
+
+ String path = property.getImageFilePath();
+ if (path != null && !path.isEmpty()) {
+ String fileName = path.substring(path
+ .lastIndexOf(File.separator) + 1, path.length());
+ if (fileName.contains(".")) {
+ fileName = fileName.substring(0, fileName.lastIndexOf("."));
+ }
+ value = fileName;
+ textInputBox.setText(value);
+ }
+ }
+ }
+}
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.TextInputBoxItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
}
@Override
+ public void setInitialValue(PropertyValue value) {
+ if (value == null) {
+ return;
+ }
+
+ this.value = value.getDescritpion();
+ }
+
+ @Override
public void create(Composite parent) {
create(parent, TITILE_ICON, INPUT_BOX_WIDTH, true);
// call make body
item.setItemHeight(ITEM_HEIGHT);
item.setBodyLayoutForm();
- if (getItemListComp().getDialogMode() == DIALOG_MODE.DETAIL) {
- // TODO
- } else {
- createTextBox();
- }
+ createTextBox();
}
// for create mode
}
@Override
- public void setInitialValue(PropertyValue value) {
- if (value == null) {
- return;
- }
-
- this.value = value.getDescritpion();
- }
-
- @Override
public void setValue(PropertyValue value) {
value.setDescription(this.value);
}
}
@Override
+ public void setInitialValue(PropertyValue value) {
+ selectedPlatform = value.getPlatform();
+ arch = value.getArchitecture();
+
+ profile = ProfileList.getProfile(value.getProfile());
+ }
+
+ @Override
public void create(Composite parent) {
item.init(parent);
item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_VERSION));
item.create();
- createCombo(item, COMBO_WIDTH);
-
button32 = new ImageButton(item.getBody(), SWT.RADIO);
button64 = new ImageButton(item.getBody(), SWT.RADIO);
- settingRadioButton();
- profile = ProfileList.getProfile(getItemListComp().getPropertyValue().getProfile());
+ createCombo(item, COMBO_WIDTH);
+
+ settingRadioButton();
initPlatformCombo();
}
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setPlatform(selectedPlatform);
+ value.setArchitecture(arch);
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ return new PlatformItem();
+ }
+
private void settingRadioButton() {
button32.setText("32 bit");
button32.setFontColor(ColorResources.CONTENT_FONT.getColor());
data.top = new FormAttachment(0, top);
button64.setLayoutData(data);
- // set listener
- button32.addListener(SWT.Selection, radioButtonListener);
- button64.addListener(SWT.Selection, radioButtonListener);
+ if (getItemListComp().isDetailMode()) {
+ button32.setEnabled(false, button32.isSelection());
+ button64.setEnabled(false, button64.isSelection());
+ } else {
+ // set listener
+ button32.addListener(SWT.Selection, radioButtonListener);
+ button64.addListener(SWT.Selection, radioButtonListener);
+ }
}
private Listener radioButtonListener = new Listener() {
return;
}
if (button32.isSelection()) {
- Architecture arch = selectedPlatform.findArchitecture(32);
+ arch = selectedPlatform.findArchitecture(32);
arch = arch != null ? arch : Architecture.i386;
}
if (button64.isSelection()) {
arch = Architecture.x86_64;
}
}
-
};
private void initPlatformCombo() {
this.comboBox.clear();
- if (getItemListComp().isModifyMode()) {
- addComboItem(selectedPlatform.getName());
+ if (getItemListComp().isDetailMode()) {
+ addComboItem(selectedPlatform.getName(), selectedPlatform);
comboBox.select(0);
comboBox.setEnabled(false);
} else {
}
if (!comboBox.getItemList().isEmpty()) {
- if (selectedPlatform != null) {
+ if (selectedPlatform != null && selectedPlatform.getProfile().equals(profile.getName())) {
for (int i = 0; i < comboBox.getItemList().size(); i++) {
if (selectedPlatform.getName().equals(comboBox.getItemList().get(i))) {
+ // call item selected
selectComboItem(i);
break;
}
}
} else {
selectComboItem(0);
- comboSelected();
}
}
}
}
- private void comboSelected() {
+ @Override
+ public void itemSelected(ComboBox comboBox) {
selectedPlatform = (Platform)getSelectedData();
- button32.setEnabled(false);
- button64.setEnabled(false);
+
+ button32.setEnabled(false, false);
+ button64.setEnabled(false, false);
+
for (Architecture arch : selectedPlatform.getArchitectureList()) {
if (arch == Architecture.i386
|| arch == Architecture.x86) {
}
}
- button64.setSelection(false);
- button32.setSelection(true);
+ // if platform does not support 64bit kernel, change architecture to 32bit from 64bit
+ if (arch.getBit() == 64 && !button64.isEnabled()) {
+ arch = Architecture.default32Bit;
+ }
+
+ button32.setSelection(arch.getBit() == 32);
+ button64.setSelection(arch.getBit() == 64);
// TODO
getItemListComp().checkValid();
}
@Override
- public void setInitialValue(PropertyValue value) {
- selectedPlatform = value.getPlatform();
- arch = value.getArchitecture();
- }
-
- @Override
- public void itemSelected(ComboBox comboBox) {
- // This is called when combo item is selected
- comboSelected();
- }
-
- @Override
- public void setValue(PropertyValue value) {
- value.setPlatform(selectedPlatform);
- value.setArchitecture(arch);
- }
-
- @Override
- public ModifyDialogItem cloneItem() {
- return new PlatformItem();
- }
-
- @Override
public void changeItemValue(PropertyValue value) {
+ // changeItemLsitForBaseImageDialog call changeItemValue
+
+ // change profile
if (profile == null || !profile.getName().equals(value.getProfile())) {
profile = ProfileList.getProfile(value.getProfile());
initPlatformCombo();
}
+ // change image path
if (imagePath == null || !imagePath.equals(value.getImageFilePath())) {
imagePath = value.getImageFilePath();
Architecture a = Architecture.findCpuTypeFromPath(imagePath);
if (a != null) {
- arch = selectedPlatform.findArchitecture(a.getBit());
+ Architecture temp = selectedPlatform.findArchitecture(a.getBit());
+ if (temp == null) {
+ // support x86 -> select x86_64
+ return;
+ }
+ arch = temp;
button32.setSelection(false);
button64.setSelection(false);
- if (arch.getBit() == 64) {
- button64.setSelection(true);
- } else {
+ if (arch.getBit() == 32) {
button32.setSelection(true);
+ } else {
+ button64.setSelection(true);
}
}
}
package org.tizen.emulator.manager.ui.renewal.item.modify.common;
-import java.io.File;
-
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.platform.BaseImage;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.Messages;
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_VMNAME;
private final int INPUT_BOX_WIDTH = 236;
- private String name;
-
public NameItem(String name, String title) {
super(name, title);
} else {
this.value = value.getName();
}
- name = this.value;
}
@Override
msg = checkTemplateName(value);
} else if (property.isVMValue()) {
msg = checkVMName(value);
- } else if (property.isBaseImageValue()) {
- if (getItemListComp().isCloneMode() && !value.isEmpty()) {
- if (!value.equals(name)) {
- msg = checkBaseImageName(value);
- }
- } else {
- msg = checkBaseImageName(value);
- }
} else {
// TODO
}
return errorMsg;
}
-
- public static String checkBaseImageName(String newName) {
- String errorMsg = "";
-
- if (newName.length() > 30) {
- errorMsg = "Max length of name is 30";
- } else if (newName.isEmpty()) {
- errorMsg = "Please, input base image name";
- } else {
- BaseImage image = HelperClass.checkDuplicateBaseImageName(newName);
- if (image != null) {
- errorMsg = "Same name already exist!"
- + StringResources.NEW_LINE
- + newName + " ( " + image.getPlatformName() + " )"
- + StringResources.NEW_LINE
- + "Path: " + image.getPath();
- }
- }
- return errorMsg;
- }
-
- @Override
- public void changeItemValue(PropertyValue property) {
- if (property.isBaseImageValue()) {
- if (value != null && !value.isEmpty()) {
- return;
- }
-
- String path = property.getImageFilePath();
- if (path != null && !path.isEmpty()) {
- String fileName = path.substring(path
- .lastIndexOf(File.separator) + 1, path.length());
- if (fileName.contains(".")) {
- fileName = fileName.substring(0, fileName.lastIndexOf("."));
- }
- value = fileName;
- textInputBox.setText(value);
- textModified();
- }
- }
- }
}
@Override
public void handleEvent(Event e) {
if (e.type == SWT.Selection) {
- if (!currentProfile.equals(profile)) {
+ if (currentProfile.equals(profile)) {
+ return;
+ }
+
+ PropertyValue value = getItemListComp().getPropertyValue();
+ if (value.isBaseImageValue()) {
+ value.setProfile(profile);
+ getItemListComp().changeItemListForBaseImageDialog();
+ } else if (value.isTemplateValue()) {
getItemListComp().changeItemListByProfile(profile);
}
}
return new ProfileItem();
}
+ @Override
+ public void changeItemValue(PropertyValue value) {
+ currentProfile = value.getProfile();
+ }
}
protected void makeBody(int textBoxWidth, boolean needClearButton) {
item.setBodyLayoutForm();
- if (getItemListComp().getDialogMode() == DIALOG_MODE.MODIFY
- || getItemListComp().getDialogMode() == DIALOG_MODE.DETAIL) {
+ if (getItemListComp().isModifyMode() || getItemListComp().isDetailMode()) {
createTextLabel();
} else {
createTextBox(textBoxWidth, needClearButton);
}
// for create mode
- private void createTextBox(int textBoxWidth, boolean needClearButton) {
+ protected void createTextBox(int textBoxWidth, boolean needClearButton) {
FormData data = new FormData(textBoxWidth, ModifyItem.WIDGET_HEIGHT);
data.top = new FormAttachment(0, (item.getHeight() - ModifyItem.WIDGET_HEIGHT) / 2);
data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT);
}
- private void createTextLabel() {
+ protected void createTextLabel() {
// init canvas;
Canvas detailCanvas = new Canvas(item.getBody(), SWT.NONE);
}
}
-
public boolean getCPUVirtualization() {
if (isVMValue()) {
return vmValue.isHWVirtualization;
ImageResources.RADIO_BUTTON_ON.getImage(),
ImageResources.RADIO_BUTTON_ON.getImage(),
ImageResources.RADIO_BUTTON_ON.getImage(),
+ ImageResources.RADIO_BUTTON_ON.getImage(),
ImageResources.RADIO_BUTTON_OFF.getImage());
}
}
private String name;
private int bit;
+ // for support old version (under 3.0)
+ public static final Architecture default32Bit = Architecture.x86;
Architecture(String arch, int bit) {
this.name = arch;
}
}
}
- return i386;
+ return null;
}
public static Architecture getType(String arch) {
return type;
}
}
- return i386;
+ return null;
}
};