*/
package org.tizen.emulator.manager;
+
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+//import org.tizen.emulator.manager.console.Action;
+//import org.tizen.emulator.manager.console.CommandLineParser;
import org.tizen.emulator.manager.console.Action;
import org.tizen.emulator.manager.console.CommandLineParser;
-import org.tizen.emulator.manager.image.Platform;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.platform.CustomPlatform;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.tool.CheckSDCard;
import org.tizen.emulator.manager.tool.CheckVirtualization;
-import org.tizen.emulator.manager.tool.FilePath;
import org.tizen.emulator.manager.tool.SelectWorkspace;
-import org.tizen.emulator.manager.tool.StringResource;
import org.tizen.emulator.manager.ui.MainDialog;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-
-
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
public class EmulatorManager {
- private static EmulatorManager instance = null;
+ //private static EmulatorManager instance = null;
- private ManagerModeType mode;
- private Display display;
- private MainDialog mainDialog;
+ private static ManagerModeType mode;
+ private static Display display;
+ private static MainDialog mainDialog;
- private ArrayList<Platform> platformList = null;
+ private static ArrayList<Platform> platformList = null;
private static CommandLineParser processor = null;
private static boolean isConsoleMode = true;
- // for multi touch
+ //
private static boolean isInhoseMode = false;
private static RandomAccessFile randomAccessFile;
- private static boolean isMac = false;
- private static boolean isWin = false;
- private static boolean isLinux = false;
+ private static boolean isMac = false;
+ private static boolean isWin = false;
+ private static boolean isLinux = false;
static {
+
if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
isLinux = true;
} else if (System.getProperty("os.name").toLowerCase().indexOf("win") > -1) {
public static boolean isLinux() {
return isLinux;
}
-
+/*
public static EmulatorManager getInstance() {
return instance;
}
-
+*/
+ /*
private EmulatorManager(ManagerModeType mode) {
this.mode = mode;
}
+ */
- public ManagerModeType getManagerMode() {
+ public static ManagerModeType getManagerMode() {
return mode;
}
- public MainDialog getMainDialog() {
+ public static MainDialog getMainDialog() {
return mainDialog;
}
- private void preare() {
- this.display = Display.getCurrent();
+ private static void preare() {
+ EmulatorManager.display = Display.getCurrent();
mainDialog = new MainDialog(mode);
}
- private void DrawUI() {
+ private static void draw() {
mainDialog.draw();
mainDialog.open();
display.dispose();
}
- private void dispose() {
+ private static void dispose() {
mainDialog.dispose();
}
return isConsoleMode;
}
- private void startConsoleProcessor() {
+ private static void startConsoleProcessor() {
Action action = processor.getAction();
if (!action.process()) {
exitEmulatorManager(-1);
}
}
+ mode = isInhoseMode ? ManagerModeType.INHOUSE_MODE
+ : ManagerModeType.PUBLIC_MODE;
+
if (!SelectWorkspace.setWorkspace(workspacePath, isSave)) {
exitEmulatorManager(-1);
}
MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
if (isArgsError == true) {
- msg.openWarningDialog("Used workspace option parameter is not proper. Aborting..."
- + StringResource.NEW_LINE + StringResource.NEW_LINE
- + "See right examples below." + StringResource.NEW_LINE
- + "[--workspace {workspace path},save=true]" + StringResource.NEW_LINE
- + "[-w {workspace path},save=true]" + StringResource.NEW_LINE
- + "[--workspace {workspace path},save=false]" + StringResource.NEW_LINE
- + "[-w {workspace path},save=false]" + StringResource.NEW_LINE + StringResource.NEW_LINE
- + "The workspace path must be absolute."
+ msg.openWarningDialog("Used workspace option parameter is not proper. Aborting...\n" +
+ "\nSee right examples below.\n" +
+ "[--workspace {workspace path},save=true]\n" +
+ "[-w {workspace path},save=true]\n" +
+ "[--workspace {workspace path},save=false]\n" +
+ "[-w {workspace path},save=false]\n" +
+ "\nThe workspace path must be absolute."
);
exitEmulatorManager(-1);
}
}
public static void main(String[] args) {
-
- if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
+ if (isMac()) {
//TODO: event handling of about menu
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Emulator Manager");
}
-
- try{
-
- checkConsoleMode(args);
+
+ try{
+
+ checkConsoleMode(args);
randomAccessFile = new RandomAccessFile(new File(FilePath.getInstance().getBinPath()
+ File.separator + "." +System.getProperty("user.name"))+ ".lock",
FileLock lock = randomAccessFile.getChannel().tryLock();
if (lock == null) {
EMLogger.getLogger().log(Level.WARNING, "Can not launch Emulator Manager."
- + StringResource.NEW_LINE
- + "Another one with the same user name is running now."
- + StringResource.NEW_LINE);
+ + StringResources.NEW_LINE
+ + "Another one with the same user name is running now."
+ + StringResources.NEW_LINE);
exitEmulatorManager(-1);
}
} catch (IOException e) {
EMLogger.getLogger().log(Level.WARNING, "Can not launch Emulator Manager."
- + StringResource.NEW_LINE +e.getMessage() + StringResource.NEW_LINE);
+ + StringResources.NEW_LINE +e.getMessage() + StringResources.NEW_LINE);
exitEmulatorManager(-1);
}
try {
FileLock lock = randomAccessFile.getChannel().tryLock();
if (lock == null) {
- msg.openInfoDialog("Can not launch Emulator Manager." + StringResource.NEW_LINE +
- "Another one with the same user name is running now.");
+ msg.openInfoDialog("Can not launch Emulator Manager." + StringResources.NEW_LINE +
+ "Another one with the same user name is running now.");
exitEmulatorManager(0);
}
} catch (IOException e) {
- msg.openInfoDialog("Can not launch Emulator Manager." + StringResource.NEW_LINE + e.getMessage());
+ msg.openInfoDialog("Can not launch Emulator Manager."
+ + StringResources.NEW_LINE + e.getMessage());
exitEmulatorManager(-1);
}
parseArgs(args);
}
-
+
+ /*
instance = new EmulatorManager(isInhoseMode ? ManagerModeType.INHOUSE_MODE
: ManagerModeType.PUBLIC_MODE);
+ */
// check hax or kvm
CheckVirtualization.getInstance().check();
CheckSDCard.CheckSDCardDir();
CheckSDCard.CheckSwapDir();
- EmulatorVMs.getInstance().loadProperties();
+ //EmulatorVMs.getInstance().loadProperties();
- instance.makePlatformList();
+ EmulatorManager.makePlatformList();
if (isConsoleMode) {
- instance.startConsoleProcessor();
+ EmulatorManager.startConsoleProcessor();
} else {
- EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!" + StringResource.NEW_LINE);
+ EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!");
- instance.preare();
- instance.DrawUI();
- instance.dispose();
+ EmulatorManager.preare();
+ EmulatorManager.draw();
+ EmulatorManager.dispose();
}
} catch (Throwable e) {
System.exit(returnValue);
}
- public ArrayList<Platform> getPlatformList() {
+ public static ArrayList<Platform> getPlatformList() {
return platformList;
}
- public void makePlatformList() {
+ private static CustomPlatform custom = new CustomPlatform();
+
+ public static CustomPlatform getCustomPlatform() {
+ return custom;
+ }
+
+ static void makePlatformList() {
platformList = new ArrayList<Platform>();
File platforms = new File(FilePath.getInstance().getPlatformsPath());
}
}
}
+ settingVMPropertyList();
+ }
+
+ public static void settingVMPropertyList() {
+ EmulatorVMList vms = EmulatorVMList.getInstance();
+ vms.refreshProperties();
+
+
+ custom.clearVMs();
+ for(Platform p : EmulatorManager.getPlatformList()) {
+ p.clearVMs();
+ }
+
+ for (VMProperty prop : (VMProperty[])vms.getProperties()) {
+ if (prop.getImageType() == FSImageType.custom) {
+ custom.addVMsProperty(prop);
+ } else {
+ for (Platform p : EmulatorManager.getPlatformList()) {
+ if (prop.getImageVersion().equals(p.getName())) {
+ for (BaseImage b : p.getImageList()) {
+ if (prop.getBaseImageName().equals(b.getName())) {
+ b.addVMsProperty(prop);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
}
public enum ManagerModeType {
import java.util.logging.Logger;
import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.image.SkinList;
-import org.tizen.emulator.manager.image.Skin;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
+import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
+import org.tizen.emulator.manager.resources.FilePath;
import org.tizen.emulator.manager.tool.SelectTemplate;
import org.tizen.emulator.manager.tool.SelectWorkspace;
import org.tizen.emulator.manager.vms.RAM_SIZE;
if (!r.getType().isEmpty()) {
resolution += (r.getType() + " | ");
} else {
- resolution += (r.getValue() + " | ");
+ resolution += (r.getStrValue() + " | ");
}
}
resolution = resolution.substring(0, resolution.length() - 3);
"DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true));
/** TODO : resolution and skin..***********************************************/
- ArrayList<Skin> skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue());
+ ArrayList<Skin> skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD);
String skinType = "";
int i = 1;
for (Skin skin : skinList) {
if (!r.getType().isEmpty()) {
resolution += (r.getType() + " | ");
} else {
- resolution += (r.getValue() + " | ");
+ resolution += (r.getStrValue() + " | ");
}
}
resolution = resolution.substring(0, resolution.length() - 3);
"DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true));
/** TODO : resolution and skin..***********************************************/
- ArrayList<Skin> skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue());
+ ArrayList<Skin> skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD);
String skinType = "";
int i = 1;
for (Skin skin : skinList) {
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.StringResource;
-
+import org.tizen.emulator.manager.resources.StringResources;
public class CommandLineParser {
private ActionList actionList = null;
private Action mAction = null;
System.out.println("Error: " + String.format(errorFormat, args));
}
- System.out.println(StringResource.NEW_LINE + "Usage:" + StringResource.NEW_LINE +" emulator-manager [global options] "
+ System.out.println(StringResources.NEW_LINE + "Usage:" + StringResources.NEW_LINE +" emulator-manager [global options] "
+ (action == null ? "action" : action.getAction())
+ " [action options]");
actionList.printGlobaloptions();
if (action == null ) {
- System.out.println(StringResource.NEW_LINE + "Valid actions: ");
+ System.out.println(StringResources.NEW_LINE + "Valid actions: ");
actionList.printActions();
} else {
actionList.printAction(action);
import java.util.ArrayList;
import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.image.Platform;
-import org.tizen.emulator.manager.image.Skin;
-import org.tizen.emulator.manager.image.SkinList;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
import org.tizen.emulator.manager.tool.CheckVirtualization;
-import org.tizen.emulator.manager.ui.detail.VMPropertyView;
import org.tizen.emulator.manager.vms.Creator;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.HelperClass;
import org.tizen.emulator.manager.vms.RAM_SIZE;
import org.tizen.emulator.manager.vms.RESOLUTION;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
+import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMPropertyValue;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
+import org.tizen.emulator.manager.vms.VMWorkerException;
public class ConsoleCreateVM {
prop.baseImagePath = checkImagePath(c.getCurrentValue());
if (prop.baseImagePath.endsWith(".x86")) {
prop.archType = "x86";
- EmulatorVMs.getInstance().CustomArch = "x86";
+ EmulatorVMList.getInstance().CustomArch = "x86";
} else if (prop.baseImagePath.endsWith(".arm")) {
prop.archType = "arm";
- EmulatorVMs.getInstance().CustomArch = "arm";
+ EmulatorVMList.getInstance().CustomArch = "arm";
} else {
throw new ConsoleException("Avaliable format of base image is .x86 or .arm.");
}
try {
Creator.create(prop);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: ");
System.out.println(e.getMessage());
return false;
} else if (c.getShortName() == "b") {
boolean check = false;
- for (Platform platform : EmulatorManager.getInstance().getPlatformList()) {
+ for (Platform platform : EmulatorManager.getPlatformList()) {
for (BaseImage image : platform.getImageList()) {
if (image.getID().equals(c.getCurrentValue())) {
check = true;
prop.version = image.getVersion();
prop.baseName = image.getName();
prop.baseImagePath = image.getPath();
- prop.baseImagePathName = image.getImagePathName();
+ prop.baseImagePathName = image.getPathName();
prop.archType = image.getCpu();
break;
}
try {
Creator.create(prop);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: It is failed to create new Virtual Machine.");
System.out.println(e.getMessage());
return false;
else if (c.getLongName() == Actions.OP_DPI) {
check = false;
int dpi = Integer.valueOf(c.getCurrentValue());
- if (dpi >= VMPropertyView.MIN_DPI && dpi <= VMPropertyView.MAX_DPI) {
+ if (dpi >= VMProperty.MIN_DPI && dpi <= VMProperty.MAX_DPI) {
prop.dpi = dpi;
check = true;
}
RESOLUTION r = checkResolution(resolutionCommand.getCurrentValue());
prop.resolution = r;
prop.dpi = r.getDPI();
- ArrayList<Skin> list = SkinList.getInstance().findSkinList(prop.resolution.getValue());
+ ArrayList<Skin> list = SkinList.getInstance().findSkinList(prop.resolution);
if (!list.isEmpty()) {
prop.skin = list.get(0);
} else {
ArrayList<Skin> list = null;
int i = 0;
i = Integer.parseInt(skinCommand.getCurrentValue());
- list = SkinList.getInstance().findSkinList(prop.resolution.getValue());
+ list = SkinList.getInstance().findSkinList(prop.resolution);
if (!list.isEmpty()) {
if (i <= 0 || i > list.size()) {
if (r.getType().equals(value)) {
return r;
}
- if (r.getValue().equals(value)) {
+ if (r.getStrValue().equals(value)) {
return r;
}
}
}
private void checkVMName(String name) throws ConsoleException {
- if (name.length() > VMPropertyView.MAX_NAME_LEN) {
+ if (name.length() > VMProperty.MAX_NAME_LEN) {
throw new ConsoleException("Max length of virtual target name is "
- + Integer.toString(VMPropertyView.MAX_NAME_LEN) + ".");
+ + Integer.toString(VMProperty.MAX_NAME_LEN) + ".");
}
- VMCreateHelper helper = new VMCreateHelper();
- if (!helper.checkString(name)) {
+ if (!HelperClass.checkString(name)) {
throw new ConsoleException("Name has invalid character.\n" +
"Valid Charater : a-z, A-Z, 0-9, 0, _");
}
- if (helper.checkDupulicateName(name)) {
+ if (HelperClass.checkDupulicateName(name)) {
throw new ConsoleException("The name (" + name + ") already exists!");
}
import java.util.ArrayList;
+import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMPropertyValue;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
+import org.tizen.emulator.manager.vms.VMWorkerException;
public class ConsoleModifyVM {
- VMsProperty prop;
+ VMProperty prop;
VMPropertyValue oldVM;
VMPropertyValue newVM;
public boolean ModifyVM(ArrayList<Command> list) {
}
try {
- prop.getWorker().modifyVM(oldVM, newVM);
- } catch (VMsWorkerException e) {
+ prop.getWorker().modifyVM(newVM);
+ } catch (VMWorkerException e) {
System.out.println("Error: It is failed to modify Virtual Machine.");
System.out.println(e.getMessage());
return false;
import java.util.logging.Level;
import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.image.Platform;
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.tool.About;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.HelperClass;
import org.tizen.emulator.manager.vms.Launcher;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
-import org.tizen.emulator.manager.vms.VMsProperty.FSImageType;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
+import org.tizen.emulator.manager.vms.VMWorkerException;
public class ConsoleProcessor {
- private EmulatorVMs vms = EmulatorVMs.getInstance();
+ private EmulatorVMList vms = EmulatorVMList.getInstance();
- public VMsProperty getProperty(String value) {
+ public VMProperty getProperty(String value) {
return vms.getProperty(value);
}
About.getInstance().getContents();
}
- public String getDetailInfoOfVM(VMsProperty prop) {
+ public String getDetailInfoOfVM(VMProperty prop) {
String str = new String();
try {
str += String.format("%s\n", prop.getName());
}
public String getDetailInfoOfVM(String value) {
- VMsProperty prop = vms.getProperty(value);
+ VMProperty prop = vms.getProperty(value);
if (prop == null) {
// error
return "Error: The name (" + value + ") dose not exist in the VM list.";
public ArrayList<String> getInfoOfVMList(boolean isDetail) {
ArrayList<String> message = new ArrayList<String>();
- VMsProperty[] properties = (VMsProperty[])vms.getProperties();
+ VMProperty[] properties = (VMProperty[])vms.getProperties();
if (properties.length == 0) {
// error
message.add("VM list is empty.");
} else {
if (!isDetail) {
- for (VMsProperty prop : properties) {
+ for (VMProperty prop : properties) {
message.add(prop.getName());
}
} else {
String temp = null;
- for (VMsProperty prop : properties) {
+ for (VMProperty prop : properties) {
//temp = getInfoOfVM(prop);
temp = getDetailInfoOfVM(prop);
if (temp != null) {
}
public int getCountOfVMList() {
- return ((VMsProperty[])vms.getProperties()).length;
+ return ((VMProperty[])vms.getProperties()).length;
}
public ArrayList<String> getInfoOfImageList(boolean isDetail) {
ArrayList<String> list = new ArrayList<String>();
list.add("Avaliable Base Image: \n");
- for (Platform platform : EmulatorManager.getInstance().getPlatformList()) {
+ for (Platform platform : EmulatorManager.getPlatformList()) {
for (BaseImage image : platform.getImageList()) {
list.add(image.toString());
}
public int getCountOfImageList() {
ArrayList<String> list = new ArrayList<String>();
- for (Platform platform : EmulatorManager.getInstance().getPlatformList()) {
+ for (Platform platform : EmulatorManager.getPlatformList()) {
for (BaseImage image : platform.getImageList()) {
list.add(image.getName());
}
}
public boolean launchEmulator(String name, String path, boolean isTest) {
- VMsProperty prop = getProperty(name);
+ VMProperty prop = getProperty(name);
if(prop == null) {
System.out.println("Error: There is no Virtual Machine named " + name);
List<String> cmd;
try {
cmd = launcher.getLaunchCommand(prop, path);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
EMLogger.getLogger().log(Level.WARNING, "Failed to launch :" + e.getMessage());
return false;
}
}
public boolean deleteVM(String name) {
- VMsProperty prop = getProperty(name);
+ VMProperty prop = getProperty(name);
if(prop == null) {
System.out.println("Error: There is no Virtual Machine named " + name);
try {
prop.getWorker().deleteVM();
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: " + e.getMessage());
return false;
}
}
public boolean resetVM(String name) {
- VMsProperty prop = getProperty(name);
+ VMProperty prop = getProperty(name);
if(prop == null) {
System.out.println("Error: There is no Virtual Machine named " + name);
try {
prop.getWorker().resetVM();
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: " + e.getMessage());
return false;
}
}
public boolean createBaseIamge(String name, String path) {
- VMsProperty prop = getProperty(name);
+ VMProperty prop = getProperty(name);
if(prop == null) {
System.out.println("Error: There is no Virtual Machine named " + name);
path = path + File.separator + "emulimg-" + name + "." + prop.getArch().toString();
}
prop.getWorker().createNewBaseImage(prop, path);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: " + e.getMessage());
return false;
}
}
public boolean cloneVM(String name, String target) {
- VMsProperty prop = getProperty(name);
+ VMProperty prop = getProperty(name);
if(prop == null) {
System.out.println("Error: There is no Virtual Machine named " + name);
return false;
}
- VMCreateHelper helper = new VMCreateHelper();
- if (helper.checkDupulicateName(target)) {
+ if (HelperClass.checkDupulicateName(target)) {
System.out.println("Error: The target name (" + target + ") already exists!");
return false;
}
try {
prop.getWorker().cloneVM(target);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
System.out.println("Error: " + e.getMessage());
return false;
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.button;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+public class DACustomButton extends Canvas {
+
+ public static final int MAX_SIZE = 100;
+
+ public static final int STATE_NORMAL = 0;
+ public static final int STATE_PUSH = 1;
+ public static final int STATE_HOVER = 2;
+ public static final int STATE_DISABLE = 3;
+
+ public static final int TYPE_IMAGE = 0;
+ public static final int TYPE_COLOR = 1;
+ public static final int TYPE_GRADATION = 2;
+
+ protected int state = STATE_NORMAL;
+ protected DACustomButtonAttribute attr;
+ protected DACustomButtonRenderer buttonRenderer = null;
+
+ public void addListeners() {
+ this.addListener(SWT.MouseEnter, buttonMouseListener);
+ this.addListener(SWT.MouseExit, buttonMouseListener);
+ this.addListener(SWT.MouseDown, buttonMouseListener);
+ this.addListener(SWT.MouseUp, buttonMouseListener);
+ }
+
+ public DACustomButton(Composite parent, int style) {
+ super(parent, style);
+
+ this.setForeground(ColorResources.WHITE.getColor());
+ this.addPaintListener(buttonPaintListener);
+ addListeners();
+ buttonRenderer = new DACustomButtonDefaultRenderer();
+ attr = new DACustomButtonAttribute();
+ setDefaultColors();
+ }
+
+ public DACustomButton(Composite parent, int style, String titleText) {
+ this(parent, style);
+ attr.setText(titleText);
+ }
+
+ public DACustomButton(Composite parent, Image normal, Image mouseDown,
+ Image hover, Image disable) {
+ this(parent, SWT.TRANSPARENT);
+ setImages(normal, mouseDown, hover, disable);
+ attr.setDrawType(TYPE_IMAGE);
+ }
+
+ public DACustomButton(Composite parent, Color normalStart, Color normalEnd,
+ Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
+ Color disableStart, Color disableEnd) {
+ this(parent, SWT.NONE);
+ attr.setColor(0, normalStart);
+ attr.setColor(1, normalEnd);
+ attr.setColor(2, pushStart);
+ attr.setColor(3, pushEnd);
+ attr.setColor(4, hoverStart);
+ attr.setColor(5, hoverEnd);
+ attr.setColor(6, disableStart);
+ attr.setColor(7, disableEnd);
+ attr.setDrawType(TYPE_GRADATION);
+ }
+
+ protected void changeButtonState(int s) {
+ if (s == STATE_DISABLE) {
+ super.setEnabled(false);
+ } else {
+ super.setEnabled(true);
+ }
+
+ state = s;
+ this.redraw();
+ }
+
+ protected Listener buttonMouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (state == STATE_DISABLE) {
+ return;
+ }
+
+ if (event.type == SWT.MouseEnter) {
+ changeButtonState(STATE_HOVER);
+ }
+
+ if (event.type == SWT.MouseExit) {
+ changeButtonState(STATE_NORMAL);
+ }
+
+ if (event.type == SWT.MouseDown) {
+ changeButtonState(STATE_PUSH);
+ }
+
+ if (event.type == SWT.MouseUp) { // FIXME
+ changeButtonState(STATE_HOVER);
+ }
+ }
+ };
+
+ private void setDefaultColors() {
+ attr.setColor(STATE_DISABLE,
+ new Color(Display.getCurrent(), 48, 48, 48));
+ attr.setColor(STATE_PUSH, new Color(Display.getCurrent(), 29, 109, 140));
+ attr.setColor(STATE_HOVER, new Color(Display.getCurrent(), 0, 134, 185));
+ attr.setColor(STATE_NORMAL, new Color(Display.getCurrent(), 67, 67, 67));
+ }
+
+ private PaintListener buttonPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ buttonRenderer.draw(e.gc, (Canvas) e.widget, state, attr);
+ }
+ };
+
+ public void setTitle(String newTitle) {
+ attr.setText(newTitle);
+ }
+
+ public void setText(String newTitle) {
+ attr.setText(newTitle);
+ }
+
+ public void setButtonImage(Image img) {
+ attr.setButtonImage(img);
+ }
+
+ public void setRenderer(DACustomButtonRenderer newRenderer) {
+ buttonRenderer = newRenderer;
+ }
+/*
+ public boolean isEnabled() {
+ return (state != STATE_DISABLE ? true : false);
+ }
+*/
+ public void setEnabled(boolean enabled) {
+ if (enabled) {
+ super.setEnabled(true);
+ changeButtonState(STATE_NORMAL);
+ } else {
+ changeButtonState(STATE_DISABLE);
+ }
+ }
+
+ public void setImage(int state, Image image) {
+ attr.setImage(state, image);
+ }
+
+ public Image getImage(int state) {
+ return attr.getImage(state);
+ }
+
+ public void setColor(int state, Color color) {
+ attr.setColor(state, color);
+ }
+
+ public void setFont(Font font) {
+ attr.setFont(font);
+ }
+
+ public void setFontPoint(Point p) {
+ attr.setFontPoint(p);
+ }
+
+ public void setColors(Color normal, Color push, Color hover, Color disable) {
+ attr.setColor(STATE_NORMAL, normal);
+ attr.setColor(STATE_PUSH, push);
+ attr.setColor(STATE_HOVER, hover);
+ attr.setColor(STATE_DISABLE, disable);
+ attr.setDrawType(TYPE_COLOR);
+ }
+
+ public void setImages(Image normal, Image push, Image hover, Image disable) {
+ attr.setImage(STATE_NORMAL, normal);
+ attr.setImage(STATE_PUSH, push);
+ attr.setImage(STATE_HOVER, hover);
+ attr.setImage(STATE_DISABLE, disable);
+ attr.setDrawType(TYPE_IMAGE);
+ }
+
+ public void setOutlineColors(Color normal, Color push, Color hover,
+ Color disable) {
+ attr.setOutlineColor(STATE_NORMAL, normal);
+ attr.setOutlineColor(STATE_PUSH, push);
+ attr.setOutlineColor(STATE_HOVER, hover);
+ attr.setOutlineColor(STATE_DISABLE, disable);
+ }
+
+ public void setOutlineInColors(Color normal, Color push, Color hover,
+ Color disable) {
+ attr.setOutlineInColor(STATE_NORMAL, normal);
+ attr.setOutlineInColor(STATE_PUSH, push);
+ attr.setOutlineInColor(STATE_HOVER, hover);
+ attr.setOutlineInColor(STATE_DISABLE, disable);
+ }
+
+ public void addClickListener(DACustomButtonClickEventListener listener) {
+ addListener(SWT.MouseUp, listener);
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setGradation(Color normalStart, Color normalEnd,
+ Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
+ Color disableStart, Color disableEnd) {
+ attr.setColor(0, normalStart);
+ attr.setColor(1, normalEnd);
+ attr.setColor(2, pushStart);
+ attr.setColor(3, pushEnd);
+ attr.setColor(4, hoverStart);
+ attr.setColor(5, hoverEnd);
+ attr.setColor(6, disableStart);
+ attr.setColor(7, disableEnd);
+ attr.setDrawType(TYPE_GRADATION);
+ }
+
+ public void setGradationColor(int state, Color start, Color end) {
+ attr.setColor(state * 2, start);
+ attr.setColor(state * 2 + 1, end);
+ }
+
+ public void setFontColors(Color normal, Color push, Color hover,
+ Color disable) {
+ attr.setFontColor(STATE_NORMAL, normal);
+ attr.setFontColor(STATE_PUSH, push);
+ attr.setFontColor(STATE_HOVER, hover);
+ attr.setFontColor(STATE_DISABLE, disable);
+ }
+
+ public void setFontColor(int state, Color color) {
+ attr.setFontColor(state, color);
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.button;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public class DACustomButtonAttribute {
+ private final int MAX_SIZE = 12;
+ private String text;
+ private Image buttonImage = null;
+ private Font font;
+ private Point fontPoint;
+ private int drawType = DACustomButton.TYPE_COLOR;
+
+ private List<Image> images = new ArrayList<Image>();
+ private List<Color> colors = new ArrayList<Color>();
+ private List<Color> fontColors = new ArrayList<Color>();
+ private List<Color> outlineColors = new ArrayList<Color>();
+ private List<Color> outlineInColors = new ArrayList<Color>();
+ private boolean enabled;
+
+ public DACustomButtonAttribute() {
+ enabled = true;
+
+ // init array list
+ for (int i = 0; i < MAX_SIZE; i++) {
+ images.add(null);
+ colors.add(null);
+ fontColors.add(null);
+ outlineColors.add(null);
+ outlineInColors.add(null);
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Image getButtonImage() {
+ return buttonImage;
+ }
+
+ public void setButtonImage(Image img) {
+ buttonImage = img;
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public void setFont(Font font) {
+ this.font = font;
+ }
+
+ public Point getFontPoint() {
+ return fontPoint;
+ }
+
+ public void setFontPoint(Point fontPoint) {
+ this.fontPoint = fontPoint;
+ }
+
+ public int getDrawType() {
+ return drawType;
+ }
+
+ public void setDrawType(int type) {
+ drawType = type;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Image getImage(int state) {
+ if (!images.isEmpty()) {
+ return images.get(state);
+ }
+ return null;
+ }
+
+ public void setImage(int state, Image img) {
+ images.set(state, img);
+ }
+
+ public Color getColor(int state) {
+ if (!colors.isEmpty()) {
+ return colors.get(state);
+ }
+ return null;
+ }
+
+ public void setColor(int state, Color color) {
+ colors.set(state, color);
+ }
+
+ public void setFontColor(int state, Color color) {
+ fontColors.set(state, color);
+ }
+
+ public Color getFontColor(int state) {
+ return fontColors.get(state);
+ }
+
+ public void setOutlineColor(int state, Color color) {
+ outlineColors.set(state, color);
+ }
+
+ public Color getOutlineColor(int state) {
+ return outlineColors.get(state);
+ }
+
+ public void setOutlineInColor(int state, Color color) {
+ outlineInColors.set(state, color);
+ }
+
+ public Color getOutlineInColor(int state) {
+ return outlineInColors.get(state);
+ }
+}
--- /dev/null
+/*\r
+ * Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Jooyoul Lee <jy.exe.lee@samsung.com>\r
+ * Juyoung Kim <j0.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.emulator.manager.da.widgets.button;\r
+\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+\r
+public abstract class DACustomButtonClickEventListener implements Listener {\r
+\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ DACustomButton button = (DACustomButton) event.widget;\r
+ if (null != button && button.getState() != DACustomButton.STATE_DISABLE) {\r
+ Rectangle rectangle = button.getBounds();\r
+ int x = event.x;\r
+ int y = event.y;\r
+\r
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {\r
+ return;\r
+ }\r
+ } else {\r
+ return;\r
+ }\r
+\r
+ handleClickEvent(button);\r
+ }\r
+\r
+ public abstract void handleClickEvent(DACustomButton button);\r
+}\r
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.button;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+public class DACustomButtonDefaultRenderer extends DACustomButtonRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state,
+ DACustomButtonAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+
+ if (attr.getDrawType() == DACustomButton.TYPE_IMAGE) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
+ }
+
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, attr, state);
+ } else if (attr.getDrawType() == DACustomButton.TYPE_COLOR
+ || attr.getDrawType() == DACustomButton.TYPE_GRADATION) {
+ drawButton(gc, rect, state, attr);
+ }
+ drawButtonImage(gc, rect, attr);
+ }
+
+ public int computeFontSize(Rectangle rect) {
+ if (rect.height > 20)
+ return 10;
+ else
+ return 8;
+ }
+
+ public void drawButton(GC gc, Rectangle rect, int state,
+ DACustomButtonAttribute attr) {
+ if (attr.getDrawType() == DACustomButton.TYPE_COLOR) {
+ gc.setBackground(attr.getColor(state));
+ gc.fillRectangle(rect);
+ } else {
+ int index = state * 2;
+ gc.setForeground(attr.getColor(index));
+ gc.setBackground(attr.getColor(index + 1));
+ gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height,
+ true);
+ }
+
+ Rectangle r = new Rectangle(0, 0, rect.width - 1, rect.height - 1);
+ if (attr.getButtonImage() == null) {
+ drawButtonText(gc, r, attr, state);
+ }
+ Color c = gc.getForeground();
+ if (null != attr.getOutlineColor(state)) {
+ gc.setForeground(attr.getOutlineColor(state));
+ } else {
+ gc.setForeground(ColorResources.BLACK.getColor());
+ }
+ gc.drawRectangle(r);
+ Rectangle ir = new Rectangle(r.x + 1, r.y + 1, r.width - 2,
+ r.height - 2);
+ if (null != attr.getOutlineInColor(state)) {
+ gc.setForeground(attr.getOutlineInColor(state));
+ } else {
+ gc.setForeground(c);
+ return;
+ }
+ gc.drawRectangle(ir);
+ gc.setForeground(c);
+ }
+
+ protected void drawButtonImage(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr) {
+ if (attr != null && attr.getButtonImage() != null) {
+ Image img = attr.getButtonImage();
+ Rectangle imgRect = img.getBounds();
+ int width = rect.width - imgRect.width;
+ int height = rect.height - imgRect.height;
+ int x = 0, y = 0;
+ if (width > 0) {
+ x = width / 2;
+ }
+
+ if (height > 0) {
+ y = height / 2;
+ }
+ gc.drawImage(img, x, y);
+ }
+ }
+
+ protected void drawButtonText(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr, int state) {
+ String text = null;
+ Font font = null;
+ Point p = null;
+ if (null != (text = attr.getText())) {
+ if (null == (font = attr.getFont())) {
+ font = new Font(Display.getCurrent(), "Arial",
+ computeFontSize(rect), SWT.BOLD);
+ attr.setFont(font);
+ }
+ gc.setFont(font);
+
+ int x = 0, y = 0;
+ int offset = 0;
+ if (null == (p = attr.getFontPoint())) {
+ p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+ y = (rect.height - p.y) / 2;
+ x = (x < 0) ? 0 : x;
+ // rect size < text length -> insert offset
+ // offset = ((x - rect.x) < 4) ? 4 : 0;
+ offset = 0;
+ } else {
+ x = p.x;
+ y = p.y;
+ }
+
+ if (null != attr.getFontColor(state)) {
+ gc.setForeground(attr.getFontColor(state));
+ } else {
+ gc.setForeground(ColorResources.BLACK.getColor());
+ }
+
+ if (state == DACustomButton.STATE_PUSH) {
+ x += 1;
+ y += 1;
+ }
+ gc.drawString(text, x + offset, y, true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.button;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class DACustomButtonRenderer {
+ public abstract void draw(GC gc, Canvas canvas, int state,
+ DACustomButtonAttribute attr);
+
+}
--- /dev/null
+/*\r
+ * Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Jooyoul Lee <jy.exe.lee@samsung.com>\r
+ * Juyoung Kim <j0.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.emulator.manager.da.widgets.button.toggle;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;\r
+import org.tizen.emulator.manager.resources.ColorResources;\r
+\r
+public class DACustomToggleButton extends DACustomButton {\r
+\r
+ public static final int STATE_TOGGLE = 4;\r
+ public static final int STATE_TOGGLE_HOVER = 5;\r
+ public static final int STATE_TOGGLE_PUSH = 6;\r
+ private boolean toggle = false;\r
+ private boolean toggleByButton = false;\r
+\r
+ public DACustomToggleButton(Composite parent, Image normal, Image push,\r
+ Image hover, Image disable, Image toggle, Image toggleHover) {\r
+ super(parent, normal, push, hover, disable);\r
+ buttonRenderer = new DACustomToggleButtonRenderer();\r
+\r
+ attr.setImage(STATE_TOGGLE, toggle);\r
+ attr.setImage(STATE_TOGGLE_HOVER, toggleHover);\r
+ addListeners();\r
+ }\r
+\r
+ public DACustomToggleButton(Composite parent, Image normal, Image push,\r
+ Image hover, Image disable, Image toggle, Image toggleHover,\r
+ Image togglePush) {\r
+ this(parent, normal, push, hover, disable, toggle, toggleHover);\r
+ buttonRenderer = new DACustomToggleButtonRenderer();\r
+\r
+ attr.setImage(STATE_TOGGLE_PUSH, togglePush);\r
+ }\r
+\r
+ public DACustomToggleButton(Composite parent, int style) {\r
+ super(parent, style);\r
+ buttonRenderer = new DACustomToggleButtonRenderer();\r
+ attr.setColor(STATE_TOGGLE, ColorResources.BLUE.getColor());\r
+ attr.setColor(STATE_TOGGLE_HOVER, ColorResources.WHITE.getColor());\r
+ addListeners();\r
+ }\r
+\r
+ public DACustomToggleButton(Composite parent, Color normalStart,\r
+ Color normalEnd, Color pushStart, Color pushEnd, Color hoverStart,\r
+ Color hoverEnd, Color disableStart, Color disableEnd,\r
+ Color toggleStart, Color toggleEnd, Color toggleHoverStart,\r
+ Color toggleHoverEnd) {\r
+ this(parent, SWT.NONE);\r
+ attr.setColor(0, normalStart);\r
+ attr.setColor(1, normalEnd);\r
+ attr.setColor(2, pushStart);\r
+ attr.setColor(3, pushEnd);\r
+ attr.setColor(4, hoverStart);\r
+ attr.setColor(5, hoverEnd);\r
+ attr.setColor(6, disableStart);\r
+ attr.setColor(7, disableEnd);\r
+ attr.setColor(8, toggleStart);\r
+ attr.setColor(9, toggleEnd);\r
+ attr.setColor(10, toggleHoverStart);\r
+ attr.setColor(11, toggleHoverEnd);\r
+ attr.setDrawType(TYPE_GRADATION);\r
+ }\r
+\r
+ public void setToggled(boolean toggled) {\r
+ toggle = toggled;\r
+ if (toggled) {\r
+ changeButtonState(STATE_TOGGLE);\r
+ } else {\r
+ changeButtonState(STATE_NORMAL);\r
+ }\r
+ }\r
+\r
+ public void setToggled2(boolean toggled) {\r
+ if (!toggleByButton) {\r
+ toggle = toggled;\r
+ if (toggled) {\r
+ changeButtonState(STATE_TOGGLE);\r
+ } else {\r
+ changeButtonState(STATE_NORMAL);\r
+ }\r
+ }\r
+ }\r
+\r
+ public boolean isToggled() {\r
+ return toggle;\r
+ }\r
+\r
+ @Override\r
+ public void addListeners() {\r
+ if (null != toggleButtonMouseListener) {\r
+ this.addListener(SWT.MouseEnter, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseExit, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseDown, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseUp, toggleButtonMouseListener);\r
+ }\r
+ }\r
+\r
+ private Listener toggleButtonMouseListener = new Listener() {\r
+\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ if (state == STATE_DISABLE) {\r
+ return;\r
+ }\r
+\r
+ if (event.type == SWT.MouseEnter) {\r
+ if (toggle) {\r
+ changeButtonState(STATE_TOGGLE_HOVER);\r
+ } else {\r
+ changeButtonState(STATE_HOVER);\r
+ }\r
+ }\r
+\r
+ if (event.type == SWT.MouseExit) {\r
+ if (toggle) {\r
+ changeButtonState(STATE_TOGGLE);\r
+ } else {\r
+ changeButtonState(STATE_NORMAL);\r
+ }\r
+ }\r
+\r
+ if (event.type == SWT.MouseDown) {\r
+ if (toggle) {\r
+ if (null != attr.getImage(STATE_TOGGLE_PUSH)) {\r
+ changeButtonState(STATE_TOGGLE_PUSH);\r
+ } else {\r
+ changeButtonState(STATE_PUSH);\r
+ }\r
+ } else {\r
+ changeButtonState(STATE_PUSH);\r
+ }\r
+ }\r
+\r
+ if (event.type == SWT.MouseUp) { // FIXME\r
+ toggle = !toggle;\r
+ toggleByButton = !toggleByButton;\r
+ if (toggle) {\r
+ changeButtonState(STATE_TOGGLE_HOVER);\r
+ } else {\r
+ changeButtonState(STATE_HOVER);\r
+ }\r
+ }\r
+ }\r
+ };\r
+}\r
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.button.toggle;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonAttribute;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonDefaultRenderer;
+
+public class DACustomToggleButtonRenderer extends DACustomButtonDefaultRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state,
+ DACustomButtonAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+ if (attr.getDrawType() == DACustomButton.TYPE_IMAGE) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
+ }
+
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, attr, state);
+ } else if (attr.getDrawType() == DACustomButton.TYPE_COLOR
+ || attr.getDrawType() == DACustomButton.TYPE_GRADATION) {
+ drawButton(gc, rect, state, attr);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonRenderer;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+public class DACustomCombo extends Canvas {
+ public static final int MAX_SIZE = 10;
+ public static final int STATE_NORMAL = 0;
+ public static final int STATE_HOVER = 1;
+ public static final int STATE_PUSH = 2;
+ public static final int STATE_DISABLE = 3;
+
+ private static final int pageSize = 5;
+
+ Composite parent;
+ protected Canvas combo = null;
+ private Canvas popup = null;
+ private int itemHeight = 0;
+ private DACustomButton upArrowButton = null;
+ private DACustomButton downArrowButton = null;
+ private int itemIndex = 0;
+ private boolean dirty = false;
+
+ private List<String> items;
+ private List<Rectangle> rects = null;
+
+ private List<Image> images = null;
+ protected Image buttonUp = null;
+ private Image buttonDown = null;
+ private boolean enabled = true;
+ private Shell childShell = null;
+ private int selection = 0;
+ private String text = ""; //$NON-NLS-1$
+ private boolean imgCombo = false;
+ protected int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable
+ protected DACustomComboRenderer comboRenderer = new DACustomComboDefaultRenderer();;
+ private DACustomComboPopupRenderer popupRenderer = new DACustomComboPopupDefaultRenderer();
+ private DACustomButtonRenderer buttonRenderer = null;
+
+ private List<Color> arrowColors = null;
+ private List<Image> arrowImages = null;
+
+ public DACustomCombo(Composite parent, int style) {
+ super(parent, style);
+ combo = this;
+
+ this.parent = parent;
+ addPaintListener(comboPaintListener);
+ setForeground(ColorResources.WHITE.getColor());
+ addListeners();
+ initCombo();
+ }
+
+ public void addListeners() {
+ addListener(SWT.MouseEnter, comboMouseListener);
+ addListener(SWT.MouseHover, comboMouseListener);
+ addListener(SWT.MouseExit, comboMouseListener);
+ addListener(SWT.MouseDown, comboMouseListener);
+ addListener(SWT.MouseMove, comboMouseListener);
+ addListener(SWT.MouseUp, comboMouseListener);
+ }
+
+ public String getText() {
+ if (getItems().size() > 0) {
+ return getItems().get(itemIndex + selection);
+ }
+ return null;
+ }
+
+ public List<String> getItems() {
+ if (null == items) {
+ items = new ArrayList<String>();
+ }
+ return items;
+ }
+
+ private List<Rectangle> getRects() {
+ if (null == rects) {
+ rects = new ArrayList<Rectangle>();
+ }
+ return rects;
+ }
+
+ private void changeComboState(int s) {
+ state = s;
+ redraw();
+ }
+
+ private Listener popupSelectionListener = new DACustomComboSelectionListener() {
+
+ @Override
+ public void selectionEvent(DACustomCombo combo) {
+ //System.out.println("default selection" + combo.getText());
+ }
+ };
+
+ public void addSelectionListener(DACustomComboSelectionListener listener) {
+ popupSelectionListener = listener;
+ }
+
+ private Listener comboMouseListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (enabled) {
+ if (event.type == SWT.MouseEnter) {
+ changeComboState(STATE_HOVER);
+ }
+
+ if (event.type == SWT.MouseHover) {
+ if (!isOutOfBounds(event.x, event.y)) {
+ if (0 != (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_PUSH);
+ } else if (0 == (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_HOVER);
+ }
+ }
+ }
+
+ if (event.type == SWT.MouseDown) {
+ changeComboState(STATE_PUSH);
+ }
+
+ if (event.type == SWT.MouseUp) {
+ changeComboState(STATE_HOVER);
+ if (childShell == null || childShell.isDisposed()) {
+ openChildShell();
+ } else {
+ childShell.close();
+ childShell = null;
+ }
+ }
+
+ if (event.type == SWT.MouseMove) {
+ if (isOutOfBounds(event.x, event.y)) {
+ changeComboState(STATE_NORMAL);
+ } else if (isOutOfBounds(event.x, event.y)) {
+ if (0 != (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_PUSH);
+ } else if (0 == (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_HOVER);
+ }
+ }
+ }
+
+ if (event.type == SWT.MouseExit) {
+ changeComboState(STATE_NORMAL);
+ }
+ }
+ }
+ };
+
+ protected boolean isOutOfBounds(int x, int y) {
+ Rectangle rectangle = combo.getBounds();
+
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private int getShellWidth() {
+ if (getItems().isEmpty()) {
+ return 0;
+ }
+ int max = 0;
+ int size = items.size();
+ GC gc = new GC(parent.getDisplay(), SWT.NONE);
+ for (int i = 0; i < size; i++) {
+ Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
+ if (p.x > max) {
+ max = p.x;
+ }
+ }
+ max += 10;
+ gc.dispose();
+ return max;
+ }
+
+ public int getItemHeight() {
+ return itemHeight;
+ }
+
+ public void setItemHeight(int height) {
+ itemHeight = height;
+ }
+
+ private void openChildShell() {
+ childShell = new Shell(parent.getShell(), SWT.ON_TOP);
+ childShell.setLayout(new FormLayout());
+
+ Point p = combo.toDisplay(0, 0);
+ Rectangle rect = combo.getBounds();
+ int size = getItems().size();
+
+ int boundSize = (size > MAX_SIZE) ? MAX_SIZE : (size > 0) ? size : 1;
+
+ int textSize = getShellWidth() + 4;
+ int shellWidth = (textSize > rect.width) ? textSize : rect.width;
+ int height = 0;
+
+ if (getItemHeight() == 0) {
+ height = rect.height;
+ } else {
+ height = getItemHeight();
+ }
+ int shellHeight = height * boundSize + 5;
+
+ childShell.setSize(shellWidth, shellHeight);
+ childShell.setLocation(p.x, p.y + rect.height);
+ // childShell.setBackground(ColorResources.BLUE);
+ setSelect(text);
+
+ popup = new Canvas(childShell, SWT.DOUBLE_BUFFERED);
+ popup.setData(this);
+ popup.setBackground(ColorResources.WHITE.getColor());
+ popup.addPaintListener(popupPaintListener);
+ popup.addListener(SWT.MouseUp, popupMouseEventListener);
+ popup.addListener(SWT.MouseMove, popupMouseEventListener);
+ popup.addListener(SWT.FocusOut, popupMouseEventListener);
+ popup.addListener(SWT.MouseUp, popupSelectionListener);
+ popup.addListener(SWT.MouseWheel, popupMouseEventListener);
+
+ if (size > MAX_SIZE) {
+ upArrowButton = makeButton();
+ if (buttonUp == null) {
+ upArrowButton.setText("UP");
+ } else {
+ upArrowButton.setButtonImage(buttonUp);
+ }
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height;
+ upArrowButton.setLayoutData(data);
+ upArrowButton.addMouseListener(upArrowListener);
+ upArrowButton.addListener(SWT.MouseExit, upButtonMouseExitListener);
+ shellHeight += height;
+ if (itemIndex > 0) {
+ upArrowButton.setEnabled(true);
+ } else {
+ upArrowButton.setEnabled(false);
+ }
+
+ data = new FormData();
+ data.top = new FormAttachment(upArrowButton, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height * boundSize + 5 - 2;
+ popup.setLayoutData(data);
+
+ // downArrowButton = new DACustomButton(childShell, SWT.NONE);
+ downArrowButton = makeButton();
+ // downArrowButton.setText("down"); //$NON-NLS-1$
+ if (null == buttonDown) {
+ downArrowButton.setText("DOWN");
+ } else {
+ downArrowButton.setButtonImage(buttonDown);
+ }
+ data = new FormData();
+ data.top = new FormAttachment(popup, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height;
+ downArrowButton.setLayoutData(data);
+ downArrowButton.addMouseListener(downArrowListener);
+ downArrowButton.addListener(SWT.MouseExit,
+ downButtonMouseExitListener);
+ shellHeight += height;
+ if (itemIndex + MAX_SIZE < size - 1) {
+ downArrowButton.setEnabled(true);
+ } else {
+ downArrowButton.setEnabled(false);
+ }
+
+ childShell.setSize(shellWidth, shellHeight);
+ } else {
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = shellHeight - 2;
+ popup.setLayoutData(data);
+ }
+
+ size = (size > MAX_SIZE) ? MAX_SIZE : size;
+ getRects().clear();
+ for (int i = 0; i < size; i++) {
+ Rectangle r = new Rectangle(2, 2 + i * height, shellWidth - 2,
+ height);
+ getRects().add(r);
+ }
+ childShell.open();
+ }
+
+ private MouseListener upArrowListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+ if (!upArrowButton.isEnabled()) {
+ return;
+ }
+
+ if (null != upArrowButton) {
+ Rectangle rectangle = upArrowButton.getBounds();
+ int x = event.x;
+ int y = event.y;
+
+ if (x < 0 || x > rectangle.width || y < 0
+ || y > rectangle.height) {
+ return;
+ }
+ }
+
+ int size = getItems().size();
+ if (itemIndex - pageSize < 0) {
+ itemIndex = 0;
+ upArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= pageSize;
+ }
+
+ if (itemIndex + pageSize < size - 1) {
+ downArrowButton.setEnabled(true);
+ }
+ popup.redraw();
+ }
+
+ @Override
+ public void mouseDown(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ private MouseListener downArrowListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+
+ if (!downArrowButton.isEnabled()) {
+ return;
+ }
+
+ if (null != downArrowButton) {
+ Rectangle rectangle = downArrowButton.getBounds();
+ int x = event.x;
+ int y = event.y;
+
+ if (x < 0 || x > rectangle.width || y < 0
+ || y > rectangle.height) {
+ return;
+ }
+ }
+
+ int size = getItems().size();
+ if (itemIndex + pageSize + MAX_SIZE >= size - 1) {
+ itemIndex = size - MAX_SIZE;
+ downArrowButton.setEnabled(false);
+ } else {
+ itemIndex += pageSize;
+ }
+
+ // if (itemIndex - pageSize > 0) {
+ if (itemIndex > 0) {
+ upArrowButton.setEnabled(true);
+ }
+ popup.redraw();
+ }
+
+ @Override
+ public void mouseDown(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+ };
+
+ private PaintListener popupPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ List<String> items = getItems();
+ List<String> input = new ArrayList<String>();
+ int size = (items.size() > MAX_SIZE) ? MAX_SIZE : items.size();
+ for (int i = 0; i < size; i++) {
+ input.add(items.get(itemIndex + i));
+ }
+ popupRenderer
+ .draw(e.gc, popup, state, getRects(), selection, input);
+ }
+ };
+
+ public void setText(String text) {
+ if (!setSelect(text)) {
+ this.text = text;
+ redraw();
+ }
+ }
+
+ private boolean setSelect(String text) {
+ if (getItems().isEmpty()) {
+ return false;
+ }
+
+ int index = items.indexOf(text);
+ if (index < 0) {
+ return false;
+ }
+ int size = items.size();
+ if (size < MAX_SIZE) {
+ selection = index;
+ select(selection);
+ } else if (index + MAX_SIZE >= size) {
+ int lower = size - index;
+ selection = MAX_SIZE - lower;
+ itemIndex = size - MAX_SIZE;
+ select(selection);
+ } else {
+ selection = index - itemIndex;
+ select(selection);
+ }
+ return true;
+ }
+
+ public void upEvent() {
+ if (getItems().size() > 0) {
+ setText(getItems().get(itemIndex + selection));
+ } else {
+ setText(""); //$NON-NLS-1$
+ }
+ childShell.close();
+ childShell = null;
+ }
+
+ private Listener popupMouseEventListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.MouseMove) {
+ List<Rectangle> rs = getRects();
+ int size = rs.size();
+ for (int i = 0; i < size; i++) {
+ if (rs.get(i).contains(event.x, event.y)) {
+ selection = i;
+ popup.redraw();
+ break;
+ }
+ }
+ }
+
+ if (event.type == SWT.FocusOut) {
+ childShell.close();
+ childShell = null;
+ }
+
+ if (event.type == SWT.MouseWheel) {
+ int size = getItems().size();
+ if (null != downArrowButton && null != upArrowButton) {
+ if (event.count < 0) {
+ if (itemIndex - event.count + MAX_SIZE >= size - 1) {
+ itemIndex = size - MAX_SIZE;
+ downArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= event.count;
+ }
+
+ // if (itemIndex - pageSize > 0) {
+ if (itemIndex > 0) {
+ upArrowButton.setEnabled(true);
+ }
+ } else {
+
+ if (itemIndex - event.count < 0) {
+ itemIndex = 0;
+ upArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= event.count;
+ }
+
+ if (itemIndex + event.count < size - 1) {
+ downArrowButton.setEnabled(true);
+ }
+ }
+ popup.redraw();
+ }
+ }
+ }
+ };
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ if (enabled) {
+ changeComboState(STATE_NORMAL);
+ if (isImageCombo()) {
+ setBackgroundImage(images.get(STATE_NORMAL));
+ }
+ } else {
+ changeComboState(STATE_DISABLE);
+ if (isImageCombo()) {
+ setBackgroundImage(images.get(STATE_DISABLE));
+ }
+ }
+ }
+
+ private PaintListener comboPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (!isImageCombo()) {
+ comboRenderer.draw(e.gc, combo, text, state);
+ } else {
+ comboRenderer.drawImage(e.gc, combo, images.get(state), text,
+ state);
+ }
+ }
+ };
+
+ public void setComboRender(DACustomComboRenderer newRenderer) {
+ comboRenderer = newRenderer;
+ }
+
+ public void setComboPopupRender(DACustomComboPopupRenderer newRenderer) {
+ popupRenderer = newRenderer;
+ }
+
+ // public void removeAll() {
+ // getItems().clear();
+ // }
+
+ public void add(String item) {
+ if (dirty) {
+ getItems().add(item);
+ } else {
+ getItems().set(0, item);
+ dirty = true;
+ }
+ }
+
+ public void add(String item, int index) {
+ getItems().add(index, item);
+ }
+
+ public void select(int index) {
+ selection = index;
+ this.text = items.get(itemIndex + selection);
+ redraw();
+ }
+
+ public String getItem(int index) {
+ if (getItems().size() > 0) {
+ return getItems().get(index);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public void setImages(Image normal, Image hover, Image push, Image disable) {
+ if (null == normal || null == hover || null == push || null == disable) {
+ return;
+ }
+ List<Image> imgs = getImages();
+
+ imgs.add(normal);
+ imgs.add(hover);
+ imgs.add(push);
+ imgs.add(disable);
+ setImageCombo(true);
+ }
+
+ protected List<Image> getImages() {
+ if (null == images) {
+ images = new ArrayList<Image>();
+ }
+ return images;
+ }
+
+ private void setImageCombo(boolean b) {
+ this.imgCombo = b;
+ }
+
+ public boolean isImageCombo() {
+ return imgCombo;
+ }
+
+ private Listener upButtonMouseExitListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ }
+ };
+
+ private Listener downButtonMouseExitListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+
+ }
+ };
+
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ public void initCombo() {
+ getItems().clear();
+ itemIndex = 0;
+ selection = 0;
+ items.add("");
+ dirty = false;
+ }
+
+ public void setComboButtonColor(Color normal, Color push, Color hover,
+ Color disable) {
+ arrowColors = new ArrayList<Color>();
+ arrowColors.add(normal);
+ arrowColors.add(push);
+ arrowColors.add(hover);
+ arrowColors.add(disable);
+ }
+
+ public void setComboButtonImage(Image normal, Image push, Image hover,
+ Image disable) {
+ arrowImages = new ArrayList<Image>();
+ arrowImages.add(normal);
+ arrowImages.add(push);
+ arrowImages.add(hover);
+ arrowImages.add(disable);
+ }
+
+ public void setComboButtonGradation(Color normalStart, Color normalEnd,
+ Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
+ Color disableStart, Color disableEnd) {
+ arrowColors = new ArrayList<Color>();
+ arrowColors.add(normalStart);
+ arrowColors.add(normalEnd);
+ arrowColors.add(pushStart);
+ arrowColors.add(pushEnd);
+ arrowColors.add(hoverStart);
+ arrowColors.add(hoverEnd);
+ arrowColors.add(disableStart);
+ arrowColors.add(disableEnd);
+ }
+
+ private DACustomButton makeButton() {
+ DACustomButton button = null;
+ if (arrowImages != null) {
+ button = new DACustomButton(childShell,
+ arrowImages.get(STATE_NORMAL), arrowImages.get(STATE_PUSH),
+ arrowImages.get(STATE_HOVER),
+ arrowImages.get(STATE_DISABLE));
+ } else if (arrowColors != null) {
+ if (arrowColors.size() > 4) {
+ // gradation
+ button = new DACustomButton(childShell,
+ arrowColors.get(STATE_NORMAL),
+ arrowColors.get(STATE_NORMAL + 1),
+ arrowColors.get(STATE_PUSH * 2),
+ arrowColors.get(STATE_PUSH * 2 + 1),
+ arrowColors.get(STATE_HOVER * 2),
+ arrowColors.get(STATE_HOVER * 2 + 1),
+ arrowColors.get(STATE_DISABLE * 2),
+ arrowColors.get(STATE_DISABLE * 2 + 1));
+ } else {
+ button = new DACustomButton(childShell, SWT.NONE);
+ button.setColors(arrowColors.get(STATE_NORMAL),
+ arrowColors.get(STATE_PUSH),
+ arrowColors.get(STATE_HOVER),
+ arrowColors.get(STATE_DISABLE));
+ }
+ } else {
+ button = new DACustomButton(childShell, SWT.NONE);
+ }
+ if (null != buttonRenderer) {
+ button.setRenderer(buttonRenderer);
+ }
+ return button;
+ }
+
+ public void setButtonRenderer(DACustomButtonRenderer renderer) {
+ buttonRenderer = renderer;
+ }
+
+ public void setButtonImages(Image up, Image down) {
+ buttonUp = up;
+ buttonDown = down;
+ }
+
+ public int getItemIndex(String text) {
+ return getItems().indexOf(text);
+ }
+
+ public boolean isChildShellOpened() {
+ if (childShell == null || childShell.isDisposed()) {
+ return false;
+ }
+ return true;
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+
+public class DACustomComboDefaultRenderer extends DACustomComboRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, String text, int state) {
+ Rectangle rect = canvas.getClientArea();
+ if (state == DACustomCombo.STATE_NORMAL) {
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR.getColor());
+ } else if (state == DACustomCombo.STATE_HOVER) {
+ gc.setBackground(ColorResources.ITEM_BLUE_DARK.getColor());
+ } else if (state == DACustomCombo.STATE_PUSH) {
+ gc.setBackground(ColorResources.BLUE.getColor());
+ } else if (state == DACustomCombo.STATE_DISABLE) {
+ gc.setBackground(ColorResources.GRAY1.getColor());
+ }
+ gc.fillRectangle(rect);
+ gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1);
+
+ if (null == text) {
+ text = ""; //$NON-NLS-1$
+ }
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.drawString(text, 5, (rect.height - p.y)/2, true);
+ gc.fillRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
+ gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ String text, int state) {
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, String text,
+ int state) {
+
+ }
+
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+
+public class DACustomComboPopupDefaultRenderer extends DACustomComboPopupRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state, List<Rectangle> rects,
+ int selection, List<String> items) {
+ int size = rects.size();
+ for (int i = 0; i < size; i++) {
+ Rectangle r = rects.get(i);
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR.getColor());
+ if (selection == i) {
+ gc.setBackground(ColorResources.RED.getColor());
+ gc.fillRectangle(r);
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR.getColor());
+ }
+ gc.setForeground(ColorResources.WHITE.getColor());
+ gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
+ Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
+ gc.drawString(items.get(i), 5, (r.height - p.y) / 2 + i * r.height,
+ true);
+ }
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ int state, List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, int state,
+ List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class DACustomComboPopupRenderer {
+ public abstract void draw(GC gc, Canvas canvas, int state,
+ List<Rectangle> rects, int selection, List<String> items);
+
+ public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ int state, List<Rectangle> rects, int selection, List<String> items);
+
+ public abstract void drawImage(GC gc, Canvas canvas, Image image,
+ int state, List<Rectangle> rects, int selection, List<String> items);
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class DACustomComboRenderer {
+ public abstract void draw(GC gc, Canvas canvas, String text, int state);
+ public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage, String text, int state);
+ public abstract void drawImage(GC gc, Canvas canvas, Image image, String text, int state);
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+public abstract class DACustomComboSelectionListener implements Listener {
+
+ @Override
+ public void handleEvent(Event event) {
+ Canvas popup = (Canvas) event.widget;
+ DACustomCombo combo = (DACustomCombo) popup.getData();
+ if (null != combo) {
+ selectionEvent(combo);
+ combo.upEvent();
+ }
+ }
+
+ public abstract void selectionEvent(DACustomCombo combo);
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+
+
+public class TitleComboPopupRenderer extends DACustomComboPopupRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state, List<Rectangle> rects,
+ int selection, List<String> items) {
+ int size = rects.size();
+ for (int i = 0; i < size; i++) {
+ Rectangle r = rects.get(i);
+ if (selection == i) {
+ gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_INNER.getColor());
+ gc.fillRectangle(r);
+
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_TOP.getColor());
+ gc.drawLine(r.x, r.y, r.x + r.width, r.y);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_BOTTOM.getColor());
+ gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
+ + r.height - 1);
+ } else {
+ gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_INNER.getColor());
+ gc.fillRectangle(r);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_TOP.getColor());
+ gc.drawLine(r.x, r.y, r.x + r.width, r.y);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM.getColor());
+ gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
+ + r.height - 1);
+ }
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_DROPDOWN_TEXT.getColor());
+ gc.setFont(FontResources.DROPDOWN.getFont());
+ // Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
+ // gc.drawString(items.get(i), 5, (r.height - p.y) / 2 + i *
+ // r.height,
+ // true);
+ gc.drawString(items.get(i), 5, 6 + i * r.height, true);
+
+ Rectangle rect = canvas.getClientArea();
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_1.getColor());
+ gc.drawRectangle(rect);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_2.getColor());
+ gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 2,
+ rect.height - 2);
+ }
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ int state, List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, int state,
+ List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.da.widgets.combo;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+
+public class TitleComboRenderer extends DACustomComboRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, String text, int state) {
+ Rectangle rect = canvas.getClientArea();
+ setColors(state, gc);
+ gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
+ gc.setForeground(ColorResources.BLACK.getColor());
+ gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1);
+
+ if (null == text) {
+ text = "";
+ }
+ gc.setFont(FontResources.COMBO.getFont());
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE.getColor());
+ gc.drawString(text, 5, (rect.height - p.y) / 2, true);
+
+ setColors(state, gc);
+ gc.fillGradientRectangle(rect.x + rect.width - 20, rect.y, 19,
+ rect.height - 1, true);
+ gc.setForeground(ColorResources.BLACK.getColor());
+ gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ String text, int state) {
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, String text,
+ int state) {
+ Rectangle rect = canvas.getClientArea();
+ gc.drawImage(image, rect.x, rect.y);
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.setFont(FontResources.COMBO.getFont());
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE.getColor());
+ gc.drawString(text, 5, (rect.height - p.y) / 2, true);
+ Rectangle clipping = new Rectangle(rect.x + rect.width - 19, rect.y,
+ 19, rect.height);
+ gc.setClipping(clipping);
+ gc.drawImage(image, rect.x, rect.y);
+ }
+
+ private void setColors(int state, GC gc) {
+ if (state == DACustomCombo.STATE_NORMAL) {
+ gc.setForeground(ColorResources.GRAY2.getColor());
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR.getColor());
+ } else if (state == DACustomCombo.STATE_HOVER) {
+ gc.setForeground(ColorResources.GRAY2.getColor());
+ gc.setBackground(ColorResources.ITEM_BLUE_DARK.getColor());
+ } else if (state == DACustomCombo.STATE_PUSH) {
+ gc.setForeground(ColorResources.GRAY2.getColor());
+ gc.setBackground(ColorResources.BLUE.getColor());
+ } else if (state == DACustomCombo.STATE_DISABLE) {
+ gc.setForeground(ColorResources.GRAY2.getColor());
+ gc.setBackground(ColorResources.GRAY1.getColor());
+ }
+ }
+
+}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.image;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import org.tizen.emulator.manager.logging.EMLogger;
-
-public class Skins {
- private ArrayList<Skin> skins = null;
- private String path = null;
-
- public Skins(File dir) throws IOException {
- if (dir.exists()) {
- this.path = dir.getAbsolutePath();
- skins = new ArrayList<Skin>();
- for (File skin : dir.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- if (!pathname.isDirectory()) {
- return false;
- }
- return true;
- }
- })) {
- Skin s = null;
- try {
- s = new Skin(skin);
- } catch(IOException e) {
- EMLogger.getLogger().warning("Error while skin information: " + e.getMessage());
- continue;
- }
- skins.add(s);
- }
- } else {
- throw new IOException("This directory does not exist (" + path + ")");
- }
- }
-
- public String getSkinsPath() {
- return path;
- }
-
- public ArrayList<Skin> getSkinList() {
- return skins;
- }
-}
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import org.tizen.emulator.manager.tool.FilePath;
+import org.tizen.emulator.manager.resources.FilePath;
public class EMLogger {
private static EMLogger instance;
*
*/
-package org.tizen.emulator.manager.image;
+package org.tizen.emulator.manager.platform;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.VMProperty;
public class BaseImage {
- private Platform platform;
- private String id = "0";
- private String platformName;
- private String type;
- private String name;
- private String imageName;
- private String version;
- private String release;
-
- private String domain;
- private String cpu;
- private String path;
+ protected Platform platform;
+ protected String platformName;
+ protected String type;
+
+ protected String path;
+ protected String pathName;
+
+ protected String id = "0";
+ protected String name;
+ protected String version;
+ protected String releaseVersion;
+ protected String domain;
+ protected String cpu;
+
private String information;
+ protected BaseImage() {
+
+ }
+
public BaseImage(Platform platform, File path) throws IOException {
this.platform = platform;
loadProperty(path);
}
private void loadProperty(File path) throws IOException {
- File f = new File(path + File.separator + StringResource.IMAGE_INFO_FILENAME);
+ File f = new File(path + File.separator + StringResources.IMAGE_INFO_FILENAME);
FileInputStream inputStream = null;
try {
if (f.exists()) {
inputStream = new FileInputStream(f);
Properties prop = new Properties();
prop.load(inputStream);
- platformName = prop.getProperty(StringResource.IMAGE_PLATFORM, platform.getVersion());
- type = prop.getProperty(StringResource.IMAGE_TYPE, "default");
- name = prop.getProperty(StringResource.IMAGE_NAME).toLowerCase();
+ platformName = prop.getProperty(StringResources.IMAGE_PLATFORM, platform.getName());
+ type = prop.getProperty(StringResources.IMAGE_TYPE, "default");
+ name = prop.getProperty(StringResources.IMAGE_NAME).toLowerCase();
if (name == null) {
throw new IOException("Image name is null. This image can not add.");
}
- version = prop.getProperty(StringResource.IMAGE_VERSION, platform.getVersion());
- domain = prop.getProperty(StringResource.PRODUCT_DOMAIN, "Phone");
- cpu = prop.getProperty(StringResource.TARGET_CPU, "x86");
+ version = prop.getProperty(StringResources.IMAGE_VERSION, platform.getName());
+ releaseVersion = prop.getProperty(StringResources.RELEASE_VERSION, "Not identified");
+ domain = prop.getProperty(StringResources.PRODUCT_DOMAIN, "Phone");
+ cpu = prop.getProperty(StringResources.TARGET_CPU, "x86");
cpu = cpu.toLowerCase();
- release = prop.getProperty(StringResource.RELEASE_VERSION, "Not identified");
} else {
throw new IOException("This file does not exist (" + path + ")");
}
for (File f : path.listFiles()) {
if (f.isFile() && f.getName().endsWith(cpu.toLowerCase())) {
this.path = f.getCanonicalPath();
- this.imageName = f.getName();
+ this.pathName = f.getName();
}
}
if (this.path == null) {
void setID(int id) {
this.id = Integer.toString(id);
//
- information = getName() + StringResource.NEW_LINE +
- " ID : " + getID() + StringResource.NEW_LINE +
- " Platform : " + getPlatformName() + StringResource.NEW_LINE +
- " Type : " + getType() + StringResource.NEW_LINE +
- " Version : " + getVersion() + StringResource.NEW_LINE +
- " Release Version : " + getRelease() + StringResource.NEW_LINE +
- " Target CPU : " + getCpu().toUpperCase() + StringResource.NEW_LINE +
- " Product Domain : " + getDomain() + StringResource.NEW_LINE +
- " Base Disk Image Path : " + getPath() + StringResource.NEW_LINE;
+ information = getName() + StringResources.NEW_LINE
+ + " ID : " + getID() + StringResources.NEW_LINE
+ + " Platform : " + getPlatformName() + StringResources.NEW_LINE
+ + " Type : " + getType() + StringResources.NEW_LINE
+ + " Version : " + getVersion() + StringResources.NEW_LINE
+ + " Release Version : " + getRelease() + StringResources.NEW_LINE
+ + " Target CPU : " + getCpu() + StringResources.NEW_LINE
+ + " Product Domain : " + getDomain() + StringResources.NEW_LINE
+ + " Base Disk Image Path : " + getPath() + StringResources.NEW_LINE;
//
}
- public String getID() {
- return id;
- }
-
- public String getVersion() {
- return version;
- }
-
public String getPath() {
return path;
}
+ public String getPathName() {
+ return pathName;
+ }
+
public String toString() {
return information;
}
+ public String getID() {
+ return id;
+ }
+
+ // Platform name
+ public String getVersion() {
+ return version;
+ }
+
public String getCpu() {
return cpu;
}
}
public String getRelease() {
- return release;
- }
-
- public String getImagePathName() {
- return imageName;
+ return releaseVersion;
}
public String getName() {
return name;
}
- public String getDirName() {
- return name;
- }
-
public String getType() {
return type;
}
public Platform getPlatform() {
return platform;
}
+
+ protected ArrayList<VMProperty> vmsList = new ArrayList<VMProperty>();
+
+ public ArrayList<VMProperty> getVmsList() {
+ return vmsList;
+ }
+
+ public void addVMsProperty(VMProperty property) {
+ vmsList.add(property);
+ }
+
+ public void removeVMsProerty(VMProperty property) {
+ vmsList.remove(property);
+ }
+
+ public void clearVMsList() {
+ vmsList.clear();
+ }
}
--- /dev/null
+package org.tizen.emulator.manager.platform;
+
+import java.io.IOException;
+
+public class CustomBaseImage extends BaseImage {
+
+ public CustomBaseImage(Platform platform, String name, String cpu) throws IOException {
+ this.platform = platform;
+ this.platformName = platform.getName();
+
+ this.name = name;
+ this.cpu = cpu;
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.platform;
+
+import java.io.IOException;
+
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class CustomPlatform extends Platform {
+
+ public CustomPlatform() {
+ this.platformName = "custom";
+ this.platformPath = "";
+ //this.version = name;
+ try {
+ imageList.add(new CustomBaseImage(this, "x86-custom", "x86"));
+ if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+ imageList.add(new CustomBaseImage(this, "arm-custom", "arm"));
+ }
+ } catch (IOException e) {
+ // TODO
+ }
+
+ }
+
+ public void clearImageList() {
+ imageList.clear();
+ }
+
+ //private boolean isX86 = false;
+ //private boolean isArm = false;
+ public void addVMsProperty(VMProperty prop) {
+ /*
+ if (prop.getArch() == Architecture.x86) {
+ if (!isX86) {
+ try {
+ imageList.add(new CustomBaseImage(this, "x86-custom", "x86"));
+ } catch (IOException e) {
+ // TODO
+ }
+ isX86 = true;
+ }
+
+ } else {
+ if (!isArm) {
+ try {
+ imageList.add(new CustomBaseImage(this, "arm-custom", "arm"));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ isArm = true;
+ }
+ }
+ */
+
+ for (BaseImage b : getImageList()) {
+ if (prop.getArch().toString().equals(b.getCpu())) {
+ b.addVMsProperty(prop);
+ break;
+ }
+ }
+ }
+
+}
/*
* Emulator Manager
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
*
*/
-package org.tizen.emulator.manager.image;
+package org.tizen.emulator.manager.platform;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
+import org.tizen.emulator.manager.resources.FilePath;
public class Platform {
- private String platform_name = null;
- private String platform_path = null;
- private String version = null;
- private static int id = 1;
+ protected String platformName = null;
+ protected String platformPath = null;
+ //protected String version = null;
+ protected static int id = 1;
// TODO : for skins
//private String skins_path = null;
//private String template_path = null;
//private ArrayList<VMsProperty> templateList = new ArrayList<VMsProperty>();
- private ArrayList<BaseImage> imageList = new ArrayList<BaseImage>();
+ protected ArrayList<BaseImage> imageList = new ArrayList<BaseImage>();
+
+ protected Platform() {
+
+ }
public Platform(String name) {
- this.platform_name = name;
- this.platform_path = FilePath.getInstance().getPlatformsPath()
- + File.separator + platform_name;
- this.version = name;
+ this.platformName = name;
+ this.platformPath = FilePath.getInstance().getPlatformsPath()
+ + File.separator + platformName;
+ //this.version = name;
//loadSkins();
//loadTemplate();
//versionCheck();
}
+ private void loadProperties() {
+ if (platformPath == null) {
+ return;
+ }
+ File dir = new File(platformPath);
+ if (!dir.isDirectory()) {
+ // TODO
+ EMLogger.getLogger().info("This path is not directory." + platformPath);
+ return;
+ }
+
+ File defaultImages = new File(platformPath + FilePath.getInstance().getDefaultImagePath());
+ File addonsImages = new File(platformPath + FilePath.getInstance().getAddonsImagePath());
+
+ //boolean isDuplicate = false;
+ if(defaultImages.exists() && defaultImages.isDirectory()) {
+ BaseImage image;
+ for (File f : defaultImages.listFiles()) {
+ if (f.isDirectory()) {
+ try {
+ image = new BaseImage(this, f);
+ for (BaseImage i : imageList) {
+ if (i.getName().equals(image.getName())){
+ // TODO: duplicate name
+ EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )");
+ throw new IOException();
+ }
+ }
+ imageList.add(image);
+ } catch (IOException e) {
+ EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath());
+ }
+ }
+ }
+ }
+
+ if (addonsImages.exists() && addonsImages.isDirectory()) {
+ BaseImage image;
+ for (File f : addonsImages.listFiles()) {
+ if (f.isDirectory()) {
+ try {
+ image = new BaseImage(this, f);
+ for (BaseImage i : imageList) {
+ if (i.getName().equals(image.getName())){
+ // TODO: duplicate name
+ EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )");
+ throw new IOException();
+ }
+ }
+ imageList.add(image);
+ } catch (IOException e) {
+ EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath());
+ }
+ }
+ }
+ }
+
+ // set image id
+ for (BaseImage i : imageList) {
+ if (i.getCpu().equals("x86")) {
+ i.setID(id++);
+ break;
+ }
+ }
+ for (BaseImage i : imageList) {
+ if (!i.getID().equals("1")) {
+ i.setID(id++);
+ }
+ }
+ }
+
+ public ArrayList<BaseImage> getImageList() {
+ return imageList;
+ }
+
+ public String getName() {
+ return platformName;
+ }
+
+ public void clearVMs() {
+ for (BaseImage base : imageList) {
+ base.clearVMsList();
+ }
+ }
+
/*
private void loadTemplate() {
// Common Template Path
}
*/
- private void loadProperties() {
- File dir = new File(platform_path);
- if (!dir.isDirectory()) {
- // TODO
- EMLogger.getLogger().info("This path is not directory." + platform_path);
- return;
- }
-
- File defaultImages = new File(platform_path + FilePath.getInstance().getDefaultImagePath());
- File addonsImages = new File(platform_path + FilePath.getInstance().getAddonsImagePath());
-
- //boolean isDuplicate = false;
- if(defaultImages.exists() && defaultImages.isDirectory()) {
- BaseImage image;
- for (File f : defaultImages.listFiles()) {
- if (f.isDirectory()) {
- try {
- image = new BaseImage(this, f);
- for (BaseImage i : imageList) {
- if (i.getName().equals(image.getName())){
- // TODO: duplicate name
- EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )");
- throw new IOException();
- }
- }
- imageList.add(image);
- } catch (IOException e) {
- EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath());
- }
- }
- }
- }
-
- if (addonsImages.exists() && addonsImages.isDirectory()) {
- BaseImage image;
- for (File f : addonsImages.listFiles()) {
- if (f.isDirectory()) {
- try {
- image = new BaseImage(this, f);
- for (BaseImage i : imageList) {
- if (i.getName().equals(image.getName())){
- // TODO: duplicate name
- EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )");
- throw new IOException();
- }
- }
- imageList.add(image);
- } catch (IOException e) {
- EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath());
- }
- }
- }
- }
-
- // set image id
- for (BaseImage i : imageList) {
- if (i.getCpu().equals("x86")) {
- i.setID(id++);
- break;
- }
- }
- for (BaseImage i : imageList) {
- if (!i.getID().equals("1")) {
- i.setID(id++);
- }
- }
- }
-
-
- public ArrayList<BaseImage> getImageList() {
- return imageList;
- }
-
+/*
public String getVersion() {
return version;
}
-
+*/
// TODO
/*
public Skins getSkin() {
*
*/
-package org.tizen.emulator.manager.image;
+package org.tizen.emulator.manager.platform;
import java.io.File;
import java.io.FileInputStream;
import java.util.logging.Level;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_TYPE;
public class Skin {
private String name;
- private String type;
- private String resolution;
+ private RESOLUTION resolution = null;
private String path;
+ private SKIN_TYPE type;
+
public Skin(File path) throws IOException {
loadProperty(path);
- for (RESOLUTION r : RESOLUTION.values()) {
- if(r.getValue().equals(resolution)) {
- this.type = r.getType();
- }
- }
}
private void loadProperty(File path) throws IOException {
this.path = path.getCanonicalPath();
- File f = new File(path + File.separator + StringResource.SKIN_INFO_FILENAME);
+ File f = new File(path + File.separator + StringResources.SKIN_INFO_FILENAME);
FileInputStream inputStream = null;
try {
if (f.exists()) {
inputStream = new FileInputStream(f);
Properties prop = new Properties();
prop.load(inputStream);
- name = prop.getProperty(StringResource.SKIN_NAME);
- String width = prop.getProperty(StringResource.SKIN_WIDTH);
- String height = prop.getProperty(StringResource.SKIN_HEIGHT);
+ name = prop.getProperty(StringResources.SKIN_NAME);
+ String width = prop.getProperty(StringResources.SKIN_WIDTH);
+ String height = prop.getProperty(StringResources.SKIN_HEIGHT);
- if(width.equals(StringResource.SKIN_GENERAL) && height.equals(StringResource.SKIN_GENERAL)) {
- resolution = StringResource.SKIN_GENERAL;
+ String re = "";
+ if(width.equals(StringResources.SKIN_GENERAL) && height.equals(StringResources.SKIN_GENERAL)) {
+ type = SKIN_TYPE.GENERAL;
} else {
- resolution = width + "x" + height;
+ type = SKIN_TYPE.PHONE_SHAPE;
+ re = width + "x" + height;
}
+
+ if (type == SKIN_TYPE.PHONE_SHAPE) {
+ for (RESOLUTION r : RESOLUTION.values()) {
+ if(r.getStrValue().equals(re)) {
+ this.resolution = r;
+ }
+ }
+ if (this.resolution == null) {
+ throw new IOException("This resolution is not supported ( + " +
+ re + ")");
+ }
+ }
+
} else {
throw new IOException("This file does not exist (" + path + ")");
}
this.name = name;
}
- public String getResolution() {
+ public RESOLUTION getResolution() {
return resolution;
}
- public void setResolution(String resolution) {
+ public void setResolution(RESOLUTION resolution) {
this.resolution = resolution;
}
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
public String getPath() {
return path;
}
this.path = path;
}
+ @ Override
public String toString() {
return name;
}
+ @ Override
public boolean equals(Object obj) {
if (!(obj instanceof Skin)) {
return false;
return false;
}
+ public SKIN_TYPE getType() {
+ return type;
+ }
}
*
*/
-package org.tizen.emulator.manager.image;
+package org.tizen.emulator.manager.platform;
import java.io.File;
+import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_TYPE;
public class SkinList {
- private ArrayList<Skins> skinsList = new ArrayList<Skins>();
private ArrayList<Skin> skinList = new ArrayList<Skin>();
//private Skins defaultSkin = null;
private SkinList() {
try {
- skinsList.add(new Skins(new File(FilePath.getInstance().getSkinPath())));
+ makeSkinList(new File(FilePath.getInstance().getSkinPath()));
//defaultSkin = skinsList.get(0);
} catch (IOException e) {
EMLogger.getLogger().warning(e.getMessage());
}
+ /*
try {
- skinsList.add(new Skins(new File(FilePath.getInstance().getDataSkinPath())));
+ makeSkinList(new File(FilePath.getInstance().getDataSkinPath()));
} catch (IOException e) {
EMLogger.getLogger().warning(e.getMessage());
}
+ */
- for (Skins skins : skinsList) {
- for (Skin s : skins.getSkinList()) {
- if (!skinList.contains(s)) {
- skinList.add(s);
+ }
+
+ private void makeSkinList(File dir) throws IOException {
+ if (dir.exists()) {
+ for (File skin : dir.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ if (!pathname.isDirectory()) {
+ return false;
+ }
+ return true;
}
+ })) {
+ Skin s = null;
+ try {
+ s = new Skin(skin);
+ } catch(IOException e) {
+ EMLogger.getLogger().warning("Error while skin information: " + e.getMessage());
+ continue;
+ }
+ skinList.add(s);
}
+ } else {
+ throw new IOException("This directory does not exist (" + dir.getPath() + ")");
}
}
- public ArrayList<Skins> getSkinsList() {
- return skinsList;
- }
-
public ArrayList<Skin> getSkinList() {
return skinList;
}
}
private ArrayList<Skin> returnSkins = new ArrayList<Skin>();
- public ArrayList<Skin> findSkinList(String resolution) {
+ public ArrayList<Skin> findSkinList(RESOLUTION resolution) {
boolean isGeneral = false;
returnSkins.clear();
if (skinList != null) {
for (Skin skin : skinList) {
- if (skin.getResolution().equals(resolution)) {
- returnSkins.add(skin);
- }
- if (skin.getResolution().equals(StringResource.SKIN_GENERAL)) {
+ if (skin.getType() == SKIN_TYPE.PHONE_SHAPE) {
+ if (skin.getResolution().equals(resolution)) {
+ returnSkins.add(skin);
+ }
+ } else {
if (!isGeneral) {
returnSkins.add(0, skin);
isGeneral = true;
returnSkins.clear();
if (skinList != null) {
for (Skin skin : skinList) {
- if (skin.getResolution().equals(StringResource.SKIN_GENERAL)) {
+ if (skin.getType() == SKIN_TYPE.GENERAL) {
returnSkins.add(skin);
}
}
}
*/
}
+
--- /dev/null
+/*\r
+ * Dynamic Analyzer\r
+ *\r
+ * Copyright(c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Jooyoul Lee <jy.exe.lee@samsung.com>\r
+ * Juyoung Kim <j0.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0(the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.emulator.manager.resources;\r
+\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+\r
+public enum ColorResources {\r
+ WHITE("white", null),\r
+ BLACK("black", null),\r
+ BLUE("blue", null),\r
+ RED("red", null),\r
+ YELLOW("yellow", null),\r
+ PURPLE("purple", null),\r
+\r
+ GREEN("green", null),\r
+ BROWN("brown", null),\r
+ NAVY("navy", null),\r
+ DARKVIOLET("darkviolet", null),\r
+ MAROON("maroon", null),\r
+ TEAL("teal", null),\r
+ INDIGO("indigo", null),\r
+ DARKGOLDENROD("darkgoldenrod", null),\r
+ CHOCOLATE("chocolate", null),\r
+ MAGNETA("magneta", null),\r
+\r
+ GOLDENROD("goldenrod", null),\r
+ TURQUOISE("turquoise", null),\r
+ VIOLET("violet", null),\r
+ SLATEBLUE("slateblue", null),\r
+ ORANGE("orange", null),\r
+ YELLOWGREEN("yellowgreen", null),\r
+ SKYBLUE("skyblue", null),\r
+ ORCHID("orchid", null),\r
+ SANDYBROWN("sandybrown", null),\r
+ MEDIUMPURPLE("mediumpurple", null),\r
+ GRAY1("gray1", null),\r
+ GRAY2("gray2", null),\r
+ GRAY3("gray3", null),\r
+\r
+ // shell window background color\r
+ WINDOW_BG_COLOR("window_bg_color", null),\r
+\r
+ DIALOG_BG_UPPER("dialg_bg_upper", null),\r
+ DIALOG_BG_LOWER("dialg_bg_lower", null),\r
+ DIALOG_SUNKEN_1("dialg_sunken_1", null),\r
+ DIALOG_SUNKEN_2("dialg_sunken_2", null),\r
+\r
+ EDIT_CHART_DIALOG_UPPER("edit_chart_dialog_upper", null),\r
+ EDIT_CHART_DIALOG_LOWER("edit_chart_dialog_lower", null),\r
+\r
+ VIEW_BORDER("view_border", null),\r
+ VIEW_BG_COLOR("view_bg_color", null),\r
+ VIEW_TITLE_FONT_COLOR("view_title_font_color", null),\r
+\r
+ /** title bar colors **/\r
+ TITLEBAR_TEXT_COLOR("titlebar_text_color", null),\r
+ TITLEBAR_BG_COLOR("titlebar_bg", null),\r
+ TITLEBAR_START_COLOR("titlebar_start_color", null),\r
+ TITLEBAR_END_COLOR("titlebar_end_color", null),\r
+ TITLEBAR_BOTTOM_STROKE_1("titlebar_bottom_stroke_1", null),\r
+ TITLEBAR_BOTTOM_STROKE_2("titlebar_bottom_stroke_2", null),\r
+\r
+ /** Coolbar bg color **/\r
+ COOLBAR_BG_COLOR("coolbar_bg_color", null),\r
+ DEFAULT_FONT_COLOR("default_font_color", null),\r
+\r
+ /** device and application combo specific colors start **/\r
+ DEVICE_APPLICATION_ENABLE("device_application_enable_font", null),\r
+ DEVICE_APPLICATION_DISABLE("device_application_disable", null),\r
+ DEVICE_APPLICATION_POPUP_OUTER_1("device_application_popup_outer_1", null),\r
+ DEVICE_APPLICATION_POPUP_OUTER_2("device_application_popup_outer_2", null),\r
+ DEVICE_APPLICATION_DROPDOWN_TEXT("device_application_enable_font", null),\r
+ DEVICE_APPLICATION_ITEM_NORMAL_TOP("device_application_item_normal_top", null),\r
+ DEVICE_APPLICATION_ITEM_NORMAL_INNER("device_application_item_normal_inner", null),\r
+ DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM("device_application_item_normal_bottom", null),\r
+ DEVICE_APPLICATION_ITEM_SELECT_TOP("device_application_item_select_top", new RGB(76, 76, 77)),\r
+ DEVICE_APPLICATION_ITEM_SELECT_INNER("device_application_item_select_inner", null),\r
+ DEVICE_APPLICATION_ITEM_SELECT_BOTTOM("device_application_item_select_bottom", null),\r
+\r
+ /*** combo button color ***/\r
+ DEVICE_APPLICATION_BUTTON_NORMAL_START("device_application_button_normal_start", null),\r
+ DEVICE_APPLICATION_BUTTON_NORMAL_END("device_application_button_normal_end", null),\r
+ DEVICE_APPLICATION_BUTTON_PUSH_START("device_application_button_push_start", null),\r
+ DEVICE_APPLICATION_BUTTON_PUSH_END("device_application_button_push_end", null),\r
+ DEVICE_APPLICATION_BUTTON_HOVER_START("device_application_button_hover_start", null),\r
+ DEVICE_APPLICATION_BUTTON_HOVER_END("device_application_button_hover_end", null),\r
+ DEVICE_APPLICATION_BUTTON_DISABLE_START("device_application_button_disable_start", null),\r
+ DEVICE_APPLICATION_BUTTON_DISABLE_END("device_application_button_disable_end", null),\r
+ DEVICE_APPLICATION_BUTTON_OUTLINE("device_application_button_outline", null),\r
+\r
+ /*** common button colors ***/\r
+ BUTTON_NORMAL_FONT_COLOR("button_normal_font_color", null),\r
+ BUTTON_PUSH_FONT_COLOR("button_push_font_color", null),\r
+ BUTTON_HOVER_FONT_COLOR("button_hover_font_color", null),\r
+ BUTTON_DISABLE_FONT_COLOR("button_disable_font_color", null),\r
+\r
+ /** normal view layout colors start **/\r
+ NORMAL_VIEW_LAYOUT_OUTER("normal_view_layout_outer", null),\r
+ NORMAL_VIEW_LAYOUT_MIDDLE("normal_view_layout_middle", null),\r
+ NORMAL_VIEW_LAYOUT_INNER("normal_view_layout_inner", null),\r
+ /** normal view layout colors end **/\r
+\r
+ /** tab widget colors start **/\r
+ TAB_SELECTED_FONT_COLOR("tab_selected_font_color", null),\r
+ TAB_NORMAL_FONT_COLOR("tab_normal_font_color", null),\r
+ TAB_HOVER_FONT_COLOR("tab_hover_font_color", null),\r
+ TAB_PUSH_FONT_COLOR("tab_push_font_color", null),\r
+\r
+ TAB_BG_COLOR("tab_bg_color", null),\r
+ TAB_CONTENTS_BG_COLOR("tab_contents_bg_color", null),\r
+ /** tab widget colors end **/\r
+\r
+ /** list view colors start **/\r
+ LIST_BG_COLOR("list_bg_color", null),\r
+ VM_BUTTON_FONT_COLOR("vm_button_font_color", null),\r
+ /** list view colors end **/\r
+\r
+ /** detail view colors start **/\r
+ DETAIL_VIEW_PAGE_COLOR("detail_view_page_color", null),\r
+ DETAIL_TOP_FONT_COLOR("detail_top_font_color", null),\r
+ DETAIL_TITILE_FONT_COLOR("detail_title_font_color", null),\r
+ DETAIL_ENABLE_FONT_COLOR("detail_enable_font_color", null),\r
+ DETAIL_DISABLE_FONT_COLOR("detail_disable_font_color", null),\r
+ DETAIL_CATEGORY_FONT_COLOR("detail_category_font_color", null),\r
+ DETAIL_TOP_COLOR("detail_top_color", null),\r
+ DETAIL_MIDDLE_COLOR("detail_middle_color", null),\r
+ DETAIL_INPUT_BOX_COLOR("detail_input_box_color", null),\r
+ /** detail view colors end **/\r
+\r
+ TOOLTIP("tooltip", null),\r
+\r
+ /** status bar **/\r
+ STATUS_BAR_COLOR("status_bar_color", null),\r
+ STATUS_BAR_FONT_COLOR("status_bar_font_color", null),\r
+\r
+ ITEM_BLUE_RIGHT("item_blue_right", null),\r
+ ITEM_BLUE_DARK("item_blue_dark", null);\r
+\r
+ String name;\r
+ Color color;\r
+ RGB rgb;\r
+\r
+ ColorResources(String name, RGB rgb) {\r
+ this.name = name;\r
+ this.rgb = rgb;\r
+ }\r
+\r
+ public Color getColor() {\r
+ if (this.color == null) {\r
+ if (rgb != null) {\r
+ this.color = DAThemeWhite.getInstance().getColor(name, rgb);\r
+ } else {\r
+ this.color = DAThemeWhite.getInstance().getColor(name);\r
+ }\r
+ }\r
+ return color;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name;\r
+ }\r
+\r
+ public static void dispose() {\r
+ for (ColorResources c : ColorResources.values()) {\r
+ c.color = null;\r
+ }\r
+ // TODO\r
+ }\r
+}\r
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.resources;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+class ColorRegistry {
+ private Map<String,Color> stringToColor = new HashMap<String, Color>(7);
+ private Map<String, RGB> stringToRGB = new HashMap<String, RGB>(7);
+ private Display display = null;
+ private final boolean cleanOnDisplayDisposal = true;
+
+ public ColorRegistry() {
+ this.display = Display.getCurrent();
+ }
+
+ private Color createColor(RGB rgb) {
+ if (this.display == null) {
+ Display display = Display.getCurrent();
+ if (display == null) {
+ throw new IllegalStateException();
+ }
+ this.display = display;
+ if (cleanOnDisplayDisposal) {
+ hookDisplayDispose();
+ }
+ }
+ return new Color(display, rgb);
+ }
+
+ private void disposeColors(Iterator<Color> iterator) {
+ while (iterator.hasNext()) {
+ Color next = iterator.next();
+ next.dispose();
+ }
+ }
+
+ public Color get(String symbolicName) {
+
+ assert symbolicName == null;
+
+ Color result = stringToColor.get(symbolicName);
+ if (result != null) {
+ return (Color) result;
+ }
+
+ Color color = null;
+
+ RGB rgb = stringToRGB.get(symbolicName);
+ if (rgb == null) {
+ return null;
+ }
+
+ color = createColor(rgb);
+
+ stringToColor.put(symbolicName, color);
+
+ return color;
+ }
+
+ public boolean hasValueFor(String colorKey) {
+ return stringToRGB.containsKey(colorKey);
+ }
+
+ private void hookDisplayDispose() {
+ display.disposeExec(displayRunnable);
+ }
+
+ public void put(String symbolicName, RGB colorData) {
+
+ assert symbolicName == null;
+ assert colorData == null;
+
+ RGB existing = (RGB) stringToRGB.get(symbolicName);
+ if (colorData.equals(existing)) {
+ return;
+ }
+
+ stringToRGB.put(symbolicName, colorData);
+ }
+
+ protected Runnable displayRunnable = new Runnable() {
+ public void run() {
+ clearCaches();
+ }
+ };
+
+ protected void clearCaches() {
+ disposeColors(stringToColor.values().iterator());
+ stringToColor.clear();
+ display = null;
+ }
+}
+
+public abstract class DATheme {
+ protected String name = "black";//$NON-NLS-1$
+ protected static ColorRegistry colorRegistry = new ColorRegistry();
+
+ public DATheme() {
+ setColor("white", new RGB(255, 255, 255)); //$NON-NLS-1$
+ setColor("black", new RGB(0, 0, 0)); //$NON-NLS-1$
+ setColor("blue", new RGB(0, 0, 255)); //$NON-NLS-1$
+ setColor("red", new RGB(255, 0, 0)); //$NON-NLS-1$
+ setColor("purple", new RGB(226, 101, 225)); //$NON-NLS-1$
+ }
+
+ public abstract Color getColor(String colorName, RGB rgb);
+
+ public abstract Color getColor(String colorName);
+
+ public abstract void setColor(String colorName, RGB rgb);
+
+ public String getThemePath() {
+ return "theme" + File.separator + name + File.separator;//$NON-NLS-1$
+ }
+
+ public String getImagePath() {
+ String path = getThemePath() + "img" + File.separator;//$NON-NLS-1$
+ return path;
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.resources;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+public class DAThemeWhite extends DATheme {
+ private static DAThemeWhite instance;
+
+ public static DAThemeWhite getInstance() {
+ if (instance == null) {
+ instance = new DAThemeWhite();
+ }
+ return instance;
+ }
+
+ DAThemeWhite() {
+ super();
+ name = "white";
+
+ // defaule
+ setColor("blue", new RGB(0, 102, 134));
+ setColor("green", new RGB(68, 98, 12));
+ setColor("yellow", new RGB(255, 210, 10));
+ setColor("purple", new RGB(139, 42, 118));
+ setColor("brown", new RGB(138, 83, 0));
+ setColor("navy", new RGB(57, 66, 161));
+ setColor("darkviolet", new RGB(105, 2, 126));
+ setColor("maroon", new RGB(126, 41, 2));
+ setColor("teal", new RGB(27, 110, 92));
+ setColor("indigo", new RGB(80, 26, 146));
+ setColor("goldenrod", new RGB(212, 150, 57));
+ setColor("turquoise", new RGB(72, 194, 168));
+ setColor("violet", new RGB(226, 109, 201));
+ setColor("slateblue", new RGB(122, 132, 238));
+ setColor("orange", new RGB(236, 107, 47));
+ setColor("yellowgreen", new RGB(129, 172, 50));
+ setColor("skyblue", new RGB(72, 185, 221));
+ setColor("orchid", new RGB(175, 49, 200));
+ setColor("sandybrown", new RGB(201, 168, 58));
+ setColor("mediumpurple", new RGB(160, 108, 224));
+ setColor("chocolate", new RGB(151, 124, 39));
+ setColor("magneta", new RGB(155, 20, 184));
+ setColor("GRAY1", new RGB(177, 177, 177)); //$NON-NLS-1$
+ setColor("GRAY2", new RGB(153, 153, 153)); //$NON-NLS-1$
+ setColor("GRAY3", new RGB(216, 216, 216)); //$NON-NLS-1$
+
+ // shell window background color
+ setColor("window_bg_color", new RGB(160, 160, 160)); //$NON-NLS-1$
+ setColor("dialg_bg_upper", new RGB(206, 206, 206));
+ setColor("dialg_bg_lower", new RGB(240, 240, 240));
+ setColor("dialg_sunken_1", new RGB(160, 160, 160));
+ setColor("dialg_sunken_2", new RGB(255, 255, 255));
+ setColor("edit_chart_dialog_upper", new RGB(255, 255, 255));
+ setColor("edit_chart_dialog_lower", new RGB(240, 240, 240));
+
+ setColor("view_border", new RGB(206, 206, 206)); //$NON-NLS-1$
+ setColor("view_bg_color", new RGB(230, 230, 230)); //$NON-NLS-1$
+ getColor("view_title_font_color", new RGB(0, 0, 0));
+
+ setColor("coolbar_bg_color", new RGB(228, 228, 228)); //$NON-NLS-1$
+ setColor("default_font_color", new RGB(0, 0, 0));//$NON-NLS-1$
+
+ /** title bar colors **/
+ setColor("titlebar_text_color", new RGB(64, 208, 255)); //$NON-NLS-1$
+ setColor("titlebar_bg", new RGB(78, 79, 81)); //$NON-NLS-1$
+ setColor("titlebar_start_color", new RGB(240, 240, 240)); //$NON-NLS-1$
+ setColor("titlebar_end_color", new RGB(165, 165, 165)); //$NON-NLS-1$
+ setColor("titlebar_bottom_stroke_1", new RGB(115, 115, 115));
+ setColor("titlebar_bottom_stroke_2", new RGB(160, 160, 160));
+
+ /** device and application combo specific colors start **/
+ setColor("device_application_enable_font", new RGB(0, 0, 0)); //$NON-NLS-1$
+ setColor("device_application_disable_font", new RGB(160, 160, 160)); //$NON-NLS-1$
+ setColor("device_application_popup_outer_1", new RGB(120, 120, 120)); //$NON-NLS-1$
+ setColor("device_application_popup_outer_2", new RGB(50, 185, 231)); //$NON-NLS-1$
+ setColor("device_application_item_normal_top", new RGB(255, 255, 255)); //$NON-NLS-1$
+ setColor("device_application_item_normal_inner", new RGB(230, 230, 230)); //$NON-NLS-1$
+ setColor(
+ "device_application_item_normal_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
+ setColor("device_application_item_select_top", new RGB(255, 255, 255)); //$NON-NLS-1$
+ setColor("device_application_item_select_inner", new RGB(50, 185, 231)); //$NON-NLS-1$
+ setColor(
+ "device_application_item_select_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
+ /** device and application combo specific colors end **/
+
+ /*** combo button gradation ***/
+ setColor("device_application_button_normal_start", new RGB(221, 221, 221)); //$NON-NLS-1$
+ setColor("device_application_button_normal_end", new RGB(157, 157, 157)); //$NON-NLS-1$
+ setColor("device_application_button_push_start", new RGB(24, 147, 189)); //$NON-NLS-1$
+ setColor("device_application_button_push_end", new RGB(24, 147, 189)); //$NON-NLS-1$
+ setColor("device_application_button_hover_start", new RGB(50, 185, 231)); //$NON-NLS-1$
+ setColor("device_application_button_hover_end", new RGB(50, 185, 231)); //$NON-NLS-1$
+ setColor("device_application_button_disable_start", new RGB(157, 157, 157)); //$NON-NLS-1$
+ setColor("device_application_button_disable_end", new RGB(78, 79, 81)); //$NON-NLS-1$
+ setColor("device_application_button_outline", new RGB(31, 31, 31));
+
+ /*** common button colors ***/
+ setColor("button_normal_font_color", new RGB(0, 0, 0));
+ setColor("button_push_font_color", new RGB(91, 91, 91));
+ setColor("button_hover_font_color", new RGB(91, 91, 91));
+ setColor("button_disable_font_color", new RGB(140, 140, 140));
+
+ /** normal view layout colors start **/
+ setColor("normal_view_layout_outer", new RGB(160, 160, 160)); //$NON-NLS-1$
+ setColor("normal_view_layout_middle", new RGB(74, 74, 74)); //$NON-NLS-1$
+ setColor("normal_view_layout_inner", new RGB(66, 66, 68)); //$NON-NLS-1$
+ /** normal view layout colors end **/
+
+ /** tab widget colors **/
+ setColor("tab_selected_font_color", new RGB(48, 48, 48));
+ setColor("tab_normal_font_color", new RGB(205, 205, 205));
+ setColor("tab_hover_font_color", new RGB(205, 205, 205));
+ setColor("tab_push_font_color", new RGB(205, 205, 205));
+
+ setColor("tab_bg_color", new RGB(55, 55, 55));
+ setColor("tab_contents_bg_color", new RGB(209, 209, 209));
+
+ /** list view colors **/
+ setColor("list_bg_color", new RGB(226, 226, 226));
+ setColor("vm_button_font_color", new RGB(240, 240, 240));
+ /**********************/
+
+ /** detail view colors **/
+ setColor("detail_view_page_color", new RGB(209, 209, 209)); //tab_contents_bg_color
+ setColor("detail_top_font_color", new RGB(255, 255, 255));
+ setColor("detail_title_font_color", new RGB(0, 0, 0));
+ setColor("detail_enable_font_color", new RGB(38, 38, 38));
+ setColor("detail_disable_font_color", new RGB(153, 153, 153));
+ setColor("detail_category_font_color", new RGB(255, 255, 255));
+ setColor("detail_top_color", new RGB(0x7F, 0x7F, 0x7F));
+ setColor("detail_middle_color", new RGB(0xB6, 0xB6, 0xB6));
+ setColor("detail_input_box_color", new RGB(229, 229, 229));
+ /************************/
+ setColor("tooltip", new RGB(255, 255, 225)); //$NON-NLS-1$
+
+ /** status bar **/
+ setColor("status_bar_color", new RGB(174, 174, 174));
+ setColor("status_bar_font_color", new RGB(0, 0, 0));
+
+ setColor("item_blue_right", new RGB(131, 196, 218));
+ setColor("item_blue_dark", new RGB(38, 104, 138));
+ }
+
+ public Color getColor(String colorName, RGB rgb) {
+ if (!colorRegistry.hasValueFor(colorName)) {
+ colorRegistry.put(colorName, rgb);
+ }
+ return colorRegistry.get(colorName);
+ }
+
+ public void setColor(String colorName, RGB rgb) {
+ colorRegistry.put(colorName, rgb);
+ }
+
+ @Override
+ public Color getColor(String colorName) {
+ return colorRegistry.get(colorName);
+ }
+
+}
*
*/
-package org.tizen.emulator.manager.tool;
+package org.tizen.emulator.manager.resources;
import java.io.BufferedReader;
import java.io.File;
import java.net.URISyntaxException;
import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
public class FilePath {
private final static String bin_suffix = File.separator + "tools" + File.separator + "emulator" + File.separator + "bin";
private final static String swap_suffix = File.separator + "swap";
private final static String data_suffix = File.separator +"data";
- private final static String sdkpath_suffix = File.separator + "tizensdkpath";
- private final static String sdkdata_suffix = File.separator + "tizen-sdk-data";
- private final static String win_sdb_exec = File.separator + "sdb.exe";
- private final static String sdb_exec = File.separator + "sdb";
+ final static String sdkpath_suffix = File.separator + "tizensdkpath";
+ final static String sdkdata_suffix = File.separator + "tizen-sdk-data";
+ final static String win_sdb_exec = File.separator + "sdb.exe";
+ final static String sdb_exec = File.separator + "sdb";
- private final static String storages_suffix = File.separator + "storages";
- private final static String sdcard_suffix = File.separator + "sdcard";
- private final static String template_suffix = File.separator + "templates";
+ final static String storages_suffix = File.separator + "storages";
+ final static String sdcard_suffix = File.separator + "sdcard";
+ final static String template_suffix = File.separator + "templates";
private static String currentPath;
private static String sdkPath = null;
skinPath = emulatorPath + skin_suffix;
templatePath = emulatorPath + template_suffix;
- workspacePath = EmulatorVMs.getInstance().getVMsBaseDirectory();
- vmsPath = EmulatorVMs.getInstance().getVMsConfigDirectory();
+ workspacePath = EmulatorVMList.getInstance().getVMsBaseDirectory();
+ vmsPath = EmulatorVMList.getInstance().getVMsConfigDirectory();
swapPath = workspacePath + swap_suffix;
dataSkinPath = workspacePath + skin_suffix;
- EmulatorVMs.makeSDKDataPath(tizenSDKDataPath);
+ EmulatorVMList.makeSDKDataPath(tizenSDKDataPath);
setVMSPath();
//testPrintPath();
}
public static void setVMSPath() {
- workspacePath = EmulatorVMs.getInstance().getVMsBaseDirectory();
- vmsPath = EmulatorVMs.getInstance().getVMsConfigDirectory();
+ workspacePath = EmulatorVMList.getInstance().getVMsBaseDirectory();
+ vmsPath = EmulatorVMList.getInstance().getVMsConfigDirectory();
swapPath = workspacePath + swap_suffix;
dataSkinPath = workspacePath + skin_suffix;
//testPrintPath();
--- /dev/null
+/*\r
+ * Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Jooyoul Lee <jy.exe.lee@samsung.com>\r
+ * Juyoung Kim <j0.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+package org.tizen.emulator.manager.resources;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Font;\r
+import org.eclipse.swt.graphics.FontData;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.tizen.emulator.manager.EmulatorManager;\r
+\r
+public enum FontResources {\r
+ // * Toolbal Layout\r
+ // Main Title\r
+ TITLEBAR("titlebar", resizeDefaultFont(10)),\r
+ // Device Name\r
+ COMBO("combo", resizeDefaultFont(9)),\r
+ // Application Name\r
+ DROPDOWN("dropdown", resizeDefaultFont(9)),\r
+ // Timer\r
+ TIMER("timer", resizeDefaultFont(12)),\r
+\r
+ // * Tab Layout\r
+ TAB_BUTTON_FONT("tab_button_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)),\r
+\r
+ // * List Layout\r
+ VM_BUTTON_TITLE_FONT("vm_button_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 8)),\r
+ VM_BUTTON_FONT("vm_button_font", resizeDefaultFont(8)),\r
+\r
+ // * Detail Layout\r
+ DETAIL_TOP_FONT("detail_top_font", setDefaultFontStyleAndSize(SWT.BOLD, 10)),\r
+ DETAIL_TITLE_FONT("detail_title_font", resizeDefaultFont(9)),\r
+ DETAIL_LABEL_FONT("datail_label_font", resizeDefaultFont(8)),\r
+\r
+ // * Nomal button\r
+ BUTTON_FONT("button_font", resizeDefaultFont(9)),\r
+\r
+ // * Combo button\r
+ COMBO_BUTTON_FONT("combo_button_font", resizeDefaultFont(8)),\r
+\r
+ // * About Dlg.\r
+ ABOUT_TITLE("about_title", resizeDefaultFont(12)),\r
+ ABOUT_TEXT("about_text", resizeDefaultFont(9)),\r
+ DIALOG_BUTTON_FONT("dialog_button_font", resizeDefaultFont(10)),\r
+\r
+ // * Status bar\r
+ STATUS_BAR_FONT("status_bar_font", resizeDefaultFont(9)),\r
+\r
+ // * not support\r
+ TOOLTIP("tooltip", resizeDefaultFont(9));\r
+\r
+ String name;\r
+ Font font;\r
+ FontData[] data;\r
+ FontResources(String name, FontData[] data) {\r
+ this.name = name;\r
+ this.data = data;\r
+ }\r
+\r
+ public Font getFont() {\r
+ return getFont(name, data);\r
+ }\r
+\r
+ public Font getFont(String fontName, FontData[] fontData) {\r
+ if (this.font == null) {\r
+ this.font = FontRegistry.getFont(name, data);\r
+ }\r
+ return font;\r
+ }\r
+\r
+ //private static FontRegistry fontRegistry = new FontRegistry();\r
+ private static Font defaultFont = null;\r
+ static {\r
+ defaultFont = getDADefaultFont();\r
+ }\r
+\r
+ public static FontData[] resizeDefaultFont(int size) {\r
+ if (defaultFont == null) {\r
+ defaultFont = getDADefaultFont();\r
+ }\r
+ FontData[] fontData = defaultFont.getFontData();\r
+ for (int i = 0; i < fontData.length; i++) {\r
+ fontData[i].setHeight(size);\r
+ }\r
+ return fontData;\r
+ }\r
+\r
+ public static FontData[] setDefaultFontStyle(int style) {\r
+ if (defaultFont == null) {\r
+ defaultFont = getDADefaultFont();\r
+ }\r
+ FontData[] fontData = defaultFont.getFontData();\r
+ for (int i = 0; i < fontData.length; i++) {\r
+ fontData[i].setStyle(style);\r
+ }\r
+ return fontData;\r
+ }\r
+\r
+ public static FontData[] setDefaultFontStyleAndSize(int style, int size) {\r
+ if (defaultFont == null) {\r
+ defaultFont = getDADefaultFont();\r
+ }\r
+ FontData[] fontData = defaultFont.getFontData();\r
+ for (int i = 0; i < fontData.length; i++) {\r
+ fontData[i].setStyle(style);\r
+ fontData[i].setHeight(size);\r
+ }\r
+ return fontData;\r
+ }\r
+\r
+ public static Font getDADefaultFont() {\r
+ String fontName = null;\r
+ if (EmulatorManager.isLinux()) {\r
+ fontName = "Dejavu Sans";\r
+ } else if (EmulatorManager.isWin()) {\r
+ fontName = "Verdana";\r
+ } else {\r
+ return Display.getCurrent().getSystemFont();\r
+ }\r
+ return FontRegistry.getFont(\r
+ "ex_font", new FontData[] { new FontData(fontName, 9, SWT.NORMAL) });\r
+ }\r
+}\r
+\r
+class FontRegistry {\r
+ private static Map<String, FontData[]> stringToFontData = null;\r
+ static {\r
+ if (stringToFontData == null) {\r
+ stringToFontData = new HashMap<String, FontData[]>(7);\r
+ }\r
+ }\r
+\r
+ public static Font getFont(String fontName, FontData[] fontData) {\r
+ if (stringToFontData == null) {\r
+ stringToFontData = new HashMap<String, FontData[]>(7);\r
+ }\r
+ if (!stringToFontData.containsKey(fontName)) {\r
+ stringToFontData.put(fontName, fontData);\r
+ }\r
+\r
+ return new Font(Display.getCurrent(), fontData);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 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>
+ * YeongKyoon Lee <yeongkyoon.lee@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.resources;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+enum ImageType {
+ PNG,GIF;
+}
+
+public enum ImageResources {
+ // PNG TYPE
+ CANCEL("cancel", ImageType.PNG),
+ CONFIRM("confirm", ImageType.PNG),
+ CREATE("create", ImageType.PNG),
+ DELETE("delete", ImageType.PNG),
+ DETAILS("details", ImageType.PNG),
+ FOLDER("folder", ImageType.PNG),
+ MODIFY("modify", ImageType.PNG),
+ REFRESH("refresh", ImageType.PNG),
+ RESET("reset", ImageType.PNG),
+ LAUNCH("launch", ImageType.PNG),
+ CREATEIMAGE("createimage", ImageType.PNG),
+ ABOUT("about", ImageType.PNG),
+ CLONE("clone", ImageType.PNG),
+ ARM("arm", ImageType.PNG),
+ X86("x86", ImageType.PNG),
+ ABOUTSDK("aboutSDK", ImageType.PNG),
+ COMBO_NORMAL("dropdown_normal", ImageType.PNG),
+ COMBO_HOVER("dropdown_hover", ImageType.PNG),
+ COMBO_PUSH("dropdown_push", ImageType.PNG),
+ COMBO_DISABLE("dropdown_disable", ImageType.PNG),
+ COMBO_DROPDOWN_UP("dropdown_up", ImageType.PNG),
+ COMBO_DROPDOWN_DOWN("dropdown_down", ImageType.PNG),
+
+ // GIF TYPE
+ TAB_SELECTED_LEFT("tab_selected_left"),
+ TAB_SELECTED_MIDDLE("tab_selected_middle"),
+ TAB_SELECTED_RIGHT("tab_selected_right"),
+ TAB_UNSELECTED_LEFT("tab_unselected_left"),
+ TAB_UNSELECTED_MIDDLE("tab_unselected_middle"),
+ TAB_UNSELECTED_RIGHT("tab_unselected_right"),
+ TAB_UNSELECTED_LEFT_HOVER("tab_unselected_left_hover"),
+ TAB_UNSELECTED_MIDDLE_HOVER("tab_unselected_middle_hover"),
+ TAB_UNSELECTED_RIGHT_HOVER("tab_unselected_right_hover"),
+
+ RESET_ICON_NOMAL("reset_icon_nml"),
+ RESET_ICON_HOVER("reset_icon_hover"),
+ RESET_ICON_PUSH("reset_icon_pushed"),
+ INFO_ICON_NOMAL("info_icon_nml"),
+ INFO_ICON_HOVER("info_icon_hover"),
+ INFO_ICON_PUSH("info_icon_pushed"),
+
+ DETAIL_LIST_TOP("detail_list_top"),
+ DETAIL_LIST_MIDDLE("detail_list_middle"),
+ DETAIL_LIST_BOTTOM("detail_list_bottom"),
+ DETAIL_LIST_ITEM("detail_list_item"),
+
+ CREATE_NEW_NOMAL("create_new_nml"),
+ CREATE_NEW_PUSH("create_new_pushed"),
+ CREATE_NEW_HOVER("create_new_hover"),
+
+ VM_IMAGE_NOMAL("emulator_list_image_nml"),
+ VM_IMAGE_HOVER("emulator_list_image_hover"),
+ VM_IMAGE_CREATE("emulator_list_image_new_ani"),
+ VM_IMAGE_SELECTED("emulator_list_selected"),
+
+ ADD_NEW_NOMAL("add_new_nml"),
+ ADD_NEW_HOVER("add_new_hover"),
+ ADD_NEW_PUSH("add_new_pushed"),
+
+ BUTTON_LAUNCH_NOMAL("button_launch_nml"),
+ BUTTON_LAUNCH_HOVER("button_launch_hover"),
+ BUTTON_LAUNCH_PUSH("button_launch_pushed"),
+
+ INPUTBOX_OFF_LEFT("inputbox_off_left"),
+ INPUTBOX_OFF_MIDDLE("inputbox_off_middle"),
+ INPUTBOX_OFF_RIGHT("inputbox_off_right"),
+ INPUTBOX_ON_LEFT("inputbox_on_left"),
+ INPUTBOX_ON_MIDDLE("inputbox_on_middle"),
+ INPUTBOX_ON_RIGHT("inputbox_on_right"),
+ CATEGORYBOX_RIGHT("detail_category_right"),
+ CATEGORYBOX_MIDDLE("detail_category_middle"),
+ CATEGORYBOX_LEFT("detail_category_left"),
+
+ MODIFY_BUTTON_HOVER("modify_hover"),
+ MODIFY_BUTTON_NOMAL("modify_nml"),
+ MODIFY_BUTTON_PUSH("modify_pushed"),
+
+ CANCEL_BUTTON_HOVER("modify_cancel_hover"),
+ CANCEL_BUTTON_NOMAL("modify_cancel_nml"),
+ CANCEL_BUTTON_PUSH("modify_cancel_pushed"),
+
+ BUTTON_FILE_NOMAL("button_file_nml"),
+ BUTTON_FILE_HOVER("button_file_hover"),
+ BUTTON_FILE_PUSH("button_file_pushed"),
+ BUTTON_FILE_DISABLE("button_file_dis"),
+
+ ARROW_DOWN("arrow_down"),
+ ARROW_UP("arrow_up"),
+
+ ARROW_DROPDOWN("dropdown_arrow"),
+
+ TOGGLE_ON_NOMAL("button_on_nml"),
+ TOGGLE_ON_HOVER("button_on_hover"),
+ TOGGLE_ON_PUSH("button_on_pushed"),
+
+ TOGGLE_OFF_NOMAL("button_off_nml"),
+ TOGGLE_OFF_HOVER("button_off_hover"),
+ TOGGLE_OFF_PUSH("button_off_pushed"),
+
+ BUTTON_NOMAL_LEFT("button_nml_left"),
+ BUTTON_NOMAL_MIDDLE("button_nml_middle"),
+ BUTTON_NOMAL_RIGHT("button_nml_right"),
+
+ BUTTON_HOVER_LEFT("button_hover_left"),
+ BUTTON_HOVER_MIDDLE("button_hover_middle"),
+ BUTTON_HOVEr_RIGHT("button_hover_right");
+
+ String name;
+ Image image;
+ ImageType type;
+
+ ImageResources(String name) {
+ this.name = name;
+ this.type = ImageType.GIF;
+ }
+
+ ImageResources(String name, ImageType type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Image getImage() {
+ if (this.image == null) {
+ switch(this.type) {
+ case GIF:
+ this.image = ImageRegistry.getGifImage(name);
+ break;
+ case PNG:
+ this.image = ImageRegistry.getPngImage(name);
+ }
+ }
+ return image;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public static void dispose() {
+ for (ImageResources r : ImageResources.values()) {
+ r.image = null;
+ }
+ ImageRegistry.dispose();
+ }
+}
+
+class ImageRegistry {
+ //private static final String ID = "org.tizen.dynamicanalyzer";
+ private static Map<String, Image> map = new HashMap<String, Image>();
+
+ public static Image getImage(String key, String folderName, String extension) {
+ return null;
+ }
+
+ public static void dispose() {
+ for (Image i : map.values()) {
+ i.dispose();
+ }
+ }
+
+ /*
+ private static DATheme getTheme() {
+ return AnalyzerManager.getTheme();
+ }
+
+ private static Image getImage(String imageName, String extension) {
+ return getImage(ID, getTheme().getImagePath(), imageName, extension);
+ }
+ */
+
+ public static Image getPngImage(String name) {
+ Image i = map.get(name);
+ if (i == null) {
+ ClassLoader loader = ImageRegistry.class.getClassLoader();
+ InputStream is = loader.getResourceAsStream("res/" + name + ".png");
+ if (is != null) {
+ i = new Image(Display.getCurrent(), is);
+ map.put(name, i);
+ }
+ }
+ return i;
+ }
+
+ public static Image getGifImage(String name) {
+ Image i = map.get(name);
+ if (i == null) {
+ ClassLoader loader = ImageRegistry.class.getClassLoader();
+ InputStream is = loader.getResourceAsStream("res/" + name + ".gif");
+ if (is != null) {
+ i = new Image(Display.getCurrent(), is);
+ map.put(name, i);
+ }
+ }
+ return i;
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.resources;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+public class PatchImageResources {
+ public static Image getNomalButton(int width) {
+ Image left = ImageResources.BUTTON_NOMAL_LEFT.getImage();
+ Image middle = ImageResources.BUTTON_NOMAL_MIDDLE.getImage();
+ Image right = ImageResources.BUTTON_NOMAL_RIGHT.getImage();
+
+ int height = left.getImageData().height;
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ gc.drawImage(left, 0, 0);
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width + right.getImageData().width, height);
+ gc.drawImage(right, width - right.getImageData().width, 0);
+ return image;
+ }
+
+ public static Image getHoverButton(int width) {
+ Image left = ImageResources.BUTTON_HOVER_LEFT.getImage();
+ Image middle = ImageResources.BUTTON_HOVER_MIDDLE.getImage();
+ Image right = ImageResources.BUTTON_HOVEr_RIGHT.getImage();
+
+ int height = left.getImageData().height;
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ gc.drawImage(left, 0, 0);
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width + right.getImageData().width, height);
+ gc.drawImage(right, width - right.getImageData().width, 0);
+ return image;
+ }
+
+ public static Image getCategoryBox(int width) {
+ Image left = ImageResources.CATEGORYBOX_LEFT.getImage();
+ Image middle = ImageResources.CATEGORYBOX_MIDDLE.getImage();
+
+ int height = middle.getImageData().height;
+ Image image = new Image(Display.getCurrent(), width, height);
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ // left
+ gc.drawImage(left, 0, 0);
+
+ // middle
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width * 2, height);
+
+ // right
+ gc.drawImage(ImageResources.CATEGORYBOX_RIGHT.getImage(),
+ width - left.getImageData().width, 0);
+
+ gc.dispose();
+ return image;
+ }
+
+ public static Image getInputBoxON(int width) {
+ Image left = ImageResources.INPUTBOX_ON_LEFT.getImage();
+ Image middle = ImageResources.INPUTBOX_ON_MIDDLE.getImage();
+
+ int height = middle.getImageData().height;
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ // left
+ gc.drawImage(left, 0, 0);
+
+ // middle
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width * 2, height);
+
+ // right
+ gc.drawImage(ImageResources.INPUTBOX_ON_RIGHT.getImage(),
+ width - left.getImageData().width, 0);
+
+ gc.dispose();
+ return image;
+ }
+
+ public static Image getInputBoxOff(int width) {
+ Image left = ImageResources.INPUTBOX_OFF_LEFT.getImage();
+ Image middle = ImageResources.INPUTBOX_OFF_MIDDLE.getImage();
+
+ int height = middle.getImageData().height;
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ // left
+ gc.drawImage(left, 0, 0);
+
+ // middle
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width * 2, height);
+
+ // right
+ gc.drawImage(ImageResources.INPUTBOX_OFF_RIGHT.getImage(),
+ width - left.getImageData().width, 0);
+
+ gc.dispose();
+ return image;
+ }
+
+ public static Image getSelectTabFolder(int width, int height) {
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+
+ // left
+ Image left = ImageResources.TAB_SELECTED_LEFT.getImage();
+ gc.drawImage(left, 0, 0);
+
+ // middle
+ Image middle = ImageResources.TAB_SELECTED_MIDDLE.getImage();
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ left.getImageData().width, 0,
+ width - left.getImageData().width * 2, height);
+
+ // right
+ gc.drawImage(ImageResources.TAB_SELECTED_RIGHT.getImage(),
+ width - left.getImageData().width , 0);
+
+ gc.dispose();
+
+ return image;
+ }
+
+ public static Image getUnselectedTabFolder(int width, int height) {
+
+ Image left = ImageResources.TAB_UNSELECTED_LEFT.getImage();
+ Image middle = ImageResources.TAB_UNSELECTED_MIDDLE.getImage();
+ Image right = ImageResources.TAB_UNSELECTED_RIGHT.getImage();
+
+ int leftWidth = left.getImageData().width;
+ int rightWidth = right.getImageData().width;
+
+ Image image = new Image(Display.getCurrent(),
+ width + leftWidth + rightWidth, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, image.getImageData().width, image.getImageData().height);
+
+ gc.drawImage(left, 0, 0);
+
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ leftWidth, 0,
+ width - (leftWidth + rightWidth), height);
+
+ // right
+ gc.drawImage(right, width - leftWidth , 0);
+
+ gc.dispose();
+
+ return image;
+ }
+
+ public static Image getUnselectedTabFolderHover(int width, int height) {
+ Image left = ImageResources.TAB_UNSELECTED_LEFT_HOVER.getImage();
+ Image middle = ImageResources.TAB_UNSELECTED_MIDDLE_HOVER.getImage();
+ Image right = ImageResources.TAB_UNSELECTED_RIGHT_HOVER.getImage();
+
+ int leftWidth = left.getImageData().width;
+ int rightWidth = right.getImageData().width;
+
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, image.getImageData().width, image.getImageData().height);
+
+ gc.drawImage(left, 0, 0);
+
+ gc.drawImage(middle, 0, 0,
+ middle.getImageData().width, middle.getImageData().height,
+ leftWidth, 0,
+ width - (leftWidth + rightWidth), height);
+
+ // right
+ gc.drawImage(right, width - leftWidth , 0);
+
+ gc.dispose();
+
+ return image;
+ }
+
+ public static Image getDetailListView2(int count) {
+ Image top = ImageResources.DETAIL_LIST_TOP.getImage();
+ Image middle = ImageResources.DETAIL_LIST_MIDDLE.getImage();
+ Image bottom = ImageResources.DETAIL_LIST_BOTTOM.getImage();
+
+ Image image = new Image(Display.getCurrent(),
+ top.getImageData().width,
+ top.getImageData().height + middle.getImageData().height * (count-1)
+ + bottom.getImageData().height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, image.getImageData().width, image.getImageData().height);
+
+ gc.drawImage(top, 0, 0);
+
+ for (int i = 0; i < (count-1); i++) {
+ gc.drawImage(middle, 0,
+ top.getImageData().height + (middle.getImageData().height * i));
+ }
+
+ gc.drawImage(bottom, 0, image.getImageData().height - bottom.getImageData().height);
+
+ gc.dispose();
+
+ return image;
+ }
+
+ public static Image getDetailListView(int count) {
+ Image middle = ImageResources.DETAIL_LIST_MIDDLE.getImage();
+ Image bottom = ImageResources.DETAIL_LIST_BOTTOM.getImage();
+
+ Image image = new Image(Display.getCurrent(),
+ middle.getImageData().width,
+ middle.getImageData().height * (count-1)
+ + bottom.getImageData().height);
+
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, image.getImageData().width, image.getImageData().height);
+
+ for (int i = 0; i < (count-1); i++) {
+ gc.drawImage(middle, 0,
+ (middle.getImageData().height * i));
+ }
+
+ gc.drawImage(bottom, 0, image.getImageData().height - bottom.getImageData().height);
+
+ gc.dispose();
+
+ return image;
+ }
+}
*
*/
-package org.tizen.emulator.manager.tool;
+package org.tizen.emulator.manager.resources;
-public class StringResource {
+public class StringResources {
// VMsProperty View
- public final static String SUPPORTED = "Enabled";
- public final static String NOT_SUPPORTED = "Disabled";
+ public final static String SUPPORTED = "ON";
+ public final static String NOT_SUPPORTED = "OFF";
public final static String MANUAL_SUPPORT = "Manual support";
- public final static String None = "( None )";
+ public final static String None = "";
// key type
public final static String ONE_KEY = "1key";
public final static String THREE_KEYS = "3keys";
public static final String DELETE = "Delete";
public static final String RESET = "Reset";
public static final String CLONE = "Clone";
- public static final String CREATE_IMAGE = "Create Base Image";
+ public static final String CREATE_IMAGE = "Create Image";
// Select Workspace and Dialog
public static final String WORKSPACE_NAME = ".tizen-vms-path";
public static final String ARM = "ARM";
//About Dialog
+ public static final String UNDEFINED = "undefined";
public static final String ABOUT_PROP_FILENAME = "about.properties";
public static final String PROP_KEY_VERSION = "version";
public static final String PROP_KEY_BUILD_TIME = "build_time";
public static final String SKIN_WIDTH = "resolution.width";
public static final String SKIN_HEIGHT = "resolution.height";
public static final String SKIN_GENERAL = "all";
-
+ public static final String SKIN_PHONE_SHAPE = "shape";
// SD card
public static final String SD_CARD_DIR = "sdcard";
public static final String[] SD_CARD = {"sdcard_ext4_4G.img", "sdcard_ext4_8G.img", "sdcard_ext4_16G.img","sdcard_ext4_32G.img"};
import java.util.logging.Level;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
public class About {
private static About about = null;
}
private About() {
- workspace = EmulatorVMs.getInstance().getVMsBaseDirectory();
+ workspace = EmulatorVMList.getInstance().getVMsBaseDirectory();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(StringResource.ABOUT_PROP_FILENAME );
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(StringResources.ABOUT_PROP_FILENAME );
Properties properties = new Properties();
String ver = null;
if(in != null) {
try {
properties.load(in);
- //ver = properties.getProperty(StringResource.PROP_KEY_VERSION);
- time = properties.getProperty(StringResource.PROP_KEY_BUILD_TIME);
- gitVersion = properties.getProperty(StringResource.PROP_KEY_GIT_VERSION);
+ //ver = properties.getProperty(StringResources.PROP_KEY_VERSION);
+ time = properties.getProperty(StringResources.PROP_KEY_BUILD_TIME);
+ gitVersion = properties.getProperty(StringResources.PROP_KEY_GIT_VERSION);
} catch (IOException e1) {
EMLogger.getLogger().log(Level.SEVERE, e1.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
- // TODO Auto-generated catch block
EMLogger.getLogger().log(Level.SEVERE, e.getMessage());
}
}
//BaseImage image = Platforms.getInstance().getImageList().get(0);
//about_version = image.getRelease();
//version = image.getVersion();
- about_version = "undefined";
- version = "standard";
+ about_version = StringResources.UNDEFINED;
+ version = StringResources.UNDEFINED;
} else {
if (ver.indexOf('(') == -1) {
about_version = version = ver;
about_version = ver.substring(start+1, end);
}
}
- if(time.isEmpty() || time.contains(StringResource.PROP_KEY_BUILD_TIME)) {
- time = "undefined";
+ if(time.isEmpty() || time.contains(StringResources.PROP_KEY_BUILD_TIME)) {
+ time = StringResources.UNDEFINED;
}
- if(gitVersion.isEmpty() || gitVersion.contains(StringResource.PROP_KEY_GIT_VERSION)) {
- gitVersion = "undefined";
+ if(gitVersion.isEmpty() || gitVersion.contains(StringResources.PROP_KEY_GIT_VERSION)) {
+ gitVersion = StringResources.UNDEFINED;
}
if(workspace.isEmpty()) {
- workspace = "undefined";
+ workspace = StringResources.UNDEFINED;
}
contents = String.format("%-12s : %s\n%-12s : %s\n%-12s : %s\n%-12s : %s",
import java.util.logging.Level;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
public class CheckSDCard {
private CheckSDCard() {
File dest = null;
File src = null;
dest = new File(FilePath.getInstance().getSwapPath()
- + File.separator + StringResource.SWAP_IMAGE);
+ + File.separator + StringResources.SWAP_IMAGE);
if (!dest.exists()) {
src = new File(FilePath.getInstance().getbaseSwapPath()
- + File.separator + StringResource.SWAP_IMAGE);
+ + File.separator + StringResources.SWAP_IMAGE);
if (!src.exists()) {
EMLogger.getLogger().log(Level.WARNING,
- "Failed to create swap image.!" + StringResource.NEW_LINE
+ "Failed to create swap image.!" + StringResources.NEW_LINE
+ "File does not exist :" + src.getPath());
return;
}
dest.createNewFile();
} catch (IOException e1) {
EMLogger.getLogger().log(Level.WARNING,
- "Failed to create swap image!" + StringResource.NEW_LINE + e1.getMessage());
+ "Failed to create swap image!" + StringResources.NEW_LINE
+ + e1.getMessage());
return;
}
fcin.transferTo(0, size, fcout);
} catch (FileNotFoundException e) {
EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
- + StringResource.NEW_LINE + e.getMessage());
+ + StringResources.NEW_LINE + e.getMessage());
dest.delete();
} catch (IOException e) {
EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
- + StringResource.NEW_LINE + e.getMessage());
+ + StringResources.NEW_LINE + e.getMessage());
dest.delete();
}finally {
try {
public static void CheckSDCardDir() {
File dir = new File(FilePath.getInstance().getTizenWorkspacePath()
- + File.separator + StringResource.SD_CARD_DIR);
+ + File.separator + StringResources.SD_CARD_DIR);
if (!dir.exists()) {
dir.mkdir();
File dest = null;
File src = null;
- for (String s : StringResource.SD_CARD) {
+ for (String s : StringResources.SD_CARD) {
dest = new File(FilePath.getInstance().getTizenWorkspacePath()
- + File.separator + StringResource.SD_CARD_DIR
+ + File.separator + StringResources.SD_CARD_DIR
+ File.separator + s);
if (!dest.exists()) {
src = new File(FilePath.getInstance().getSDCardPath()
+ File.separator +s);
if (!src.exists()) {
EMLogger.getLogger().log(Level.WARNING,
- "Failed to create SD card image.!" + StringResource.NEW_LINE +"File does not exist :" + src.getPath());
+ "Failed to create SD card image.! + StringResources.NEW_LINE"
+ + "File does not exist :" + src.getPath());
continue;
}
dest.createNewFile();
} catch (IOException e1) {
EMLogger.getLogger().log(Level.WARNING,
- "Failed to create SD card image!" + StringResource.NEW_LINE + e1.getMessage());
+ "Failed to create SD card image!" + StringResources.NEW_LINE + e1.getMessage());
continue;
}
long size = fcin.size();
fcin.transferTo(0, size, fcout);
} catch (FileNotFoundException e) {
- EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
- + StringResource.NEW_LINE + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
+ + StringResources.NEW_LINE + e.getMessage());
dest.delete();
continue;
} catch (IOException e) {
- EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
- + StringResource.NEW_LINE + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "Failed to create SD card image!"
+ + StringResources.NEW_LINE + e.getMessage());
dest.delete();
continue;
}finally {
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
public class CheckVirtualization {
private static CheckVirtualization instance = new CheckVirtualization();
process = pb.start();
process.waitFor();
exitValue = process.exitValue();
- EMLogger.getLogger().log(Level.WARNING, "'check-gl's exit value : " + exitValue);
+ EMLogger.getLogger().log(Level.INFO, "'check-gl's exit value : " + exitValue);
} catch (IOException e) {
EMLogger.getLogger().log(Level.WARNING, "IOException" + e.getMessage());
} catch (InterruptedException e) {
Label label = new Label(dialog, SWT.NONE);
label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true));
- label.setText("Please wait !!\nCheck whether virtualization is supported.");
+ label.setText("Please wait !!" + StringResources.NEW_LINE + "Check whether virtualization is supported.");
}
public void open() {
public void close() {
dialog.close();
}
-}
+}
\ No newline at end of file
import javax.xml.transform.stream.StreamSource;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.vms.VMsProperty;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
// TOOD
public class SelectTemplate {
- private VMsProperty defaultTemplate = null;
- private ArrayList<VMsProperty> templateList;
+ private VMProperty defaultTemplate = null;
+ private ArrayList<VMProperty> templateList;
private static SelectTemplate instance = null;
static {
// Common Template Path
File dir = new File(FilePath.getInstance().getTemplatePath());
if (dir.exists()) {
- templateList = new ArrayList<VMsProperty>();
+ templateList = new ArrayList<VMProperty>();
for (File config : dir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (!pathname.isFile()) {
return true;
}
})) {
- VMsProperty property = parseXML(config);
+ VMProperty property = parseXML(config);
if (property != null) {
templateList.add(property);
}
}
}
- private VMsProperty parseXML(File configFile) {
+ private VMProperty parseXML(File configFile) {
JAXBContext context = null;
JAXBElement<EmulatorConfiguration> element = null;
return null;
}
- return new VMsProperty(configFile, element.getValue());
+ return new VMProperty(configFile, element.getValue());
}
- public VMsProperty getDefaultTemplate() {
+ public VMProperty getDefaultTemplate() {
return defaultTemplate;
}
- public void setDefaultTemplate(VMsProperty defaultTemplate) {
+ public void setDefaultTemplate(VMProperty defaultTemplate) {
this.defaultTemplate = defaultTemplate;
}
}
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.ui.SelectWorkspaceDialog;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.ui.dialog.SelectWorkspaceDialog;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
public class SelectWorkspace {
private static Properties prop = null;
prop = new Properties();
}
- String workspaceConfPath = EmulatorVMs.getInstance().getTizenSdkDataPath()
- + File.separator + StringResource.WORKSPACE_NAME;
+ String workspaceConfPath = EmulatorVMList.getInstance().getTizenSdkDataPath()
+ + File.separator + StringResources.WORKSPACE_NAME;
FileInputStream inputStream = null;
try {
}
if (result) {
- String path = prop.getProperty(StringResource.RECENT_VMS_PATH);
+ String path = prop.getProperty(StringResources.RECENT_VMS_PATH);
if (!path.isEmpty()) {
- EmulatorVMs.getInstance().setVMsBaseDirectory(path);
+ EmulatorVMList.getInstance().setVMsBaseDirectory(path);
}
}
out = new BufferedWriter(writer);
try {
- out.write(StringResource.SHOW_SELECTION_DIAGLOG + "=false\n");
- out.write(StringResource.RECENT_VMS_PATH + "=\n");
- out.write(StringResource.MAC_ADDRESS + "=\n");
+ out.write(StringResources.SHOW_SELECTION_DIAGLOG + "=false\n");
+ out.write(StringResources.RECENT_VMS_PATH + "=\n");
+ out.write(StringResources.MAC_ADDRESS + "=\n");
} catch (IOException e1) {
prop = null;
return;
}
return dialog.getSelectedPath();
} else if (show.equals("false")) {
- return prop.getProperty(StringResource.RECENT_VMS_PATH);
+ return prop.getProperty(StringResources.RECENT_VMS_PATH);
}
}
return null;
public static String getWorkspaceConfPath() {
String workspaceConfPath = null;
- workspaceConfPath = EmulatorVMs.getInstance().getTizenSdkDataPath()
- + File.separator + StringResource.WORKSPACE_NAME;
+ workspaceConfPath = EmulatorVMList.getInstance().getTizenSdkDataPath()
+ + File.separator + StringResources.WORKSPACE_NAME;
return workspaceConfPath;
}
}
private static String getMACaddrFromHost() {
- int isLinux = System.getProperty("os.name").toLowerCase()
- .indexOf("linux");
- int isWindows = System.getProperty("os.name").toLowerCase()
- .indexOf("windows");
- int isMac = System.getProperty("os.name").toLowerCase()
- .indexOf("mac");
try {
- if (isLinux > -1) {
+ if (EmulatorManager.isLinux()) {
getMACaddrFromLinuxHost();
- } else if (isWindows > -1) {
+ } else if (EmulatorManager.isWin()) {
getMACaddrFromWindowsHost();
- }else if (isMac > -1) {
+ }else if (EmulatorManager.isMac()) {
getMACaddrFromMacHost();
}
} catch (SocketException e) {
boolean isModify = false;
String workspaceConfPath = null;
if (isSave) {
- workspaceConfPath = EmulatorVMs.getInstance().getTizenSdkDataPath()
- + File.separator + StringResource.WORKSPACE_NAME;
+ workspaceConfPath = EmulatorVMList.getInstance().getTizenSdkDataPath()
+ + File.separator + StringResources.WORKSPACE_NAME;
if (prop == null) {
prop = new Properties();
}
String show = "false";
if (prop != null) {
- oldShow = prop.getProperty(StringResource.SHOW_SELECTION_DIAGLOG);
- oldPath = prop.getProperty(StringResource.RECENT_VMS_PATH);
- macAddr = prop.getProperty(StringResource.MAC_ADDRESS);
+ oldShow = prop.getProperty(StringResources.SHOW_SELECTION_DIAGLOG);
+ oldPath = prop.getProperty(StringResources.RECENT_VMS_PATH);
+ macAddr = prop.getProperty(StringResources.MAC_ADDRESS);
if (! EmulatorManager.isConsoleMode()) {
show = oldShow;
macAddr = "";
macAddr = getMACaddrFromHost();
if(macAddr != null) {
- prop.setProperty(StringResource.MAC_ADDRESS, macAddr);
+ prop.setProperty(StringResources.MAC_ADDRESS, macAddr);
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(workspaceConfPath);
} else if (macAddr.isEmpty()) {
macAddr = getMACaddrFromHost();
if(macAddr != null) {
- prop.setProperty(StringResource.MAC_ADDRESS, macAddr);
+ prop.setProperty(StringResources.MAC_ADDRESS, macAddr);
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(workspaceConfPath);
if (workspacePath != null && !workspacePath.isEmpty()) {
if (prop != null) {
if (show != oldShow) {
- prop.setProperty(StringResource.SHOW_SELECTION_DIAGLOG, show);
+ prop.setProperty(StringResources.SHOW_SELECTION_DIAGLOG, show);
isModify = true;
}
if (!workspacePath.equals(oldPath)) {
- prop.setProperty(StringResource.RECENT_VMS_PATH, workspacePath);
+ prop.setProperty(StringResources.RECENT_VMS_PATH, workspacePath);
isModify = true;
}
}
}
}
- EmulatorVMs.getInstance().setVMsBaseDirectory(workspacePath);
+ EmulatorVMList.getInstance().setVMsBaseDirectory(workspacePath);
//FilePath.setVMSPath();
}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
-
-public class ArchitectureGroup {
- //MainDialog dialog;
- Group group;
- Button x86RadioButton;
- Button armRadioButton;
-
-
- public ArchitectureGroup(final MainDialog dialog, Composite archComposite) {
- //this.dialog = dialog;
-
- group = new Group(archComposite, SWT.NONE);
-
- group.setText(StringResource.GROUP_TITLE);
- group.setLayout(new GridLayout(2, false));
-
- x86RadioButton = new Button(group, SWT.RADIO);
- x86RadioButton.setData(Architecture.x86);
- x86RadioButton.setText(StringResource.X86);
- x86RadioButton.setSelection(true);
-
- armRadioButton = new Button(group, SWT.RADIO);
- armRadioButton.setData(Architecture.ARM);
- armRadioButton.setText(StringResource.ARM);
- armRadioButton.setSelection(false);
- // TODO : not support ARM
- armRadioButton.setEnabled(false);
-
- SelectionListener archSelectionListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- dialog.refreshVMsTable();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- dialog.refreshVMsTable();
- }
-
- };
-
- x86RadioButton.addSelectionListener(archSelectionListener);
- armRadioButton.addSelectionListener(archSelectionListener);
- }
-
- public void setLayoutData(Object data) {
- group.setLayoutData(data);
- }
-}
package org.tizen.emulator.manager.ui;
import java.io.InputStream;
-
+import java.util.ArrayList;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.ui.detail.DetailTableView;
-import org.tizen.emulator.manager.ui.vmstree.VMsTree;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.dialog.AboutDialog;
+import org.tizen.emulator.manager.ui.tabfolder.PlatformTabFolder;
+import org.tizen.emulator.manager.ui.tabfolder.PlatformTabItem;
public class MainDialog {
private static final String ICON_FILE_NAME = "res/em.ico";
- SashForm sashForm;
- //ArchitectureGroup archGroup;
-
- // ToolItems...
- ToolItem aboutItem;
- ToolItem refreshItem;
- ToolItem resetItem;
- ToolItem deleteItem;
- ToolItem cloneItem;
- ToolItem createImageItem;
-// ToolItem modifyItem;
-
-
- ToolItem x86ToggleItem;
- ToolItem armToggleItem;
-
- // LEFT VIEW
- VMsTree vmsTree;
-
- // RIGHT VIEW
- DetailTableView detailView;
- // Launch, Confirm
- Button leftButton;
- // Create, Modify, Cancel
- Button rightButton;
+ public static final int WIDTH = 840;
+ public static final int HEIGHT = 482;
- MenuHandling handling;
-
- Shell shell;
+ static Shell shell = null;
Image icon;
public MainDialog(ManagerModeType mode) {
Display.setAppName("Emulator Manager");
- shell = new Shell(Display.getCurrent());
- shell.setSize(700, 500);
+ shell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.TITLE | SWT.MIN);
+ //
+ shell.setBackground(ColorResources.TAB_BG_COLOR.getColor());
+ //
+ shell.setLayout(new FillLayout());
+
+ final Menu bar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(bar);
+
+ shell.addShellListener(new ShellListener() {
+ public void shellIconified(ShellEvent e) {
+ }
+ public void shellDeiconified(ShellEvent e) {
+ }
+ public void shellDeactivated(ShellEvent e) {
+ }
+ public void shellClosed(ShellEvent e) {
+ }
+ public void shellActivated(ShellEvent e) {
+ int frameX = shell.getSize().x - shell.getClientArea().width;
+ int frameY = shell.getSize().y - shell.getClientArea().height;
+ shell.setSize(WIDTH + frameX, HEIGHT + frameY);
+ }
+ });
+
if (mode.equals(ManagerModeType.INHOUSE_MODE)) {
- shell.setText(StringResource.MAIN_TITLE_INHOUSE);
+ shell.setText(StringResources.MAIN_TITLE_INHOUSE);
} else {
- shell.setText(StringResource.MAIN_TITLE);
+ shell.setText(StringResources.MAIN_TITLE);
}
- shell.setLayout(new FillLayout());
InputStream is = this.getClass().getClassLoader().getResourceAsStream(ICON_FILE_NAME);
if(is != null) {
}
}
+ private ArrayList<PlatformTabItem> platformItems = new ArrayList<PlatformTabItem>(10);
+ private static PlatformTabFolder tabFolder = null;
+ private DACustomButton resetButton = null;
+ private DACustomButton infoButton = null;
+ private static StatusBar statusBar = null;
public void draw() {
Composite mainComposite = new Composite(shell, SWT.NONE);
- mainComposite.setLayout(getNopaddedGridLayout(1, false));
-
- {
- // Architecture selection group and main SashForm...
-
- Composite archComposite = new Composite(mainComposite, SWT.NONE);
- GridLayout upperLayout = new GridLayout(1, false);
- upperLayout.marginWidth = 0;
- archComposite.setLayout(upperLayout);
- archComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- // Top ToolBar
- ToolBar leftToolBar = new ToolBar(archComposite, SWT.NONE | SWT.RIGHT);
- leftToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
- aboutItem = new ToolItem(leftToolBar, SWT.PUSH);
- ToolItem separator = new ToolItem(leftToolBar, SWT.SEPARATOR);
- separator.setWidth(10);
- refreshItem = new ToolItem(leftToolBar, SWT.PUSH);
- separator = new ToolItem(leftToolBar, SWT.SEPARATOR);
- separator.setWidth(10);
-// modifyItem = new ToolItem(leftToolBar, SWT.PUSH);
- resetItem = new ToolItem(leftToolBar, SWT.PUSH);
- deleteItem = new ToolItem(leftToolBar, SWT.PUSH);
-
- cloneItem = new ToolItem(leftToolBar, SWT.PUSH);
- createImageItem = new ToolItem(leftToolBar, SWT.PUSH);
-
- decorateLeftSideToolItems();
-
- /*
- ToolBar toolBar = new ToolBar(archComposite, SWT.RIGHT);
- toolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
- x86ToggleItem = new ToolItem(toolBar, SWT.CHECK);
- armToggleItem = new ToolItem(toolBar, SWT.CHECK);
-
- decorateRightSideToolItems();
- */
-
- // Main SashForm
- sashForm = new SashForm(mainComposite, SWT.HORIZONTAL);
- sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sashForm.setLayout(new FillLayout());
- // Left : VMs tree
- {
- final Composite leftView = new Composite(sashForm, SWT.FILL);
- GridLayout layout = getNopaddedGridLayout(1, false);
- leftView.setLayout(layout);
-
- vmsTree = new VMsTree(this, leftView);
- vmsTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- }
-
- // Right : detail table
- {
- final Composite rightView = new Composite(sashForm, SWT.FILL);
- GridLayout layout = getNopaddedGridLayout(1, false);
- rightView.setLayout(layout);
-
- detailView = new DetailTableView(this);
- detailView.createDetailView(shell, rightView);
- detailView.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
-
-
- Composite bottomComposite = new Composite(rightView, SWT.NONE);
- GridLayout bottomLayout = getNopaddedGridLayout(2, false);
- bottomComposite.setLayout(bottomLayout);
- bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
-
- leftButton = new Button(bottomComposite, SWT.PUSH);
-
- // Launch, Cancel
- leftButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- leftButton.setText(StringResource.MODIFY);
- leftButton.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- String type = leftButton.getText();
- if (type.equals(StringResource.MODIFY)) {
- VMsProperty property = detailView.getCurrentPoperty();
- openModifyView(property);
- } else if (type.equals(StringResource.CREATE)) {
- openCreateView();
- } else if (type.equals(StringResource.CANCEL)) {
- if (detailView.getCurrentPoperty() == null) {
- openCreateDetailView();
- } else {
- openDetailView(detailView.getCurrentPoperty());
- vmsTree.setSelectProperty(detailView.getCurrentPoperty());
- }
- }
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
+ // TODO
+ mainComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor());
+ mainComposite.setLayout(new FormLayout());
+
+ tabFolder = new PlatformTabFolder(mainComposite);
+ statusBar = new StatusBar(mainComposite);
+
+ Composite tabComposite = tabFolder.getComposite();
+ Composite barComposite = statusBar.getBarComposite();
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = 460;
+ //data.bottom = new FormAttachment(barComposite, 0);
+ tabComposite.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(tabComposite, 0);
+ data.left = new FormAttachment(0, 2);
+ data.right = new FormAttachment(100, -2);
+ data.height = 20;
+ barComposite.setLayoutData(data);
+
+
+ // add platform tab item
+ for (Platform p : EmulatorManager.getPlatformList()) {
+ platformItems.add(new PlatformTabItem(p, tabFolder, SWT.CENTER));
+ }
+ // add custom tab
+ platformItems.add(new PlatformTabItem(EmulatorManager.getCustomPlatform(),
+ tabFolder, SWT.CENTER));
- // Modify, Confirm
- rightButton = new Button(bottomComposite, SWT.PUSH);
- rightButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- rightButton.setText(StringResource.LAUNCH);
- rightButton.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String type = rightButton.getText();
- if (type.equals(StringResource.LAUNCH)) {
- try {
- detailView.getCurrentPoperty().getWorker().launchVM();
- } catch (VMsWorkerException e) {
- new MessageDialog().openInfoDialog(e.getMessage());
- }
- } else if (type.equals(StringResource.CONFIRM)) {
- VMsProperty pro = detailView.confirm();
- if (pro != null) { // success
- refreshProperties();
- vmsTree.setSelectProperty(pro);
- openDetailView(pro);
- }
- }
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent event) {
- }
- });
+ resetButton = new DACustomButton(tabFolder.getTabComposite(),
+ ImageResources.RESET_ICON_NOMAL.getImage(),
+ ImageResources.RESET_ICON_PUSH.getImage(),
+ ImageResources.RESET_ICON_HOVER.getImage(),
+ ImageResources.RESET_ICON_NOMAL.getImage());
- }
+ infoButton = new DACustomButton(tabFolder.getTabComposite(),
+ ImageResources.INFO_ICON_NOMAL.getImage(),
+ ImageResources.INFO_ICON_PUSH.getImage(),
+ ImageResources.INFO_ICON_HOVER.getImage(),
+ ImageResources.INFO_ICON_NOMAL.getImage());
- sashForm.setWeights(new int[] { 100, 0 });
- }
+ tabFolder.addTabRightButton(resetButton);
+ tabFolder.addTabRightButton(infoButton);
+ decorateRightSideToolItems();
- handling = new MenuHandling(shell, vmsTree);
+ tabFolder.draw();
}
public void open() {
Display.getCurrent().sleep();
}
}
-
}
- public Shell getShell() {
+ public static Shell getShell() {
return shell;
}
- public void resetVM() {
- handling.resetVirtualMachine(detailView.getCurrentPoperty());
- vmsTree.setSelectProperty(detailView.getCurrentPoperty());
- }
-
- public void cloneVM() {
- handling.cloneVirtualMachine(detailView.getCurrentPoperty());
- }
-
- // TOOD : error checking
- public void deleteVM() {
- if (handling.deleteVirtualMachine(detailView.getCurrentPoperty())) {
- refreshProperties();
- closeDetailView();
- } else {
- vmsTree.setSelectProperty(detailView.getCurrentPoperty());
- }
- }
-
- public void createBaseImage() {
- handling.createBaseImage(detailView.getCurrentPoperty());
- vmsTree.setSelectProperty(detailView.getCurrentPoperty());
- }
-
- public void refreshVMsTable() {
- vmsTree.refreshContents();
- }
-
- public void refreshProperties() {
- EmulatorVMs.getInstance().refreshProperties();
- vmsTree.refreshContents();
- }
-
- public int[] getSashFormWeight() {
- return sashForm.getWeights();
- }
-
- public void setDetailViewWeights(int[] weight) {
- sashForm.setWeights(weight);
- }
-
- public void openDetailView(VMsProperty property) {
- if (vmsTree.getSelectionContentCount() == 1) {
- setToolBarState(State.TRUE);
- } else {
- setToolBarState(State.FALSE);
- }
-
- leftButton.setText(StringResource.MODIFY);
- leftButton.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
- rightButton.setText(StringResource.LAUNCH);
- rightButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
- leftButton.setEnabled(true);
- rightButton.setEnabled(true);
-
- detailView.openDetailView(property);
- }
-
- public void closeDetailView() {
- if(vmsTree == null) {
- return;
- }
- else if (vmsTree.getSelectionContentCount() > 1) {
- setToolBarState(State.CLOSE_DETAIL);
- }
- else {
- setToolBarState(State.FALSE);
- }
- detailView.closeDetailView();
- }
-
- public void openModifyView(VMsProperty property) {
- MessageDialog msg = new MessageDialog();
- if(property.getWorker().isRunningNow()) {
- msg.openInfoDialog("Not allowed to modify active VMs\n" + "[" + property.getName() + "] is running now...");
- return;
- }
-
- setToolBarState(State.FALSE);
-
- leftButton.setText(StringResource.CANCEL);
- leftButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
- rightButton.setText(StringResource.CONFIRM);
- rightButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
- leftButton.setEnabled(true);
- rightButton.setEnabled(false);
-
- detailView.openModifyView(property, rightButton);
- }
-
- public void openCreateDetailView(BaseImage image, VMsProperty template) {
- setToolBarState(State.FALSE);
-
- leftButton.setText(StringResource.CREATE);
- leftButton.setImage(ResourceRegistry.getImage(ImageName.CREATE));
- rightButton.setText(StringResource.LAUNCH);
- rightButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
-
- leftButton.setEnabled(true);
- rightButton.setEnabled(false);
-
- this.image = image;
- this.template = template;
- detailView.openCreateDetailView(image, template);
-
- }
-
- private BaseImage image;
- private VMsProperty template;
- public void openCreateDetailView() {
- setToolBarState(State.FALSE);
-
- leftButton.setText(StringResource.CREATE);
- leftButton.setImage(ResourceRegistry.getImage(ImageName.CREATE));
- rightButton.setText(StringResource.LAUNCH);
- rightButton.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
-
- leftButton.setEnabled(true);
- rightButton.setEnabled(false);
-
- detailView.openCreateDetailView(image, template);
+ public static StatusBar getStatusBar() {
+ return statusBar;
}
- public void openCreateView() {
- setToolBarState(State.FALSE);
-
- leftButton.setText(StringResource.CANCEL);
- leftButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
- rightButton.setText(StringResource.CONFIRM);
- rightButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
-
- leftButton.setEnabled(true);
- rightButton.setEnabled(false);
-
- detailView.openCreateView(rightButton);
+ public static void refreshVMPropertyList() {
+ EmulatorManager.settingVMPropertyList();
+ tabFolder.getSelection().redraw();
}
public void dispose() {
- ResourceRegistry.dispose();
-
+ ImageResources.dispose();
+ ColorResources.dispose();
if(icon != null) {
icon.dispose();
}
}
-enum State {
- FALSE, TRUE, CLOSE_DETAIL;
-}
- private void setToolBarState(State state) {
- switch(state) {
- case FALSE:
- deleteItem.setEnabled(false);
- resetItem.setEnabled(false);
- cloneItem.setEnabled(false);
- createImageItem.setEnabled(false);
- break;
- case TRUE:
- deleteItem.setEnabled(true);
- resetItem.setEnabled(true);
- cloneItem.setEnabled(true);
- createImageItem.setEnabled(true);
- break;
- case CLOSE_DETAIL:
- deleteItem.setEnabled(true);
- resetItem.setEnabled(true);
- cloneItem.setEnabled(false);
- createImageItem.setEnabled(false);
- break;
- }
- }
- private GridLayout getNopaddedGridLayout(int numColumns, boolean makeColumnEqualWidth) {
- GridLayout layout = new GridLayout(numColumns, makeColumnEqualWidth);
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- layout.marginBottom = 0;
- layout.marginHeight = 0;
- layout.marginLeft = 0;
- layout.marginRight = 0;
- layout.marginTop = 0;
- layout.marginWidth = 0;
-
- return layout;
- }
- private void decorateLeftSideToolItems() {
- aboutItem.setImage(ResourceRegistry.getImage(ImageName.ABOUT));
- aboutItem.setToolTipText("About Emulator Manager");
- aboutItem.addSelectionListener(new SelectionListener() {
+ private void decorateRightSideToolItems() {
+ infoButton.setToolTipText("About Emulator Manager");
+ infoButton.addClickListener(new DACustomButtonClickEventListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- /*
- new MessageDialog().openInfoDialog("About Emulator Manager",
- About.getInstance().getContents());
- */
+ public void handleClickEvent(DACustomButton button) {
AboutDialog.open();
}
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {}
});
- refreshItem.setImage(ResourceRegistry.getImage(ImageName.REFRESH));
- refreshItem.setToolTipText("refresh list of VM");
- refreshItem.addSelectionListener(new SelectionListener() {
+ resetButton.setToolTipText("Refresh list of VM");
+ resetButton.addClickListener(new DACustomButtonClickEventListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- // reload platform
- EmulatorManager.getInstance().makePlatformList();
- refreshProperties();
- closeDetailView();
+ public void handleClickEvent(DACustomButton button) {
+ // reload vm list
+ refreshVMPropertyList();
}
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {}
- });
-
- cloneItem.setText(StringResource.CLONE);
- cloneItem.setImage(ResourceRegistry.getImage(ImageName.CLONE));
- cloneItem.setToolTipText("Clone from selected VM");
- cloneItem.setEnabled(false);
- cloneItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- cloneVM();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {}
- });
-
-// modifyItem.setText("Modify");
-// modifyItem.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
-// modifyItem.setToolTipText("Modify selected VM");
-// modifyItem.addSelectionListener(new SelectionListener() {
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-// modifyVM(vmsTree.getSelectionItem());
-// }
-// @Override
-// public void widgetDefaultSelected(SelectionEvent e) {
-// }
-// });
-
- resetItem.setText(StringResource.RESET);
- resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
- resetItem.setToolTipText("Format OS of selected VM");
- resetItem.setEnabled(false);
- resetItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- resetVM();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- deleteItem.setText(StringResource.DELETE);
- deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
- deleteItem.setToolTipText("Delete selected VM");
- deleteItem.setEnabled(false);
- deleteItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- deleteVM();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- createImageItem.setText(StringResource.CREATE_IMAGE);
- createImageItem.setImage(ResourceRegistry.getImage(ImageName.CREATEIMAGE));
- createImageItem.setToolTipText("Create new base image from selected VM");
- createImageItem.setEnabled(false);
- createImageItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createBaseImage();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
- /*
- private void decorateRightSideToolItems() {
- x86ToggleItem.setText(StringResource.x86);
- x86ToggleItem.setImage(ResourceRegistry.getImage(ImageName.X86));
- x86ToggleItem.setToolTipText("x86 Architecture");
- x86ToggleItem.setSelection(true);
- x86ToggleItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- x86ToggleItem.setSelection(true);
- refreshProperties();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {}
-
});
-
- armToggleItem.setText(StringResource.ARM);
- armToggleItem.setImage(ResourceRegistry.getImage(ImageName.ARM));
- armToggleItem.setToolTipText("ARM Architecture");
- armToggleItem.setSelection(false);
- armToggleItem.setEnabled(false);
}
- */
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.tool.FilePath;
-import org.tizen.emulator.manager.ui.vmstree.VMsTree;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.dialog.CloneDialog;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMWorkerException;
public class MenuHandling {
private Shell shell;
- private VMsTree vmsTree;
private static ArrayList<String> baseImagePaths = new ArrayList<String>();
- public MenuHandling(Shell shell, VMsTree vmsTree) {
- this.shell = shell;
- this.vmsTree = vmsTree;
+ public MenuHandling() {
+ this.shell = MainDialog.getShell();
}
- public void resetVirtualMachine(VMsProperty prop) {
+ public void resetVirtualMachine(VMProperty property) {
MessageDialog msg = new MessageDialog();
int response = msg.openSelectionDialog("This VM will be formatted.\nAre you sure you want to continue?");
-
+
if (response != SWT.OK) {
return;
}
- VMsProperty[] properties = vmsTree.getSelectionItems();
- if (properties.length == 0) {
- properties = new VMsProperty[1];
- properties[0] = prop;
- }
- for (VMsProperty property : properties) {
- if(property.getWorker().isRunningNow()) {
- msg.openInfoDialog("Not allowed to reset active VMs.\n" + "[" + property.getName() + "] is running now...");
- return;
- }
+ if(property.getWorker().isRunningNow()) {
+ msg.openInfoDialog("Not allowed to reset active VMs."
+ + StringResources.NEW_LINE
+ + "[" + property.getName() + "] is running now...");
+ return;
}
- for (VMsProperty property : properties) {
- try {
- property.getWorker().resetVM();
- } catch (VMsWorkerException e) {
- msg.openInfoDialog(" Reset [" + property.getName() + "] failed...\n"
- + e.getMessage());
- return;
- }
+ try {
+ property.getWorker().resetVM();
+ } catch (VMWorkerException e) {
+ msg.openInfoDialog(" Reset [" + property.getName() + "] failed..."
+ + e.getMessage());
+ return;
}
-
- //msg.openInfoDialog("Completed reset process!");
}
- public boolean deleteVirtualMachine(VMsProperty prop) {
+ public boolean deleteVirtualMachine(VMProperty property) {
MessageDialog msg = new MessageDialog();
int response = msg.openSelectionDialog("Are you sure you want to delete selected VM?");
if (response != SWT.OK) {
return false;
}
- VMsProperty[] properties = vmsTree.getSelectionItems();
- if (properties.length == 0) {
- properties = new VMsProperty[1];
- properties[0] = prop;
- }
- for (VMsProperty property : properties) {
- if(property.getWorker().isRunningNow()) {
- msg.openInfoDialog("Not allowed to delete active VMs.\n" + "[" + property.getName() + "] is running now...");
- return false;
- }
+ if(property.getWorker().isRunningNow()) {
+ msg.openInfoDialog("Not allowed to delete active VMs."
+ + StringResources.NEW_LINE
+ + "[" + property.getName() + "] is running now...");
+ return false;
}
- for(VMsProperty property : properties) {
- try {
- property.getWorker().deleteVM();
- } catch (VMsWorkerException e) {
- msg.openInfoDialog(" Delete [" + property.getName() + "] failed...\n"
- + e.getMessage());
- return false;
- }
+ try {
+ property.getWorker().deleteVM();
+ } catch (VMWorkerException e) {
+ msg.openInfoDialog(" Delete [" + property.getName() + "] failed..."
+ + e.getMessage());
+ return false;
}
-
- //msg.openInfoDialog("Completed delete process!");
-
return true;
}
- public void createBaseImage(VMsProperty prop) {
+ public void createBaseImage(VMProperty property) {
MessageDialog msg = new MessageDialog();
- VMsProperty property = prop;
- if(prop.getWorker().isRunningNow()) {
- msg.openWarningDialog("Not allowed to 'Create Base Image' while source VM is running.");
+ if(property.getWorker().isRunningNow()) {
+ msg.openWarningDialog("Not allowed to 'Create Base Image'"
+ + StringResources.NEW_LINE
+ + "while source VM is running.");
return ;
}
try {
MenuHandling.addBaseImagePath(path);
property.getWorker().createNewBaseImage(property, path);
- //returnMSG = "Succeeded to create 'Base Image'!\nPath: " + path;
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
returnMSG =e.getMessage();
msg.openInfoDialog(returnMSG);
}
}
- public void cloneVirtualMachine(VMsProperty currentPoperty) {
+ public void cloneVirtualMachine(VMProperty property) {
MessageDialog msg = new MessageDialog();
- if(currentPoperty.getWorker().isRunningNow()) {
+ if(property.getWorker().isRunningNow()) {
msg.openWarningDialog("Not allowed to 'Clone' while source VM is running.");
return ;
}
- CloneDialog cloneDialog = new CloneDialog(EmulatorManager.getInstance().getMainDialog(), currentPoperty);
+ CloneDialog cloneDialog = new CloneDialog(property);
cloneDialog.open();
}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class ResourceRegistry {
- public enum ImageName {
- CANCEL("cancel"), CONFIRM("confirm"), CREATE("create"), DELETE("delete"), DETAILS("details"),
- FOLDER("folder"), MODIFY("modify"), REFRESH("refresh"), RESET("reset"), LAUNCH("launch"), CREATEIMAGE("createimage"),
- ABOUT("about"), CLONE("clone"), ARM("arm"), X86("x86"), ABOUTSDK("aboutSDK");
-
- String name;
-
- ImageName(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
- public enum FontType {
- BOLD("bold");
-
- String name;
-
- FontType(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
- private static ResourceRegistry instance;
-
- Map<ImageName, Image> imagesMap = new HashMap<ImageName, Image>();
-
- static {
- synchronized(ResourceRegistry.class) {
- instance = new ResourceRegistry();
-
- ClassLoader loader = ResourceRegistry.class.getClassLoader();
-
- InputStream is = null;
-
- for(ImageName imageName : ImageName.values()) {
- is = loader.getResourceAsStream("res/" + imageName.toString() + ".png");
- if(is != null) {
- instance.imagesMap.put(imageName, new Image(Display.getCurrent(), is));
- }
- }
- }
- }
-
- Map<Integer, Font> fontsMap = new HashMap<Integer, Font>();
-
- public static Image getImage(ImageName imagename) {
- return instance.imagesMap.get(imagename);
- }
-
- public static void addFont(int fontStyle, Font font) {
- instance.fontsMap.put(fontStyle, font);
- }
-
- public static Font getFont(int fonttype) {
- return instance.fontsMap.get(fonttype);
- }
-
- public static void dispose() {
- for(Image image : instance.imagesMap.values()) {
- image.dispose();
- }
-
- for(Font font : instance.fontsMap.values()) {
- font.dispose();
- }
- }
-
- private ResourceRegistry() {}
-}
--- /dev/null
+package org.tizen.emulator.manager.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+
+public class StatusBar {
+ private Composite bar = null;
+ private Label msgLabel = null;
+
+ public StatusBar(Composite parent) {
+ bar = new Composite(parent, SWT.NONE);
+ bar.setLayout(new FormLayout());
+ bar.setBackground(ColorResources.STATUS_BAR_COLOR.getColor());
+
+ msgLabel = new Label(bar, SWT.NONE);
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 10);
+ data.right = new FormAttachment(100, -10);
+ data.bottom = new FormAttachment(100, 0);
+ msgLabel.setLayoutData(data);
+ msgLabel.setFont(FontResources.STATUS_BAR_FONT.getFont());
+ msgLabel.setForeground(ColorResources.STATUS_BAR_FONT_COLOR.getColor());
+ msgLabel.setBackground(ColorResources.STATUS_BAR_COLOR.getColor());
+ }
+
+ private boolean isError = false;
+ private String message;
+ public void info(String msg) {
+ if (isError) {
+ return;
+ }
+ message = msg;
+ msgLabel.setText(message);
+ }
+
+ public void error(String msg) {
+ if (isError) {
+ return;
+ }
+ isError = true;
+ message = msg;
+ msgLabel.setText(message);
+
+ }
+
+ public void reset() {
+ isError = false;
+ message = "";
+ msgLabel.setText(message);
+ }
+
+ public Composite getBarComposite() {
+ return bar;
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.ui.widgets.VMButton;
+import org.tizen.emulator.manager.ui.widgets.VMButtonClickEventListener;
+
+class VMCreateButton extends VMButton {
+ public VMCreateButton(Composite parent, int style) {
+ super(parent, style);
+ // delete launchButton
+ launchButton.dispose();
+ launchButton = null;
+ // set Image
+ setImages(ImageResources.ADD_NEW_NOMAL.getImage(),
+ ImageResources.ADD_NEW_PUSH.getImage(),
+ ImageResources.ADD_NEW_HOVER.getImage(),
+ ImageResources.VM_IMAGE_CREATE.getImage());
+ }
+}
+
+public class VMButtonFactory {
+ private static ArrayList<VMButton> buttons = new ArrayList<VMButton> ();
+ private static int selectedIndex = 0;
+
+ public static VMButton getButton(Composite parent) {
+ VMButton b = new VMButton(parent, SWT.NONE);
+ b.addClickListener(new VMButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMButtonFactory.clickVMButton(button);
+ }
+ });
+ buttons.add(b);
+ return b;
+ }
+
+ public static VMButton getCreateButton(Composite parent) {
+ VMCreateButton b = new VMCreateButton(parent, SWT.NONE);
+ buttons.add(b);
+ return b;
+ }
+
+ public static ArrayList<VMButton> getButtonList() {
+ return buttons;
+ }
+
+ public static void clear() {
+ for(VMButton b : buttons) {
+ b.dispose();
+ }
+ buttons.clear();
+ selectedIndex = 0;
+ }
+
+ public static void clickVMButton(DACustomButton button) {
+ VMButton b = null;
+ for(int i = 0; i < buttons.size(); i++) {
+ b = buttons.get(i);
+ if (button == b) {
+ b.setSelected(true);
+ b.redraw();
+ selectedIndex= i;
+ } else {
+ b.setSelected(false);
+ b.redraw();
+ }
+ }
+ }
+
+ public static void clickVMButton(int index) {
+ clickVMButton(buttons.get(index));
+ }
+
+ public static int getSelectedButtonIndex() {
+ return selectedIndex;
+ }
+
+ public static VMButton getSelectedButton() {
+ return buttons.get(selectedIndex);
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.ui.detail.PInfoViewPage;
+import org.tizen.emulator.manager.ui.detail.PEmptyViewPage;
+import org.tizen.emulator.manager.ui.detail.PModifyViewPage;
+import org.tizen.emulator.manager.ui.detail.DetailViewPage;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class VMsDetailView {
+ private Composite parent = null;
+ private Composite mainView = null;
+ private int WIDTH = 328;
+ private int HEIGHT = 430;
+
+ public VMsDetailView(Composite parent) {
+ this.parent = parent;
+ }
+
+ public void setSize(int width, int height) {
+ this.WIDTH = width;
+ this.HEIGHT = height;
+ }
+
+ public Point getSize() {
+ return new Point(WIDTH, HEIGHT);
+ }
+
+ public Composite getComposite() {
+ if (mainView == null) {
+ init();
+ }
+ return mainView;
+ }
+
+ private DetailViewPage emptyView = null;
+ private DetailViewPage detailView = null;
+ private DetailViewPage modifyView = null;
+
+ private final StackLayout stackLayout = new StackLayout();
+ public void init(int width, int height) {
+ mainView = new Composite(parent, SWT.NONE);
+ mainView.setLayout(stackLayout);
+ mainView.setSize(width, height);
+ mainView.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+
+ emptyView = new PEmptyViewPage(this, SWT.NONE);
+
+ detailView = new PInfoViewPage(this, SWT.NONE);
+
+ modifyView = new PModifyViewPage(this, SWT.NONE);
+
+ stackLayout.topControl = detailView.getComposite();
+ mainView.layout();
+ }
+
+ public void init() {
+ init(WIDTH, HEIGHT);
+ }
+
+ public void drawEmptyVM() {
+ stackLayout.topControl = emptyView.getComposite();
+ mainView.layout();
+ }
+
+ public void drawDetailVM(VMProperty property) {
+ detailView.drawPropertyView(property.getPropertyValue(), false);
+ stackLayout.topControl = detailView.getComposite();
+ mainView.layout();
+ }
+
+ public void drawModifyVM(VMProperty property, boolean isCreate) {
+ modifyView.drawPropertyView(property.getPropertyValue(), false);
+ stackLayout.topControl = modifyView.getComposite();
+ mainView.layout();
+ }
+
+ public void drawCreateVM(VMPropertyValue value) {
+ stackLayout.topControl = modifyView.getComposite();
+ mainView.layout();
+ modifyView.drawPropertyView(value, true);
+ }
+
+ public void close() {
+ emptyView.close();
+ detailView.close();
+ modifyView.close();
+ mainView.dispose();
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomCombo;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomComboSelectionListener;
+import org.tizen.emulator.manager.da.widgets.combo.TitleComboPopupRenderer;
+import org.tizen.emulator.manager.da.widgets.combo.TitleComboRenderer;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.ui.widgets.VMButton;
+
+public class VMsListView {
+ private Composite parent = null;
+ private Composite listView = null;
+ private int WIDTH = 510;
+ private int HEIGHT = 430;
+
+ public VMsListView(Composite parent) {
+ this.parent = parent;
+ }
+
+ public void setSize(int width, int height) {
+ this.WIDTH = width;
+ this.HEIGHT = height;
+ }
+
+ public Point getSize() {
+ return new Point(WIDTH, HEIGHT);
+ }
+
+ public Composite getComposite() {
+ if (listView == null) {
+ init();
+ }
+ return listView;
+ }
+
+ private DACustomCombo imageCombo = null;
+ private ScrolledComposite scrolledList = null;
+ private Composite vmList = null;
+
+ public void init(int width, int height) {
+ listView = new Composite(parent, SWT.NONE);
+ listView.setLayout(new FormLayout());
+ listView.setSize(width, height);
+ //
+ listView.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor());
+ //
+ makeComboButton();
+ makeVMList();
+ }
+
+ public void init() {
+ init(WIDTH, HEIGHT);
+ }
+
+ private static int COMBO_WIDTH = 145;
+ private static int COMBO_HEIGHT = 24;
+ private void makeComboButton() {
+ imageCombo = new DACustomCombo(listView, SWT.NONE);
+ imageCombo.setImages(ImageResources.COMBO_NORMAL.getImage(),
+ ImageResources.COMBO_HOVER.getImage(),
+ ImageResources.COMBO_PUSH.getImage(),
+ ImageResources.COMBO_DISABLE.getImage());
+ imageCombo.setEnabled(true);
+
+ imageCombo.setItemHeight(COMBO_HEIGHT);
+ imageCombo.setComboRender(new TitleComboRenderer());
+ imageCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(0, 10);
+ data.width = COMBO_WIDTH;
+ data.height = COMBO_HEIGHT;
+ imageCombo.setLayoutData(data);
+
+ imageCombo.addSelectionListener(new DACustomComboSelectionListener() {
+ @Override
+ public void selectionEvent(DACustomCombo combo) {
+ int index = combo.getItemIndex(combo.getText());
+ VMsMainView.getInstance().drawVMList(index);
+ }
+ });
+ }
+
+ private Text dumyText = null;
+ private void makeVMList() {
+ scrolledList = new ScrolledComposite(listView, SWT.V_SCROLL);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(0, 40);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, -10);
+ scrolledList.setLayoutData(data);
+ scrolledList.setBackground(ColorResources.LIST_BG_COLOR.getColor());
+
+ vmList = new Composite(scrolledList, SWT.BORDER);
+ // TODO
+ vmList.setBackground(ColorResources.LIST_BG_COLOR.getColor());
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100);
+ data.bottom = new FormAttachment(100);
+ vmList.setLayoutData(data);
+ vmList.setLayout(new FormLayout());
+
+ scrolledList.setContent(vmList);
+ scrolledList.setExpandHorizontal(true);
+
+
+ dumyText = new Text(listView, SWT.NONE);
+ dumyText.setText("");
+ data = new FormData();
+ data.left = new FormAttachment(0, -100);
+ data.top = new FormAttachment(0, 0);
+ data.width = 0;
+ data.height = 0;
+ dumyText.setLayoutData(data);
+ dumyText.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ controlKeyEvent(event);
+ }
+ });
+ }
+
+ public void drawPlatform(Platform platform, int imageIndex) {
+ imageCombo.setEnabled(true);
+ imageCombo.initCombo();
+ for (BaseImage image : platform.getImageList()) {
+ imageCombo.add(image.getName());
+ }
+
+ imageCombo.select(imageIndex);
+ VMsMainView.getInstance().drawVMList(imageIndex);
+ }
+
+ // TODO
+ private int LIST_HEIGHT = 379;
+ private int LIST_WIDTH = 484;
+ private int WIDTH_GAP = 10;
+ private int HEIGHT_GAP = 12;
+ private int BUTTON_WIDTH = 106 + 4;
+ private int BUTTON_HEIGHT = 146 + 4;
+
+ private int WIDTH_COUNT = 0;
+ private int HEIGHT_COUNT = 0;
+
+ private DACustomButton createButton = null; // for empty list
+ private VMButton addNewButton = null;
+
+
+ private int CREATE_BUTTON_WIDTH = 190;
+ private int CREATE_BUTTON_HEIGHT = 190;
+ public void drawEmptyVMList() {
+ if (createButton != null) {
+ return;
+ }
+
+ // clear
+ VMButtonFactory.clear();
+
+ int leftOffset = (LIST_WIDTH - CREATE_BUTTON_WIDTH) / 2;
+ int topOffset = (LIST_HEIGHT - CREATE_BUTTON_HEIGHT) / 2;
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, leftOffset);
+ data.top = new FormAttachment(0, topOffset);
+ data.width = CREATE_BUTTON_WIDTH;
+ data.height = CREATE_BUTTON_HEIGHT;
+ createButton = new DACustomButton(vmList,
+ ImageResources.CREATE_NEW_NOMAL.getImage(),
+ ImageResources.CREATE_NEW_PUSH.getImage(),
+ ImageResources.CREATE_NEW_HOVER.getImage(),
+ ImageResources.CREATE_NEW_NOMAL.getImage());
+ createButton.setLayoutData(data);
+
+ createButton.addClickListener(new DACustomButtonClickEventListener(){
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMsMainView.getInstance().drawCreateVM();
+ }
+ });
+
+ vmList.setSize(LIST_WIDTH, LIST_HEIGHT);
+ vmList.layout(true, true);
+ scrolledList.layout(true, true);
+ }
+
+ public void drawVMList(BaseImage base, int select, boolean isCreate) {
+ if (createButton != null) {
+ createButton.dispose();
+ createButton = null;
+ }
+
+ if (select == -1) {
+ select = 0;
+ }
+
+ WIDTH_COUNT = LIST_WIDTH / (BUTTON_WIDTH + WIDTH_GAP);
+
+ int wIndex = 0;
+ int hIndex = 0;
+ VMButtonFactory.clear();
+ if (base.getVmsList().size() != 0) {
+ HEIGHT_COUNT = (base.getVmsList().size() + 1) / WIDTH_COUNT;
+ if ((base.getVmsList().size() + 1) % WIDTH_COUNT != 0) {
+ HEIGHT_COUNT++;
+ }
+
+ if (((BUTTON_HEIGHT + HEIGHT_GAP) * HEIGHT_COUNT) > LIST_HEIGHT) {
+ vmList.setSize(LIST_WIDTH, ((BUTTON_HEIGHT + HEIGHT_GAP) * HEIGHT_COUNT) + HEIGHT_GAP);
+ } else {
+ vmList.setSize(LIST_WIDTH, LIST_HEIGHT);
+ }
+
+ FormData data = null;
+ VMButton button = null;
+ for (int i = 0; i < base.getVmsList().size(); i++) {
+ data = new FormData();
+ data.left = new FormAttachment(0, WIDTH_GAP + (BUTTON_WIDTH + WIDTH_GAP) * wIndex);
+ data.top = new FormAttachment(0, HEIGHT_GAP + (BUTTON_HEIGHT + HEIGHT_GAP) * hIndex);
+ data.width = BUTTON_WIDTH;
+ data.height = BUTTON_HEIGHT;
+ button = VMButtonFactory.getButton(vmList);
+ button.setProperty(base.getVmsList().get(i));
+ button.setLayoutData(data);
+ if (i == select) {
+ VMButtonFactory.clickVMButton(button);
+ }
+
+ button.redraw();
+ ++wIndex;
+ if (wIndex == WIDTH_COUNT) {
+ wIndex = 0;
+ hIndex++;
+ }
+ }
+ }
+
+ // add create button
+ addNewButton = VMButtonFactory.getCreateButton(vmList);
+ if (isCreate) {
+ addNewButton.setEnabled(false);
+ } else {
+ addNewButton.setEnabled(true);
+ }
+ addNewButton.addClickListener(new DACustomButtonClickEventListener(){
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ clickCreateButton();
+ }
+ });
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, WIDTH_GAP + (BUTTON_WIDTH + WIDTH_GAP) * wIndex);
+ data.top = new FormAttachment(0, HEIGHT_GAP + (BUTTON_HEIGHT + HEIGHT_GAP) * hIndex);
+ data.width = BUTTON_WIDTH;
+ data.height = BUTTON_HEIGHT;
+ addNewButton.setLayoutData(data);
+
+ vmList.layout(true, true);
+ scrolledList.layout(true, true);
+ }
+
+ private void clickCreateButton() {
+ VMButtonFactory.clickVMButton(addNewButton);
+ addNewButton.setEnabled(false);
+ VMsMainView.getInstance().drawCreateVM();
+ }
+
+ public void controlKeyEvent(KeyEvent event) {
+ switch (event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
+ if (VMButtonFactory.getSelectedButton() instanceof VMCreateButton) {
+ clickCreateButton();
+ } else {
+ VMsMainView.getInstance().launchEmulator(null);
+ }
+ break;
+ case SWT.ARROW_UP:
+ int size = VMButtonFactory.getButtonList().size();
+ int index = VMButtonFactory.getSelectedButtonIndex() - WIDTH_COUNT;
+ if (index >= 0) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.ARROW_DOWN:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() + WIDTH_COUNT;
+ if (index < size) {
+ VMButtonFactory.clickVMButton(index);
+ } else {
+ VMButtonFactory.clickVMButton(VMButtonFactory.getButtonList().size() - 1);
+ }
+ break;
+ case SWT.ARROW_LEFT:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() - 1;
+ if (index >= 0) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.ARROW_RIGHT:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() + 1;
+ if (index < size) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.DEL:
+ if (VMButtonFactory.getSelectedButton() instanceof VMCreateButton) {
+ // nothing
+ } else {
+ VMsMainView.getInstance().deleteEmulator();
+ }
+ break;
+ case SWT.ESC:
+ if (!VMsMainView.getInstance().isCreateMode()) {
+ VMsMainView.getInstance().drawDetailVM();
+ }
+ }
+ scrolledList.showControl(VMButtonFactory.getSelectedButton());
+ }
+
+ public void cancelModify(int index) {
+ if (addNewButton != null && !addNewButton.isDisposed()) {
+ addNewButton.setEnabled(true);
+ }
+ if (index >= 0) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ MainDialog.getStatusBar().reset();
+ dumyText.setFocus();
+ }
+
+ public void cancelModify() {
+ cancelModify(-1);
+ }
+
+ public void draw() {
+ vmList.layout(true, true);
+ scrolledList.layout(true, true);
+ }
+
+ public void close() {
+ imageCombo.dispose();
+ VMButtonFactory.clear();
+
+ vmList.dispose();
+ scrolledList.dispose();
+ listView.dispose();
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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.platform.Platform;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.tool.SelectTemplate;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.Creator;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.VMWorkerException;
+
+public class VMsMainView {
+ private Composite mainView;
+ private VMsListView listView;
+ private VMsDetailView detailView;
+
+ private boolean isInitialize = false;
+ private boolean isCreateMode = false;
+
+ private static VMsMainView view = new VMsMainView();
+ public static VMsMainView getInstance() {
+ return view;
+ }
+
+ private VMsMainView() {}
+
+ public Composite getComposite() {
+ return mainView;
+ }
+ /**
+ * parent를 이용해서 VMsMainView를 initialize 한다.
+ * if 이미 초기화 된 경우에는 ??? 현재는 기존 view 삭제 후에 다시 그린다???
+ * @param parent
+ */
+ public void setInit(Composite parent) {
+ if (isInitialize) {
+ // TODO
+ // dispose
+ }
+ isInitialize = true;
+
+ mainView = new Composite(parent, SWT.NONE);
+ mainView.setLayout(new FormLayout());
+/*
+ mainView.addControlListener(new ControlListener() {
+
+ @Override
+ public void controlMoved(ControlEvent e) {
+ }
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ Composite c = (Composite)e.widget;
+ Rectangle rect = c.getBounds();
+ listView.getControl().setSize(rect.x - 325, rect.y);
+ listView.getControl().update();
+ }
+
+ });
+*/
+
+ listView = new VMsListView(mainView);
+ detailView = new VMsDetailView(mainView);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ data.width = listView.getSize().x;
+ listView.getComposite().setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(listView.getComposite(), 0);
+ data.top = new FormAttachment(0, 0);
+ //data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
+ data.width = detailView.getSize().x;
+ detailView.getComposite().setLayoutData(data);
+ }
+
+ public void dispose() {
+ //TODO
+ listView.close();
+ detailView.close();
+
+ mainView.dispose();
+ }
+
+ private Platform currentPlatform = null;
+ private BaseImage currentImage = null;
+ private VMProperty currentProperty = null;
+
+ public void setPlatform(Platform platform, int index) {
+ this.currentPlatform = platform;
+ if (platform == null) {
+ // TODO
+ }
+
+ if (platform.getImageList().isEmpty()) {
+ // TODO
+ } else {
+ listView.drawPlatform(platform, index);
+ }
+ }
+
+ public void setPlatform(Platform platform) {
+ setPlatform(platform, 0);
+ }
+
+ public void resetPlatform() {
+ setPlatform(currentPlatform,
+ currentPlatform.getImageList().indexOf(currentImage));
+ }
+
+ public Platform getPlatform() {
+ return currentPlatform;
+ }
+
+ public void setCurrentImage(BaseImage image) {
+ this.currentImage = image;
+ }
+
+ public BaseImage getCurrentImage() {
+ return currentImage;
+ }
+
+ public VMProperty getCurrentProperty() {
+ return currentProperty;
+ }
+
+ public void setCurrentProperty(VMProperty currentProperty) {
+ this.currentProperty = currentProperty;
+ }
+
+ public void drawVMList(BaseImage image) {
+ currentImage = image;
+ if (image.getVmsList().isEmpty()) {
+ drawEmptyVMList();
+ } else {
+ listView.drawVMList(image,
+ currentImage.getVmsList().indexOf(currentProperty), false);
+ }
+ }
+
+ public void drawVMList(int index) {
+ if (currentPlatform == null) {
+ return;
+ } else {
+ drawVMList(currentPlatform.getImageList().get(index));
+ }
+ }
+
+ public void drawEmptyVMList() {
+ listView.drawEmptyVMList();
+ detailView.drawEmptyVM();
+ }
+
+ public void drawDetailVM(VMProperty property) {
+ currentProperty = property;
+ isCreateMode = false;
+ listView.cancelModify();
+ detailView.drawDetailVM(property);
+ }
+
+ public void drawDetailVM() {
+ drawDetailVM(currentProperty);
+ }
+
+ public void drawModifyVM(VMProperty property) {
+ currentProperty = property;
+ isCreateMode = false;
+ detailView.drawModifyVM(property, false);
+ }
+
+ public void drawModifyVM() {
+ MessageDialog msg = new MessageDialog();
+ if(currentProperty.getWorker().isRunningNow()) {
+ msg.openInfoDialog("Not allowed to modify active VMs"
+ + StringResources.NEW_LINE
+ + "[" + currentProperty.getName() + "] is running now...");
+ return;
+ }
+ drawModifyVM(currentProperty);
+ }
+
+ public void drawCreateVM() {
+ isCreateMode = true;
+
+ if (currentImage.getVmsList().isEmpty()) {
+ listView.drawVMList(currentImage, -1, true);
+ }
+
+ BaseImage image = (currentPlatform.getName().equals("custom")) ? null : currentImage;
+ detailView.drawCreateVM(
+ new VMPropertyValue(image, SelectTemplate.getInstance().getDefaultTemplate()));
+ }
+
+ public void drawCancelCreaetVM() {
+ isCreateMode = false;
+
+ if (currentImage.getVmsList().isEmpty()) {
+ drawEmptyVMList();
+ } else {
+ int i = currentImage.getVmsList().indexOf(currentProperty);
+ listView.cancelModify(i);
+ detailView.drawDetailVM(currentProperty);
+ }
+ }
+
+ public void launchEmulator(VMProperty property) {
+ if (property == null) {
+ property = getCurrentProperty();
+ }
+
+ if (property != null) {
+ try {
+ property.getWorker().launchVM();
+ } catch (VMWorkerException e) {
+ String msg = "Failed to launch Emulator ("
+ + property.getPropertyValue().vmsName
+ + ") " + StringResources.NEW_LINE
+ + e.getMessage();
+ EMLogger.getLogger().warning(msg);
+ new MessageDialog().openWarningDialog(msg);
+ return;
+ }
+ }
+ }
+
+ public boolean createEmualtor(VMPropertyValue newValue) {
+ VMProperty prop = null;
+ try {
+ prop = Creator.create(newValue);
+ } catch (VMWorkerException e) {
+ String msg = "Failed to create Emulator ("
+ + newValue.vmsName
+ + ") " + StringResources.NEW_LINE
+ + e.getMessage();
+ EMLogger.getLogger().warning(msg);
+ new MessageDialog().openWarningDialog(msg);
+ return false;
+ }
+
+ setCurrentProperty(prop);
+ return true;
+ }
+
+ public boolean modifyEmulator(VMPropertyValue newValue) {
+ try {
+ getCurrentProperty().getWorker()
+ .modifyVM(newValue);
+ } catch (VMWorkerException e) {
+ String msg = "Failed to modify Emulator ("
+ + newValue.vmsName
+ + ") " + StringResources.NEW_LINE
+ + e.getMessage();
+ EMLogger.getLogger().warning(msg);
+ new MessageDialog().openWarningDialog(msg);
+ return false;
+ }
+ return true;
+ }
+
+ private MenuHandling handling = new MenuHandling();
+ public boolean createBaseImage() {
+ handling.createBaseImage(currentProperty);
+ return true;
+ }
+
+ public boolean deleteEmulator() {
+ handling.deleteVirtualMachine(currentProperty);
+ MainDialog.refreshVMPropertyList();
+ return true;
+ }
+
+ public boolean resetEmulator() {
+ handling.resetVirtualMachine(currentProperty);
+ return true;
+ }
+
+ public boolean isCreateMode() {
+ return isCreateMode;
+ }
+
+ public void setCreateMode(boolean isCreateMode) {
+ this.isCreateMode = isCreateMode;
+ }
+}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.detail;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.MainDialog;
-import org.tizen.emulator.manager.vms.VMsProperty;
-
-public class DetailTableView {
- static final int[] DEFAULT_WEIGHT = new int[] { 60, 40 };
- static final int[] STATUS_CLOSE_WEIGHT = new int[] { 100, 0 };
-
- private MainDialog mainDialog;
- private Table detailTable;
- private TableColumn tableColumn;
-
- private boolean isDetailOpened = false;
-
- private boolean isCreateState = false;
- private boolean isModifyState = false;
-
- private VMsProperty currentProperty;
- private VMPropertyView vmView = null;
- private int[] weight = new int[] { 60, 40 };
-
- // Implement a "fake" tooltip
- final Listener labelListener = new Listener() {
- public void handleEvent(Event event) {
- Label label = (Label) event.widget;
- Shell shell = label.getShell();
- switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event();
- e.item = (TableItem) label.getData("_TABLEITEM");
- // Assuming table is single select, set the selection as if
- // the mouse down event went through to the table
- detailTable.setSelection(new TableItem[] { (TableItem) e.item });
- detailTable.notifyListeners(SWT.Selection, e);
- // fall through
- case SWT.MouseExit:
- shell.dispose();
- break;
- }
- }
- };
-
- Listener tableListener = new Listener() {
- Shell tip = null;
-
- Label label = null;
-
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null)
- break;
- tip.dispose();
- tip = null;
- label = null;
- break;
- }
- case SWT.MouseHover: {
- TableItem item = detailTable.getItem(new Point(event.x, event.y));
- if (item != null) {
- String tooltip = vmView.getToolTipText(item.getText(0));
- if (tooltip != null && !tooltip.isEmpty()) {
- if (tip != null && !tip.isDisposed())
- tip.dispose();
- tip = new Shell(mainDialog.getShell(), SWT.ON_TOP | SWT.TOOL);
- tip.setLayout(new FillLayout());
- label = new Label(tip, SWT.NONE);
- label.setForeground(Display.getCurrent()
- .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(Display.getCurrent()
- .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setData("_TABLEITEM", item);
- label.setText(tooltip);
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- //Rectangle rect = item.getBounds(0);
- Point pt = detailTable.toDisplay(event.x, event.y);
- tip.setBounds(pt.x + 8, pt.y + 8, size.x, size.y);
- tip.setVisible(true);
- }
- }
- }
- }
- }
- };
-
- public DetailTableView(MainDialog mainDialog) {
- this.mainDialog = mainDialog;
- }
-
- public void createDetailView(Shell shell, Composite rightView) {
- detailTable = new Table(rightView, SWT.BORDER);
- detailTable.setHeaderVisible(true);
- detailTable.setLinesVisible(false);
- detailTable.addListener(SWT.MeasureItem, new Listener() {
- @Override
- public void handleEvent(Event event) {
- // TODO
- event.height = 25;
- }
- });
-
- detailTable.addListener(SWT.Dispose, tableListener);
- detailTable.addListener(SWT.KeyDown, tableListener);
- detailTable.addListener(SWT.MouseMove, tableListener);
- detailTable.addListener(SWT.MouseHover, tableListener);
-
- tableColumn = new TableColumn(detailTable, SWT.NONE);
- tableColumn.setText(StringResource.DETAIL);
- TableColumn tableColumn2 = new TableColumn(detailTable, SWT.NONE);
- tableColumn2.setText("");
- //TableColumn tableColumn3 = new TableColumn(detailTable, SWT.NONE);
- //tableColumn3.setText("");
- vmView = new VMPropertyView(detailTable);
- }
-
- public VMsProperty getCurrentPoperty() {
- return currentProperty;
- }
-
- public void openDetailView(VMsProperty property)
- {
- if (isModifyState) {
- closeModifyView();
- } else if (isCreateState) {
- closeCreateView();
- }
-
- currentProperty = property;
- detailTable.setEnabled(true);
- tableColumn.setText(StringResource.DETAIL);
-
- vmView.detailView(property);
-
- detailTable.getColumn(0).pack();
- detailTable.getColumn(1).pack();
-
- if(!isDetailOpened) {
- mainDialog.setDetailViewWeights(weight);
- isDetailOpened = true;
- }
- }
-
- public void closeDetailView()
- {
- if (isModifyState) {
- closeModifyView();
- } else if (isCreateState) {
- closeCreateView();
- }
-
- if(isDetailOpened) {
- weight = mainDialog.getSashFormWeight();
- mainDialog.setDetailViewWeights(STATUS_CLOSE_WEIGHT);
- isDetailOpened = false;
- }
- }
-
- public void openModifyView(VMsProperty property, Button confirmButton)
- {
- isModifyState = true;
- tableColumn.setText(StringResource.MODIFY);
-
- // TODO : error
- if (vmView == null) {
- return;
- }
- vmView.modifyView(confirmButton);
- }
-
- public void closeModifyView()
- {
- isModifyState = false;
-
- if (vmView != null) {
- vmView.close();
- }
- }
-
- public void openCreateDetailView(BaseImage image, VMsProperty template) {
- if (isModifyState) {
- closeModifyView();
- } else if (isCreateState) {
- closeCreateView();
- }
-
- currentProperty = null;
- tableColumn.setText(StringResource.DETAIL);
-
- vmView.createDetailView(image, template);
-
- detailTable.getColumn(0).pack();
- detailTable.getColumn(1).pack();
-
- detailTable.setEnabled(false);
- if (!isDetailOpened) {
- mainDialog.setDetailViewWeights(weight);
- isDetailOpened = true;
- }
- }
-
-
- public void openCreateView(Button confirmButton) {
- isCreateState = true;
-
- tableColumn.setText(StringResource.CREATE);
- detailTable.setEnabled(true);
-
- // TODO : error
- if (vmView == null) {
- return;
- }
-
- vmView.createView(confirmButton);
- }
-
- public void closeCreateView()
- {
- isCreateState = false;
-
- if (vmView != null) {
- vmView.close();
- }
- }
-
- public VMsProperty confirm() {
- return vmView.confirm();
- }
-
- public void setLayoutData(Object data) {
- detailTable.setLayoutData(data);
- }
-}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.da.widgets.button.toggle.DACustomToggleButton;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+class DetailItemList {
+ private static ArrayList<DetailViewItem> list = null;
+ public static ArrayList<DetailViewItem> getItemList() {
+ //if (list == null) {
+ makeList();
+ //}
+ return list;
+ }
+
+ private static void makeList() {
+ list = new ArrayList<DetailViewItem>();
+
+ list.add(new TNameTextItem());
+ list.add(new TDisplayItem());
+ list.add(new TRAMItem());
+ list.add(new TTouchPointItem());
+ list.add(new TFileShareItem());
+ list.add(new THWSupportItem());
+ }
+}
+
+public abstract class DetailViewItem {
+ protected Composite comp = null;
+ protected DetailViewItem upperItem = null;
+ protected DetailViewItem downItem = null;
+ protected Label titleLabel;
+ protected String title;
+ private boolean isCreateMode;
+ private boolean isMinMode = false;
+
+ private DACustomToggleButton arrowButton;
+ protected int count;
+
+ protected DetailViewItem item;
+
+ // for modify
+ private DetailViewItemChangeListener listener;
+
+ public DetailViewItemChangeListener getListener() {
+ return listener;
+ }
+
+ public void setListener(DetailViewItemChangeListener listener) {
+ this.listener = listener;
+ }
+
+ public DetailViewItem() {
+ this.item = this;
+ }
+
+ public DetailViewItem getThis() {
+ return item;
+ }
+
+ public void setDownItem(DetailViewItem down) {
+ this.downItem = down;
+ }
+
+ protected ArrayList<Composite> compList = new ArrayList<Composite>();
+ protected static int ITEM_HEIGHT = 20;
+ protected static int TITILE_WIDTH = 100;
+
+ protected static int FILE_SELECT_BUTTON_WIDTH = 38;
+ protected static int FILE_SELECT_BUTTON_HEIGHT = 20;
+ protected static int TOGGLE_BUTTON_WIDTH = 38;
+ protected static int TOGGLE_BUTTON_HEIGHT = 20;
+
+ protected static int INPUTBOX_OFFSET = 118;
+ protected static int INPUTBOX_TOP_GAP = 1;
+
+ protected static int TITLE_TOP_GAP = 2;
+ protected static int TITLE_LEFT_GAP = 10;
+ protected static int TOP_ITEM_TOP_GAP = 3;
+ protected static int MIDDLE_ITEM_TOP_GAP = 7;
+ protected static int ITEM_LEFT_GAP = 3;
+ protected static int ITEM_RIGHT_GAP = -3;
+
+ public void initItem(Composite parent, DetailViewItem upperItem) {
+ this.upperItem = upperItem;
+ Composite up;
+ if (upperItem != null) {
+ upperItem.setDownItem(this);
+ up = upperItem.getBottomComposite();
+ } else {
+ up = null;
+ }
+
+ init();
+
+ for (int i = 0; i < count; i++) {
+ comp = new Composite(parent, SWT.NONE);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ITEM_LEFT_GAP);
+ if(up == null) {
+ data.top = new FormAttachment(0, TOP_ITEM_TOP_GAP);
+ } else {
+ data.top = new FormAttachment(up, MIDDLE_ITEM_TOP_GAP);
+ }
+ data.right = new FormAttachment(100, ITEM_RIGHT_GAP);
+ data.height = ITEM_HEIGHT;
+ comp.setLayoutData(data);
+ comp.setLayout(new FormLayout());
+ comp.setBackgroundImage(ImageResources.DETAIL_LIST_ITEM.getImage());
+
+ compList.add(comp);
+ up = comp;
+ }
+
+ //comp = new Composite(parent, SWT.NONE);
+ /*
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ if(up == null) {
+ data.top = new FormAttachment(0, 0);
+ } else {
+ data.top = new FormAttachment(up, 0);
+ }
+ data.right = new FormAttachment(100, 0);
+ data.height =ImageResources.DETAIL_LIST_ITEM.getImage().getImageData().height * count;
+ comp.setLayoutData(data);
+ comp.setLayout(new FormLayout());
+ comp.setBackgroundImage(ImageResources.DETAIL_LIST_ITEM.getImage());
+ */
+
+ initTitle(true);
+ }
+
+ private static int ARROW_BUTTON_WIDTH = 7;
+ private static int ARROW_BUTTON_HEIGHT = 7;
+ protected void initTitle(boolean supportMinMode) {
+ if (supportMinMode && count > 1) {
+ arrowButton = new DACustomToggleButton(compList.get(0),
+ ImageResources.ARROW_DOWN.getImage(),
+ ImageResources.ARROW_DOWN.getImage(),
+ ImageResources.ARROW_DOWN.getImage(),
+ null,
+ ImageResources.ARROW_UP.getImage(),
+ ImageResources.ARROW_UP.getImage());
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 2);
+ data.top = new FormAttachment(0, 6);
+ data.height = ARROW_BUTTON_WIDTH;
+ data.width = ARROW_BUTTON_HEIGHT;
+ arrowButton.setLayoutData(data);
+ arrowButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if (arrowButton.isToggled()) {
+ /*
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(up, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height =ImageResources.DETAIL_LIST_ITEM.getImage().getImageData().height;
+ compList.get(0).setLayoutData(data);
+ compList.get(0).getParent().layout(true, true);
+ */
+ for (int i = 1; i < count; i++) {
+ FormData data = new FormData();
+ data.height = 0;
+ compList.get(i).setLayoutData(data);
+ compList.get(i).getParent().layout(true, true);
+ }
+
+ if (downItem != null) {
+ downItem.changeUpComposite(compList.get(0));
+ }
+ } else {
+ /*
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(up, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height =ImageResources.DETAIL_LIST_ITEM.getImage().getImageData().height * count;
+ compList.get(0).setLayoutData(data);
+ compList.get(0).getParent().layout(true, true);
+ */
+ for (int i = 1; i < count; i++) {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ITEM_LEFT_GAP);
+ data.top = new FormAttachment(compList.get(i-1), MIDDLE_ITEM_TOP_GAP);
+ data.right = new FormAttachment(100, ITEM_RIGHT_GAP);
+ data.height = ITEM_HEIGHT;
+ compList.get(i).setLayoutData(data);
+ compList.get(i).getParent().layout(true, true);
+ }
+ if (downItem != null) {
+ downItem.changeUpComposite(compList.get(count-1));
+ }
+ }
+ }
+
+ });
+ }
+
+ titleLabel = new Label(compList.get(0), SWT.NONE);
+ titleLabel.setFont(FontResources.DETAIL_TITLE_FONT.getFont());
+ titleLabel.setForeground(ColorResources.DETAIL_TITILE_FONT_COLOR.getColor());
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, TITLE_LEFT_GAP);
+ data.top = new FormAttachment(0, TITLE_TOP_GAP);
+ data.height = ITEM_HEIGHT;
+ data.width = TITILE_WIDTH;
+ titleLabel.setLayoutData(data);
+ titleLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ titleLabel.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ drawTitle(e, title);
+ }
+ });
+ }
+
+ protected void drawTitle(PaintEvent e, String title) {
+ String text = title;
+ if (!titleLabel.isEnabled() || text == null) {
+ return;
+ }
+
+ Point p = null;
+
+ GC gc = e.gc;
+ gc.setFont(FontResources.DETAIL_TITLE_FONT.getFont());
+
+ int x = 0, y = 0;
+ int offset = 0;
+ p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ x = 0;
+ y = (e.height - p.y) / 2;
+
+ gc.setForeground(ColorResources.DETAIL_TITILE_FONT_COLOR.getColor());
+ gc.drawText(text, x + offset , y, true);
+ }
+
+ public ArrayList<Composite> getCompositeList() {
+ return compList;
+ }
+
+ public Composite getTopComposite() {
+ return compList.get(0);
+ }
+
+ public Composite getBottomComposite() {
+ return compList.get(compList.size()-1);
+ }
+
+ protected void changeUpComposite(Composite up) {
+ Composite comp = compList.get(0);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ITEM_LEFT_GAP);
+ if(up == null) {
+ data.top = new FormAttachment(0, TOP_ITEM_TOP_GAP);
+ } else {
+ data.top = new FormAttachment(up, MIDDLE_ITEM_TOP_GAP);
+ }
+ data.right = new FormAttachment(100, ITEM_RIGHT_GAP);
+ data.height = ITEM_HEIGHT;
+ comp.setLayoutData(data);
+ comp.getParent().layout(true, true);
+ }
+
+
+ /*
+ public void setEnabled(boolean enable) {
+ titleLabel.setEnabled(enable);
+ }
+ */
+
+ public boolean isCreateMode() {
+ return isCreateMode;
+ }
+
+ public void setCreateMode(boolean isCreateMode) {
+ this.isCreateMode = isCreateMode;
+ }
+
+ public boolean isMinMode() {
+ return isMinMode;
+ }
+
+ public void setMinMode(boolean isMinMode) {
+ this.isMinMode = isMinMode;
+ }
+
+ public int getCount() {
+ if (isMinMode) {
+ return 1;
+ } else {
+ return count;
+ }
+ }
+
+ public void close() {
+ titleLabel.dispose();
+
+ closeItem();
+ }
+
+ protected abstract void init();
+ public abstract void setValue(VMPropertyValue value);
+ public abstract void drawDetail();
+ public abstract void drawModify();
+ public abstract boolean settingDetailItem(VMPropertyValue value);
+ public abstract boolean settingModifyItem(VMPropertyValue value);
+ public abstract void closeItem();
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+// TODO: need new name
+enum State {
+ CREATE, MODIFY, CANCEL;
+}
+
+public interface DetailViewItemChangeListener {
+ public void ChangeValue(DetailViewItem item);
+ public void ChangeValue(boolean isChange);
+ public void ChangeState(State state);
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.ui.VMsDetailView;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public abstract class DetailViewPage {
+ protected VMsDetailView parent = null;
+ protected Composite view = null;
+ protected Composite itemListTop = null;
+ protected Composite itemList = null;
+ protected Composite buttonComp = null;
+
+ protected int ITEM_COUNT = 11;
+ public DetailViewPage(VMsDetailView parent, int style) {
+ this.parent = parent;
+ view = new Composite((Composite)parent.getComposite(), style);
+ view.setLayout(new FormLayout());
+ view.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+
+ itemListTop = new Composite(view, SWT.NONE);
+ Image topImage = ImageResources.DETAIL_LIST_TOP.getImage();
+ itemListTop.setBackgroundImage(topImage);
+ itemListTop.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+
+ itemList = new Composite(view, SWT.NONE);
+ // TODO
+ Image image = PatchImageResources.getDetailListView(ITEM_COUNT);
+ itemList.setBackgroundImage(image);
+ itemList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(0, 40);
+ data.height = topImage.getImageData().height;
+ data.width = topImage.getImageData().width;
+ itemListTop.setLayoutData(data);
+ itemListTop.setLayout(new FormLayout());
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(itemListTop, 0);
+ data.height = image.getImageData().height;
+ data.width = image.getImageData().width;
+ itemList.setSize(data.width, data.height);
+ itemList.setLayoutData(data);
+ itemList.setLayout(new FormLayout());
+
+ buttonComp = new Composite(view, SWT.NONE);
+ data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(itemList, 10);
+ data.right = new FormAttachment(100, -10);
+ data.bottom = new FormAttachment(100, -10);
+ buttonComp.setLayoutData(data);
+ buttonComp.setLayout(new FormLayout());
+ // TODO
+ buttonComp.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+
+ // draw child
+ drawInitView();
+ //
+ }
+
+ public Composite getComposite() {
+ return view;
+ }
+
+ private static int TOP_BUTTON_WIDTH = 21;
+ private static int TOP_BUTTON_HEIGHT = 21;
+ protected void makeListTop(DACustomButton button) {
+ Label title = new Label(itemListTop, SWT.NONE);
+ title.setBackground(ColorResources.DETAIL_TOP_COLOR.getColor());
+ title.setForeground(ColorResources.DETAIL_TOP_FONT_COLOR.getColor());
+ Font font = FontResources.DETAIL_TOP_FONT.getFont();
+ title.setFont(font);
+ title.setText("Detail");
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(45, 0);
+ data.top = new FormAttachment(0, 9);
+ title.setLayoutData(data);
+
+ if (null != button) {
+ data = new FormData();
+ data.top = new FormAttachment(0, 5);
+ data.right = new FormAttachment(100, -6);
+ data.width = TOP_BUTTON_WIDTH;
+ data.height = TOP_BUTTON_HEIGHT;
+ button.setLayoutData(data);
+ }
+ }
+
+ public void close() {
+ itemListTop.dispose();
+ itemList.dispose();
+ buttonComp.dispose();
+
+ view.dispose();
+ }
+
+ protected abstract void drawInitView();
+ public abstract void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate);
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonAttribute;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonDefaultRenderer;
+
+public class EMComboButtonRenderer extends DACustomButtonDefaultRenderer {
+
+ protected void drawButtonImage(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr) {
+ if (attr != null && attr.getButtonImage() != null) {
+ Image img = attr.getButtonImage();
+ Rectangle imgRect = img.getBounds();
+ int width = rect.width - imgRect.width;
+ int height = rect.height - imgRect.height;
+ int x = 0, y = 0;
+ if (width > 0) {
+ x = width / 2;
+ }
+
+ if (height > 0) {
+ y = height / 2;
+ }
+ gc.drawImage(img, x, y);
+ }
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.ui.VMsDetailView;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class PEmptyViewPage extends DetailViewPage {
+ public static String NO_ITEM = "No items selected";
+
+ public PEmptyViewPage(VMsDetailView parent, int style) {
+ super(parent, style);
+ }
+
+ @Override
+ protected void drawInitView() {
+ makeListTop(null);
+
+ // write message
+ Label title = new Label(itemList, SWT.NONE);
+ title.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ title.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ title.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ title.setText(NO_ITEM);
+
+ Point p = itemList.getSize();
+ int h = (int)FontResources.DETAIL_LABEL_FONT.getFont().getFontData()[0].getHeight();
+ FormData data = new FormData();
+ // TODO
+ data.left = new FormAttachment(0, (p.x - 5 * NO_ITEM.length()) / 2);
+ data.top = new FormAttachment(0, (p.y - h * 2) / 2);
+ title.setLayoutData(data);
+ }
+
+ @Override
+ public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) {
+ // empty function
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+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.VMsDetailView;
+import org.tizen.emulator.manager.ui.VMsMainView;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class PInfoViewPage extends DetailViewPage {
+
+ public PInfoViewPage(VMsDetailView parent, int style) {
+ super(parent, style);
+ }
+
+ private DACustomButton modifyButton;
+ @Override
+ protected void drawInitView() {
+ modifyButton = new DACustomButton(itemListTop,
+ ImageResources.MODIFY_BUTTON_NOMAL.getImage(),
+ ImageResources.MODIFY_BUTTON_PUSH.getImage(),
+ ImageResources.MODIFY_BUTTON_HOVER.getImage(),
+ null);
+ modifyButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMsMainView.getInstance().drawModifyVM();
+ }
+ });
+
+ makeListTop(modifyButton);
+
+ makeDetailView();
+ makeButton();
+ }
+
+ private ArrayList<DetailViewItem> list;
+ private void makeDetailView() {
+ list = DetailItemList.getItemList();
+
+ DetailViewItem item = null;
+ DetailViewItem up = null;
+ for (int i = 0; i < list.size(); i++) {
+ item = list.get(i);
+ item.initItem(itemList, up);
+ item.drawDetail();
+ up = item;
+ }
+ itemList.layout(true, true);
+ }
+
+ private DACustomButton createButton;
+ private DACustomButton deleteButton;
+ private DACustomButton resetButton;
+ private static int BUTTON_WIDTH = 92;
+ private static int BUTTON_HEIGHT = 36;
+ private static Image BUTTON_IMAGE = null;
+ private void makeButton() {
+ if (BUTTON_IMAGE == null) {
+ BUTTON_IMAGE = PatchImageResources.getNomalButton(BUTTON_WIDTH);
+ }
+ createButton = new DACustomButton(buttonComp,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ null);
+ createButton.setText(StringResources.CREATE_IMAGE);
+ createButton.setEnabled(true);
+
+ deleteButton = new DACustomButton(buttonComp,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ null);
+ deleteButton.setText(StringResources.DELETE);
+ deleteButton.setEnabled(true);
+
+ resetButton = new DACustomButton(buttonComp,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ BUTTON_IMAGE,
+ null);
+ resetButton.setText(StringResources.RESET);
+ resetButton.setEnabled(true);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ data.width = 92;
+ data.height = BUTTON_HEIGHT;
+ createButton.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(createButton, 14);
+ data.top = new FormAttachment(0, 0);
+ data.width = BUTTON_WIDTH;
+ data.height = BUTTON_HEIGHT;
+ deleteButton.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(deleteButton, 14);
+ data.top = new FormAttachment(0, 0);
+ data.width = BUTTON_WIDTH;
+ data.height = BUTTON_HEIGHT;
+ resetButton.setLayoutData(data);
+
+ addButtonListener();
+ }
+
+ private void addButtonListener() {
+ createButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMsMainView.getInstance().createBaseImage();
+ }
+ });
+
+ deleteButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMsMainView.getInstance().deleteEmulator();
+ }
+ });
+
+ resetButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ VMsMainView.getInstance().resetEmulator();
+ }
+ });
+ }
+
+ @Override
+ public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) {
+ assert propertyValue == null;
+
+ for (DetailViewItem item : list) {
+ item.settingDetailItem(propertyValue);
+ }
+ }
+
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.VMsDetailView;
+import org.tizen.emulator.manager.ui.VMsMainView;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class PModifyViewPage extends DetailViewPage
+ implements DetailViewItemChangeListener {
+
+ public PModifyViewPage(VMsDetailView parent, int style) {
+ super(parent, style);
+ }
+
+ private DACustomButton cancelButton;
+ private boolean isCreateMode = false;
+
+ @Override
+ protected void drawInitView() {
+ cancelButton = new DACustomButton(itemListTop,
+ ImageResources.CANCEL_BUTTON_NOMAL.getImage(),
+ ImageResources.CANCEL_BUTTON_PUSH.getImage(),
+ ImageResources.CANCEL_BUTTON_HOVER.getImage(),
+ null);
+ cancelButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ cancelModify();
+ }
+ });
+
+ makeListTop(cancelButton);
+
+ makeModifyView();
+ makeButton();
+ }
+
+ protected void cancelModify() {
+ if (isCreateMode) {
+ VMsMainView.getInstance().drawCancelCreaetVM();
+ isCreateMode = false;
+ } else {
+ VMsMainView.getInstance().drawDetailVM();
+ }
+ }
+
+ private ArrayList<DetailViewItem> list;
+ private void makeModifyView() {
+ list = DetailItemList.getItemList();
+
+ DetailViewItem item = null;
+ DetailViewItem up = null;
+ for (int i = 0; i < list.size(); i++) {
+ item = list.get(i);
+ item.initItem(itemList, up);
+ item.drawModify();
+ item.setListener(this);
+ up = item;
+ }
+
+ itemList.layout(true, true);
+ }
+
+ private static int CONFIRM_BUTTON_WIDTH = 303;
+ private static int CONFIRM_BUTTON_HEIGHT = 36;
+ private static Image CONFIRM_BUTTON_IMAGE = null;
+ private DACustomButton confirmButton;
+
+ private void makeButton() {
+ if (CONFIRM_BUTTON_IMAGE == null) {
+ CONFIRM_BUTTON_IMAGE = PatchImageResources.getNomalButton(CONFIRM_BUTTON_WIDTH);
+ }
+ confirmButton = new DACustomButton(buttonComp,
+ CONFIRM_BUTTON_IMAGE,
+ CONFIRM_BUTTON_IMAGE,
+ CONFIRM_BUTTON_IMAGE,
+ CONFIRM_BUTTON_IMAGE);
+ confirmButton.setText(StringResources.CONFIRM);
+ confirmButton.setEnabled(false);
+ confirmButton.setFontColor(DACustomButton.STATE_DISABLE,
+ ColorResources.BUTTON_DISABLE_FONT_COLOR.getColor());
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ data.height = CONFIRM_BUTTON_HEIGHT;
+ data.width = CONFIRM_BUTTON_WIDTH;
+ confirmButton.setLayoutData(data);
+
+ confirmButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ modifyVMProperty();
+ }
+ });
+ }
+
+ private void modifyVMProperty() {
+ for (DetailViewItem item : list) {
+ item.setValue(newValue);
+ }
+ // dpi check
+ if (newValue.dpi < VMProperty.MIN_DPI
+ || newValue.dpi > VMProperty.MAX_DPI) {
+ String msg = "Invalid value." +
+ StringResources.NEW_LINE + "Display Density should be from 100 to 480";
+ EMLogger.getLogger().warning(msg);
+ new MessageDialog().openWarningDialog(msg);
+ return;
+ }
+
+ if (isCreateMode) {
+ if (!VMsMainView.getInstance().createEmualtor(newValue)) {
+ return;
+ }
+ } else {
+ if (!VMsMainView.getInstance().modifyEmulator(newValue)) {
+ return;
+ }
+ }
+
+ MainDialog.refreshVMPropertyList();
+ }
+
+ VMPropertyValue oldValue;
+ VMPropertyValue newValue;
+ @Override
+ public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) {
+ assert propertyValue == null;
+
+ confirmButton.setEnabled(false);
+ buttonComp.layout(true, true);
+
+ isCreateMode = isCreate;
+ oldValue = propertyValue;
+ newValue = oldValue.clone();
+ for (DetailViewItem item : list) {
+ item.setCreateMode(isCreate);
+ item.settingModifyItem(propertyValue);
+ }
+ }
+
+ // DetailViewItemChangeListner
+ @Override
+ public void ChangeValue(DetailViewItem item) {
+ item.setValue(newValue);
+ if (!oldValue.equals(newValue)) {
+ confirmButton.setEnabled(true);
+ } else {
+ confirmButton.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void ChangeValue(boolean isChange) {
+ confirmButton.setEnabled(isChange);
+ }
+
+ @Override
+ public void ChangeState(State state) {
+ if (state == State.CREATE) {
+ if (confirmButton.isEnabled()) {
+ modifyVMProperty();
+ }
+ } else if (state == State.CANCEL) {
+ cancelModify();
+ }
+ }
+ //
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.Spinner;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomCombo;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomComboSelectionListener;
+import org.tizen.emulator.manager.da.widgets.combo.TitleComboPopupRenderer;
+import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.ui.widgets.ModifyViewCombo;
+import org.tizen.emulator.manager.ui.widgets.ModifyViewComboRenderer;
+import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.SKIN_TYPE;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TDisplayItem extends DetailViewItem {
+ private RESOLUTION oldResolution;
+ private RESOLUTION newResolution;
+ private int oldDPI;
+ private int newDPI;
+ private Skin oldSkin;
+ private Skin newSkin;
+
+ @Override
+ public void init() {
+ title = "Display";
+ count = 3;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.resolution = newResolution;
+ value.dpi = newDPI;
+ value.skin = newSkin;
+ if (newSkin != null) {
+ value.skinPath = newSkin.getPath();
+ } else {
+ value.skinPath = null;
+ }
+ }
+
+ private ImageLabel reCategory;
+ private ImageLabel dpiCategory;
+ private ImageLabel skinCategory;
+ private ImageLabel resolution;
+ private ImageLabel dpi;
+ private ImageLabel skin;
+
+ private static int CATEGORY_WIDTH = 66;
+ private static int INPUTBOX_WIDTH = 110;
+ private static Image CATEGORY_IMAGE = null;
+ private static Image INPUTBOX_ON_IMAGE = null;
+ private static Image INPUTBOX_OFF_IMAGE = null;
+
+ private void drawCategory() {
+ if (CATEGORY_IMAGE == null) {
+ CATEGORY_IMAGE = PatchImageResources.getCategoryBox(CATEGORY_WIDTH);
+ }
+
+ reCategory = new ImageLabel(compList.get(0), SWT.NONE);
+ reCategory.setText("Resolution");
+ reCategory.setImage(ImageLabel.STATE_ENABLE, CATEGORY_IMAGE);
+ reCategory.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ reCategory.setForeground(ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = reCategory.getSize().x;
+ data.height = reCategory.getSize().y;
+ reCategory.setLayoutData(data);
+
+ dpiCategory = new ImageLabel(compList.get(1), SWT.NONE);
+ dpiCategory.setText("Density");
+ dpiCategory.setImage(ImageLabel.STATE_ENABLE, CATEGORY_IMAGE);
+ dpiCategory.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ dpiCategory.setForeground(ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = dpiCategory.getSize().x;
+ data.height = dpiCategory.getSize().y;
+ dpiCategory.setLayoutData(data);
+
+ skinCategory = new ImageLabel(compList.get(2), SWT.NONE);
+ skinCategory.setText("Skin");
+ skinCategory.setImage(ImageLabel.STATE_ENABLE, CATEGORY_IMAGE);
+ skinCategory.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ skinCategory.setForeground(ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = skinCategory.getSize().x;
+ data.height = skinCategory.getSize().y;
+ skinCategory.setLayoutData(data);
+ }
+
+ @Override
+ public void drawDetail() {
+ drawCategory();
+
+ if (INPUTBOX_OFF_IMAGE == null) {
+ INPUTBOX_OFF_IMAGE = PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH);
+ }
+
+ resolution = new ImageLabel(compList.get(0), SWT.NONE);
+ resolution.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_OFF_IMAGE);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(reCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = resolution.getSize().x;
+ data.height = resolution.getSize().y;
+ resolution.setLayoutData(data);
+
+ dpi = new ImageLabel(compList.get(1), SWT.NONE);
+ dpi.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_OFF_IMAGE);
+
+ data = new FormData();
+ data.left = new FormAttachment(dpiCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = dpi.getSize().x;
+ data.height = dpi.getSize().y;
+ dpi.setLayoutData(data);
+
+ skin = new ImageLabel(compList.get(2), SWT.NONE);
+ skin.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_OFF_IMAGE);
+
+ data = new FormData();
+ data.left = new FormAttachment(skinCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = skin.getSize().x;
+ data.height = skin.getSize().y;
+ skin.setLayoutData(data);
+ }
+
+ private DACustomCombo reCombo = null;
+ private Spinner dpiSpinner = null;
+ private DACustomCombo skinCombo = null;
+ @Override
+ public void drawModify() {
+ drawCategory();
+
+ if (INPUTBOX_ON_IMAGE == null) {
+ INPUTBOX_ON_IMAGE = PatchImageResources.getInputBoxON(INPUTBOX_WIDTH);
+ }
+
+ reCombo = new ModifyViewCombo(compList.get(0), SWT.NONE);
+ reCombo.setImages(INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE);
+ reCombo.setButtonImages(ImageResources.ARROW_DROPDOWN.getImage(), null);
+ reCombo.setEnabled(true);
+
+ // TODO
+ reCombo.setComboRender(new ModifyViewComboRenderer());
+ reCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ reCombo.setItemHeight(INPUTBOX_ON_IMAGE.getImageData().height);
+ //
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(reCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = INPUTBOX_ON_IMAGE.getImageData().width;
+ data.height = INPUTBOX_ON_IMAGE.getImageData().height;
+ reCombo.setLayoutData(data);
+
+ dpi = new ImageLabel(compList.get(1), SWT.NONE);
+ dpi.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_ON_IMAGE);
+
+ data = new FormData();
+ data.left = new FormAttachment(dpiCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = dpi.getSize().x;
+ data.height = dpi.getSize().y;
+ dpi.setLayoutData(data);
+
+ dpi.setLayout(new FormLayout());
+
+ dpiSpinner = new Spinner(dpi, SWT.NONE);
+ dpiSpinner.setValues(0, 0, 999, 0, 1, 1);
+ dpiSpinner.setTextLimit(3);
+
+ dpiSpinner.setBackground(ColorResources.DETAIL_INPUT_BOX_COLOR.getColor());
+ dpiSpinner.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ dpiSpinner.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 5);
+ data.top = new FormAttachment(0, 1);
+ data.right = new FormAttachment(100, -2);
+ data.bottom = new FormAttachment(100, -2);
+ dpiSpinner.setLayoutData(data);
+
+
+ skinCombo = new ModifyViewCombo(compList.get(2), SWT.NONE);
+ skinCombo.setImages(INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE);
+ skinCombo.setButtonImages(ImageResources.ARROW_DROPDOWN.getImage(), null);
+ skinCombo.setEnabled(true);
+
+ skinCombo.setComboRender(new ModifyViewComboRenderer());
+ skinCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ skinCombo.setItemHeight(INPUTBOX_ON_IMAGE.getImageData().height);
+ //
+
+ data = new FormData();
+ data.left = new FormAttachment(skinCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = INPUTBOX_ON_IMAGE.getImageData().width;
+ data.height = INPUTBOX_ON_IMAGE.getImageData().height;
+ skinCombo.setLayoutData(data);
+
+ addWidgetListener();
+ }
+
+ private void addWidgetListener() {
+ reCombo.addSelectionListener(new DACustomComboSelectionListener() {
+ @Override
+ public void selectionEvent(DACustomCombo combo) {
+ String re = combo.getText();
+ reCombo.setToolTipText(combo.getText());
+
+ RESOLUTION d = DisplayResolution.getInstance().findResolution(re);
+ if (d != null) {
+ newResolution = d;
+ changeResolution(d);
+ }
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+ dpiSpinner.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ newDPI = dpiSpinner.getSelection();
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+ skinCombo.addSelectionListener(new DACustomComboSelectionListener() {
+ @Override
+ public void selectionEvent(DACustomCombo combo) {
+ String name = combo.getText();
+ skinCombo.setToolTipText(combo.getText());
+
+ newSkin = SkinList.getInstance().findSkinUseName(name);
+ if (newSkin == null && name.equals(oldSkin)) {
+ newSkin = oldSkin;
+ }
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+ }
+
+ @Override
+ public void closeItem() {
+ reCategory.dispose();
+ dpiCategory.dispose();
+ skinCategory.dispose();
+ if (resolution != null) {
+ resolution.dispose();
+ }
+ if (dpi != null) {
+ dpi.dispose();
+ }
+ if (skin != null) {
+ skin.dispose();
+ }
+
+ if (reCombo != null) {
+ reCombo.dispose();
+ }
+
+ if (dpiSpinner != null) {
+ dpiSpinner.dispose();
+ }
+
+ if (skinCombo != null) {
+ skinCombo.dispose();
+ }
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ resolution.setText(value.resolution.getStrTypeValue());
+ resolution.setToolTipText(value.resolution.getStrTypeValue());
+
+ dpi.setText(Integer.toString(value.dpi));
+
+ skin.setText(value.skin.getName());
+ skin.setToolTipText(value.skin.getName());
+
+ return false;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ oldResolution = newResolution = value.resolution;
+ newDPI = oldDPI = value.dpi;
+ newSkin = oldSkin = value.skin;
+
+ //RESOLUTION
+ DisplayResolution.getInstance().initialize(oldResolution);
+ reCombo.initCombo();
+
+ String r = null;
+ int f = -1;
+ for (int i = 0; i < DisplayResolution.getInstance().getList().length; i++) {
+ r = DisplayResolution.getInstance().get(i);
+ if (r.equals(oldResolution.toString())) {
+ f = i;
+ }
+ reCombo.add(r);
+ }
+
+ if (f == -1) {
+ reCombo.add(oldResolution.toString(), 0);
+ f = 0;
+ }
+ reCombo.select(f);
+ reCombo.setToolTipText(reCombo.getText());
+
+ // DPI
+ dpiSpinner.setSelection(value.dpi);
+
+ // SKIN
+ settingSkinList(value.resolution);
+
+ return true;
+ }
+
+ private void settingSkinList(RESOLUTION re) {
+ skinCombo.initCombo();
+
+ int find = -1;
+ ArrayList<Skin> skinList = null;
+
+ if (!isCreateMode()
+ && !DisplayResolution.getInstance().isMinResoluion(re)
+ && EmulatorManager.getManagerMode() != ManagerModeType.INHOUSE_MODE) {
+ skinCombo.add(oldSkin.toString());
+ find = 0;
+ } else {
+ skinList
+ = SkinList.getInstance().findSkinList(re);
+
+ Skin s = null;
+ for (int i = 0; i < skinList.size(); i++) {
+ s = skinList.get(i);
+ if (newSkin != null && newSkin.equals(s)) {
+ find = i;
+ }
+ skinCombo.add(s.toString());
+ }
+
+ if (find == -1) {
+ if (newSkin != null
+ && newSkin.getType() == SKIN_TYPE.GENERAL) {
+ skinList.add(0, newSkin);
+ skinCombo.add(newSkin.toString(), 0);
+ }
+ find = 0;
+ }
+ }
+
+ if (find >= 0) {
+ skinCombo.select(find);
+ skinCombo.setToolTipText(skinCombo.getText());
+ newSkin = skinList == null ? oldSkin : skinList.get(find);
+ }
+ }
+
+ private void changeResolution(RESOLUTION re) {
+ // DPI
+ if (!DisplayResolution.getInstance().isMinResoluion(re)
+ && EmulatorManager.getManagerMode() != ManagerModeType.INHOUSE_MODE) {
+ dpiSpinner.setSelection(oldDPI);
+ } else {
+ dpiSpinner.setSelection(re.getDPI());
+ }
+
+ // SKIN
+ settingSkinList(re);
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.io.File;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.da.widgets.button.toggle.DACustomToggleButton;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TFileShareItem extends DetailViewItem {
+ private boolean oldSupport;
+ private boolean newSupport;
+
+ private String newPath;
+ private String oldPathName;
+ private String newPathName;
+ private DirectoryDialog sharedFD;
+
+ @Override
+ protected void init() {
+ title = "File Sharing";
+ count = 2;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.isFileShareSupport = newSupport;
+
+ value.fileSharePath = newPath;
+ value.fileSharePathName = newPathName;
+ }
+
+
+ private ImageLabel supportLabel;
+ private ImageLabel dirCategory;
+ private ImageLabel directoryLabel;
+
+ private static int INPUTBOX_WIDTH = 180;
+ private static int DIR_CATEGORY_WIDTH = 66;
+ private static int DIR_INPUTBOX_OFF_WIDTH = 110;
+ // for modify
+ private static int DIR_INPUTBOX_ON_WIDTH = 140;
+
+ @Override
+ public void drawDetail() {
+ supportLabel = new ImageLabel(compList.get(0), SWT.NONE);
+ supportLabel.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+
+ dirCategory = new ImageLabel(compList.get(1), SWT.NONE);
+ dirCategory.setText("Directory");
+ dirCategory.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getCategoryBox(DIR_CATEGORY_WIDTH));
+ dirCategory.setFontColor(ImageLabel.STATE_ENABLE,
+ ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+
+ directoryLabel = new ImageLabel(compList.get(1), SWT.NONE);
+ directoryLabel.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(DIR_INPUTBOX_OFF_WIDTH));
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = supportLabel.getSize().x;
+ data.height = supportLabel.getSize().y;
+ supportLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = dirCategory.getSize().x;
+ data.height = dirCategory.getSize().y;
+ dirCategory.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(dirCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = directoryLabel.getSize().x;
+ data.height = directoryLabel.getSize().y;
+ directoryLabel.setLayoutData(data);
+
+ comp.layout(true, true);
+ }
+
+ private Label stateLabel;
+ private DACustomToggleButton selectSupport;
+ private DACustomButton selectDirButton;
+
+ private static String toolTipforMac = "Please refer to file sharing section in SDK documentation.";
+ @Override
+ public void drawModify() {
+ if (EmulatorManager.isMac()) {
+ drawDetail();
+ } else {
+ makeModifyWidget();
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, 0);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ data.height = TOGGLE_BUTTON_HEIGHT;
+ selectSupport.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(selectSupport, 10);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ stateLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0,INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = directoryLabel.getSize().x;
+ data.height = directoryLabel.getSize().y;
+ directoryLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(directoryLabel, 5);
+ data.top = new FormAttachment(0, 0);
+ data.width = FILE_SELECT_BUTTON_WIDTH;
+ data.height = FILE_SELECT_BUTTON_HEIGHT;
+ selectDirButton.setLayoutData(data);
+ }
+ }
+
+ private void makeModifyWidget() {
+ selectSupport = new DACustomToggleButton(compList.get(0),
+ ImageResources.TOGGLE_ON_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_PUSH.getImage(),
+ ImageResources.TOGGLE_ON_HOVER.getImage(),
+ null,
+ ImageResources.TOGGLE_OFF_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_HOVER.getImage());
+
+ selectSupport.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if (selectSupport.isToggled()) { // NOT SUPPORT
+ newSupport = false;
+ stateLabel.setText(StringResources.NOT_SUPPORTED);
+ directoryLabel.setText("");
+ selectDirButton.setEnabled(false);
+ } else { // SUPPORT
+ newSupport = true;
+ stateLabel.setText(StringResources.SUPPORTED);
+ directoryLabel.setText(newPathName);
+ selectDirButton.setEnabled(true);
+ }
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+ stateLabel = new Label(compList.get(0), SWT.NONE);
+ stateLabel.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ stateLabel.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ stateLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+
+ directoryLabel = new ImageLabel(compList.get(1), SWT.NONE);
+ directoryLabel.setImage(ImageLabel.STATE_DISABLE,
+ PatchImageResources.getInputBoxON(DIR_INPUTBOX_ON_WIDTH));
+ directoryLabel.setEnabled(false);
+
+ selectDirButton = new DACustomButton(compList.get(1),
+ ImageResources.BUTTON_FILE_NOMAL.getImage(),
+ ImageResources.BUTTON_FILE_PUSH.getImage(),
+ ImageResources.BUTTON_FILE_HOVER.getImage(),
+ ImageResources.BUTTON_FILE_DISABLE.getImage());
+
+ selectDirButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if(sharedFD == null) {
+ sharedFD = new DirectoryDialog(
+ MainDialog.getShell(), SWT.OPEN);
+ sharedFD.setText("Select directory");
+ }
+
+ String path = sharedFD.open();
+ if (path != null) {
+ newPath = path;
+ newPath = path;
+ newPathName = path.substring(path
+ .lastIndexOf(File.separator) + 1, path.length());
+ directoryLabel.setText(newPathName);
+ directoryLabel.setToolTipText(newPath);
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ supportLabel.setText(value.isFileShareSupport
+ ? StringResources.SUPPORTED
+ : StringResources.NOT_SUPPORTED);
+
+ directoryLabel.setText(value.isFileShareSupport
+ ? value.fileSharePathName
+ : "");
+ directoryLabel.setToolTipText(value.fileSharePath);
+
+ return true;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ newSupport = oldSupport = value.isFileShareSupport;
+ newPath = value.fileSharePath;
+ newPathName = oldPathName = value.fileSharePathName;
+
+ if (EmulatorManager.isMac()) {
+ supportLabel.setText(StringResources.MANUAL_SUPPORT);
+ supportLabel.setToolTipText(toolTipforMac);
+ directoryLabel.setText("");
+ directoryLabel.setToolTipText(toolTipforMac);
+ } else {
+ if (oldSupport) {
+ selectSupport.setToggled(false);
+ stateLabel.setText(StringResources.SUPPORTED);
+ directoryLabel.setText(oldPathName);
+ directoryLabel.setToolTipText(newPath);
+ selectDirButton.setEnabled(true);
+ } else {
+ selectSupport.setToggled(true);
+ stateLabel.setText(StringResources.NOT_SUPPORTED);
+ directoryLabel.setText(oldPathName);
+ selectDirButton.setEnabled(false);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void closeItem() {
+ if (supportLabel != null) {
+ supportLabel.dispose();
+ }
+
+ if (dirCategory != null) {
+ dirCategory.dispose();
+ }
+
+ if (directoryLabel != null) {
+ directoryLabel.dispose();
+ }
+
+ if (stateLabel != null) {
+ stateLabel.dispose();
+ }
+
+ if (selectSupport != null) {
+ selectSupport.dispose();
+ }
+
+ if (selectDirButton != null) {
+ selectDirButton.dispose();
+ }
+ }
+
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.da.widgets.button.toggle.DACustomToggleButton;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.tool.CheckVirtualization;
+import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class THWSupportItem extends DetailViewItem {
+ private boolean oldHWSupport;
+ private boolean newHWSupport;
+ private boolean oldGPUSupport;
+ private boolean newGPUSupport;
+
+ @Override
+ protected void init() {
+ title = "HW Support";
+ count = 2;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.isHWVirtualization = newHWSupport;
+ value.isGLAcceleration = newGPUSupport;
+ }
+
+ private ImageLabel virtualCategory;
+ private ImageLabel GPUCategory;
+
+ private ImageLabel virtualLabel;
+ private ImageLabel GPULabel;
+
+ private static int INPUTBOX_WIDTH = 100;
+ private static int CATEGORY_WIDTH = 76;
+
+ private static String GPUToolTipText = "If you enable the GPU option,"
+ + StringResources.NEW_LINE
+ + "the rendering performance of video player or camera may degrade.";
+
+ private void makeCategory() {
+ virtualCategory = new ImageLabel(compList.get(0), SWT.NONE);
+ virtualCategory.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getCategoryBox(CATEGORY_WIDTH));
+ virtualCategory.setFontColor(ImageLabel.STATE_ENABLE,
+ ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+ virtualCategory.setText("Virtualization");
+
+ GPUCategory = new ImageLabel(compList.get(1), SWT.NONE);
+ GPUCategory.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getCategoryBox(CATEGORY_WIDTH));
+ GPUCategory.setFontColor(ImageLabel.STATE_ENABLE,
+ ColorResources.DETAIL_CATEGORY_FONT_COLOR.getColor());
+ GPUCategory.setText("GPU");
+ GPUCategory.setToolTipText(GPUToolTipText);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = virtualCategory.getSize().x;
+ data.height = virtualCategory.getSize().y;
+ virtualCategory.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = GPUCategory.getSize().x;
+ data.height = GPUCategory.getSize().y;
+ GPUCategory.setLayoutData(data);
+ }
+
+ @Override
+ public void drawDetail() {
+ makeCategory();
+
+ virtualLabel = new ImageLabel(compList.get(0), SWT.NONE);
+ virtualLabel.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+
+ GPULabel = new ImageLabel(compList.get(1), SWT.NONE);
+ GPULabel.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+ GPULabel.setToolTipText(GPUToolTipText);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(virtualCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = virtualLabel.getSize().x;
+ data.height = virtualLabel.getSize().y;
+ virtualLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(GPUCategory, 4);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = GPULabel.getSize().x;
+ data.height = GPULabel.getSize().y;
+ GPULabel.setLayoutData(data);
+ }
+
+ private DACustomToggleButton virtualButton;
+ private DACustomToggleButton GPUButton;
+ private Label virtualState;
+ private Label GPUState;
+ @Override
+ public void drawModify() {
+ makeCategory();
+ makeModifyWidget();
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(virtualCategory, 4);
+ data.top = new FormAttachment(0, 0);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ data.height = TOGGLE_BUTTON_HEIGHT;
+ virtualButton.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(virtualButton, 10);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ virtualState.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(GPUCategory, 4);
+ data.top = new FormAttachment(0, 0);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ data.height = TOGGLE_BUTTON_HEIGHT;
+ GPUButton.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(GPUButton, 10);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = TOGGLE_BUTTON_WIDTH;
+ GPUState.setLayoutData(data);
+ }
+
+ private void makeModifyWidget() {
+ virtualButton = new DACustomToggleButton(compList.get(0),
+ ImageResources.TOGGLE_ON_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_PUSH.getImage(),
+ ImageResources.TOGGLE_ON_HOVER.getImage(),
+ ImageResources.TOGGLE_OFF_PUSH.getImage(),
+ ImageResources.TOGGLE_OFF_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_HOVER.getImage());
+
+ virtualButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if (virtualButton.isToggled()) { // NOT SUPPORT
+ newHWSupport = false;
+ virtualState.setText(StringResources.NOT_SUPPORTED);
+ } else { // SUPPORT
+ newHWSupport = true;
+ virtualState.setText(StringResources.SUPPORTED);
+ }
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+ virtualState = new Label(compList.get(0), SWT.NONE);
+ virtualState.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ virtualState.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ virtualState.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+
+ GPUButton = new DACustomToggleButton(compList.get(1),
+ ImageResources.TOGGLE_ON_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_PUSH.getImage(),
+ ImageResources.TOGGLE_ON_HOVER.getImage(),
+ ImageResources.TOGGLE_OFF_PUSH.getImage(),
+ ImageResources.TOGGLE_OFF_NOMAL.getImage(),
+ ImageResources.TOGGLE_OFF_HOVER.getImage());
+
+ GPUButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if (GPUButton.isToggled()) { // NOT SUPPORT
+ newGPUSupport = false;
+ GPUState.setText(StringResources.NOT_SUPPORTED);
+ } else { // SUPPORT
+ newGPUSupport = true;
+ GPUState.setText(StringResources.SUPPORTED);
+ }
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+ GPUButton.setToolTipText(GPUToolTipText);
+
+ GPUState = new Label(compList.get(1), SWT.NONE);
+ GPUState.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ GPUState.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ GPUState.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ }
+
+ private boolean isArm = false;
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ isArm = value.archType.equals("arm");
+
+ virtualLabel.setText(value.isHWVirtualization
+ && CheckVirtualization.getInstance().isSupportVirtualization()
+ && !isArm
+ ? StringResources.SUPPORTED
+ : StringResources.NOT_SUPPORTED);
+
+ GPULabel.setText(value.isGLAcceleration
+ && CheckVirtualization.getInstance().isSupportGPU()
+ && !isArm
+ ? StringResources.SUPPORTED
+ : StringResources.NOT_SUPPORTED);
+
+ return false;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ isArm = value.archType.equals("arm");
+ if (isCreateMode() && isArm) {
+ newHWSupport = oldHWSupport = false;
+ newGPUSupport = oldGPUSupport = false;
+ } else {
+ newHWSupport = oldHWSupport = value.isHWVirtualization;
+ newGPUSupport = oldGPUSupport = value.isGLAcceleration;
+ }
+
+ if (oldHWSupport && !isArm
+ && CheckVirtualization.getInstance().isSupportVirtualization()) {
+ virtualButton.setToggled(false);
+ virtualState.setText(StringResources.SUPPORTED);
+ } else {
+ virtualButton.setToggled(true);
+ virtualState.setText(StringResources.NOT_SUPPORTED);
+ }
+
+ if (!CheckVirtualization.getInstance().isSupportVirtualization()
+ || isArm) {
+ virtualButton.setEnabled(false);
+ }
+
+ if (oldGPUSupport && !isArm
+ && CheckVirtualization.getInstance().isSupportGPU()) {
+ GPUButton.setToggled(false);
+ GPUState.setText(StringResources.SUPPORTED);
+ } else {
+ GPUButton.setToggled(true);
+ GPUState.setText(StringResources.NOT_SUPPORTED);
+ }
+
+ if (!CheckVirtualization.getInstance().isSupportGPU() || isArm) {
+ GPUButton.setEnabled(false);
+ }
+ return false;
+ }
+
+ @Override
+ public void closeItem() {
+ if (virtualCategory != null) {
+ virtualCategory.dispose();
+ }
+
+ if (GPUCategory != null) {
+ GPUCategory.dispose();
+ }
+
+ if (virtualLabel != null) {
+ virtualLabel.dispose();
+ }
+
+ if (GPULabel != null) {
+ GPULabel.dispose();
+ }
+
+ if (virtualButton != null) {
+ virtualButton.dispose();
+ }
+
+ if (GPUButton != null) {
+ GPUButton.dispose();
+ }
+
+ if (virtualState != null) {
+ virtualState.dispose();
+ }
+
+ if (GPUState != null) {
+ GPUState.dispose();
+ }
+ }
+
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import java.io.File;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.ui.MainDialog;
+import org.tizen.emulator.manager.ui.MenuHandling;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.HelperClass;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TNameTextItem extends DetailViewItem {
+ private boolean isStandard;
+
+ // for vm name
+ private String oldName = "";
+ private String newName = "";
+
+ // for base image
+ private String subTitle;
+ private Label subTitleLabel;
+
+ private String newPath;
+ private String newPathName;
+ private FileDialog baseImageFD;
+ private boolean isSelected;
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.vmsName = newName;
+
+ value.baseImagePath = newPath;
+ value.baseImagePathName = newPathName;
+ }
+
+ @Override
+ public void init() {
+ title = "Name";
+ subTitle = "Base Image";
+ count = 2;
+ }
+
+ @Override
+ protected void initTitle(boolean supportMinMode) {
+ super.initTitle(false);
+
+ subTitleLabel = new Label(compList.get(1), SWT.NONE);
+
+ subTitleLabel.setFont(FontResources.DETAIL_TITLE_FONT.getFont());
+ subTitleLabel.setForeground(ColorResources.DETAIL_TITILE_FONT_COLOR.getColor());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, TITLE_LEFT_GAP);
+ data.top = new FormAttachment(0, TITLE_TOP_GAP);
+ data.height = ITEM_HEIGHT;
+ data.width = TITILE_WIDTH;
+ subTitleLabel.setLayoutData(data);
+ subTitleLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ subTitleLabel.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ drawTitle(e, subTitle);
+ }
+ });
+ }
+
+ private ImageLabel nameLabel;
+ private ImageLabel baseImageLabel;
+
+ private static int INPUTBOX_WIDTH = 180;
+ private static Image INPUTBOX_ON_IMAGE = null;
+ private static Image INPUTBOX_OFF_IMAGE = null;
+
+ // for modify (base image)
+ private static int IMAGE_INPUTBOX_WIDTH = 140;
+ private static Image IMAGE_INPUTBOX_IMAGE = null;
+
+ @Override
+ public void drawDetail() {
+ if (INPUTBOX_OFF_IMAGE == null) {
+ INPUTBOX_OFF_IMAGE = PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH);
+ }
+
+ nameLabel = new ImageLabel(compList.get(0), SWT.NONE);
+ nameLabel.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_OFF_IMAGE);
+ nameLabel.setImage(ImageLabel.STATE_DISABLE, INPUTBOX_OFF_IMAGE);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = nameLabel.getSize().x;
+ data.height = nameLabel.getSize().y;
+ nameLabel.setLayoutData(data);
+
+ baseImageLabel = new ImageLabel(compList.get(1), SWT.NONE);
+ baseImageLabel.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_OFF_IMAGE);
+ baseImageLabel.setImage(ImageLabel.STATE_DISABLE, INPUTBOX_OFF_IMAGE);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = baseImageLabel.getSize().x;
+ data.height = baseImageLabel.getSize().y;
+ baseImageLabel.setLayoutData(data);
+
+ comp.layout(true, true);
+ }
+
+ private Text nameText;
+ private DACustomButton selectImageButton;
+ @Override
+ public void drawModify() {
+ if (INPUTBOX_ON_IMAGE == null) {
+ INPUTBOX_ON_IMAGE = PatchImageResources.getInputBoxON(INPUTBOX_WIDTH);
+ }
+ if (IMAGE_INPUTBOX_IMAGE == null) {
+ IMAGE_INPUTBOX_IMAGE = PatchImageResources.getInputBoxON(IMAGE_INPUTBOX_WIDTH);
+ }
+
+ makeModifyNameLabel();
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = nameLabel.getSize().x;
+ data.height = nameLabel.getSize().y;
+ nameLabel.setLayoutData(data);
+
+ makeModifyBaseImage();
+
+ data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = baseImageLabel.getSize().x;
+ data.height = baseImageLabel.getSize().y;
+ baseImageLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(baseImageLabel, 5);
+ data.top = new FormAttachment(0, 0);
+ data.width = FILE_SELECT_BUTTON_WIDTH;
+ data.height = FILE_SELECT_BUTTON_HEIGHT;
+ selectImageButton.setLayoutData(data);
+ }
+
+ private void makeModifyNameLabel() {
+ nameLabel = new ImageLabel(compList.get(0), SWT.NONE);
+ nameLabel.setImage(ImageLabel.STATE_ENABLE, INPUTBOX_ON_IMAGE);
+ nameLabel.setImage(ImageLabel.STATE_DISABLE, INPUTBOX_ON_IMAGE);
+ nameLabel.setLayout(new FormLayout());
+
+ nameText = new Text(nameLabel, SWT.NONE);
+ nameText.setBackground(ColorResources.DETAIL_INPUT_BOX_COLOR.getColor());
+ nameText.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ nameText.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ nameText.setTextLimit(VMProperty.MAX_NAME_LEN);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 5);
+ data.top = new FormAttachment(0, 2);
+ data.right = new FormAttachment(100, -5);
+ data.bottom = new FormAttachment(100, -2);
+ nameText.setLayoutData(data);
+
+ nameText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ if (isCreateMode()) {
+ newName = nameText.getText();
+ checkVMName();
+ }
+ }
+ });
+
+ nameText.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ switch (event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
+ //TODO
+ //System.out.println("Enter");
+ getListener().ChangeState(State.CREATE);
+ break;
+ case SWT.ESC:
+ getListener().ChangeState(State.CANCEL);
+ break;
+ case SWT.TAB:
+ System.out.println("tab");
+ break;
+ }
+ }
+ });
+ }
+
+ private void checkVMName() {
+ if (HelperClass.checkImageName(newName, true)) {
+ if (isStandard) {
+ getListener().ChangeValue(true);
+ } else {
+ if (isSelected) {
+ getListener().ChangeValue(true);
+ } else {
+ getListener().ChangeValue(false);
+ }
+ }
+ } else {
+ getListener().ChangeValue(false);
+ }
+ }
+
+ private void makeModifyBaseImage() {
+ baseImageLabel = new ImageLabel(compList.get(1), SWT.NONE);
+ baseImageLabel.setImage(ImageLabel.STATE_ENABLE, IMAGE_INPUTBOX_IMAGE);
+ baseImageLabel.setImage(ImageLabel.STATE_DISABLE, IMAGE_INPUTBOX_IMAGE);
+
+ selectImageButton = new DACustomButton(compList.get(1),
+ ImageResources.BUTTON_FILE_NOMAL.getImage(),
+ ImageResources.BUTTON_FILE_PUSH.getImage(),
+ ImageResources.BUTTON_FILE_HOVER.getImage(),
+ ImageResources.BUTTON_FILE_DISABLE.getImage());
+ selectImageButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ if (baseImageFD == null) {
+ baseImageFD = new FileDialog(MainDialog.getShell(), SWT.OPEN);
+ baseImageFD.setText(String.format("Select existing Base Image"));
+ 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)"};
+ } else {
+ filter = new String[]{"*.x86"};
+ filterName = new String[]{"Disk Image Files(*.x86)"};
+ }
+ baseImageFD.setFilterExtensions(filter);
+ baseImageFD.setFilterNames(filterName);
+ }
+
+ String path = baseImageFD.open();
+ if (path != null) {
+ if (!MenuHandling.isPathAvaliable(path)) {
+ new MessageDialog().openWarningDialog("This base image not ready yet.\n" +
+ "Please select again in a few seconds.");
+ return;
+ }
+ newPath = path;
+ newPathName = path.substring(path.lastIndexOf(File.separator) + 1, path.length());
+
+ // for arm emulator
+ boolean isArm = newPathName.endsWith("arm");
+ EmulatorVMList.getInstance().CustomArch = !isArm ? "x86" : "arm";
+
+ baseImageLabel.setText(newPathName);
+ baseImageLabel.redraw();
+ isSelected = true;
+ checkVMName();
+
+ // TODO
+ //arm image
+ //false hw virtualization
+ //false gl accelertaion
+ }
+ }
+ });
+ }
+
+ protected boolean checkImageName() {
+ return true;
+ }
+
+ @Override
+ public void closeItem() {
+ subTitleLabel.dispose();
+
+ nameLabel.dispose();
+ baseImageLabel.dispose();
+
+ if (nameText != null) {
+ nameText.dispose();
+ }
+ if (selectImageButton != null) {
+ selectImageButton.dispose();
+ }
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ if (nameLabel != null) {
+ nameLabel.setText(value.vmsName);
+ }
+
+ if (baseImageLabel != null) {
+ baseImageLabel.setText(value.baseImagePathName);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ newName = oldName = value.vmsName;
+ isStandard = value.isStandard;
+
+ newPath = value.baseImagePath;
+ newPathName = value.baseImagePathName;
+ isSelected = false;
+
+ if (isCreateMode()) {
+ nameText.setText(oldName);
+ nameText.setEnabled(true);
+
+ if (value.isStandard) {
+ baseImageLabel.setText(value.image == null
+ ? value.baseImagePathName
+ : value.image.getPathName());
+ baseImageLabel.setEnabled(false);
+ selectImageButton.setEnabled(false);
+ } else {
+ baseImageLabel.setEnabled(true);
+ baseImageLabel.setText("");
+ selectImageButton.setEnabled(true);
+ }
+ } else {
+ nameText.setText(oldName);
+ nameText.setEnabled(false);
+
+ baseImageLabel.setText(value.baseImagePathName);
+ baseImageLabel.setEnabled(false);
+ selectImageButton.setEnabled(false);
+ }
+
+ setFocus();
+ return false;
+ }
+
+ public void setFocus() {
+ nameLabel.setFocus();
+ nameText.setFocus();
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomCombo;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomComboSelectionListener;
+import org.tizen.emulator.manager.da.widgets.combo.TitleComboPopupRenderer;
+import org.tizen.emulator.manager.resources.ColorResources;
+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.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.ui.widgets.ModifyViewCombo;
+import org.tizen.emulator.manager.ui.widgets.ModifyViewComboRenderer;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TRAMItem extends DetailViewItem {
+ private int oldSize;
+ private int newSize;
+
+ @Override
+ protected void init() {
+ title = "RAM Size";
+ count = 1;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.ramSize = newSize;
+ }
+
+ private ImageLabel ramSize;
+ private DACustomCombo ramSizeCombo;
+ private Label stateLabel;
+
+ private static int INPUTBOX_WIDTH = 180;
+ private static Image INPUTBOX_ON_IMAGE = null;
+ @Override
+ public void drawDetail() {
+ ramSize = new ImageLabel(compList.get(0), SWT.NONE);
+ ramSize.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = ramSize.getSize().x;
+ data.height = ramSize.getSize().y;
+ ramSize.setLayoutData(data);
+ }
+
+
+ @Override
+ public void drawModify() {
+ if (INPUTBOX_ON_IMAGE == null) {
+ INPUTBOX_ON_IMAGE = PatchImageResources.getInputBoxON(INPUTBOX_WIDTH - 40);
+ }
+
+ ramSizeCombo = new ModifyViewCombo(compList.get(0), SWT.NONE);
+ ramSizeCombo.setImages(INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE,
+ INPUTBOX_ON_IMAGE);
+
+ ramSizeCombo.setButtonImages(ImageResources.ARROW_DROPDOWN.getImage(), null);
+ ramSizeCombo.setEnabled(true);
+
+ ramSizeCombo.setComboRender(new ModifyViewComboRenderer());
+ ramSizeCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ ramSizeCombo.setItemHeight(INPUTBOX_ON_IMAGE.getImageData().height);
+ //
+
+ stateLabel = new Label(compList.get(0), SWT.NONE);
+ stateLabel.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ stateLabel.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ stateLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ stateLabel.setText("MB");
+
+ 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;
+ ramSizeCombo.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(ramSizeCombo, 10);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+ data.width = 30;
+ stateLabel.setLayoutData(data);
+
+ for (String s : RamSize.getInstance().getList()) {
+ ramSizeCombo.add(s);
+ }
+
+ ramSizeCombo.addSelectionListener(new DACustomComboSelectionListener() {
+ @Override
+ public void selectionEvent(DACustomCombo combo) {
+ String size = combo.getText();
+ newSize = Integer.valueOf(size);
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ ramSize.setText(value.ramSize + " MB");
+ return false;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ newSize = oldSize = value.ramSize;
+ String s = Integer.toString(oldSize);
+ ramSizeCombo.select(RamSize.getInstance().findIndex(s));
+ return false;
+ }
+
+ @Override
+ public void closeItem() {
+ if (ramSize != null) {
+ ramSize.dispose();
+ }
+
+ if (ramSizeCombo != null) {
+ ramSizeCombo.dispose();
+ }
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.tizen.emulator.manager.resources.PatchImageResources;
+import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TTouchPointItem extends DetailViewItem {
+ private int touchPointValue;
+ @Override
+ protected void init() {
+ title = "Max Touch Point";
+ count = 1;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.maxTouchCount = touchPointValue;
+ }
+
+ private ImageLabel touchPoint;
+ private static int INPUTBOX_WIDTH = 180;
+ @Override
+ public void drawDetail() {
+ touchPoint = new ImageLabel(compList.get(0), SWT.NONE);
+ touchPoint.setImage(ImageLabel.STATE_ENABLE,
+ PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = touchPoint.getSize().x;
+ data.height = touchPoint.getSize().y;
+ touchPoint.setLayoutData(data);
+ touchPoint.redraw();
+ }
+
+ @Override
+ public void drawModify() {
+ touchPoint = new ImageLabel(compList.get(0), SWT.NONE);
+ touchPoint.setImage(ImageLabel.STATE_DISABLE,
+ PatchImageResources.getInputBoxON(INPUTBOX_WIDTH));
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, INPUTBOX_OFFSET);
+ data.top = new FormAttachment(0, INPUTBOX_TOP_GAP);
+ data.width = touchPoint.getSize().x;
+ data.height = touchPoint.getSize().y;
+ touchPoint.setLayoutData(data);
+ touchPoint.setEnabled(false);
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ touchPointValue = value.maxTouchCount;
+ touchPoint.setText(Integer.toString(touchPointValue));
+ return false;
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ touchPointValue = value.maxTouchCount;
+ touchPoint.setText(Integer.toString(touchPointValue));
+ return false;
+ }
+
+ @Override
+ public void closeItem() {
+ touchPoint.dispose();
+ }
+}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.detail;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
-import org.tizen.emulator.manager.image.SkinList;
-import org.tizen.emulator.manager.image.Skin;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.MenuHandling;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.ui.ResourceRegistry;
-import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-import org.tizen.emulator.manager.vms.RESOLUTION;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
-import org.tizen.emulator.manager.vms.VMPropertyValue;
-
-public abstract class TableWidget {
- private String id;
- private String title;
- private boolean isCreateMode;
- private TableWidgetChangeListener listener;
- private TableWidget widget;
- private String tooltip = "";
-
- public TableWidget(String id, boolean isCreate) {
- this.id = id;
- this.isCreateMode = isCreate;
- widget = this;
- }
-
- public abstract Control getWidget();
- public abstract String getValue(VMPropertyValue value);
- public abstract void setValue(VMPropertyValue value);
- public abstract boolean settingWidget(Table table, VMPropertyValue value); // oldValue
- public abstract boolean settingWidgetListener(TableWidgetChangeListener listener); // newValue
- public abstract void closeWidget();
-
- public String getId() {
- return id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getToolTip() {
- return tooltip;
- }
-
- public void setToolTip(String tooltip) {
- this.tooltip = tooltip;
- }
-
- public boolean isCreateMode() {
- return isCreateMode;
- }
-
- public void setCreateMode(boolean isCreateMode) {
- this.isCreateMode = isCreateMode;
- }
-
- public void setListener (TableWidgetChangeListener listener) {
- this.listener = listener;
- }
-
- public TableWidgetChangeListener getListener() {
- return this.listener;
- }
-
- protected TableWidget getThis() {
- return widget;
- }
-}
-
-class NameText extends TableWidget {
- private Text vmsNameText;
- private String newName;
- private String oldName;
- private boolean isStandard;
-
- // for create
- private Label infoLabel;
- private BaseImageButton baseimage;
- private VMCreateHelper helper;
-
- public NameText(boolean isCreate) {
- super("name", isCreate);
- setTitle("Name");
- }
-
- public Control getWidget() {
- return vmsNameText;
- }
-
- public String getValue(VMPropertyValue value) {
- return value.vmsName;
- }
-
- public void setValue(VMPropertyValue value) {
- value.vmsName = newName;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- oldName = newName = value.vmsName;
- isStandard = value.isStandard;
- vmsNameText = new Text(table, SWT.BORDER);
- vmsNameText.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- vmsNameText.setText(oldName);
- vmsNameText.setTextLimit(VMPropertyView.MAX_NAME_LEN);
- vmsNameText.setEnabled(isCreateMode());
-
- if (isCreateMode()) {
- helper = new VMCreateHelper();
- }
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- TableWidget widget = TableWidgetList.getInstance().findVMWidget("info", isCreateMode());
- if (widget != null) {
- infoLabel = (Label)widget.getWidget();
- }
- baseimage = (BaseImageButton)TableWidgetList.getInstance().findVMWidget("image", isCreateMode());
-
- vmsNameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- newName = vmsNameText.getText();
- checkImageName();
- }
- });
-
- return false;
- }
-
- public void checkImageName() {
- if (newName.length() > VMPropertyView.MAX_NAME_LEN) {
- infoLabel.setText("Max length is 20.");
- getListener().ChangeValue(false);
- return;
- }
-
- if (!helper.checkString(newName)) {
- infoLabel.setText("Name is invalid!");
- getListener().ChangeValue(false);
- return;
- }
-
- if (!oldName.equals(newName)
- && helper.checkDupulicateName(newName)) {
- infoLabel.setText("Same name exists!");
- getListener().ChangeValue(false);
- return;
- }
-
- if (newName.length() == VMPropertyView.MAX_NAME_LEN) {
- infoLabel.setText("Max length is 20.");
- } else {
- infoLabel.setText("");
- }
- if (newName.isEmpty()) {
- getListener().ChangeValue(false);
- } else {
- if (isStandard) {
- getListener().ChangeValue(true);
- } else {
- if (baseimage.isSelected()) {
- getListener().ChangeValue(true);
- } else {
- getListener().ChangeValue(false);
- }
- }
- }
- }
-
- public void closeWidget() {
- if (vmsNameText != null) {
- vmsNameText.dispose();
- }
- }
-}
-
-class NameInfoLabel extends TableWidget {
- private Label nameInfoLabel;
-
- public NameInfoLabel( boolean isCreate) {
- super("info", isCreate);
- setTitle("");
- }
-
- public Control getWidget() {
- return nameInfoLabel;
- }
-
- public String getValue(VMPropertyValue value) {
- return "";
- }
-
- public void setValue(VMPropertyValue value) {
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- if (isCreateMode()) {
- //add vm name info
- nameInfoLabel = new Label(table, SWT.WRAP);
- nameInfoLabel.setText("");
- }
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- return false;
- }
-
- public void closeWidget() {
- if (nameInfoLabel != null) {
- nameInfoLabel.dispose();
- }
- }
-}
-
-class BaseImageButton extends TableWidget {
- private Button baseImageButton;
- private String newPath;
- private String newPathName;
- private Image image;
- private FileDialog baseImageFD;
- private boolean isSelected;
-
- public BaseImageButton(boolean isCreate) {
- super("image", isCreate);
- setTitle("Base Image");
- this.image = ResourceRegistry.getImage(ImageName.FOLDER);
- isSelected = false;
- }
-
- public Control getWidget() {
- return baseImageButton;
- }
-
- public String getValue(VMPropertyValue value) {
- return value.baseImagePathName;
- }
-
- public void setValue(VMPropertyValue value) {
- value.baseImagePath = newPath;
- value.baseImagePathName = newPathName;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- newPath = value.baseImagePath;
- newPathName = value.baseImagePathName;
- baseImageButton = new Button(table, SWT.PUSH);
-
- if (isCreateMode()) {
- if (value.isStandard) {
- baseImageButton.setText(value.image == null
- ? value.baseImagePathName
- : value.image.getImagePathName());
- baseImageButton.setEnabled(false);
- } else {
- baseImageButton.setImage(image);
- baseImageButton.setText("");
- }
- } else {
- baseImageButton.setText(value.baseImagePathName);
- baseImageButton.setEnabled(false);
- }
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- baseImageButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- if (baseImageFD == null) {
- baseImageFD = new FileDialog(
- EmulatorManager.getInstance().getMainDialog().getShell(),
- SWT.OPEN);
- baseImageFD.setText(String.format("Select existing Base Image"));
- String[] filter = {"*.x86", "*.arm"};
- String[] filterName = {"Disk Image Files(*.x86)", "Disk Image Files(*.arm)"};
- baseImageFD.setFilterExtensions(filter);
- baseImageFD.setFilterNames(filterName);
- }
-
- String path = baseImageFD.open();
- if(path != null) {
- if (!MenuHandling.isPathAvaliable(path)) {
- new MessageDialog().openWarningDialog("This base image not ready yet.\n" +
- "Please select again in a few seconds.");
- return;
- }
- newPath = path;
- newPathName = path.substring(path.lastIndexOf(File.separator) + 1, path.length());
-
- boolean isArm = newPathName.endsWith("arm");
- EmulatorVMs.getInstance().CustomArch = !isArm ? "x86" : "arm";
-
- baseImageButton.setText(newPathName);
- isSelected = true;
- ((NameText)TableWidgetList.getInstance().findVMWidget("name", isCreateMode())).checkImageName();
- ((HWVirtualizationCombo)TableWidgetList.getInstance()
- .findVMWidget("hw", isCreateMode())).settingWidgetState(isArm);
- ((GLAccelerationCombo)TableWidgetList.getInstance()
- .findVMWidget("gl", isCreateMode())).settingWidgetState(isArm);
- }
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return true;
- }
-
- public void closeWidget() {
- baseImageButton.dispose();
- }
-
- public boolean isSelected() {
- return isSelected;
- }
-}
-
-class ResolutionCombo extends TableWidget {
- Combo resolutionCombo;
- RESOLUTION oldResolution;
- RESOLUTION newResolution;
-
- public ResolutionCombo( boolean isCreate) {
- super("resolution", isCreate);
- setTitle("Display Resolution");
- }
-
- public Control getWidget() {
- return resolutionCombo;
- }
-
- public String getValue(VMPropertyValue value) {
- return value.resolution.toString();
- }
-
- public void setValue(VMPropertyValue value) {
- value.resolution = newResolution;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- oldResolution = newResolution = value.resolution;
-
- VMCreateHelper helper = new VMCreateHelper();
- resolutionCombo = helper.makeCombo(table);
-
- DisplayResolution.getInstance().initialize(oldResolution);
-
- helper.addComboItem(resolutionCombo, DisplayResolution.getInstance().getList(),
- DisplayResolution.getInstance().findIndex(oldResolution.toString()));
-
- resolutionCombo.setToolTipText(resolutionCombo.getItem(resolutionCombo.getSelectionIndex()));
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- resolutionCombo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- String re = resolutionCombo.getItem(resolutionCombo.getSelectionIndex());
- resolutionCombo.setToolTipText(re);
-
- RESOLUTION d = DisplayResolution.getInstance().findResolution(re);
- if (d != null) {
- newResolution = d;
- DPISpinner dpi = (DPISpinner)TableWidgetList.getInstance()
- .findVMWidget("dpi", isCreateMode());
- dpi.selectDPI(d);
-
- SkinCombo skin = (SkinCombo)TableWidgetList.getInstance().findVMWidget("skin", isCreateMode());
- skin.selectResolution(d);
- }
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
- });
- return true;
- }
-
- public void closeWidget() {
- resolutionCombo.dispose();
- }
-}
-
-class DPISpinner extends TableWidget {
- private Spinner dpiSpinner;
- private int oldDPI;
- private int newDPI;
-
- public DPISpinner(boolean isCreate) {
- super("dpi", isCreate);
- setTitle("Display Density");
- }
-
- public Control getWidget() {
- return dpiSpinner;
- }
-
- public String getValue(VMPropertyValue value) {
- return String.valueOf(value.dpi);
- }
-
- public void setValue(VMPropertyValue value) {
- value.dpi = newDPI;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- oldDPI = newDPI = value.dpi;
- dpiSpinner = new Spinner(table, SWT.BORDER);
- dpiSpinner.setValues(oldDPI,
- /*VMPropertyView.MIN_DPI*/0, /*VMPropertyView.MAX_DPI*/999, 0, 1, 1);
- dpiSpinner.setTextLimit(3);
-
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- dpiSpinner.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- newDPI = dpiSpinner.getSelection();
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
- });
-
- return true;
- }
-
- public void closeWidget() {
- dpiSpinner.dispose();
- }
-
- public void selectDPI(RESOLUTION resolution) {
- if (!DisplayResolution.getInstance().isMinResoluion(resolution)
- && EmulatorManager.getInstance().getManagerMode() != ManagerModeType.INHOUSE_MODE) {
- dpiSpinner.setSelection(oldDPI);
- } else {
- dpiSpinner.setSelection(resolution.getDPI());
- }
- }
-}
-
-class SkinCombo extends TableWidget {
- Combo skinCombo;
- Skin oldSkin;
- Skin newSkin;
- VMCreateHelper helper;
- private Skin selectSkin = null;
-
- public SkinCombo(boolean isCreate) {
- super("skin", isCreate);
- setTitle("Skin");
- }
-
- public Control getWidget() {
- return skinCombo;
- }
-
- public String getValue(VMPropertyValue value) {
- if (value.skin != null) {
- return value.skin.getName();
- } else {
- return "";
- }
- }
-
- public void setValue(VMPropertyValue value) {
- value.skin = newSkin;
- if (newSkin != null) {
- value.skinPath = newSkin.getPath();
- } else {
- value.skinPath = null;
- }
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- oldSkin = newSkin = value.skin;
-
- ArrayList<Skin> skinList = SkinList.getInstance()
- .findSkinList(value.resolution.getValue());
-
- helper = new VMCreateHelper();
- skinCombo = helper.makeCombo(table);
- helper.addComboItem(skinCombo, skinList.toArray(), 0);
- skinCombo.setToolTipText(skinCombo.getItem(0));
-
- if (!isCreateMode() && oldSkin != null) {
- boolean find = false;
- if (!DisplayResolution.getInstance().isMinResoluion(value.resolution)
- && EmulatorManager.getInstance().getManagerMode() != ManagerModeType.INHOUSE_MODE) {
- skinCombo.removeAll();
- } else {
- for (int i = 0; i < skinCombo.getItemCount(); i++) {
- if (skinCombo.getItem(i).equals(oldSkin.toString())) {
- skinCombo.select(i);
- skinCombo.setToolTipText(skinCombo.getItem(i));
- find = true;
- break;
- }
- }
- }
-
- if (!find) {
- skinCombo.add(oldSkin.toString(), 0);
- skinCombo.select(0);
- skinCombo.setToolTipText(skinCombo.getItem(0));
- }
- }
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- skinCombo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- String name = skinCombo.getItem(skinCombo.getSelectionIndex());
- skinCombo.setToolTipText(name);
-
- newSkin = SkinList.getInstance().findSkinUseName(name);
- if (newSkin == null && name.equals(oldSkin)){
- newSkin = oldSkin;
- }
- selectSkin = newSkin;
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return true;
- }
-
- public void selectResolution(RESOLUTION resolution) {
- skinCombo.removeAll();
- ArrayList<Skin> skinList = null;
- skinList = SkinList.getInstance().findSkinList(resolution.getValue());
- helper.addComboItem(skinCombo, skinList.toArray(), 0);
-
- int selection = 0;
- if (selectSkin != null
- && selectSkin.getResolution().equals(StringResource.SKIN_GENERAL)) {
- boolean find = false;
- for (int i = 0; i < skinCombo.getItemCount(); i++) {
- if (skinCombo.getItem(i).equals(selectSkin.toString())) {
- selection = i;
- find = true;
- break;
- }
- }
-
- if (!find) {
- skinList.add(0, selectSkin);
- skinCombo.add(selectSkin.toString(), 0);
- }
- }
-
- if (!isCreateMode()
- && !DisplayResolution.getInstance().isMinResoluion(resolution)
- && EmulatorManager.getInstance().getManagerMode() != ManagerModeType.INHOUSE_MODE) {
- selection = 0;
- skinCombo.removeAll();
- skinCombo.add(oldSkin.toString());
- }
-
- if (!skinList.isEmpty()) {
- skinCombo.select(selection);
- skinCombo.setToolTipText(skinCombo.getItem(selection));
- newSkin = skinList.get(selection);
- } else {
- newSkin = null;
- }
- }
-
- public void closeWidget() {
- skinCombo.dispose();
- }
-}
-
-class RAMSizeCombo extends TableWidget {
- Combo ramSizeCombo;
- int oldSize;
- int newSize;
-
- public RAMSizeCombo(boolean isCreate) {
- super("ram", isCreate);
- setTitle("RAM Size");
- }
-
- public Control getWidget() {
- return ramSizeCombo;
- }
-
- public String getValue(VMPropertyValue value) {
- return String.valueOf(value.ramSize);
- }
-
- public void setValue(VMPropertyValue value) {
- value.ramSize = newSize;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- oldSize = newSize = value.ramSize;
- VMCreateHelper helper = new VMCreateHelper();
- ramSizeCombo = helper.makeCombo(table);
- helper.addComboItem(ramSizeCombo, RamSize.getInstance().getList(),
- RamSize.getInstance().findIndex(String.valueOf(value.ramSize)));
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- ramSizeCombo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- String str = ramSizeCombo.getItem(ramSizeCombo.getSelectionIndex());
- newSize = Integer.valueOf(str.substring(0, str.length() - 3));
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- return true;
- }
-
- public void closeWidget() {
- ramSizeCombo.dispose();
- }
-}
-
-class FileShareTypeCombo extends TableWidget {
- private Combo shareTypeCombo;
- private Label shareTypeLabel; // for Mac os
-
- private boolean oldIsSupport;
- private boolean newIsSupport;
- static String toolTipforMac = "Please refer to file sharing section in SDK documentation.";
- public FileShareTypeCombo(boolean isCreate) {
- super("filesharetype", isCreate);
- setTitle("File Sharing");
- }
-
- public Control getWidget() {
- if (EmulatorManager.isMac()) {
- return shareTypeLabel;
- } else {
- return shareTypeCombo;
- }
- }
-
- public String getValue(VMPropertyValue value) {
- return value.isFileShareSupport && !EmulatorManager.isMac()
- ? StringResource.SUPPORTED + " ": StringResource.NOT_SUPPORTED + " ";
- }
-
- public void setValue(VMPropertyValue value) {
- value.isFileShareSupport = newIsSupport;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- newIsSupport = oldIsSupport = value.isFileShareSupport;
-
- if (EmulatorManager.isMac()) {
- shareTypeLabel = new Label(table, SWT.WRAP);
- shareTypeLabel.setText(StringResource.MANUAL_SUPPORT);
- shareTypeLabel.setToolTipText(FileShareTypeCombo.toolTipforMac);
- } else {
- VMCreateHelper helper = new VMCreateHelper();
- shareTypeCombo = helper.makeCombo(table);
- helper.addComboItem(shareTypeCombo, SupportType.getInstance().getList());
- shareTypeCombo.select(oldIsSupport == true ? 0 : 1);
- }
-
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- if (EmulatorManager.isMac()) {
- return true;
- } else {
- shareTypeCombo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- int index = shareTypeCombo.getSelectionIndex();
- Button button = (Button)TableWidgetList.getInstance()
- .findVMWidget("filesharefolder", isCreateMode()).getWidget();
-
- newIsSupport = index == 0 ? true : false;
- button.setEnabled(newIsSupport);
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return true;
- }
- }
-
- public void closeWidget() {
- if (EmulatorManager.isMac()) {
- shareTypeLabel.dispose();
- } else {
- shareTypeCombo.dispose();
- }
- }
-}
-
-class FileShareFolderButton extends TableWidget {
- private Button shareFolderButton;
- private Label shareFolderLabel; // for Mac os
-
- private String newPath;
- private String oldPathName;
- private String newPathName;
- private Image image;
- private DirectoryDialog shareFileDD;
-
- public FileShareFolderButton(boolean isCreate) {
- super("filesharefolder", isCreate);
- setTitle("File Sharing Path");
- this.image = ResourceRegistry.getImage(ImageName.FOLDER);
- }
-
- public Control getWidget() {
- if (EmulatorManager.isMac()) {
- return shareFolderLabel;
- } else {
- return shareFolderButton;
- }
- }
-
- public String getValue(VMPropertyValue value) {
- if (EmulatorManager.isMac()) {
- return StringResource.None;
- } else {
- return value.fileSharePathName;
- }
- }
-
- public void setValue(VMPropertyValue value) {
- value.fileSharePath = newPath;
- value.fileSharePathName = newPathName;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- newPath = value.fileSharePath;
- oldPathName = newPathName = value.fileSharePathName;
-
- if (EmulatorManager.isMac()) {
- shareFolderLabel = new Label(table, SWT.WRAP);
- shareFolderLabel.setText(StringResource.None);
- shareFolderLabel.setToolTipText(FileShareTypeCombo.toolTipforMac);
- } else {
- shareFolderButton = new Button(table, SWT.PUSH);
- shareFolderButton.setImage(image);
- shareFolderButton.setText(oldPathName);
- shareFolderButton.setEnabled(value.isFileShareSupport);
-
- }
-
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- if (EmulatorManager.isMac()) {
- return true;
- } else {
- shareFolderButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- if (shareFileDD == null) {
- shareFileDD = new DirectoryDialog(
- EmulatorManager.getInstance().getMainDialog().getShell(), SWT.OPEN);
- shareFileDD.setText("Select a Direcory");
- }
-
- String path = shareFileDD.open();
- if(path != null) {
- newPath = path;
- newPathName = path.substring(path.lastIndexOf(File.separator) + 1, path.length());
- shareFolderButton.setText(newPathName);
- }
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return true;
- }
- }
-
- public void closeWidget() {
- if (EmulatorManager.isMac()) {
- shareFolderLabel.dispose();
- } else {
- shareFolderButton.dispose();
- }
- }
-}
-
-class HWVirtualizationCombo extends TableWidget {
- private Combo HWVirtualCombo;
- private boolean oldIsSupport;
- private boolean newIsSupport;
- private boolean isSelectedArm;
-
- public HWVirtualizationCombo(boolean isCreate) {
- super("hw", isCreate);
- setTitle("HW Virtualization");
- }
-
- public Control getWidget() {
- return HWVirtualCombo;
- }
-
- public String getValue(VMPropertyValue value) {
- if (value.archType.equals("arm")) {
- return StringResource.NOT_SUPPORTED;
- } else {
- return value.isHWVirtualization
- ? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED;
- }
- }
-
- public void setValue(VMPropertyValue value) {
- value.isHWVirtualization = newIsSupport;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- isSelectedArm = false;
-
- boolean isArm = value.archType.equals("arm");
-
- if (isCreateMode() && isArm) {
- oldIsSupport = newIsSupport = false;
- } else {
- oldIsSupport = newIsSupport = value.isHWVirtualization;
- }
-
- VMCreateHelper helper = new VMCreateHelper();
- HWVirtualCombo = helper.makeCombo(table);
- helper.addComboItem(HWVirtualCombo, SupportType.getInstance().getList());
- HWVirtualCombo.select(oldIsSupport
- && CheckVirtualization.getInstance().isSupportVirtualization() && !isArm
- ? 0 : 1);
-
- if (!CheckVirtualization.getInstance().isSupportVirtualization() || isArm) {
- HWVirtualCombo.setEnabled(false);
- }
-
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- HWVirtualCombo.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int i = HWVirtualCombo.getSelectionIndex();
- newIsSupport = i == 0 ? true : false;
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
- return true;
- }
-
- public void closeWidget() {
- HWVirtualCombo.dispose();
- }
-
- public void settingWidgetState(boolean isArm) {
- if (isArm) {
- if (!isSelectedArm) {
- oldIsSupport = newIsSupport;
- newIsSupport = false;
- }
- isSelectedArm = true;
- HWVirtualCombo.select(1);
- HWVirtualCombo.setEnabled(false);
- } else {
- if (isSelectedArm) {
- newIsSupport = oldIsSupport;
- }
- isSelectedArm = false;
- HWVirtualCombo.select(newIsSupport ? 0 : 1);
- HWVirtualCombo.setEnabled(true);
- }
- }
-}
-
-class GLAccelerationCombo extends TableWidget {
- private Combo GLAcceleCombo;
- private boolean oldIsSupport;
- private boolean newIsSupport;
- private boolean isSelectedArm;
-
- public GLAccelerationCombo(boolean isCreate) {
- super("gl", isCreate);
- setTitle("GPU ");
- setToolTip(String.format("%s\n%s", "If you enable the GPU option,",
- "the rendering performance of video player or camera may degrade."));
- }
-
- public Control getWidget() {
- return GLAcceleCombo;
- }
-
- public String getValue(VMPropertyValue value) {
- if (value.archType.equals("arm")) {
- return StringResource.NOT_SUPPORTED;
- } else {
- return value.isGLAcceleration
- ? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED;
- }
- }
-
- public void setValue(VMPropertyValue value) {
- value.isGLAcceleration = newIsSupport;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- isSelectedArm = false;
- boolean isArm = value.archType.equals("arm");
-
- if (isCreateMode() && isArm) {
- oldIsSupport = newIsSupport = false;
- } else {
- oldIsSupport = newIsSupport = value.isGLAcceleration;
- }
-
- VMCreateHelper helper = new VMCreateHelper();
- GLAcceleCombo = helper.makeCombo(table);
- helper.addComboItem(GLAcceleCombo, SupportType.getInstance().getList());
- GLAcceleCombo.select(oldIsSupport
- && CheckVirtualization.getInstance().isSupportGPU() && !isArm ? 0 : 1);
-
- if (!CheckVirtualization.getInstance().isSupportGPU() || isArm) {
- GLAcceleCombo.setEnabled(false);
- }
-
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- setListener(listener);
- GLAcceleCombo.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- int i = GLAcceleCombo.getSelectionIndex();
- newIsSupport = i == 0 ? true : false;
-
- if (!isCreateMode()) {
- getListener().ChangeValue(getThis());
- }
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return true;
- }
-
- public void closeWidget() {
- GLAcceleCombo.dispose();
- }
-
- public void settingWidgetState(boolean isArm) {
- if (isArm) {
- if (!isSelectedArm) {
- oldIsSupport = newIsSupport;
- newIsSupport = false;
- }
- isSelectedArm = true;
- GLAcceleCombo.select(1);
- GLAcceleCombo.setEnabled(false);
- } else {
- if (isSelectedArm) {
- newIsSupport = oldIsSupport;
- }
- isSelectedArm = false;
- GLAcceleCombo.select(newIsSupport ? 0 : 1);
- GLAcceleCombo.setEnabled(true);
- }
- }
-}
-
-class TouchPointLabel extends TableWidget {
- private Label touchPoint;
-
- public TouchPointLabel(boolean isCreate) {
- super("touch", isCreate);
- setTitle("Max Touch Point");
- }
-
- public Control getWidget() {
- return touchPoint;
- }
-
- public String getValue(VMPropertyValue value) {
- return String.valueOf(value.maxTouchCount);
- }
-
- public void setValue(VMPropertyValue value) {
- // fixed value
- value.maxTouchCount = VMPropertyValue.maxTouch;
- }
-
- public boolean settingWidget(Table table, VMPropertyValue value) {
- touchPoint = new Label(table, SWT.WRAP);
- touchPoint.setText(String.valueOf(value.maxTouchCount));
- return true;
- }
-
- public boolean settingWidgetListener(TableWidgetChangeListener listener) {
- return true;
- }
-
- public void closeWidget() {
- touchPoint.dispose();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.detail;
-
-public interface TableWidgetChangeListener {
- public void ChangeValue(TableWidget widget);
- public void ChangeValue(boolean isState);
-}
+++ /dev/null
-package org.tizen.emulator.manager.ui.detail;
-
-import java.util.ArrayList;
-
-public class TableWidgetList {
- ArrayList<TableWidget> createList;
- ArrayList<TableWidget> modifyList;
- private static TableWidgetList instance;
- static {
- instance = new TableWidgetList();
- }
-
- public static TableWidgetList getInstance() {
- assert instance == null;
-
- return instance;
- }
-
- private TableWidgetList() {
- createList = new ArrayList<TableWidget>();
- modifyList = new ArrayList<TableWidget>();
- makeCreateList();
- makeModifyList();
- }
-
- public ArrayList<TableWidget> getCreateList() {
- return createList;
- }
-
- public ArrayList<TableWidget> getModifyList() {
- return modifyList;
- }
-
- private void makeCreateList() {
- createList.add(new NameText(true));
- createList.add(new NameInfoLabel(true));
- createList.add(new BaseImageButton(true));
- createList.add(new ResolutionCombo(true));
- createList.add(new DPISpinner(true));
- createList.add(new SkinCombo(true));
- createList.add(new RAMSizeCombo(true));
- createList.add(new FileShareTypeCombo(true));
- createList.add(new FileShareFolderButton(true));
- createList.add(new HWVirtualizationCombo(true));
- createList.add(new GLAccelerationCombo(true));
- createList.add(new TouchPointLabel(true));
- }
-
- private void makeModifyList() {
- modifyList.add(new NameText(false));
- modifyList.add(new BaseImageButton(false));
- modifyList.add(new ResolutionCombo(false));
- modifyList.add(new DPISpinner(false));
- modifyList.add(new SkinCombo(false));
- modifyList.add(new RAMSizeCombo(false));
- modifyList.add(new FileShareTypeCombo(false));
- modifyList.add(new FileShareFolderButton(false));
- modifyList.add(new HWVirtualizationCombo(false));
- modifyList.add(new GLAccelerationCombo(false));
- modifyList.add(new TouchPointLabel(false));
- }
-
- public TableWidget findVMWidget(String id, boolean isCreate) {
- if (isCreate) {
- return findInCreateList(id);
- } else {
- return findInModifyList(id);
- }
- }
-
- private TableWidget findInModifyList(String id) {
- for (TableWidget widget : modifyList) {
- if (widget.getId().equals(id)) {
- return widget;
- }
- }
- return null;
- }
-
- private TableWidget findInCreateList(String id) {
- for (TableWidget widget : createList) {
- if (widget.getId().equals(id)) {
- return widget;
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.detail;
-
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableEditor;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.vms.Creator;
-import org.tizen.emulator.manager.vms.VMPropertyValue;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
-
-public class VMPropertyView implements TableWidgetChangeListener {
- public static final int MAX_NAME_LEN = 20;
- public static final int MIN_DPI = 100;
- public static final int MAX_DPI = 480;
-
- private Table table;
- private VMsProperty property;
- private VMPropertyValue oldValue;
- private VMPropertyValue newValue;
-
- private Button confirmButton;
-
- private boolean isCreateMode = true;
-
- ArrayList<TableItem> itemList;
- ArrayList<TableWidget> createList;
- ArrayList<TableWidget> modifyList;
-
- public VMPropertyView(Table table) {
- this.table = table;
- makeItemList();
- }
-
- private void makeItemList() {
- itemList = new ArrayList<TableItem>();
- createList = TableWidgetList.getInstance().getCreateList();
- modifyList = TableWidgetList.getInstance().getModifyList();
- for (int i = 0; i < createList.size(); i++) {
- TableItem item = new TableItem(table, SWT.NONE);
- itemList.add(i, item);
- }
- }
-
- private void settingDetailColumn(ArrayList<TableWidget> list) {
- // settingDetailColumn
- table.deselectAll();
- table.clearAll();
- TableWidget widget = null;
- for (int i = 0; i < list.size(); i++) {
- widget = list.get(i);
- itemList.get(i).setText(0, widget.getTitle());
- itemList.get(i).setText(1, widget.getValue(oldValue));
- //itemList.get(i).setText(2, widget.getToolTip());
- }
- }
- public void detailView(VMsProperty property) {
- this.property = property;
- oldValue = property.getPropertyValue();
- this.isCreateMode = false;
-
- settingDetailColumn(modifyList);
- }
-
- public void createDetailView(BaseImage image, VMsProperty template) {
- oldValue = new VMPropertyValue(image, template);
- this.isCreateMode = true;
-
- settingDetailColumn(createList);
- }
-
- private void settingMoidfyColumn(ArrayList<TableWidget> list) {
- TableWidget widget = null;
- TableEditor editor = null;
- for (int i = 0; i < list.size(); i++) {
- // clear table item..
- itemList.get(i).setText(1,"");
- widget = list.get(i);
- widget.settingWidget(table, oldValue);
-
- // setting table editor
- editor = new TableEditor(table);
- editor.grabHorizontal = true;
- editor.setEditor(widget.getWidget(), itemList.get(i), 1);
- }
-
- // add listener
- for (TableWidget w : list) {
- w.settingWidgetListener(this);
- }
-
- // NameText widget
- list.get(0).getWidget().setFocus();
- }
-
- public void modifyView(Button confirm) {
- //need select Skins.
- //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin());
- newValue = oldValue.clone();
- confirmButton = confirm;
-
- settingMoidfyColumn(modifyList);
- }
-
- public void createView(Button confirm) {
- //need select Skins.
- //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin());
- newValue = oldValue.clone();
- confirmButton = confirm;
-
- settingMoidfyColumn(createList);
- }
-
- public void close() {
- if (isCreateMode) {
- for (TableWidget widget : createList) {
- widget.closeWidget();
- }
- } else {
- for (TableWidget widget : modifyList) {
- widget.closeWidget();
- }
- }
- }
-
- public VMsProperty confirm() {
- VMsProperty p = null;
- MessageDialog msg = new MessageDialog();
- String message = "";
- try {
- if (isCreateMode) {
- for (TableWidget widget : createList) {
- widget.setValue(newValue);
- }
- }
- else {
- for (TableWidget widget : modifyList) {
- widget.setValue(newValue);
- }
- }
- // dpi check
- if (newValue.dpi < VMPropertyView.MIN_DPI || newValue.dpi > VMPropertyView.MAX_DPI) {
- throw new VMsWorkerException("Invalid value.\nDisplay Density should be from 100 to 480");
- }
-
- if (isCreateMode) {
- p = Creator.create(newValue);
- }
- else {
- property.getWorker().modifyVM(oldValue, newValue);
- p = property;
- }
- } catch (VMsWorkerException e) {
- message = e.getMessage();
- msg.openWarningDialog(message);
- }
- return p;
- }
-
- // WidgetChangeListener
- @Override
- public void ChangeValue(TableWidget widget) {
- widget.setValue(newValue);
- if (!oldValue.equals(newValue)) {
- confirmButton.setEnabled(true);
- } else {
- confirmButton.setEnabled(false);
- }
- }
-
- @Override
- public void ChangeValue(boolean isSate) {
- confirmButton.setEnabled(isSate);
- }
-
- public String getToolTipText(String name) {
- ArrayList<TableWidget> list = null;
- if (isCreateMode) {
- list = createList;
- } else {
- list = modifyList;
- }
-
- for (TableWidget widget : list) {
- if (widget.getTitle().equals(name)) {
- return widget.getToolTip();
- }
- }
-
- return null;
- }
-}
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.RAM_SIZE;
import org.tizen.emulator.manager.vms.RESOLUTION;
private SupportType()
{
- add(0, StringResource.SUPPORTED);
- add(1, StringResource.NOT_SUPPORTED);
+ add(0, StringResources.SUPPORTED);
+ add(1, StringResources.NOT_SUPPORTED);
setDefaultIndex(1);
}
clear();
int i = 0;
- if (EmulatorManager.getInstance().getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+ if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
for (RESOLUTION r : RESOLUTION.values()) {
if (r == RESOLUTION.HD) {
setDefaultIndex(i);
}
}
- if (!(EmulatorManager.getInstance().getManagerMode() == ManagerModeType.INHOUSE_MODE)) {
+ if (!(EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE)) {
for (String s : getList()) {
if (s.equals(re.toString())) {
return;
public boolean isMinResoluion(RESOLUTION resolution) {
for (RESOLUTION r : minResoultion) {
- if (resolution.getValue().equals(r.getValue())) {
+ if (resolution.getStrValue().equals(r.getStrValue())) {
return true;
}
}
if (r == RAM_SIZE.RAM512) {
setDefaultIndex(i);
}
- add(i++, r.toString() + " MB");
+ add(i++, r.toString());
}
}
-package org.tizen.emulator.manager.ui;
+package org.tizen.emulator.manager.ui.dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.tool.About;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.ui.MainDialog;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
public class AboutDialog {
private static Shell dialog = null;
private static String textContents = "";
- private static int width = 436; //149 + 287
+ private static int width = 436; //149 + 287
private static int height = 290; // 180 + 110
static {
About.initAboutContents();
- textContents = StringResource.NEW_LINE +
- "Tizen SDK" +
- StringResource.NEW_LINE + StringResource.NEW_LINE +
- "Version : " + About.getInstance().getAboutVersion() +
- StringResource.NEW_LINE +
- "Build id : " + About.getInstance().getBuildTime();
+ textContents = StringResources.NEW_LINE
+ + "Tizen SDK"
+ + StringResources.NEW_LINE + StringResources.NEW_LINE
+ + "Version : " + About.getInstance().getAboutVersion()
+ + StringResources.NEW_LINE
+ + "Build id : " + About.getInstance().getBuildTime();
}
}
private static void makeDialog() {
- dialog = new Shell(EmulatorManager.getInstance().getMainDialog().getShell(),
+ dialog = new Shell(MainDialog.getShell(),
SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setText("About Emulator Manager");
dialog.setSize(width, height);
upperComposite.setSize(width, 180);
upperComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- if (!(System.getProperty("os.name").toLowerCase().indexOf("mac") > -1)) {
+ if (!(EmulatorManager.isMac())) {
upperComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}
// About icon
Label label = new Label(upperComposite, SWT.NONE);
- label.setImage(ResourceRegistry.getImage(ImageName.ABOUTSDK));
+ label.setImage(ImageResources.ABOUTSDK.getImage());
// About Contents
makeTextContents(upperComposite);
Button okButton = new Button(lowerComposite, SWT.PUSH);
okButton.setLayoutData(new GridData(110, SWT.DEFAULT));
- okButton.setText(StringResource.OK);
+ okButton.setText(StringResources.OK);
okButton.setFocus();
okButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Link workspace = new Link(textComposite, SWT.NONE);
workspace.setLayoutData(new GridData(280, SWT.DEFAULT));
workspace.setText("Workspace Path : " +
- "<a>" + EmulatorVMs.getInstance().getVMsBaseDirectory() + "</a>");
+ "<a>" + EmulatorVMList.getInstance().getVMsBaseDirectory() + "</a>");
workspace.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
workspace.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent arg0) {
}
public void widgetSelected(SelectionEvent arg0) {
try {
- org.eclipse.swt.program.Program.launch(EmulatorVMs.getInstance().getVMsBaseDirectory());
+ org.eclipse.swt.program.Program.launch(EmulatorVMList.getInstance().getVMsBaseDirectory());
} catch (Throwable e) {
return;
}
}
});
- // link to tizen site
+ // link to tizen developer site
Link visit = new Link(textComposite, SWT.NONE);
visit.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
visit.setText("\n\n" +
}
} catch (Throwable e) {
EMLogger.getLogger().warning("Failed to open developer site"
- + StringResource.NEW_LINE + e.getMessage());
+ + StringResources.NEW_LINE + e.getMessage());
return;
}
}
-
});
}
*
*/
-package org.tizen.emulator.manager.ui;
+package org.tizen.emulator.manager.ui.dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.ui.detail.VMPropertyView;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.MainDialog;
+import org.tizen.emulator.manager.vms.HelperClass;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMWorkerException;
public class CloneDialog {
- private VMsProperty property = null;
- private VMCreateHelper helper = null;
-
- private MainDialog mainDialog = null;
+ private VMProperty property = null;
private Shell dialog = null;
private Text name = null;
private Label infoLabel = null;
private String vmName = null;
- public CloneDialog(MainDialog mainDialog, VMsProperty prop) {
- this.mainDialog = mainDialog;
+ public CloneDialog(VMProperty prop) {
property = prop;
-
- helper = new VMCreateHelper();
}
public void open() {
- dialog = new Shell(mainDialog.getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ dialog = new Shell(MainDialog.getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setText("Emulator Cloning");
dialog.setSize(350, 180);
dialog.setLayout(new GridLayout(1, true));
sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
name = new Text(dialog, SWT.BORDER);
- name.setTextLimit(VMPropertyView.MAX_NAME_LEN);
+ //name.setTextLimit(VMPropertyView.MAX_NAME_LEN);
name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
infoLabel = new Label(dialog, SWT.WRAP);
buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false));
confirmButton = new Button(buttonComposite, SWT.PUSH);
- confirmButton.setText(StringResource.CONFIRM);
- confirmButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
+ confirmButton.setText(StringResources.CONFIRM);
+ confirmButton.setImage(ImageResources.CONFIRM.getImage());
confirmButton.setEnabled(false);
cancelButton = new Button(buttonComposite, SWT.PUSH);
- cancelButton.setText(StringResource.CANCEL);
- cancelButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
+ cancelButton.setText(StringResources.CANCEL);
+ cancelButton.setImage(ImageResources.CANCEL.getImage());
addListener();
try {
property.getWorker().cloneVM(vmName);
//message = "Emulator cloning completed!";
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
message = e.getMessage();
msg.openInfoDialog(message);
}
dialog.close();
- mainDialog.refreshProperties();
- mainDialog.vmsTree.setSelectProperty(property);
+ MainDialog.refreshVMPropertyList();
+ //mainDialog.vmsTree.setSelectProperty(property);
}
});
@Override
public void widgetSelected(SelectionEvent arg0) {
dialog.close();
- mainDialog.refreshProperties();
- mainDialog.vmsTree.setSelectProperty(property);
+ MainDialog.refreshVMPropertyList();
+ //mainDialog.vmsTree.setSelectProperty(property);
}
});
}
private void checkImageName() {
+ /*
if (vmName.length() > VMPropertyView.MAX_NAME_LEN) {
infoLabel.setText("Max length of name is 20.");
confirmButton.setEnabled(false);
return;
}
+ */
- if (!helper.checkString(vmName)) {
+ if (!HelperClass.checkString(vmName)) {
infoLabel.setText("Name has invalid character!");
confirmButton.setEnabled(false);
return;
}
- if (helper.checkDupulicateName(vmName)) {
+ if (HelperClass.checkDupulicateName(vmName)) {
infoLabel.setText("The same name already exists!");
confirmButton.setEnabled(false);
return;
}
+ /*
if (vmName.length() == VMPropertyView.MAX_NAME_LEN) {
infoLabel.setText("Max length of name is 20.");
} else {
infoLabel.setText("Input new VM-name.");
}
+ */
if (vmName.isEmpty()) {
confirmButton.setEnabled(false);
} else {
*
*/
-package org.tizen.emulator.manager.ui;
+package org.tizen.emulator.manager.ui.dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.MainDialog;
public class MessageDialog
{
private Shell shell;
public MessageDialog() {
- this.shell = EmulatorManager.getInstance().getMainDialog().getShell();
+ this.shell = MainDialog.getShell();
}
public MessageDialog(Shell shell) {
dialog.setSize(x + 50, y + 100);
- if (EmulatorManager.getInstance() != null
- && EmulatorManager.getInstance().getMainDialog() != null) {
- Point p = EmulatorManager.getInstance().getMainDialog().getShell().getLocation();
- Point s = EmulatorManager.getInstance().getMainDialog().getShell().getSize();
+ if (MainDialog.getShell() != null) {
+ Point p = MainDialog.getShell().getLocation();
+ Point s = MainDialog.getShell().getSize();
dialog.setLocation(p.x + (s.x>>2), p.y + (s.y>>2));
}
if ((style & SWT.CANCEL) != 0 ) {
Button cancleButton = new Button(buttonComposite, SWT.PUSH);
cancleButton.setLayoutData(new GridData(90, SWT.DEFAULT));
- cancleButton.setText(StringResource.CANCEL);
+ cancleButton.setText(StringResources.CANCEL);
cancleButton.setFocus();
cancleButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Button okButton = new Button(buttonComposite, SWT.PUSH);
okButton.setLayoutData(new GridData(90, SWT.DEFAULT));
- okButton.setText(StringResource.OK);
+ okButton.setText(StringResources.OK);
okButton.setFocus();
okButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
*
*/
-package org.tizen.emulator.manager.ui;
+package org.tizen.emulator.manager.ui.dialog;
import java.util.Properties;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
public class SelectWorkspaceDialog {
private Shell dialog;
public void create() {
dialog = new Shell(Display.getCurrent(), SWT.CLOSE);
- dialog.setText(StringResource.SWD_TITLE);
+ dialog.setText(StringResources.SWD_TITLE);
dialog.setSize(500, 180);
GridLayout layout = new GridLayout(1, false);
layout.horizontalSpacing = 0;
pathText = new Text(browseComposite, SWT.BORDER);
- if (prop == null || prop.getProperty(StringResource.RECENT_VMS_PATH).isEmpty()) {
- selectedPath = EmulatorVMs.getInstance().getVMsBaseDirectory();
+ if (prop == null || prop.getProperty(StringResources.RECENT_VMS_PATH).isEmpty()) {
+ selectedPath = EmulatorVMList.getInstance().getVMsBaseDirectory();
} else {
- selectedPath =prop.getProperty(StringResource.RECENT_VMS_PATH);
+ selectedPath =prop.getProperty(StringResources.RECENT_VMS_PATH);
}
pathText.setText(selectedPath);
pathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
browseButton = new Button(browseComposite, SWT.PUSH);
- browseButton.setText(StringResource.SWD_BROWSE);
+ browseButton.setText(StringResources.SWD_BROWSE);
Composite bottomComposite = new Composite(dialog, SWT.NONE);
bottomComposite.setLayout(new GridLayout(3, false));
bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, true));
askButton = new Button(bottomComposite, SWT.CHECK);
- askButton.setText(StringResource.SWD_ASK_AGAIN);
+ askButton.setText(StringResources.SWD_ASK_AGAIN);
new Label(bottomComposite, SWT.NONE);
new Label(bottomComposite, SWT.NONE);
new Label(bottomComposite, SWT.NONE);
cancelButton = new Button(bottomComposite, SWT.PUSH);
- cancelButton.setText(StringResource.CANCEL);
+ cancelButton.setText(StringResources.CANCEL);
cancelButton.setSize(100, SWT.NONE);
cancelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
okButton = new Button(bottomComposite, SWT.PUSH);
- okButton.setText(StringResource.OK);
+ okButton.setText(StringResources.OK);
okButton.setSize(100, SWT.NONE);
okButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(dialog, SWT.OPEN);
- dd.setText(StringResource.SELECT_DIRECTORY);
+ dd.setText(StringResources.SELECT_DIRECTORY);
selectedPath = dd.open();
if (selectedPath != null) {
pathText.setText(selectedPath);
--- /dev/null
+package org.tizen.emulator.manager.ui.tabfolder;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonAttribute;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonDefaultRenderer;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.resources.PatchImageResources;
+
+public class PlatformTabButton extends DACustomButton {
+ private boolean isSelected = false;
+
+ public void setSelected(boolean isSelected) {
+ this.isSelected = isSelected;
+ ((PlatformTabButtonAttribute)attr).setSelected(isSelected);
+ }
+
+ public PlatformTabButton(Composite parent, int style) {
+ super(parent, style);
+ // change Listener
+ buttonMouseListener = buttonMouseListener2;
+ attr = new PlatformTabButtonAttribute();
+ this.addListeners();
+
+ this.setRenderer(new PlatformTabButtonRenderer());
+
+ // set Font
+ this.setFont(FontResources.TAB_BUTTON_FONT.getFont());
+
+ this.setFontColors(ColorResources.TAB_NORMAL_FONT_COLOR.getColor(),
+ ColorResources.TAB_SELECTED_FONT_COLOR.getColor(),
+ ColorResources.TAB_HOVER_FONT_COLOR.getColor(),
+ ColorResources.TAB_NORMAL_FONT_COLOR.getColor());
+
+ // set image
+ this.setImages(PatchImageResources.getUnselectedTabFolder(120, 29),
+ PatchImageResources.getSelectTabFolder(120, 29),
+ PatchImageResources.getUnselectedTabFolderHover(120, 29),
+ PatchImageResources.getUnselectedTabFolder(120, 29));
+ }
+
+ public PlatformTabButton(Composite parent, int style, String text) {
+ this(parent, style);
+ attr.setText(text);
+ }
+
+ private Listener buttonMouseListener2 = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (state == STATE_DISABLE) {
+ return;
+ }
+
+ if (isSelected) {
+ //changeButtonState(STATE_PUSH);
+ //state = STATE_PUSH;
+ } else {
+ switch(event.type) {
+ case SWT.MouseEnter:
+ changeButtonState(STATE_HOVER);
+ break;
+ case SWT.MouseExit:
+ changeButtonState(STATE_NORMAL);
+ break;
+ case SWT.MouseDown:
+ changeButtonState(STATE_HOVER);
+ break;
+ case SWT.MouseUp: // FIXME
+ changeButtonState(STATE_HOVER);
+ break;
+ default:
+ changeButtonState(STATE_NORMAL);
+ break;
+ }
+ }
+ }
+ };
+}
+
+class PlatformTabButtonRenderer extends DACustomButtonDefaultRenderer {
+ @Override
+ public void draw(GC gc, Canvas canvas, int state,
+ DACustomButtonAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+
+ if (attr.getDrawType() == DACustomButton.TYPE_IMAGE) {
+ PlatformTabButtonAttribute tabAttr = (PlatformTabButtonAttribute)attr;
+ Image image = null;
+ if (tabAttr.isSelected()) {
+ // STATE_SELECT -> STATE_PUSH
+ image = tabAttr.getImage(DACustomButton.STATE_PUSH);
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, tabAttr, DACustomButton.STATE_PUSH);
+ } else {
+ image = attr.getImage(state);
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, attr, state);
+ }
+ if (null == image) {
+ return;
+ }
+ } else if (attr.getDrawType() == DACustomButton.TYPE_COLOR
+ || attr.getDrawType() == DACustomButton.TYPE_GRADATION) {
+ drawButton(gc, rect, state, attr);
+ }
+
+ drawButtonImage(gc, rect, attr);
+ }
+}
+
+class PlatformTabButtonAttribute extends DACustomButtonAttribute {
+ private boolean selected;
+ public PlatformTabButtonAttribute() {
+ this.selected = false;
+ }
+ public boolean isSelected() {
+ return selected;
+ }
+ public void setSelected(boolean selected) {
+ this.selected = selected;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.tizen.emulator.manager.ui.tabfolder;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.ui.VMsMainView;
+
+public class PlatformTabFolder {
+ private static final int TAB_WIDTH = 120;
+ private static final int TAB_HEIGHT = 29;
+ private static final int RIGHT_BUTTON_WIDTH = 18;
+ private static final int RIGHT_BUTTON_HEIGHT = 18;
+
+ private ArrayList<PlatformTabItem> items
+ = new ArrayList<PlatformTabItem>(5);
+ private ArrayList<PlatformTabButton> buttons
+ = new ArrayList<PlatformTabButton>(5);
+
+ private ArrayList<DACustomButton> rightButtons
+ = new ArrayList<DACustomButton>(5);
+
+ private Composite mainComposite = null;
+ private Composite tabComposite = null;
+ private Composite contentsComposite = null;
+
+ //
+ private static VMsMainView view;
+
+ public Composite getTabComposite() {
+ return tabComposite;
+ }
+
+ public Composite getComposite() {
+ return mainComposite;
+ }
+
+ public PlatformTabFolder(Composite parent) {
+ mainComposite = new Composite(parent, SWT.NONE);
+ mainComposite.setLayout(new FormLayout());
+ //
+ mainComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor());
+ //
+ /*
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = 460;
+ mainComposite.setLayoutData(data);
+ */
+
+ tabComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED);
+ tabComposite.setLayout(new FormLayout());
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 2);
+ data.right = new FormAttachment(100, -2);
+ data.height = TAB_HEIGHT + 1;
+ tabComposite.setLayoutData(data);
+ tabComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor());
+
+ contentsComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED);
+ contentsComposite.setLayout(new FillLayout());
+
+ data = new FormData();
+ data.top = new FormAttachment(tabComposite, 0);
+ data.left = new FormAttachment(0, 2);
+ data.right = new FormAttachment(100, -2);
+ data.bottom = new FormAttachment(100, 0);
+ contentsComposite.setLayoutData(data);
+ contentsComposite.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor());
+
+ // initialize main view
+ view = VMsMainView.getInstance();
+ view.setInit(contentsComposite);
+ }
+
+ public void draw() {
+ if(!items.isEmpty()) {
+ // clear
+ if (!buttons.isEmpty()) {
+ for (PlatformTabButton b : buttons) {
+ b.dispose();
+ }
+ buttons.clear();
+ }
+
+ for (PlatformTabItem item : items) {
+ buttons.add(makeTabButton(item));
+ }
+
+ selectionItem(buttons.get(0));
+ }
+
+ if(!rightButtons.isEmpty()) {
+ int size = rightButtons.size() - 1;
+ for (int i = rightButtons.size() - 1; i >= 0; i--) {
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 6);
+ if (i == size) {
+ data.right = new FormAttachment(99, 0);
+ } else {
+ data.right = new FormAttachment(rightButtons.get(i+1), -11);
+ }
+ data.width = RIGHT_BUTTON_WIDTH;
+ data.height = RIGHT_BUTTON_HEIGHT;
+ rightButtons.get(i).setLayoutData(data);
+ }
+ }
+ }
+
+ public void redraw() {
+ // TODO
+ }
+
+ private PlatformTabButton makeTabButton(PlatformTabItem item) {
+ PlatformTabButton tabButton = new PlatformTabButton(tabComposite, SWT.NONE);
+ tabButton.setText(item.getText());
+ tabButton.setEnabled(true);
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 2);
+ if (buttons.size() == 0) {
+ data.left = new FormAttachment(0, 0);
+ } else {
+ data.left = new FormAttachment(buttons.get(buttons.size() - 1), 2);
+ }
+
+ data.width = TAB_WIDTH;
+ data.height = TAB_HEIGHT;
+ tabButton.setLayoutData(data);
+
+ tabButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ selectionItem((PlatformTabButton)button);
+ }
+ });
+
+ return tabButton;
+ }
+
+ private void selectionItem(PlatformTabButton button) {
+ PlatformTabButton b = null;
+ for (int i = 0; i < buttons.size(); i++) {
+ b = buttons.get(i);
+ if (button == b) {
+ this.setSelection(i);
+ b.setSelected(true);
+ b.redraw();
+ // draw main view using selected platform
+ items.get(i).draw();
+ contentsComposite.layout(true, true);
+ } else {
+ b.setSelected(false);
+ b.redraw();
+ }
+ }
+ }
+
+ private int selection = -1;
+
+ public void setSelection(int index) {
+ selection = index;
+ }
+
+ public PlatformTabItem getSelection() {
+ if (selection == -1) {
+ return null;
+ } else {
+ return items.get(selection);
+ }
+ }
+
+ public int getSelectionIndex() {
+ return selection;
+ }
+
+ public void clear() {
+ // TODO
+ }
+
+ public VMsMainView getView() {
+ return view;
+ }
+
+ public void addTabItem(PlatformTabItem item) {
+ items.add(item);
+ }
+
+ public void addTabItem(int index, PlatformTabItem item) {
+ items.add(index, item);
+ }
+
+ public void removeTabItem(PlatformTabItem item) {
+ items.remove(item);
+ }
+
+ public PlatformTabItem removeTabItem(int index) {
+ return items.remove(index);
+ }
+
+ public void addTabRightButton(DACustomButton button) {
+ rightButtons.add(button);
+ }
+
+ public void addTabRightButton(int index, DACustomButton button) {
+ rightButtons.add(index, button);
+ }
+
+ public void removeTabRightButton(DACustomButton button) {
+ rightButtons.remove(button);
+ }
+
+ public DACustomButton removeTabRightButton(int index) {
+ return rightButtons.remove(index);
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.tabfolder;
+
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.ui.VMsMainView;
+
+public class PlatformTabItem {
+ private Platform platform;
+
+ /**
+ * 모든 platform tab item 들이 공유
+ */
+ private static VMsMainView view;
+
+ private String text;
+// private Control control;
+
+ public PlatformTabItem(Platform platform, PlatformTabFolder mainTab, int style) {
+ this.platform = platform;
+ mainTab.addTabItem(this);
+
+ this.text = this.platform.getName();
+ view = mainTab.getView();
+ }
+
+ public void draw() {
+ // TODO
+ view.setPlatform(platform);
+ }
+
+ public void redraw() {
+ // TODO
+ view.resetPlatform();
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+/*
+ public Control getControl() {
+ return control;
+ }
+
+ public void setControl(Control control) {
+ this.control = control;
+ }
+*/
+ public Platform getPlatform() {
+ return platform;
+ }
+
+ public void setPlatform(Platform platform) {
+ this.platform = platform;
+ }
+}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.vmstree;
-
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.xml.DeviceType;
-import org.tizen.emulator.manager.vms.xml.DisplayType;
-
-
-// TODO: Support dynamic column editing
-public abstract class ColumnContentHelper {
- static final int numberOfColumns = 4;
- static final String[] columnTitles = new String[] { "Name", "CPU", "Resolution", "Density", "RAM size", };
- static final ColumnContentHelper[] helpers = new ColumnContentHelper[] {
- new NameContentHelper(0),
- new ArchitectureHelper(1),
- new ResolutionContentHelper(2),
- new DensityContentHelper(3),
- new RAMSizeContentHelper(4),
- };
-
- int index;
-
- protected ColumnContentHelper(int index) {
- this.index = index;
- }
-
- public String getTitle() {
- return columnTitles[index];
- }
-
- public int getIndex() {
- return index;
- }
-
- public abstract String getContent(VMsProperty property);
-
- public static int getContentCount() {
- return numberOfColumns;
- }
-
- public static ColumnContentHelper[] getContentHelpers() {
- return helpers;
- }
-
-}
-
-class NameContentHelper extends ColumnContentHelper {
- public NameContentHelper(int index) {
- super(index);
- }
-
- @Override
- public String getContent(VMsProperty property) {
- return property.getName();
- }
-}
-
-class ArchitectureHelper extends ColumnContentHelper {
- public ArchitectureHelper(int index) {
- super(index);
- }
-
- @Override
- public String getContent(VMsProperty property) {
- return property.getArch().name();
- }
-}
-
-class ResolutionContentHelper extends ColumnContentHelper {
- public ResolutionContentHelper(int index) {
- super(index);
- }
-
- @Override
- public String getContent(VMsProperty property) {
- DisplayType displayType = property.getConfiguration().getDevice().getDisplay();
-
- return displayType.getResolution().getWidth()
- + " x " + displayType.getResolution().getHeight();
- }
-}
-
-class DensityContentHelper extends ColumnContentHelper {
- public DensityContentHelper(int index) {
- super(index);
- }
-
- @Override
- public String getContent(VMsProperty property) {
- DisplayType displayType = property.getConfiguration().getDevice().getDisplay();
- return displayType.getDensity().getValue() + "";
- }
-}
-
-class RAMSizeContentHelper extends ColumnContentHelper {
- public RAMSizeContentHelper(int index) {
- super(index);
- }
-
- @Override
- public String getContent(VMsProperty property) {
- DeviceType deviceType = property.getConfiguration().getDevice();
- return deviceType.getRAM().getSize().getValue() + "";
- }
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.vmstree;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-public class ColumnSortListner implements SelectionListener {
- @Override
- public void widgetSelected(SelectionEvent event) {
- TreeColumn column = (TreeColumn)event.widget;
- Tree tree = column.getParent();
-
- tree.setSortColumn(column);
- if(tree.getSortDirection() == SWT.NONE) {
- tree.setSortDirection(SWT.UP);
- } else if(tree.getSortDirection() == SWT.UP) {
- tree.setSortDirection(SWT.DOWN);
- } else if(tree.getSortDirection() == SWT.DOWN) {
- tree.setSortDirection(SWT.UP);
- }
- for(TreeItem item : tree.getItems()) {
- if(!(item.getData() instanceof Container)) {// double checking...
- continue;
- }
-
- int count = item.getItemCount();
-
- for(int i = 0; i < count - 1; ++i) {
- TreeItem subItem0 = item.getItem(i);
- if(subItem0.getData() instanceof TreeMarker) {
- continue;
- }
-
- for(int j = i + 1; j < count; ++j) {
- TreeItem subItem1 = item.getItem(j);
-
- if(subItem1.getData() instanceof TreeMarker) {
- continue;
- }
-
- if(tree.getSortDirection() == SWT.UP) {
- if(subItem0.getText().compareTo(subItem1.getText()) > 0) {
- PropertyContent content0 = (PropertyContent)subItem0.getData();
- PropertyContent content1 = (PropertyContent)subItem1.getData();
-
- RowItem rowItem = new PropertyContent(content1.getProperty(), subItem0);
- subItem0.setData(rowItem);
- rowItem = new PropertyContent(content0.getProperty(), subItem1);
- subItem1.setData(rowItem);
- }
- }
- else if(tree.getSortDirection() == SWT.DOWN) {
- if(subItem0.getText().compareTo(subItem1.getText()) < 0) {
- PropertyContent content0 = (PropertyContent)subItem0.getData();
- PropertyContent content1 = (PropertyContent)subItem1.getData();
-
- RowItem rowItem = new PropertyContent(content1.getProperty(), subItem0);
- subItem0.setData(rowItem);
- rowItem = new PropertyContent(content0.getProperty(), subItem1);
- subItem1.setData(rowItem);
- }
- }
- }
- }
- tree.redraw();
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent event) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.vmstree;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MenuListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.ui.ResourceRegistry;
-import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
-
-public class ContextMenu {
- Menu treeMenu;
-
- public Menu getMenu() {
- return treeMenu;
- }
-
- public void prepare(final Tree vmsTree) {
- treeMenu = new Menu(vmsTree);
-
- final MenuItem launchItem = new MenuItem(treeMenu, SWT.NONE);
- launchItem.setText(StringResource.LAUNCH);
- launchItem.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
- launchItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- if(vmsTree.getSelectionCount() > 1) {
- return;
- }
-
- VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property;
- try {
- property.getWorker().launchVM();
- } catch (VMsWorkerException e) {
- new MessageDialog().openInfoDialog(e.getMessage());
- }
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent event) {
- }
- });
-
- final MenuItem modifyItem = new MenuItem(treeMenu, SWT.NONE);
- modifyItem.setText(StringResource.MODIFY);
- modifyItem.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
- modifyItem.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property;
- EmulatorManager.getInstance().getMainDialog().openModifyView(property);
- }
- });
-
- new MenuItem(treeMenu, SWT.SEPARATOR);
-
- final MenuItem resetItem = new MenuItem(treeMenu, SWT.NONE);
- resetItem.setText(StringResource.RESET);
- resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
- resetItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().resetVM();
- }
- });
-
- final MenuItem deleteItem = new MenuItem(treeMenu, SWT.NONE);
- deleteItem.setText(StringResource.DELETE);
- deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
- deleteItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().deleteVM();
- }
- });
-
- new MenuItem(treeMenu, SWT.SEPARATOR);
-
- final MenuItem cloneItem = new MenuItem(treeMenu, SWT.NONE);
- cloneItem.setText(StringResource.CLONE);
- cloneItem.setImage(ResourceRegistry.getImage(ImageName.CLONE));
- cloneItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().cloneVM();
- }
- });
-
- final MenuItem createImageItem = new MenuItem(treeMenu, SWT.NONE);
- createImageItem.setText(StringResource.CREATE_IMAGE);
- createImageItem.setImage(ResourceRegistry.getImage(ImageName.CREATEIMAGE));
- createImageItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- EmulatorManager.getInstance().getMainDialog().createBaseImage();
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
-
- treeMenu.addMenuListener(new MenuListener() {
- @Override
- public void menuShown(MenuEvent e) {
- if(vmsTree.getSelectionCount() == 0) {
- launchItem.setEnabled(false);
- deleteItem.setEnabled(false);
- resetItem.setEnabled(false);
- modifyItem.setEnabled(false);
- cloneItem.setEnabled(false);
- createImageItem.setEnabled(false);
- return;
- }
-
- for(MenuItem menuItem : treeMenu.getItems()) {
- menuItem.setEnabled(true);
- }
-
- if(vmsTree.getSelectionCount() > 1) {
- for(TreeItem treeItem : vmsTree.getSelection()) {
- RowItem rowItem = (RowItem)treeItem.getData();
- if(rowItem instanceof TreeMarker) {
- deleteItem.setEnabled(false);
- resetItem.setEnabled(false);
- break;
- }
- }
- cloneItem.setEnabled(false);
- launchItem.setEnabled(false);
- modifyItem.setEnabled(false);
- createImageItem.setEnabled(false);
- }
- else {
- if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) {
- launchItem.setEnabled(false);
- deleteItem.setEnabled(false);
- resetItem.setEnabled(false);
- modifyItem.setEnabled(false);
- cloneItem.setEnabled(false);
- createImageItem.setEnabled(false);
- return;
- }
- }
- }
-
- @Override
- public void menuHidden(MenuEvent e) {}
- });
- }
-
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.vmstree;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TreeItem;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.ui.ResourceRegistry;
-import org.tizen.emulator.manager.vms.VMsProperty;
-
-public interface RowItem {}
-
-interface TreeMarker extends RowItem {}
-
-interface TreeContent extends RowItem {}
-
-
-class PropertyContent implements TreeContent {
- VMsProperty property;
-
- public PropertyContent(VMsProperty property, TreeItem item) {
- this.property = property;
-
- for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) {
- item.setText(helper.getIndex(), helper.getContent(property));
- }
- }
-
- public VMsProperty getProperty() {
- return property;
- }
-}
-
-class CreateMarker implements TreeMarker {
- private BaseImage image = null;
- public CreateMarker(TreeItem item, BaseImage image) {
- item.setText("<< Create new... >>");
-
- Font font = ResourceRegistry.getFont(SWT.BOLD);
- if(font == null) {
- FontData[] fontData = item.getFont().getFontData();
- fontData[0].setStyle(SWT.BOLD);
- font = new Font(Display.getCurrent(), fontData);
- ResourceRegistry.addFont(SWT.BOLD, font);
- }
- item.setFont(font);
-
- this.image =image;
- }
-
- public BaseImage getBaseImage() {
- return image;
- }
-}
-
-
-abstract class Container {
- public Container(String text, TreeItem item) {
- item.setText(text);
- }
-}
-
-class StandardVMsMarker extends Container implements TreeMarker {
- public StandardVMsMarker(String version, TreeItem item) {
- super(version, item);
- }
-}
-
-class CustomVMsMarker extends Container implements TreeMarker {
- public CustomVMsMarker(TreeItem item) {
- super("Custom", item);
- }
-}
-
\ No newline at end of file
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 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>
- * YeongKyoon Lee <yeongkyoon.lee@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.vmstree;
-
-import java.util.ArrayList;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.image.Platform;
-import org.tizen.emulator.manager.ui.MainDialog;
-import org.tizen.emulator.manager.ui.MessageDialog;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsProperty.FSImageType;
-import org.tizen.emulator.manager.vms.VMsWorkerException;
-import org.tizen.emulator.manager.tool.SelectTemplate;
-
-public class VMsTree {
- MainDialog mainDialog;
-
- Tree vmsTree;
- ContextMenu contextMenu = new ContextMenu();
-
- EmulatorVMs fsImage = EmulatorVMs.getInstance();
-
- public VMsTree(final MainDialog mainDialog, Composite parent) {
- this.mainDialog = mainDialog;
-
- this.vmsTree = new Tree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-
- vmsTree.setHeaderVisible(true);
- vmsTree.setLinesVisible(true);
-
- for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) {
- TreeColumn treeColumn = new TreeColumn(vmsTree, SWT.NONE);
- treeColumn.setText(helper.getTitle());
-
- if("Name".equalsIgnoreCase(treeColumn.getText())) {
- treeColumn.addSelectionListener(new ColumnSortListner());
- }
- }
-
- refreshContents();
- packAll();
- packAll(); // FIXME: Need second pack avoid column becomes too narrow... why ???
-
- contextMenu.prepare(vmsTree);
- Menu tableMenu = contextMenu.getMenu();
- vmsTree.setMenu(tableMenu);
-
- vmsTree.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- if(vmsTree.getSelectionCount() == 0
- || vmsTree.getSelectionCount() > 1) {
- VMsTree.this.mainDialog.closeDetailView();
- }
- else {
- Object data = vmsTree.getSelection()[0].getData();
-
- if(!(data instanceof RowItem)) {
- return;
- }
-
- // TODO : select template using platform
- if (vmsTree.getSelection()[0].getData() instanceof CreateMarker) {
- if (vmsTree.getSelection()[0].getParentItem().getText().equals("Custom")) {
- mainDialog.openCreateDetailView(null, SelectTemplate.getInstance().getDefaultTemplate());
- } else {
- mainDialog.openCreateDetailView(((CreateMarker)vmsTree.getSelection()[0].getData()).getBaseImage(),
- SelectTemplate.getInstance().getDefaultTemplate());
- //mainDialog.openCreateDetailView(true);
- }
- return;
- }
-
- if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) {
- mainDialog.closeDetailView();
- return;
- }
-
- PropertyContent content = (PropertyContent)data;
- mainDialog.openDetailView(content.property);
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent event) {
- if(vmsTree.getSelectionCount() == 0
- || vmsTree.getSelectionCount() > 1) {
- return;
- }
- if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) {
- return;
- }
-
- VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property;
- try {
- property.getWorker().launchVM();
- } catch (VMsWorkerException e) {
- new MessageDialog().openInfoDialog(e.getMessage());
- }
- }
- });
-
- vmsTree.addKeyListener(new KeyListener() {
- @Override
- public void keyReleased(KeyEvent e) {}
- @Override
- public void keyPressed(KeyEvent e) {
- if(e.keyCode == SWT.DEL) {
- if (vmsTree.getSelectionCount() == 0) {
- return;
- } else {
- for(TreeItem item : vmsTree.getSelection()) {
- if(!(item.getData() instanceof PropertyContent)) {
- return;
- }
- }
- mainDialog.deleteVM();
- }
- }
- }
- });
- }
-
- private void packAll() {
- for(TreeColumn column : vmsTree.getColumns()) {
- column.pack();
- }
- vmsTree.pack();
- }
-
- public void refreshContents() {
- refreshContents(null);
- }
-
- private ArrayList<TreeItem> createItems = new ArrayList<TreeItem>();
- private ArrayList<TreeItem> typeItems = new ArrayList<TreeItem>();
- private Map<String, TreeItem> itemsMap = new HashMap<String, TreeItem>();
- private void refreshContents(String text) {
-// boolean x86Selected = mainDialog.isX86Selected();
- vmsTree.removeAll();
-
- createItems.clear();
- typeItems.clear();
- itemsMap.clear();
-
- VMsProperty[] properties = (VMsProperty[])fsImage.getProperties();
- RowItem rowItem = null;
- TreeItem createItem = null;
-
- // FIXME !!
- // add standard image
- for (Platform p : EmulatorManager.getInstance().getPlatformList()) {
- String standardVersion = p.getVersion();
- if (!standardVersion.isEmpty()) {
- TreeItem tempItem = new TreeItem(vmsTree, SWT.NONE);
- rowItem = new StandardVMsMarker(standardVersion, tempItem);
- tempItem.setData(rowItem);
- itemsMap.put(p.getVersion(), tempItem);
- typeItems.add(tempItem);
-
- for (BaseImage b : p.getImageList()) {
- TreeItem t = new TreeItem(tempItem, SWT.NONE);
- rowItem = new StandardVMsMarker(b.getName(), t);
- t.setData(rowItem);
-
- itemsMap.put(p.getVersion()+b.getName(), t);
- typeItems.add(t);
-
- createItem = new TreeItem(t, SWT.NONE);
- rowItem = new CreateMarker(createItem, b);
- createItem.setData(rowItem);
- createItems.add(createItem);
- }
- }
- }
- //
- //
-
- // add custom image
- TreeItem customItem = new TreeItem(vmsTree, SWT.NONE);
- rowItem = new CustomVMsMarker(customItem);
- customItem.setData(rowItem);
-
- createItem = new TreeItem(customItem, SWT.NONE);
- rowItem = new CreateMarker(createItem, null);
- createItem.setData(rowItem);
- createItems.add(createItem);
-
- // add VM
- for(int i = 0; i < properties.length; ++i) {
- if(text != null && !properties[i].getName().startsWith(text)) {
- continue;
- }
-
- // temporarily hard coded now...
- /*
- if(properties[i].getArch() == Architecture.ARM)
- continue;
- */
-
- TreeItem propertyItem = null;
-
- if(FSImageType.standard == properties[i].getImageType()) {
- String version = properties[i].getConfiguration().getBaseInformation().getDiskImage().getVersion();
- String base = properties[i].getConfiguration().getBaseInformation().getDiskImage().getBase();
- propertyItem = itemsMap.get(version+base);
- if(propertyItem == null) {
- propertyItem = itemsMap.get(version);
- if (propertyItem == null) {
- propertyItem = new TreeItem(vmsTree, SWT.NONE);
- rowItem = new StandardVMsMarker(version, propertyItem);
- propertyItem.setData(rowItem);
- itemsMap.put(version, propertyItem);
- typeItems.add(propertyItem);
- }
- propertyItem = new TreeItem(propertyItem, SWT.NONE);
- rowItem = new StandardVMsMarker(base, propertyItem);
- propertyItem.setData(rowItem);
-
- itemsMap.put(version+base, propertyItem);
- typeItems.add(propertyItem);
- }
- propertyItem = new TreeItem(propertyItem, SWT.NONE);
- }
- else {
- propertyItem = new TreeItem(customItem, SWT.NONE);
- }
-
- rowItem = new PropertyContent(properties[i], propertyItem);
- propertyItem.setData(rowItem);
- }
-
- for (TreeItem item : createItems) {
- item.setExpanded(true);
- }
- customItem.setExpanded(true);
- for(TreeItem item : typeItems) {
- item.setExpanded(true);
- }
-
- }
-
- public int getSelectionContentCount() {
- int count = 0;
- Object data;
- for (int i = 0; i < vmsTree.getSelectionCount(); i++) {
- data = vmsTree.getSelection()[i].getData();
- if (data instanceof TreeMarker) {
- return 0;
- }
-
- count++;
- }
- return count;
- }
-
- public VMsProperty[] getSelectionItems() {
- VMsProperty[] properties = new VMsProperty[vmsTree.getSelectionCount()];
-
- for(int i = 0; i < properties.length; ++i) {
- properties[i] = ((PropertyContent)vmsTree.getSelection()[i].getData()).property;
- }
-
- return properties;
- }
-
- public ArrayList<VMsProperty> getSelectionItemsList() {
- ArrayList<VMsProperty> list = new ArrayList<VMsProperty>();
-
- VMsProperty property = null;
- for (int i = 0; i < vmsTree.getSelectionCount(); i++) {
- property = ((PropertyContent)vmsTree.getSelection()[i].getData()).property;
- list.add(property);
- }
-
- return list;
- }
-
- public VMsProperty getSelectionItem() {
- return ((PropertyContent)vmsTree.getSelection()[0].getData()).property;
-
- }
-
- public void setLayoutData(Object data) {
- vmsTree.setLayoutData(data);
- }
-
- private TreeItem isPropertySelected(TreeItem item, VMsProperty property) {
- Object data;
- for (TreeItem i : item.getItems()) {
- data = i.getData();
- if (data instanceof CreateMarker) {
- continue;
- } else if (data instanceof TreeMarker) {
- TreeItem t = isPropertySelected(i, property);
- if (t == null) {
- continue;
- } else {
- return t;
- }
- } else {
- if (((PropertyContent)data).getProperty().getName().equals(property.getName())) {
- return i;
- }
- }
- }
- return null;
- }
-
- public void setSelectProperty(VMsProperty property) {
- TreeItem t;
- vmsTree.deselectAll();
- for (TreeItem item : vmsTree.getItems()) {
- t = isPropertySelected(item, property);
- if (t != null) {
- vmsTree.setFocus();
- vmsTree.setSelection(t);
- break;
- }
- }
- }
-}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+
+public class ImageLabel extends Canvas{
+ public static final int STATE_ENABLE = 0;
+ public static final int STATE_DISABLE = 1;
+
+ private ImageLabelRenderer renderer = new ImageLabelDefaultRenderer();
+ private ImageLabelAttribute attr = new ImageLabelAttribute();
+
+ public ImageLabel(Composite parent, int style) {
+ super(parent, style);
+ attr.setState(STATE_ENABLE);
+
+ attr.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ attr.setFontColor(STATE_ENABLE, ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ attr.setFontColor(STATE_DISABLE, ColorResources.DETAIL_DISABLE_FONT_COLOR.getColor());
+
+ this.addPaintListener(labelPaintListener);
+ }
+
+ private PaintListener labelPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ renderer.draw(e.gc, (Canvas) e.widget, attr);
+ }
+ };
+
+ public void setText(String text) {
+ attr.setText(text);
+ this.redraw();
+ }
+
+ public String getText() {
+ return attr.getText();
+ }
+
+ public void setImage(int state, Image img) {
+ attr.setImage(state, img);
+ this.setSize(img.getImageData().width, img.getImageData().height);
+ }
+
+ public Image getImage(int state) {
+ return attr.getImage(state);
+ }
+
+ public void setFont(Font font) {
+ attr.setFont(font);
+ }
+
+ public void setFontPoint(Point p) {
+ attr.setFontPoint(p);
+ }
+
+ public void setForeground (Color color) {
+ this.setFontColor(STATE_ENABLE, color);
+ this.setFontColor(STATE_DISABLE, color);
+ super.setForeground(color);
+ }
+
+ public void setFontColor(int state, Color color) {
+ attr.setFontColor(state, color);
+ }
+
+ public void setRenderer(ImageLabelRenderer newRenderer) {
+ renderer = newRenderer;
+ }
+
+ public void setEnabled(boolean enabled) {
+ if (enabled) {
+ changeState(STATE_ENABLE);
+ } else {
+ changeState(STATE_DISABLE);
+ }
+ }
+
+ public boolean isEnabled() {
+ return attr.getState() == STATE_ENABLE ? true : false;
+ }
+
+ protected void changeState(int s) {
+ attr.setState(s);
+ this.redraw();
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public class ImageLabelAttribute {
+ private ArrayList<Color> fontColors = new ArrayList<Color>(5);
+ private ArrayList<Image> images = new ArrayList<Image>(5);
+ private int state;
+ private Font font;
+ private Point fontPoint;
+ private String text;
+
+ public ImageLabelAttribute() {
+ images.add(ImageLabel.STATE_ENABLE, null);
+ images.add(ImageLabel.STATE_DISABLE, null);
+
+ fontColors.add(ImageLabel.STATE_ENABLE, null);
+ fontColors.add(ImageLabel.STATE_DISABLE, null);
+ }
+
+ public void setImage(int state, Image image) {
+ images.add(state, image);
+ }
+
+ public Image getImage(int state) {
+ return images.get(state);
+ }
+
+ public void setFontColor(int state, Color color) {
+ fontColors.add(state, color);
+ }
+
+ public Color getFontColor(int state) {
+ return fontColors.get(state);
+ }
+
+ public Point getFontPoint() {
+ return fontPoint;
+ }
+
+ public void setFontPoint(Point fontPoint) {
+ this.fontPoint = fontPoint;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public void setFont(Font font) {
+ this.font = font;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+
+public class ImageLabelDefaultRenderer extends ImageLabelRenderer{
+
+ @Override
+ public void draw(GC gc, Canvas canvas, ImageLabelAttribute attr) {
+ Image image = attr.getImage(attr.getState());
+ if (null == image) {
+ return;
+ }
+
+ Rectangle rect = canvas.getClientArea();
+ gc.drawImage(image, rect.x, rect.y);
+ drawText(gc, rect, attr);
+ }
+
+ public int computeFontSize(Rectangle rect) {
+ if (rect.height > 20)
+ return 10;
+ else
+ return 8;
+ }
+
+ protected void drawText(GC gc, Rectangle rect, ImageLabelAttribute attr) {
+ String text = attr.getText();
+ Font font = null;
+ Point p = null;
+
+ if (null != text) {
+ if (null == (font = attr.getFont())) {
+ font = new Font(Display.getCurrent(), "Arial",
+ computeFontSize(rect), SWT.BOLD);
+ attr.setFont(font);
+ }
+ gc.setFont(font);
+ gc.setForeground(attr.getFontColor(attr.getState()));
+
+ int x = 0, y = 0;
+ int offset = 0;
+ if (null == (p = attr.getFontPoint())) {
+ p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+ y = (rect.height - p.y) / 2;
+ x = (x < 0) ? 0 : x;
+ offset = 0;
+ } else {
+ x = p.x;
+ y = p.y;
+ }
+
+ gc.drawText(text, x + offset , y, true);
+ }
+ }
+
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class ImageLabelRenderer {
+ public abstract void draw(GC gc, Canvas canvas, ImageLabelAttribute attr);
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.da.widgets.combo.DACustomCombo;
+
+public class ModifyViewCombo extends DACustomCombo {
+
+ public ModifyViewCombo(Composite parent, int style) {
+ super(parent, style);
+ addPaintListener(comboPaintListener);
+ }
+
+ private PaintListener comboPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (!isImageCombo()) {
+ comboRenderer.draw(e.gc, combo, getText(), state);
+ } else {
+ comboRenderer.drawImage(e.gc, combo,
+ buttonUp != null ? buttonUp : getImages().get(state), getText(),
+ state);
+ }
+ }
+ };
+
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.manager.da.widgets.combo.TitleComboRenderer;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+
+public class ModifyViewComboRenderer extends TitleComboRenderer {
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, String text,
+ int state) {
+ Rectangle rect = canvas.getClientArea();
+ gc.drawImage(canvas.getBackgroundImage(), rect.x, rect.y);
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ gc.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ gc.drawString(text, 5, (rect.height - p.y) / 2 + 2, true);
+ Rectangle clipping = new Rectangle(rect.x + rect.width - 19, rect.y,
+ 19, rect.height);
+ gc.setClipping(clipping);
+ gc.drawImage(canvas.getBackgroundImage(), rect.x, rect.y);
+ // image is drop down image
+ gc.drawImage(image, rect.x + rect.width - 12,
+ rect.y + 7 /*(rect.height - image.getImageData().height)/2*/);
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonAttribute;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonDefaultRenderer;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.ui.VMButtonFactory;
+import org.tizen.emulator.manager.ui.VMsMainView;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class VMButton extends DACustomButton {
+ private VMButton button = null;
+ private VMProperty property = null;
+ protected DACustomButton launchButton = null;
+
+ static int W_OFFSET = 2;
+ static int H_OFFSET = 3;
+ private static int LAUNCH_BUTTON_WIDTH = 40;
+ private static int LAUNCH_BUTTON_HEIGHT =14;
+
+ public VMButton(Composite parent, int style) {
+ super(parent, style);
+ //button = this;
+
+ this.attr = new VMButtonAttribute();
+ this.setRenderer(new VMButtonRenderer());
+
+ // set font
+ this.setFontColors(ColorResources.VM_BUTTON_FONT_COLOR.getColor(),
+ ColorResources.VM_BUTTON_FONT_COLOR.getColor(),
+ ColorResources.VM_BUTTON_FONT_COLOR.getColor(),
+ ColorResources.VM_BUTTON_FONT_COLOR.getColor());
+ this.setFont(FontResources.VM_BUTTON_FONT.getFont());
+
+ // set image
+ this.setImages(ImageResources.VM_IMAGE_NOMAL.getImage(),
+ ImageResources.VM_IMAGE_NOMAL.getImage(),
+ ImageResources.VM_IMAGE_HOVER.getImage(),
+ null);
+
+ this.setBackground(ColorResources.LIST_BG_COLOR.getColor());
+ this.setLayout(new FormLayout());
+
+ // TODO
+ launchButton = new DACustomButton(this,
+ ImageResources.BUTTON_LAUNCH_NOMAL.getImage(),
+ ImageResources.BUTTON_LAUNCH_PUSH.getImage(),
+ ImageResources.BUTTON_LAUNCH_HOVER.getImage(),
+ ImageResources.BUTTON_LAUNCH_NOMAL.getImage());
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 119 + H_OFFSET);
+ data.left = new FormAttachment(0, 34 + W_OFFSET);
+ data.width = LAUNCH_BUTTON_WIDTH;
+ data.height = LAUNCH_BUTTON_HEIGHT;
+
+ launchButton.setLayoutData(data);
+ launchButton.addClickListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ // TODO Auto-generated method stub
+ VMButtonFactory.clickVMButton(getThis());
+ if (property != null) {
+ VMsMainView.getInstance().launchEmulator(property);
+ }
+ }
+ });
+
+ }
+
+ private VMButton getThis() {
+ return button;
+ }
+
+ public void setSelected(boolean selected) {
+ ((VMButtonAttribute)attr).setSelected(selected);
+ if (selected && property != null) {
+ VMsMainView.getInstance().drawDetailVM(property);
+ }
+ }
+
+ public void setProperty(VMProperty property) {
+ ((VMButtonAttribute)attr).setProperty(property);
+ this.property = property;
+ }
+}
+
+class VMButtonRenderer extends DACustomButtonDefaultRenderer {
+ @Override
+ public void draw(GC gc, Canvas canvas, int state,
+ DACustomButtonAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+
+ if (attr.getDrawType() == DACustomButton.TYPE_IMAGE) {
+ Image image = null;
+ image = attr.getImage(state);
+
+ if (null == image) {
+ return;
+ }
+
+ VMButtonAttribute vmAttr = (VMButtonAttribute)attr;
+
+ gc.drawImage(image, rect.x + VMButton.W_OFFSET, rect.y + VMButton.H_OFFSET);
+ if (vmAttr.isSelected()) {
+ gc.drawImage(ImageResources.VM_IMAGE_SELECTED.getImage(), rect.x, rect.y);
+ }
+ drawButtonText(gc, rect, attr, state);
+ } else if (attr.getDrawType() == DACustomButton.TYPE_COLOR
+ || attr.getDrawType() == DACustomButton.TYPE_GRADATION) {
+ drawButton(gc, rect, state, attr);
+ }
+ drawButtonImage(gc, rect, attr);
+ }
+
+ private static int X_POINT = 40 + VMButton.W_OFFSET;
+ private static int Y_POINT = 27 + VMButton.H_OFFSET;
+ private static int Y_GAP = 23;
+ private static int RE_X_POINT = 16 + VMButton.W_OFFSET;
+ protected void drawButtonText(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr, int state) {
+ VMButtonAttribute vmAttr = (VMButtonAttribute)attr;
+ VMProperty property = vmAttr.getProperty();
+ if (property == null) {
+ return;
+ }
+
+ int x = 0;
+ Point p = null;
+ p = gc.textExtent(property.getName(), SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+
+ gc.setFont(FontResources.VM_BUTTON_TITLE_FONT.getFont());
+ gc.setForeground(attr.getFontColor(state));
+
+ if (vmAttr.isSelected()) {
+ gc.setForeground(ColorResources.BLUE.getColor());
+ }
+
+ gc.drawString(property.getName(), x, 8, true);
+
+ // reset font coloer
+ gc.setForeground(attr.getFontColor(state));
+
+ VMPropertyValue value = property.getPropertyValue();
+
+ gc.drawString(property.getArch().name(), X_POINT, Y_POINT, true);
+ gc.drawString(Integer.toString(value.dpi), X_POINT, Y_POINT + Y_GAP, true);
+ gc.drawString(Integer.toString(value.ramSize), X_POINT, Y_POINT + Y_GAP * 2, true);
+ gc.drawString(value.resolution.getStrValue(), RE_X_POINT, Y_POINT + Y_GAP * 3, true);
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonAttribute;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class VMButtonAttribute extends DACustomButtonAttribute{
+ private boolean selected = false;
+ private VMProperty property = null;
+
+ public boolean isSelected() {
+ return selected;
+ }
+ public void setSelected(boolean selected) {
+ this.selected = selected;
+ }
+ public VMProperty getProperty() {
+ return property;
+ }
+ public void setProperty(VMProperty property) {
+ this.property = property;
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Event;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButton;
+import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener;
+
+public abstract class VMButtonClickEventListener extends DACustomButtonClickEventListener{
+ @Override
+ public void handleEvent(Event event) {
+ DACustomButton button = (DACustomButton) event.widget;
+ if (null != button && button.getState() != DACustomButton.STATE_DISABLE) {
+ Rectangle rectangle = button.getBounds();
+ int x = event.x;
+ int y = event.y;
+
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
+ return;
+ } else {
+ // TODO
+ // -> open detail view
+ // -> start emulator
+ /*
+ if ((x > 33 && x < 73) && (y > 118 && y < 133)) {
+ //new MessageDialog().openInfoDialog("TEST");
+ } else {
+
+ }
+ */
+ }
+ } else {
+ return;
+ }
+
+ handleClickEvent(button);
+ }
+}
\ No newline at end of file
import java.util.ArrayList;
import java.util.List;
-import org.tizen.emulator.manager.image.Skin;
-import org.tizen.emulator.manager.image.SkinList;
-import org.tizen.emulator.manager.tool.FilePath;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
import org.tizen.emulator.manager.vms.xml.ObjectFactory;
public class Creator {
- VMsProperty property;
+ VMProperty property;
VMPropertyValue newVM;
File folder;
private Creator() {} // for createInitialVMImage;
private Creator(VMPropertyValue newVM) {
- this.property = EmulatorVMs.getInstance().getNewProperty(newVM.vmsName);
+ this.property = EmulatorVMList.getInstance().getNewProperty(newVM.vmsName);
this.newVM = newVM;
this.folder = new File(FilePath.getInstance().getVirtualTargetPath(newVM.vmsName));
}
- public VMsProperty createInternal() throws VMsWorkerException {
+ public VMProperty createInternal() throws VMWorkerException {
if (this.property == null) {
- throw new VMsWorkerException("Failed to create the VM property!");
+ throw new VMWorkerException("Failed to create the VM property!");
}
folder.mkdirs();
createRam();
createUsability();
}
- catch(VMsCreatorException e) {
+ catch(VMCreatorException e) {
deleteFolder(folder);
throw e;
}
settingProperty();
- EmulatorVMs.getInstance().storeXML(property);
+ EmulatorVMList.getInstance().storeXML(property);
return property;
}
private String customPath = null;
private String swapPath = null;
- private void createDiskImage() throws VMsCreatorException {
+ private void createDiskImage() throws VMCreatorException {
if (newVM.baseImagePath == null || newVM.baseImagePath.isEmpty()) {
// TODO
//newVM.baseImagePath = FilePath.getInstance().getBaseimgPath();
- throw new VMsCreatorException("Base image does not exist.\n");
+ throw new VMCreatorException("Base image does not exist.\n");
}
if (!new File(newVM.baseImagePath).exists()) {
- throw new VMsCreatorException("Base image does not exist.\n" + newVM.baseImagePath);
+ throw new VMCreatorException("Base image does not exist.\n" + newVM.baseImagePath);
}
checkCustomBaseImage(newVM.baseImagePath);
customPath = folder.getAbsolutePath() + File.separator + "emulimg-" +
- newVM.vmsName + "." + (newVM.isStandard ? newVM.archType.toString() : EmulatorVMs.getInstance().CustomArch.toString());
+ newVM.vmsName + "." + (newVM.isStandard ? newVM.archType.toString() : EmulatorVMList.getInstance().CustomArch.toString());
createInitialVMImageInternal(newVM.baseImagePath, customPath);
- String swap_base_path = FilePath.getInstance().getSwapPath() + File.separator + StringResource.SWAP_IMAGE;
+ String swap_base_path = FilePath.getInstance().getSwapPath() + File.separator + StringResources.SWAP_IMAGE;
if (!new File(swap_base_path).exists()) {
return;
}
createSwapImageInternal(swap_base_path, swapPath);
}
- private void createSwapImageInternal(String basePath, String targetPath) throws VMsCreatorException {
+ private void createSwapImageInternal(String basePath, String targetPath) throws VMCreatorException {
String exe_path = FilePath.getInstance().getBinPath() + File.separator + "qemu-img";
List<String> cmd = new ArrayList<String>();
cmd.add(targetPath);
if (!new QemuImgProc(cmd).Running()) {
- throw new VMsCreatorException("Failed to create the VM because of failed qemu-img processing.\n"
+ throw new VMCreatorException("Failed to create the VM because of failed qemu-img processing.\n"
+ "You can get more information in log file ("
+ FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)");
}
}
- private void checkCustomBaseImage(final String path) throws VMsCreatorException {
+ private void checkCustomBaseImage(final String path) throws VMCreatorException {
String exe_path = FilePath.getInstance().getBinPath() + File.separator + "qemu-img";
List<String> cmd = new ArrayList<String>();
String errorMsg = new QemuImgProc(cmd).RunningForCheckImg();
if (errorMsg != null) {
- throw new VMsCreatorException(errorMsg);
+ throw new VMCreatorException(errorMsg);
}
}
- public void createInitialVMImageInternal(String baseImagePath, String targetImagePath) throws VMsCreatorException {
+ public void createInitialVMImageInternal(String baseImagePath, String targetImagePath) throws VMCreatorException {
String exe_path = FilePath.getInstance().getBinPath() + File.separator + "qemu-img";
List<String> cmd = new ArrayList<String>();
cmd.add(targetImagePath);
if (!new QemuImgProc(cmd).Running()) {
- throw new VMsCreatorException("Failed to create the VM because of failed qemu-img processing.\n"
+ throw new VMCreatorException("Failed to create the VM because of failed qemu-img processing.\n"
+ "You can get more information in log file ("
+ FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)");
}
}
// usability
- private void createFileShare() throws VMsCreatorException {
+ private void createFileShare() throws VMCreatorException {
if (newVM.isFileShareSupport) {
if (newVM.fileSharePath == null || newVM.fileSharePath.isEmpty()) {
- throw new VMsCreatorException("Select sharing file path");
+ throw new VMCreatorException("Select sharing file path");
}
}
}
// Device
- private void createDisplay() throws VMsCreatorException {
+ private void createDisplay() throws VMCreatorException {
/*
int i = newVM.resolution.indexOf('x');
newVM.resolutionType = new Resolution();
// TODO
if (newVM.skin == null && newVM.skinPath == null) {
- ArrayList<Skin> list = SkinList.getInstance().findSkinList(newVM.resolution.getValue());
+ ArrayList<Skin> list = SkinList.getInstance().findSkinList(newVM.resolution);
if (!list.isEmpty()) {
newVM.skin = list.get(0);
}
private void createUsability() {}
private void settingProperty() {
- ObjectFactory factory = EmulatorVMs.getInstance().getObjectFactory();
+ ObjectFactory factory = EmulatorVMList.getInstance().getObjectFactory();
EmulatorConfiguration ec = property.getConfiguration();
ec.setBaseInformation(factory.createBaseInformationType());
ec.setUsability(factory.createUsabilityType());
}
} else {
ec.getBaseInformation().getDiskImage().setType("custom");
- ec.getBaseInformation().setArchitecture(EmulatorVMs.getInstance().CustomArch);
+ ec.getBaseInformation().setArchitecture(EmulatorVMList.getInstance().CustomArch);
}
//
}
}
- public static VMsProperty create(VMPropertyValue newVM) throws VMsWorkerException {
+ public static VMProperty create(VMPropertyValue newVM) throws VMWorkerException {
return new Creator(newVM).createInternal();
}
- public static void createInitialVMImage(String basePath, String targetPath) throws VMsCreatorException {
+ public static void createInitialVMImage(String basePath, String targetPath) throws VMCreatorException {
new Creator().createInitialVMImageInternal(basePath, targetPath);
}
- public static void createSwapImage(String basePath, String targetPath) throws VMsWorkerException {
+ public static void createSwapImage(String basePath, String targetPath) throws VMWorkerException {
new Creator().createSwapImageInternal(basePath, targetPath);
}
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.transform.stream.StreamSource;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
import org.tizen.emulator.manager.vms.xml.ObjectFactory;
-public class EmulatorVMs {
- static EmulatorVMs instance = null;
+public class EmulatorVMList {
+ static EmulatorVMList instance = null;
static {
- synchronized(EmulatorVMs.class) {
- instance = new EmulatorVMs();
+ synchronized(EmulatorVMList.class) {
+ instance = new EmulatorVMList();
}
}
}
}
- List<VMsProperty> propertiesList = new ArrayList<VMsProperty>();
+ List<VMProperty> propertiesList = new ArrayList<VMProperty>();
ObjectFactory objectFactory = new ObjectFactory();
- public static EmulatorVMs getInstance() {
+ public static EmulatorVMList getInstance() {
return instance;
}
loadProperties();
}
+ class Pair implements Comparable<Object> {
+ public long t;
+ public File f;
+
+ public Pair(File file) {
+ f = file;
+ t = file.lastModified();
+ }
+
+ public int compareTo(Object o) {
+ long u = ((Pair) o).t;
+ return t < u ? -1 : t == u ? 0 : 1;
+ }
+ };
+
public void loadProperties() {
propertiesList.clear();
// traverse VMs...
File vmsDirectory = new File(vmsConfigDirectory);
String configFilename = null;
File configFile = null;
- VMsProperty property = null;
- for(File vm : vmsDirectory.listFiles(new FileFilter() {
+ VMProperty property = null;
+ File[] files = vmsDirectory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if(!pathname.isDirectory()) {
}
return true;
}
- })) {
- configFilename = StringResource.PROPERTY_XML_NAME;
+ });
+ Pair[] pairs = new Pair[files.length];
+ for (int i = 0; i < files.length; i++)
+ pairs[i] = new Pair(files[i]);
+
+ // Sort them by timestamp.
+ Arrays.sort(pairs);
+
+ // Take the sorted pairs and extract only the file part, discarding the timestamp.
+ for (int i = 0; i < files.length; i++)
+ files[i] = pairs[i].f;
+ for(File vm : files) {
+ configFilename = StringResources.PROPERTY_XML_NAME;
configFile = new File(vm, configFilename);
if(!configFile.exists()) {
continue ; // FIXME
}
}
- private VMsProperty parseXML(File configFile) {
+ private VMProperty parseXML(File configFile) {
JAXBContext context = null;
JAXBElement<EmulatorConfiguration> element = null;
return null;
}
- return new VMsProperty(configFile, element.getValue());
+ return new VMProperty(configFile, element.getValue());
}
- public VMsProperty getProperty(String name) {
+ public VMProperty getProperty(String name) {
if(name == null) {
return null;
}
- for(VMsProperty property : propertiesList) {
+ for(VMProperty property : propertiesList) {
if(name.equals(property.getName())) {
return property;
}
return null;
}
- public VMsProperty[] getProperties() {
- return propertiesList.toArray(new VMsProperty[propertiesList.size()]);
+ public VMProperty[] getProperties() {
+ return propertiesList.toArray(new VMProperty[propertiesList.size()]);
}
- public boolean storeXML(VMsProperty property) {
+ public boolean storeXML(VMProperty property) {
JAXBContext context = null;
try {
return true;
}
- public VMsProperty getNewProperty(String name) {
+ public VMProperty getNewProperty(String name) {
String configDirectoryName = FilePath.getInstance().getTizenVmsPath() + File.separator + name;
- String configFilename = configDirectoryName + File.separator + StringResource.PROPERTY_XML_NAME;
+ String configFilename = configDirectoryName + File.separator + StringResources.PROPERTY_XML_NAME;
File configFile = new File(configFilename);
// .
// .
- return new VMsProperty(configFile, ec);
+ return new VMProperty(configFile, ec);
}
// for testing "load properties"...
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.ui.MainDialog;
-public class VMCreateHelper {
- public boolean checkString(String t) {
+public class HelperClass {
+ public static boolean checkImageName(String newName, boolean showStatus) {
+ String errorMsg = "";
+ boolean result = true;
+ if (newName.length() > VMProperty.MAX_NAME_LEN) {
+ errorMsg = "Max length is 20.";
+ result = false;
+ } else if (!checkString(newName)) {
+ errorMsg = "Name is invalid!";
+ result = false;
+ } else if (checkDupulicateName(newName)) {
+ errorMsg = "Same name exists!";
+ result = false;
+ } else if (newName.length() == VMProperty.MAX_NAME_LEN) {
+ errorMsg = "Max length is 20.";
+ } else if (newName.isEmpty()) {
+ result = false;
+ }
+ if (showStatus) {
+ if (errorMsg.isEmpty()) {
+ MainDialog.getStatusBar().reset();
+ } else {
+ MainDialog.getStatusBar().error(errorMsg);
+ }
+ }
+ return result;
+ }
+ public static boolean checkString(String t) {
for(char ch : t.toCharArray()) {
if((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
return true;
}
- public boolean checkDupulicateName(String t) {
+ public static boolean checkDupulicateName(String t) {
boolean isWindows = false;
- if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+ if (EmulatorManager.isWin()) {
isWindows = true;
t = t.toLowerCase();
}
- VMsProperty[] properties = (VMsProperty[])EmulatorVMs.getInstance().getProperties();
- for (VMsProperty p : properties) {
+ VMProperty[] properties = (VMProperty[])EmulatorVMList.getInstance().getProperties();
+ for (VMProperty p : properties) {
if (isWindows ) {
if (p.getName().toLowerCase().equals(t)) {
return true;
return false;
}
- public Combo makeCombo(Composite composite) {
+ public static Combo makeCombo(Composite composite) {
Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.addListener(SWT.MouseWheel, new Listener() {
return combo;
}
- public void addComboItem(Combo combo, Object[] items) {
+ public static void addComboItem(Combo combo, Object[] items) {
if (items == null) {
return;
} else {
}
}
- public void addComboItem(Combo combo, Object[] items, int defaultIndex) {
+ public static void addComboItem(Combo combo, Object[] items, int defaultIndex) {
if (items == null || items.length == 0) {
return;
}
combo.select(defaultIndex);
}
+
+ public static GridLayout getNopaddedGridLayout(int numColumns, boolean makeColumnEqualWidth) {
+ GridLayout layout = new GridLayout(numColumns, makeColumnEqualWidth);
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginBottom = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginWidth = 0;
+
+ return layout;
+ }
}
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePath;
import org.tizen.emulator.manager.tool.CheckVirtualization;
-import org.tizen.emulator.manager.tool.FilePath;
import org.tizen.emulator.manager.tool.PortHelper;
import org.tizen.emulator.manager.tool.SelectWorkspace;
-import org.tizen.emulator.manager.ui.MessageDialog;
+import org.tizen.emulator.manager.ui.MainDialog;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
import org.tizen.emulator.manager.vms.xml.TouchType;
public class Launcher {
isConsole = EmulatorManager.isConsoleMode();
}
- public List<String> getLaunchCommand(VMsProperty property, String path) throws VMsWorkerException{
+ public List<String> getLaunchCommand(VMProperty property, String path) throws VMWorkerException{
String binary;
String hwVirtualization = "";
int portNo;
if(portNo == -1) {
String error = "Can not execute emulator.\n All available ports are in use.";
if (!isConsole) {
- MessageDialog alert = new MessageDialog(EmulatorManager.getInstance().getMainDialog().getShell());
+ MessageDialog alert = new MessageDialog(MainDialog.getShell());
alert.openInfoDialog(error);
}
logger.log(Level.WARNING, error);
}
if (property.getArch().toString().equals("x86")) {
- if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+ if (EmulatorManager.isWin()) {
binary = "emulator-x86.exe";
} else {
binary = "emulator-x86";
}
} else {
- if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+ if (EmulatorManager.isWin()) {
binary = "emulator-arm.exe";
} else {
binary = "emulator-arm";
File child = new File(property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue());
File base = new File(property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue());
if (!child.exists()) {
- throw new VMsWorkerException("Child disk image does not exist.\n" + child.getAbsolutePath());
+ throw new VMWorkerException("Child disk image does not exist.\n" + child.getAbsolutePath());
}
if (!base.exists()) {
- throw new VMsWorkerException("Base disk image does not exist.\n" + base.getAbsolutePath());
+ throw new VMWorkerException("Base disk image does not exist.\n" + base.getAbsolutePath());
}
if (property.getConfiguration().getUsability().isHwVirtualization() && CheckVirtualization.getInstance().isSupportVirtualization()) {
}
}
String fileshare = property.getConfiguration().getUsability().getFileSharing().getPath();
- int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
- int isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows");
String osVersion = System.getProperty("os.version");
boolean isFileshare = true;
if (fileshare == null) {
cmd.add("c");
cmd.add("-append");
/* is linux and use fileshare [kernel option] */
- if(isLinux > -1 && isFileshare) {
+ if(EmulatorManager.isLinux() && isFileshare) {
cmd.add("console=ttyS0 video=uvesafb:ywrap,"
+ width
+ "x"
+ " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5");
}
/* is linux and use fileshare [non-kernel option] */
- if(isLinux > -1 && isFileshare) {
+ if(EmulatorManager.isLinux() && isFileshare) {
cmd.add("-virtfs");
cmd.add("local,path=" + property.getConfiguration().getUsability().getFileSharing().getPath() +",security_model=none,mount_tag=fileshare");
}
/* is windows XP and use fileshare */
- if(isWindows > -1 && osVersion.equals("5.1") && isFileshare) {
+ if(EmulatorManager.isWin() && osVersion.equals("5.1") && isFileshare) {
/* delete if fileshare with the same name existed */
List<String> cmd2 = new ArrayList<String>();
cmd2.add("net");
}
}
/* is windows 7 and use fileshare */
- else if(isWindows > -1 && osVersion.equals("6.1") && isFileshare) {
+ else if(EmulatorManager.isWin() && osVersion.equals("6.1") && isFileshare) {
/* delete if fileshare with the same name existed */
List<String> cmd2 = new ArrayList<String>();
cmd2.add("net");
}
}
cmd.add("-serial");
- cmd.add("file:" + EmulatorVMs.getInstance().getVMsConfigDirectory() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
+ cmd.add("file:" + EmulatorVMList.getInstance().getVMsConfigDirectory() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
cmd.add("-m");
cmd.add(String.valueOf(property.getConfiguration().getDevice().getRAM().getSize().getValue()));
cmd.add("-M");
+ " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5"
+ " virtio_mmio.device=4K@0x10AD0000:423 virtio_mmio.device=4K@0x10AC0000:422");
cmd.add("-serial");
- cmd.add(isLinux > -1 ? "/dev/null" : "none");
+ cmd.add(EmulatorManager.isLinux() ? "/dev/null" : "none");
cmd.add("-serial");
- cmd.add(isLinux > -1 ? "/dev/null" : "none");
+ cmd.add(EmulatorManager.isLinux() ? "/dev/null" : "none");
cmd.add("-serial");
- cmd.add("file:" + EmulatorVMs.getInstance().getVMsConfigDirectory() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
+ cmd.add("file:" + EmulatorVMList.getInstance().getVMsConfigDirectory() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
cmd.add("-m");
cmd.add(String.valueOf(property.getConfiguration().getDevice().getRAM().getSize().getValue()));
cmd.add("-M");
return cmd;
}
- public boolean launch(VMsProperty property) {
+ public boolean launch(VMProperty property) {
List<String> cmd;
try {
cmd = getLaunchCommand(property, null);
- } catch (VMsWorkerException e) {
+ } catch (VMWorkerException e) {
if (!isConsole) {
MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
msg.openWarningDialog("Failed to launch : " + e.getMessage());
}
class MonitoringEmulator extends Thread {
- private VMsProperty property;
- public MonitoringEmulator(VMsProperty property) {
+ private VMProperty property;
+ public MonitoringEmulator(VMProperty property) {
this.property = property;
this.setDaemon(true);
}
public void run() {
boolean isChecking = false;
for (int i = 0; i < 8 ; i++) {
- if (VMsWorker.checking(property)) {
+ if (VMWorker.checking(property)) {
isChecking = true;
CheckingRunningEmulator.removeEmulator(property.getName());
break;
public class Modifier {
private Modifier() {}
- static void modify(VMsProperty property, VMPropertyValue oldVM, VMPropertyValue newVM) throws VMsWorkerException {
+ static void modify(VMProperty property, VMPropertyValue newVM) throws VMWorkerException {
+ VMPropertyValue oldVM = property.getPropertyValue();
if(oldVM.equals(newVM)) {// if nothing if modified...
return;
}
//else if (EmulatorManager.getInstance().getManagerMode().equals(ManagerModeType.INHOUSE_MODE)) {
//touchType == null
EmulatorConfiguration ec = property.getConfiguration();
- ec.getDevice().setTouch(EmulatorVMs.getInstance().getObjectFactory().createTouchType());
+ ec.getDevice().setTouch(EmulatorVMList.getInstance().getObjectFactory().createTouchType());
ec.getDevice().getTouch().setMaxTouchPoint(newVM.maxTouchCount);
}
}
property.getConfiguration().getUsability().setAdvancedOptions(newVM.addOptions);
}
- EmulatorVMs.getInstance().storeXML(property);
+ EmulatorVMList.getInstance().storeXML(property);
}
- private static void modifyFileShare(VMPropertyValue newVM) throws VMsWorkerException {
+ private static void modifyFileShare(VMPropertyValue newVM) throws VMWorkerException {
if (newVM.isFileShareSupport && newVM.fileSharePath.isEmpty()) {
- throw new VMsWorkerException("Select sharing file path");
+ throw new VMWorkerException("Select sharing file path");
}
}
}
import java.util.logging.Level;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
+import org.tizen.emulator.manager.resources.FilePath;
public class QemuImgProc {
private List<String> cmd = null;
private String type;
private int dpi;
private String strValue;
- private String str;
+ private String strTypeValue;
RESOLUTION(int width, int height, String type, int dpi) {
this.resolution = new Resolution();
strValue = width +"x" + height;
if (type.isEmpty()) {
- str = width + "x" + height;
+ strTypeValue = width + "x" + height;
} else {
- str = type + "(" + width + "x" + height + ")";
+ strTypeValue = type + "(" + width + "x" + height + ")";
}
}
return resolution;
}
- public String getValue() {
+ public String getStrValue() {
return strValue;
}
+ public String getStrTypeValue() {
+ return strTypeValue;
+ }
+
public String toString() {
- return str;
+ return strTypeValue;
}
}
--- /dev/null
+package org.tizen.emulator.manager.vms;
+
+public enum SKIN_TYPE {
+ GENERAL(0), PHONE_SHAPE(1);
+ int type;
+ SKIN_TYPE(int t) {
+ this.type = t;
+ }
+}
package org.tizen.emulator.manager.vms;
-public class VMsCreatorException extends VMsWorkerException {
+public class VMCreatorException extends VMWorkerException {
private static final long serialVersionUID = -1670534140703381550L;
- public VMsCreatorException(String message) {
+ public VMCreatorException(String message) {
super(message);
}
}
import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
-public class VMsProperty {
+public class VMProperty {
+ public static final int MAX_NAME_LEN = 20;
+ public static final int MIN_DPI = 100;
+ public static final int MAX_DPI = 480;
+
File propertyFile;
EmulatorConfiguration configuration;
- VMsWorker worker;
- VMPropertyValue value;
-
- public VMsProperty(File propertyFile, EmulatorConfiguration element) {
+ VMWorker worker;
+ VMPropertyValue value = null;
+
+ @Override
+ public boolean equals(Object obj) {
+ VMProperty target = (VMProperty)obj;
+ if (target.getName().equals(getName())) {
+ return true;
+ }
+ return false;
+ }
+ public VMProperty(File propertyFile, EmulatorConfiguration element) {
this.propertyFile = propertyFile;
this.configuration = element;
- this.worker = new VMsWorker(this);
+ this.worker = new VMWorker(this);
}
public VMPropertyValue getPropertyValue() {
-// if(this.value == null)
-// this.value = new VMPropertyValue(this);
-// return value;
- return new VMPropertyValue(this); // FIXME
+ if(this.value == null) {
+ this.value = new VMPropertyValue(this);
+ }
+ return value;
+ //return new VMsPropertyValue(this); // FIXME
}
- public VMsWorker getWorker() {
+ public VMWorker getWorker() {
return worker;
}
FSImageType.standard : FSImageType.custom;
}
+ public String getBaseImageName() {
+ if(configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+ return null;
+ }
+
+ return configuration.getBaseInformation().getDiskImage().getBase();
+ }
+
+ public String getImageVersion() {
+ if(configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+ return null;
+ }
+
+ return configuration.getBaseInformation().getDiskImage().getVersion();
+ }
+
public EmulatorConfiguration getConfiguration() {
return configuration;
}
import java.io.IOException;
import java.util.ArrayList;
-import org.tizen.emulator.manager.image.BaseImage;
-import org.tizen.emulator.manager.image.SkinList;
-import org.tizen.emulator.manager.image.Skin;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.platform.Skin;
+import org.tizen.emulator.manager.platform.SkinList;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.tool.CheckVirtualization;
-import org.tizen.emulator.manager.tool.StringResource;
import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution;
import org.tizen.emulator.manager.vms.xml.TouchType;
customSkins = new ArrayList<Skin>();
}
public BaseImage image;
- public VMsProperty template;
+ public VMProperty template;
public String vmsName;
public String archType;
private VMPropertyValue(){} // for clone
- public VMPropertyValue(BaseImage image, VMsProperty template) {
+ public VMPropertyValue(BaseImage image, VMProperty template) {
this.image = image;
this.template = template;
isStandard = true;
archType = image.getCpu();
version = image.getVersion();
- baseName = image.getDirName();
+ baseName = image.getName();
baseImagePath = image.getPath();
- baseImagePathName = image.getImagePathName();
+ baseImagePathName = image.getPathName();
settingConfigure(template);
}
}
- public VMPropertyValue(VMsProperty property) {
+ public VMPropertyValue(VMProperty property) {
assert property == null;
this.template = property;
return true;
}
- private void settingConfigure(VMsProperty property) {
+ private void settingConfigure(VMProperty property) {
if (property == null) {
settingConfigure();
return;
(fileSharePath.lastIndexOf(File.separator) + 1, fileSharePath.length());
} else {
fileSharePath = "";
- fileSharePathName = StringResource.None;
+ fileSharePathName = StringResources.None;
}
ramSize = property.getConfiguration().getDevice().getRAM().getSize().getValue();
resolution = RESOLUTION.HD;
dpi = RESOLUTION.HD.getDPI(); // this value be related to resolution
- ArrayList<Skin> list = SkinList.getInstance().findSkinList(resolution.getValue());
+ ArrayList<Skin> list = SkinList.getInstance().findSkinList(resolution);
if (!list.isEmpty()) {
skin = list.get(0);
}
isFileShareSupport = false;
fileSharePath = "";
- fileSharePathName = StringResource.None;
+ fileSharePathName = StringResources.None;
isHWVirtualization = CheckVirtualization.getInstance().isSupportVirtualization();
isGLAcceleration = CheckVirtualization.getInstance().isSupportGPU();
addOptions = null;
}
- private void settingDefault(boolean isStandard, VMsProperty template) {
+ private void settingDefault(boolean isStandard, VMProperty template) {
vmsName = "";
archType = isStandard ? template.getArch().toString() : "x86";
baseImagePath = "";
- baseImagePathName = isStandard ? (archType.equals("x86") ? "( emulimg-2.0.x86 )" : "( emulimg-2.0.arm )") : StringResource.None;
+ baseImagePathName = isStandard ? (archType.equals("x86") ? "( emulimg-2.0.x86 )" : "( emulimg-2.0.arm )") : StringResources.None;
settingConfigure(template);
}
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.tool.FilePath;
-import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.resources.FilePath;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.MenuHandling;
-import org.tizen.emulator.manager.ui.MessageDialog;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
-public class VMsWorker {
- VMsProperty property;
+public class VMWorker {
+ VMProperty property;
Launcher launcher;
- WorkerThread worker = null;
+ WorkerThread worker = null;
String baseImagePath = null;
- public VMsWorker(VMsProperty property) {
+ public VMWorker(VMProperty property) {
this.property = property;
launcher = new Launcher();
}
- public void launchVM() throws VMsWorkerException {
+ public void launchVM() throws VMWorkerException {
if(isRunningNow()) {
- throw new VMsWorkerException("Can not execute this VM."
- + StringResource.NEW_LINE
+ throw new VMWorkerException("Can not execute this VM." + StringResources.NEW_LINE
+ "The same name is running now.");
}
launcher.launch(property);
}
- public boolean createVM(VMPropertyValue newVM) throws VMsWorkerException {
- Creator.create(newVM);
-
- return true;
- }
-
- public void modifyVM(VMPropertyValue oldVM, VMPropertyValue newVM) throws VMsWorkerException {
+ public void modifyVM(VMPropertyValue newVM) throws VMWorkerException {
if(EmulatorManager.isConsoleMode() && property.getWorker().isRunningNow()) {
- throw new VMsWorkerException("Not allowed to modify active VMs"
- + StringResource.NEW_LINE
+ throw new VMWorkerException("Not allowed to modify active VMs"
+ + StringResources.NEW_LINE
+ "[" + property.getName() + "] is running now...");
}
- Modifier.modify(property, oldVM, newVM);
+ Modifier.modify(property, newVM);
}
- public void createNewBaseImage(VMsProperty property, String dest) throws VMsWorkerException {
+ public void createNewBaseImage(VMProperty property, String dest) throws VMWorkerException {
baseImagePath = dest;
File childImage = new File(property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue());
File baseImage = new File(property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue());
if(!childImage.exists()) {
- throw new VMsWorkerException("Failed to create base image!\nFile does not exist :" + childImage.getAbsolutePath());
+ throw new VMWorkerException("Failed to create base image!" + StringResources.NEW_LINE
+ + "File does not exist :" + childImage.getAbsolutePath());
}
if(!baseImage.exists()) {
- throw new VMsWorkerException("Failed to create base image!\nFile does not exist :" + baseImage.getAbsolutePath());
+ throw new VMWorkerException("Failed to create base image!" + StringResources.NEW_LINE
+ + "File does not exist :" + baseImage.getAbsolutePath());
}
String exe_path = FilePath.getInstance().getBinPath() + File.separator + "qemu-img";
worker = new WorkerThread(proc);
worker.start();
if (EmulatorManager.isConsoleMode()) {
- System.out.println("Wait....while creating base image." + StringResource.NEW_LINE
+ System.out.println("Wait....while creating base image.\n"
+ "This task can take about 30 ~ 60 seconds");
synchronized(worker) {
try {
e.printStackTrace();
}
if (worker.isError()) {
- throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
- + StringResource.NEW_LINE
+ throw new VMWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
+ + StringResources.NEW_LINE
+ "You can get more information in log file ("
+ FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)");
}
e.printStackTrace();
}
if (worker.isError()) {
- throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
- + StringResource.NEW_LINE
+ throw new VMWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
+ + StringResources.NEW_LINE
+ "You can get more information in log file ("
+ FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)");
}
/*
if (! proc.Running()) {
//dialog.Close();
- throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n"
+ throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
+ + StringResources.NEW_LINE
+ "You can get more information in log file ("
+ FileIO.getInstance().getTizenVmsArchPath() + File.separator + "emulator-manager)");
}
}
}
- public void deleteVM() throws VMsWorkerException {
+ public void deleteVM() throws VMWorkerException {
File vmDirectory = property.propertyFile.getParentFile();
if(!vmDirectory.isDirectory()) {
- throw new VMsWorkerException("Check VM path !");
+ throw new VMWorkerException("Check VM path!");
}
if (vmDirectory.exists()) {
}
}
- public void resetVM() throws VMsWorkerException {
+ public void resetVM() throws VMWorkerException {
String basePath = property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
String targetPath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
if (basePath == null || basePath.isEmpty() || targetPath == null || targetPath.isEmpty()) {
- throw new VMsWorkerException("Fail to reset Emulator" + StringResource.NEW_LINE +
- "Emulator Name : " + property.getName());
+ throw new VMWorkerException("Fail to reset Emulator " + StringResources.NEW_LINE
+ + "Emulator Name : " + property.getName());
}
File oldImageFile = new File(targetPath);
try {
Creator.createInitialVMImage(basePath, targetPath);
- } catch (VMsCreatorException e) {
- throw new VMsWorkerException("Fail to reset Emulator" + StringResource.NEW_LINE
+ } catch (VMCreatorException e) {
+ throw new VMWorkerException("Fail to reset Emulator" + StringResources.NEW_LINE
+ "Emulator Name : " + property.getName()
- + StringResource.NEW_LINE + e.getMessage());
+ + StringResources.NEW_LINE + e.getMessage());
}
if (property.getConfiguration().getBaseInformation().getDiskImage().getSwapDiskImage() != null) {
- String swapBasePath = FilePath.getInstance().getSwapPath() + File.separator + StringResource.SWAP_IMAGE;
+ String swapBasePath = FilePath.getInstance().getSwapPath() + File.separator + StringResources.SWAP_IMAGE;
String swapTargetPath = property.getConfiguration().getBaseInformation().getDiskImage().getSwapDiskImage().getValue();
if (!new File(swapBasePath).exists()) {
return;
}
if (swapTargetPath == null || swapTargetPath.isEmpty()) {
- throw new VMsWorkerException("Fail to reset Emulator beacause swap path is empty." + StringResource.NEW_LINE +
- "Emulator Name : " + property.getName());
+ throw new VMWorkerException("Fail to reset Emulator beacause swap path is empty." + StringResources.NEW_LINE
+ + "Emulator Name : " + property.getName());
}
File oldSwapFile = new File(swapTargetPath);
}
try {
- Creator.createSwapImage(swapBasePath, swapTargetPath);
- } catch (VMsCreatorException e) {
- throw new VMsWorkerException("Fail to reset Emulator" + StringResource.NEW_LINE
+ Creator.createSwapImage(swapBasePath, swapTargetPath);
+ } catch (VMCreatorException e) {
+ throw new VMWorkerException("Fail to reset Emulator" + StringResources.NEW_LINE
+ "Emulator Name : " + property.getName()
- + StringResource.NEW_LINE + e.getMessage());
+ + StringResources.NEW_LINE + e.getMessage());
}
}
}
- public void cloneVM(String newVMName) throws VMsWorkerException {
- EmulatorVMs.getInstance().CustomArch = property.getArch().toString();
+ public void cloneVM(String newVMName) throws VMWorkerException {
+ EmulatorVMList.getInstance().CustomArch = property.getArch().toString();
VMPropertyValue newValue = property.getPropertyValue();
newValue.vmsName = newVMName;
// TODO
return checking(property);
}
- public static boolean checking(VMsProperty prop) {
+ public static boolean checking(VMProperty prop) {
Logger logger = EMLogger.getLogger();
boolean result = false;
- int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
- int isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows");
- int isMac = System.getProperty("os.name").toLowerCase().indexOf("mac");
-
String line;
List<String> cmd = new ArrayList<String>();
- if(isLinux > -1) {
+ if(EmulatorManager.isLinux()) {
cmd.add("/bin/ps");
cmd.add("-ef");
}
- else if(isWindows > -1) {
+ else if(EmulatorManager.isWin()) {
cmd.add("tasklist");
cmd.add("/V");
cmd.add("/FI");
cmd.add("/FO");
cmd.add("CSV");
}
- else if (isMac > -1){
+ else if (EmulatorManager.isMac()){
cmd.add("/bin/ps");
cmd.add("-ef");
}
p = pb.start();
inputReader = new InputStreamReader(p.getInputStream());
stdOut = new BufferedReader(inputReader);
- if(isLinux > -1) {
+ if(EmulatorManager.isLinux()) {
while ((line = stdOut.readLine()) != null) {
String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
if(line.contains(imagePath)) {
}
}
}
- else if(isWindows > -1) {
+ else if(EmulatorManager.isWin()) {
while ((line = stdOut.readLine()) != null) {
String[] titleName = line.split(",");
// "split[split.length - 1]" is window title.
}
}
}
- else if(isMac > -1) {
+ else if(EmulatorManager.isMac()) {
while ((line = stdOut.readLine()) != null) {
String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
if(line.contains(imagePath)) {
}
if (!result) {
- logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.\n");
+ logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.");
}
return result;
} catch (IOException err) {
logger.log(Level.SEVERE, err.getMessage());
if (!EmulatorManager.isConsoleMode()) {
MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
- msg.openWarningDialog("Error occured while checking if the same VM ."
- + StringResource.NEW_LINE
- + err.getMessage());
+ msg.openWarningDialog("Error occured while checking if the same VM."
+ + StringResources.NEW_LINE + err.getMessage());
}
return false;
package org.tizen.emulator.manager.vms;
-public class VMsWorkerException extends Exception {
+public class VMWorkerException extends Exception {
private static final long serialVersionUID = -6819776106619652987L;
- public VMsWorkerException(String message) {
+ public VMWorkerException(String message) {
super(message);
}
}