Author: snjeza
Date: 2012-10-06 16:03:34 -0400 (Sat, 06 Oct 2012)
New Revision: 44354
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditorContributor.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/ToolTip.java
Log:
JBIDE-12809 - Memory leaks in JBoss Central editor
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-10-06
15:18:47 UTC (rev 44353)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-10-06
20:03:34 UTC (rev 44354)
@@ -159,6 +159,7 @@
private ToolBarManager newsToolBarManager;
private ToolBarManager blogsToolBarManager;
private Action blogsWarning;
+ private ToolBarManager tutorialsToolBarManager;
public GettingStartedPage(FormEditor editor) {
super(editor, ID, "Getting Started");
@@ -484,25 +485,25 @@
headerComposite.setLayout(rowLayout);
headerComposite.setBackground(null);
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
- toolBarManager.createControl(headerComposite);
+ tutorialsToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
+ tutorialsToolBarManager.createControl(headerComposite);
CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.newProjectExamplesWizard");
- toolBarManager.add(item);
+ tutorialsToolBarManager.add(item);
item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.runtime.preferences");
- toolBarManager.add(item);
+ tutorialsToolBarManager.add(item);
item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.wtp.runtime.preferences");
- toolBarManager.add(item);
+ tutorialsToolBarManager.add(item);
item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.refreshJBossTutorials");
- toolBarManager.add(item);
+ tutorialsToolBarManager.add(item);
//Action action = new DownloadRuntimeAction("Download and Install JBoss AS
7.0.1",
JBossCentralActivator.imageDescriptorFromPlugin(JBossCentralActivator.PLUGIN_ID,
"/icons/jbossas7.png"), "org.jboss.tools.runtime.core.as.701");
//toolBarManager.add(action);
- toolBarManager.update(true);
+ tutorialsToolBarManager.update(true);
section.setTextClient(headerComposite);
}
@@ -750,8 +751,22 @@
@Override
public void dispose() {
- newWizardDropDownAction.dispose();
- newWizardDropDownAction = null;
+ if (newWizardDropDownAction != null) {
+ newWizardDropDownAction.dispose();
+ newWizardDropDownAction = null;
+ }
+ if (newsToolBarManager != null) {
+ newsToolBarManager.dispose();
+ newsToolBarManager = null;
+ }
+ if (blogsToolBarManager != null) {
+ blogsToolBarManager.dispose();
+ blogsToolBarManager = null;
+ }
+ if (tutorialsToolBarManager != null) {
+ tutorialsToolBarManager.dispose();
+ tutorialsToolBarManager = null;
+ }
if (refreshBlogsJobChangeListener != null) {
RefreshBlogsJob.INSTANCE.removeJobChangeListener(refreshBlogsJobChangeListener);
refreshBlogsJobChangeListener = null;
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2012-10-06
15:18:47 UTC (rev 44353)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2012-10-06
20:03:34 UTC (rev 44354)
@@ -24,6 +24,7 @@
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.swt.SWT;
@@ -38,9 +39,9 @@
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -96,6 +97,8 @@
}
public void dispose() {
+ gettingStartedPage = null;
+ softwarePage = null;
if (headerImage != null) {
headerImage.dispose();
headerImage = null;
@@ -116,6 +119,9 @@
} catch (InterruptedException e) {
// ignore
}
+
+ getSite().setSelectionProvider(null);
+
super.dispose();
}
@@ -186,7 +192,7 @@
form.setImage(getHeaderImage());
getToolkit().decorateFormHeading(form.getForm());
- IToolBarManager toolbar = form.getToolBarManager();
+ final IToolBarManager toolbar = form.getToolBarManager();
ControlContribution searchControl = new ControlContribution("Search") {
@Override
protected Control createControl(Composite parent) {
@@ -204,6 +210,18 @@
}
toolbar.update(true);
+ form.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (toolbar instanceof ToolBarManager) {
+ ((ToolBarManager)toolbar).dispose();
+ } else {
+ toolbar.removeAll();
+ }
+ form.removeDisposeListener(this);
+ }
+ });
form.layout(true, true);
}
@@ -240,7 +258,7 @@
searchControl.setLayoutData(gd);
searchControl.setBackground(null);
getToolkit().adapt(searchControl);
- searchControl.addSelectionListener(new SelectionAdapter() {
+ final SelectionListener searchControlListener = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
@@ -284,8 +302,16 @@
}
}
+ };
+ searchControl.addSelectionListener(searchControlListener);
+ searchControl.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ searchControl.removeSelectionListener(searchControlListener);
+ searchControl.removeDisposeListener(this);
+ }
});
-
final Menu menu = new Menu(menuLink);
final MenuItem searchCommunityPortal = new MenuItem(menu, SWT.CHECK);
searchCommunityPortal
@@ -300,7 +326,7 @@
} else {
searchCommunity.setSelection(true);
}
- searchCommunity.addSelectionListener(new SelectionAdapter() {
+ final SelectionListener searchCommunityListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -310,9 +336,18 @@
.setInitialMessage(JBossCentralActivator.SEARCH_THE_COMMUNITY);
}
+ };
+ searchCommunity.addSelectionListener(searchCommunityListener);
+ searchCommunity.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ searchCommunity.removeSelectionListener(searchCommunityListener);
+ searchCommunity.removeDisposeListener(this);
+ }
});
- searchCommunityPortal.addSelectionListener(new SelectionAdapter() {
+ final SelectionListener searchCommunityPortalListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -322,8 +357,17 @@
.setInitialMessage(JBossCentralActivator.SEARCH_RED_HAT_CUSTOMER_PORTAL);
}
+ };
+ searchCommunityPortal.addSelectionListener(searchCommunityPortalListener);
+
+ searchCommunityPortal.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ searchCommunityPortal.removeSelectionListener(searchCommunityPortalListener);
+ searchCommunityPortal.removeDisposeListener(this);
+ }
});
-
menuLink.addMouseListener(new MouseListener() {
@Override
@@ -341,6 +385,14 @@
}
});
+ searchComposite.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ menu.dispose();
+ searchComposite.removeDisposeListener(this);
+ }
+ });
return searchComposite;
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditorContributor.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditorContributor.java 2012-10-06
15:18:47 UTC (rev 44353)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditorContributor.java 2012-10-06
20:03:34 UTC (rev 44354)
@@ -17,6 +17,7 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.internal.EditorActionBars;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -32,6 +33,15 @@
public JBossCentralEditorContributor() {
super();
}
+ @Override
+ public void dispose() {
+ IActionBars bars = getActionBars();
+ if (bars instanceof EditorActionBars) {
+ ((EditorActionBars) bars).setEditorContributor(null);
+ }
+
+ super.dispose();
+ }
/**
* Returns the action registed with the given text editor.
* @return IAction or null if editor is null.
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java 2012-10-06
15:18:47 UTC (rev 44353)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java 2012-10-06
20:03:34 UTC (rev 44354)
@@ -80,6 +80,8 @@
private InstallAction installAction;
private Button installButton;
+
+ private ToolBarManager toolBarManager;
public SoftwarePage(FormEditor editor) {
super(editor, ID, "Software/Update");
@@ -231,7 +233,7 @@
headerComposite.setLayout(rowLayout);
headerComposite.setBackground(null);
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
+ toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
toolBarManager.createControl(headerComposite);
installAction = new InstallAction();
@@ -308,6 +310,10 @@
RefreshDiscoveryJob.INSTANCE.removeJobChangeListener(refreshJobChangeListener);
refreshJobChangeListener = null;
}
+ if (toolBarManager != null) {
+ toolBarManager.dispose();
+ toolBarManager = null;
+ }
super.dispose();
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/ToolTip.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/ToolTip.java 2012-10-06
15:18:47 UTC (rev 44353)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/ToolTip.java 2012-10-06
20:03:34 UTC (rev 44354)
@@ -467,7 +467,7 @@
CURRENT_TOOLTIP = shell;
control.getShell().addListener(SWT.Deactivate, shellListener);
- control.getShell().addDisposeListener(new DisposeListener() {
+ control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {