import org.tizen.emulator.manager.ui.renewal.MainDialog;
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.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;
itemList.add(new NameItem("name", "Image Name"));
itemList.add(new ProfileItem());
- //itemList.add(new PlatformItem());
- //itemList.add(new BaseImageFileItem());
+ itemList.add(new PlatformItem());
+ itemList.add(new BaseImageFileItem());
//itemList.add(new DescriptionItem());
return itemList;
}
--- /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 org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
+import org.tizen.emulator.manager.ui.renewal.dialog.MessageBox;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.vms.VMProperty.Architecture;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+
+public class BaseImageFileItem extends FileDialogItem {
+ private static final String NAME="imagefile";
+ private static final String TITLE="Image File";
+ private final int TEXT_BOX_WIDTH = 233;
+
+ private String imageFilePath;
+ // TODO
+ //private File imageFile;
+
+ private FileDialog fd;
+
+ public BaseImageFileItem() {
+ super(NAME, TITLE);
+ }
+ @Override
+ public void create(Composite parent) {
+ create(parent, getTitle(), ImageResources.ICON_TITLE_IMAGE_FILE, TEXT_BOX_WIDTH);
+ if (imageFilePath == null || imageFilePath.isEmpty()) {
+ setTextBox("(select base imaeg path...)");
+ } else {
+ setTextBox(imageFilePath);
+ }
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ imageFilePath = value.getImageFilePath();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setImageFilePath(imageFilePath);
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ return new BaseImageFileItem();
+ }
+
+ @Override
+ protected String clickFileDialogButon() {
+ if (fd == null) {
+ fd = new FileDialog(MainDialog.getShell(), SWT.OPEN);
+ fd.setText("Select Base Image");
+ String[] filter = null;
+ String[] filterName = null;
+ filter = new String[] { // "*.x86;*.i386;*.x86_64"
+ "*." + Architecture.x86.toString()
+ + ";*." + Architecture.i386.toString()
+ + ";*." + Architecture.x86_64.toString()
+ };
+ fd.setFilterExtensions(filter);
+ filterName = new String[] {
+ "Disk Image Files ("
+ + "*." + Architecture.x86.toString()
+ + ", *." + Architecture.i386.toString()
+ + ", *." + Architecture.x86_64.toString()
+ + ")"
+ };
+ fd.setFilterNames(filterName);
+ }
+
+ String path = fd.open();
+ if (path != null) {
+ if (!HelperClass.isPathAvaliable(path)) {
+ MessageBox
+ .openMessageBox("This base image not ready yet."
+ + StringResources.NEW_LINE
+ + "Please, select again in a few seconds.");
+ return null;
+ }
+ // TODO: need to check file format
+ return path;
+ }
+ return null;
+ }
+
+ @Override
+ public void fileSelected() {
+ imageFilePath = filePath;
+ getDialog().getPropertyValue().setImageFilePath(imageFilePath);
+ getDialog().changeItemList("");
+ }
+}
--- /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 org.eclipse.swt.widgets.Composite;
+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.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+public class PlatformItem extends ComboItem {
+ private static final String TITLE = "Platform";
+ private static final String NAME = "platform";
+ private final int COMBO_WIDTH = 200;
+
+ private Platform selectedPlatform;
+ private Profile profile;
+
+ public PlatformItem() {
+ super(NAME, TITLE);
+ item = new ModifyItem();
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item.init(parent);
+ item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_VERSION));
+ item.create();
+
+ createCombo(item, COMBO_WIDTH);
+ initPlatformCombo();
+ }
+
+ private void initPlatformCombo() {
+ if (profile == null) {
+ return;
+ }
+
+ if (comboBox == null) {
+ return;
+ }
+
+ this.comboBox.clear();
+
+ for (Platform platform : profile.getPlatformList()) {
+ addComboItem(platform.getName(), platform);
+ }
+
+ if (!comboBox.getItemList().isEmpty()) {
+ selectComboItem(0);
+ comboSelected();
+ }
+ }
+
+ private void comboSelected() {
+ selectedPlatform = (Platform)getSelectedData();
+ // TODO
+ getDialog().checkValid();
+ }
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ // TODO
+ }
+
+ @Override
+ public void itemSelected(ComboBox comboBox) {
+ // This is called when combo item is selected
+ comboSelected();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ value.setPlatform(selectedPlatform);
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ return new PlatformItem();
+ }
+
+ @Override
+ public void changeItemValue(PropertyValue value) {
+ if (profile != null && profile.getName().equals(value.getProfile())) {
+ return;
+ }
+
+ profile = ProfileList.getProfile(value.getProfile());
+ initPlatformCombo();
+ }
+}
@Override
public void handleEvent(Event event) {
if (event.type == SWT.Selection) {
- if (dd == null) {
- dd = new DirectoryDialog(
- getDialog().getShell(), SWT.OPEN);
- dd.setText("Select directory");
- }
- String path = dd.open();
+ String path = clickFileDialogButon();
if (path != null) {
filePath = path;
setTextBox(filePath);
});
}
+ protected String clickFileDialogButon() {
+ if (dd == null) {
+ dd = new DirectoryDialog(
+ getDialog().getShell(), SWT.OPEN);
+ dd.setText("Select directory");
+ }
+
+ return dd.open();
+ }
+
public abstract void fileSelected();
}
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.renewal.resources.ImageResources;
}
String msg = "";
- if (getDialog().getPropertyValue().isTemplateValue()) {
+ PropertyValue property = getDialog().getPropertyValue();
+ if (property.isTemplateValue()) {
msg = checkTemplateName(value);
-
- } else {
+ } else if (property.isVMValue()) {
msg = checkVMName(value);
+ } else if (property.isBaseImageValue()) {
+ msg = checkBaseImageName(value);
+ } else {
+ // TODO
}
if (!msg.isEmpty()) {
return errorMsg;
}
+ public static String checkBaseImageName(String newName) {
+ // TODO
+ return "";
+ }
+
+ @Override
+ public void changeItemValue(PropertyValue property) {
+ if (!property.isBaseImageValue()) {
+ return;
+ }
+ 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();
+ }
+ }
}
public void handleEvent(Event e) {
if (e.type == SWT.Selection) {
if (!currentProfile.equals(profile)) {
-// System.out.println("profile changed : " + profile);
- currentProfile = profile;
- getDialog().changeItemList(profile);
+ changedProfile(profile);
}
}
}
private void selectButton() {
// TODO default
- buttonMap.get(MOBILE).selectRadio();
+ //buttonMap.get(MOBILE).selectRadio();
if (currentProfile.isEmpty()) {
currentProfile = MOBILE;
}
for (String profile : buttonMap.keySet()) {
if (profile.equals(currentProfile)) {
buttonMap.get(profile).selectRadio();
+ changedProfile(profile);
}
}
}
+ private void changedProfile(String profile) {
+ currentProfile = profile;
+ getDialog().getPropertyValue().setProfile(profile);
+ getDialog().changeItemList(profile);
+ }
+
@Override
public void setValue(PropertyValue value) {
value.setProfile(currentProfile);