From e44210c0274a40d4453a0d322fa7492b4960e828 Mon Sep 17 00:00:00 2001 From: "jihye1128.kim" Date: Tue, 16 Apr 2013 16:30:38 +0900 Subject: [PATCH] [Title] emulator-manager : resize emulator-manager [Desc.] resize emulator-manager [Issue] N/A Change-Id: I235956464481033f789e48571af15d196f6f1532 --- .../tizen/emulator/manager/EmulatorManager.java | 2 +- src/org/tizen/emulator/manager/ui/MainDialog.java | 48 +++++++++++-- .../tizen/emulator/manager/ui/VMsDetailView.java | 3 + src/org/tizen/emulator/manager/ui/VMsListView.java | 82 +++++++++++++++------- src/org/tizen/emulator/manager/ui/VMsMainView.java | 21 ++++-- .../emulator/manager/ui/detail/DetailViewPage.java | 19 ++++- .../emulator/manager/ui/detail/PEmptyViewPage.java | 17 +++++ .../emulator/manager/ui/detail/PInfoViewPage.java | 15 ++++ .../manager/ui/detail/PModifyViewPage.java | 15 ++++ .../manager/ui/tabfolder/PlatformTabFolder.java | 2 +- 10 files changed, 182 insertions(+), 42 deletions(-) diff --git a/src/org/tizen/emulator/manager/EmulatorManager.java b/src/org/tizen/emulator/manager/EmulatorManager.java index 831f203..88cbe0b 100755 --- a/src/org/tizen/emulator/manager/EmulatorManager.java +++ b/src/org/tizen/emulator/manager/EmulatorManager.java @@ -220,7 +220,7 @@ public class EmulatorManager { public static void main(String[] args) { if (isMac()) { - //TODO: event handling of about menu + //TODO : event handling of about menu System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Emulator Manager"); } diff --git a/src/org/tizen/emulator/manager/ui/MainDialog.java b/src/org/tizen/emulator/manager/ui/MainDialog.java index 22f0c98..a13adf5 100644 --- a/src/org/tizen/emulator/manager/ui/MainDialog.java +++ b/src/org/tizen/emulator/manager/ui/MainDialog.java @@ -33,9 +33,10 @@ package org.tizen.emulator.manager.ui; import java.io.InputStream; import java.util.ArrayList; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.events.ShellListener; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -59,16 +60,22 @@ import org.tizen.emulator.manager.ui.tabfolder.PlatformTabItem; public class MainDialog { private static final String ICON_FILE_NAME = "res/em.ico"; - public static final int WIDTH = 840; - public static final int HEIGHT = 482; + public static final int DEFALUT_WIDTH = 840; + public static final int DEFAULT_HEIGHT = 482; + public static final int MIN_HEIGHT = 483; + public static final int MIN_WIDTH = 500; + public static int WIDTH = DEFALUT_WIDTH; + public static int HEIGHT = DEFAULT_HEIGHT; static Shell shell = null; Image icon; + private int frameX = 0; + private int frameY = 0; public MainDialog(ManagerModeType mode) { Display.setAppName("Emulator Manager"); - shell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.TITLE | SWT.MIN); + shell = new Shell(Display.getCurrent()); // shell.setBackground(ColorResources.TAB_BG_COLOR.getColor()); // @@ -76,7 +83,11 @@ public class MainDialog { final Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); - + shell.setMinimumSize(MIN_WIDTH, MIN_HEIGHT); + frameX = shell.getSize().x - shell.getClientArea().width; + frameY = shell.getSize().y - shell.getClientArea().height; + shell.setSize(WIDTH + frameX, HEIGHT + frameY); + /* shell.addShellListener(new ShellListener() { public void shellIconified(ShellEvent e) { } @@ -92,6 +103,7 @@ public class MainDialog { shell.setSize(WIDTH + frameX, HEIGHT + frameY); } }); + */ if (mode.equals(ManagerModeType.INHOUSE_MODE)) { shell.setText(StringResources.MAIN_TITLE_INHOUSE); @@ -116,6 +128,28 @@ public class MainDialog { // TODO mainComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor()); mainComposite.setLayout(new FormLayout()); + mainComposite.addControlListener(new ControlListener() { + @Override + public void controlMoved(ControlEvent arg0) { + // TODO Auto-generated method stub + } + + @Override + public void controlResized(ControlEvent e) { + Composite comp = (Composite)e.widget; + Rectangle rect = comp.getBounds(); + WIDTH = MIN_WIDTH > rect.width ? MIN_WIDTH : rect.width; + HEIGHT = MIN_HEIGHT > rect.height ? MIN_HEIGHT : rect.height; + + FormData data = new FormData(); + data.top = new FormAttachment(0, 0); + data.left = new FormAttachment(0, 0); + data.right = new FormAttachment(100, 0); + data.height = HEIGHT - 22; // - status bar - offset; + tabFolder.getComposite().setLayoutData(data); + comp.redraw(); + } + }); tabFolder = new PlatformTabFolder(mainComposite); statusBar = new StatusBar(mainComposite); @@ -127,7 +161,7 @@ public class MainDialog { data.top = new FormAttachment(0, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); - data.height = 460; + data.height = HEIGHT - 22; // status bar - offset; //data.bottom = new FormAttachment(barComposite, 0); tabComposite.setLayoutData(data); diff --git a/src/org/tizen/emulator/manager/ui/VMsDetailView.java b/src/org/tizen/emulator/manager/ui/VMsDetailView.java index 6792a76..71da390 100644 --- a/src/org/tizen/emulator/manager/ui/VMsDetailView.java +++ b/src/org/tizen/emulator/manager/ui/VMsDetailView.java @@ -25,6 +25,9 @@ public class VMsDetailView { public void setSize(int width, int height) { this.WIDTH = width; this.HEIGHT = height; + emptyView.resize(HEIGHT); + detailView.resize(HEIGHT); + modifyView.resize(HEIGHT); } public Point getSize() { diff --git a/src/org/tizen/emulator/manager/ui/VMsListView.java b/src/org/tizen/emulator/manager/ui/VMsListView.java index cd7600a..28957fe 100644 --- a/src/org/tizen/emulator/manager/ui/VMsListView.java +++ b/src/org/tizen/emulator/manager/ui/VMsListView.java @@ -22,19 +22,29 @@ import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.ImageResources; import org.tizen.emulator.manager.ui.widgets.VMButton; +enum VIEW_STATE { + EMPTY, DETAIL, MODIFY, CREATE; +} public class VMsListView { private Composite parent = null; private Composite listView = null; private int WIDTH = 510; private int HEIGHT = 430; + private int LIST_WIDTH = 485; // -25 + private int LIST_HEIGHT = 378; // -52 + + // for resize + private VIEW_STATE state; public VMsListView(Composite parent) { this.parent = parent; } public void setSize(int width, int height) { - this.WIDTH = width; + this.WIDTH = width; this.HEIGHT = height; + this.LIST_WIDTH = WIDTH - 25; + this.LIST_HEIGHT = HEIGHT - 52; } public Point getSize() { @@ -98,7 +108,7 @@ public class VMsListView { private Text dumyText = null; private void makeVMList() { - scrolledList = new ScrolledComposite(listView, SWT.V_SCROLL); + scrolledList = new ScrolledComposite(listView, SWT.V_SCROLL | SWT.BORDER); FormData data = new FormData(); data.left = new FormAttachment(0, 10); data.top = new FormAttachment(0, 40); @@ -107,8 +117,7 @@ public class VMsListView { scrolledList.setLayoutData(data); scrolledList.setBackground(ColorResources.LIST_BG_COLOR.getColor()); - vmList = new Composite(scrolledList, SWT.BORDER); - // TODO + vmList = new Composite(scrolledList, SWT.NONE); vmList.setBackground(ColorResources.LIST_BG_COLOR.getColor()); data = new FormData(); data.left = new FormAttachment(0, 0); @@ -127,7 +136,7 @@ public class VMsListView { data = new FormData(); data.left = new FormAttachment(0, -100); data.top = new FormAttachment(0, 0); - data.width = 0; + data.width = 0; data.height = 0; dumyText.setLayoutData(data); dumyText.addKeyListener(new KeyAdapter() { @@ -148,16 +157,13 @@ public class VMsListView { VMsMainView.getInstance().drawVMList(imageIndex); } - // TODO - private int LIST_HEIGHT = 379; - private int LIST_WIDTH = 484; - private int WIDTH_GAP = 10; - private int HEIGHT_GAP = 12; + private int W_GAP = 10; + private int H_GAP = 12; private int BUTTON_WIDTH = 106 + 4; private int BUTTON_HEIGHT = 146 + 4; - private int WIDTH_COUNT = 0; - private int HEIGHT_COUNT = 0; + private int W_COUNT = 0; + private int H_COUNT = 0; private DACustomButton createButton = null; // for empty list private VMButton addNewButton = null; @@ -170,6 +176,8 @@ public class VMsListView { return; } + state = VIEW_STATE.EMPTY; + // clear VMButtonFactory.clear(); @@ -209,19 +217,25 @@ public class VMsListView { select = 0; } - WIDTH_COUNT = LIST_WIDTH / (BUTTON_WIDTH + WIDTH_GAP); + if (isCreate) { + state = VIEW_STATE.CREATE; + } else { + state = VIEW_STATE.DETAIL; + } + + W_COUNT = LIST_WIDTH / (BUTTON_WIDTH + W_GAP); int wIndex = 0; int hIndex = 0; VMButtonFactory.clear(); if (base.getVmsList().size() != 0) { - HEIGHT_COUNT = (base.getVmsList().size() + 1) / WIDTH_COUNT; - if ((base.getVmsList().size() + 1) % WIDTH_COUNT != 0) { - HEIGHT_COUNT++; + H_COUNT = (base.getVmsList().size() + 1) / W_COUNT; + if ((base.getVmsList().size() + 1) % W_COUNT != 0) { + H_COUNT++; } - if (((BUTTON_HEIGHT + HEIGHT_GAP) * HEIGHT_COUNT) > LIST_HEIGHT) { - vmList.setSize(LIST_WIDTH, ((BUTTON_HEIGHT + HEIGHT_GAP) * HEIGHT_COUNT) + HEIGHT_GAP); + if (((BUTTON_HEIGHT + H_GAP) * H_COUNT) > LIST_HEIGHT) { + vmList.setSize(LIST_WIDTH, ((BUTTON_HEIGHT + H_GAP) * H_COUNT) + H_GAP); } else { vmList.setSize(LIST_WIDTH, LIST_HEIGHT); } @@ -230,8 +244,8 @@ public class VMsListView { VMButton button = null; for (int i = 0; i < base.getVmsList().size(); i++) { data = new FormData(); - data.left = new FormAttachment(0, WIDTH_GAP + (BUTTON_WIDTH + WIDTH_GAP) * wIndex); - data.top = new FormAttachment(0, HEIGHT_GAP + (BUTTON_HEIGHT + HEIGHT_GAP) * hIndex); + data.left = new FormAttachment(0, W_GAP + (BUTTON_WIDTH + W_GAP) * wIndex); + data.top = new FormAttachment(0, H_GAP + (BUTTON_HEIGHT + H_GAP) * hIndex); data.width = BUTTON_WIDTH; data.height = BUTTON_HEIGHT; button = VMButtonFactory.getButton(vmList); @@ -243,7 +257,7 @@ public class VMsListView { button.redraw(); ++wIndex; - if (wIndex == WIDTH_COUNT) { + if (wIndex == W_COUNT) { wIndex = 0; hIndex++; } @@ -265,8 +279,8 @@ public class VMsListView { }); FormData data = new FormData(); - data.left = new FormAttachment(0, WIDTH_GAP + (BUTTON_WIDTH + WIDTH_GAP) * wIndex); - data.top = new FormAttachment(0, HEIGHT_GAP + (BUTTON_HEIGHT + HEIGHT_GAP) * hIndex); + data.left = new FormAttachment(0, W_GAP + (BUTTON_WIDTH + W_GAP) * wIndex); + data.top = new FormAttachment(0, H_GAP + (BUTTON_HEIGHT + H_GAP) * hIndex); data.width = BUTTON_WIDTH; data.height = BUTTON_HEIGHT; addNewButton.setLayoutData(data); @@ -293,14 +307,14 @@ public class VMsListView { break; case SWT.ARROW_UP: int size = VMButtonFactory.getButtonList().size(); - int index = VMButtonFactory.getSelectedButtonIndex() - WIDTH_COUNT; + int index = VMButtonFactory.getSelectedButtonIndex() - W_COUNT; if (index >= 0) { VMButtonFactory.clickVMButton(index); } break; case SWT.ARROW_DOWN: size = VMButtonFactory.getButtonList().size(); - index = VMButtonFactory.getSelectedButtonIndex() + WIDTH_COUNT; + index = VMButtonFactory.getSelectedButtonIndex() + W_COUNT; if (index < size) { VMButtonFactory.clickVMButton(index); } else { @@ -356,6 +370,24 @@ public class VMsListView { scrolledList.layout(true, true); } + public void redraw() { + switch(state) { + case EMPTY: + drawEmptyVMList(); + break; + case DETAIL: + drawVMList(VMsMainView.getInstance().getCurrentImage(), + VMsMainView.getInstance().getCurrentImage().getVmsList().indexOf( + VMsMainView.getInstance().getCurrentProperty()), false); + break; + case CREATE: + drawVMList(VMsMainView.getInstance().getCurrentImage(), -1, true); + break; + case MODIFY: + break; + } + } + public void close() { imageCombo.dispose(); VMButtonFactory.clear(); diff --git a/src/org/tizen/emulator/manager/ui/VMsMainView.java b/src/org/tizen/emulator/manager/ui/VMsMainView.java index 60a967c..1a2dbe7 100644 --- a/src/org/tizen/emulator/manager/ui/VMsMainView.java +++ b/src/org/tizen/emulator/manager/ui/VMsMainView.java @@ -1,5 +1,8 @@ package org.tizen.emulator.manager.ui; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; @@ -7,6 +10,7 @@ import org.eclipse.swt.widgets.Composite; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.platform.Platform; +import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.tool.SelectTemplate; import org.tizen.emulator.manager.ui.dialog.MessageDialog; @@ -47,7 +51,8 @@ public class VMsMainView { mainView = new Composite(parent, SWT.NONE); mainView.setLayout(new FormLayout()); -/* + mainView.setBackground(ColorResources.RED.getColor()); + mainView.addControlListener(new ControlListener() { @Override @@ -58,12 +63,16 @@ public class VMsMainView { public void controlResized(ControlEvent e) { Composite c = (Composite)e.widget; Rectangle rect = c.getBounds(); - listView.getControl().setSize(rect.x - 325, rect.y); - listView.getControl().update(); + int width = detailView.getSize().x; + + listView.setSize(rect.width - width, rect.height); + detailView.setSize(width, rect.height); + + listView.redraw(); } }); -*/ + listView = new VMsListView(mainView); detailView = new VMsDetailView(mainView); @@ -72,9 +81,9 @@ public class VMsMainView { data.left = new FormAttachment(0, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); - data.width = listView.getSize().x; + data.right = new FormAttachment(100, -detailView.getSize().x); listView.getComposite().setLayoutData(data); - + data = new FormData(); data.left = new FormAttachment(listView.getComposite(), 0); data.top = new FormAttachment(0, 0); diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java index 250224e..3b64ebc 100644 --- a/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java @@ -24,6 +24,20 @@ public abstract class DetailViewPage { protected Composite buttonComp = null; protected int ITEM_COUNT = 11; + public int checkItemCount() { + int h = parent.getSize().y - 30 - 36 - 60; + int middleH = ImageResources.DETAIL_LIST_MIDDLE.getImage().getImageData().height; + int bottomH = ImageResources.DETAIL_LIST_BOTTOM.getImage().getImageData().height; + + int count = h / middleH; + int l = h % middleH; + if (l != 0 && l >= bottomH - middleH) { + ITEM_COUNT = count; + } else { + ITEM_COUNT = count - 1; + } + return ITEM_COUNT; + } public DetailViewPage(VMsDetailView parent, int style) { this.parent = parent; view = new Composite((Composite)parent.getComposite(), style); @@ -37,7 +51,7 @@ public abstract class DetailViewPage { itemList = new Composite(view, SWT.NONE); // TODO - Image image = PatchImageResources.getDetailListView(ITEM_COUNT); + Image image = PatchImageResources.getDetailListView(checkItemCount()); itemList.setBackgroundImage(image); itemList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor()); @@ -61,7 +75,7 @@ public abstract class DetailViewPage { buttonComp = new Composite(view, SWT.NONE); data = new FormData(); data.left = new FormAttachment(0, 10); - data.top = new FormAttachment(itemList, 10); + data.top = new FormAttachment(itemList, 12); data.right = new FormAttachment(100, -10); data.bottom = new FormAttachment(100, -10); buttonComp.setLayoutData(data); @@ -112,5 +126,6 @@ public abstract class DetailViewPage { } protected abstract void drawInitView(); + public abstract void resize(int height); public abstract void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate); } diff --git a/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java index 9a3e72e..67e651e 100644 --- a/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java @@ -1,12 +1,14 @@ package org.tizen.emulator.manager.ui.detail; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Label; import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.FontResources; +import org.tizen.emulator.manager.resources.PatchImageResources; import org.tizen.emulator.manager.ui.VMsDetailView; import org.tizen.emulator.manager.vms.VMPropertyValue; @@ -40,5 +42,20 @@ public class PEmptyViewPage extends DetailViewPage { @Override public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) { // empty function + } + + @Override + public void resize(int height) { + Image image = PatchImageResources.getDetailListView(checkItemCount()); + itemList.setBackgroundImage(image); + itemList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor()); + FormData data = new FormData(); + data.left = new FormAttachment(0, 10); + data.top = new FormAttachment(itemListTop, 0); + data.height = image.getImageData().height; + data.width = image.getImageData().width; + itemList.setSize(data.width, data.height); + itemList.setLayoutData(data); + itemList.redraw(); } } diff --git a/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java index 318bb1e..5d575bc 100644 --- a/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java @@ -7,6 +7,7 @@ import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.tizen.emulator.manager.da.widgets.button.DACustomButton; import org.tizen.emulator.manager.da.widgets.button.DACustomButtonClickEventListener; +import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.ImageResources; import org.tizen.emulator.manager.resources.PatchImageResources; import org.tizen.emulator.manager.resources.StringResources; @@ -146,4 +147,18 @@ public class PInfoViewPage extends DetailViewPage { } } + @Override + public void resize(int height) { + Image image = PatchImageResources.getDetailListView(checkItemCount()); + itemList.setBackgroundImage(image); + itemList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor()); + FormData data = new FormData(); + data.left = new FormAttachment(0, 10); + data.top = new FormAttachment(itemListTop, 0); + data.height = image.getImageData().height; + data.width = image.getImageData().width; + itemList.setSize(data.width, data.height); + itemList.setLayoutData(data); + itemList.redraw(); + } } diff --git a/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java index 27e7714..ee30670 100644 --- a/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java @@ -181,4 +181,19 @@ public class PModifyViewPage extends DetailViewPage } } // + + @Override + public void resize(int height) { + Image image = PatchImageResources.getDetailListView(checkItemCount()); + itemList.setBackgroundImage(image); + itemList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor()); + FormData data = new FormData(); + data.left = new FormAttachment(0, 10); + data.top = new FormAttachment(itemListTop, 0); + data.height = image.getImageData().height; + data.width = image.getImageData().width; + itemList.setSize(data.width, data.height); + itemList.setLayoutData(data); + itemList.redraw(); + } } diff --git a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java index f68fa05..b3ef432 100644 --- a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java +++ b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java @@ -119,7 +119,7 @@ public class PlatformTabFolder { } public void redraw() { - // TODO + items.get(getSelectionIndex()).redraw(); } private PlatformTabButton makeTabButton(PlatformTabItem item) { -- 2.7.4