From 777bfd9939a8598c7c479141f01ce89aefc5ddbe Mon Sep 17 00:00:00 2001 From: "nakyoung2.choi" Date: Thu, 8 May 2014 15:28:05 +0900 Subject: [PATCH] PROP : Fix expansion function of CSS Selector Category. Change-Id: I9305e14addea3b679843380b25ee7ceb74b27188 Signed-off-by: nakyoung2.choi --- .../style/CssSelectorCategoryComposite.java | 54 ++++++++++++++++------ .../ui/views/properties/style/CssStyleTab.java | 10 ++++ 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssSelectorCategoryComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssSelectorCategoryComposite.java index d7837b7..0e52ba9 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssSelectorCategoryComposite.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssSelectorCategoryComposite.java @@ -47,6 +47,8 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,6 +73,22 @@ public class CssSelectorCategoryComposite extends CategoryComposite implements I private CssStyleEventDelegater delegater; private List currentSelectors; private Map> selectorMap = new HashMap>(); + private Composite buttons; + private ExpansionAdapter expansionListener = new ExpansionAdapter() { + + @Override + public void expansionStateChanged(ExpansionEvent e) { + ExpandableComposite expandableComposite = (ExpandableComposite) e.getSource(); + if (e.getState()) { + if (buttons == null || buttons.isDisposed()) { + createButtons(); + } + expandableComposite.setTextClient(buttons); + } else { + expandableComposite.setTextClient(null); + } + } + }; public CssSelectorCategoryComposite(Composite parent, String name, CssFile cssFile, CssStyleEventDelegater delegater) { @@ -86,6 +104,10 @@ public class CssSelectorCategoryComposite extends CategoryComposite implements I @Override public void dispose() { cssFile.removeCssSelectorListener(this); + ExpandableComposite expandableComposite = getExpandableComposite(); + expandableComposite.removeExpansionListener(expansionListener); + super.dispose(); + } private void createListBox() { @@ -96,19 +118,8 @@ public class CssSelectorCategoryComposite extends CategoryComposite implements I composite.setLayout(new FormLayout()); /* buttons */ - Composite btns = new Composite(expandableComposite, SWT.NONE); - btns.setLayout(new RowLayout()); - - Label addButton = new Label(btns, SWT.NONE); - Label deleteButton = new Label(btns, SWT.NONE); - addButton.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, - "animator_action_add_normal.png")); - addMouseListenerForSelector(addButton, "add"); - deleteButton.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, - "animator_action_delete_normal.png")); - addMouseListenerForSelector(deleteButton, "delete"); - expandableComposite.setTextClient(btns); - /* buttons */ + createButtons(); + expandableComposite.setTextClient(buttons); listBox = new Table(composite, SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER); listBox.setLinesVisible(false); @@ -125,6 +136,23 @@ public class CssSelectorCategoryComposite extends CategoryComposite implements I listBox.setLayoutData(formData); expandableComposite.pack(); + + expandableComposite.addExpansionListener(expansionListener); + } + + private void createButtons() { + ExpandableComposite expandableComposite = getExpandableComposite(); + buttons = new Composite(expandableComposite, SWT.NONE); + buttons.setLayout(new RowLayout()); + + Label addButton = new Label(buttons, SWT.NONE); + Label deleteButton = new Label(buttons, SWT.NONE); + addButton.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, + "animator_action_add_normal.png")); + addMouseListenerForSelector(addButton, "add"); + deleteButton.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, + "animator_action_delete_normal.png")); + addMouseListenerForSelector(deleteButton, "delete"); } private void addMouseListenerForSelector(final Label label, final String function) { diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssStyleTab.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssStyleTab.java index cff0896..d74f851 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssStyleTab.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssStyleTab.java @@ -273,6 +273,16 @@ public class CssStyleTab extends PropertiesTabItem implements IPageDataListener private void createCssSelectorCategory() { cssCategory = new CssSelectorCategoryComposite(categoryContainer, "CSS Selector", cssFile, cssDelegater); cssCategory.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + cssCategory.addExpansionListener(new ExpansionAdapter() { + + @Override + public void expansionStateChanged(ExpansionEvent e) { + content.pack(); + content.layout(); + resizeScrolledComposite(); + } + }); } /** -- 2.7.4