Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMélanie Bats2017-05-16 16:04:01 +0000
committerStéphane Bégaudeau2017-05-22 08:14:29 +0000
commit36fed57ece5f11fbe32bb7fa63210a68a8d167c0 (patch)
treec1d4a972f72841ec323360977c97553176941681
parent790154e3e22c9f323381b385057bd386c4fbc130 (diff)
downloadorg.eclipse.eef-36fed57ece5f11fbe32bb7fa63210a68a8d167c0.tar.gz
org.eclipse.eef-36fed57ece5f11fbe32bb7fa63210a68a8d167c0.tar.xz
org.eclipse.eef-36fed57ece5f11fbe32bb7fa63210a68a8d167c0.zip
[516741] Recompute the property view when a group is expanded
Bug: 516741 Change-Id: I7e8fae8942e81a9dca8ac991fb13e505ee3ed8e3 Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.common.ui/src/org/eclipse/eef/common/ui/api/SWTUtils.java20
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java21
2 files changed, 40 insertions, 1 deletions
diff --git a/plugins/org.eclipse.eef.common.ui/src/org/eclipse/eef/common/ui/api/SWTUtils.java b/plugins/org.eclipse.eef.common.ui/src/org/eclipse/eef/common/ui/api/SWTUtils.java
index bd89ab292..d44d8482d 100644
--- a/plugins/org.eclipse.eef.common.ui/src/org/eclipse/eef/common/ui/api/SWTUtils.java
+++ b/plugins/org.eclipse.eef.common.ui/src/org/eclipse/eef/common/ui/api/SWTUtils.java
@@ -21,6 +21,9 @@ import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
/**
* Utility methods for SWT.
@@ -86,4 +89,21 @@ public final class SWTUtils {
}
};
}
+
+ /**
+ * Static helper method to create an expansion listener for {@link #expansionStateChanged(ExpansionEvent event)})
+ * method with a lambda expression.
+ *
+ * @param consumer
+ * The consumer of the event
+ * @return IExpansionListener
+ */
+ public static IExpansionListener expansionListenerAdapter(Consumer<ExpansionEvent> consumer) {
+ return new ExpansionAdapter() {
+ @Override
+ public void expansionStateChanged(ExpansionEvent event) {
+ consumer.accept(event);
+ }
+ };
+ }
}
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
index 7a409673c..87b4ebd23 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
@@ -23,6 +23,7 @@ import org.eclipse.eef.EEF_TITLE_BAR_STYLE;
import org.eclipse.eef.EEF_TOGGLE_STYLE;
import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
+import org.eclipse.eef.common.ui.api.SWTUtils;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
import org.eclipse.eef.core.api.controllers.IEEFController;
@@ -44,6 +45,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.Section;
/**
@@ -89,6 +91,16 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager implem
private Section section;
/**
+ * The form container.
+ */
+ private IEEFFormContainer eefFormContainer;
+
+ /**
+ * The expansion listener.
+ */
+ private IExpansionListener expansionListener;
+
+ /**
* The constructor.
*
* @param description
@@ -117,7 +129,7 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager implem
@Override
public void createControl(Composite parent, IEEFFormContainer formContainer) {
super.createControl(parent, formContainer);
-
+ this.eefFormContainer = formContainer;
EEFWidgetFactory widgetFactory = formContainer.getWidgetFactory();
Composite groupComposite = widgetFactory.createComposite(parent);
@@ -316,6 +328,10 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager implem
public void aboutToBeShown() {
super.aboutToBeShown();
+ // Refresh the page when a group is expanded in order to force the computation of the properties view height.
+ this.expansionListener = SWTUtils.expansionListenerAdapter((event) -> this.eefFormContainer.refreshPage());
+ this.section.addExpansionListener(this.expansionListener);
+
this.controller.onNewLabel((value) -> Optional.ofNullable(value).ifPresent(this.section::setText));
this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeShown);
@@ -343,6 +359,9 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager implem
super.aboutToBeHidden();
this.controller.removeNewLabelConsumer();
+ if (!this.section.isDisposed()) {
+ this.section.removeExpansionListener(this.expansionListener);
+ }
this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeHidden);
}

Back to the top