aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime PORHEL2014-04-02 04:20:24 (EDT)
committerPaul Webster2014-04-09 09:58:09 (EDT)
commitf01438295d4a1650a36d4c0605cd3523a7f80136 (patch)
tree20671933b1477b3a6d8317fc2c112ee24c76f83e
parentf57ff125d5c0d604482906cb90f9dd0712e9cfa5 (diff)
downloadeclipse.platform.ui-f01438295d4a1650a36d4c0605cd3523a7f80136.zip
eclipse.platform.ui-f01438295d4a1650a36d4c0605cd3523a7f80136.tar.gz
eclipse.platform.ui-f01438295d4a1650a36d4c0605cd3523a7f80136.tar.bz2
Bug 431778: Cleanup is not called for toolbar not created by the managerrefs/changes/04/24304/7
renderer The cleanup dispose listener has been moved to the processContribution method. This allows to cleanup the toolbar model even for toolabr not created by the renderer. The processContribution method populate the toolbar model and shoudl be responsible to add the dispose listener which will trigger the cleannup. Change-Id: I4c0476468e1fe93b97b313a35e6f893c4cc45c25 Signed-off-by: Maxime PORHEL <maxime.porhel@obeo.fr>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java39
1 files changed, 30 insertions, 9 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
index 4016656..51129a7 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 410426
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 426535
+ * Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 431778
*******************************************************************************/
package org.eclipse.e4.ui.workbench.renderers.swt;
@@ -96,12 +97,13 @@ public class ToolBarManagerRenderer extends SWTPartRenderer {
public static final String POST_PROCESSING_FUNCTION = "ToolBarManagerRenderer.postProcess.func"; //$NON-NLS-1$
public static final String POST_PROCESSING_DISPOSE = "ToolBarManagerRenderer.postProcess.dispose"; //$NON-NLS-1$
public static final String UPDATE_VARS = "ToolBarManagerRenderer.updateVars"; //$NON-NLS-1$
+ private static final String DISPOSE_ADDED = "ToolBarManagerRenderer.disposeAdded"; //$NON-NLS-1$
/**
* This is a persistedState 'key' which can be used by the renderer
* implementation to decide that a user interface element has been hidden by
* the user
- *
+ *
*/
// TODO migrate to IPresentationEngine after the Luna release
public static final String HIDDEN_BY_USER = "HIDDEN_BY_USER"; //$NON-NLS-1$
@@ -459,6 +461,12 @@ public class ToolBarManagerRenderer extends SWTPartRenderer {
* @param elementId
*/
public void processContribution(MToolBar toolbarModel, String elementId) {
+
+ ToolBarManager manager = getManager(toolbarModel);
+ if (manager != null && manager.getControl() != null) {
+ addCleanupDisposeListener(toolbarModel, manager.getControl());
+ }
+
final ArrayList<MToolBarContribution> toContribute = new ArrayList<MToolBarContribution>();
ContributionsAnalyzer.XXXgatherToolBarContributions(toolbarModel,
application.getToolBarContributions(), elementId, toContribute);
@@ -466,6 +474,26 @@ public class ToolBarManagerRenderer extends SWTPartRenderer {
}
/**
+ * @param manager
+ * @param control
+ */
+ private void addCleanupDisposeListener(final MToolBar toolbarModel,
+ ToolBar control) {
+
+ if (!toolbarModel.getTags().contains(DISPOSE_ADDED)) {
+ toolbarModel.getTags().add(DISPOSE_ADDED);
+ control.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ cleanUp(toolbarModel);
+ toolbarModel.getTags().remove(DISPOSE_ADDED);
+ }
+ });
+ }
+
+ }
+
+ /**
* @param toolbarModel
* @param toContribute
*/
@@ -571,13 +599,6 @@ public class ToolBarManagerRenderer extends SWTPartRenderer {
bar.setData(manager);
bar.setData(AbstractPartRenderer.OWNING_ME, element);
bar.getShell().layout(new Control[] { bar }, SWT.DEFER);
- bar.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- cleanUp((MToolBar) element);
- toolbarMenu = null;
- }
- });
return bar;
}
@@ -1040,7 +1061,7 @@ public class ToolBarManagerRenderer extends SWTPartRenderer {
/**
* Removes the IPresentationEngine.HIDDEN_BY_USER from the toolbars
- *
+ *
* @param toolbarModel
*/
private void removeHiddenByUserTags(MToolBar toolbarModel) {