- When create or modify VM, added validation of each option value.
Invalid option is indicated with different color and message in status-bar.
Change-Id: I5979dcceb1f33014ab47933c6b46b0904efc8dd3
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
GOLDENROD("goldenrod", new RGB(212, 150, 57)),
TURQUOISE("turquoise", new RGB(72, 194, 168)),
ORANGE("orange", new RGB(236, 107, 47)),
+ ORANGERED("orangeRed", new RGB(255,69,0)),
YELLOWGREEN("yellowgreen", new RGB(129, 172, 50)),
SKYBLUE("skyblue", new RGB(72, 185, 221)),
ORCHID("orchid", new RGB(175, 49, 200)),
/** status bar **/
STATUS_BAR_COLOR("status_bar_color", new RGB(106, 119, 125)),
- STATUS_BAR_FONT_COLOR("status_bar_font_color", new RGB(255, 255, 255));
+ STATUS_BAR_FONT_COLOR("status_bar_font_color", new RGB(255, 255, 255)),
+
+ /** warning/error color **/
+ WARNING_FONT("warningFont", new RGB(243, 134, 29)),
+ ERROR_FONT("errorFont", new RGB(226, 30, 40)),
+ CATEGORY_WARNING_BG("categoryWarningBg", new RGB(240, 178, 73)),
+ CATEGORY_ERROR_BG("categoryErrorBg", new RGB(217, 83, 79)),
+ STATUS_WARNING_FONT("statusWarningFont", new RGB(231, 119, 37));
String name;
Color color;
-/*\r
- * Emulator Manager\r
- *\r
- * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact:\r
- * JiHye Kim <jihye1128.kim@samsung.com>\r
- * SeokYeon Hwang <syeon.hwang@samsung.com>\r
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
- *\r
- * Contributors:\r
- * - S-Core Co., Ltd\r
- *\r
- */\r
-\r
-package org.tizen.emulator.manager.resources;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.tizen.emulator.manager.EmulatorManager;\r
-\r
-public enum FontResources {\r
- // * Toolbal Layout\r
- // Main Title\r
- TITLEBAR("titlebar", resizeDefaultFont(10)),\r
- // Device Name\r
- COMBO("combo", resizeDefaultFont(9)),\r
- // Application Name\r
- DROPDOWN("dropdown", resizeDefaultFont(9)),\r
- // Timer\r
- TIMER("timer", resizeDefaultFont(12)),\r
-\r
- // * Tab Layout\r
- TAB_BUTTON_FONT("tab_button_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)),\r
-\r
- // * List Layout\r
- VM_BUTTON_TITLE_FONT("vm_button_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 8)),\r
- VM_BUTTON_FONT("vm_button_font", resizeDefaultFont(8)),\r
-\r
- // * Detail Layout\r
- DETAIL_TOP_FONT("detail_top_font", setDefaultFontStyleAndSize(SWT.BOLD, 10)),\r
- DETAIL_TITLE_FONT("detail_title_font", resizeDefaultFont(9)),\r
- DETAIL_LABEL_FONT("datail_label_font", resizeDefaultFont(8)),\r
-\r
- // * Nomal button\r
- BUTTON_FONT("button_font", resizeDefaultFont(9)),\r
-\r
- // * Combo button\r
- COMBO_BUTTON_FONT("combo_button_font", resizeDefaultFont(8)),\r
-\r
- // * About Dlg.\r
- ABOUT_TITLE("about_title", resizeDefaultFont(12)),\r
- ABOUT_TEXT("about_text", resizeDefaultFont(9)),\r
- DIALOG_BUTTON_FONT("dialog_button_font", resizeDefaultFont(10)),\r
-\r
- // * Status bar\r
- STATUS_BAR_FONT("status_bar_font", resizeDefaultFont(9)),\r
-\r
- // * Radio button\r
- RADIO_BUTTON_FONT("radio_button_font", resizeDefaultFont(8)),\r
-\r
- // * Tree view\r
- TREE_CREATE_FONT("tree_creaet_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)),\r
- TREE_HEADER_FONT("tree_header_font", resizeDefaultFont(9)),\r
- TREE_ITEM_FONT("tree_item_font", resizeDefaultFont(8)),\r
-\r
- // * not support\r
- TOOLTIP("tooltip", resizeDefaultFont(9));\r
-\r
- String name;\r
- Font font;\r
- FontData[] data;\r
- FontResources(String name, FontData[] data) {\r
- this.name = name;\r
- this.data = data;\r
- }\r
-\r
- public Font getFont() {\r
- return getFont(name, data);\r
- }\r
-\r
- public Font getFont(String fontName, FontData[] fontData) {\r
- if (this.font == null) {\r
- this.font = new Font(Display.getCurrent(), fontData);\r
- }\r
- return font;\r
- }\r
-\r
- //private static FontRegistry fontRegistry = new FontRegistry();\r
- private static Font defaultFont = null;\r
- static {\r
- defaultFont = getDADefaultFont();\r
- }\r
-\r
- public static FontData[] resizeDefaultFont(int size) {\r
- if (defaultFont == null) {\r
- defaultFont = getDADefaultFont();\r
- }\r
-\r
- if (EmulatorManager.isMac()) {\r
- size = size + 2;\r
- }\r
-\r
- FontData[] fontData = defaultFont.getFontData();\r
- for (int i = 0; i < fontData.length; i++) {\r
- fontData[i].setHeight(size);\r
- }\r
- return fontData;\r
- }\r
-\r
- public static FontData[] setDefaultFontStyle(int style) {\r
- if (defaultFont == null) {\r
- defaultFont = getDADefaultFont();\r
- }\r
- FontData[] fontData = defaultFont.getFontData();\r
- for (int i = 0; i < fontData.length; i++) {\r
- fontData[i].setStyle(style);\r
- }\r
- return fontData;\r
- }\r
-\r
- public static FontData[] setDefaultFontStyleAndSize(int style, int size) {\r
- if (defaultFont == null) {\r
- defaultFont = getDADefaultFont();\r
- }\r
-\r
- if (EmulatorManager.isMac()) {\r
- size = size + 2;\r
- }\r
-\r
- FontData[] fontData = defaultFont.getFontData();\r
- for (int i = 0; i < fontData.length; i++) {\r
- fontData[i].setStyle(style);\r
- fontData[i].setHeight(size);\r
- }\r
- return fontData;\r
- }\r
-\r
- public static Font getDADefaultFont() {\r
- if (defaultFont == null) {\r
- String fontName = null;\r
- if (EmulatorManager.isLinux()) {\r
- fontName = "Dejavu Sans";\r
- } else if (EmulatorManager.isWin()) {\r
- fontName = "Verdana";\r
- } else if (EmulatorManager.isMac()) {\r
- fontName = "Lucida Grande";\r
- } else {\r
- defaultFont = Display.getCurrent().getSystemFont();\r
- return defaultFont;\r
- }\r
- defaultFont = EmulatorManager.isMac()\r
- ? new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 11, SWT.NORMAL) })\r
- : new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 9, SWT.NORMAL) });\r
- }\r
-\r
- return defaultFont;\r
- }\r
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.resources;
+
+import 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_TITLE_FONT_BOLD("detail_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 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)),
+ STATUS_BAR_SUB_FONT("status_bar_sub_font", resizeDefaultFont(8)),
+
+ // * Radio button
+ RADIO_BUTTON_FONT("radio_button_font", resizeDefaultFont(8)),
+
+ // * Tree view
+ TREE_CREATE_FONT("tree_creaet_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)),
+ TREE_HEADER_FONT("tree_header_font", resizeDefaultFont(9)),
+ TREE_ITEM_FONT("tree_item_font", resizeDefaultFont(8)),
+
+ // * 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 = new Font(Display.getCurrent(), fontData);
+ }
+ 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();
+ }
+
+ if (EmulatorManager.isMac()) {
+ size = size + 2;
+ }
+
+ 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();
+ }
+
+ if (EmulatorManager.isMac()) {
+ size = size + 2;
+ }
+
+ 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() {
+ if (defaultFont == null) {
+ String fontName = null;
+ if (EmulatorManager.isLinux()) {
+ fontName = "Dejavu Sans";
+ } else if (EmulatorManager.isWin()) {
+ fontName = "Verdana";
+ } else if (EmulatorManager.isMac()) {
+ fontName = "Lucida Grande";
+ } else {
+ defaultFont = Display.getCurrent().getSystemFont();
+ return defaultFont;
+ }
+ defaultFont = EmulatorManager.isMac()
+ ? new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 11, SWT.NORMAL) })
+ : new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 9, SWT.NORMAL) });
+ }
+
+ return defaultFont;
+ }
}
\ No newline at end of file
private static boolean isGallium = false; // for ubuntu OS
private static boolean isNonUG = false; // non-UG mode
-
private CheckVirtualization() {
// singleton class
}
msgList.clear();
}
}
+
}
static private final String IPV4_REGEX = "(([0-1]?[0-9]{1,2}\\.)|(2[0-4][0-9]\\.)|(25[0-5]\\.)){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))";
static private Pattern IPV4_PATTERN = Pattern.compile(IPV4_REGEX);
- public static boolean checkIPString(boolean widgetEnable, String ip,
+ public static String checkIPString(boolean widgetEnable, String ip,
String title) {
- boolean result = true;
String errMsg = "";
if (widgetEnable == true) {
if (ip == null || ip.isEmpty()) {
errMsg = title + " cannot be empty!";
- result = false;
} else {
- result = IPV4_PATTERN.matcher(ip).matches();
- if (result == false) {
+ boolean isMatch = IPV4_PATTERN.matcher(ip).matches();
+ if (!isMatch) {
errMsg = title + " is invalid!";
}
}
}
- HelperClass.setStatusBar(errMsg);
- return result;
+ return errMsg;
}
public static boolean checkIP(String ip) {
private static final String ICON_FILE_NAME = "res/em.ico";
public static final int DEFALUT_WIDTH = 840;
- public static final int DEFAULT_HEIGHT = 482;
+ public static final int DEFAULT_HEIGHT = 493;
public static final int MIN_HEIGHT = 380;
public static final int MIN_WIDTH = 620;
public static int WIDTH = DEFALUT_WIDTH;
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.detail.item.ItemState;
public class StatusBar {
private Composite bar = null;
private boolean isError = false;
private String message;
+
public void info(String msg) {
if (isError) {
return;
isError = true;
message = msg;
msgLabel.setText(message);
-
+
}
public void reset() {
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * sangho Park <sangho1204.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+
+public class UIHelper {
+
+ public static String shortenText(GC gc, String text, Rectangle clientRect) {
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ int x = (clientRect.width - p.x) / 2;
+
+ if (x >= 0) {
+ return text;
+
+ } else { // shorten text and add "..."
+ String subStr = null;
+ String ellipsis = "...";
+ int fixedWidth;
+ for(int i = text.length() ; i > 0 ; i--){
+ subStr = text.substring(0, i);
+ subStr += ellipsis;
+ fixedWidth = gc.textExtent(subStr, SWT.DRAW_MNEMONIC).x;
+ if(fixedWidth < clientRect.width){
+ break;
+ }
+ }
+ return subStr;
+ }
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * sangho Park <sangho1204.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+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.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
+
+public class VMStatusBar {
+
+ private Composite comp;
+ private Canvas msgLabel;
+ private Image warningIcon;
+ private Image errorIcon;
+ private ItemState itemState = new ItemState(ItemState.NORMAL);
+
+ public VMStatusBar(Composite parent, int style) {
+ comp = new Composite(parent, style);
+ comp.setLayout(new FormLayout());
+ comp.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+ }
+
+ public void init(Object layoutData) {
+ comp.setLayoutData(layoutData);
+
+ msgLabel = new Canvas(comp, SWT.NONE);
+ msgLabel.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+ msgLabel.setFont(FontResources.STATUS_BAR_SUB_FONT.getFont());
+ FormData data = new FormData();
+ data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
+ msgLabel.setLayoutData(data);
+
+ addCompositeListener();
+ addPaintListener();
+
+ }
+
+ public void addPaintListener() {
+ msgLabel.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ GC gc = e.gc;
+
+ String text = itemState.getDisplayMsg();
+ ((Canvas)e.widget).setToolTipText(text);
+ text = UIHelper.shortenText(gc, text, ((Canvas)e.widget).getClientArea());
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.setFont(msgLabel.getFont());
+
+ // Clear status bar.
+ gc.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
+ gc.fillRectangle(rect);
+
+ // Draw text
+ int x = 0, y = 0;
+ y = (e.height - p.y) / 2;
+ gc.setForeground(itemState.getStatusFontColor());
+ gc.drawText(text, x+5, y, true);
+ }
+ });
+ }
+
+ public void updateStatus(ItemState state) {
+ itemState = state;
+ msgLabel.redraw();
+ }
+
+ private void addCompositeListener() {
+ comp.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent arg0) {
+ if (warningIcon != null) {
+ warningIcon.dispose();
+ }
+ if (errorIcon != null) {
+ errorIcon.dispose();
+ }
+ }
+ });
+ }
+}
private Composite parent = null;
private Composite mainView = null;
private int WIDTH = 328;
- private int HEIGHT = 430;
+ private int HEIGHT = 350;
private DetailViewPage emptyView = null;
private DetailViewPage detailView = null;
protected VMsDetailView parent = null;
protected Composite view = null;
protected Composite itemListTop = null;
- private Composite itemListBack = null;
+ protected Composite itemListBack = null;
protected CustomScrolledComposite scrolledList= null;
protected Composite itemList = null;
protected Composite buttonComp = null;
protected int itemListCount = 0;
public int checkItemCountwithSize() {
- int h = parent.getSize().y - 30 - 36 - 60;
+ int h = parent.getSize().y - 30 - 36 - 60 - (PModifyViewPage.statusBarHeight - 2);
int middleH = ImageResources.DETAIL_LIST_MIDDLE.getImage().getImageData().height;
int bottomH = ImageResources.DETAIL_LIST_BOTTOM.getImage().getImageData().height;
// draw button
settingButtonStatus(property);
+
}
private void settingButtonStatus(VMProperty property) {
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.VMStatusBar;
import org.tizen.emulator.manager.ui.VMsDetailView;
import org.tizen.emulator.manager.ui.VMsMainView;
import org.tizen.emulator.manager.ui.detail.item.DetailViewItem;
import org.tizen.emulator.manager.ui.detail.item.IItemListFactory;
import org.tizen.emulator.manager.ui.detail.item.IModifyViewItem;
import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
+import org.tizen.emulator.manager.ui.detail.item.ItemValidator;
import org.tizen.emulator.manager.ui.dialog.MessageDialog;
import org.tizen.emulator.manager.ui.widgets.ImageButton;
import org.tizen.emulator.manager.vms.VMProperty;
super(parent, style);
}
+ private static VMStatusBar statusBar;
+ public static VMStatusBar getStatusBar() {
+ return statusBar;
+ }
+ private ItemValidator currentStatusBarItem;
+ public static final int statusBarHeight = 14;
+
private ImageButton cancelButton;
private boolean isCreateMode = false;
cancelButton.setToolTipText("cancel modification of vm");
topButton = cancelButton;
+
makeButton();
makeModifyView();
+ statusBar = new VMStatusBar(view, SWT.NONE);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.right = new FormAttachment(100, -13);
+ data.bottom = new FormAttachment(buttonComp, -3);
+ data.height = statusBarHeight;
+ statusBar.init(data);
}
private static int CONFIRM_BUTTON_WIDTH = 303;
}
@Override
- public void changeConfirmButton() {
- boolean isAvailable = true;
- for (IModifyViewItem item : topViewList.itemList) {
- if (!item.checkValue()) { // Check if confirm button available
- isAvailable = false;
- break;
- }
- }
- confirmButton.setEnabled(isAvailable);
+ public void changeCreateConfirmButton() {
+ boolean isConfirmAvailable = checkItemList();
+ // Update confirm button state.
+ confirmButton.setEnabled(isConfirmAvailable);
}
@Override
- public void changeConfirmButton(DetailViewItem viewItem) {
-
- // Check item value is valid.
- boolean isAvailable = true;
- for (IModifyViewItem item : topViewList.itemList) {
- if (!item.checkValue()) {
- isAvailable = false;
- break;
- }
- }
-
+ public void changeModifyConfirmButton(DetailViewItem viewItem) {
+ boolean isConfirmAvailable = checkItemList();
viewItem.setValue(newValue);
- if (isAvailable) { // If valid, check if value is changed.
+ if (isConfirmAvailable) { // If valid, check if value is changed.
if (!oldValue.equals(newValue)) {
confirmButton.setEnabled(true);
} else {
}
+ // Set item 's normal, warning, error state and
+ // return false if more than one error found.
+ private boolean checkItemList() {
+ boolean isValid = true;
+ DetailViewItem errorItem = null;
+
+ // Check Item state
+ for (IModifyViewItem item : topViewList.itemList) {
+ if (item instanceof DetailViewItem) {
+ DetailViewItem viewItem = (DetailViewItem)item;
+ viewItem.checkValue();
+ viewItem.updateItemUI(); // normal / warning / error
+
+ if (viewItem.getItemState().isError()) {
+ if (errorItem == null || !errorItem.getItemState().isError()) {
+ errorItem = viewItem;
+ }
+
+ } else if (viewItem.getItemState().isWarning()) {
+ if (errorItem == null || errorItem.getItemState().isNormal()) {
+ errorItem = viewItem;
+ }
+ }
+
+ if (viewItem.getItemState().isError()) {
+ isValid = false;
+ }
+ }
+ }
+
+ // Update status bar
+ if (errorItem == null) {
+ statusBar.updateStatus(ItemState.CreateNormalState());
+
+ } else {
+ statusBar.updateStatus(errorItem.getItemState());
+ }
+
+ // Mark current status bar item.
+ if (currentStatusBarItem != errorItem) {
+ changeStatusBarItem(errorItem);
+ }
+
+ return isValid;
+ }
+
+ private void changeStatusBarItem(DetailViewItem item) {
+ if (item == null) {
+ currentStatusBarItem.setItemMarked(false);
+
+ } else {
+ item.setItemMarked(true);
+ if (currentStatusBarItem != null) {
+ currentStatusBarItem.setItemMarked(false);
+ }
+ }
+ currentStatusBarItem = item;
+ }
+
@Override
public void ChangeState(ItemChangeState state) {
if (state == ItemChangeState.CREATE) {
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.vms.xml.template.Item;
public abstract class AdvancedViewItem extends DetailViewItem {
protected LineLabelViewItem lineLabelViewItem;
- public AdvancedViewItem(LineLabelViewItem lineLabelViewItem) {
+ public AdvancedViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
+ super(template);
this.lineLabelViewItem = lineLabelViewItem;
}
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.tizen.emulator.manager.resources.FontResources;
import org.tizen.emulator.manager.resources.ImageResources;
import org.tizen.emulator.manager.ui.widgets.ImageButton;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.xml.template.Item;
-public abstract class DetailViewItem implements IInfoViewItem, IModifyViewItem {
+public abstract class DetailViewItem extends ViewItem {
protected Composite comp = null;
protected DetailViewItem upperItem = null;
protected DetailViewItem downItem = null;
protected Canvas titleLabel;
- protected String title;
private boolean isCreateMode;
protected boolean isMinMode = false;
private boolean isViewMode;
+ protected Canvas stateLabel;
+
protected ImageButton arrowButton;
protected int count;
protected DetailViewItem item;
public DetailViewItem() {
+
+ }
+
+ public DetailViewItem(Item template) {
+ super(template.getName(), template.getTitle());
this.item = this;
}
return upperItem;
}
- @Override
public void initItem(Composite parent, IInfoViewItem upperItem) {
initItem(parent, (DetailViewItem) upperItem);
+ initStateLabel();
}
- @Override
public void initItem(Composite parent, IModifyViewItem upperItem) {
initItem(parent, (DetailViewItem) upperItem);
+ initStateLabel();
}
+ public abstract void init();
+
protected ArrayList<Composite> compList = new ArrayList<Composite>();
protected static int ITEM_HEIGHT = 20;
protected static int ITEM_WIDTH = 20;
compList.add(comp);
up = comp;
+
}
+ addCompListener();
//comp = new Composite(parent, SWT.NONE);
/*
initTitle(true);
}
+ private void addCompListener() {
+ compList.get(0).addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ drawComp(e);
+ }
+
+ });
+ }
+
+ public void drawComp(PaintEvent e) {
+ Rectangle rect = ((Composite)e.widget).getClientArea();
+ if (!itemState.isNormal()) {
+ // fillBackground(e.gc, rect.x+1, rect.y-1, rect.width-2, rect.height);
+ }
+ }
+
private void setDownItem(DetailViewItem down) {
this.downItem = down;
}
}
});
+
}
titleLabel = new Canvas(compList.get(0), SWT.NONE);
}
+ protected void initStateLabel() {
+ stateLabel = new Canvas(compList.get(0), SWT.NONE);
+ FormData data = new FormData();
+ data.left = new FormAttachment(titleLabel, 3); // 15
+ data.top = new FormAttachment(titleLabel, 0, SWT.CENTER); // 4
+ data.height = TITLE_HEIGHT - 5; // 20 - 5
+ data.width = TITLE_HEIGHT - 10;
+ stateLabel.setLayoutData(data);
+ stateLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+ stateLabel.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ Canvas canvas = (Canvas)e.widget;
+
+ if (!itemState.isNormal()) {
+
+ Rectangle rect = canvas.getClientArea();
+ // fillBackground(gc, rect.x, rect.y, rect.width, rect.height);
+
+ // Draw mark next to title label.
+ // "*" : Item which is showed in status bar.
+ // "" : Items that aren't showed in status bar.
+ String mark;
+ Point p;
+ gc.setForeground(itemState.getFontColor());
+ canvas.setToolTipText(itemState.getDisplayMsg());
+ int x = 0, y = 0;
+ if (itemState.isTitleMarked()) {
+ gc.setFont(titleLabel.getFont()); // font size 9
+ mark = "*";
+ p = gc.textExtent(mark, SWT.DRAW_MNEMONIC);
+
+ } else {
+ gc.setFont(FontResources.STATUS_BAR_SUB_FONT.getFont()); // font size 8
+ mark = "";
+ p = gc.textExtent(mark, SWT.DRAW_MNEMONIC);
+ }
+ y = (e.height - p.y) / 2;
+ gc.drawText(mark, x, y, true);
+ }
+ }
+ });
+ }
+
protected void changeArrowState() {
if (arrowButton == null) {
return;
}
Point p = null;
-
GC gc = e.gc;
- gc.setFont(titleLabel.getFont());
+ // Draw text
+ if (itemState.isNormal()) {
+ gc.setFont(titleLabel.getFont());
+
+ } else {
+ gc.setFont(FontResources.DETAIL_TITLE_FONT_BOLD.getFont());
+ }
+ gc.setFont(titleLabel.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.setForeground(itemState.getFontColor());
+ ((Canvas)e.widget).setToolTipText(itemState.getDisplayMsg());
gc.drawText(text, x + offset , y, true);
+
}
- @Override
public ArrayList<Composite> getCompositeList() {
return compList;
}
- @Override
public Composite getTopComposite() {
return compList.get(0);
}
- @Override
public Composite getBottomComposite() {
return compList.get(compList.size()-1);
}
closeItem();
}
+ @Override
+ public ItemState checkValue() {
+ itemState.setNormal();
+ return itemState;
+ }
+
+ @Override
+ public void updateItemUI() {
+ if (titleLabel != null) {
+ titleLabel.redraw();
+ }
+ if (stateLabel != null) {
+ stateLabel.redraw();
+ }
+ if (compList != null && compList.get(0) != null) {
+ compList.get(0).redraw();
+ }
+ }
+
+ @Override
+ public void setItemMarked(boolean marked) {
+ itemState.setTitleMarked(marked);
+ stateLabel.redraw();
+ }
+
+ public String getItemValue(VMPropertyValue value) {
+ return value.getAdvancedOptionValue(name);
+ }
}
public void ChangeValue(DetailViewItem item);
public void ChangeValue(boolean isChange);
public void ChangeState(ItemChangeState state);
- public void changeConfirmButton();
- public void changeConfirmButton(DetailViewItem item);
+ public void changeCreateConfirmButton();
+ public void changeModifyConfirmButton(DetailViewItem item);
}
public abstract void drawModify();
public abstract boolean settingModifyItem(VMPropertyValue value);
- public boolean checkValue();
-
+ public String getModifyValue(VMPropertyValue value);
+
}
package org.tizen.emulator.manager.ui.detail.item;
-import java.util.ArrayList;
-
-import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
public interface IViewItem {
public int getCount();
public void close();
- public ArrayList<Composite> getCompositeList();
- public Composite getTopComposite();
- public Composite getBottomComposite();
+ public void init();
- public abstract void init();
public abstract void settingStatus(boolean isRefresh);
public abstract void closeItem();
+
+ public String getItemValue(VMPropertyValue property);
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: *
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * Sangho Park<sangho1204.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.detail.item;
+
+import org.eclipse.swt.graphics.Color;
+import org.tizen.emulator.manager.resources.ColorResources;
+
+public class ItemState {
+ public static final int NORMAL = 0;
+ public static final int WARNING = 1;
+ public static final int ERROR = 2;
+
+ private int state = NORMAL;
+ private String msg = "";
+ private boolean isTitleMarked = false;
+
+ public ItemState() {
+
+ }
+
+ public boolean isTitleMarked() {
+ return isTitleMarked;
+ }
+
+ public void setTitleMarked(boolean isTitleMarked) {
+ this.isTitleMarked = isTitleMarked;
+ }
+
+ public Color getCategoryBGColor() {
+ if (state == WARNING) {
+ return ColorResources.CATEGORY_WARNING_BG.getColor();
+
+ } else if (state == ERROR) {
+ return ColorResources.CATEGORY_ERROR_BG.getColor();
+
+ } else {
+ return ColorResources.TEAL.getColor();
+ }
+ }
+
+ public Color getFontColor() {
+ if (state == WARNING) {
+ return ColorResources.WARNING_FONT.getColor();
+
+ } else if (state == ERROR) {
+ return ColorResources.ERROR_FONT.getColor();
+
+ } else {
+ return ColorResources.DETAIL_TITILE_FONT_COLOR.
+ getColor();
+ }
+ }
+
+ public Color getStatusFontColor() {
+ if (state == WARNING) {
+ return ColorResources.STATUS_WARNING_FONT.getColor();
+
+ } else if (state == ERROR) {
+ return ColorResources.ERROR_FONT.getColor();
+
+ } else {
+ return ColorResources.DETAIL_TITILE_FONT_COLOR.
+ getColor();
+ }
+ }
+
+ public Color getBGColor() {
+ if (state == WARNING) {
+ return ColorResources.CATEGORY_WARNING_BG.getColor();
+
+ } else if (state == ERROR) {
+ return ColorResources.CATEGORY_ERROR_BG.getColor();
+
+ } else {
+ return ColorResources.DETAIL_MIDDLE_COLOR.getColor();
+ }
+ }
+
+ public static ItemState CreateNormalState() {
+ return new ItemState();
+ }
+
+ public ItemState(int state) {
+ this.state = state;
+ }
+
+ public ItemState(int state, String msg) {
+ this.state = state;
+ this.msg = msg;
+ }
+
+ public void updateState(int state, String msg) {
+ this.state = state;
+ this.msg = msg;
+ }
+
+ public void updateState(ItemState state) {
+ this.state = state.getState();
+ this.msg = state.getMsg();
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public String getDisplayMsg() {
+ if (msg == null) {
+ return "";
+
+ } else {
+ if (isWarning()) {
+ return "* (Warning) " + msg;
+
+ } else if (isError()) {
+ return "* " + msg;
+
+ } else {
+ return msg;
+ }
+ }
+ }
+
+
+ public boolean isNormal() {
+ return state == NORMAL ;
+ }
+
+ public boolean isWarning() {
+ return state == WARNING;
+ }
+
+ public boolean isError() {
+ return state == ERROR;
+ }
+
+ public void setWarning(String msg) {
+ this.state = WARNING;
+ this.msg = msg;
+ }
+
+ public void setError(String msg) {
+ this.state = ERROR;
+ this.msg = msg;
+ }
+
+ public void setNormal() {
+ this.state = NORMAL;
+ this.msg = "";
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 20114 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.detail.item;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+public abstract class ItemValidator implements IModifyViewItem {
+
+ protected ItemState itemState = ItemState.CreateNormalState();
+
+ public ItemState getItemState() {
+ return itemState;
+ }
+
+ // This changes item state in UI.
+ // And this can be overridden for each Item.
+ public abstract void updateItemUI();
+
+ // This tells that this item is being mentioned in status bar.
+ public abstract void setItemMarked(boolean marked);
+
+ // This should be overridden for each item if needed.
+ public ItemState checkValue() {
+ itemState.setNormal();
+ return itemState;
+ }
+
+ public void fillBackground(GC gc, int x, int y, int width, int height) {
+ gc.setBackground(itemState.getBGColor());
+ // gc.setAlpha(200);
+ gc.fillRectangle(x, y, width, height);
+ }
+
+ public void fillBackground(GC gc, Rectangle rect, int alpha) {
+ gc.setBackground(itemState.getBGColor());
+ gc.setAlpha(alpha);
+ gc.fillRectangle(rect);
+ }
+
+}
private Map<String, AdvancedViewItem> itemMap = new HashMap<String, AdvancedViewItem>();
- public LineLabelViewItem() {
- this.title = "Advanced Options";
- }
public LineLabelViewItem(Item template) {
- this.title = template.getTitle();
+ super(template);
}
public void addItem(String name, AdvancedViewItem item) {
});
+ initStateLabel();
+
}
private static boolean isShareMinMode = false;
// TODO Auto-generated method stub
return false;
}
-
@Override
- public boolean checkValue() {
- return true;
+ public String getItemValue(VMPropertyValue property) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public String getModifyValue(VMPropertyValue value) {
+ // TODO Auto-generated method stub
+ return null;
}
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.detail.item;
+
+import java.util.List;
+
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.xml.template.Option;
+
+public abstract class ViewItem extends ItemValidator implements IInfoViewItem {
+
+ protected String name;
+ protected String title;
+ private Boolean modifyEnable = null;
+ protected boolean useDefaultOnCreate = false;
+ protected String defaultOnCreate = null;
+ protected boolean spreadOnStart = true;
+
+ public ViewItem() {
+
+ }
+
+ public ViewItem(String name, String title) {
+ this.name = name;
+ this.title = title;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Boolean getModifyEnable() {
+ return modifyEnable;
+ }
+
+ public boolean isModifyEnable() {
+ if (modifyEnable == null) {
+ return true;
+
+ } else {
+ return modifyEnable;
+ }
+ }
+
+ public void setModifyEnable(boolean enable){
+ modifyEnable = enable;
+ }
+
+ public void setEnabled(boolean enabled) {}
+
+ public void setItemEnabled() {
+ if (modifyEnable != null) {
+ setEnabled(modifyEnable);
+ }
+ }
+
+ protected void parseOption(List<Option> optionList) {
+ for (Option option : optionList) {
+ if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
+ useDefaultOnCreate = true;
+ defaultOnCreate = option.getValue();
+
+ } else if (option.getName().equals(OptionType.MODIFY_ENABLE.getName())) {
+ if (option.getValue().equals(OptionType.VALUE_FALSE)) {
+ modifyEnable = false;
+
+ } else if (option.getValue().equals(OptionType.VALUE_TRUE)) {
+ modifyEnable = true;
+ }
+
+ } else if (option.getName().equals(OptionType.SPREAD_ON_START.getName())) {
+ if(option.getValue().equals(OptionType.VALUE_FALSE)){
+ this.spreadOnStart = false;
+ }
+ }
+ }
+ }
+
+ @Override
+ public String getModifyValue(VMPropertyValue value) {
+ if (isCreateMode() && useDefaultOnCreate) {
+ return defaultOnCreate;
+
+ } else {
+ return getItemValue(value);
+ }
+ }
+
+}
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.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.FileViewItem;
import org.tizen.emulator.manager.ui.dialog.MessageDialog;
filePathLabel.setText(newPathName);
filePathLabel.redraw();
isSelected = true;
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
// TODO
//arm image
selectFileButton.setEnabled(false);
}
if(isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
}
return false;
}
@Override
- public boolean checkValue() {
- return isSelected;
+ public ItemState checkValue() {
+ itemState.setNormal();
+
+ if (isSelected) {
+ File f = new File(newPath);
+ if (!f.exists()) {
+ itemState.setError("Base image file is not exist.");
+ }
+
+ } else {
+ itemState.setError("Please select base image file.");
+ }
+
+ return itemState;
}
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.ISubViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.vms.RESOLUTION;
import org.tizen.emulator.manager.vms.xml.template.Item;
}
}
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i=0;
buttonLabel.setText(StringResources.SUPPORTED);
fileShareItem.setFileShareOn();
}
- if (!parentItem.isCreateMode()) {
- parentItem.getListener().ChangeValue(parentItem.getThis());
+ if (parentItem.isCreateMode()) {
+ parentItem.getListener().changeCreateConfirmButton();
+
+ } else {
+ parentItem.getListener().changeModifyConfirmButton(
+ parentItem.getThis());
}
}
package org.tizen.emulator.manager.ui.detail.item.property;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.ISubViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.vms.xml.template.Item;
public static String ITEM_DIR = "directory";
FileShareDialogSubViewItem dialogItem;
+ FileShareOnOffSubViewItem shareOnOffItem;
public FileShareViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
super(template, lineLabelViewItem);
}
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i=0;
for (Item item : itemList) {
String itemName = item.getName();
if (itemName.equals(ITEM_SHARE)) {
- subItemList.add(new FileShareOnOffSubViewItem(this, compList.get(i++), item));
+ shareOnOffItem = new FileShareOnOffSubViewItem(this, compList.get(i++), item);
+ subItemList.add(shareOnOffItem);
} else if (itemName.equals(ITEM_DIR)) {
dialogItem = new FileShareDialogSubViewItem(this, compList.get(i++), item);
}
}
+ @Override
+ public ItemState checkValue() {
+ itemState.setNormal();
+
+ if (shareOnOffItem.getValue() == true) {
+ String sharePath = dialogItem.getValue();
+ if (sharePath == null || sharePath.isEmpty()) {
+ itemState.setError("Please select file sharing path.");
+
+ } else {
+ File f = new File(sharePath);
+ if (!f.exists()) {
+ itemState.setError("Sharing file path is Not exist.");
+ }
+ }
+ }
+ return itemState;
+ }
+
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.EmulatorManager;
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.StringResources;
import org.tizen.emulator.manager.tool.CheckVirtualization;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.OnOffSubViewItem;
import org.tizen.emulator.manager.ui.widgets.ImageButton;
super(parentItem, comp, template);
}
+ public final String GALLIUM_WARNING_MSG =
+ "You are using invalid graphic card driver for the emulator."
+ +" If you continue launching emulator, it may not work properly."
+ + " You have to use the lastest vendor-provided graphic card driver."
+ + " For more information, see under ubuntu driver help page."
+ + " (https://help.ubuntu.com/community/BinaryDriverHowto/) ";
+
@Override
protected void makeModifyWidget() {
onOffButton = new ImageButton(comp, SWT.TOGGLE);
return true;
}
+
+ @Override
+ public ItemState checkValue() {
+ itemState.setNormal();
+
+ if (CheckVirtualization.getInstance().isGallium()
+ && EmulatorManager.isLinux() && getValue() == true) {
+ itemState.setWarning(GALLIUM_WARNING_MSG);
+ }
+
+ return itemState;
+ }
}
import java.util.List;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.ISubViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.vms.xml.template.Item;
}
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i=0;
}
return count;
}
+
}
package org.tizen.emulator.manager.ui.detail.item.property;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextViewItem;
import org.tizen.emulator.manager.vms.VMPropertyValue;
-import org.tizen.emulator.manager.vms.helper.HelperClass;
import org.tizen.emulator.manager.vms.xml.template.Item;
public class MaxTouchViewItem extends TextViewItem {
newValue = String.valueOf(value.maxTouchCount);
}
- if (modifyEnable) {
+ if (isModifyEnable()) {
text.setText(newValue);
} else {
}
@Override
- public boolean checkValue() {
- if (!modifyEnable) {
- return true;
- }
+ public ItemState checkValue() {
+ if (!isModifyEnable()) {
+ itemState.setNormal();
- boolean result = true;
- String errMsg = null;
- try {
- int val = Integer.parseInt(newValue);
- if (val <= 0) {
- errMsg = "Max touch value should be positive integer.";
- result = false;
- }
+ } else {
+ String errMsg = "";
+ try {
+ int val = Integer.parseInt(newValue);
+ if (val <= 0) {
+ itemState.setError("Max touch value should be positive integer.");
- } catch(NumberFormatException e) {
- result = false;
- errMsg = "Max touch value should be integer number.";
- }
+ } else {
+ itemState.setNormal();
+ }
- HelperClass.setStatusBar(errMsg);
- return result;
+ } catch(NumberFormatException e) {
+ itemState.setError("Max touch value should be integer number.");
+ }
+ }
+ return itemState;
}
}
}
if (isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
} else {
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextViewItem;
import org.tizen.emulator.manager.vms.VMPropertyValue;
newValue = text.getText();
if (isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
} else {
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
});
}
@Override
- public boolean checkValue() {
- return TapUtil.checkIPString(text.isEnabled(), newValue, title);
+ public ItemState checkValue() {
+ String msg = TapUtil.checkIPString(text.isEnabled(), newValue, title);
+ if (msg.isEmpty()) {
+ itemState.setNormal();
+ } else {
+ itemState.setError(msg);
+ }
+ return itemState;
}
}
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
import org.tizen.emulator.manager.ui.detail.item.template.CheckSubViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.ISubViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextViewItem;
}
public void resetCheckbox(String connectType) {
- if (modifyEnable == true) { // config from template.
+ if (isModifyEnable()) { // config from template.
if (connectType.equals(NetConnectTypeViewItem.VALUE_NAT)) {
setCheckBox(false);
setEnabled(false);
setEnabled(true);
}
- setItemState();
+ setItemEnabled();
AdvancedViewItem item = parentItem.getLineLabelViewItem().getItem(
CommonItemListFactory.ITEM_NET_CONNECT_TYPE);
}
// Set checkbox state.
- if (modifyEnable) {
+ if (isModifyEnable()) {
modifyCheckBox.setChecked(newValue);
}
setIPInfoEnabled(newValue ? false : true); // Disabled if "checked".
}
if (parentItem.isCreateMode()) {
- parentItem.getListener().changeConfirmButton();
+ parentItem.getListener().changeCreateConfirmButton();
} else {
- parentItem.getListener().changeConfirmButton(
+ parentItem.getListener().changeModifyConfirmButton(
parentItem.getThis());
}
}
// Enable/Disable ip setting
if (parentItem instanceof NetIPInfoViewItem) {
NetIPInfoViewItem item = (NetIPInfoViewItem)parentItem;
- for (ISubViewItem subItem : item.getSubItemList()) {
+ for (DetailSubViewItem subItem : item.getSubItemList()) {
if (subItem instanceof TextSubViewItem) {
((TextSubViewItem) subItem).resetText(enabled);
}
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextSubViewItem;
import org.tizen.emulator.manager.vms.VMPropertyValue;
public void modifyText(ModifyEvent e) {
newValue = text.getText();
if (parentItem.isCreateMode()) {
- parentItem.getListener().changeConfirmButton();
+ parentItem.getListener().changeCreateConfirmButton();
} else {
- parentItem.getListener().changeConfirmButton(
+ parentItem.getListener().changeModifyConfirmButton(
parentItem.getThis());
}
}
});
}
- public String getValue() {
- return newValue;
- }
+ public ItemState checkValue() {
+ String msg = TapUtil.checkIPString(text.isEnabled(), newValue, title);
+ if (msg.isEmpty()) {
+ itemState.setNormal();
+ } else {
+ itemState.setError(msg);
+ }
+ return itemState;
- public boolean checkValue() {
- return TapUtil.checkIPString(text.isEnabled(), newValue, title);
}
}
import java.util.ArrayList;
import java.util.List;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.CheckSubViewItem;
-import org.tizen.emulator.manager.ui.detail.item.template.ISubViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
import org.tizen.emulator.manager.vms.xml.template.Item;
public boolean useDHCP() {
boolean useDHCP = false;
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_USE_DHCP)) {
useDHCP = ((NetIPInfoDHCPSubViewItem) subItem).getValue();
}
}
public void setIPAddress(String ipAddress) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_IP)) {
((NetIPInfoTextSubViewItem) subItem).setText(ipAddress);
}
}
public void setSubnet(String subnet) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_SUBNET)) {
((NetIPInfoTextSubViewItem) subItem).setText(subnet);
}
}
public void setGateway(String gateway) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_GATEWAY)) {
((NetIPInfoTextSubViewItem) subItem).setText(gateway);
}
}
public String getIpAddress() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_IP)) {
return ((NetIPInfoTextSubViewItem) subItem).getValue();
}
}
public String getSubnet() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_SUBNET)) {
return ((NetIPInfoTextSubViewItem) subItem).getValue();
}
}
public String getGateway() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem.getName().equals(ITEM_GATEWAY)) {
return ((NetIPInfoTextSubViewItem) subItem).getValue();
}
}
public void resetSubItems(String connectType) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem instanceof NetIPInfoTextSubViewItem) {
((NetIPInfoTextSubViewItem) subItem).resetText(connectType);
}
@Override
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i = 0;
return count;
}
- @Override
- public boolean checkValue() {
- boolean isValid = true;
-
- for (ISubViewItem subItem : getSubItemList()) {
- if (subItem instanceof NetIPInfoTextSubViewItem) {
- isValid = ((NetIPInfoTextSubViewItem) subItem).checkValue();
- if (!isValid) {
- break;
- }
- }
- }
-
- return isValid;
-
- }
-
}
import org.tizen.emulator.manager.resources.PatchImageResources;
import org.tizen.emulator.manager.ui.MainDialog;
import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.ComboViewItem;
import org.tizen.emulator.manager.ui.widgets.ImageCombo;
resetAddress();
if (isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
} else {
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
settingAddress(ProxyDialog.open(makeDialogValue()));
if (isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
} else {
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
return true;
}
- public boolean checkValue() {
- String errMsg = null;
+ @Override
+ public ItemState checkValue() {
if (newValue != null && newValue.equals(MODE_MANUAL)) {
if (httpProxy.isEmpty() && httpsProxy.isEmpty()
&& ftpProxy.isEmpty() && socksProxy.isEmpty()) {
- errMsg = "Please set manual proxy address.";
+ itemState.setError("Please set manual proxy address.");
+
+ } else {
+ itemState.setNormal();
}
+
+ } else {
+ itemState.setNormal();
}
- HelperClass.setStatusBar(errMsg);
- return errMsg == null ? true : false;
+
+ return itemState;
}
private void getProxyValues(VMPropertyValue value) {
import org.tizen.emulator.manager.tool.TapUtil;
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.ComboViewItem;
import org.tizen.emulator.manager.ui.dialog.MessageDialog;
if (!isCreateMode()) {
// getListener().ChangeValue(getThis());
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
}
}
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
return true;
}
}
@Override
- public boolean checkValue() {
+ public ItemState checkValue() {
if (!combo.isEnabled()) {
- return true;
- }
+ itemState.setNormal();
+
+ } else if (newValue == null || !newValue.isEmpty()) {
+ itemState.setNormal();
- if (newValue == null || !newValue.isEmpty()) {
- return true;
+ } else {
+ itemState.setError("At least one Tap device should be created.");
}
- HelperClass.setStatusBar("At least one Tap device should be created.");
- return false;
+ return itemState;
}
private void resetAddress() {
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.tizen.emulator.manager.tool.CheckVirtualization;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.ComboViewItem;
-import org.tizen.emulator.manager.ui.dialog.MessageDialog;
import org.tizen.emulator.manager.vms.CPU;
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
@Override
public void widgetSelected(SelectionEvent e) {
newValue = combo.getText();
+ if (isCreateMode()) {
+ getListener().changeCreateConfirmButton();
- if (!isCreateMode()) {
+ } else {
getListener().ChangeValue(getThis());
- getListener().changeConfirmButton(getThis());
- }
-
- if (checkUGWarning()) {
- String msg = "\nPlease use processors 1 at non-UG platform." +
- "\nMulti-processors might cause VM slower.";
- new MessageDialog().openWarningDialog("Emulator Manager Warning", msg);
+ getListener().changeModifyConfirmButton(getThis());
}
}
return String.valueOf(value.cpu);
}
- @Override
- public boolean checkValue() {
- return true;
- }
-
private boolean checkUGWarning() {
if (CheckVirtualization.getInstance().isNonUG()) {
- if (Integer.parseInt(newValue) > 1) {
+ if (newValue == null) {
+ return true;
+ } else if (Integer.parseInt(newValue) > 1) {
return true;
}
}
return false;
}
+
+ @Override
+ // This should be overriden if item validation is needed.
+ public ItemState checkValue() {
+
+ if (checkUGWarning()) {
+ String msg = "Please use processors 1 at non-UG platform."
+ + "Multi-processors might cause VM slower.";
+ itemState.setWarning(msg);
+
+ } else {
+ itemState.setNormal();
+ }
+ return itemState;
+ }
}
}
@Override
- protected String getItemValue(VMPropertyValue value) {
+ public String getItemValue(VMPropertyValue value) {
return String.valueOf(value.ramSize);
}
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.Text;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.platform.PlatformList;
import org.tizen.emulator.manager.resources.ColorResources;
import org.tizen.emulator.manager.resources.FontResources;
import org.tizen.emulator.manager.resources.PatchImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.VMsMainView;
import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.template.TextViewItem;
import org.tizen.emulator.manager.ui.widgets.ImageLabel;
import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.helper.HelperClass;
import org.tizen.emulator.manager.vms.xml.template.Item;
public class VMNameViewItem extends TextViewItem{
+ Canvas canvas;
+ private boolean isStandard;
+
public VMNameViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
super(template, lineLabelViewItem);
}
public void modifyText(ModifyEvent e) {
if (isCreateMode()) {
newValue = text.getText();
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
}
}
});
}
@Override
- public boolean checkValue() {
+ public ItemState checkValue() {
if (!isCreateMode()) {
- return true;
- }
- if (HelperClass.checkImageName(newValue, true)) {
- return true;
+ itemState.setNormal();
+
+ } else {
+ String msg = checkImageName(newValue);
+ if (msg.isEmpty()) {
+ itemState.setNormal();
+
+ } else {
+ itemState.setError(msg);
+ }
}
- return false;
- }
-// private void checkVMName() {
-// if (HelperClass.checkImageName(newValue, true)) {
-// if (isStandard) {
-// getListener().ChangeValue(true);
-// } else {
-//// if (isSelected) {
-//// getListener().ChangeValue(true);
-//// } else {
-//// getListener().ChangeValue(false);
-//// }
-// }
-// } else {
-// getListener().ChangeValue(false);
-// }
-// }
+ return itemState;
+ }
// Generate VMName automatically.
// ex) "m-0626-1"
return vmName.toString();
}
+ public static String checkImageName(String newName) {
+ String errorMsg = "";
+ VMProperty prop = null;
+ boolean result = true;
+ if (newName.length() > VMProperty.MAX_NAME_LEN) {
+ errorMsg = "Max length is 20.";
+ result = false;
+ } else if (!HelperClass.checkString(newName)) {
+ errorMsg = "Name has invalid character!";
+ result = false;
+ } else if ((prop = HelperClass.checkDupulicateName(newName)) != null) {
+ String platform = prop.getImagePlatform();
+ errorMsg = "Same name already exists in " + platform + "!";
+
+ if (!existPlatform(prop)){
+ errorMsg += " (" + platform + " platform image does not exist.)";
+ EMLogger.getLogger().info(platform + " platform image does not exist." + StringResources.NEW_LINE
+ + "If you do not need this VM(" + newName + "), delete VM folder."
+ + StringResources.NEW_LINE + "VM folder path: " + prop.getPropertyFile().getAbsolutePath());
+ }
+
+ result = false;
+ } else if (newName.length() == VMProperty.MAX_NAME_LEN) {
+ errorMsg = "Max length is 20.";
+ } else if (newName.isEmpty()) {
+ errorMsg = "Please input VM name.";
+ result = false;
+ }
+
+ return errorMsg;
+ }
+
+ private static boolean existPlatform(VMProperty prop) {
+ boolean existPlatform = false;
+
+ String platform = prop.getImagePlatform();
+
+ for (Platform p : PlatformList.getPlatformList()) {
+ if (p.getName().equals(platform)) {
+ existPlatform = true;
+ break;
+ }
+ }
+
+ if (!existPlatform) {
+ if (prop.getImageType() == FSImageType.custom) {
+ existPlatform = true;
+ }
+ }
+
+ return existPlatform;
+ }
+
}
}
}
- protected void parseOption(List<Option> optionList) {
+ @Override
+ public void parseOption(List<Option> optionList) {
+ super.parseOption(optionList);
for (Option option : optionList) {
if (option.getName().equals(OptionType.HIDE_LABEL.getName())) {
if(option.getValue().equals("on")) {
}
@Override
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i = this.hideLabel ? -1 : 0;
@Override
public void drawModify() {
makeModifyWidget();
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.drawModify();
+ if (subItem.getModifyEnable() == null) {
+ subItem.setModifyEnable(isModifyEnable()); // Set sub item's state as parent's.
+ }
}
}
isChecked = true;
}
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
if (subItem instanceof CheckSubViewItem) {
((CheckSubViewItem)subItem).setCheckBox(isChecked);
}
@Override
public boolean settingModifyItem(VMPropertyValue value) {
checkBox.setSelection(true);
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.settingModifyItem(value);
}
if (!isCreateMode()) {
import org.tizen.emulator.manager.vms.xml.template.Item;
import org.tizen.emulator.manager.vms.xml.template.Option;
-public class CheckSubViewItem extends SubViewItem {
+public class CheckSubViewItem extends DetailSubViewItem {
// protected String name;
// protected String title;
}
if (parentItem.isCreateMode()) {
- parentItem.getListener().changeConfirmButton();
+ parentItem.getListener().changeCreateConfirmButton();
} else {
- parentItem.getListener().changeConfirmButton(
+ parentItem.getListener().changeModifyConfirmButton(
parentItem.getThis());
}
}
// Set checkbox state.
modifyCheckBox.setChecked(newValue);
modifyCheckBox.notifyListeners(SWT.Selection, new Event());
- setItemState();
+ setItemEnabled();
return false;
}
modifyCheckBox.setSelection(checked);
if (parentItem.isCreateMode()) {
- parentItem.getListener().changeConfirmButton();
+ parentItem.getListener().changeCreateConfirmButton();
} else {
- parentItem.getListener().changeConfirmButton(
+ parentItem.getListener().changeModifyConfirmButton(
parentItem.getThis());
}
}
import org.tizen.emulator.manager.vms.xml.template.Item;
import org.tizen.emulator.manager.vms.xml.template.Option;
-public class ComboSubViewItem extends SubViewItem {
+public class ComboSubViewItem extends DetailSubViewItem {
protected String oldValue;
protected String newValue;
protected Image INPUTBOX_ON_IMAGE = null;
protected static int COMBO_WIDTH = 105;
+ public String getValue() {
+ return newValue;
+ }
+
public ComboSubViewItem(LabelViewItem parentItem, Composite comp, Item template) {
super(parentItem, comp, template);
parseOption(template.getOption());
}
}
- setItemState();
+ setItemEnabled();
return true;
}
public class ComboViewItem extends AdvancedViewItem{
- protected String name;
-
protected String oldValue;
protected String newValue;
protected Image INPUTBOX_OFF_IMAGE = null;
protected int COMBOBOX_WIDTH = 175;
+
protected boolean useDefaultOnCreate = false;
protected String defaultOnCreate = null;
}
public ComboViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
- super(lineLabelViewItem);
+ super(template, lineLabelViewItem);
if (lineLabelViewItem == null) {
INDENT = 0;
}
- name = template.getName();
- title = template.getTitle();
count = 1;
parseOption(template.getOption());
}
protected void parseOption(List<Option> optionList) {
+ super.parseOption(optionList);
for (Option option : optionList) {
if (option.getName().equals(OptionType.COMBO_LIST.getName())) {
String[] split = option.getValue().split(",");
comboOptions.add(s.trim());
}
}
-
- if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
- useDefaultOnCreate = true;
- defaultOnCreate = option.getValue();
- }
}
}
return true;
}
- protected String getItemValue(VMPropertyValue value) {
- return value.getAdvancedOptionValue(name);
- }
-
-
- @Override
- public boolean checkValue() {
- return true;
- }
-
public void resetCombo() {
}
+
}
package org.tizen.emulator.manager.ui.detail.item.template;
-import java.util.List;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.resources.ColorResources;
import org.tizen.emulator.manager.resources.PatchImageResources;
-import org.tizen.emulator.manager.ui.detail.item.OptionType;
+import org.tizen.emulator.manager.ui.detail.item.DetailViewItemChangeListener;
+import org.tizen.emulator.manager.ui.detail.item.IInfoViewItem;
+import org.tizen.emulator.manager.ui.detail.item.IModifyViewItem;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
+import org.tizen.emulator.manager.ui.detail.item.ViewItem;
import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.ui.widgets.ItemCategoryLabel;
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
-import org.tizen.emulator.manager.vms.xml.template.Option;
-public abstract class SubViewItem implements ISubViewItem {
+public abstract class DetailSubViewItem extends ViewItem {
+
// for category
- protected String name;
- protected ImageLabel category;
+ protected ItemCategoryLabel category;
protected Image CATEGORYBOX_IMAGE;
- protected String title;
protected ImageLabel valueLabel;
protected Image INPUTBOX_OFF_IMAGE;
protected static int LABEL_WIDTH = 105;
protected static int TOP_GAP = 3;
- protected boolean useDefaultOnCreate = false;
- protected String defaultOnCreate = null;
- protected Boolean modifyEnable = null;
-
-
- public SubViewItem(LabelViewItem parentItem, Composite comp, Item template) {
+ public DetailSubViewItem(LabelViewItem parentItem, Composite comp, Item template) {
+ super(template.getName(), template.getTitle());
this.parentItem = parentItem;
this.comp = comp;
- this.name = template.getName();
- this.title = template.getTitle();
- }
-
- protected void parseOption(List<Option> optionList) {
- for (Option option : optionList) {
- if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
- useDefaultOnCreate = true;
- defaultOnCreate = option.getValue();
-
- } else if (option.getName().equals(OptionType.MODIFY_ENABLE.getName())) {
- if (option.getValue().equals(OptionType.VALUE_FALSE)) {
- modifyEnable = false;
-
- } else if (option.getValue().equals(OptionType.VALUE_TRUE)) {
- modifyEnable = true;
- }
- }
- }
- }
-
- @Override
- public String getName() {
- return name;
}
@Override
}
protected void makeCategory() {
- category = new ImageLabel(comp, SWT.NONE);
+ category = new ItemCategoryLabel(comp, SWT.NONE, itemState);
if (CATEGORYBOX_IMAGE == null) {
CATEGORYBOX_IMAGE = PatchImageResources.getCategoryBox(CATEGORY_WIDTH);
}
category.setLayoutData(data);
}
+
@Override
public void closeItem() {
if (category != null) {
}
@Override
- public void setEnabled(boolean enabled) {}
+ public String getItemValue(VMPropertyValue value) {
+ return value.getAdvancedOptionSubValue(parentItem.getName(), name);
+ }
+
+
+ @Override
+ public void close() {
+ closeItem();
+ }
+
+ @Override
+ public int getCount() {
+ return 1;
+ }
@Override
- public Boolean getModifyEnable() {
- return modifyEnable;
+ public boolean isCreateMode() {
+ return parentItem.isCreateMode();
}
@Override
- public void setModifyEnable(boolean enable){
- modifyEnable = enable;
+ public ItemState checkValue() {
+ itemState.setNormal();
+ return itemState;
}
- public void setItemState() {
- if (modifyEnable != null) {
- setEnabled(modifyEnable);
+ @Override
+ public void updateItemUI() {
+ if (category != null) {
+ category.redraw();
}
}
@Override
- public String getItemValue(VMPropertyValue value) {
- return value.getAdvancedOptionSubValue(parentItem.getName(), name);
+ public void setItemMarked(boolean marked) {
+ // TODO Auto-generated method stub
}
@Override
- public String getModifyValue(VMPropertyValue value) {
- if (parentItem.isCreateMode() && useDefaultOnCreate) {
- return defaultOnCreate;
+ public void setCreateMode(boolean isCreateMode) {
+ // TODO Auto-generated method stub
+ }
- } else {
- return getItemValue(value);
- }
+ @Override
+ public void initItem(Composite parent, IInfoViewItem upperItem) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void setViewMode(boolean isViewMode) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void init() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void initItem(Composite parent, IModifyViewItem upperItem) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void setListener(DetailViewItemChangeListener listener) {
+ // TODO Auto-generated method stub
}
}
import org.tizen.emulator.manager.vms.xml.template.Item;
import org.tizen.emulator.manager.vms.xml.template.Option;
-public class FileSubViewItem extends SubViewItem {
+public class FileSubViewItem extends DetailSubViewItem {
protected String oldValue;
protected String newValue;
}
}
+ public String getValue() {
+ return newValue;
+ }
+
@Override
public void drawModify() {
makeModifyWidget();
filePathLabel.setToolTipText(newValue);
}
}
- if (!parentItem.isCreateMode()) {
- parentItem.getListener().ChangeValue(parentItem.getThis());
+
+ if (parentItem.isCreateMode()) {
+ parentItem.getListener().changeCreateConfirmButton();
+
+ } else {
+ parentItem.getListener().changeModifyConfirmButton(
+ parentItem.getThis());
}
}
.lastIndexOf(File.separator) + 1, newValue.length());
filePathLabel.setText(fileName);
filePathLabel.setToolTipText(newValue);
- setItemState();
+ setItemEnabled();
return true;
}
protected String name;
+ private String oldValue;
private String newValue;
// for Info view
protected List<String> filters = new ArrayList<String>();
public FileViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
- super(lineLabelViewItem);
+ super(template, lineLabelViewItem);
if (lineLabelViewItem == null) {
INDENT = 0;
}
- name = template.getName();
- title = template.getTitle();
count = 1;
+ parseOption(template.getOption());
+ }
- List<Option> optionList = template.getOption();
+ @Override
+ public void parseOption(List<Option> optionList) {
+ super.parseOption(optionList);
for (Option option : optionList) {
if (option.getName().equals(OptionType.FILE_FILTER.getName())) {
String[] split = option.getValue().split(",");
return true;
}
- @Override
- public boolean checkValue() {
- return true;
- }
-
}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * MunKyu Im <munkyu.im@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
- * Minkee Lee <minkee.lee@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.emulator.manager.ui.detail.item.template;
-
-import org.tizen.emulator.manager.vms.VMPropertyValue;
-
-public interface ISubViewItem {
- public void drawDetail();
- public void drawModify() ;
- public boolean settingDetailItem(VMPropertyValue value);
- public void setValue(VMPropertyValue value);
- public boolean settingModifyItem(VMPropertyValue value);
- public void closeItem();
- public String getName();
- public void setEnabled(boolean enabled);
- public Boolean getModifyEnable();
- public void setModifyEnable(boolean enable);
- public String getItemValue(VMPropertyValue value);
- public String getModifyValue(VMPropertyValue value);
-}
import java.util.List;
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
import org.tizen.emulator.manager.ui.detail.item.ItemType;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
import org.tizen.emulator.manager.ui.detail.item.OptionType;
public class LabelViewItem extends AdvancedViewItem{
- protected String name;
- protected List<ISubViewItem> subItemList;
+ protected List<DetailSubViewItem> subItemList;
protected Item template;
boolean isDeviceItem;
- boolean spreadOnStart = true;
- protected boolean modifyEnable = true;
public LabelViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
- super(lineLabelViewItem);
+ super(template, lineLabelViewItem);
if (lineLabelViewItem == null) {
INDENT = 0;
}
- title = template.getTitle();
- name = template.getName();
// count = template.getItem().size();
count = getSubItemCount(template);
if (count == 0) {
parseOption(template.getOption());
}
- private void parseOption(List<Option> optionList) {
+ public void parseOption(List<Option> optionList) {
+ super.parseOption(optionList);
for (Option option : optionList) {
- if (option.getName().equals(OptionType.SPREAD_ON_START.getName())) {
- if(option.getValue().equals(OptionType.VALUE_FALSE)){
- this.spreadOnStart = false;
- }
-
- } else if (option.getName().equals(OptionType.MODIFY_ENABLE.getName())) {
- if (option.getValue().equals(OptionType.VALUE_FALSE)) {
- modifyEnable = false;
- }
- }
- }
+ if (option.getName().equals(OptionType.SPREAD_ON_START.getName())) {
+ if(option.getValue().equals(OptionType.VALUE_FALSE)){
+ this.spreadOnStart = false;
+ }
+ }
+ }
}
@Override
public void drawDetail() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.drawDetail();
}
}
@Override
public boolean settingDetailItem(VMPropertyValue value) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.settingDetailItem(value);
}
return true;
@Override
public void closeItem() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.closeItem();
}
}
@Override
public void setValue(VMPropertyValue value) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.setValue(value);
}
}
@Override
public void drawModify() {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.drawModify();
if (subItem.getModifyEnable() == null) {
- subItem.setModifyEnable(modifyEnable);
+ subItem.setModifyEnable(isModifyEnable()); // Set sub item's state as parent's.
}
}
}
@Override
public boolean settingModifyItem(VMPropertyValue value) {
- for (ISubViewItem subItem : getSubItemList()) {
+ for (DetailSubViewItem subItem : getSubItemList()) {
subItem.settingModifyItem(value);
}
if (!isCreateMode()) {
}
- protected List<ISubViewItem> getSubItemList() {
+ protected List<DetailSubViewItem> getSubItemList() {
if (subItemList == null) {
- subItemList = new ArrayList<ISubViewItem>();
+ subItemList = new ArrayList<DetailSubViewItem>();
List<Item> itemList = template.getItem();
int i=0;
}
@Override
- public boolean checkValue() {
- return true;
+ public ItemState checkValue() {
+ DetailSubViewItem errorItem = null;
+ for (DetailSubViewItem subItem : getSubItemList()) {
+ subItem.checkValue();
+ subItem.updateItemUI();
+
+ if (subItem.getItemState().isError()) {
+ if (errorItem == null || !errorItem.getItemState().isError()) {
+ errorItem = subItem;
+ }
+
+ } else if (subItem.getItemState().isWarning()) {
+ if (errorItem == null || errorItem.getItemState().isNormal()) {
+ errorItem = subItem;
+ }
+ }
+ }
+
+ if (errorItem == null) {
+ itemState.setNormal();
+
+ } else {
+ itemState.updateState(errorItem.getItemState());
+ }
+
+ return itemState;
}
+
}
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
-public class OnOffSubViewItem extends SubViewItem{
+public class OnOffSubViewItem extends DetailSubViewItem{
protected boolean oldValue;
protected boolean newValue;
super(parentItem, comp, template);
}
+ public boolean getValue() {
+ return newValue;
+ }
+
@Override
public void drawModify() {
makeCategory();
newValue = true;
buttonLabel.setText(StringResources.SUPPORTED);
}
- if (!parentItem.isCreateMode()) {
- parentItem.getListener().ChangeValue(parentItem.getThis());
+
+ if (parentItem.isCreateMode()) {
+ parentItem.getListener().changeCreateConfirmButton();
+
+ } else {
+ parentItem.getListener().changeModifyConfirmButton(
+ parentItem.getThis());
}
}
onOffButton.setSelection(true);
buttonLabel.setText(StringResources.NOT_SUPPORTED);
}
- setItemState();
+ setItemEnabled();
return true;
}
protected String name;
+ private boolean oldValue;
private boolean newValue;
public static String VALUE_ON = "on";
public OnOffViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
- super(lineLabelViewItem);
+ super(template, lineLabelViewItem);
if (lineLabelViewItem == null) {
INDENT = 0;
}
-
- name = template.getName();
- title = template.getTitle();
count = 1;
+ parseOption(template.getOption());
}
@Override
return true;
}
- @Override
- public boolean checkValue() {
- return true;
- }
-
}
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
-public class SpinnerSubViewItem extends SubViewItem {
+public class SpinnerSubViewItem extends DetailSubViewItem {
protected int oldValue;
protected int newValue;
// TODO Auto-generated constructor stub
}
+ public int getValue() {
+ return newValue;
+ }
+
@Override
public void drawModify() {
makeCategory();
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
-public class TextSubViewItem extends SubViewItem {
+public class TextSubViewItem extends DetailSubViewItem {
protected String oldValue;
protected String newValue;
super(parentItem, comp, template);
}
+ public String getValue() {
+ return newValue;
+ }
+
+
public void drawModify() {
makeCategory();
public boolean settingModifyItem(VMPropertyValue value) {
newValue = getModifyValue(value);
text.setText(newValue);
- setItemState();
+ setItemEnabled();
return false;
}
package org.tizen.emulator.manager.ui.detail.item.template;
-import java.util.List;
-
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.GC;
import org.eclipse.swt.graphics.Image;
+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.Text;
import org.tizen.emulator.manager.resources.ColorResources;
import org.tizen.emulator.manager.resources.FontResources;
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
-import org.tizen.emulator.manager.ui.detail.item.OptionType;
import org.tizen.emulator.manager.ui.widgets.ImageLabel;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.xml.template.Item;
-import org.tizen.emulator.manager.vms.xml.template.Option;
public class TextViewItem extends AdvancedViewItem{
- protected String name;
-
protected String oldValue = "";
protected String newValue = "";
protected Image INPUTBOX_ON_IMAGE = null;
protected Image INPUTBOX_OFF_IMAGE = null;
- protected boolean modifyEnable = true;
- protected boolean useDefaultOnCreate = false;
- protected String defaultOnCreate = null;
-
protected String VALUE_FALSE = "false";
public TextViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
- super(lineLabelViewItem);
+ super(template, lineLabelViewItem);
if (lineLabelViewItem == null) {
INDENT = 0;
}
- name = template.getName();
- title = template.getTitle();
count = 1;
parseOption(template.getOption());
}
- protected void parseOption(List<Option> optionList) {
- for (Option option : optionList) {
- if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
- useDefaultOnCreate = true;
- defaultOnCreate = option.getValue();
-
- } else if (option.getName().equals(OptionType.MODIFY_ENABLE.getName())) {
- if (option.getValue().equals(VALUE_FALSE)) {
- modifyEnable = false;
- }
- }
- }
- }
-
@Override
public void drawDetail() {
if (INPUTBOX_OFF_IMAGE == null) {
@Override
public void drawModify() {
- if (modifyEnable) {
+ if (isModifyEnable()) {
if (INPUTBOX_ON_IMAGE == null) {
INPUTBOX_ON_IMAGE = PatchImageResources.getInputBoxON(INPUTBOX_WIDTH);
}
newValue = text.getText();
if (isCreateMode()) {
- getListener().changeConfirmButton();
+ getListener().changeCreateConfirmButton();
} else {
- getListener().changeConfirmButton(getThis());
+ getListener().changeModifyConfirmButton(getThis());
}
}
});
newValue = value.getAdvancedOptionValue(name);
}
- if (modifyEnable) {
+ if (isModifyEnable()) {
text.setText(newValue);
} else {
}
@Override
- public boolean checkValue() {
- return true;
- }
-
- @Override
public void setEnabled(boolean enabled) {
valueLabel.setEnabled(enabled);
text.setEnabled(enabled);
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.resources.ColorResources;
import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.ui.UIHelper;
public class ImageLabel extends Canvas{
- private WSTATE state = WSTATE.NORMAL;
- private Image enableImage;
- private Image disableImage;
- private Font font;
- private Color enableFontColor;
- private Color disableFontColor;
- private Point fontPoint;
- private String text;
+ protected WSTATE state = WSTATE.NORMAL;
+ protected Image enableImage;
+ protected Image disableImage;
+ protected Font font;
+ protected Color enableFontColor;
+ protected Color disableFontColor;
+ protected Point fontPoint;
+ protected String text;
+ protected String displayText;
public ImageLabel(Composite parent, int style) {
super(parent, style);
setEnableFontColor(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
setDisableFontColor(ColorResources.DETAIL_DISABLE_FONT_COLOR.getColor());
- this.addPaintListener(labelPaintListener);
+ addPaintListener();
}
- private PaintListener labelPaintListener = new PaintListener() {
+ public void drawImage(PaintEvent e) {
+ Image image = (state == WSTATE.NORMAL
+ ? enableImage : disableImage);
+ if (image == null) {
+ return;
+ }
- @Override
- public void paintControl(PaintEvent e) {
- Image image = (state == WSTATE.NORMAL
- ? enableImage : disableImage);
- if (image == null) {
- return;
- }
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ GC gc = e.gc;
+ gc.drawImage(image, rect.x, rect.y);
+ }
- Rectangle rect = ((Canvas)e.widget).getClientArea();
- GC gc = e.gc;
- gc.drawImage(image, rect.x, rect.y);
- drawText(gc, rect);
+ public void drawText(PaintEvent e) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ GC gc = e.gc;
+ Point p = null;
+ if (text != null) {
+ if (font == null) {
+ font = FontResources.DETAIL_LABEL_FONT.getFont();
+ setFont(font);
+ }
+ gc.setFont(font);
+ gc.setForeground((state == WSTATE.NORMAL ? enableFontColor : disableFontColor));
+
+ int x = 0, y = 0;
+ if (fontPoint == null) {
+ text = UIHelper.shortenText(gc, text, rect);
+ p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+ y = (rect.height - p.y) / 2;
+ } else {
+ x = fontPoint.x;
+ y = fontPoint.y;
+ }
+ gc.drawText(text, x, y, true);
}
+ }
+
+ public void addPaintListener() {
+ this.addPaintListener(new PaintListener() {
- private void drawText(GC gc, Rectangle rect) {
- Point p = null;
-
- if (text != null) {
- if (font == null) {
- font = FontResources.DETAIL_LABEL_FONT.getFont();
- setFont(font);
- }
- gc.setFont(font);
- gc.setForeground((state == WSTATE.NORMAL ? enableFontColor : disableFontColor));
-
- int x = 0, y = 0;
- int offset = 0;
- if (fontPoint == null) {
- p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- x = (rect.width - p.x) / 2;
- y = (rect.height - p.y) / 2;
- if(x < 0) { // shorten text and add "..."
- String subStr = null;
- String ellipsis = "...";
- int fixedWidth;
- for(int i = text.length() ; i > 0 ; i--){
- subStr = text.substring(0, i).trim();
- subStr += ellipsis;
- fixedWidth = gc.textExtent(subStr, SWT.DRAW_MNEMONIC).x;
- if(fixedWidth < rect.width){
- break;
- }
- }
- text = subStr;
- x = 2; // x = (x < 0) ? 2 : x;
- }
- offset = 0;
- } else {
- x = fontPoint.x;
- y = fontPoint.y;
- }
-
- gc.drawText(text, x + offset , y, true);
+ @Override
+ public void paintControl(PaintEvent e) {
+ drawImage(e);
+ drawText(e);
}
- }
- };
+ });
+ }
public void setText(String text) {
this.text = text;
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: *
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * Sangho Park<sangho1204.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+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.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.ui.UIHelper;
+import org.tizen.emulator.manager.ui.detail.item.ItemState;
+
+public class ItemCategoryLabel extends ImageLabel {
+
+ private ItemState itemState;
+
+ public ItemCategoryLabel(Composite parent, int style, ItemState itemState) {
+ super(parent, style);
+ this.itemState = itemState;
+ }
+
+ @Override
+ public void drawImage(PaintEvent e) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ GC gc = e.gc;
+
+ if (itemState.isNormal()) {
+ Image image = (state == WSTATE.NORMAL
+ ? enableImage : disableImage);
+ if (image == null) {
+ return;
+ }
+ gc.drawImage(image, rect.x, rect.y);
+
+ } else {
+ // Fill Background by state
+ gc.setBackground(itemState.getCategoryBGColor());
+ gc.setAntialias(SWT.ON);
+ gc.fillRoundRectangle(rect.x, rect.y, rect.width, rect.height, 8, 4);
+ }
+ }
+
+ @Override
+ public void drawText(PaintEvent e) {
+ Rectangle rect = ((Canvas)e.widget).getClientArea();
+ GC gc = e.gc;
+
+ Point p = null;
+ if (text != null) {
+ if (font == null) {
+ font = FontResources.DETAIL_LABEL_FONT.getFont();
+ setFont(font);
+ }
+ gc.setFont(font);
+ Color fontColor = null;
+ if (state == WSTATE.NORMAL) {
+ if (itemState.isNormal()) {
+ fontColor = enableFontColor; // use ImageLabel's font color.
+//
+ } else {
+ fontColor = enableFontColor;
+// fontColor = itemState.getFontColor();
+ }
+
+ } else {
+ fontColor = disableFontColor;
+ }
+
+ gc.setForeground(fontColor);
+
+ int x = 0, y = 0;
+ if (fontPoint == null) {
+ text = UIHelper.shortenText(gc, text, rect);
+ p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+ y = (rect.height - p.y) / 2;
+ } else {
+ x = fontPoint.x;
+ y = fontPoint.y;
+ }
+ gc.drawText(text, x, y, true);
+ ((Canvas)e.widget).setToolTipText(itemState.getDisplayMsg());
+ }
+ }
+
+
+}
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.platform.Platform;
-import org.tizen.emulator.manager.platform.PlatformList;
-import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.MainDialog;
import org.tizen.emulator.manager.vms.EmulatorVMList;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
public class HelperClass {
- public static boolean checkImageName(String newName, boolean showStatus) {
- String errorMsg = "";
- VMProperty prop = null;
- boolean result = true;
- if (newName.length() > VMProperty.MAX_NAME_LEN) {
- errorMsg = "Max length is 20.";
- result = false;
- } else if (!checkString(newName)) {
- errorMsg = "Name has invalid character!";
- result = false;
- } else if ((prop = checkDupulicateName(newName)) != null) {
- String platform = prop.getImagePlatform();
- errorMsg = "Same name already exists in " + platform + "!";
-
- if (!existPlatform(prop)){
- errorMsg += " (" + platform + " platform image does not exist.)";
- EMLogger.getLogger().info(platform + " platform image does not exist." + StringResources.NEW_LINE
- + "If you do not need this VM(" + newName + "), delete VM folder."
- + StringResources.NEW_LINE + "VM folder path: " + prop.getPropertyFile().getAbsolutePath());
- }
-
- 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;
- }
- private static boolean existPlatform(VMProperty prop) {
- boolean existPlatform = false;
-
- String platform = prop.getImagePlatform();
-
- for (Platform p : PlatformList.getPlatformList()) {
- if (p.getName().equals(platform)) {
- existPlatform = true;
- break;
- }
- }
-
- if (!existPlatform) {
- if (prop.getImageType() == FSImageType.custom) {
- existPlatform = true;
- }
- }
-
- return existPlatform;
- }
public static boolean checkString(String t) {
for(char ch : t.toCharArray()) {