From 2fa9ec6e16b9be286aac964aa0dd0b5f4effbc80 Mon Sep 17 00:00:00 2001 From: jihye kim Date: Mon, 5 Aug 2013 12:45:57 +0900 Subject: [PATCH] fix detail view error (info and modify view except empty view) Signed-off-by: jihye kim --- .../tizen/emulator/manager/ui/VMsDetailView.java | 68 ++++++---- .../org/tizen/emulator/manager/ui/VMsMainView.java | 1 + .../emulator/manager/ui/detail/DetailViewItem.java | 6 +- .../emulator/manager/ui/detail/DetailViewPage.java | 34 ++--- .../emulator/manager/ui/detail/PEmptyViewPage.java | 6 +- .../emulator/manager/ui/detail/PInfoViewPage.java | 129 +++++++++++------- .../manager/ui/detail/PModifyViewPage.java | 151 +++++++++++++-------- 7 files changed, 231 insertions(+), 164 deletions(-) diff --git a/common-project/src/org/tizen/emulator/manager/ui/VMsDetailView.java b/common-project/src/org/tizen/emulator/manager/ui/VMsDetailView.java index 420fdf0..1b45b7d 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/VMsDetailView.java +++ b/common-project/src/org/tizen/emulator/manager/ui/VMsDetailView.java @@ -48,16 +48,34 @@ public class VMsDetailView { private int WIDTH = 328; private int HEIGHT = 430; + private DetailViewPage emptyView = null; + private DetailViewPage detailView = null; + private DetailViewPage modifyView = null; + + private boolean isModifyMode = false; + private boolean isChnagePlatform = false; + public VMsDetailView(Composite parent) { this.parent = parent; } + static final StackLayout stackLayout = new StackLayout(); + static DetailViewPage topViewPage; + private void setTopControl(DetailViewPage page) { + if (isChnagePlatform || stackLayout.topControl != page.getComposite()) { + stackLayout.topControl = page.getComposite(); + topViewPage = page; + page.resize(HEIGHT); + isChnagePlatform = false; + } + mainView.layout(); + } + public void setSize(int width, int height) { this.WIDTH = width; this.HEIGHT = height; - emptyView.resize(HEIGHT); - detailView.resize(HEIGHT); - modifyView.resize(HEIGHT); + + topViewPage.resize(HEIGHT); } public Point getSize() { @@ -71,14 +89,6 @@ public class VMsDetailView { return mainView; } - private DetailViewPage emptyView = null; - private DetailViewPage detailView = null; - private DetailViewPage modifyView = null; - - private final StackLayout stackLayout = new StackLayout(); - - private boolean isModifyMode = false; - public boolean isModifyMode() { return isModifyMode; } @@ -94,8 +104,9 @@ public class VMsDetailView { detailView = new PInfoViewPage(this, SWT.NONE); modifyView = new PModifyViewPage(this, SWT.NONE); - - stackLayout.topControl = detailView.getComposite(); + + setTopControl(detailView); + mainView.layout(); } @@ -103,11 +114,14 @@ public class VMsDetailView { init(WIDTH, HEIGHT); } + public void changePlatform() { + isChnagePlatform = true; + } + public void drawEmptyVM() { // for setting text emptyView.drawPropertyView(null, false); - stackLayout.topControl = emptyView.getComposite(); - mainView.layout(); + setTopControl(emptyView); } public void drawDetailVM(VMProperty property) { @@ -117,28 +131,29 @@ public class VMsDetailView { } detailView.drawPropertyView(property.getPropertyValue(), false); - stackLayout.topControl = detailView.getComposite(); - mainView.layout(); + setTopControl(detailView); } public void drawModifyVM(VMProperty property) { isModifyMode = true; - modifyView.reset(); modifyView.drawPropertyView(property.getPropertyValue(), false); - stackLayout.topControl = modifyView.getComposite(); - mainView.layout(); + setTopControl(modifyView); } public void drawCreateVM(VMPropertyValue value) { isModifyMode = true; - modifyView.reset(); - stackLayout.topControl = modifyView.getComposite(); - mainView.layout(); + setTopControl(modifyView); modifyView.drawPropertyView(value, true); } + public void drawEmptyDetailVM() { + // for all tree view + ((PEmptyViewPage)emptyView).drawEmptyDetailVM(); + setTopControl(emptyView); + } + public void close() { emptyView.close(); detailView.close(); @@ -158,11 +173,4 @@ public class VMsDetailView { modifyView.setFocus(setFocus); } } - - public void drawEmptyDetailVM() { - // for all tree view - ((PEmptyViewPage)emptyView).drawEmptyDetailVM(); - stackLayout.topControl = emptyView.getComposite(); - mainView.layout(); - } } diff --git a/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java b/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java index 253cc11..18ac338 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java +++ b/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java @@ -158,6 +158,7 @@ public class VMsMainView { this.currentPlatform = platform; listView.drawPlatform(platform, index, isRefresh); + detailView.changePlatform(); } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java index 158ef48..ce58101 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java @@ -258,14 +258,14 @@ public abstract class DetailViewItem implements IInfoViewItem, IModifyViewItem { FormData data = new FormData(); data.height = 0; compList.get(i).setLayoutData(data); - compList.get(i).layout(true, false); - compList.get(i).getParent().layout(); + compList.get(i).getParent().layout(true, false); } if (downItem != null) { downItem.changeUpComposite(compList.get(0)); } compList.get(0).getParent().getParent().layout(); + compList.get(0).getParent().getParent().getParent().layout(); } else { /* @@ -287,12 +287,12 @@ public abstract class DetailViewItem implements IInfoViewItem, IModifyViewItem { data.height = ITEM_HEIGHT; compList.get(i).setLayoutData(data); compList.get(i).getParent().layout(true, false); - compList.get(i).getParent().getParent().layout(); } if (downItem != null) { downItem.changeUpComposite(compList.get(count-1)); } compList.get(0).getParent().getParent().layout(); + compList.get(0).getParent().getParent().getParent().layout(); } } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java b/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java index 5d75bc0..f7f0e8a 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java @@ -57,7 +57,6 @@ public abstract class DetailViewPage { protected CustomScrolledComposite scrolledList= null; protected Composite itemList = null; protected Composite buttonComp = null; - private Point itemListSize = new Point(0, 0); protected int ITEM_COUNT = 11; @@ -173,10 +172,9 @@ public abstract class DetailViewPage { public void settingItemList() { Image image = PatchImageResources.getDetailListView(checkItemCountwithSize()); Image image2 = PatchImageResources.getDetailListView2(checkItemCountwithSize()); - + itemListBack.setBackgroundImage(image); scrolledList.setBackgroundImage(image2); - //itemList.setBackgroundImage(image3); FormData data = new FormData(); data.left = new FormAttachment(0, 10); @@ -198,13 +196,14 @@ public abstract class DetailViewPage { int count = checkItemCount(); if (count != 0) { Image image3 = PatchImageResources.getDetailListView2(count); - itemListSize.x = image3.getImageData().width; - itemListSize.y = image3.getImageData().height; + Point size = new Point(image3.getImageData().width, + image3.getImageData().height); if (stackLayout.topControl != null) { stackLayout.topControl.setBackgroundImage(image3); - stackLayout.topControl.setSize(itemListSize); + stackLayout.topControl.setSize(size); } - //itemList.setSize(itemListSize); + itemList.setSize(size); + itemList.layout(); } itemListBack.layout(true, false); } @@ -213,24 +212,13 @@ public abstract class DetailViewPage { settingItemList(); } - public abstract void drawInitView(); - public abstract void reset(); - public abstract void setFocus(boolean setFocus); - public abstract void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate); - - public void setItemListSize(int width, int height) { - itemListSize.x = width; - itemListSize.y = height; - } - - public Point getItemListSize() { - return itemListSize; - } - public void setStackTop(Composite comp) { stackLayout.topControl = comp; scrolledList.setContent(comp); - itemList.layout(true, false); - scrolledList.layout(); } + + public abstract void drawInitView(); + public abstract void reset(); + public abstract void setFocus(boolean setFocus); + public abstract void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate); } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java b/common-project/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java index b37e56e..a4a33dd 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java @@ -65,8 +65,10 @@ public class PEmptyViewPage extends DetailViewPage { title.setLayoutData(data); data = new FormData(); - data.width = this.getItemListSize().x; - data.height = this.getItemListSize().y; + data.left = new FormAttachment(0, 0); + data.right = new FormAttachment(100, 0); + data.top = new FormAttachment(0, 0); + data.bottom = new FormAttachment(100, 0); comp.setLayoutData(data); comp.layout(true, false); diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java b/common-project/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java index 5def9e4..f8ef409 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java @@ -37,6 +37,8 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; 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.plugin.EMPluginList; import org.tizen.emulator.manager.plugin.ExtensionItem; @@ -71,36 +73,15 @@ public class PInfoViewPage extends DetailViewPage { @Override public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - } }); modifyButton.setToolTipText("modify property of vm"); topButton = modifyButton; - makeButton(); - makeDetailView(); - } - private ArrayList list; - private void makeDetailView() { - list = new ArrayList(); - Extension point = EMPluginList.getExtension(PluginStringResources.ItemFactory); - for (ExtensionItem item : point.getItemList()) { - list.add(new DetailViewItemList(item, this)); - } -/* - IInfoViewItem item = null; - DetailViewItem up = null; - for (int i = 0; i < list.size(); i++) { - item = list.get(i); - item.initItem(itemList, up); - item.drawDetail(); - up = (DetailViewItem) item; - } - itemList.layout(true, true); - */ + makeDetailView(); + makeButton(); } private ImageButton exportButton; @@ -192,55 +173,107 @@ public class PInfoViewPage extends DetailViewPage { }); } + + private ArrayList itemList; + private void makeDetailView() { + itemList = new ArrayList(); + Extension point = EMPluginList.getExtension(PluginStringResources.ItemFactory); + for (ExtensionItem item : point.getItemList()) { + itemList.add(new InfoViewItemList(item, this.getItemListComposite())); + } + } + + private InfoViewItemList topViewList; + private boolean needChangeItemList(VMPropertyValue propertyValue) { + if (topViewList == null + || !topViewList.exItem.getProfile().equals(propertyValue.profile)) { + return true; + } + return false; + } + + private void changeItemList(VMPropertyValue propertyValue) { + for (InfoViewItemList item : itemList) { + if (item.exItem.getProfile().equals(propertyValue.profile)) { + topViewList = item; + setStackTop(topViewList.comp); + reset(); + settingItemList(); + break; + } + } + } + @Override public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) { assert propertyValue == null; - for (DetailViewItemList item : list) { - if (item.getProfile().equals(propertyValue.profile)) { - for (IInfoViewItem i : item.getInfoItemList()) { - i.settingDetailItem(propertyValue); - } - setStackTop(item.getInfoComposite()); - break; - } + if (needChangeItemList(propertyValue)) { + changeItemList(propertyValue); + } + + for (IInfoViewItem i : topViewList.itemList) { + i.settingDetailItem(propertyValue); } } @Override public int checkItemCount() { - if (list == null || list.isEmpty()) { + if (itemList == null || topViewList == null) { return checkItemCountwithSize(); } + int count = 0; - for (DetailViewItemList item : list) { - if (stackLayout.topControl == item.getInfoComposite()) { - for (IInfoViewItem i : item.getInfoItemList()) { - count += i.getCount(); - } - break; - } + + for (IInfoViewItem i : topViewList.itemList) { + count += i.getCount(); } + return count; } @Override public void reset() { scrolledList.setOrigin(0, 0); - for (DetailViewItemList item : list) { - for (IInfoViewItem i : item.getInfoItemList()) { + if (topViewList != null) { + for (IInfoViewItem i : topViewList.itemList) { i.settingStatus(true); } } - /* - for (int i = 0; i < list.size(); i++) { - list.get(i).settingStatus(true); - } - */ } @Override public void setFocus(boolean setFocus) { - // TODO Auto-generated method stub - + // empty } } + +class InfoViewItemList { + ExtensionItem exItem; + Composite comp; + ArrayList itemList; + + InfoViewItemList(ExtensionItem item, Composite parent) { + exItem = item; + makeItemList(parent); + } + + private void makeItemList(Composite parent) { + comp = new Composite(parent, SWT.NONE); + comp.setLayout(new FormLayout()); + + IItemListFactory f = (IItemListFactory)(exItem.createClass()); + itemList = new ArrayList(); + itemList = f.getInfoItemList(); + + // init itemList + IInfoViewItem infoItem = null; + DetailViewItem up = null; + for (int i = 0; i < itemList.size(); i++) { + infoItem = (IInfoViewItem) itemList.get(i); + infoItem.initItem(comp, up); + infoItem.drawDetail(); + up = (DetailViewItem) infoItem; + } + comp.layout(true, true); + } +} \ No newline at end of file diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java b/common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java index 89571f8..3a790d7 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java @@ -37,6 +37,8 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; 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.logging.EMLogger; import org.tizen.emulator.manager.plugin.EMPluginList; import org.tizen.emulator.manager.plugin.ExtensionItem; @@ -89,37 +91,6 @@ public class PModifyViewPage extends DetailViewPage makeModifyView(); } - protected void cancelModify() { - if (isCreateMode) { - VMsMainView.getInstance().drawCancelCreaetVM(); - isCreateMode = false; - } else { - VMsMainView.getInstance().drawDetailVM(); - } - } - - private ArrayList list; - private void makeModifyView() { - list = new ArrayList(); - Extension point = EMPluginList.getExtension(PluginStringResources.ItemFactory); - for (ExtensionItem item : point.getItemList()) { - list.add(new DetailViewItemList(item, this)); - } - /* - IModifyViewItem item = null; - DetailViewItem up = null; - for (int i = 0; i < list.size(); i++) { - item = list.get(i); - item.initItem(itemList, up); - item.drawModify(); - item.setListener(this); - up = (DetailViewItem) item; - } - - itemList.layout(true, true); - */ - } - private static int CONFIRM_BUTTON_WIDTH = 303; private static int CONFIRM_BUTTON_HEIGHT = 36; private static Image CONFIRM_BUTTON_IMAGE = null; @@ -154,15 +125,49 @@ public class PModifyViewPage extends DetailViewPage }); } - private void modifyVMProperty() { - for (DetailViewItemList item : list) { - if (stackLayout.topControl == item.getModifyComposite()) { - for (IModifyViewItem i : item.getModifyItemList()) { - i.setValue(newValue); - } + protected void cancelModify() { + if (isCreateMode) { + VMsMainView.getInstance().drawCancelCreaetVM(); + isCreateMode = false; + } else { + VMsMainView.getInstance().drawDetailVM(); + } + } + + private ArrayList itemList; + private void makeModifyView() { + itemList = new ArrayList(); + Extension point = EMPluginList.getExtension(PluginStringResources.ItemFactory); + for (ExtensionItem item : point.getItemList()) { + itemList.add(new ModifyViewItemList(item, this)); + } + } + + private ModifyViewItemList topViewList; + private boolean needChangeItemList(VMPropertyValue propertyValue) { + if (topViewList == null + || !topViewList.exItem.getProfile().equals(propertyValue.profile)) { + return true; + } + return false; + } + + private void changeItemList(VMPropertyValue propertyValue) { + for (ModifyViewItemList item : itemList) { + if (item.exItem.getProfile().equals(propertyValue.profile)) { + topViewList = item; + setStackTop(topViewList.comp); + reset(); + settingItemList(); break; } } + } + + private void modifyVMProperty() { + for (IModifyViewItem i : topViewList.itemList) { + i.setValue(newValue); + } // dpi check if (newValue.dpi < VMProperty.MIN_DPI @@ -200,15 +205,15 @@ public class PModifyViewPage extends DetailViewPage oldValue = propertyValue; newValue = oldValue.clone(); - for (DetailViewItemList item : list) { - if (item.getProfile().equals(propertyValue.profile)) { - for (IModifyViewItem i : item.getModifyItemList()) { - i.setCreateMode(isCreate); - i.settingModifyItem(propertyValue); - } - setStackTop(item.getModifyComposite()); - break; - } + if (needChangeItemList(propertyValue)) { + changeItemList(propertyValue); + } else { + reset(); + } + + for (IModifyViewItem i : topViewList.itemList) { + i.setCreateMode(isCreate); + i.settingModifyItem(propertyValue); } } @@ -241,26 +246,24 @@ public class PModifyViewPage extends DetailViewPage @Override public int checkItemCount() { - if (list == null || list.isEmpty()) { + if (itemList == null || topViewList == null) { return checkItemCountwithSize(); } + int count = 0; - for (DetailViewItemList item : list) { - if (stackLayout.topControl == item.getModifyComposite()) { - for (IModifyViewItem i : item.getModifyItemList()) { - count += i.getCount(); - } - break; - } + + for (IModifyViewItem i : topViewList.itemList) { + count += i.getCount(); } + return count; } @Override public void reset() { scrolledList.setOrigin(0, 0); - for (DetailViewItemList item : list) { - for (IModifyViewItem i : item.getModifyItemList()) { + if (topViewList != null) { + for (IModifyViewItem i : topViewList.itemList) { i.settingStatus(true); } } @@ -268,10 +271,42 @@ public class PModifyViewPage extends DetailViewPage @Override public void setFocus(boolean setFocus) { - for (DetailViewItemList item : list) { - for (IModifyViewItem i : item.getModifyItemList()) { + if (topViewList != null) { + for (IModifyViewItem i : topViewList.itemList) { i.settingStatus(false); } } } } + +class ModifyViewItemList { + ExtensionItem exItem; + Composite comp; + ArrayList itemList; + + ModifyViewItemList(ExtensionItem item, PModifyViewPage page) { + exItem = item; + makeItemList(page); + } + + private void makeItemList(PModifyViewPage page) { + comp = new Composite(page.getItemListComposite(), SWT.NONE); + comp.setLayout(new FormLayout()); + + IItemListFactory f = (IItemListFactory)(exItem.createClass()); + itemList = new ArrayList(); + itemList = f.getModifyItemList(); + + // init itemList + IModifyViewItem modifyItem = null; + DetailViewItem up = null; + for (int i = 0; i < itemList.size(); i++) { + modifyItem = (IModifyViewItem) itemList.get(i); + modifyItem.initItem(comp, up); + modifyItem.drawModify(); + modifyItem.setListener(page); + up = (DetailViewItem) modifyItem; + } + comp.layout(true, true); + } +} \ No newline at end of file -- 2.7.4