From df1bfb6e1b99b0762a3cbfb81c031e887273663a Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Fri, 2 Oct 2015 19:11:51 +0900 Subject: [PATCH] ui: adding device-template item. - Add Display, Ram, Processor, Sensor, Device item. (UI only) Change-Id: Id290c477165b9a1f6f5e3687f7cc1cc082e831bc Signed-off-by: minkee.lee --- .../renewal/res/btn_checkbox_checked_hover.png | Bin 0 -> 3172 bytes resource/renewal/res/btn_checkbox_checked_nml.png | Bin 0 -> 3157 bytes .../renewal/res/btn_checkbox_unchecked_hover.png | Bin 0 -> 2909 bytes .../renewal/res/btn_checkbox_unchecked_nml.png | Bin 0 -> 2870 bytes .../tizen/emulator/manager/EmulatorManager.java | 5 +- .../manager/handler/renewal/VMModifyHandler.java | 26 +- .../manager/renewal/resources/ColorResources.java | 2 + .../manager/renewal/resources/FontResources.java | 3 +- .../manager/renewal/resources/ImageResources.java | 23 +- .../renewal/resources/PatchImageResources.java | 68 +++-- .../emulator/manager/ui/renewal/dialog/Dialog.java | 9 +- .../manager/ui/renewal/dialog/DialogTitle.java | 11 +- .../manager/ui/renewal/dialog/DragHandler.java | 8 +- .../manager/ui/renewal/dialog/VMModifyDialog.java | 20 +- .../ui/renewal/item/modify/vm/CheckBoxItem.java | 80 ++++++ .../ui/renewal/item/modify/vm/CheckBoxSubItem.java | 110 ++++++++ .../ui/renewal/item/modify/vm/ComboItem.java | 88 ++++++ .../ui/renewal/item/modify/vm/DeviceItem.java | 81 ++++++ .../renewal/item/modify/vm/DeviceTemplateItem.java | 83 ++++++ .../ui/renewal/item/modify/vm/DisplayItem.java | 213 +++++++++++++++ .../modify/vm/{common => }/IModifyDialogItem.java | 4 +- .../ui/renewal/item/modify/vm/ImageItem.java | 3 +- .../renewal/item/modify/vm/ModifyDialogItem.java | 47 ++++ .../ui/renewal/item/modify/vm/ProcessorItem.java | 82 ++++++ .../ui/renewal/item/modify/vm/ProfileItem.java | 12 +- .../ui/renewal/item/modify/vm/RamSizeItem.java | 93 +++++++ .../ui/renewal/item/modify/vm/SensorItem.java | 85 ++++++ .../item/modify/vm/{common => }/TextLabelItem.java | 22 +- .../ui/renewal/item/modify/vm/VMNameItem.java | 3 +- .../item/modify/vm/common/IconItemTitle.java | 49 ++++ .../renewal/item/modify/vm/common/ItemTitle.java | 54 ++-- .../renewal/item/modify/vm/common/ModifyItem.java | 64 +++-- .../item/modify/vm/common/SubTreeItemTitle.java | 50 ++++ .../item/modify/vm/common/SubTreeModifyItem.java | 31 +++ .../item/modify/vm/common/TreeItemTitle.java | 119 +++++++++ .../item/modify/vm/common/TreeModifyItem.java | 60 +++++ .../manager/ui/renewal/widgets/CheckBoxButton.java | 197 ++++++++++++++ .../manager/ui/renewal/widgets/ComboBox.java | 293 ++++++++++++++++++++ .../manager/ui/renewal/widgets/ComboBoxPopup.java | 296 +++++++++++++++++++++ .../ui/renewal/widgets/CreateVMComboPopup.java | 6 +- .../manager/ui/renewal/widgets/NinePatchBox.java | 11 + .../manager/ui/renewal/widgets/TextInputBox.java | 19 +- .../manager/ui/renewal/widgets/WidgetHelper.java | 38 ++- 43 files changed, 2343 insertions(+), 125 deletions(-) create mode 100644 resource/renewal/res/btn_checkbox_checked_hover.png create mode 100644 resource/renewal/res/btn_checkbox_checked_nml.png create mode 100644 resource/renewal/res/btn_checkbox_unchecked_hover.png create mode 100644 resource/renewal/res/btn_checkbox_unchecked_nml.png create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxSubItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ComboItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DisplayItem.java rename src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/{common => }/IModifyDialogItem.java (91%) create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ModifyDialogItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProcessorItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/RamSizeItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SensorItem.java rename src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/{common => }/TextLabelItem.java (80%) create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IconItemTitle.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeItemTitle.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeModifyItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeItemTitle.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeModifyItem.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/widgets/CheckBoxButton.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java create mode 100644 src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java diff --git a/resource/renewal/res/btn_checkbox_checked_hover.png b/resource/renewal/res/btn_checkbox_checked_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..4581d0914525d7dfc499ae19a169591ac473b722 GIT binary patch literal 3172 zcmV-q44dKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Z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hoq7NaHkPx0cE!Q@4I_&iBu0iYv$~7ZC6g8##cWpt zxAtfKW&n%7iK(_)%qAZ+O`~OOj-8WB02+%jNr(v5=^=bBQez_-YN~t}$|#C-ROC^g zpYg2=!qdNHD@c7dDuL<*Dd}-aQHn=~=pR=v5Od34r*8u?D=zKZAOw)J(0000< KMNUMnLSTYPS>_G^ literal 0 HcmV?d00001 diff --git a/resource/renewal/res/btn_checkbox_checked_nml.png b/resource/renewal/res/btn_checkbox_checked_nml.png new file mode 100644 index 0000000000000000000000000000000000000000..37ee0e4c242dba6299370ea6e01e6749bbfd23cf GIT binary patch literal 3157 zcmV-b465^qP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##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LXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0004iNkl1vj{^p-?-Pj-^gIqEzDbqwVB$p}5WkDv&!onz7$)#LM zO|y`cm5nG1vQly>c9s~oX@rEW#;wsmbF6;hcNx#_eCNF1_w~LWwacLye;5g`OqGjklB_yMT2+ek}I*7%|Scra&W(9z!fZj>ZR)H|zi zlv}?|LI1T-SM9)FRti9lIg^$~Cnl5e#~-7i)78S&^$pJ23KA3If6QOE>AMiW<*f1; vdSx$g3xJ~_L-%R2dhs9hYL{sF`2KAGmPvg+*Yq{X00000NkvXXu0mjfnN{RQ literal 0 HcmV?d00001 diff --git a/resource/renewal/res/btn_checkbox_unchecked_hover.png b/resource/renewal/res/btn_checkbox_unchecked_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..58a33bc7f8a064890c62f8e1ac14847927e923b5 GIT binary patch literal 2909 zcmV-j3!?OiP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B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resource/renewal/res/btn_checkbox_unchecked_nml.png new file mode 100644 index 0000000000000000000000000000000000000000..9ba00831101170e2a852b9cb45e62c503fb856bf GIT binary patch literal 2870 zcmV-63(53}P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gF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joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001CNkl getItemList(VMProperty property) { + private static List getItemList(VMProperty property) { // TODO make item list using Image's item-template return getTmpItemList(); } - // FOR TEST - public static List getTmpItemList() { - List itemList = new ArrayList(); + // FOR TES + public static List getTmpItemList() { + List itemList = new ArrayList(); itemList.add(new VMNameItem()); itemList.add(new ProfileItem()); itemList.add(new ImageItem()); + DeviceTemplateItem deviceItem = new DeviceTemplateItem(); + itemList.add(deviceItem); + itemList.add(new DisplayItem(deviceItem.getTreeRoot())); + itemList.add(new RamSizeItem(deviceItem.getTreeRoot())); + itemList.add(new ProcessorItem(deviceItem.getTreeRoot())); + itemList.add(new SensorItem(deviceItem.getTreeRoot())); + itemList.add(new DeviceItem(deviceItem.getTreeRoot())); + + + return itemList; } diff --git a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java index 16c1825..1b782a4 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java @@ -37,6 +37,8 @@ public enum ColorResources { WHITE(255, 255, 255), BLACK(0, 0, 0), RED(255, 0, 0), + BLUE(0, 0, 255), + GREEN(0, 255, 0), // nine patch button GRAY_BTN_NORMAL(149, 159, 164), diff --git a/src/org/tizen/emulator/manager/renewal/resources/FontResources.java b/src/org/tizen/emulator/manager/renewal/resources/FontResources.java index 6c3202a..d97a4ab 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/FontResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/FontResources.java @@ -48,7 +48,8 @@ public enum FontResources { MESSAGE_BOX_CONTENTS("msg_box_contents", resizeDefaultFont(9)), DEFAULT_FONT_10("default_font_10", resizeDefaultFont(10)), - DEFAULT_FONT_9("default_font_9", resizeDefaultFont(9)); + DEFAULT_FONT_9("default_font_9", resizeDefaultFont(9)), + DEFAULT_FONT_8("default_font_8", resizeDefaultFont(8)); public static FontResources MODIFY_ITEM_TITLE = DEFAULT_FONT_9; public static FontResources CONTENT = DEFAULT_FONT_9; diff --git a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java index 7ab25e4..ce9898d 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java @@ -210,6 +210,22 @@ public enum ImageResources { ICON_TITLE_VMNAME("icon_title_vmname"), ICON_TITLE_IMAGE("icon_title_image"), ICON_TITLE_PROFILE("icon_title_profile"), + ICON_TITLE_DISPLAY("icon_title_display"), + ICON_TITLE_RAM("icon_title_ram"), + ICON_TITLE_DEVICE("icon_title_device"), + ICON_TITLE_EXTERNAL_INPUT("icon_title_externalinput"), + ICON_TITLE_FILESHARING("icon_title_filesharing"), + ICON_TITLE_HWSUPPORT("icon_title_hwsupport"), + ICON_TITLE_IMAGE_FILE("icon_title_imagefile"), + ICON_TITLE_JACK("icon_title_jack"), + ICON_TITLE_NETWORK("icon_title_network"), + ICON_TITLE_OCI_DEVICE("icon_title_ocidevice"), + ICON_TITLE_SENSOR("icon_title_sensor"), + ICON_TITLE_TUNER("icon_title_tuner"), + ICON_TITLE_VERSION("icon_title_version"), + ICON_TITLE_PROCESSOR("icon_title_processor"), + ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"), + ICON_TITLE_TREE_CLOSED("icon_title_tree_closed"), // profile select button BTN_PROFILE_MOBILE_SELECTED("btn_profile_mobile_selected"), @@ -220,8 +236,13 @@ public enum ImageResources { BTN_PROFILE_WEARABLEE_UNSELECTED_NML("btn_profile_wearable_unselected_nml"), BTN_PROFILE_TV_SELECTED("btn_profile_tv_selected"), BTN_PROFILE_TV_UNSELECTED_HOVER("btn_profile_tv_unselected_hover"), - BTN_PROFILE_TV_UNSELECTED_NML("btn_profile_tv_unselected_nml"); + BTN_PROFILE_TV_UNSELECTED_NML("btn_profile_tv_unselected_nml"), + // checkbox + CHECKBOX_UNCHECKED_NML("btn_checkbox_unchecked_nml"), + CHECKBOX_UNCHECKED_HOVER("btn_checkbox_unchecked_hover"), + CHECKBOX_CHECKED_NML("btn_checkbox_checked_nml"), + CHECKBOX_CHECKED_HOVER("btn_checkbox_checked_hover"); String name; Image image; diff --git a/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java b/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java index 4aa820a..1bcb0b3 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/PatchImageResources.java @@ -65,18 +65,10 @@ public class PatchImageResources { return image; } + /** Image should be disposed by caller */ public static Image getNinePatchButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) { - Image lt = ninePatchImagesInfo.getLeftTopImage().getImage(); - Image t = ninePatchImagesInfo.getTopImage().getImage(); - Image rt = ninePatchImagesInfo.getRightTopImage().getImage(); - Image r = ninePatchImagesInfo.getRightImage().getImage(); - Image rb = ninePatchImagesInfo.getRightBottomImage().getImage(); - Image b = ninePatchImagesInfo.getBottomImage().getImage(); - Image lb = ninePatchImagesInfo.getLeftBottomImage().getImage(); - Image l = ninePatchImagesInfo.getLeftImage().getImage(); Image image = new Image(Display.getCurrent(), width, height); - GC gc = new GC(image); gc.setInterpolation(SWT.NONE); @@ -85,7 +77,50 @@ public class PatchImageResources { gc.setBackground(transparentColor); gc.fillRectangle(0, 0, width, height); - // draw background + drawNinePatchImage(gc, width, height, ninePatchImagesInfo); + 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); + gc.setInterpolation(SWT.NONE); + + // Draw background + gc.setBackground(ColorResources.WHITE.getColor()); + gc.fillRectangle(0, 0, width, height); + + drawNinePatchImage(gc, width, height, ninePatchImagesInfo); + + gc.dispose(); + + return image; + } + + private static void drawNinePatchImage(GC gc, int width, int height, NinePatchResourceInfo ninePatchImagesInfo) { + Image lt = ninePatchImagesInfo.getLeftTopImage().getImage(); + Image t = ninePatchImagesInfo.getTopImage().getImage(); + Image rt = ninePatchImagesInfo.getRightTopImage().getImage(); + Image r = ninePatchImagesInfo.getRightImage().getImage(); + Image rb = ninePatchImagesInfo.getRightBottomImage().getImage(); + Image b = ninePatchImagesInfo.getBottomImage().getImage(); + Image lb = ninePatchImagesInfo.getLeftBottomImage().getImage(); + Image l = ninePatchImagesInfo.getLeftImage().getImage(); + + // draw center gc.setBackground(ninePatchImagesInfo.getBackground().getColor()); gc.fillRectangle(l.getImageData().width, t.getImageData().height, width - l.getImageData().width - r.getImageData().width, @@ -120,18 +155,5 @@ public class PatchImageResources { width - lb.getImageData().width - rb.getImageData().width, b.getImageData().height); gc.drawImage(rb, width - rb.getImageData().width, height - rb.getImageData().height); - 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; } - } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java index 6acc923..a09efac 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java @@ -31,6 +31,9 @@ package org.tizen.emulator.manager.ui.renewal.dialog; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; @@ -52,6 +55,7 @@ public class Dialog { private final int height; private final int buttonStyle; + private final List childShell = new ArrayList(); private Composite bodyComp; private int returnValue = SWT.CANCEL; @@ -85,6 +89,9 @@ public class Dialog { return shell; } + public void addChildShell(Shell shell) { + childShell.add(shell); + } public void setReturnValue(int returnValue) { this.returnValue = returnValue; @@ -99,7 +106,7 @@ public class Dialog { private void makeDialog() { - DialogTitle.create(shell, title); + DialogTitle.create(shell, childShell, title); initBody(); DialogButtons.create(this, buttonStyle); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/DialogTitle.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/DialogTitle.java index 1f2c887..07d6c1c 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/DialogTitle.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/DialogTitle.java @@ -31,6 +31,8 @@ package org.tizen.emulator.manager.ui.renewal.dialog; +import java.util.List; + import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -48,10 +50,10 @@ public class DialogTitle { private static final int TITLE_MARGIN_TOP = 7; private static final int TITLE_MARGIN_LEFT = 15; - public static void create(Shell parentDialog, String title) { + public static void create(Shell parentDialog, List childShell, String title) { Composite titleComp = new Composite(parentDialog, SWT.NONE); initTitleComp(parentDialog, titleComp); - makeTitle(parentDialog, titleComp, title); + makeTitle(parentDialog, childShell, titleComp, title); } @@ -70,7 +72,8 @@ public class DialogTitle { } - private static void makeTitle(Shell parentDialog, Composite titleComp, String title) { + private static void makeTitle(Shell parentDialog, + List childShell, Composite titleComp, String title) { // add title FormData data = new FormData(); data.top = new FormAttachment(0, TITLE_MARGIN_TOP); @@ -84,6 +87,6 @@ public class DialogTitle { titleLabel.setLayoutData(data); // make title drag-able - DragHandler.set(parentDialog, titleLabel, titleComp); + DragHandler.set(parentDialog, childShell, titleLabel, titleComp); } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/DragHandler.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/DragHandler.java index 6ebd363..aa50a0a 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/DragHandler.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/DragHandler.java @@ -31,6 +31,8 @@ package org.tizen.emulator.manager.ui.renewal.dialog; +import java.util.List; + import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; @@ -49,15 +51,15 @@ public class DragHandler { * @param shell * @param controls to receive drag event. */ - public static void set(Shell shell, Control... controls) { + public static void set(Shell shell, List childShell, Control... controls) { DragHandler controller = new DragHandler(); - controller.setTargetShell(shell); + controller.setTargetShell(shell, childShell); controller.setControls(controls); } // set dialog (shell) - private void setTargetShell(Shell shell) { + private void setTargetShell(Shell shell, List childShell) { this.dialog = shell; } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/VMModifyDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/VMModifyDialog.java index 4bb14ae..47eb65f 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/VMModifyDialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/VMModifyDialog.java @@ -40,18 +40,19 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.manager.renewal.resources.ColorResources; -import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem; import org.tizen.emulator.manager.vms.VMProperty; public class VMModifyDialog extends Dialog { private final static String TITLE = "VM Modify"; - private final static int WIDTH = 484; + public final static int WIDTH = 484; +// private final static int WIDTH = 500; private final static int HEIGHT = 496; private final static int BUTTON_STYLE = SWT.OK | SWT.CANCEL; private Composite scrolledContent; - private List itemList; + private List itemList; private VMProperty property; public VMModifyDialog(Shell parent) { @@ -59,7 +60,7 @@ public class VMModifyDialog extends Dialog { } - public void create(VMProperty property, List itemList) { + public void create(VMProperty property, List itemList) { // - create title, buttons // - init body super.create(); @@ -82,8 +83,9 @@ public class VMModifyDialog extends Dialog { } private void makeModifyItem() { - for (IModifyDialogItem item : itemList) { - item.setItemData(property); + for (ModifyDialogItem item : itemList) { + item.setParentDialog(this); + item.setInitialValue(property); item.create(scrolledContent); } @@ -93,12 +95,16 @@ public class VMModifyDialog extends Dialog { private void computeScrolledContentSize() { int height = 0; - for (IModifyDialogItem item : itemList) { + for (ModifyDialogItem item : itemList) { height += item.getHeight(); } scrolledContent.setSize(WIDTH - Dialog.BORDER_WIDTH * 2, height); } + public void layoutScrolledComposite() { + computeScrolledContentSize(); + scrolledContent.layout(); + } private void initScrolledComposite() { // add scrolled-composite diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxItem.java new file mode 100644 index 0000000..ccd8126 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxItem.java @@ -0,0 +1,80 @@ +/* + * 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.layout.GridData; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; + +public abstract class CheckBoxItem extends ModifyDialogItem { + + private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH; + private int rowNum; + private final int numColumns; + + // TODO should be structures that have name, title + private final String[] checkBoxList; + + public CheckBoxItem(int numColomn, String[] checkBoxList) { + this.numColumns = numColomn; + this.checkBoxList = checkBoxList; + initRowNum(); + } + + + private void initRowNum() { + rowNum = checkBoxList.length / numColumns; + if (checkBoxList.length % numColumns != 0) { + rowNum++; + } + } + + + protected int getContentHeight() { + return ROW_HEIGHT * rowNum; + } + + + protected void createCheckBoxItems(ModifyItem item) { + item.setBodyLayoutGrid(numColumns); + + CheckBoxSubItem checkBoxItem; + for (int i=0 ; i < checkBoxList.length ; i++) { + String sensor = checkBoxList[i]; + checkBoxItem = new CheckBoxSubItem(item.getBody(), sensor, sensor); + + // set checkbox item layout + GridData data = new GridData(); + data.heightHint = ROW_HEIGHT; + data.widthHint = ModifyItem.BODY_CONTENT_WIDTH / numColumns; + checkBoxItem.create(data); + } + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxSubItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxSubItem.java new file mode 100644 index 0000000..4c0f20f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CheckBoxSubItem.java @@ -0,0 +1,110 @@ +/* + * 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.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.FontResources; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.CheckBoxButton; + +public class CheckBoxSubItem { + private final Composite parentComp; + private final String name; + private final String title; + private boolean isChecked; + private Composite comp; + private CheckBoxButton checkBox; // TODO + + public static final int CHECK_BOX_WIDTH = 15; + private final int CHECK_BOX_HEIGHT = 14; + public static final int SPACING = 2; + + private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH; + + public CheckBoxSubItem(Composite parentComp, String name, String title) { + this.parentComp = parentComp; + this.name = name; + this.title = title; + } + + public void create(Object layoutData) { + // init comp + comp = new Composite(parentComp, SWT.NONE); + comp.setLayoutData(layoutData); + comp.setLayout(new FormLayout()); + + createCheckBox(); + drawTitle(); + } + + + private void createCheckBox() { + + FormData data = new FormData(CHECK_BOX_WIDTH, CHECK_BOX_HEIGHT); + data.left = new FormAttachment(0, 0); + data.top = new FormAttachment(0, (ROW_HEIGHT - CHECK_BOX_HEIGHT) / 2 ); + + // TODO change to checkBoxWidget + checkBox = new CheckBoxButton(comp, SWT.NONE); + checkBox.setLayoutData(data); + + } + + + private void drawTitle() { + comp.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.setForeground(ColorResources.CONTENT_FONT.getColor()); + gc.setFont(FontResources.CONTENT.getFont()); + + int itemHeight = ((Composite)e.widget).getBounds().height; + Point textExt = gc.textExtent(title); + int posY = (itemHeight - textExt.y) / 2; + + gc.drawText(title, CHECK_BOX_WIDTH + SPACING, posY); + } + }); + + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ComboItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ComboItem.java new file mode 100644 index 0000000..0e08d6f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ComboItem.java @@ -0,0 +1,88 @@ +/* + * 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.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; + + +public abstract class ComboItem extends ModifyDialogItem { + + private ComboBox comboBox; + + protected void createCombo(ModifyItem item, int width) { +// item.setBodyLayoutDefault(); +// +// // create combo widget +// GridData data = new GridData(width, COMBO_HEIGHT); +// data.grabExcessVerticalSpace = true; +// data.verticalAlignment = SWT.CENTER; + + item.getBody().setLayout(new FormLayout()); + FormData data = new FormData(); + data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP); + data.width = width; + data.height = ModifyItem.WIDGET_HEIGHT; + comboBox = new ComboBox(getParentDialog().getShell(), item.getBody(), SWT.NONE); + comboBox.setLayoutData(data); + addSelectionListener(); + } + + + private void addSelectionListener() { + Listener listener = new Listener() { + @Override + public void handleEvent(Event event) { + switch(event.type) { + case SWT.Selection: + itemSelected(comboBox); + + default: + break; + } + + } + }; + comboBox.addListener(SWT.Selection, listener); + } + + public void itemSelected(ComboBox comboBox) { + // This is called when combo item is selected + // TODO override this. + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceItem.java new file mode 100644 index 0000000..5ea947b --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceItem.java @@ -0,0 +1,81 @@ +/* + * 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.vm.common.SubTreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.vms.VMProperty; + +public class DeviceItem extends CheckBoxItem { + + private final SubTreeModifyItem item; + + private final String TITLE = "Device"; + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE; + + private static final int NUM_COLUMN = 3; + + // TODO load sensor list + private static final String[] sensorList = new String[]{"NFC", "Camera"}; + + public DeviceItem(TreeModifyItem treeRoot) { + super(NUM_COLUMN, sensorList); + item = new SubTreeModifyItem(); + item.setItemHeight(getContentHeight()); + treeRoot.addSubItem(item); + } + + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + + createCheckBoxItems(item); + + } + + @Override + public int getHeight() { + return item.getHeight(); + } + + @Override + public void setInitialValue(VMProperty property) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java new file mode 100644 index 0000000..9d837bc --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java @@ -0,0 +1,83 @@ +/* + * 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.ui.renewal.item.modify.vm.common.TreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; +import org.tizen.emulator.manager.vms.VMProperty; + +public class DeviceTemplateItem extends ComboItem { + + private final String TITLE = "Device"; + private final TreeModifyItem item; + + private final int COMBO_WIDTH = 200; + + public TreeModifyItem getTreeRoot() { + return item; + } + + public DeviceTemplateItem() { + item = new TreeModifyItem(); + } + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new TreeItemTitle(item, TITLE)); + item.create(); + + item.setModifyDialogItem(this); + + createCombo(item, COMBO_WIDTH); + } + + @Override + public int getHeight() { + return item.getHeight(); + } + + @Override + public void setInitialValue(VMProperty property) { + // TODO Auto-generated method stub + + } + + @Override + public void itemSelected(ComboBox comboBox) { + // TODO change item list for selected template. + System.out.println("item selected:" + comboBox.getSelectedItem()); + + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DisplayItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DisplayItem.java new file mode 100644 index 0000000..c1595b5 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DisplayItem.java @@ -0,0 +1,213 @@ +/* + * 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.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; +import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox; +import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper; +import org.tizen.emulator.manager.vms.VMProperty; + +public class DisplayItem extends ModifyDialogItem { + + private final SubTreeModifyItem item; + + private final String TITLE = "Display"; + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DISPLAY; + + private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH; + private final int ROW_NUM = 4; + + public DisplayItem(TreeModifyItem treeRoot) { + item = new SubTreeModifyItem(); + item.setItemHeight(ROW_HEIGHT * ROW_NUM); + treeRoot.addSubItem(item); + } + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + + item.setBodyLayoutDefault(); + createResolutionComboItem(); + createResolutionTextItem(); + createSizeItem(); + createSkinItem(); + } + + + @Override + public int getHeight() { + return item.getHeight(); + } + + + @Override + public void setInitialValue(VMProperty property) { + + } + + + private final String TITLE_RESOLUTION = "Resolution"; + private final String TITLE_SIZE = "Size"; + private final String TITLE_SKIN = "Skin"; + + private final int BODY_MARGIN_LEFT = 66; + + private final int COMBO_WIDTH = 134; + private final int TEXT_BOX_WIDTH = 58; + private final int RESOLUTION_TEXT_BOX_SPACING = 18; + private final int WIDGET_TOP = (ROW_HEIGHT - ModifyItem.WIDGET_HEIGHT) / 2; + + + private ComboBox resolutionCombo = null; + private TextInputBox widthTextBox = null; + private TextInputBox heightTextBox = null; + private TextInputBox sizeTextBox = null; + private ComboBox skinCombo = null; + + + private void createResolutionComboItem() { + Composite comp = createSubComp(1, TITLE_RESOLUTION); + + FormData data = new FormData(); + data.left = new FormAttachment(0, BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = COMBO_WIDTH; + data.height = ModifyItem.WIDGET_HEIGHT; + resolutionCombo = new ComboBox(getParentDialog().getShell(), comp, SWT.NONE); + resolutionCombo.setLayoutData(data); + + } + + private void createResolutionTextItem() { + Composite comp = createSubComp(1, ""); + + // width + FormData data = new FormData(); + data.left = new FormAttachment(0, BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = TEXT_BOX_WIDTH; + data.height = ModifyItem.WIDGET_HEIGHT; + widthTextBox = new TextInputBox(comp, SWT.NONE); + widthTextBox.setLayoutData(data); + + // "x" label + data = new FormData(); + data.left = new FormAttachment(widthTextBox, 0); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = RESOLUTION_TEXT_BOX_SPACING; + data.height = ModifyItem.WIDGET_HEIGHT; + Canvas canvas = new Canvas(comp, SWT.NONE); + canvas.setLayoutData(data); + WidgetHelper.drawText(canvas, "x", SWT.CENTER); + + + // height + data = new FormData(); + data.left = new FormAttachment(widthTextBox, RESOLUTION_TEXT_BOX_SPACING); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = TEXT_BOX_WIDTH; + data.height = ModifyItem.WIDGET_HEIGHT; + heightTextBox = new TextInputBox(comp, SWT.NONE); + heightTextBox.setLayoutData(data); + + } + + + private void createSizeItem() { + Composite comp = createSubComp(1, TITLE_SIZE); + + // text box + FormData data = new FormData(); + data.left = new FormAttachment(0, BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = TEXT_BOX_WIDTH; + data.height = ModifyItem.WIDGET_HEIGHT; + sizeTextBox = new TextInputBox(comp, SWT.NONE); + sizeTextBox.setLayoutData(data); + + // "inch" label + data = new FormData(); + data.left = new FormAttachment(sizeTextBox, 6); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = 30; // rough guess + data.height = ModifyItem.WIDGET_HEIGHT; + Canvas canvas = new Canvas(comp, SWT.NONE); + canvas.setLayoutData(data); + WidgetHelper.drawText(canvas, "inch", SWT.NONE); + } + + + private void createSkinItem() { + Composite comp = createSubComp(1, TITLE_SKIN); + + FormData data = new FormData(); + data.left = new FormAttachment(0, BODY_MARGIN_LEFT); + data.top = new FormAttachment(0, WIDGET_TOP); + data.width = COMBO_WIDTH; + data.height = ModifyItem.WIDGET_HEIGHT; + skinCombo = new ComboBox(getParentDialog().getShell(), comp, SWT.NONE); + skinCombo.setLayoutData(data); + } + + + private Composite createSubComp(int rowNum, String title) { + GridData data = new GridData(); + data.grabExcessHorizontalSpace = true; + data.horizontalAlignment = SWT.FILL; + data.heightHint = ROW_HEIGHT * rowNum; + + Composite comp = new Composite(item.getBody(), SWT.NONE); + comp.setLayoutData(data); + comp.setLayout(new FormLayout()); + + WidgetHelper.drawText(comp, title, SWT.NONE); + return comp; + } + + + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IModifyDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/IModifyDialogItem.java similarity index 91% rename from src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IModifyDialogItem.java rename to src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/IModifyDialogItem.java index b6654d0..7a47a09 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IModifyDialogItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/IModifyDialogItem.java @@ -27,7 +27,7 @@ * - S-Core Co., Ltd * */ -package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common; +package org.tizen.emulator.manager.ui.renewal.item.modify.vm; import org.eclipse.swt.widgets.Composite; import org.tizen.emulator.manager.vms.VMProperty; @@ -39,5 +39,5 @@ public interface IModifyDialogItem { /** To decide modify dialog */ public int getHeight(); - public void setItemData(VMProperty property); + public void setInitialValue(VMProperty property); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ImageItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ImageItem.java index bdad2df..030e3e5 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ImageItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ImageItem.java @@ -32,7 +32,6 @@ 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.vm.common.TextLabelItem; import org.tizen.emulator.manager.vms.VMProperty; public class ImageItem extends TextLabelItem { @@ -46,7 +45,7 @@ public class ImageItem extends TextLabelItem { } @Override - public void setItemData(VMProperty property) { + public void setInitialValue(VMProperty property) { if (property == null) { return; } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ModifyDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ModifyDialogItem.java new file mode 100644 index 0000000..e4fa35a --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ModifyDialogItem.java @@ -0,0 +1,47 @@ +/* + * 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.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog; + +public abstract class ModifyDialogItem implements IModifyDialogItem { + private VMModifyDialog parentDialog; + + public VMModifyDialog getParentDialog() { + return parentDialog; + } + + public void setParentDialog(VMModifyDialog parentDialog) { + this.parentDialog = parentDialog; + } + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProcessorItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProcessorItem.java new file mode 100644 index 0000000..eccfa50 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProcessorItem.java @@ -0,0 +1,82 @@ +/* + * 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.vm.common.SubTreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; +import org.tizen.emulator.manager.vms.VMProperty; + +public class ProcessorItem extends ComboItem { + + private final SubTreeModifyItem item; + + private final String TITLE = "Processor"; + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROCESSOR; + private final int COMBO_WIDTH = 124; + + public ProcessorItem(TreeModifyItem treeRoot) { + item = new SubTreeModifyItem(); + treeRoot.addSubItem(item); + } + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + + createCombo(item, COMBO_WIDTH); + + } + + @Override + public int getHeight() { + return item.getHeight(); + } + + @Override + public void setInitialValue(VMProperty property) { + // TODO Auto-generated method stub + + } + + @Override + public void itemSelected(ComboBox comboBox) { + // TODO change item list for selected template. + System.out.println("item selected:" + comboBox.getSelectedItem()); + + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProfileItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProfileItem.java index bae93d2..7c2f10d 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProfileItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/ProfileItem.java @@ -36,11 +36,11 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.tizen.emulator.manager.renewal.resources.ImageResources; -import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IconItemTitle; import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; import org.tizen.emulator.manager.vms.VMProperty; -public class ProfileItem implements IModifyDialogItem { +public class ProfileItem extends ModifyDialogItem { private ModifyItem item; private Canvas canvas; @@ -87,7 +87,7 @@ public class ProfileItem implements IModifyDialogItem { } @Override - public void setItemData(VMProperty property) { + public void setInitialValue(VMProperty property) { if (property == null) { return; } @@ -102,7 +102,11 @@ public class ProfileItem implements IModifyDialogItem { @Override public void create(Composite parent) { - item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE); + item = new ModifyItem(); + item.init(parent); + item.setItemTitle(new IconItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + addProfileImage(); } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/RamSizeItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/RamSizeItem.java new file mode 100644 index 0000000..beab76f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/RamSizeItem.java @@ -0,0 +1,93 @@ +/* + * 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.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper; +import org.tizen.emulator.manager.vms.VMProperty; + +public class RamSizeItem extends ComboItem { + + private final SubTreeModifyItem item; + + private final String TITLE = "Ram"; + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_RAM; + private final int COMBO_WIDTH = 124; + + public RamSizeItem(TreeModifyItem treeRoot) { + item = new SubTreeModifyItem(); + treeRoot.addSubItem(item); + } + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + + createCombo(item, COMBO_WIDTH); + addLabel(); + } + + private void addLabel() { + FormData data = new FormData(); + int left = ModifyItem.BODY_MARGIN_LEFT + COMBO_WIDTH + 6; + data.left = new FormAttachment(0, left); + data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP); + data.width = 30; // rough guess + data.height = ModifyItem.WIDGET_HEIGHT; + + Canvas canvas = new Canvas(item.getBody(), SWT.NONE); + canvas.setLayoutData(data); + WidgetHelper.drawText(canvas, "MB", SWT.NONE); + } + + @Override + public int getHeight() { + return item.getHeight(); + } + + @Override + public void setInitialValue(VMProperty property) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SensorItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SensorItem.java new file mode 100644 index 0000000..2b5bbab --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SensorItem.java @@ -0,0 +1,85 @@ +/* + * 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.vm.common.SubTreeItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.SubTreeModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TreeModifyItem; +import org.tizen.emulator.manager.vms.VMProperty; + +public class SensorItem extends CheckBoxItem { + + private final SubTreeModifyItem item; + + private final String TITLE = "Sensor"; + private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR; + + private static final int NUM_COLUMN = 3; + + // TODO load sensor list + private static final String[] sensorList = new String[]{"Accelerometer", "Gyroscope", "Geo-magnetic", + "Proximity", "Light", "Haptic", "Pressure"}; + + public SensorItem(TreeModifyItem treeRoot) { + super(NUM_COLUMN, sensorList); + item = new SubTreeModifyItem(); + item.setItemHeight(getContentHeight()); + treeRoot.addSubItem(item); + } + + + @Override + public void create(Composite parent) { + item.init(parent); + item.setItemTitle(new SubTreeItemTitle(item.getItemComp(), TITLE, TITLE_ICON_RESOURCE)); + item.create(); + + createCheckBoxItems(item); + + } + + @Override + public int getHeight() { + return item.getHeight(); + } + + @Override + public void setInitialValue(VMProperty property) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TextLabelItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TextLabelItem.java similarity index 80% rename from src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TextLabelItem.java rename to src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TextLabelItem.java index ebd3792..8f48572 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TextLabelItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TextLabelItem.java @@ -29,7 +29,7 @@ */ -package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common; +package org.tizen.emulator.manager.ui.renewal.item.modify.vm; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; @@ -42,8 +42,10 @@ 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; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IconItemTitle; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem; -public abstract class TextLabelItem implements IModifyDialogItem { +public abstract class TextLabelItem extends ModifyDialogItem { private ModifyItem item; private Canvas canvas; @@ -55,8 +57,12 @@ public abstract class TextLabelItem implements IModifyDialogItem { return item.getHeight(); } - protected void create(Composite parent, String title, ImageResources iconResources) { - item = new ModifyItem(parent, title, iconResources); + protected void create(Composite parent, String title, ImageResources iconResource) { + item = new ModifyItem(); + item.init(parent); + item.setItemTitle(new IconItemTitle(item.getItemComp(), title, iconResource)); + item.create(); + makeBody(); } @@ -65,16 +71,16 @@ public abstract class TextLabelItem implements IModifyDialogItem { // init canvas; GridData data = new GridData(); - data.heightHint = ModifyItem.ITEM_HEIGHT; + data.heightHint = getHeight() - ModifyItem.LINE_WIDTH; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; canvas = new Canvas(item.getBody(), SWT.NONE); canvas.setLayoutData(data); - drawImageName(); + drawText(); } - private void drawImageName() { + private void drawText() { canvas.addPaintListener(new PaintListener() { @Override @@ -83,7 +89,7 @@ public abstract class TextLabelItem implements IModifyDialogItem { gc.setForeground(ColorResources.CONTENT_FONT.getColor()); gc.setFont(FontResources.CONTENT.getFont()); Point textExt = gc.textExtent(value); - int poxY = (ModifyItem.ITEM_HEIGHT - textExt.y) / 2; + int poxY = (getHeight() - textExt.y) / 2; gc.drawText(value, 0, poxY); } }); diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/VMNameItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/VMNameItem.java index 3121ce6..96e699f 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/VMNameItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/VMNameItem.java @@ -32,7 +32,6 @@ 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.vm.common.TextLabelItem; import org.tizen.emulator.manager.vms.VMProperty; public class VMNameItem extends TextLabelItem { @@ -46,7 +45,7 @@ public class VMNameItem extends TextLabelItem { } @Override - public void setItemData(VMProperty property) { + public void setInitialValue(VMProperty property) { if (property == null) { return; } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IconItemTitle.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IconItemTitle.java new file mode 100644 index 0000000..0662b2f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/IconItemTitle.java @@ -0,0 +1,49 @@ +package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common; + +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.layout.GridData; +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.ImageResources; + +public class IconItemTitle extends ItemTitle { + + private Canvas iconCanvas; + private final ImageResources iconResource; + + private static int TITLE_MARGIN_LEFT = 15; + private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND; + + public IconItemTitle(Composite parent, String title, ImageResources iconResource) { + super(parent, title, TITLE_MARGIN_LEFT, background); + this.iconResource = iconResource; + } + + @Override + public void create() { + super.create(); + makeIcon(); + } + + private void makeIcon() { + // init + GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT); + data.verticalAlignment = SWT.CENTER; + data.grabExcessVerticalSpace = true; + iconCanvas = new Canvas(this, SWT.NONE); + iconCanvas.setLayoutData(data); + + // draw icon + iconCanvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.drawImage(iconResource.getImage(), 0, 0); + } + }); + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ItemTitle.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ItemTitle.java index 7475f8d..dff5962 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ItemTitle.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ItemTitle.java @@ -34,66 +34,66 @@ 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.Image; -import org.eclipse.swt.graphics.ImageData; 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 ItemTitle extends Canvas{ - private final int TITLE_MARGIN_LEFT = 15; private final int TITLE_SPACING = 8; - private final int TITLE_CANVAS_WIDTH = 144; +// private final int TITLE_CANVAS_WIDTH = 144; + public static final int TITLE_CANVAS_WIDTH = 130; private final int LINE_INDENT = 5; - private final String title; - private Image titleIcon; - private final ImageResources titleIconResource; + protected int ICON_WIDTH = 18; + protected final int ICON_HEIGHT = 18; + private final String title; + private int marginLeft = 0; + private final ColorResources background; - public ItemTitle(Composite parent, String title, ImageResources titleIconResources) { + public ItemTitle(Composite parent, String title, int marginLeft, ColorResources background) { super(parent, SWT.NONE); this.title = title; - this.titleIconResource = titleIconResources; - + this.marginLeft = marginLeft; + this.background = background; } - public void create() { - initTitle(); + protected void create() { + init(); makeTitle(); } - private void initTitle() { + private void init() { GridData data = new GridData(); data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; + data.verticalAlignment = SWT.FILL; data.widthHint = TITLE_CANVAS_WIDTH; this.setLayoutData(data); - this.setBackground(ColorResources.MODIFY_ITEM_TITLE_BACKGROUND.getColor()); + this.setBackground(background.getColor()); + this.setBackgroundMode(SWT.INHERIT_FORCE); + + // layout + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.marginWidth = marginLeft; + this.setLayout(layout); } + private void makeTitle() { - // draw icon, title + // draw title, under line this.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { GC gc = e.gc; - int itemHeight = ModifyItem.ITEM_HEIGHT; - - // draw icon - if (titleIcon == null) { - titleIcon = titleIconResource.getImage(); - } - ImageData imageData = titleIcon.getImageData(); - int iconY = (itemHeight - imageData.height) / 2; - gc.drawImage(titleIcon, TITLE_MARGIN_LEFT, iconY); + int itemHeight = ((Canvas)e.widget).getBounds().height - ModifyItem.LINE_WIDTH; // draw text gc.setForeground(ColorResources.MODIFY_ITEM_TITLE.getColor()); @@ -101,7 +101,7 @@ public class ItemTitle extends Canvas{ Point textExt = gc.textExtent(title); int titleY = (itemHeight - textExt.y) / 2; gc.drawText(title, - TITLE_MARGIN_LEFT + imageData.width + TITLE_SPACING, titleY); + marginLeft + ICON_WIDTH + TITLE_SPACING, titleY); // draw under line int lineWidth = ModifyItem.LINE_WIDTH; diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ModifyItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ModifyItem.java index 23e0bac..aa92ec5 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ModifyItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/ModifyItem.java @@ -9,7 +9,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; 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.ui.renewal.dialog.VMModifyDialog; public class ModifyItem { @@ -17,20 +17,44 @@ public class ModifyItem { public static final int LINE_WIDTH = 1; public static final int LINE_INDENT = 7; public static final int BODY_MARGIN_LEFT = 10; + public static final int BODY_CONTENT_WIDTH = + VMModifyDialog.WIDTH - ItemTitle.TITLE_CANVAS_WIDTH - BODY_MARGIN_LEFT * 2; - private Composite comp; + public static final int WIDGET_HEIGHT = 23; + + public static final int WIDGET_TOP = (ITEM_HEIGHT - WIDGET_HEIGHT) / 2; + + protected Composite comp; private ItemTitle itemTitle; private Composite bodyComp; - public ModifyItem(Composite parent, String title, ImageResources iconResource) { - create(parent); - createTitle(title, iconResource); - createEmptyBody(); + private int itemHeight = ITEM_HEIGHT; + + protected int getItemHeight() { + return itemHeight; } - private void createTitle(String title, ImageResources iconResource) { - itemTitle = new ItemTitle(comp, title, iconResource); + + public void setItemHeight(int itemHeight) { + this.itemHeight = itemHeight; + } + + + public void init(Composite parent) { + createComp(parent); + } + + public void setItemTitle(ItemTitle itemTitle) { + this.itemTitle = itemTitle; + } + + public Composite getItemComp() { + return comp; + } + + public void create() { itemTitle.create(); + createEmptyBody(); } private void createEmptyBody() { @@ -48,8 +72,8 @@ public class ModifyItem { // draw under line gc.setForeground(ColorResources.MODIFY_ITEM_LINE.getColor()); gc.setLineWidth(ModifyItem.LINE_WIDTH); - gc.drawLine(-1, ModifyItem.ITEM_HEIGHT, - rect.width, ModifyItem.ITEM_HEIGHT); + gc.drawLine(-1, getItemHeight(), + rect.width, getItemHeight()); } }); } @@ -75,20 +99,28 @@ public class ModifyItem { } public int getHeight() { - return ITEM_HEIGHT + LINE_WIDTH; + return ((GridData)comp.getLayoutData()).heightHint; + } - /** For item which has single widget. */ public void setBodyLayoutDefault() { + setBodyLayoutGrid(1); + } + + public void setBodyLayoutGrid(int numColumns) { GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = ModifyItem.BODY_MARGIN_LEFT; + layout.numColumns = numColumns; + layout.marginWidth = BODY_MARGIN_LEFT; layout.marginHeight = 0; + layout.verticalSpacing = 0; + layout.horizontalSpacing = 0; bodyComp.setLayout(layout); } - private void create(Composite parent) { + + + private void createComp(Composite parent) { initComp(parent); makeComp(); } @@ -99,7 +131,7 @@ public class ModifyItem { GridData data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; - data.heightHint = ITEM_HEIGHT + LINE_WIDTH; + data.heightHint = getItemHeight() + LINE_WIDTH; comp.setLayoutData(data); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeItemTitle.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeItemTitle.java new file mode 100644 index 0000000..13ea2df --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeItemTitle.java @@ -0,0 +1,50 @@ +package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common; + +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.layout.GridData; +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.ImageResources; + +public class SubTreeItemTitle extends ItemTitle { + + private Canvas iconCanvas; + private final ImageResources iconResource; + + private static int TITLE_MARGIN_LEFT = 23; + private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_SUB_BACKGROUDN; + + public SubTreeItemTitle(Composite parent, String title, ImageResources iconResource) { + super(parent, title, TITLE_MARGIN_LEFT, background); + this.iconResource = iconResource; + } + + + @Override + public void create() { + super.create(); + makeIcon(); + } + + private void makeIcon() { + // init + GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT); + data.verticalAlignment = SWT.CENTER; + data.grabExcessVerticalSpace = true; + iconCanvas = new Canvas(this, SWT.NONE); + iconCanvas.setLayoutData(data); + + // draw icon + iconCanvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.drawImage(iconResource.getImage(), 0, 0); + } + }); + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeModifyItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeModifyItem.java new file mode 100644 index 0000000..eb8680a --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/SubTreeModifyItem.java @@ -0,0 +1,31 @@ +package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common; + +import org.eclipse.swt.layout.GridData; + + +public class SubTreeModifyItem extends ModifyItem{ + + public void changeExpanding(boolean isExpand) { + GridData data = new GridData(); + if (isExpand) { + data.grabExcessHorizontalSpace = true; + data.horizontalAlignment = GridData.FILL; + data.heightHint = getItemHeight() + LINE_WIDTH; + } else { + data.heightHint = 0; + } + comp.setLayoutData(data); + + } + +// @Override +// @Override +// public int getHeight() { +// System.out.println(comp.getSize().y); +// if (comp.isVisible()) { +// return super.getHeight(); +// } +// return 0; +// +// } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeItemTitle.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeItemTitle.java new file mode 100644 index 0000000..353b0f8 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeItemTitle.java @@ -0,0 +1,119 @@ + +/* + * 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.common; + +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.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.ImageResources; + +public class TreeItemTitle extends ItemTitle { + + private Canvas arrowCanvas; + private boolean isExpanded = true; + + private final TreeModifyItem treeRoot; + + private static int TITLE_MARGIN_LEFT = 15; + private static ColorResources background = ColorResources.MODIFY_ITEM_TITLE_BACKGROUND; + private static ImageResources ARROW_EXPANDED = ImageResources.ICON_TITLE_TREE_EXPANDED; + private static ImageResources ARROW_CLOSED = ImageResources.ICON_TITLE_TREE_CLOSED; + + + public TreeItemTitle(TreeModifyItem treeRoot, String title) { + super(treeRoot.getItemComp(), title, TITLE_MARGIN_LEFT, background); + this.treeRoot = treeRoot; + } + + @Override + public void create() { + super.create(); + makeArrow(); + } + + private void makeArrow() { + // init + GridData data = new GridData(ICON_WIDTH, ICON_HEIGHT); + data.verticalAlignment = SWT.CENTER; + data.grabExcessVerticalSpace = true; + arrowCanvas = new Canvas(this, SWT.NONE); + arrowCanvas.setLayoutData(data); + + // draw icon + drawArrow(); + addArrowListener(); + } + + private void drawArrow() { + arrowCanvas.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + if (isExpanded) { + gc.drawImage(ARROW_EXPANDED.getImage(), 0,0); + + } else { + gc.drawImage(ARROW_CLOSED.getImage(), 0,0); + } + + } + }); + } + + + private void addArrowListener() { + + Listener mouseListener = new Listener() { + @Override + public void handleEvent(Event e) { + + if (e.type == SWT.MouseUp) { + Rectangle rect = ((Canvas)e.widget).getClientArea(); + if (rect.contains(e.x, e.y)) { + isExpanded = !isExpanded; + treeRoot.changeTreeExpanding(isExpanded); + arrowCanvas.redraw(); + } + } + } + }; + arrowCanvas.addListener(SWT.MouseUp, mouseListener); + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeModifyItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeModifyItem.java new file mode 100644 index 0000000..d3c2ba0 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/common/TreeModifyItem.java @@ -0,0 +1,60 @@ +/* + * 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.common; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ModifyDialogItem; + +public class TreeModifyItem extends ModifyItem{ + + private ModifyDialogItem modifyDialogItem; + private final List subItemList = new ArrayList(); + + public void addSubItem(SubTreeModifyItem subItem) { + subItemList.add(subItem); + } + + public void changeTreeExpanding(boolean isExpand) { + for (SubTreeModifyItem subItem : subItemList) { + subItem.changeExpanding(isExpand); + } + modifyDialogItem.getParentDialog().layoutScrolledComposite(); + } + + public void setModifyDialogItem(ModifyDialogItem modifyDialogItem) { + this.modifyDialogItem = modifyDialogItem; + } + + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/CheckBoxButton.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/CheckBoxButton.java new file mode 100644 index 0000000..01e0877 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/CheckBoxButton.java @@ -0,0 +1,197 @@ +/* + * 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.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.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +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.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.TypedListener; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.ui.table.Helper; + +public class CheckBoxButton extends Canvas { + private Image image = null; + private Image imageHover = null; + private Image checkedImage = null; + private Image checkedImageHover = null; + private boolean isSelected = false; + private boolean isHover = false; + + private Color checkedBackground = null; + + public CheckBoxButton(Composite parent, int style) { + super(parent, SWT.DOUBLE_BUFFERED | style); + + initButton(); + addListeners(); + } + + protected void initButton() { + image = ImageResources.CHECKBOX_UNCHECKED_NML.getImage(); + imageHover = ImageResources.CHECKBOX_UNCHECKED_HOVER.getImage(); + checkedImage = ImageResources.CHECKBOX_CHECKED_NML.getImage(); + checkedImageHover = ImageResources.CHECKBOX_CHECKED_HOVER.getImage(); + } + + private void addListeners() { + addPaintListener(paintListener); + addListener(SWT.MouseDown, mouseListener); + addListener(SWT.MouseUp, mouseListener); + addListener(SWT.MouseEnter, mouseListener); + addListener(SWT.MouseExit, mouseListener); + addDisposeListener(disposeListener); + } + + @Override + public Point computeSize(int wHint, int hHint, boolean changed) { + checkWidget(); + int width = 0, height = 0; + + Rectangle bounds = image.getBounds(); + width = bounds.width; + height = bounds.height; + + if (wHint != SWT.DEFAULT) + width = wHint; + + if (hHint != SWT.DEFAULT) + height = hHint; + + return new Point(width, height); + } + + private final DisposeListener disposeListener = new DisposeListener() { + + @Override + public void widgetDisposed(DisposeEvent arg0) { + Helper.tryDispose(image, imageHover, checkedImage, checkedImageHover, checkedBackground); + } + }; + + private final PaintListener paintListener = new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + Rectangle rect = ((Canvas) e.widget).getClientArea(); + + if (isSelected && checkedBackground != null) { + e.gc.setBackground(checkedBackground); + } else { + e.gc.setBackground(getBackground()); + } + e.gc.fillRectangle(rect); + + Image img = image; + if (isSelected) { + img = isHover ? checkedImageHover : checkedImage; + } else { + img = isHover ? imageHover : image; + } + + Rectangle bounds = img.getBounds(); + int x = rect.x + (rect.width - bounds.width) / 2; + int y = rect.y + (rect.height - bounds.height) / 2; + + if (null != img) { + e.gc.drawImage(img, x, y); + } + } + }; + + public void addSelectionListener(SelectionListener listener) { + checkWidget(); + addListener(SWT.Selection, new TypedListener(listener)); + addListener(SWT.DefaultSelection, new TypedListener(listener)); + } + + public void removeSelectionListener(SelectionListener listener) { + checkWidget(); + removeListener(SWT.Selection, listener); + removeListener(SWT.DefaultSelection, listener); + } + + protected Listener mouseListener = new Listener() { + + @Override + public void handleEvent(Event e) { + if (!isEnabled()) { + return; + } + + CheckBoxButton button = (CheckBoxButton) e.widget; + if (e.type == SWT.MouseUp) { + Rectangle rect = ((Canvas)e.widget).getClientArea(); + if (rect.contains(e.x, e.y)) { + setSelection(!isSelection()); + redraw(); + button.notifyListeners(SWT.Selection, new Event()); + } + + } else if (e.type == SWT.MouseEnter) { + isHover = true; + redraw(); + + } else if (e.type == SWT.MouseExit) { + isHover = false; + redraw(); + } + } + }; + + public void setSelection(boolean selected) { + checkWidget(); + isSelected = selected; + } + + public boolean isSelection() { + checkWidget(); + return isSelected; + } + + public void setSelectedBackground(Color color) { + checkWidget(); + if (color == null) { + SWT.error(SWT.ERROR_NULL_ARGUMENT); + } + this.checkedBackground = color; + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java new file mode 100644 index 0000000..8f3a867 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java @@ -0,0 +1,293 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; + +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.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.FontResources; +import org.tizen.emulator.manager.renewal.resources.ImageResources; + +public class ComboBox extends NinePatchBox { + + private static NinePatchResourceMap ninePatchResourceMap; + + private final Shell parentShell; + private Canvas textCanvas; + + private final int ARROW_AREA_WIDTH = 19; + public static final int TEXT_MARGIN_LEFT = 3; + + private Image arrowImageNormal; + private Image arrowImageHover; + + private final List items; + private final ComboBoxPopup popup; + private int selectedIndex = 0; + private String selectedItem = ""; + + public ComboBox(Shell parentShell, Composite parent, int style) { + super(parent, style); + this.parentShell = parentShell; + popup = new ComboBoxPopup(this); + items = new ArrayList(); + initNinePatchResourceMap(); + initBox(); + createText(); + addMouseListener(); + + // TODO for test + items.add("combo 1"); + items.add("combo 2"); + items.add("combo 3"); + } + + + public Shell getParentShell() { + return parentShell; + } + + public void addItem(String item) { + items.add(item); + } + + + @Override + public void redraw() { + textCanvas.redraw(); + super.redraw(); + } + + public String getSelectedItem() { + return selectedItem; + } + + public List getItemList() { + return items; + } + + + public void setIndex(int index) { + if (index < 0 || index >= items.size()) { + return; + } + selectedIndex = index; + } + + + public int getSelectionIndex() { + return selectedIndex; + } + + + public void select(int index) { + if (index < 0 || index >= items.size()) { + return; + } + + selectedIndex = index; + selectedItem = items.get(index); + + notifyListeners(SWT.Selection, new Event()); + } + + + private void initBox() { + this.setLayout(new FormLayout()); + } + + + private void createText() { + FormData data = new FormData(); + data.left = new FormAttachment(0, TEXT_MARGIN_LEFT); + data.right = new FormAttachment(100, ARROW_AREA_WIDTH * -1); + data.top = new FormAttachment(0, 1); + data.bottom = new FormAttachment(100,-1); + + textCanvas = new Canvas(this, SWT.NONE); + textCanvas.setLayoutData(data); + + drawText(); + } + + + private void drawText() { + textCanvas.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + Rectangle rect = ((Canvas)e.widget).getBounds(); + gc.setForeground(ColorResources.CONTENT_FONT.getColor()); + gc.setFont(FontResources.CONTENT.getFont()); + Point textExt = gc.textExtent(selectedItem); + int poxY = (rect.height - textExt.y) / 2; + gc.drawText(selectedItem, TEXT_MARGIN_LEFT, poxY); + } + }); + } + + + @Override + protected void draw(PaintEvent e) { + drawArrow(e); + } + + + private void drawArrow(PaintEvent e) { + // drawArrow + Image image = getArrowImage(); + ImageData imageData = image.getImageData(); + GC gc = e.gc; + Rectangle rect = ((Canvas)e.widget).getBounds(); + int posX = (rect.width - ARROW_AREA_WIDTH + + (ARROW_AREA_WIDTH - imageData.width) /2 ); + int posY = (rect.height - imageData.height) / 2; + gc.drawImage(image, posX, posY); + + } + + private Image getArrowImage() { + if (getState() == WSTATE.HOVER || getState() == WSTATE.SELECTED) { + if (arrowImageHover == null) { + arrowImageHover = ImageResources.DROP_DOWN_ARROW_HOVER.getImage(); + } + return arrowImageHover; + } + + if (arrowImageNormal == null) { + arrowImageNormal = ImageResources.DROP_DOWN_ARROW_NORMAL.getImage(); + } + return arrowImageNormal; + + } + + + private void addMouseListener() { + Listener mouseListener = new Listener() { + + @Override + public void handleEvent(Event e) { + if (e.type == SWT.MouseEnter) { + if (popup.isClosed()) { + setState(WSTATE.HOVER); + redraw(); + } + + } else if (e.type == SWT.MouseExit) { + if (popup.isClosed()) { + setState(WSTATE.NORMAL); + redraw(); + } + + } if (e.type == SWT.MouseUp) { +// if (items.size() == 0) { +// return; +// } + Rectangle rect = ((Canvas)e.widget).getClientArea(); + if (rect.contains(e.x, e.y)) { + setState(getState() == WSTATE.SELECTED ? WSTATE.HOVER : WSTATE.SELECTED); + redraw(); + popup.changePopup(); + } + } + } + }; + textCanvas.addListener(SWT.MouseEnter, mouseListener); + textCanvas.addListener(SWT.MouseExit, mouseListener); + textCanvas.addListener(SWT.MouseUp, mouseListener); + + this.addListener(SWT.MouseEnter, mouseListener); + this.addListener(SWT.MouseExit, mouseListener); + this.addListener(SWT.MouseUp, mouseListener); + + } + + @Override + public NinePatchResourceMap getNinePatchResourceMap() { + return ninePatchResourceMap; + } + + private static void initNinePatchResourceMap() { + ninePatchResourceMap = new NinePatchResourceMap(); + ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE, + ColorResources.BLACK, + ImageResources.DROP_DOWN_BOX_NORMAL_LT, + ImageResources.DROP_DOWN_BOX_NORMAL_T, + ImageResources.DROP_DOWN_BOX_NORMAL_RT, + ImageResources.DROP_DOWN_BOX_NORMAL_R, + ImageResources.DROP_DOWN_BOX_NORMAL_RB, + ImageResources.DROP_DOWN_BOX_NORMAL_B, + ImageResources.DROP_DOWN_BOX_NORMAL_LB, + ImageResources.DROP_DOWN_BOX_NORMAL_L); + + ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.WHITE, + ColorResources.BLACK, + ImageResources.DROP_DOWN_BOX_HOVER_LT, + ImageResources.DROP_DOWN_BOX_HOVER_T, + ImageResources.DROP_DOWN_BOX_HOVER_RT, + ImageResources.DROP_DOWN_BOX_HOVER_R, + ImageResources.DROP_DOWN_BOX_HOVER_RB, + ImageResources.DROP_DOWN_BOX_HOVER_B, + ImageResources.DROP_DOWN_BOX_HOVER_LB, + ImageResources.DROP_DOWN_BOX_HOVER_L); + + ninePatchResourceMap.setImages(WSTATE.SELECTED, ColorResources.WHITE, + ColorResources.BLACK, + ImageResources.DROP_DOWN_BOX_SELECTED_LT, + ImageResources.DROP_DOWN_BOX_SELECTED_T, + ImageResources.DROP_DOWN_BOX_SELECTED_RT, + ImageResources.DROP_DOWN_BOX_SELECTED_R, + ImageResources.DROP_DOWN_BOX_SELECTED_RB, + ImageResources.DROP_DOWN_BOX_SELECTED_B, + ImageResources.DROP_DOWN_BOX_SELECTED_LB, + ImageResources.DROP_DOWN_BOX_SELECTED_L); + + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java new file mode 100644 index 0000000..114a103 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java @@ -0,0 +1,296 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +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.graphics.Region; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.FontResources; +import org.tizen.emulator.manager.renewal.resources.ImageResources; +import org.tizen.emulator.manager.renewal.resources.PatchImageResources; + +public class ComboBoxPopup { + + private final ComboBox parentComboBox; + + private Shell popupShell; + private Canvas popupCanvas; + private Image popupImage = null; + private final List itemRects; + + private static final int ITEM_HEIGHT = 23; + private static final int MARGIN_WIDTH = 6; + private static int LINE_OFFSET = 1; + private static int SHADOW_WIDTH_RIGHT = 4; + private static int SHADOW_WIDTH_BOTTOM = 5; + + + private int shellWidth; + private int shellHeight; + + public ComboBoxPopup(ComboBox parentComboBox) { + this.parentComboBox = parentComboBox; + itemRects = new ArrayList(); + } + + private void open() { + initShell(); + initCanvas(); + + popupShell.open(); + } + + public void changePopup() { + if (popupShell == null || popupShell.isDisposed()) { + open(); + + } else { + dispose(); + } + } + + public boolean isClosed() { + if (popupShell == null || popupShell.isDisposed()) { + return true; + } + return false; + } + + private void initCanvas() { + popupCanvas = new Canvas(popupShell, SWT.DOUBLE_BUFFERED); + popupCanvas.setForeground(ColorResources.CONTENT_FONT.getColor()); + popupCanvas.setFont(FontResources.CONTENT.getFont()); + + List items = parentComboBox.getItemList(); + Rectangle itemRect; + for (int i = 0; i < items.size(); i++) { + itemRect = new Rectangle(LINE_OFFSET, LINE_OFFSET + i * ITEM_HEIGHT, + shellWidth - LINE_OFFSET * 2, ITEM_HEIGHT); + itemRects.add(itemRect); + } + + addPaintListener(); + addDisposeListener(); + addMouseListener(); + addFocusListener(); + + } + + + private void addMouseListener() { + Listener popupMouseEventListener = new Listener() { + @Override + public void handleEvent(Event event) { + switch(event.type) { + case SWT.MouseMove: + Rectangle rect; + for (int i = 0; i < itemRects.size(); i++) { + rect = itemRects.get(i); + if (rect.contains(event.x, event.y)) { + parentComboBox.setIndex(i); + popupCanvas.redraw(); + break; + } + } + break; + case SWT.MouseUp: + parentComboBox.select(parentComboBox.getSelectionIndex()); + parentComboBox.redraw(); + dispose(); + break; + default: + break; + } + + } + }; + + popupCanvas.addListener(SWT.MouseUp, popupMouseEventListener); + popupCanvas.addListener(SWT.MouseMove, popupMouseEventListener); + + } + + + private void addFocusListener() { + popupCanvas.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent arg0) { + dispose(); + } + + @Override + public void focusGained(FocusEvent arg0) { + } + }); + + } + private void initShell() { + popupShell = new Shell(parentComboBox.getParentShell(), SWT.ON_TOP | SWT.NO_TRIM); + popupShell.setLayout(new FillLayout()); + + List items = parentComboBox.getItemList(); + + Rectangle parentRect = parentComboBox.getBounds(); + Point parentPoint = parentComboBox.toDisplay(0, 0); + + int itemWidth = getMaxTextWidth(items) + MARGIN_WIDTH * 2; + shellWidth = ((itemWidth > parentRect.width) ? itemWidth : parentRect.width); + + // insures minimum popup height + int shellItemSize = items.size() == 0 ? 1 : items.size(); + shellHeight = (ITEM_HEIGHT) * shellItemSize + LINE_OFFSET * 2; + + Region region = new Region(); + region.add(0, 0, shellWidth + SHADOW_WIDTH_RIGHT, + shellHeight + SHADOW_WIDTH_BOTTOM); + region.subtract(0, shellHeight - 1, 1, 1); + popupShell.setRegion(region); + + Rectangle size = region.getBounds(); + popupShell.setSize(size.width, size.height); + popupShell.setLocation(parentPoint.x, parentPoint.y + parentRect.height); + } + + + private int getMaxTextWidth(List items) { + if (items.isEmpty()) { + return 0; + } + int width = 0; + GC gc = new GC(Display.getCurrent(), SWT.NONE); + for (String item : items) { + Point p = gc.textExtent(item); + if (p.x > width) { + width = p.x; + } + } + gc.dispose(); + return width; + } + + public void dispose() { + if (popupShell == null) { + return; + } + parentComboBox.setState(WSTATE.NORMAL); + parentComboBox.redraw(); + popupShell.close(); + } + + + private void addPaintListener() { + popupCanvas.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + // draw border + drawBorder(e); + + // draw item text + GC gc = e.gc; + int selectedIndex = parentComboBox.getSelectionIndex(); + int fontHeight = gc.getFontMetrics().getHeight(); + int yOffset = (ComboBoxPopup.ITEM_HEIGHT - fontHeight)/2 + LINE_OFFSET; + int totalHeight = 0; + + List items = parentComboBox.getItemList(); + for (int i = 0; i < itemRects.size(); i++) { + if (selectedIndex == i) { + gc.setBackground(ColorResources.CREATE_VM_COMBO_POPUP_SELECT_ITEM.getColor()); + } else { + gc.setBackground(ColorResources.WHITE.getColor()); + } + gc.fillRectangle(itemRects.get(i)); + + String text = items.get(i); + gc.drawText(text, MARGIN_WIDTH, totalHeight + yOffset, true); + totalHeight += ITEM_HEIGHT; + } + } + }); + } + + private void drawBorder(PaintEvent e) { + if (popupImage == null) { + NinePatchResourceInfo ninePatchImagesInfo = + new NinePatchResourceInfo(ColorResources.WHITE, + ColorResources.WHITE, + ImageResources.CONTEXT_MENU_LT, + ImageResources.CONTEXT_MENU_T, + ImageResources.CONTEXT_MENU_RT, + ImageResources.CONTEXT_MENU_R, + ImageResources.CONTEXT_MENU_RB, + ImageResources.CONTEXT_MENU_B, + ImageResources.CONTEXT_MENU_LB, + ImageResources.CONTEXT_MENU_L); + Rectangle rect = ((Canvas) e.widget).getClientArea(); + popupImage = PatchImageResources.getComboPopupImage( + rect.width, rect.height, ninePatchImagesInfo); + } + e.gc.drawImage(popupImage, 0, 0); + } + + + private void addDisposeListener() { + popupCanvas.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + System.out.println("popup disposing"); + if (popupImage != null) { + popupImage.dispose(); + popupImage = null; + } + itemRects.clear(); + } + }); + } +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java index 851a558..5f275ca 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/CreateVMComboPopup.java @@ -136,7 +136,7 @@ class CreateVMComboPopup { popupShell.open(); } - private Listener popupMouseEventListener = new Listener() { + private final Listener popupMouseEventListener = new Listener() { @Override public void handleEvent(Event event) { switch(event.type) { @@ -183,7 +183,7 @@ class CreateVMComboPopup { popupShell = null; } - private PaintListener paintListener = new PaintListener() { + private final PaintListener paintListener = new PaintListener() { @Override public void paintControl(PaintEvent e) { @@ -224,7 +224,7 @@ class CreateVMComboPopup { } }; - private DisposeListener disposeListener = new DisposeListener() { + private final DisposeListener disposeListener = new DisposeListener() { @Override public void widgetDisposed(DisposeEvent arg0) { WidgetHelper.tryDispose(popupCanvas, popupShell); diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchBox.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchBox.java index e84b64f..ca447bf 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchBox.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/NinePatchBox.java @@ -50,6 +50,15 @@ public abstract class NinePatchBox extends Canvas{ private final Map imageMap = new HashMap(); private WSTATE state = WSTATE.NORMAL; + + protected void draw(PaintEvent e) { + // This is for sub-class + } + + protected boolean isSelected() { + return state == WSTATE.SELECTED; + } + protected void setState(WSTATE state) { this.state = state; } @@ -72,10 +81,12 @@ public abstract class NinePatchBox extends Canvas{ @Override public void paintControl(PaintEvent e) { drawBox(e); + draw(e); } }); } + private void drawBox(PaintEvent e) { // get box image Image image = imageMap.get(state); diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java index 9e0f3a5..1f3de7e 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java @@ -53,7 +53,6 @@ public class TextInputBox extends NinePatchBox{ private static NinePatchResourceMap ninePatchResourceMap; private Text text; - private final ColorResources TEXT_BACKGROUND = ColorResources.WHITE; private final int TEXT_MARGIN_WIDTH = 2; private final int TEXT_MARGIN_HEIGHT = 2; @@ -62,7 +61,8 @@ public class TextInputBox extends NinePatchBox{ public TextInputBox(Composite parent, int style) { super(parent, style); initNinePatchResourceMap(); - init(); + initBox(); + createText(); } @@ -75,13 +75,6 @@ public class TextInputBox extends NinePatchBox{ text.setText(value); } - - private void init() { - initBox(); - initText(); - } - - private void initBox() { GridLayout layout = new GridLayout(); layout.marginHeight = TEXT_MARGIN_HEIGHT; @@ -91,17 +84,17 @@ public class TextInputBox extends NinePatchBox{ } - private void initText() { + private void createText() { GridData data = new GridData(); data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; data.horizontalAlignment = SWT.FILL; - data.verticalAlignment = SWT.FILL; + data.verticalAlignment = SWT.CENTER; text = new Text(this, SWT.NONE); text.setFont(FontResources.CONTENT.getFont()); text.setForeground(ColorResources.CONTENT_FONT.getColor()); - text.setBackground(TEXT_BACKGROUND.getColor()); + text.setBackground(ColorResources.WHITE.getColor()); text.setLayoutData(data); removeTextBorder(); @@ -162,7 +155,7 @@ public class TextInputBox extends NinePatchBox{ @Override public void paintControl(PaintEvent e) { // remove by overwriting border with background's color - e.gc.setForeground(TEXT_BACKGROUND.getColor()); + e.gc.setForeground(ColorResources.WHITE.getColor()); e.gc.setLineWidth(TEXT_BORDER_WIDTH); Rectangle rect = ((Text)e.widget).getBounds(); diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java index a306881..3f461d2 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java @@ -30,9 +30,17 @@ 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.widgets.Composite; import org.eclipse.swt.widgets.Widget; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.renewal.resources.FontResources; -class WidgetHelper { +public class WidgetHelper { public static void tryDispose(final Object... Disposables) { if (null == Disposables) { return; @@ -47,4 +55,32 @@ class WidgetHelper { } } } + + + // draw text + // - valign : center + // - horizontal left: default 0 + public static void drawText(Composite comp, final String text, final int horizentalAlign) { + comp.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + + GC gc = e.gc; + gc.setForeground(ColorResources.CONTENT_FONT.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; + if (horizentalAlign == SWT.CENTER) { + int itemWidth = ((Composite)e.widget).getBounds().width; + posX = (itemWidth - textExt.x)/ 2; + } + gc.drawText(text, posX, posY); + } + + }); + } } -- 2.7.4