diff options
author | Mélanie Bats | 2017-05-17 13:55:33 +0000 |
---|---|---|
committer | Stéphane Bégaudeau | 2017-05-22 08:42:24 +0000 |
commit | 31168300478790d8de9b00282638141870ebcda0 (patch) | |
tree | 241be917d669b597304570474bbf88c78f8c4c6f | |
parent | 340869c5eb9b93346858bc310f1f70aede95c799 (diff) | |
download | org.eclipse.eef-31168300478790d8de9b00282638141870ebcda0.tar.gz org.eclipse.eef-31168300478790d8de9b00282638141870ebcda0.tar.xz org.eclipse.eef-31168300478790d8de9b00282638141870ebcda0.zip |
[496076] Review the tool bar lifecyclev2.0.0_RC1
The toolbar actions are not removed when we select another page. Then if
a page without action is selected first the actions are not provided
when a page which defines action is selected. We review the
creation/deletion of the toolbar actions to be done during the
aboutToBeShwon and aboutToBeHidden phases.
Bug: 496076
Change-Id: If849f60e2c5b2929fbe3d1fcfb1d9fb9161d1437
Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
-rw-r--r-- | plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java index 02434b25b..5027dca62 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java @@ -12,6 +12,7 @@ package org.eclipse.eef.ide.ui.internal.widgets; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.eclipse.eef.common.ui.api.IEEFFormContainer; import org.eclipse.eef.core.api.EEFGroup; @@ -23,8 +24,13 @@ import org.eclipse.eef.core.api.controllers.IEEFSectionController; import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager; import org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager; import org.eclipse.eef.ide.ui.internal.widgets.quickfix.EEFMessageHyperlinkListener; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.forms.events.IHyperlinkListener; /** @@ -88,9 +94,6 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager impl this.lifecycleManagers.add(groupLifecycleManager); } - - this.populateToolBar(formContainer.getForm().getToolBarManager(), this.eefPage.getDescription().getActions(), this.controller, - this.eefPage.getView().getContextAdapter(), this.eefPage.getInterpreter(), this.eefPage.getVariableManager()); } /** @@ -102,6 +105,8 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager impl public void aboutToBeShown() { super.aboutToBeShown(); + this.populateToolBar(this.container.getForm().getToolBarManager(), this.eefPage.getDescription().getActions(), this.controller, + this.eefPage.getView().getContextAdapter(), this.eefPage.getInterpreter(), this.eefPage.getVariableManager()); this.container.getForm().addMessageHyperlinkListener(this.hyperlinkListener); this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeShown); @@ -135,12 +140,32 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager impl if (!this.container.getForm().isDisposed()) { this.container.getForm().removeMessageHyperlinkListener(this.hyperlinkListener); this.container.getForm().getMessageManager().removeAllMessages(); + this.clearToolBar(this.container.getForm().getToolBarManager()); } this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeHidden); } /** + * Clear the toolbar. + * + * @param toolBarManager + * The tool bar manager + */ + private void clearToolBar(IToolBarManager toolBarManager) { + if (toolBarManager instanceof ToolBarManager) { + // For an unknown reason, the existing tool bar of the formContainer doesn't have a transparent background. + ToolBar toolBar = ((ToolBarManager) toolBarManager).getControl(); + toolBar.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TRANSPARENT)); + } + + Optional.ofNullable(toolBarManager).ifPresent(manager -> { + manager.removeAll(); + manager.update(true); + }); + } + + /** * {@inheritDoc} * * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager#getController() |