diff options
author | Mickael ADAM | 2016-06-06 15:59:07 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-06-07 11:14:45 +0000 |
commit | 060c40f5970250c5f7482ccd8da0d08b89985186 (patch) | |
tree | 49a8c70427b678d7d96bad6e3589356eb3971def /plugins/infra/nattable | |
parent | ddfa0ee8a243fd9fdaa58ae1f7cdbe9e1aa53e3d (diff) | |
download | org.eclipse.papyrus-060c40f5970250c5f7482ccd8da0d08b89985186.tar.gz org.eclipse.papyrus-060c40f5970250c5f7482ccd8da0d08b89985186.tar.xz org.eclipse.papyrus-060c40f5970250c5f7482ccd8da0d08b89985186.zip |
Bug 495545 - [Test] Memory leak in
org.eclipse.papyrus.editor.integration.tests.tests.EditingScenariosMemoryLeakTest.testCreateNewElement_table
https://bugs.eclipse.org/bugs/show_bug.cgi?id=495545
Change-Id: I82d227e8104a244cc7cebc1a85ca23ab7d41d7e6
Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/infra/nattable')
3 files changed, 58 insertions, 7 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java index 606a1e7b62e..d2af0b1008b 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java @@ -36,6 +36,21 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration protected final NatTable natTable; /** + * Popup menu action for the body. + */ + private PapyrusBodyPopupMenuAction bodyPopupMenuAction; + + /** + * Popup menu action for the row header. + */ + private PapyrusHeaderPopupMenuAction rowHeaderPopupMenuAction; + + /** + * Popup menu action for the column header. + */ + private PapyrusHeaderPopupMenuAction columnHeaderMenuAction; + + /** * Constructor. * */ @@ -63,7 +78,8 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration * */ protected void registerBodyPopupMenu(final UiBindingRegistry uiBindingRegistry) { - uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), new PapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable)); + bodyPopupMenuAction = new PapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable); + uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), bodyPopupMenuAction); } /** @@ -73,7 +89,8 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration * */ protected void registerRowHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) { - uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID, this.natTable)); + rowHeaderPopupMenuAction = new PapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID, this.natTable); + uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), rowHeaderPopupMenuAction); } /** @@ -83,6 +100,22 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration * */ protected void registerColumnHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) { - uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.COLUMN_HEADER_POPUP_MENU_ID, this.natTable)); + columnHeaderMenuAction = new PapyrusHeaderPopupMenuAction(MenuConstants.COLUMN_HEADER_POPUP_MENU_ID, this.natTable); + uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), columnHeaderMenuAction); + } + + /** + * Dispose actions. + */ + public void dispose() { + if (null != bodyPopupMenuAction) { + bodyPopupMenuAction.dispose(); + } + if (null != rowHeaderPopupMenuAction) { + rowHeaderPopupMenuAction.dispose(); + } + if (null != columnHeaderMenuAction) { + columnHeaderMenuAction.dispose(); + } } } diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java index f59a58f04e7..fb40f2c47aa 100755 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java @@ -277,6 +277,11 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan private CellEditorAxisConfiguration cellAxisConfiguration; /** + * The table popup menu configuration. + */ + private TablePopupMenuConfiguration tablePopupMenuConfiguration; + + /** * * Constructor. * @@ -432,7 +437,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan * @since 2.0 */ protected void registerPopupMenuConfiguration(final NatTable natTable) { - natTable.addConfiguration(new TablePopupMenuConfiguration(natTable)); + tablePopupMenuConfiguration = new TablePopupMenuConfiguration(natTable); + natTable.addConfiguration(tablePopupMenuConfiguration); } /** @@ -840,8 +846,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan } } } - - if(!compositeResizeCommand.isEmpty()){ + + if (!compositeResizeCommand.isEmpty()) { // If the named style 'fillColumnSize' is used, this must be set to false to avoid re-fill BooleanValueStyle fillColumnsSize = (BooleanValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE); if (fillColumnsSize == null) { @@ -1333,6 +1339,9 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan if (this.natTable != null) { this.natTable.dispose(); } + if(this.tablePopupMenuConfiguration != null){ + tablePopupMenuConfiguration.dispose(); + } } public EObject getTableContext() { diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java index 15ffcabfd08..df0f127ec7e 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java @@ -143,7 +143,7 @@ public class AbstractPapyrusPopupMenuAction implements IMouseAction, IMenuListen final IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class); final NatEventData natEventData = (NatEventData) this.menuManager.getMenu().getData(MenuConstants.NAT_EVENT_DATA_KEY); - + MenuUtils.registerNatTableWidgetInEclipseContext(natEventData); if (menuService != null && menuManager instanceof MenuManager) { @@ -154,4 +154,13 @@ public class AbstractPapyrusPopupMenuAction implements IMouseAction, IMenuListen } + /** + * Dispose the {@link MenuManager}. + */ + public void dispose() { + if (null != menuManager) { + menuManager.dispose(); + } + } + } |