From: jihye424.kim Date: Thu, 1 Oct 2015 08:59:17 +0000 (+0900) Subject: Device Template: add custom device template icon X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccf4d18f2131b21c6f8af639785258adfd54612c;p=sdk%2Femulator%2Femulator-manager.git Device Template: add custom device template icon - seperate custom device template and standard device template - add refresh function to device template table viewer Change-Id: If35356e594102bc7dfc4edb8a618e056bfe824d0 Signed-off-by: jihye424.kim --- diff --git a/resource/renewal/res/icon_type_mobile_custom.png b/resource/renewal/res/icon_type_mobile_custom.png new file mode 100644 index 0000000..720bb61 Binary files /dev/null and b/resource/renewal/res/icon_type_mobile_custom.png differ diff --git a/resource/renewal/res/icon_type_tv_custom.png b/resource/renewal/res/icon_type_tv_custom.png new file mode 100644 index 0000000..0f11a3a Binary files /dev/null and b/resource/renewal/res/icon_type_tv_custom.png differ diff --git a/resource/renewal/res/icon_type_wearable_custom.png b/resource/renewal/res/icon_type_wearable_custom.png new file mode 100644 index 0000000..f9a5ec3 Binary files /dev/null and b/resource/renewal/res/icon_type_wearable_custom.png differ diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java b/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java index 216f680..a557171 100644 --- a/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java @@ -45,6 +45,7 @@ import org.tizen.emulator.manager.vms.RESOLUTION; public class DeviceTemplateValue implements Cloneable { private DeviceTemplate template; + private boolean isStandard = false; private String name = ""; private String type; private String profile; @@ -89,6 +90,9 @@ public class DeviceTemplateValue implements Cloneable { if (conf.getBaseInformation() != null) { name = conf.getBaseInformation().getName(); type = conf.getBaseInformation().getType(); + if (type.equals("standard")) { + isStandard = true; + } profile = conf.getBaseInformation().getProfile(); extenstion = conf.getBaseInformation().getExtension(); priority = conf.getBaseInformation().getPriority().intValue(); @@ -180,6 +184,10 @@ public class DeviceTemplateValue implements Cloneable { return template; } + public boolean isStandard() { + return isStandard; + } + public void setTemplate(DeviceTemplate template) { this.template = template; } diff --git a/src/org/tizen/emulator/manager/platform/ProfileList.java b/src/org/tizen/emulator/manager/platform/ProfileList.java index 0fcd6c7..e639770 100644 --- a/src/org/tizen/emulator/manager/platform/ProfileList.java +++ b/src/org/tizen/emulator/manager/platform/ProfileList.java @@ -88,6 +88,10 @@ public class ProfileList { settingVMPropertyListInternal(); } + public static void settingDeviceTemplateList() { + settingDeviceTemplateListInternal(true); + } + private static void initProfileList() { File platforms = new File(FilePathResources.getPlatformsPath()); if (!platforms.exists() || !platforms.isDirectory()) { @@ -134,7 +138,7 @@ public class ProfileList { settingVMPropertyListInternal(); // make device template list - settingDeviceTemplateListInternal(); + settingDeviceTemplateListInternal(false); // remove invalid last-created property file. checkLastCreatedPropertyFile(); @@ -310,12 +314,12 @@ public class ProfileList { } } - private static void settingDeviceTemplateListInternal() { + private static void settingDeviceTemplateListInternal(boolean isRefresh) { for (Profile p : profileList) { p.clearTemplateList(); } - for (DeviceTemplate template : DeviceTemplateList.getDeviceTemplateList(false)) { + for (DeviceTemplate template : DeviceTemplateList.getDeviceTemplateList(isRefresh)) { for (Profile profile : profileList) { if (profile.getName().equals(template.getValue().getProfile())) { profile.addDeviceTemplate(template); diff --git a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java index 26cc531..7ab25e4 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ImageResources.java @@ -191,6 +191,9 @@ public enum ImageResources { ICON_TYPE_MOBILE("icon_type_mobile"), ICON_TYPE_TV("icon_type_tv"), ICON_TYPE_WEARABLE("icon_type_wearable"), + ICON_TYPE_MOBILE_CUSTOM("icon_type_mobile_custom"), + ICON_TYPE_TV_CUSTOM("icon_type_tv_custom"), + ICON_TYPE_WEARABLE_CUSTOM("icon_type_wearable_custom"), ICON_SELECTED_MOBILE("icon_selected_mobile"), ICON_SELECTED_TV("icon_selected_tv"), ICON_SELECTED_WEARABLE_ROUND("icon_selected_wearable_round"), diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java index 0713c61..9854d1b 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/DeviceTemplateTableViewer.java @@ -66,8 +66,8 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { private static final int BUTTON_WIDTH = 32; private static final int BUTTON_HEIGHT = 26; - Hyperlink baseImageList; - ImageButton refreshButton; + private Hyperlink baseImageList; + private ImageButton refreshButton; private Composite comp; private boolean isTableInitialize = false; @@ -124,7 +124,7 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { @Override public void widgetSelected(SelectionEvent arg0) { - // TODO + refreshDeviceTemplateList(); } }); @@ -146,6 +146,20 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { setLayout(); } + @Override + void showTableComposite() { + if (!isTableInitialize) { + setTemplateList(); + isTableInitialize = true; + } + + } + + public void refreshDeviceTemplateList() { + ProfileList.settingDeviceTemplateList(); + setTemplateList(); + } + private void makeProfileButton() { profileButtonList = new ArrayList(); profileButtonList.add(ProfileButtonMaker.getProfileButton("mobile", comp)); @@ -187,7 +201,7 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { }); } - private String[] titles = {"", "Type", "Name", "Resolution", "Display Size", "Ram", "Processor"}; + private String[] titles = {"Type", "Name", "Resolution", "Display Size", "Ram", "Processor"}; private void makeTable() { table = new Table(comp, SWT.BORDER); @@ -199,7 +213,6 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { table.setSelectedItemHeight(table.getItemHeight()); table.getColumn(0).setResizable(false); - table.getColumn(1).setResizable(false); table.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { @@ -209,19 +222,19 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { } }); + table.getColumn(1).addListener(SWT.Selection, table.getDefaultSortListener()); table.getColumn(2).addListener(SWT.Selection, table.getDefaultSortListener()); table.getColumn(3).addListener(SWT.Selection, table.getDefaultSortListener()); table.getColumn(4).addListener(SWT.Selection, table.getDefaultSortListener()); table.getColumn(5).addListener(SWT.Selection, table.getDefaultSortListener()); - table.getColumn(6).addListener(SWT.Selection, table.getDefaultSortListener()); - table.getColumn(1).addListener(SWT.Selection, new Listener() { + table.getColumn(0).addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { TableColumn column = (TableColumn)event.widget; // set column table.settingSortColumn(column); - // make item compareable list + // make comparable item list int dir = table.getSortDirection(); ItemProfilePair[] pairs = new ItemProfilePair[table.getItemCount()]; for (int i = 0; i < table.getItemCount(); i++) { @@ -235,20 +248,6 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { }); } - protected void tableSelected() { - // TODO Auto-generated method stub - - } - - @Override - void showTableComposite() { - if (!isTableInitialize) { - setTemplateList(); - isTableInitialize = true; - } - - } - private void setTemplateList() { table.removeAll(); for (ProfileButton pButton : profileButtonList) { @@ -260,8 +259,7 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { } } - table.getColumn(0).setWidth(30); - table.getColumn(1).setWidth(100); + table.getColumn(0).setWidth(100); for (int i = 1; i < titles.length; i++) { table.getColumn(i).pack(); } @@ -290,18 +288,22 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { } // - item.setImage(1, pButton.getIcon()); + if (template.getValue().isStandard()) { + item.setImage(0, pButton.getIcon()); + } else { + item.setImage(0, pButton.getCustomIcon()); + } setTableItemProperty(item, template); // } private void setTableItemProperty(TableItem item, DeviceTemplate template) { DeviceTemplateValue value = template.getValue(); - item.setText(2, value.getName()); - item.setText(3, value.getResolution().toString()); - item.setText(4, String.valueOf(value.getDisplaySize()) + " " + value.getDisplaySizeUnit()); - item.setText(5, String.valueOf(value.getRamSize()) + " " + value.getRamSizeUnit()); - item.setText(6, String.valueOf(value.getCpuCount())); + item.setText(1, value.getName()); + item.setText(2, value.getResolution().toString()); + item.setText(3, String.valueOf(value.getDisplaySize()) + " " + value.getDisplaySizeUnit()); + item.setText(4, String.valueOf(value.getRamSize()) + " " + value.getRamSizeUnit()); + item.setText(5, String.valueOf(value.getCpuCount())); item.setData(template); } @@ -339,6 +341,8 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { } } } + + tableSelected(); } @Override @@ -410,8 +414,30 @@ public class DeviceTemplateTableViewer extends AbstractTableViewer { } } }); + + deleteButton.setEnabled(false); + modifyButton.setEnabled(false); + cloneButton.setEnabled(false); } + private void tableSelected() { + if (table.getSelectionCount() == 0) { + deleteButton.setEnabled(false); + modifyButton.setEnabled(false); + cloneButton.setEnabled(false); + } else { + DeviceTemplate template = (DeviceTemplate)table.getSelection()[0].getData(); + if (template.getValue().isStandard()) { + deleteButton.setEnabled(false); + modifyButton.setEnabled(false); + cloneButton.setEnabled(true); + } else { + deleteButton.setEnabled(true); + modifyButton.setEnabled(true); + cloneButton.setEnabled(true); + } + } + } private void setLayout() { // composite is form layout diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButton.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButton.java index 1273d10..b914669 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButton.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButton.java @@ -40,6 +40,7 @@ public class ProfileButton { private ImageButton button; private Image icon; private Image selectedIcon; + private Image customIcon; // for create vm combo private Image createIcon; @@ -89,6 +90,10 @@ public class ProfileButton { } public Image getSelectedIcon() { + if (selectedIcon == null) { + selectedIcon = icon; + } + return selectedIcon; } @@ -97,10 +102,24 @@ public class ProfileButton { } public Image getCreateIcon() { + if (createIcon == null) { + createIcon = icon; + } return createIcon; } public void setCreateIcon(Image createIcon) { this.createIcon = createIcon; } + + public Image getCustomIcon() { + if (customIcon == null) { + customIcon = icon; + } + return customIcon; + } + + public void setCustomIcon(Image customIcon) { + this.customIcon = customIcon; + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButtonMaker.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButtonMaker.java index 8a29d16..87b4cb7 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButtonMaker.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButtonMaker.java @@ -53,6 +53,7 @@ public class ProfileButtonMaker { profileButton.setIcon(ImageResources.ICON_TYPE_MOBILE.getImage()); profileButton.setSelectedIcon(ImageResources.ICON_SELECTED_MOBILE.getImage()); profileButton.setCreateIcon(ImageResources.ICON_CREATE_MOBILE.getImage()); + profileButton.setCustomIcon(ImageResources.ICON_TYPE_MOBILE_CUSTOM.getImage()); } } else if (name.equals("tv")){ button = makeTVButton(comp); @@ -61,6 +62,7 @@ public class ProfileButtonMaker { profileButton.setIcon(ImageResources.ICON_TYPE_TV.getImage()); profileButton.setSelectedIcon(ImageResources.ICON_SELECTED_TV.getImage()); profileButton.setCreateIcon(ImageResources.ICON_CREATE_TV.getImage()); + profileButton.setCustomIcon(ImageResources.ICON_TYPE_TV_CUSTOM.getImage()); } } else if (name.equals("wearable")) { button = makeWearableButton(comp); @@ -69,6 +71,7 @@ public class ProfileButtonMaker { profileButton.setIcon(ImageResources.ICON_TYPE_WEARABLE.getImage()); profileButton.setSelectedIcon(ImageResources.ICON_SELECTED_WEARABLE_SQUARE.getImage()); profileButton.setCreateIcon(ImageResources.ICON_CREATE_WEARABLE.getImage()); + profileButton.setCustomIcon(ImageResources.ICON_TYPE_WEARABLE_CUSTOM.getImage()); } } else { Profile profile = ProfileList.getProfile(name); @@ -83,6 +86,7 @@ public class ProfileButtonMaker { profileButton.setSelectedIcon(PluginImageResources.ICON_SELECTED_TYPE.getImage(p.getName())); // TODO profileButton.setSelectedIcon(PluginImageResources.ICON_CREATE_TYPE.getImage(p.getName())); + //profileButton.setCustomIcon(ImageResources.ICON_TYPE_CUSTOM.getImage()); } } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java index 94b00b7..351cd03 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java @@ -242,6 +242,8 @@ public class VMListTable { } } } + + tableSelected(); } @Override