From: minkee.lee Date: Mon, 19 Oct 2015 13:30:37 +0000 (+0900) Subject: vm-modify: add file-sharing item. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=621ab27ab9edda931e9e5d78b5119767649e3fed;p=sdk%2Femulator%2Femulator-manager.git vm-modify: add file-sharing item. Change-Id: I1167da72b2341d09ed3cab4eb11d024fba2c9cf4 Signed-off-by: minkee.lee --- diff --git a/resource/renewal/res/9p_blue_btn_hover_b.png b/resource/renewal/res/9p_blue_btn_hover_b.png new file mode 100644 index 0000000..339e183 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_b.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_l.png b/resource/renewal/res/9p_blue_btn_hover_l.png new file mode 100644 index 0000000..904069b Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_l.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_lb.png b/resource/renewal/res/9p_blue_btn_hover_lb.png new file mode 100644 index 0000000..ff68e20 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_lb.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_lt.png b/resource/renewal/res/9p_blue_btn_hover_lt.png new file mode 100644 index 0000000..e1fa684 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_lt.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_r.png b/resource/renewal/res/9p_blue_btn_hover_r.png new file mode 100644 index 0000000..2879ba2 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_r.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_rb.png b/resource/renewal/res/9p_blue_btn_hover_rb.png new file mode 100644 index 0000000..bee74c5 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_rb.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_rt.png b/resource/renewal/res/9p_blue_btn_hover_rt.png new file mode 100644 index 0000000..86dd9b1 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_rt.png differ diff --git a/resource/renewal/res/9p_blue_btn_hover_t.png b/resource/renewal/res/9p_blue_btn_hover_t.png new file mode 100644 index 0000000..d5cb769 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_hover_t.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_b.png b/resource/renewal/res/9p_blue_btn_normal_b.png new file mode 100644 index 0000000..805b3b8 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_b.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_l.png b/resource/renewal/res/9p_blue_btn_normal_l.png new file mode 100644 index 0000000..433ea7b Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_l.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_lb.png b/resource/renewal/res/9p_blue_btn_normal_lb.png new file mode 100644 index 0000000..ef91865 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_lb.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_lt.png b/resource/renewal/res/9p_blue_btn_normal_lt.png new file mode 100644 index 0000000..1a792fe Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_lt.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_r.png b/resource/renewal/res/9p_blue_btn_normal_r.png new file mode 100644 index 0000000..433ea7b Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_r.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_rb.png b/resource/renewal/res/9p_blue_btn_normal_rb.png new file mode 100644 index 0000000..b8cc065 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_rb.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_rt.png b/resource/renewal/res/9p_blue_btn_normal_rt.png new file mode 100644 index 0000000..353d40b Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_rt.png differ diff --git a/resource/renewal/res/9p_blue_btn_normal_t.png b/resource/renewal/res/9p_blue_btn_normal_t.png new file mode 100644 index 0000000..805b3b8 Binary files /dev/null and b/resource/renewal/res/9p_blue_btn_normal_t.png differ diff --git a/resource/renewal/res/icon_blue_btn_open.png b/resource/renewal/res/icon_blue_btn_open.png new file mode 100644 index 0000000..9822f1b Binary files /dev/null and b/resource/renewal/res/icon_blue_btn_open.png differ diff --git a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java index 1b782a4..c0f3c20 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java @@ -46,6 +46,8 @@ public enum ColorResources { GRAY_BTN_PUSH(100, 110, 144), GRAY_BTN_DISABLE(208, 208, 208), + BLUE_BTN(147, 188, 208), + TABLE_VIEWER_BG(240, 240, 240), LINK_MENU_FONT(255, 255, 255), CREATE_VM_COMBO_FONT(41,41,41), @@ -67,7 +69,10 @@ public enum ColorResources { MODIFY_ITEM_TITLE(41, 41, 41), MODIFY_ITEM_LINE(208, 212, 215), - DEFAULT_FONT(41, 41, 41); + DEFAULT_FONT(41, 41, 41), + + // TODO I guess .. little brighter than MESSAGE_BOX_CONTENTS_FONT + TEXTBOX_DISABLE(160, 160, 160); public static ColorResources GRAY_BTN_FONT = WHITE; public static ColorResources CONTENT_FONT = MESSAGE_BOX_CONTENTS_FONT; diff --git a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java index 67e3d9d..d20da4c 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java @@ -82,6 +82,24 @@ public enum ImageResources { GRAY_BTN_PUSH_RT("9p_btn_push_rt"), GRAY_BTN_PUSH_T("9p_btn_push_t"), + // blue 9 patch button + BLUE_BTN_HOVER_B("9p_blue_btn_hover_b"), + BLUE_BTN_HOVER_L("9p_blue_btn_hover_l"), + BLUE_BTN_HOVER_LB("9p_blue_btn_hover_lb"), + BLUE_BTN_HOVER_LT("9p_blue_btn_hover_lt"), + BLUE_BTN_HOVER_R("9p_blue_btn_hover_r"), + BLUE_BTN_HOVER_RB("9p_blue_btn_hover_rb"), + BLUE_BTN_HOVER_RT("9p_blue_btn_hover_rt"), + BLUE_BTN_HOVER_T("9p_blue_btn_hover_t"), + BLUE_BTN_NORMAL_B("9p_blue_btn_normal_b"), + BLUE_BTN_NORMAL_L("9p_blue_btn_normal_l"), + BLUE_BTN_NORMAL_LB("9p_blue_btn_normal_lb"), + BLUE_BTN_NORMAL_LT("9p_blue_btn_normal_lt"), + BLUE_BTN_NORMAL_R("9p_blue_btn_normal_r"), + BLUE_BTN_NORMAL_RB("9p_blue_btn_normal_rb"), + BLUE_BTN_NORMAL_RT("9p_blue_btn_normal_rt"), + BLUE_BTN_NORMAL_T("9p_blue_btn_normal_t"), + // text input box TEXT_INPUT_BOX_HOVER_B("9p_text_input_box_hover_b"), TEXT_INPUT_BOX_HOVER_L("9p_text_input_box_hover_l"), @@ -226,6 +244,7 @@ public enum ImageResources { ICON_TITLE_PROCESSOR("icon_title_processor"), ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"), ICON_TITLE_TREE_CLOSED("icon_title_tree_closed"), + ICON_BLUE_BUTTON_OPEN("icon_blue_btn_open"), // profile select button BTN_PROFILE_MOBILE_SELECTED("btn_profile_mobile_selected"), diff --git a/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java b/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java index 1bcb0b3..fb6baa7 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java @@ -35,6 +35,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchResourceInfo; @@ -68,6 +69,10 @@ public class PatchImageResources { /** Image should be disposed by caller */ public static Image getNinePatchButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) { + if (ninePatchImagesInfo == null) { + return null; + } + Image image = new Image(Display.getCurrent(), width, height); GC gc = new GC(image); gc.setInterpolation(SWT.NONE); @@ -77,6 +82,8 @@ public class PatchImageResources { gc.setBackground(transparentColor); gc.fillRectangle(0, 0, width, height); + + // Draw Image drawNinePatchImage(gc, width, height, ninePatchImagesInfo); gc.dispose(); @@ -94,6 +101,47 @@ public class PatchImageResources { /** Image should be disposed by caller */ + public static Image getBlueButtonImage(Image icon, int width, int height, NinePatchResourceInfo ninePatchImagesInfo) { + + if (ninePatchImagesInfo == null) { + return null; + } + + Image image = new Image(Display.getCurrent(), width, height); + GC gc = new GC(image); + gc.setInterpolation(SWT.NONE); + + // First, fill background to make corner transparent. + Color transparentColor = ninePatchImagesInfo.getTransparentColor().getColor(); + gc.setBackground(transparentColor); + gc.fillRectangle(0, 0, width, height); + + + // Draw Image + drawNinePatchImage(gc, width, height, ninePatchImagesInfo); + + // Draw icon + if (icon != null) { + Rectangle rect = icon.getBounds(); + gc.drawImage(icon, (width - rect.width) / 2, (height - rect.height) / 2); + } + + gc.dispose(); + + // Make corner transparent + ImageData data = image.getImageData(); + int cornerPixel = data.palette.getPixel(transparentColor.getRGB()); + data.transparentPixel = cornerPixel; + Image cornerTransparentedImage = new Image(Display.getCurrent(), data); + + // dispose original image + image.dispose(); + + return cornerTransparentedImage; + } + + + /** Image should be disposed by caller */ public static Image getComboPopupImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) { Image image = new Image(Display.getCurrent(), width, height); GC gc = new GC(image); diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java index 2f7b60b..da74131 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java @@ -48,6 +48,7 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem; import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem; import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem; import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceTemplateItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.FileSharingItem; import org.tizen.emulator.manager.vms.VMProperty; import org.tizen.emulator.manager.vms.VMPropertyValue; @@ -93,6 +94,7 @@ public class VMModifyHandler { itemList.add(new ProcessorItem(deviceItem.getTreeRoot())); itemList.add(new SensorItem(deviceItem.getTreeRoot(), null)); itemList.add(new ConnectivityItem(deviceItem.getTreeRoot(), null)); + itemList.add(new FileSharingItem()); diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java index 57ad2e2..5004c4b 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java @@ -37,8 +37,8 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem; public class ConnectivityItem extends CheckBoxItem { - private static final String TITLE = "Device"; - private static final String NAME = "device"; + private static final String TITLE = "Connectivity"; + private static final String NAME = "connectivity"; // private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE; private static final int NUM_COLUMN = 3; diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/FileDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/FileDialogItem.java new file mode 100644 index 0000000..a2334ad --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/FileDialogItem.java @@ -0,0 +1,145 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Minkee Lee + * JiHye Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.manager.ui.renewal.item.modify.common; + +import java.io.File; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.BlueButton; +import org.tizen.emulator.manager.ui.renewal.widgets.TextBox; + + + +public abstract class FileDialogItem extends ModifyDialogItem { + + protected TextBox textBox; + protected String filePath; + private BlueButton fileDialogButton; + + private final static int BUTTON_SPACE = 5; + private final static int BUTTON_WIDTH = 32; + private final static int BUTTON_HEIGHT = ModifyItem.WIDGET_HEIGHT; + + private DirectoryDialog dd; + + public FileDialogItem(String name, String title) { + super(name, title); + } + + + protected void create(Composite parent, String title, + ImageResources iconResource, int textBoxWidth) { + item = new ModifyItem(); + item.init(parent); + item.setItemTitle(new IconItemTitle(item.getItemComp(), title, iconResource)); + item.create(); + + makeBody(textBoxWidth); + } + + private void makeBody(int textBoxWidth) { + + item.setBodyLayoutForm(); + + createTextBox(textBoxWidth); + createFileDialogButton(); + } + + + public void setTextBox(String path) { + if (path == null || path.isEmpty()) { + return; + } + + String fileName = path.substring(path + .lastIndexOf(File.separator) + 1, path.length()); + textBox.setText(fileName); + textBox.setToolTipText(path); + } + + + private void createTextBox(int textBoxWidth) { + FormData data = new FormData(); + data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP); + data.width = textBoxWidth; + data.height = ModifyItem.WIDGET_HEIGHT; + textBox = new TextBox(item.getBody(), SWT.NONE); + textBox.setLayoutData(data); + + } + + private void createFileDialogButton() { + FormData data = new FormData(); + data.left = new FormAttachment(textBox, BUTTON_SPACE); + data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP); + data.width = BUTTON_WIDTH; + data.height = BUTTON_HEIGHT; + fileDialogButton = new BlueButton(item.getBody(), SWT.PUSH); + fileDialogButton.setIcon(ImageResources.ICON_BLUE_BUTTON_OPEN); + fileDialogButton.setLayoutData(data); + + addButtonListener(); + } + + + private void addButtonListener() { + fileDialogButton.addListener(SWT.Selection, new Listener(){ + @Override + public void handleEvent(Event event) { + if (event.type == SWT.Selection) { + if (dd == null) { + dd = new DirectoryDialog( + getDialog().getShell(), SWT.OPEN); + dd.setText("Select directory"); + } + String path = dd.open(); + if (path != null) { + filePath = path; + setTextBox(filePath); + fileSelected(); + } + } + } + }); + } + + public abstract void fileSelected(); +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java index a114de5..9dac2a0 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java @@ -142,4 +142,9 @@ public abstract class ModifyDialogItem implements IModifyDialogItem { } item.getItemComp().moveAbove(null); // move to top } + + @Override + public int getHeight() { + return item.getHeight(); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java index 84c9cdc..d28fd5e 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java @@ -61,10 +61,10 @@ public class NameItem extends TextInputBoxItem { @Override public void changeItem(ModifyDialogItem srcDialogItem) { - if (textBox == null || textBox.isDisposed()) { + if (textInputBox == null || textInputBox.isDisposed()) { return; } - textBox.setText(value); + textInputBox.setText(value); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java index 4da6e8f..03413e6 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java @@ -123,6 +123,7 @@ public class ProfileItem extends ModifyDialogItem { // set image drawProfileImage(); + imageCanvas.setToolTipText(currentProfile); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java index 316d3cd..094b181 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java @@ -47,7 +47,7 @@ import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper; public abstract class TextInputBoxItem extends ModifyDialogItem { - protected TextInputBox textBox; + protected TextInputBox textInputBox; protected String value = ""; @@ -73,7 +73,6 @@ public abstract class TextInputBoxItem extends ModifyDialogItem { makeBody(textBoxWidth); - } @@ -95,15 +94,15 @@ public abstract class TextInputBoxItem extends ModifyDialogItem { data.widthHint = textBoxWidth; data.grabExcessVerticalSpace = true; data.verticalAlignment = SWT.CENTER; - textBox = new TextInputBox(item.getBody(), SWT.NONE); - textBox.setLayoutData(data); + textInputBox = new TextInputBox(item.getBody(), SWT.NONE); + textInputBox.setLayoutData(data); - textBox.setText(value); + textInputBox.setText(value); addTextListener(); } private void addTextListener() { - textBox.getTextWidget().addModifyListener(new ModifyListener() { + textInputBox.getTextWidget().addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java index d32b5f9..e0e6fe5 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java @@ -32,6 +32,7 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.comp; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -76,6 +77,22 @@ public class PropertyValue { return templateValue != null; } + public String getFileSharingPath() { + if (isVMValue()) { + return vmValue.fileSharePath; + } + + return ""; + } + + public void setFileSharingPath(String path) { + if (isVMValue()) { + vmValue.fileSharePath = path; + vmValue.fileSharePathName = path.substring(path + .lastIndexOf(File.separator) + 1, path.length()); + } + } + public DeviceTemplate getDeivceTemplate() { if (isVMValue()) { return vmValue.device; diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/FileSharingItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/FileSharingItem.java new file mode 100644 index 0000000..2e97e85 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/FileSharingItem.java @@ -0,0 +1,90 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Minkee Lee + * JiHye Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.manager.ui.renewal.item.modify.vm; + +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue; + +public class FileSharingItem extends FileDialogItem { + + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_FILESHARING; + private static final String NAME="fileSharing"; + private static final String TITLE="File Sharing"; + private final int TEXT_BOX_WIDTH = 233; + + private String sharingPath; + + public FileSharingItem() { + super(NAME, TITLE); + } + + + @Override + public void create(Composite parent) { + create(parent, getTitle(), TITLE_ICON_RESOURCE, TEXT_BOX_WIDTH); + if (sharingPath == null || sharingPath.isEmpty()) { + setTextBox("(select sharing path...)"); + + } else { + setTextBox(sharingPath); + } + } + + + @Override + public void setInitialValue(PropertyValue value) { + sharingPath = value.getFileSharingPath(); + } + + @Override + public void setValue(PropertyValue value) { + if (sharingPath == null || sharingPath.isEmpty()) { + return; + } + + value.setFileSharingPath(sharingPath); + } + + @Override + public ModifyDialogItem cloneItem() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void fileSelected() { + sharingPath = filePath; + } + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/BlueButton.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/BlueButton.java new file mode 100644 index 0000000..b8b6c67 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/BlueButton.java @@ -0,0 +1,145 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Minkee Lee + * JiHye Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.manager.ui.renewal.widgets; + +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.renewal.resources.PatchImageResources; + +public class BlueButton extends NinePatchButton { + + private static NinePatchResourceMap ninePatchResourceMap; + private ImageResources icon; + private Image iconImage = null; + + public BlueButton(Composite parent, int style) { + super(parent, style); + initNinePatchResourceMap(); + } + + public void setIcon(ImageResources imageResource) { + icon = imageResource; + } + + @Override + public void drawPushImage(GC gc, WSTATE state, int width, int height) { + Image image = null; + if (iconImage == null && icon != null) { + iconImage = icon.getImage(); + } + + + switch(state) { + case HOVER: + if (hoverImage == null) { + hoverImage = PatchImageResources.getBlueButtonImage(iconImage, width, height, + getNinePatchResourceMap().get(state)); + } + image = hoverImage; + break; + case PUSH: + if (pushImage == null) { + pushImage = PatchImageResources.getBlueButtonImage(iconImage, width, height, + getNinePatchResourceMap().get(state)); + } + image = pushImage; + break; + case DISABLE_ON: + if (disableImage == null) { + disableImage = PatchImageResources.getBlueButtonImage(iconImage, width, height, + getNinePatchResourceMap().get(state)); + } + image = disableImage; + break; + default: + if (normalImage == null) { + normalImage = PatchImageResources.getBlueButtonImage(iconImage, width, height, + getNinePatchResourceMap().get(WSTATE.NORMAL)); + } + image = normalImage; + break; + } + + if (image == null) { + return; + } + + Rectangle rect = image.getBounds(); + gc.drawImage(image, rect.x, rect.y); + + } + + + private static void initNinePatchResourceMap() { + ninePatchResourceMap = new NinePatchResourceMap(); + ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.BLUE_BTN, + ColorResources.RED, + ImageResources.BLUE_BTN_NORMAL_LT, + ImageResources.BLUE_BTN_NORMAL_T, + ImageResources.BLUE_BTN_NORMAL_RT, + ImageResources.BLUE_BTN_NORMAL_R, + ImageResources.BLUE_BTN_NORMAL_RB, + ImageResources.BLUE_BTN_NORMAL_B, + ImageResources.BLUE_BTN_NORMAL_LB, + ImageResources.BLUE_BTN_NORMAL_L); + + ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.BLUE_BTN, + ColorResources.RED, + ImageResources.BLUE_BTN_HOVER_LT, + ImageResources.BLUE_BTN_HOVER_T, + ImageResources.BLUE_BTN_HOVER_RT, + ImageResources.BLUE_BTN_HOVER_R, + ImageResources.BLUE_BTN_HOVER_RB, + ImageResources.BLUE_BTN_HOVER_B, + ImageResources.BLUE_BTN_HOVER_LB, + ImageResources.BLUE_BTN_HOVER_L); + + ninePatchResourceMap.setImages(WSTATE.PUSH, ColorResources.BLUE_BTN, + ColorResources.RED, + ImageResources.BLUE_BTN_HOVER_LT, + ImageResources.BLUE_BTN_HOVER_T, + ImageResources.BLUE_BTN_HOVER_RT, + ImageResources.BLUE_BTN_HOVER_R, + ImageResources.BLUE_BTN_HOVER_RB, + ImageResources.BLUE_BTN_HOVER_B, + ImageResources.BLUE_BTN_HOVER_LB, + ImageResources.BLUE_BTN_HOVER_L); + } + + @Override + public NinePatchResourceMap getNinePatchResourceMap() { + return ninePatchResourceMap; + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/ImageButton.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/ImageButton.java index a4130a0..0eb6c04 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/ImageButton.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ImageButton.java @@ -190,7 +190,7 @@ public class ImageButton extends Canvas { return fontColors.get(state.getId()); } - protected Image nomalImage = null; + protected Image normalImage = null; protected Image hoverImage = null; protected Image pushImage = null;; protected Image disableImage = null; @@ -210,10 +210,10 @@ public class ImageButton extends Canvas { image = pushImage; break; default: - if (nomalImage == null) { + if (normalImage == null) { // nomalImage = PatchImageResources.getNomalButton(width); } - image = nomalImage; + image = normalImage; break; } @@ -334,7 +334,7 @@ public class ImageButton extends Canvas { i = s.getId(); WidgetHelper.tryDispose(images.get(i), colors.get(i), fontColors.get(i), fonts.get(i)); } - WidgetHelper.tryDispose(nomalImage, hoverImage, pushImage, disableImage); + WidgetHelper.tryDispose(normalImage, hoverImage, pushImage, disableImage); } }; diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchButton.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchButton.java index 4d9d494..d5885d0 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchButton.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchButton.java @@ -67,6 +67,7 @@ public abstract class NinePatchButton extends ImageButton { @Override public void drawPushImage(GC gc, WSTATE state, int width, int height) { Image image = null; + switch(state) { case HOVER: if (hoverImage == null) { @@ -90,15 +91,20 @@ public abstract class NinePatchButton extends ImageButton { image = disableImage; break; default: - if (nomalImage == null) { - nomalImage = PatchImageResources.getNinePatchButtonImage(width, height, + if (normalImage == null) { + normalImage = PatchImageResources.getNinePatchButtonImage(width, height, getNinePatchResourceMap().get(WSTATE.NORMAL)); } - image = nomalImage; + image = normalImage; break; } + if (image == null) { + return; + } + Rectangle rect = image.getBounds(); gc.drawImage(image, rect.x, rect.y); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/TextBox.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/TextBox.java new file mode 100644 index 0000000..0e4455d --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/TextBox.java @@ -0,0 +1,146 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.manager.ui.renewal.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.FontResources; +import org.tizen.emulator.manager.renewal.resources.ImageResources; + +public class TextBox extends NinePatchBox { + + private static NinePatchResourceMap ninePatchResourceMap; + + private final int TEXT_MARGIN_HEIGHT = 2; + private final int TEXT_MARGIN_WIDTH = 6; + + private String text = ""; + private Canvas canvas; + + public TextBox(Composite parent, int style) { + super(parent, style); + initNinePatchResourceMap(); + initBox(); + createCanvas(); + } + + + @Override + public void setToolTipText(String text) { + super.setToolTipText(text); + canvas.setToolTipText(text); + } + + + @Override + public NinePatchResourceMap getNinePatchResourceMap() { + return ninePatchResourceMap; + } + + public void setText(String text) { + this.text = text; + canvas.redraw(); + } + + public String getText() { + return text; + } + + private void initBox() { + GridLayout layout = new GridLayout(); + layout.marginHeight = TEXT_MARGIN_HEIGHT; + layout.marginWidth = TEXT_MARGIN_WIDTH; + layout.numColumns = 1; + this.setLayout(layout); + } + + + private void createCanvas() { + GridData data = new GridData(); + data.grabExcessHorizontalSpace = true; + data.grabExcessVerticalSpace = true; + data.horizontalAlignment = SWT.FILL; + data.verticalAlignment = SWT.FILL; + + canvas = new Canvas(this, SWT.NONE); + canvas.setLayoutData(data); + + addCanvasListener(); + } + + + private void addCanvasListener() { + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + + GC gc = e.gc; + gc.setForeground(ColorResources.TEXTBOX_DISABLE.getColor()); + gc.setFont(FontResources.CONTENT.getFont()); + + int itemHeight = ((Composite)e.widget).getBounds().height; + Point textExt = gc.textExtent(text); + int posY = (itemHeight - textExt.y) / 2; + + int posX = 0; + int itemWidth = ((Composite)e.widget).getBounds().width; + posX = (itemWidth - textExt.x)/ 2; + gc.drawText(text, posX, posY); + } + + }); + } + + + + + private static void initNinePatchResourceMap() { + ninePatchResourceMap = new NinePatchResourceMap(); + ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE, + ColorResources.BLACK, + ImageResources.TEXT_INPUT_BOX_NORMAL_LT, + ImageResources.TEXT_INPUT_BOX_NORMAL_T, + ImageResources.TEXT_INPUT_BOX_NORMAL_RT, + ImageResources.TEXT_INPUT_BOX_NORMAL_R, + ImageResources.TEXT_INPUT_BOX_NORMAL_RB, + ImageResources.TEXT_INPUT_BOX_NORMAL_B, + ImageResources.TEXT_INPUT_BOX_NORMAL_LB, + ImageResources.TEXT_INPUT_BOX_NORMAL_L); + } +}