From: jihye kim Date: Mon, 1 Apr 2013 02:32:55 +0000 (+0900) Subject: [Title] emulator-manager : update ux X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=002e5c577e708ccd70dacdf1add9793d451959c3;p=sdk%2Femulator%2Femulator-manager.git [Title] emulator-manager : update ux [Desc.] update ux [Issue] N/A Change-Id: Ib6b4f30d826cf8b4f2b8788623d16e58a6f8bcf9 --- diff --git a/resource/res/add_new_hover.gif b/resource/res/add_new_hover.gif new file mode 100755 index 0000000..cace0aa Binary files /dev/null and b/resource/res/add_new_hover.gif differ diff --git a/resource/res/add_new_nml.gif b/resource/res/add_new_nml.gif new file mode 100755 index 0000000..9b8e5ce Binary files /dev/null and b/resource/res/add_new_nml.gif differ diff --git a/resource/res/add_new_pushed.gif b/resource/res/add_new_pushed.gif new file mode 100755 index 0000000..7726b27 Binary files /dev/null and b/resource/res/add_new_pushed.gif differ diff --git a/resource/res/arrow_down.gif b/resource/res/arrow_down.gif new file mode 100755 index 0000000..38fb438 Binary files /dev/null and b/resource/res/arrow_down.gif differ diff --git a/resource/res/arrow_up.gif b/resource/res/arrow_up.gif new file mode 100755 index 0000000..d28e6d8 Binary files /dev/null and b/resource/res/arrow_up.gif differ diff --git a/resource/res/background.gif b/resource/res/background.gif new file mode 100755 index 0000000..c1d7c47 Binary files /dev/null and b/resource/res/background.gif differ diff --git a/resource/res/button_file_dis.gif b/resource/res/button_file_dis.gif new file mode 100755 index 0000000..ec532b6 Binary files /dev/null and b/resource/res/button_file_dis.gif differ diff --git a/resource/res/button_file_hover.gif b/resource/res/button_file_hover.gif new file mode 100755 index 0000000..1eea78c Binary files /dev/null and b/resource/res/button_file_hover.gif differ diff --git a/resource/res/button_file_nml.gif b/resource/res/button_file_nml.gif new file mode 100755 index 0000000..e3791bb Binary files /dev/null and b/resource/res/button_file_nml.gif differ diff --git a/resource/res/button_file_pushed.gif b/resource/res/button_file_pushed.gif new file mode 100755 index 0000000..4f88543 Binary files /dev/null and b/resource/res/button_file_pushed.gif differ diff --git a/resource/res/button_hover_left.gif b/resource/res/button_hover_left.gif new file mode 100755 index 0000000..719afbc Binary files /dev/null and b/resource/res/button_hover_left.gif differ diff --git a/resource/res/button_hover_middle.gif b/resource/res/button_hover_middle.gif new file mode 100755 index 0000000..e02ac49 Binary files /dev/null and b/resource/res/button_hover_middle.gif differ diff --git a/resource/res/button_hover_right.gif b/resource/res/button_hover_right.gif new file mode 100755 index 0000000..8408eae Binary files /dev/null and b/resource/res/button_hover_right.gif differ diff --git a/resource/res/button_launch_hover.gif b/resource/res/button_launch_hover.gif new file mode 100755 index 0000000..ad6a94f Binary files /dev/null and b/resource/res/button_launch_hover.gif differ diff --git a/resource/res/button_launch_nml.gif b/resource/res/button_launch_nml.gif new file mode 100644 index 0000000..d90abdc Binary files /dev/null and b/resource/res/button_launch_nml.gif differ diff --git a/resource/res/button_launch_pushed.gif b/resource/res/button_launch_pushed.gif new file mode 100755 index 0000000..bea863b Binary files /dev/null and b/resource/res/button_launch_pushed.gif differ diff --git a/resource/res/button_nml_left.gif b/resource/res/button_nml_left.gif new file mode 100755 index 0000000..36d382f Binary files /dev/null and b/resource/res/button_nml_left.gif differ diff --git a/resource/res/button_nml_middle.gif b/resource/res/button_nml_middle.gif new file mode 100755 index 0000000..5410a7d Binary files /dev/null and b/resource/res/button_nml_middle.gif differ diff --git a/resource/res/button_nml_right.gif b/resource/res/button_nml_right.gif new file mode 100755 index 0000000..ee6d092 Binary files /dev/null and b/resource/res/button_nml_right.gif differ diff --git a/resource/res/button_off_hover.gif b/resource/res/button_off_hover.gif new file mode 100755 index 0000000..c0c3cba Binary files /dev/null and b/resource/res/button_off_hover.gif differ diff --git a/resource/res/button_off_nml.gif b/resource/res/button_off_nml.gif new file mode 100755 index 0000000..a2c24b4 Binary files /dev/null and b/resource/res/button_off_nml.gif differ diff --git a/resource/res/button_off_pushed.gif b/resource/res/button_off_pushed.gif new file mode 100755 index 0000000..291d13d Binary files /dev/null and b/resource/res/button_off_pushed.gif differ diff --git a/resource/res/button_on_hover.gif b/resource/res/button_on_hover.gif new file mode 100755 index 0000000..76e095b Binary files /dev/null and b/resource/res/button_on_hover.gif differ diff --git a/resource/res/button_on_nml.gif b/resource/res/button_on_nml.gif new file mode 100755 index 0000000..caa26d0 Binary files /dev/null and b/resource/res/button_on_nml.gif differ diff --git a/resource/res/button_on_pushed.gif b/resource/res/button_on_pushed.gif new file mode 100755 index 0000000..670e65e Binary files /dev/null and b/resource/res/button_on_pushed.gif differ diff --git a/resource/res/button_pushed_left.gif b/resource/res/button_pushed_left.gif new file mode 100755 index 0000000..37f62ea Binary files /dev/null and b/resource/res/button_pushed_left.gif differ diff --git a/resource/res/button_pushed_middle.gif b/resource/res/button_pushed_middle.gif new file mode 100755 index 0000000..cc85868 Binary files /dev/null and b/resource/res/button_pushed_middle.gif differ diff --git a/resource/res/button_pushed_right.gif b/resource/res/button_pushed_right.gif new file mode 100755 index 0000000..be695a6 Binary files /dev/null and b/resource/res/button_pushed_right.gif differ diff --git a/resource/res/create_new_hover.gif b/resource/res/create_new_hover.gif new file mode 100755 index 0000000..613bbd9 Binary files /dev/null and b/resource/res/create_new_hover.gif differ diff --git a/resource/res/create_new_nml.gif b/resource/res/create_new_nml.gif new file mode 100755 index 0000000..d11ad4f Binary files /dev/null and b/resource/res/create_new_nml.gif differ diff --git a/resource/res/create_new_pushed.gif b/resource/res/create_new_pushed.gif new file mode 100755 index 0000000..fc4aada Binary files /dev/null and b/resource/res/create_new_pushed.gif differ diff --git a/resource/res/detail_category_left.gif b/resource/res/detail_category_left.gif new file mode 100755 index 0000000..9bdbe6d Binary files /dev/null and b/resource/res/detail_category_left.gif differ diff --git a/resource/res/detail_category_middle.gif b/resource/res/detail_category_middle.gif new file mode 100755 index 0000000..72c898d Binary files /dev/null and b/resource/res/detail_category_middle.gif differ diff --git a/resource/res/detail_category_right.gif b/resource/res/detail_category_right.gif new file mode 100755 index 0000000..8799957 Binary files /dev/null and b/resource/res/detail_category_right.gif differ diff --git a/resource/res/detail_list_bottom.gif b/resource/res/detail_list_bottom.gif new file mode 100755 index 0000000..bbc28c5 Binary files /dev/null and b/resource/res/detail_list_bottom.gif differ diff --git a/resource/res/detail_list_item.gif b/resource/res/detail_list_item.gif new file mode 100644 index 0000000..942b5bb Binary files /dev/null and b/resource/res/detail_list_item.gif differ diff --git a/resource/res/detail_list_middle.gif b/resource/res/detail_list_middle.gif new file mode 100755 index 0000000..fc41c97 Binary files /dev/null and b/resource/res/detail_list_middle.gif differ diff --git a/resource/res/detail_list_top.gif b/resource/res/detail_list_top.gif new file mode 100755 index 0000000..d259c0c Binary files /dev/null and b/resource/res/detail_list_top.gif differ diff --git a/resource/res/dropdown_arrow.gif b/resource/res/dropdown_arrow.gif new file mode 100755 index 0000000..d872b27 Binary files /dev/null and b/resource/res/dropdown_arrow.gif differ diff --git a/resource/res/dropdown_disable.png b/resource/res/dropdown_disable.png new file mode 100644 index 0000000..8a8a2ae Binary files /dev/null and b/resource/res/dropdown_disable.png differ diff --git a/resource/res/dropdown_down.png b/resource/res/dropdown_down.png new file mode 100644 index 0000000..6da26c6 Binary files /dev/null and b/resource/res/dropdown_down.png differ diff --git a/resource/res/dropdown_hover.png b/resource/res/dropdown_hover.png new file mode 100644 index 0000000..f2947ad Binary files /dev/null and b/resource/res/dropdown_hover.png differ diff --git a/resource/res/dropdown_normal.png b/resource/res/dropdown_normal.png new file mode 100644 index 0000000..053693f Binary files /dev/null and b/resource/res/dropdown_normal.png differ diff --git a/resource/res/dropdown_push.png b/resource/res/dropdown_push.png new file mode 100644 index 0000000..c1f4ffb Binary files /dev/null and b/resource/res/dropdown_push.png differ diff --git a/resource/res/dropdown_up.png b/resource/res/dropdown_up.png new file mode 100644 index 0000000..ce162c3 Binary files /dev/null and b/resource/res/dropdown_up.png differ diff --git a/resource/res/emulator_list_image_hover.gif b/resource/res/emulator_list_image_hover.gif new file mode 100755 index 0000000..a4cb87b Binary files /dev/null and b/resource/res/emulator_list_image_hover.gif differ diff --git a/resource/res/emulator_list_image_new_ani.gif b/resource/res/emulator_list_image_new_ani.gif new file mode 100755 index 0000000..565af86 Binary files /dev/null and b/resource/res/emulator_list_image_new_ani.gif differ diff --git a/resource/res/emulator_list_image_nml.gif b/resource/res/emulator_list_image_nml.gif new file mode 100755 index 0000000..1f71913 Binary files /dev/null and b/resource/res/emulator_list_image_nml.gif differ diff --git a/resource/res/emulator_list_selected.gif b/resource/res/emulator_list_selected.gif new file mode 100755 index 0000000..62f0a04 Binary files /dev/null and b/resource/res/emulator_list_selected.gif differ diff --git a/resource/res/info_icon_hover.gif b/resource/res/info_icon_hover.gif new file mode 100755 index 0000000..53a1b14 Binary files /dev/null and b/resource/res/info_icon_hover.gif differ diff --git a/resource/res/info_icon_nml.gif b/resource/res/info_icon_nml.gif new file mode 100755 index 0000000..070bea1 Binary files /dev/null and b/resource/res/info_icon_nml.gif differ diff --git a/resource/res/info_icon_pushed.gif b/resource/res/info_icon_pushed.gif new file mode 100755 index 0000000..ae418c4 Binary files /dev/null and b/resource/res/info_icon_pushed.gif differ diff --git a/resource/res/inputbox_off_left.gif b/resource/res/inputbox_off_left.gif new file mode 100755 index 0000000..50cbeaf Binary files /dev/null and b/resource/res/inputbox_off_left.gif differ diff --git a/resource/res/inputbox_off_middle.gif b/resource/res/inputbox_off_middle.gif new file mode 100755 index 0000000..cad89c9 Binary files /dev/null and b/resource/res/inputbox_off_middle.gif differ diff --git a/resource/res/inputbox_off_right.gif b/resource/res/inputbox_off_right.gif new file mode 100755 index 0000000..1409685 Binary files /dev/null and b/resource/res/inputbox_off_right.gif differ diff --git a/resource/res/inputbox_on_left.gif b/resource/res/inputbox_on_left.gif new file mode 100755 index 0000000..100f12c Binary files /dev/null and b/resource/res/inputbox_on_left.gif differ diff --git a/resource/res/inputbox_on_middle.gif b/resource/res/inputbox_on_middle.gif new file mode 100755 index 0000000..12e4e3f Binary files /dev/null and b/resource/res/inputbox_on_middle.gif differ diff --git a/resource/res/inputbox_on_right.gif b/resource/res/inputbox_on_right.gif new file mode 100755 index 0000000..0da6886 Binary files /dev/null and b/resource/res/inputbox_on_right.gif differ diff --git a/resource/res/modify_cancel_hover.gif b/resource/res/modify_cancel_hover.gif new file mode 100755 index 0000000..c21c16d Binary files /dev/null and b/resource/res/modify_cancel_hover.gif differ diff --git a/resource/res/modify_cancel_nml.gif b/resource/res/modify_cancel_nml.gif new file mode 100755 index 0000000..74ce57b Binary files /dev/null and b/resource/res/modify_cancel_nml.gif differ diff --git a/resource/res/modify_cancel_pushed.gif b/resource/res/modify_cancel_pushed.gif new file mode 100755 index 0000000..64c06d4 Binary files /dev/null and b/resource/res/modify_cancel_pushed.gif differ diff --git a/resource/res/modify_hover.gif b/resource/res/modify_hover.gif new file mode 100755 index 0000000..ff6ea56 Binary files /dev/null and b/resource/res/modify_hover.gif differ diff --git a/resource/res/modify_nml.gif b/resource/res/modify_nml.gif new file mode 100755 index 0000000..e6eaa39 Binary files /dev/null and b/resource/res/modify_nml.gif differ diff --git a/resource/res/modify_pushed.gif b/resource/res/modify_pushed.gif new file mode 100755 index 0000000..1679c68 Binary files /dev/null and b/resource/res/modify_pushed.gif differ diff --git a/resource/res/reset_icon_hover.gif b/resource/res/reset_icon_hover.gif new file mode 100755 index 0000000..d68a5b9 Binary files /dev/null and b/resource/res/reset_icon_hover.gif differ diff --git a/resource/res/reset_icon_nml.gif b/resource/res/reset_icon_nml.gif new file mode 100755 index 0000000..c3c2476 Binary files /dev/null and b/resource/res/reset_icon_nml.gif differ diff --git a/resource/res/reset_icon_pushed.gif b/resource/res/reset_icon_pushed.gif new file mode 100755 index 0000000..b59ed5d Binary files /dev/null and b/resource/res/reset_icon_pushed.gif differ diff --git a/resource/res/tab_selected_left.gif b/resource/res/tab_selected_left.gif new file mode 100755 index 0000000..c9b4d1f Binary files /dev/null and b/resource/res/tab_selected_left.gif differ diff --git a/resource/res/tab_selected_middle.gif b/resource/res/tab_selected_middle.gif new file mode 100755 index 0000000..1d0ab24 Binary files /dev/null and b/resource/res/tab_selected_middle.gif differ diff --git a/resource/res/tab_selected_right.gif b/resource/res/tab_selected_right.gif new file mode 100755 index 0000000..503eb66 Binary files /dev/null and b/resource/res/tab_selected_right.gif differ diff --git a/resource/res/tab_unselected_left.gif b/resource/res/tab_unselected_left.gif new file mode 100755 index 0000000..a48120c Binary files /dev/null and b/resource/res/tab_unselected_left.gif differ diff --git a/resource/res/tab_unselected_left_hover.gif b/resource/res/tab_unselected_left_hover.gif new file mode 100755 index 0000000..fcebfc0 Binary files /dev/null and b/resource/res/tab_unselected_left_hover.gif differ diff --git a/resource/res/tab_unselected_middle.gif b/resource/res/tab_unselected_middle.gif new file mode 100755 index 0000000..5556ede Binary files /dev/null and b/resource/res/tab_unselected_middle.gif differ diff --git a/resource/res/tab_unselected_middle_hover.gif b/resource/res/tab_unselected_middle_hover.gif new file mode 100755 index 0000000..1c739d6 Binary files /dev/null and b/resource/res/tab_unselected_middle_hover.gif differ diff --git a/resource/res/tab_unselected_right.gif b/resource/res/tab_unselected_right.gif new file mode 100755 index 0000000..e5216c3 Binary files /dev/null and b/resource/res/tab_unselected_right.gif differ diff --git a/resource/res/tab_unselected_right_hover.gif b/resource/res/tab_unselected_right_hover.gif new file mode 100755 index 0000000..bd52e99 Binary files /dev/null and b/resource/res/tab_unselected_right_hover.gif differ diff --git a/src/org/tizen/emulator/manager/EmulatorManager.java b/src/org/tizen/emulator/manager/EmulatorManager.java index 56fe688..831f203 100755 --- a/src/org/tizen/emulator/manager/EmulatorManager.java +++ b/src/org/tizen/emulator/manager/EmulatorManager.java @@ -29,6 +29,7 @@ */ package org.tizen.emulator.manager; + import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; @@ -38,40 +39,45 @@ import java.util.logging.Level; 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 platformList = null; + private static ArrayList 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) { @@ -92,36 +98,38 @@ public class EmulatorManager { 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(); } @@ -129,7 +137,7 @@ public class EmulatorManager { return isConsoleMode; } - private void startConsoleProcessor() { + private static void startConsoleProcessor() { Action action = processor.getAction(); if (!action.process()) { exitEmulatorManager(-1); @@ -189,36 +197,37 @@ public class EmulatorManager { } } + 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", @@ -230,14 +239,14 @@ public class EmulatorManager { 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); } @@ -253,20 +262,23 @@ public class EmulatorManager { 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(); @@ -275,18 +287,18 @@ public class EmulatorManager { 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) { @@ -302,11 +314,17 @@ public class EmulatorManager { System.exit(returnValue); } - public ArrayList getPlatformList() { + public static ArrayList getPlatformList() { return platformList; } - public void makePlatformList() { + private static CustomPlatform custom = new CustomPlatform(); + + public static CustomPlatform getCustomPlatform() { + return custom; + } + + static void makePlatformList() { platformList = new ArrayList(); File platforms = new File(FilePath.getInstance().getPlatformsPath()); @@ -320,6 +338,35 @@ public class EmulatorManager { } } } + 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 { diff --git a/src/org/tizen/emulator/manager/console/ActionList.java b/src/org/tizen/emulator/manager/console/ActionList.java index 2eb80e8..3a441ba 100644 --- a/src/org/tizen/emulator/manager/console/ActionList.java +++ b/src/org/tizen/emulator/manager/console/ActionList.java @@ -36,10 +36,10 @@ import java.util.logging.Level; 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; @@ -343,7 +343,7 @@ class Create extends Action { if (!r.getType().isEmpty()) { resolution += (r.getType() + " | "); } else { - resolution += (r.getValue() + " | "); + resolution += (r.getStrValue() + " | "); } } resolution = resolution.substring(0, resolution.length() - 3); @@ -354,7 +354,7 @@ class Create extends Action { "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true)); /** TODO : resolution and skin..***********************************************/ - ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue()); + ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD); String skinType = ""; int i = 1; for (Skin skin : skinList) { @@ -423,7 +423,7 @@ class Modify extends Action { if (!r.getType().isEmpty()) { resolution += (r.getType() + " | "); } else { - resolution += (r.getValue() + " | "); + resolution += (r.getStrValue() + " | "); } } resolution = resolution.substring(0, resolution.length() - 3); @@ -434,7 +434,7 @@ class Modify extends Action { "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true)); /** TODO : resolution and skin..***********************************************/ - ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue()); + ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD); String skinType = ""; int i = 1; for (Skin skin : skinList) { diff --git a/src/org/tizen/emulator/manager/console/CommandLineParser.java b/src/org/tizen/emulator/manager/console/CommandLineParser.java index f5db1d2..ebad834 100644 --- a/src/org/tizen/emulator/manager/console/CommandLineParser.java +++ b/src/org/tizen/emulator/manager/console/CommandLineParser.java @@ -33,8 +33,7 @@ import java.util.logging.Level; 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; @@ -184,13 +183,13 @@ public class CommandLineParser { 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); diff --git a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java index 24d0323..1a90cec 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java @@ -34,19 +34,19 @@ import java.io.IOException; 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 { @@ -94,10 +94,10 @@ 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."); } @@ -116,7 +116,7 @@ public class ConsoleCreateVM { try { Creator.create(prop); - } catch (VMsWorkerException e) { + } catch (VMWorkerException e) { System.out.println("Error: "); System.out.println(e.getMessage()); return false; @@ -137,7 +137,7 @@ public class ConsoleCreateVM { } 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; @@ -145,7 +145,7 @@ public class ConsoleCreateVM { 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; } @@ -170,7 +170,7 @@ public class ConsoleCreateVM { 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; @@ -192,7 +192,7 @@ public class ConsoleCreateVM { 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; } @@ -255,7 +255,7 @@ public class ConsoleCreateVM { RESOLUTION r = checkResolution(resolutionCommand.getCurrentValue()); prop.resolution = r; prop.dpi = r.getDPI(); - ArrayList list = SkinList.getInstance().findSkinList(prop.resolution.getValue()); + ArrayList list = SkinList.getInstance().findSkinList(prop.resolution); if (!list.isEmpty()) { prop.skin = list.get(0); } else { @@ -274,7 +274,7 @@ public class ConsoleCreateVM { ArrayList 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()) { @@ -350,7 +350,7 @@ public class ConsoleCreateVM { if (r.getType().equals(value)) { return r; } - if (r.getValue().equals(value)) { + if (r.getStrValue().equals(value)) { return r; } } @@ -370,18 +370,17 @@ public class ConsoleCreateVM { } 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!"); } diff --git a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java index 6e275ba..78d00e9 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java @@ -31,12 +31,12 @@ package org.tizen.emulator.manager.console; 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 list) { @@ -87,8 +87,8 @@ public class ConsoleModifyVM { } 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; diff --git a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java index f682944..dacf8f3 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java +++ b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java @@ -36,21 +36,21 @@ import java.util.List; 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); } @@ -59,7 +59,7 @@ public class ConsoleProcessor { 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()); @@ -117,7 +117,7 @@ public class ConsoleProcessor { } 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."; @@ -128,19 +128,19 @@ public class ConsoleProcessor { public ArrayList getInfoOfVMList(boolean isDetail) { ArrayList message = new ArrayList(); - 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) { @@ -153,14 +153,14 @@ public class ConsoleProcessor { } public int getCountOfVMList() { - return ((VMsProperty[])vms.getProperties()).length; + return ((VMProperty[])vms.getProperties()).length; } public ArrayList getInfoOfImageList(boolean isDetail) { ArrayList list = new ArrayList(); 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()); } @@ -177,7 +177,7 @@ public class ConsoleProcessor { public int getCountOfImageList() { ArrayList list = new ArrayList(); - for (Platform platform : EmulatorManager.getInstance().getPlatformList()) { + for (Platform platform : EmulatorManager.getPlatformList()) { for (BaseImage image : platform.getImageList()) { list.add(image.getName()); } @@ -187,7 +187,7 @@ public class ConsoleProcessor { } 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); @@ -212,7 +212,7 @@ public class ConsoleProcessor { List 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; } @@ -246,7 +246,7 @@ public class ConsoleProcessor { } 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); @@ -261,7 +261,7 @@ public class ConsoleProcessor { try { prop.getWorker().deleteVM(); - } catch (VMsWorkerException e) { + } catch (VMWorkerException e) { System.out.println("Error: " + e.getMessage()); return false; } @@ -271,7 +271,7 @@ public class ConsoleProcessor { } 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); @@ -286,7 +286,7 @@ public class ConsoleProcessor { try { prop.getWorker().resetVM(); - } catch (VMsWorkerException e) { + } catch (VMWorkerException e) { System.out.println("Error: " + e.getMessage()); return false; } @@ -296,7 +296,7 @@ public class ConsoleProcessor { } 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); @@ -321,7 +321,7 @@ public class ConsoleProcessor { 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; } @@ -331,7 +331,7 @@ public class ConsoleProcessor { } 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); @@ -344,15 +344,14 @@ public class ConsoleProcessor { 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; } diff --git a/src/org/tizen/emulator/manager/da/widgets/button/DACustomButton.java b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButton.java new file mode 100644 index 0000000..1baf80d --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButton.java @@ -0,0 +1,277 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); + } +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonAttribute.java b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonAttribute.java new file mode 100644 index 0000000..30eb0e2 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonAttribute.java @@ -0,0 +1,158 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 images = new ArrayList(); + private List colors = new ArrayList(); + private List fontColors = new ArrayList(); + private List outlineColors = new ArrayList(); + private List outlineInColors = new ArrayList(); + 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); + } +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonClickEventListener.java b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonClickEventListener.java new file mode 100644 index 0000000..962166f --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonClickEventListener.java @@ -0,0 +1,54 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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.Rectangle; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +public abstract class DACustomButtonClickEventListener implements Listener { + + @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 { + return; + } + + handleClickEvent(button); + } + + public abstract void handleClickEvent(DACustomButton button); +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonDefaultRenderer.java b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonDefaultRenderer.java new file mode 100644 index 0000000..40581b9 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonDefaultRenderer.java @@ -0,0 +1,165 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); + } + } +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonRenderer.java b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonRenderer.java new file mode 100644 index 0000000..e7ce757 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/DACustomButtonRenderer.java @@ -0,0 +1,36 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); + +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButton.java b/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButton.java new file mode 100644 index 0000000..fa948e4 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButton.java @@ -0,0 +1,175 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +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.resources.ColorResources; + +public class DACustomToggleButton extends DACustomButton { + + public static final int STATE_TOGGLE = 4; + public static final int STATE_TOGGLE_HOVER = 5; + public static final int STATE_TOGGLE_PUSH = 6; + private boolean toggle = false; + private boolean toggleByButton = false; + + public DACustomToggleButton(Composite parent, Image normal, Image push, + Image hover, Image disable, Image toggle, Image toggleHover) { + super(parent, normal, push, hover, disable); + buttonRenderer = new DACustomToggleButtonRenderer(); + + attr.setImage(STATE_TOGGLE, toggle); + attr.setImage(STATE_TOGGLE_HOVER, toggleHover); + addListeners(); + } + + public DACustomToggleButton(Composite parent, Image normal, Image push, + Image hover, Image disable, Image toggle, Image toggleHover, + Image togglePush) { + this(parent, normal, push, hover, disable, toggle, toggleHover); + buttonRenderer = new DACustomToggleButtonRenderer(); + + attr.setImage(STATE_TOGGLE_PUSH, togglePush); + } + + public DACustomToggleButton(Composite parent, int style) { + super(parent, style); + buttonRenderer = new DACustomToggleButtonRenderer(); + attr.setColor(STATE_TOGGLE, ColorResources.BLUE.getColor()); + attr.setColor(STATE_TOGGLE_HOVER, ColorResources.WHITE.getColor()); + addListeners(); + } + + public DACustomToggleButton(Composite parent, Color normalStart, + Color normalEnd, Color pushStart, Color pushEnd, Color hoverStart, + Color hoverEnd, Color disableStart, Color disableEnd, + Color toggleStart, Color toggleEnd, Color toggleHoverStart, + Color toggleHoverEnd) { + 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.setColor(8, toggleStart); + attr.setColor(9, toggleEnd); + attr.setColor(10, toggleHoverStart); + attr.setColor(11, toggleHoverEnd); + attr.setDrawType(TYPE_GRADATION); + } + + public void setToggled(boolean toggled) { + toggle = toggled; + if (toggled) { + changeButtonState(STATE_TOGGLE); + } else { + changeButtonState(STATE_NORMAL); + } + } + + public void setToggled2(boolean toggled) { + if (!toggleByButton) { + toggle = toggled; + if (toggled) { + changeButtonState(STATE_TOGGLE); + } else { + changeButtonState(STATE_NORMAL); + } + } + } + + public boolean isToggled() { + return toggle; + } + + @Override + public void addListeners() { + if (null != toggleButtonMouseListener) { + this.addListener(SWT.MouseEnter, toggleButtonMouseListener); + this.addListener(SWT.MouseExit, toggleButtonMouseListener); + this.addListener(SWT.MouseDown, toggleButtonMouseListener); + this.addListener(SWT.MouseUp, toggleButtonMouseListener); + } + } + + private Listener toggleButtonMouseListener = new Listener() { + + @Override + public void handleEvent(Event event) { + if (state == STATE_DISABLE) { + return; + } + + if (event.type == SWT.MouseEnter) { + if (toggle) { + changeButtonState(STATE_TOGGLE_HOVER); + } else { + changeButtonState(STATE_HOVER); + } + } + + if (event.type == SWT.MouseExit) { + if (toggle) { + changeButtonState(STATE_TOGGLE); + } else { + changeButtonState(STATE_NORMAL); + } + } + + if (event.type == SWT.MouseDown) { + if (toggle) { + if (null != attr.getImage(STATE_TOGGLE_PUSH)) { + changeButtonState(STATE_TOGGLE_PUSH); + } else { + changeButtonState(STATE_PUSH); + } + } else { + changeButtonState(STATE_PUSH); + } + } + + if (event.type == SWT.MouseUp) { // FIXME + toggle = !toggle; + toggleByButton = !toggleByButton; + if (toggle) { + changeButtonState(STATE_TOGGLE_HOVER); + } else { + changeButtonState(STATE_HOVER); + } + } + } + }; +} diff --git a/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButtonRenderer.java b/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButtonRenderer.java new file mode 100644 index 0000000..61392cc --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/button/toggle/DACustomToggleButtonRenderer.java @@ -0,0 +1,57 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); + } + } + +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomCombo.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomCombo.java new file mode 100644 index 0000000..65d2967 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomCombo.java @@ -0,0 +1,757 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 items; + private List rects = null; + + private List 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 arrowColors = null; + private List 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 getItems() { + if (null == items) { + items = new ArrayList(); + } + return items; + } + + private List getRects() { + if (null == rects) { + rects = new ArrayList(); + } + 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 items = getItems(); + List input = new ArrayList(); + 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 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 imgs = getImages(); + + imgs.add(normal); + imgs.add(hover); + imgs.add(push); + imgs.add(disable); + setImageCombo(true); + } + + protected List getImages() { + if (null == images) { + images = new ArrayList(); + } + 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(); + 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(); + 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(); + 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; + } +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboDefaultRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboDefaultRenderer.java new file mode 100644 index 0000000..bdfd032 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboDefaultRenderer.java @@ -0,0 +1,76 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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) { + + } + +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupDefaultRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupDefaultRenderer.java new file mode 100644 index 0000000..882bc99 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupDefaultRenderer.java @@ -0,0 +1,76 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 rects, + int selection, List 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 rects, int selection, List items) { + // TODO Auto-generated method stub + + } + + @Override + public void drawImage(GC gc, Canvas canvas, Image image, int state, + List rects, int selection, List items) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupRenderer.java new file mode 100644 index 0000000..2556fad --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboPopupRenderer.java @@ -0,0 +1,45 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 rects, int selection, List items); + + public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage, + int state, List rects, int selection, List items); + + public abstract void drawImage(GC gc, Canvas canvas, Image image, + int state, List rects, int selection, List items); +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboRenderer.java new file mode 100644 index 0000000..e0366ad --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboRenderer.java @@ -0,0 +1,37 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboSelectionListener.java b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboSelectionListener.java new file mode 100644 index 0000000..0b70388 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/DACustomComboSelectionListener.java @@ -0,0 +1,46 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboPopupRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboPopupRenderer.java new file mode 100644 index 0000000..dd6a9b7 --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboPopupRenderer.java @@ -0,0 +1,96 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 rects, + int selection, List 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 rects, int selection, List items) { + // TODO Auto-generated method stub + + } + + @Override + public void drawImage(GC gc, Canvas canvas, Image image, int state, + List rects, int selection, List items) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboRenderer.java b/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboRenderer.java new file mode 100644 index 0000000..c3943cd --- /dev/null +++ b/src/org/tizen/emulator/manager/da/widgets/combo/TitleComboRenderer.java @@ -0,0 +1,100 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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()); + } + } + +} diff --git a/src/org/tizen/emulator/manager/image/Skins.java b/src/org/tizen/emulator/manager/image/Skins.java deleted file mode 100644 index d56f3b3..0000000 --- a/src/org/tizen/emulator/manager/image/Skins.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 skins = null; - private String path = null; - - public Skins(File dir) throws IOException { - if (dir.exists()) { - this.path = dir.getAbsolutePath(); - skins = new ArrayList(); - 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 getSkinList() { - return skins; - } -} diff --git a/src/org/tizen/emulator/manager/logging/EMLogger.java b/src/org/tizen/emulator/manager/logging/EMLogger.java index 7f78839..560a2a1 100644 --- a/src/org/tizen/emulator/manager/logging/EMLogger.java +++ b/src/org/tizen/emulator/manager/logging/EMLogger.java @@ -40,7 +40,7 @@ import java.util.logging.Level; 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; diff --git a/src/org/tizen/emulator/manager/image/BaseImage.java b/src/org/tizen/emulator/manager/platform/BaseImage.java similarity index 57% rename from src/org/tizen/emulator/manager/image/BaseImage.java rename to src/org/tizen/emulator/manager/platform/BaseImage.java index fcad6bd..11004a8 100644 --- a/src/org/tizen/emulator/manager/image/BaseImage.java +++ b/src/org/tizen/emulator/manager/platform/BaseImage.java @@ -27,32 +27,40 @@ * */ -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); @@ -60,24 +68,24 @@ public class BaseImage { } 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 + ")"); } @@ -97,7 +105,7 @@ public class BaseImage { 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) { @@ -108,35 +116,40 @@ public class BaseImage { 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; } @@ -146,21 +159,13 @@ public class BaseImage { } 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; } @@ -172,4 +177,22 @@ public class BaseImage { public Platform getPlatform() { return platform; } + + protected ArrayList vmsList = new ArrayList(); + + public ArrayList getVmsList() { + return vmsList; + } + + public void addVMsProperty(VMProperty property) { + vmsList.add(property); + } + + public void removeVMsProerty(VMProperty property) { + vmsList.remove(property); + } + + public void clearVMsList() { + vmsList.clear(); + } } diff --git a/src/org/tizen/emulator/manager/platform/CustomBaseImage.java b/src/org/tizen/emulator/manager/platform/CustomBaseImage.java new file mode 100644 index 0000000..f553377 --- /dev/null +++ b/src/org/tizen/emulator/manager/platform/CustomBaseImage.java @@ -0,0 +1,14 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/platform/CustomPlatform.java b/src/org/tizen/emulator/manager/platform/CustomPlatform.java new file mode 100644 index 0000000..a3d8696 --- /dev/null +++ b/src/org/tizen/emulator/manager/platform/CustomPlatform.java @@ -0,0 +1,65 @@ +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; + } + } + } + +} diff --git a/src/org/tizen/emulator/manager/image/Platform.java b/src/org/tizen/emulator/manager/platform/Platform.java similarity index 84% rename from src/org/tizen/emulator/manager/image/Platform.java rename to src/org/tizen/emulator/manager/platform/Platform.java index d252a1e..573be5d 100644 --- a/src/org/tizen/emulator/manager/image/Platform.java +++ b/src/org/tizen/emulator/manager/platform/Platform.java @@ -1,7 +1,7 @@ /* * 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 @@ -27,20 +27,20 @@ * */ -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; @@ -50,13 +50,17 @@ public class Platform { //private String template_path = null; //private ArrayList templateList = new ArrayList(); - private ArrayList imageList = new ArrayList(); + protected ArrayList imageList = new ArrayList(); + + 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(); @@ -64,6 +68,91 @@ public class Platform { //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 getImageList() { + return imageList; + } + + public String getName() { + return platformName; + } + + public void clearVMs() { + for (BaseImage base : imageList) { + base.clearVMsList(); + } + } + /* private void loadTemplate() { // Common Template Path @@ -142,83 +231,11 @@ public class Platform { } */ - 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 getImageList() { - return imageList; - } - +/* public String getVersion() { return version; } - +*/ // TODO /* public Skins getSkin() { diff --git a/src/org/tizen/emulator/manager/image/Skin.java b/src/org/tizen/emulator/manager/platform/Skin.java similarity index 68% rename from src/org/tizen/emulator/manager/image/Skin.java rename to src/org/tizen/emulator/manager/platform/Skin.java index 559a8d2..3f67351 100644 --- a/src/org/tizen/emulator/manager/image/Skin.java +++ b/src/org/tizen/emulator/manager/platform/Skin.java @@ -27,7 +27,7 @@ * */ -package org.tizen.emulator.manager.image; +package org.tizen.emulator.manager.platform; import java.io.File; import java.io.FileInputStream; @@ -36,41 +36,53 @@ 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.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 + ")"); } @@ -94,22 +106,14 @@ public class Skin { 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; } @@ -118,10 +122,12 @@ public class Skin { this.path = path; } + @ Override public String toString() { return name; } + @ Override public boolean equals(Object obj) { if (!(obj instanceof Skin)) { return false; @@ -134,4 +140,7 @@ public class Skin { return false; } + public SKIN_TYPE getType() { + return type; + } } diff --git a/src/org/tizen/emulator/manager/image/SkinList.java b/src/org/tizen/emulator/manager/platform/SkinList.java similarity index 70% rename from src/org/tizen/emulator/manager/image/SkinList.java rename to src/org/tizen/emulator/manager/platform/SkinList.java index c17d06f..59f9589 100644 --- a/src/org/tizen/emulator/manager/image/SkinList.java +++ b/src/org/tizen/emulator/manager/platform/SkinList.java @@ -27,18 +27,19 @@ * */ -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 skinsList = new ArrayList(); private ArrayList skinList = new ArrayList(); //private Skins defaultSkin = null; @@ -53,31 +54,46 @@ public class SkinList { 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 getSkinsList() { - return skinsList; - } - public ArrayList getSkinList() { return skinList; } @@ -105,15 +121,16 @@ public class SkinList { } private ArrayList returnSkins = new ArrayList(); - public ArrayList findSkinList(String resolution) { + public ArrayList 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; @@ -130,7 +147,7 @@ public class SkinList { 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); } } @@ -147,3 +164,4 @@ public class SkinList { } */ } + diff --git a/src/org/tizen/emulator/manager/resources/ColorResources.java b/src/org/tizen/emulator/manager/resources/ColorResources.java new file mode 100644 index 0000000..44c79e4 --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/ColorResources.java @@ -0,0 +1,195 @@ +/* + * Dynamic Analyzer + * + * Copyright(c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 enum ColorResources { + WHITE("white", null), + BLACK("black", null), + BLUE("blue", null), + RED("red", null), + YELLOW("yellow", null), + PURPLE("purple", null), + + GREEN("green", null), + BROWN("brown", null), + NAVY("navy", null), + DARKVIOLET("darkviolet", null), + MAROON("maroon", null), + TEAL("teal", null), + INDIGO("indigo", null), + DARKGOLDENROD("darkgoldenrod", null), + CHOCOLATE("chocolate", null), + MAGNETA("magneta", null), + + GOLDENROD("goldenrod", null), + TURQUOISE("turquoise", null), + VIOLET("violet", null), + SLATEBLUE("slateblue", null), + ORANGE("orange", null), + YELLOWGREEN("yellowgreen", null), + SKYBLUE("skyblue", null), + ORCHID("orchid", null), + SANDYBROWN("sandybrown", null), + MEDIUMPURPLE("mediumpurple", null), + GRAY1("gray1", null), + GRAY2("gray2", null), + GRAY3("gray3", null), + + // shell window background color + WINDOW_BG_COLOR("window_bg_color", null), + + DIALOG_BG_UPPER("dialg_bg_upper", null), + DIALOG_BG_LOWER("dialg_bg_lower", null), + DIALOG_SUNKEN_1("dialg_sunken_1", null), + DIALOG_SUNKEN_2("dialg_sunken_2", null), + + EDIT_CHART_DIALOG_UPPER("edit_chart_dialog_upper", null), + EDIT_CHART_DIALOG_LOWER("edit_chart_dialog_lower", null), + + VIEW_BORDER("view_border", null), + VIEW_BG_COLOR("view_bg_color", null), + VIEW_TITLE_FONT_COLOR("view_title_font_color", null), + + /** title bar colors **/ + TITLEBAR_TEXT_COLOR("titlebar_text_color", null), + TITLEBAR_BG_COLOR("titlebar_bg", null), + TITLEBAR_START_COLOR("titlebar_start_color", null), + TITLEBAR_END_COLOR("titlebar_end_color", null), + TITLEBAR_BOTTOM_STROKE_1("titlebar_bottom_stroke_1", null), + TITLEBAR_BOTTOM_STROKE_2("titlebar_bottom_stroke_2", null), + + /** Coolbar bg color **/ + COOLBAR_BG_COLOR("coolbar_bg_color", null), + DEFAULT_FONT_COLOR("default_font_color", null), + + /** device and application combo specific colors start **/ + DEVICE_APPLICATION_ENABLE("device_application_enable_font", null), + DEVICE_APPLICATION_DISABLE("device_application_disable", null), + DEVICE_APPLICATION_POPUP_OUTER_1("device_application_popup_outer_1", null), + DEVICE_APPLICATION_POPUP_OUTER_2("device_application_popup_outer_2", null), + DEVICE_APPLICATION_DROPDOWN_TEXT("device_application_enable_font", null), + DEVICE_APPLICATION_ITEM_NORMAL_TOP("device_application_item_normal_top", null), + DEVICE_APPLICATION_ITEM_NORMAL_INNER("device_application_item_normal_inner", null), + DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM("device_application_item_normal_bottom", null), + DEVICE_APPLICATION_ITEM_SELECT_TOP("device_application_item_select_top", new RGB(76, 76, 77)), + DEVICE_APPLICATION_ITEM_SELECT_INNER("device_application_item_select_inner", null), + DEVICE_APPLICATION_ITEM_SELECT_BOTTOM("device_application_item_select_bottom", null), + + /*** combo button color ***/ + DEVICE_APPLICATION_BUTTON_NORMAL_START("device_application_button_normal_start", null), + DEVICE_APPLICATION_BUTTON_NORMAL_END("device_application_button_normal_end", null), + DEVICE_APPLICATION_BUTTON_PUSH_START("device_application_button_push_start", null), + DEVICE_APPLICATION_BUTTON_PUSH_END("device_application_button_push_end", null), + DEVICE_APPLICATION_BUTTON_HOVER_START("device_application_button_hover_start", null), + DEVICE_APPLICATION_BUTTON_HOVER_END("device_application_button_hover_end", null), + DEVICE_APPLICATION_BUTTON_DISABLE_START("device_application_button_disable_start", null), + DEVICE_APPLICATION_BUTTON_DISABLE_END("device_application_button_disable_end", null), + DEVICE_APPLICATION_BUTTON_OUTLINE("device_application_button_outline", null), + + /*** common button colors ***/ + BUTTON_NORMAL_FONT_COLOR("button_normal_font_color", null), + BUTTON_PUSH_FONT_COLOR("button_push_font_color", null), + BUTTON_HOVER_FONT_COLOR("button_hover_font_color", null), + BUTTON_DISABLE_FONT_COLOR("button_disable_font_color", null), + + /** normal view layout colors start **/ + NORMAL_VIEW_LAYOUT_OUTER("normal_view_layout_outer", null), + NORMAL_VIEW_LAYOUT_MIDDLE("normal_view_layout_middle", null), + NORMAL_VIEW_LAYOUT_INNER("normal_view_layout_inner", null), + /** normal view layout colors end **/ + + /** tab widget colors start **/ + TAB_SELECTED_FONT_COLOR("tab_selected_font_color", null), + TAB_NORMAL_FONT_COLOR("tab_normal_font_color", null), + TAB_HOVER_FONT_COLOR("tab_hover_font_color", null), + TAB_PUSH_FONT_COLOR("tab_push_font_color", null), + + TAB_BG_COLOR("tab_bg_color", null), + TAB_CONTENTS_BG_COLOR("tab_contents_bg_color", null), + /** tab widget colors end **/ + + /** list view colors start **/ + LIST_BG_COLOR("list_bg_color", null), + VM_BUTTON_FONT_COLOR("vm_button_font_color", null), + /** list view colors end **/ + + /** detail view colors start **/ + DETAIL_VIEW_PAGE_COLOR("detail_view_page_color", null), + DETAIL_TOP_FONT_COLOR("detail_top_font_color", null), + DETAIL_TITILE_FONT_COLOR("detail_title_font_color", null), + DETAIL_ENABLE_FONT_COLOR("detail_enable_font_color", null), + DETAIL_DISABLE_FONT_COLOR("detail_disable_font_color", null), + DETAIL_CATEGORY_FONT_COLOR("detail_category_font_color", null), + DETAIL_TOP_COLOR("detail_top_color", null), + DETAIL_MIDDLE_COLOR("detail_middle_color", null), + DETAIL_INPUT_BOX_COLOR("detail_input_box_color", null), + /** detail view colors end **/ + + TOOLTIP("tooltip", null), + + /** status bar **/ + STATUS_BAR_COLOR("status_bar_color", null), + STATUS_BAR_FONT_COLOR("status_bar_font_color", null), + + ITEM_BLUE_RIGHT("item_blue_right", null), + ITEM_BLUE_DARK("item_blue_dark", null); + + String name; + Color color; + RGB rgb; + + ColorResources(String name, RGB rgb) { + this.name = name; + this.rgb = rgb; + } + + public Color getColor() { + if (this.color == null) { + if (rgb != null) { + this.color = DAThemeWhite.getInstance().getColor(name, rgb); + } else { + this.color = DAThemeWhite.getInstance().getColor(name); + } + } + return color; + } + + @Override + public String toString() { + return name; + } + + public static void dispose() { + for (ColorResources c : ColorResources.values()) { + c.color = null; + } + // TODO + } +} diff --git a/src/org/tizen/emulator/manager/resources/DATheme.java b/src/org/tizen/emulator/manager/resources/DATheme.java new file mode 100644 index 0000000..4d15cc7 --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/DATheme.java @@ -0,0 +1,152 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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 stringToColor = new HashMap(7); + private Map stringToRGB = new HashMap(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 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; + } +} diff --git a/src/org/tizen/emulator/manager/resources/DAThemeWhite.java b/src/org/tizen/emulator/manager/resources/DAThemeWhite.java new file mode 100644 index 0000000..005752e --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/DAThemeWhite.java @@ -0,0 +1,186 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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); + } + +} diff --git a/src/org/tizen/emulator/manager/tool/FilePath.java b/src/org/tizen/emulator/manager/resources/FilePath.java similarity index 91% rename from src/org/tizen/emulator/manager/tool/FilePath.java rename to src/org/tizen/emulator/manager/resources/FilePath.java index 648ac90..1d1d3ea 100644 --- a/src/org/tizen/emulator/manager/tool/FilePath.java +++ b/src/org/tizen/emulator/manager/resources/FilePath.java @@ -28,7 +28,7 @@ * */ -package org.tizen.emulator.manager.tool; +package org.tizen.emulator.manager.resources; import java.io.BufferedReader; import java.io.File; @@ -38,7 +38,7 @@ import java.io.IOException; 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"; @@ -59,14 +59,14 @@ public class FilePath { 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; @@ -227,19 +227,19 @@ public class FilePath { 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(); diff --git a/src/org/tizen/emulator/manager/resources/FontResources.java b/src/org/tizen/emulator/manager/resources/FontResources.java new file mode 100644 index 0000000..8cde158 --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/FontResources.java @@ -0,0 +1,169 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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.util.HashMap; +import java.util.Map; + +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.tizen.emulator.manager.EmulatorManager; + +public enum FontResources { + // * Toolbal Layout + // Main Title + TITLEBAR("titlebar", resizeDefaultFont(10)), + // Device Name + COMBO("combo", resizeDefaultFont(9)), + // Application Name + DROPDOWN("dropdown", resizeDefaultFont(9)), + // Timer + TIMER("timer", resizeDefaultFont(12)), + + // * Tab Layout + TAB_BUTTON_FONT("tab_button_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)), + + // * List Layout + VM_BUTTON_TITLE_FONT("vm_button_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 8)), + VM_BUTTON_FONT("vm_button_font", resizeDefaultFont(8)), + + // * Detail Layout + DETAIL_TOP_FONT("detail_top_font", setDefaultFontStyleAndSize(SWT.BOLD, 10)), + DETAIL_TITLE_FONT("detail_title_font", resizeDefaultFont(9)), + DETAIL_LABEL_FONT("datail_label_font", resizeDefaultFont(8)), + + // * Nomal button + BUTTON_FONT("button_font", resizeDefaultFont(9)), + + // * Combo button + COMBO_BUTTON_FONT("combo_button_font", resizeDefaultFont(8)), + + // * About Dlg. + ABOUT_TITLE("about_title", resizeDefaultFont(12)), + ABOUT_TEXT("about_text", resizeDefaultFont(9)), + DIALOG_BUTTON_FONT("dialog_button_font", resizeDefaultFont(10)), + + // * Status bar + STATUS_BAR_FONT("status_bar_font", resizeDefaultFont(9)), + + // * not support + TOOLTIP("tooltip", resizeDefaultFont(9)); + + String name; + Font font; + FontData[] data; + FontResources(String name, FontData[] data) { + this.name = name; + this.data = data; + } + + public Font getFont() { + return getFont(name, data); + } + + public Font getFont(String fontName, FontData[] fontData) { + if (this.font == null) { + this.font = FontRegistry.getFont(name, data); + } + return font; + } + + //private static FontRegistry fontRegistry = new FontRegistry(); + private static Font defaultFont = null; + static { + defaultFont = getDADefaultFont(); + } + + public static FontData[] resizeDefaultFont(int size) { + if (defaultFont == null) { + defaultFont = getDADefaultFont(); + } + FontData[] fontData = defaultFont.getFontData(); + for (int i = 0; i < fontData.length; i++) { + fontData[i].setHeight(size); + } + return fontData; + } + + public static FontData[] setDefaultFontStyle(int style) { + if (defaultFont == null) { + defaultFont = getDADefaultFont(); + } + FontData[] fontData = defaultFont.getFontData(); + for (int i = 0; i < fontData.length; i++) { + fontData[i].setStyle(style); + } + return fontData; + } + + public static FontData[] setDefaultFontStyleAndSize(int style, int size) { + if (defaultFont == null) { + defaultFont = getDADefaultFont(); + } + FontData[] fontData = defaultFont.getFontData(); + for (int i = 0; i < fontData.length; i++) { + fontData[i].setStyle(style); + fontData[i].setHeight(size); + } + return fontData; + } + + public static Font getDADefaultFont() { + String fontName = null; + if (EmulatorManager.isLinux()) { + fontName = "Dejavu Sans"; + } else if (EmulatorManager.isWin()) { + fontName = "Verdana"; + } else { + return Display.getCurrent().getSystemFont(); + } + return FontRegistry.getFont( + "ex_font", new FontData[] { new FontData(fontName, 9, SWT.NORMAL) }); + } +} + +class FontRegistry { + private static Map stringToFontData = null; + static { + if (stringToFontData == null) { + stringToFontData = new HashMap(7); + } + } + + public static Font getFont(String fontName, FontData[] fontData) { + if (stringToFontData == null) { + stringToFontData = new HashMap(7); + } + if (!stringToFontData.containsKey(fontName)) { + stringToFontData.put(fontName, fontData); + } + + return new Font(Display.getCurrent(), fontData); + } + +} diff --git a/src/org/tizen/emulator/manager/resources/ImageResources.java b/src/org/tizen/emulator/manager/resources/ImageResources.java new file mode 100644 index 0000000..3180aa1 --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/ImageResources.java @@ -0,0 +1,242 @@ +/* + * Emulator Manager + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * MunKyu Im + * SeokYeon Hwang + * JiHye Kim + * YeongKyoon Lee + * + * 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 map = new HashMap(); + + 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; + } +} diff --git a/src/org/tizen/emulator/manager/resources/PatchImageResources.java b/src/org/tizen/emulator/manager/resources/PatchImageResources.java new file mode 100644 index 0000000..4ccf1e3 --- /dev/null +++ b/src/org/tizen/emulator/manager/resources/PatchImageResources.java @@ -0,0 +1,262 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/tool/StringResource.java b/src/org/tizen/emulator/manager/resources/StringResources.java similarity index 92% rename from src/org/tizen/emulator/manager/tool/StringResource.java rename to src/org/tizen/emulator/manager/resources/StringResources.java index 6e920f1..9994429 100644 --- a/src/org/tizen/emulator/manager/tool/StringResource.java +++ b/src/org/tizen/emulator/manager/resources/StringResources.java @@ -28,15 +28,15 @@ * */ -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"; @@ -58,7 +58,7 @@ public class StringResource { 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"; @@ -78,6 +78,7 @@ public class StringResource { 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"; @@ -98,7 +99,7 @@ public class StringResource { 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"}; diff --git a/src/org/tizen/emulator/manager/tool/About.java b/src/org/tizen/emulator/manager/tool/About.java index 2c7936a..411f620 100644 --- a/src/org/tizen/emulator/manager/tool/About.java +++ b/src/org/tizen/emulator/manager/tool/About.java @@ -39,7 +39,9 @@ import java.util.Properties; 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; @@ -67,24 +69,23 @@ public class About { } 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()); } } @@ -119,8 +120,8 @@ public class About { //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; @@ -131,16 +132,16 @@ public class About { 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", diff --git a/src/org/tizen/emulator/manager/tool/CheckSDCard.java b/src/org/tizen/emulator/manager/tool/CheckSDCard.java index 1175a1f..06571a0 100644 --- a/src/org/tizen/emulator/manager/tool/CheckSDCard.java +++ b/src/org/tizen/emulator/manager/tool/CheckSDCard.java @@ -38,6 +38,8 @@ import java.nio.channels.FileChannel; 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() { @@ -53,13 +55,13 @@ public class 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; } @@ -68,7 +70,8 @@ public class CheckSDCard { 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; } @@ -85,11 +88,11 @@ public class CheckSDCard { 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 { @@ -114,7 +117,7 @@ public class CheckSDCard { 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(); @@ -122,16 +125,17 @@ public class CheckSDCard { 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; } @@ -139,7 +143,7 @@ public class CheckSDCard { 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; } @@ -155,13 +159,13 @@ public class CheckSDCard { 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 { diff --git a/src/org/tizen/emulator/manager/tool/CheckVirtualization.java b/src/org/tizen/emulator/manager/tool/CheckVirtualization.java index 3b3c320..3aebbd5 100644 --- a/src/org/tizen/emulator/manager/tool/CheckVirtualization.java +++ b/src/org/tizen/emulator/manager/tool/CheckVirtualization.java @@ -42,6 +42,8 @@ import org.eclipse.swt.widgets.Display; 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(); @@ -194,7 +196,7 @@ public class 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) { @@ -224,7 +226,7 @@ class CheckDialog { 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() { @@ -234,4 +236,4 @@ class CheckDialog { public void close() { dialog.close(); } -} +} \ No newline at end of file diff --git a/src/org/tizen/emulator/manager/tool/SelectTemplate.java b/src/org/tizen/emulator/manager/tool/SelectTemplate.java index 1697dec..2b4b79f 100644 --- a/src/org/tizen/emulator/manager/tool/SelectTemplate.java +++ b/src/org/tizen/emulator/manager/tool/SelectTemplate.java @@ -40,13 +40,14 @@ import javax.xml.bind.Unmarshaller; 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 templateList; + private VMProperty defaultTemplate = null; + private ArrayList templateList; private static SelectTemplate instance = null; static { @@ -61,7 +62,7 @@ public class SelectTemplate { // Common Template Path File dir = new File(FilePath.getInstance().getTemplatePath()); if (dir.exists()) { - templateList = new ArrayList(); + templateList = new ArrayList(); for (File config : dir.listFiles(new FileFilter() { public boolean accept(File pathname) { if (!pathname.isFile()) { @@ -72,7 +73,7 @@ public class SelectTemplate { return true; } })) { - VMsProperty property = parseXML(config); + VMProperty property = parseXML(config); if (property != null) { templateList.add(property); } @@ -87,7 +88,7 @@ public class SelectTemplate { } } - private VMsProperty parseXML(File configFile) { + private VMProperty parseXML(File configFile) { JAXBContext context = null; JAXBElement element = null; @@ -103,14 +104,14 @@ public class SelectTemplate { 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; } } diff --git a/src/org/tizen/emulator/manager/tool/SelectWorkspace.java b/src/org/tizen/emulator/manager/tool/SelectWorkspace.java index 35fff3b..6e07c02 100644 --- a/src/org/tizen/emulator/manager/tool/SelectWorkspace.java +++ b/src/org/tizen/emulator/manager/tool/SelectWorkspace.java @@ -50,9 +50,10 @@ import org.eclipse.swt.widgets.Display; 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; @@ -69,8 +70,8 @@ public class SelectWorkspace { 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 { @@ -89,9 +90,9 @@ public class SelectWorkspace { } 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); } } @@ -127,9 +128,9 @@ public class SelectWorkspace { 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; @@ -184,7 +185,7 @@ public class SelectWorkspace { } return dialog.getSelectedPath(); } else if (show.equals("false")) { - return prop.getProperty(StringResource.RECENT_VMS_PATH); + return prop.getProperty(StringResources.RECENT_VMS_PATH); } } return null; @@ -192,8 +193,8 @@ public class SelectWorkspace { 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; } @@ -262,18 +263,12 @@ public class SelectWorkspace { } 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) { @@ -295,8 +290,8 @@ public class SelectWorkspace { 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(); } @@ -325,9 +320,9 @@ public class SelectWorkspace { 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; @@ -337,7 +332,7 @@ public class SelectWorkspace { 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); @@ -364,7 +359,7 @@ public class SelectWorkspace { } 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); @@ -406,12 +401,12 @@ public class SelectWorkspace { 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; } } @@ -446,7 +441,7 @@ public class SelectWorkspace { } } - EmulatorVMs.getInstance().setVMsBaseDirectory(workspacePath); + EmulatorVMList.getInstance().setVMsBaseDirectory(workspacePath); //FilePath.setVMSPath(); } diff --git a/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java b/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java deleted file mode 100644 index d39f6b9..0000000 --- a/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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); - } -} diff --git a/src/org/tizen/emulator/manager/ui/MainDialog.java b/src/org/tizen/emulator/manager/ui/MainDialog.java index 2f3e029..22f0c98 100644 --- a/src/org/tizen/emulator/manager/ui/MainDialog.java +++ b/src/org/tizen/emulator/manager/ui/MainDialog.java @@ -31,77 +31,73 @@ 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) { @@ -110,138 +106,64 @@ public class MainDialog { } } + private ArrayList platformItems = new ArrayList(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() { @@ -251,317 +173,45 @@ public class MainDialog { 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); } - */ } diff --git a/src/org/tizen/emulator/manager/ui/MenuHandling.java b/src/org/tizen/emulator/manager/ui/MenuHandling.java index d3d10ee..812784e 100644 --- a/src/org/tizen/emulator/manager/ui/MenuHandling.java +++ b/src/org/tizen/emulator/manager/ui/MenuHandling.java @@ -35,94 +35,75 @@ import java.util.ArrayList; 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 baseImagePaths = new ArrayList(); - 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 ; } @@ -145,22 +126,21 @@ public class MenuHandling { 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(); } diff --git a/src/org/tizen/emulator/manager/ui/ResourceRegistry.java b/src/org/tizen/emulator/manager/ui/ResourceRegistry.java deleted file mode 100644 index 8fb2e8c..0000000 --- a/src/org/tizen/emulator/manager/ui/ResourceRegistry.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 imagesMap = new HashMap(); - - 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 fontsMap = new HashMap(); - - 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() {} -} diff --git a/src/org/tizen/emulator/manager/ui/StatusBar.java b/src/org/tizen/emulator/manager/ui/StatusBar.java new file mode 100644 index 0000000..a1f7b6d --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/StatusBar.java @@ -0,0 +1,62 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/ui/VMButtonFactory.java b/src/org/tizen/emulator/manager/ui/VMButtonFactory.java new file mode 100644 index 0000000..12cdc3f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/VMButtonFactory.java @@ -0,0 +1,86 @@ +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 buttons = new ArrayList (); + 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 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); + } +} diff --git a/src/org/tizen/emulator/manager/ui/VMsDetailView.java b/src/org/tizen/emulator/manager/ui/VMsDetailView.java new file mode 100644 index 0000000..6792a76 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/VMsDetailView.java @@ -0,0 +1,95 @@ +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(); + } +} diff --git a/src/org/tizen/emulator/manager/ui/VMsListView.java b/src/org/tizen/emulator/manager/ui/VMsListView.java new file mode 100644 index 0000000..cd7600a --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/VMsListView.java @@ -0,0 +1,367 @@ +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(); + } +} diff --git a/src/org/tizen/emulator/manager/ui/VMsMainView.java b/src/org/tizen/emulator/manager/ui/VMsMainView.java new file mode 100644 index 0000000..85e4352 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/VMsMainView.java @@ -0,0 +1,294 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailTableView.java b/src/org/tizen/emulator/manager/ui/detail/DetailTableView.java deleted file mode 100644 index d2149c5..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/DetailTableView.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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); - } -} diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java new file mode 100644 index 0000000..d81ad42 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java @@ -0,0 +1,330 @@ +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 list = null; + public static ArrayList getItemList() { + //if (list == null) { + makeList(); + //} + return list; + } + + private static void makeList() { + list = new ArrayList(); + + 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 compList = new ArrayList(); + 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 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(); +} diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewItemChangeListener.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewItemChangeListener.java new file mode 100644 index 0000000..89670c0 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewItemChangeListener.java @@ -0,0 +1,12 @@ +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); +} diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java new file mode 100644 index 0000000..250224e --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java @@ -0,0 +1,116 @@ +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); +} diff --git a/src/org/tizen/emulator/manager/ui/detail/EMComboButtonRenderer.java b/src/org/tizen/emulator/manager/ui/detail/EMComboButtonRenderer.java new file mode 100644 index 0000000..8bea1d6 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/EMComboButtonRenderer.java @@ -0,0 +1,29 @@ +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); + } + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java new file mode 100644 index 0000000..9a3e72e --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java @@ -0,0 +1,44 @@ +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 + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java new file mode 100644 index 0000000..318bb1e --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java @@ -0,0 +1,149 @@ +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 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); + } + } + +} diff --git a/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java new file mode 100644 index 0000000..27e7714 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java @@ -0,0 +1,184 @@ +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 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(); + } + } + // +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TDisplayItem.java b/src/org/tizen/emulator/manager/ui/detail/TDisplayItem.java new file mode 100644 index 0000000..aa190cc --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/TDisplayItem.java @@ -0,0 +1,412 @@ +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 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); + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TFileShareItem.java b/src/org/tizen/emulator/manager/ui/detail/TFileShareItem.java new file mode 100644 index 0000000..001494e --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/TFileShareItem.java @@ -0,0 +1,279 @@ +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(); + } + } + +} diff --git a/src/org/tizen/emulator/manager/ui/detail/THWSupportItem.java b/src/org/tizen/emulator/manager/ui/detail/THWSupportItem.java new file mode 100644 index 0000000..3ba8db6 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/THWSupportItem.java @@ -0,0 +1,304 @@ +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(); + } + } + +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TNameTextItem.java b/src/org/tizen/emulator/manager/ui/detail/TNameTextItem.java new file mode 100644 index 0000000..d48a67d --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/TNameTextItem.java @@ -0,0 +1,363 @@ +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(); + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TRAMItem.java b/src/org/tizen/emulator/manager/ui/detail/TRAMItem.java new file mode 100644 index 0000000..a58abc8 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/TRAMItem.java @@ -0,0 +1,136 @@ +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(); + } + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TTouchPointItem.java b/src/org/tizen/emulator/manager/ui/detail/TTouchPointItem.java new file mode 100644 index 0000000..9762dd5 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/TTouchPointItem.java @@ -0,0 +1,73 @@ +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(); + } +} diff --git a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java b/src/org/tizen/emulator/manager/ui/detail/TableWidget.java deleted file mode 100644 index 0acb833..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java +++ /dev/null @@ -1,1107 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 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 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 diff --git a/src/org/tizen/emulator/manager/ui/detail/TableWidgetChangeListener.java b/src/org/tizen/emulator/manager/ui/detail/TableWidgetChangeListener.java deleted file mode 100644 index d17e437..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/TableWidgetChangeListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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); -} diff --git a/src/org/tizen/emulator/manager/ui/detail/TableWidgetList.java b/src/org/tizen/emulator/manager/ui/detail/TableWidgetList.java deleted file mode 100644 index efea0c1..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/TableWidgetList.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.tizen.emulator.manager.ui.detail; - -import java.util.ArrayList; - -public class TableWidgetList { - ArrayList createList; - ArrayList modifyList; - private static TableWidgetList instance; - static { - instance = new TableWidgetList(); - } - - public static TableWidgetList getInstance() { - assert instance == null; - - return instance; - } - - private TableWidgetList() { - createList = new ArrayList(); - modifyList = new ArrayList(); - makeCreateList(); - makeModifyList(); - } - - public ArrayList getCreateList() { - return createList; - } - - public ArrayList 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; - } -} diff --git a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java b/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java deleted file mode 100644 index d366088..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 itemList; - ArrayList createList; - ArrayList modifyList; - - public VMPropertyView(Table table) { - this.table = table; - makeItemList(); - } - - private void makeItemList() { - itemList = new ArrayList(); - 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 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 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 list = null; - if (isCreateMode) { - list = createList; - } else { - list = modifyList; - } - - for (TableWidget widget : list) { - if (widget.getTitle().equals(name)) { - return widget.getToolTip(); - } - } - - return null; - } -} diff --git a/src/org/tizen/emulator/manager/ui/detail/VMResource.java b/src/org/tizen/emulator/manager/ui/detail/VMResources.java similarity index 91% rename from src/org/tizen/emulator/manager/ui/detail/VMResource.java rename to src/org/tizen/emulator/manager/ui/detail/VMResources.java index eb382ca..44f6993 100644 --- a/src/org/tizen/emulator/manager/ui/detail/VMResource.java +++ b/src/org/tizen/emulator/manager/ui/detail/VMResources.java @@ -34,7 +34,7 @@ import java.util.ArrayList; 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; @@ -95,8 +95,8 @@ class SupportType extends StringArrayResource private SupportType() { - add(0, StringResource.SUPPORTED); - add(1, StringResource.NOT_SUPPORTED); + add(0, StringResources.SUPPORTED); + add(1, StringResources.NOT_SUPPORTED); setDefaultIndex(1); } @@ -132,7 +132,7 @@ class DisplayResolution extends StringArrayResource 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); @@ -148,7 +148,7 @@ class DisplayResolution extends StringArrayResource } } - if (!(EmulatorManager.getInstance().getManagerMode() == ManagerModeType.INHOUSE_MODE)) { + if (!(EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE)) { for (String s : getList()) { if (s.equals(re.toString())) { return; @@ -183,7 +183,7 @@ class DisplayResolution extends StringArrayResource public boolean isMinResoluion(RESOLUTION resolution) { for (RESOLUTION r : minResoultion) { - if (resolution.getValue().equals(r.getValue())) { + if (resolution.getStrValue().equals(r.getStrValue())) { return true; } } @@ -206,7 +206,7 @@ class RamSize extends StringArrayResource if (r == RAM_SIZE.RAM512) { setDefaultIndex(i); } - add(i++, r.toString() + " MB"); + add(i++, r.toString()); } } diff --git a/src/org/tizen/emulator/manager/ui/AboutDialog.java b/src/org/tizen/emulator/manager/ui/dialog/AboutDialog.java similarity index 82% rename from src/org/tizen/emulator/manager/ui/AboutDialog.java rename to src/org/tizen/emulator/manager/ui/dialog/AboutDialog.java index 7fa98c4..314a33a 100644 --- a/src/org/tizen/emulator/manager/ui/AboutDialog.java +++ b/src/org/tizen/emulator/manager/ui/dialog/AboutDialog.java @@ -1,4 +1,4 @@ -package org.tizen.emulator.manager.ui; +package org.tizen.emulator.manager.ui.dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -11,26 +11,27 @@ import org.eclipse.swt.widgets.Link; 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(); } @@ -40,7 +41,7 @@ public class AboutDialog { } 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); @@ -51,13 +52,13 @@ public class AboutDialog { 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); @@ -74,7 +75,7 @@ public class AboutDialog { 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) { @@ -104,21 +105,21 @@ public class AboutDialog { Link workspace = new Link(textComposite, SWT.NONE); workspace.setLayoutData(new GridData(280, SWT.DEFAULT)); workspace.setText("Workspace Path : " + - "" + EmulatorVMs.getInstance().getVMsBaseDirectory() + ""); + "" + EmulatorVMList.getInstance().getVMsBaseDirectory() + ""); 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" + @@ -139,11 +140,10 @@ public class AboutDialog { } } catch (Throwable e) { EMLogger.getLogger().warning("Failed to open developer site" - + StringResource.NEW_LINE + e.getMessage()); + + StringResources.NEW_LINE + e.getMessage()); return; } } - }); } diff --git a/src/org/tizen/emulator/manager/ui/CloneDialog.java b/src/org/tizen/emulator/manager/ui/dialog/CloneDialog.java similarity index 77% rename from src/org/tizen/emulator/manager/ui/CloneDialog.java rename to src/org/tizen/emulator/manager/ui/dialog/CloneDialog.java index 02beb93..ccbf1ca 100644 --- a/src/org/tizen/emulator/manager/ui/CloneDialog.java +++ b/src/org/tizen/emulator/manager/ui/dialog/CloneDialog.java @@ -28,7 +28,7 @@ * */ -package org.tizen.emulator.manager.ui; +package org.tizen.emulator.manager.ui.dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -42,19 +42,15 @@ import org.eclipse.swt.widgets.Composite; 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; @@ -63,15 +59,12 @@ public class CloneDialog { 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)); @@ -83,7 +76,7 @@ public class CloneDialog { 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); @@ -95,13 +88,13 @@ public class CloneDialog { 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(); @@ -128,15 +121,15 @@ public class CloneDialog { 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); } }); @@ -149,37 +142,41 @@ public class CloneDialog { @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 { diff --git a/src/org/tizen/emulator/manager/ui/MessageDialog.java b/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java similarity index 90% rename from src/org/tizen/emulator/manager/ui/MessageDialog.java rename to src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java index b7d2cc3..15d503c 100644 --- a/src/org/tizen/emulator/manager/ui/MessageDialog.java +++ b/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java @@ -28,7 +28,7 @@ * */ -package org.tizen.emulator.manager.ui; +package org.tizen.emulator.manager.ui.dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -41,14 +41,14 @@ import org.eclipse.swt.widgets.Composite; 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) { @@ -109,10 +109,9 @@ public class MessageDialog 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)); } @@ -152,7 +151,7 @@ public class MessageDialog 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) { @@ -169,7 +168,7 @@ public class MessageDialog 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) { diff --git a/src/org/tizen/emulator/manager/ui/SelectWorkspaceDialog.java b/src/org/tizen/emulator/manager/ui/dialog/SelectWorkspaceDialog.java similarity index 90% rename from src/org/tizen/emulator/manager/ui/SelectWorkspaceDialog.java rename to src/org/tizen/emulator/manager/ui/dialog/SelectWorkspaceDialog.java index 0129255..a088929 100644 --- a/src/org/tizen/emulator/manager/ui/SelectWorkspaceDialog.java +++ b/src/org/tizen/emulator/manager/ui/dialog/SelectWorkspaceDialog.java @@ -28,7 +28,7 @@ * */ -package org.tizen.emulator.manager.ui; +package org.tizen.emulator.manager.ui.dialog; import java.util.Properties; @@ -47,8 +47,8 @@ import org.eclipse.swt.widgets.Label; 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; @@ -71,7 +71,7 @@ public class SelectWorkspaceDialog { 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; @@ -102,24 +102,24 @@ public class SelectWorkspaceDialog { 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); @@ -127,12 +127,12 @@ public class SelectWorkspaceDialog { 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)); @@ -157,7 +157,7 @@ public class SelectWorkspaceDialog { @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); diff --git a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabButton.java b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabButton.java new file mode 100644 index 0000000..4a3373f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabButton.java @@ -0,0 +1,130 @@ +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 diff --git a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java new file mode 100644 index 0000000..f68fa05 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java @@ -0,0 +1,227 @@ +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 items + = new ArrayList(5); + private ArrayList buttons + = new ArrayList(5); + + private ArrayList rightButtons + = new ArrayList(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); + } +} diff --git a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabItem.java b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabItem.java new file mode 100644 index 0000000..1b23f26 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabItem.java @@ -0,0 +1,58 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java b/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java deleted file mode 100644 index 5cd39c2..0000000 --- a/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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() + ""; - } -} diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java b/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java deleted file mode 100644 index bc14c72..0000000 --- a/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 - } - -} diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java b/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java deleted file mode 100644 index 1614150..0000000 --- a/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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) {} - }); - } - -} diff --git a/src/org/tizen/emulator/manager/ui/vmstree/RowItem.java b/src/org/tizen/emulator/manager/ui/vmstree/RowItem.java deleted file mode 100644 index d1859f8..0000000 --- a/src/org/tizen/emulator/manager/ui/vmstree/RowItem.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 diff --git a/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java b/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java deleted file mode 100644 index 95a0c1d..0000000 --- a/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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 createItems = new ArrayList(); - private ArrayList typeItems = new ArrayList(); - private Map itemsMap = new HashMap(); - 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 getSelectionItemsList() { - ArrayList list = new ArrayList(); - - 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; - } - } - } -} diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java b/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java new file mode 100644 index 0000000..90ed755 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java @@ -0,0 +1,96 @@ +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(); + } +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageLabelAttribute.java b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelAttribute.java new file mode 100644 index 0000000..be9bc4c --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelAttribute.java @@ -0,0 +1,73 @@ +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 fontColors = new ArrayList(5); + private ArrayList images = new ArrayList(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 diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageLabelDefaultRenderer.java b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelDefaultRenderer.java new file mode 100644 index 0000000..0383619 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelDefaultRenderer.java @@ -0,0 +1,64 @@ +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); + } + } + +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageLabelRenderer.java b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelRenderer.java new file mode 100644 index 0000000..02caf08 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageLabelRenderer.java @@ -0,0 +1,8 @@ +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); +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/ModifyViewCombo.java b/src/org/tizen/emulator/manager/ui/widgets/ModifyViewCombo.java new file mode 100644 index 0000000..cc2a8ed --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ModifyViewCombo.java @@ -0,0 +1,29 @@ +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); + } + } + }; + +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/ModifyViewComboRenderer.java b/src/org/tizen/emulator/manager/ui/widgets/ModifyViewComboRenderer.java new file mode 100644 index 0000000..b920028 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/ModifyViewComboRenderer.java @@ -0,0 +1,31 @@ +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*/); + } +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/VMButton.java b/src/org/tizen/emulator/manager/ui/widgets/VMButton.java new file mode 100644 index 0000000..b8fe8d9 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/VMButton.java @@ -0,0 +1,165 @@ +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 diff --git a/src/org/tizen/emulator/manager/ui/widgets/VMButtonAttribute.java b/src/org/tizen/emulator/manager/ui/widgets/VMButtonAttribute.java new file mode 100644 index 0000000..d09c062 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/VMButtonAttribute.java @@ -0,0 +1,22 @@ +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; + } +} diff --git a/src/org/tizen/emulator/manager/ui/widgets/VMButtonClickEventListener.java b/src/org/tizen/emulator/manager/ui/widgets/VMButtonClickEventListener.java new file mode 100644 index 0000000..d6ed8ff --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/widgets/VMButtonClickEventListener.java @@ -0,0 +1,37 @@ +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 diff --git a/src/org/tizen/emulator/manager/vms/Creator.java b/src/org/tizen/emulator/manager/vms/Creator.java index 4a5e702..ba0ceb8 100644 --- a/src/org/tizen/emulator/manager/vms/Creator.java +++ b/src/org/tizen/emulator/manager/vms/Creator.java @@ -34,30 +34,30 @@ import java.io.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(); @@ -68,7 +68,7 @@ public class Creator { createRam(); createUsability(); } - catch(VMsCreatorException e) { + catch(VMCreatorException e) { deleteFolder(folder); throw e; } @@ -78,7 +78,7 @@ public class Creator { settingProperty(); - EmulatorVMs.getInstance().storeXML(property); + EmulatorVMList.getInstance().storeXML(property); return property; } @@ -103,24 +103,24 @@ public class Creator { 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; } @@ -129,7 +129,7 @@ public class Creator { 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 cmd = new ArrayList(); @@ -142,13 +142,13 @@ public class Creator { 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 cmd = new ArrayList(); @@ -158,11 +158,11 @@ public class Creator { 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 cmd = new ArrayList(); @@ -175,23 +175,23 @@ public class Creator { 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(); @@ -201,7 +201,7 @@ public class Creator { // TODO if (newVM.skin == null && newVM.skinPath == null) { - ArrayList list = SkinList.getInstance().findSkinList(newVM.resolution.getValue()); + ArrayList list = SkinList.getInstance().findSkinList(newVM.resolution); if (!list.isEmpty()) { newVM.skin = list.get(0); } @@ -213,7 +213,7 @@ public class Creator { 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()); @@ -237,7 +237,7 @@ public class Creator { } } else { ec.getBaseInformation().getDiskImage().setType("custom"); - ec.getBaseInformation().setArchitecture(EmulatorVMs.getInstance().CustomArch); + ec.getBaseInformation().setArchitecture(EmulatorVMList.getInstance().CustomArch); } // @@ -299,15 +299,15 @@ public class Creator { } } - 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); } diff --git a/src/org/tizen/emulator/manager/vms/EmulatorVMs.java b/src/org/tizen/emulator/manager/vms/EmulatorVMList.java similarity index 78% rename from src/org/tizen/emulator/manager/vms/EmulatorVMs.java rename to src/org/tizen/emulator/manager/vms/EmulatorVMList.java index c0faf14..9bffb52 100644 --- a/src/org/tizen/emulator/manager/vms/EmulatorVMs.java +++ b/src/org/tizen/emulator/manager/vms/EmulatorVMList.java @@ -35,6 +35,7 @@ import java.io.FileFilter; 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; @@ -45,18 +46,18 @@ import javax.xml.bind.Unmarshaller; 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(); } } @@ -84,11 +85,11 @@ public class EmulatorVMs { } } - List propertiesList = new ArrayList(); + List propertiesList = new ArrayList(); ObjectFactory objectFactory = new ObjectFactory(); - public static EmulatorVMs getInstance() { + public static EmulatorVMList getInstance() { return instance; } @@ -117,14 +118,29 @@ public class EmulatorVMs { loadProperties(); } + class Pair implements Comparable { + 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()) { @@ -132,8 +148,19 @@ public class EmulatorVMs { } 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 @@ -145,7 +172,7 @@ public class EmulatorVMs { } } - private VMsProperty parseXML(File configFile) { + private VMProperty parseXML(File configFile) { JAXBContext context = null; JAXBElement element = null; @@ -161,15 +188,15 @@ public class EmulatorVMs { 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; } @@ -178,11 +205,11 @@ public class EmulatorVMs { 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 { @@ -209,9 +236,9 @@ public class EmulatorVMs { 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); @@ -231,7 +258,7 @@ public class EmulatorVMs { // . // . - return new VMsProperty(configFile, ec); + return new VMProperty(configFile, ec); } // for testing "load properties"... diff --git a/src/org/tizen/emulator/manager/vms/VMCreateHelper.java b/src/org/tizen/emulator/manager/vms/HelperClass.java similarity index 57% rename from src/org/tizen/emulator/manager/vms/VMCreateHelper.java rename to src/org/tizen/emulator/manager/vms/HelperClass.java index a42abf6..5ec5730 100644 --- a/src/org/tizen/emulator/manager/vms/VMCreateHelper.java +++ b/src/org/tizen/emulator/manager/vms/HelperClass.java @@ -32,13 +32,42 @@ package org.tizen.emulator.manager.vms; 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') || @@ -52,14 +81,14 @@ public class VMCreateHelper { 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; @@ -73,7 +102,7 @@ public class VMCreateHelper { 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() { @@ -88,7 +117,7 @@ public class VMCreateHelper { return combo; } - public void addComboItem(Combo combo, Object[] items) { + public static void addComboItem(Combo combo, Object[] items) { if (items == null) { return; } else { @@ -96,7 +125,7 @@ public class VMCreateHelper { } } - 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; } @@ -107,4 +136,18 @@ public class VMCreateHelper { 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; + } } diff --git a/src/org/tizen/emulator/manager/vms/Launcher.java b/src/org/tizen/emulator/manager/vms/Launcher.java index 2896d9a..fe28204 100644 --- a/src/org/tizen/emulator/manager/vms/Launcher.java +++ b/src/org/tizen/emulator/manager/vms/Launcher.java @@ -43,11 +43,12 @@ import org.eclipse.swt.widgets.Display; 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 { @@ -58,7 +59,7 @@ public class Launcher { isConsole = EmulatorManager.isConsoleMode(); } - public List getLaunchCommand(VMsProperty property, String path) throws VMsWorkerException{ + public List getLaunchCommand(VMProperty property, String path) throws VMWorkerException{ String binary; String hwVirtualization = ""; int portNo; @@ -69,7 +70,7 @@ public class Launcher { 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); @@ -77,13 +78,13 @@ public class Launcher { } 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"; @@ -94,10 +95,10 @@ public class Launcher { 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()) { @@ -117,8 +118,6 @@ public class Launcher { } } 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) { @@ -156,7 +155,7 @@ public class Launcher { 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" @@ -175,13 +174,13 @@ public class Launcher { + " 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 cmd2 = new ArrayList(); cmd2.add("net"); @@ -216,7 +215,7 @@ public class Launcher { } } /* 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 cmd2 = new ArrayList(); cmd2.add("net"); @@ -252,7 +251,7 @@ public class Launcher { } } 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"); @@ -320,11 +319,11 @@ public class Launcher { + " 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"); @@ -365,11 +364,11 @@ public class Launcher { return cmd; } - public boolean launch(VMsProperty property) { + public boolean launch(VMProperty property) { List 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()); @@ -446,8 +445,8 @@ public class Launcher { } class MonitoringEmulator extends Thread { - private VMsProperty property; - public MonitoringEmulator(VMsProperty property) { + private VMProperty property; + public MonitoringEmulator(VMProperty property) { this.property = property; this.setDaemon(true); } @@ -455,7 +454,7 @@ class MonitoringEmulator extends Thread { 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; diff --git a/src/org/tizen/emulator/manager/vms/Modifier.java b/src/org/tizen/emulator/manager/vms/Modifier.java index 1dcccb8..9adbae5 100644 --- a/src/org/tizen/emulator/manager/vms/Modifier.java +++ b/src/org/tizen/emulator/manager/vms/Modifier.java @@ -36,7 +36,8 @@ import org.tizen.emulator.manager.vms.xml.TouchType; 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; } @@ -113,7 +114,7 @@ public class Modifier { //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); } } @@ -122,12 +123,12 @@ public class Modifier { 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"); } } } diff --git a/src/org/tizen/emulator/manager/vms/QemuImgProc.java b/src/org/tizen/emulator/manager/vms/QemuImgProc.java index 38f042a..5ae4924 100644 --- a/src/org/tizen/emulator/manager/vms/QemuImgProc.java +++ b/src/org/tizen/emulator/manager/vms/QemuImgProc.java @@ -37,7 +37,7 @@ import java.util.List; 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 cmd = null; diff --git a/src/org/tizen/emulator/manager/vms/RESOLUTION.java b/src/org/tizen/emulator/manager/vms/RESOLUTION.java index 8ada0d4..9bea875 100644 --- a/src/org/tizen/emulator/manager/vms/RESOLUTION.java +++ b/src/org/tizen/emulator/manager/vms/RESOLUTION.java @@ -39,7 +39,7 @@ public enum RESOLUTION { 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(); @@ -50,9 +50,9 @@ public enum 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 + ")"; } } @@ -68,11 +68,15 @@ public enum RESOLUTION { return resolution; } - public String getValue() { + public String getStrValue() { return strValue; } + public String getStrTypeValue() { + return strTypeValue; + } + public String toString() { - return str; + return strTypeValue; } } diff --git a/src/org/tizen/emulator/manager/vms/SKIN_TYPE.java b/src/org/tizen/emulator/manager/vms/SKIN_TYPE.java new file mode 100644 index 0000000..5bee1e6 --- /dev/null +++ b/src/org/tizen/emulator/manager/vms/SKIN_TYPE.java @@ -0,0 +1,9 @@ +package org.tizen.emulator.manager.vms; + +public enum SKIN_TYPE { + GENERAL(0), PHONE_SHAPE(1); + int type; + SKIN_TYPE(int t) { + this.type = t; + } +} diff --git a/src/org/tizen/emulator/manager/vms/VMsCreatorException.java b/src/org/tizen/emulator/manager/vms/VMCreatorException.java similarity index 91% rename from src/org/tizen/emulator/manager/vms/VMsCreatorException.java rename to src/org/tizen/emulator/manager/vms/VMCreatorException.java index dba3965..f027eaf 100644 --- a/src/org/tizen/emulator/manager/vms/VMsCreatorException.java +++ b/src/org/tizen/emulator/manager/vms/VMCreatorException.java @@ -30,10 +30,10 @@ 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); } } diff --git a/src/org/tizen/emulator/manager/vms/VMsProperty.java b/src/org/tizen/emulator/manager/vms/VMProperty.java similarity index 69% rename from src/org/tizen/emulator/manager/vms/VMsProperty.java rename to src/org/tizen/emulator/manager/vms/VMProperty.java index f1e1abb..62a5ba0 100644 --- a/src/org/tizen/emulator/manager/vms/VMsProperty.java +++ b/src/org/tizen/emulator/manager/vms/VMProperty.java @@ -34,28 +34,41 @@ import java.io.File; 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; } @@ -83,6 +96,22 @@ public class VMsProperty { 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; } diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java index 26d86e0..06a4323 100644 --- a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java +++ b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java @@ -34,12 +34,12 @@ import java.io.File; 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; @@ -50,7 +50,7 @@ public class VMPropertyValue implements Cloneable { customSkins = new ArrayList(); } public BaseImage image; - public VMsProperty template; + public VMProperty template; public String vmsName; public String archType; @@ -81,7 +81,7 @@ public class VMPropertyValue implements Cloneable { private VMPropertyValue(){} // for clone - public VMPropertyValue(BaseImage image, VMsProperty template) { + public VMPropertyValue(BaseImage image, VMProperty template) { this.image = image; this.template = template; @@ -94,14 +94,14 @@ public class VMPropertyValue implements Cloneable { 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; @@ -212,7 +212,7 @@ public class VMPropertyValue implements Cloneable { return true; } - private void settingConfigure(VMsProperty property) { + private void settingConfigure(VMProperty property) { if (property == null) { settingConfigure(); return; @@ -267,7 +267,7 @@ public class VMPropertyValue implements Cloneable { (fileSharePath.lastIndexOf(File.separator) + 1, fileSharePath.length()); } else { fileSharePath = ""; - fileSharePathName = StringResource.None; + fileSharePathName = StringResources.None; } ramSize = property.getConfiguration().getDevice().getRAM().getSize().getValue(); @@ -291,7 +291,7 @@ public class VMPropertyValue implements Cloneable { resolution = RESOLUTION.HD; dpi = RESOLUTION.HD.getDPI(); // this value be related to resolution - ArrayList list = SkinList.getInstance().findSkinList(resolution.getValue()); + ArrayList list = SkinList.getInstance().findSkinList(resolution); if (!list.isEmpty()) { skin = list.get(0); } @@ -309,7 +309,7 @@ public class VMPropertyValue implements Cloneable { isFileShareSupport = false; fileSharePath = ""; - fileSharePathName = StringResource.None; + fileSharePathName = StringResources.None; isHWVirtualization = CheckVirtualization.getInstance().isSupportVirtualization(); isGLAcceleration = CheckVirtualization.getInstance().isSupportGPU(); @@ -319,12 +319,12 @@ public class VMPropertyValue implements Cloneable { 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); } diff --git a/src/org/tizen/emulator/manager/vms/VMsWorker.java b/src/org/tizen/emulator/manager/vms/VMWorker.java similarity index 77% rename from src/org/tizen/emulator/manager/vms/VMsWorker.java rename to src/org/tizen/emulator/manager/vms/VMWorker.java index 6d831ac..cd98ebf 100644 --- a/src/org/tizen/emulator/manager/vms/VMsWorker.java +++ b/src/org/tizen/emulator/manager/vms/VMWorker.java @@ -43,57 +43,52 @@ import org.eclipse.swt.widgets.Display; 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"; @@ -121,7 +116,7 @@ public class VMsWorker { 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 { @@ -130,8 +125,8 @@ public class VMsWorker { 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)"); } @@ -144,8 +139,8 @@ public class VMsWorker { 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)"); } @@ -154,7 +149,8 @@ public class VMsWorker { /* 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)"); } @@ -185,11 +181,11 @@ public class VMsWorker { } } - 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()) { @@ -209,13 +205,13 @@ public class VMsWorker { } } - 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); @@ -225,21 +221,21 @@ public class VMsWorker { 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); @@ -248,17 +244,17 @@ public class VMsWorker { } 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 @@ -283,21 +279,17 @@ public class VMsWorker { 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 cmd = new ArrayList(); - 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"); @@ -305,7 +297,7 @@ public class VMsWorker { cmd.add("/FO"); cmd.add("CSV"); } - else if (isMac > -1){ + else if (EmulatorManager.isMac()){ cmd.add("/bin/ps"); cmd.add("-ef"); } @@ -319,7 +311,7 @@ public class VMsWorker { 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)) { @@ -329,7 +321,7 @@ public class VMsWorker { } } } - else if(isWindows > -1) { + else if(EmulatorManager.isWin()) { while ((line = stdOut.readLine()) != null) { String[] titleName = line.split(","); // "split[split.length - 1]" is window title. @@ -340,7 +332,7 @@ public class VMsWorker { } } } - 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)) { @@ -352,16 +344,15 @@ public class VMsWorker { } 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; diff --git a/src/org/tizen/emulator/manager/vms/VMsWorkerException.java b/src/org/tizen/emulator/manager/vms/VMWorkerException.java similarity index 92% rename from src/org/tizen/emulator/manager/vms/VMsWorkerException.java rename to src/org/tizen/emulator/manager/vms/VMWorkerException.java index 6e550df..d2d0751 100644 --- a/src/org/tizen/emulator/manager/vms/VMsWorkerException.java +++ b/src/org/tizen/emulator/manager/vms/VMWorkerException.java @@ -30,10 +30,10 @@ 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); } }