summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-10-30 14:31:37 (EDT)
committerKaren Butzke2012-10-30 14:31:37 (EDT)
commit80909e670a0ccec3caa13f21d7eb9f91f1f94fbd (patch)
treea1514e8d6a4b6304832a04ce788f8b2b8d03c19a
parent0ef177969c0527affa4e0838f036663d569397e0 (diff)
downloadwebtools.dali-80909e670a0ccec3caa13f21d7eb9f91f1f94fbd.zip
webtools.dali-80909e670a0ccec3caa13f21d7eb9f91f1f94fbd.tar.gz
webtools.dali-80909e670a0ccec3caa13f21d7eb9f91f1f94fbd.tar.bz2
Properly disposing of WidgetFactory and its wrapped FormToolkit. Deleted PropertySheetWidgetFactory, as far as i can tell, it was unnecessary.
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java7
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java21
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java19
6 files changed, 52 insertions, 84 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java
index 3047738..6526be1 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java
@@ -33,7 +33,7 @@ import org.eclipse.ui.forms.widgets.Section;
* adopters on the understanding that any code that uses this API will almost
* certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.0
+ * @version 3.3
* @since 2.0
*/
public interface WidgetFactory {
@@ -207,4 +207,9 @@ public interface WidgetFactory {
* @return A new <code>Button</code> that has 3 selection states
*/
Button createTriStateCheckBox(Composite parent, String text);
+
+ /**
+ * Dispose of the widget factory
+ */
+ void dispose();
} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java
index f091298..9dfcf3d 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java
@@ -207,4 +207,8 @@ public class DefaultWidgetFactory implements WidgetFactory {
TriStateCheckBox checkBox = new TriStateCheckBox(parent, text, this);
return checkBox.getCheckBox();
}
+
+ public void dispose() {
+ //nothing to dispose
+ }
} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java
index 644060c..ab671d1 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java
@@ -26,16 +26,18 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
/**
* This <code>WidgetFactory</code> is responsible to create the widgets
* using the <code>FormToolkit</code> in order use the form style (flat-style)
- * look and feel.
+ * look and feel. Clients that create a FormWidgetFactory must call {@link #dispose()}
+ * when they are finished using the widget factory.
+
*
* @see FormToolkit
- *
- * @version 2.0
+ * @version 3.3
* @since 2.0
*/
@SuppressWarnings("nls")
@@ -48,9 +50,8 @@ public class FormWidgetFactory implements WidgetFactory {
/**
* Creates a new <code>FormWidgetFactory</code>.
- *
- * @param widgetFactory The actual factory responsible for creating the new
- * widgets
+ * <p>
+ * Clients that call this method must call {@link #dispose()}
*/
public FormWidgetFactory(FormToolkit widgetFactory) {
super();
@@ -219,6 +220,10 @@ public class FormWidgetFactory implements WidgetFactory {
return this.widgetFactory.createSection(parent, SWT.FLAT | style);
}
+ public ScrolledForm createScrolledForm(Composite parent) {
+ return this.widgetFactory.createScrolledForm(parent);
+ }
+
/**
* {@inheritDoc}
*/
@@ -268,4 +273,8 @@ public class FormWidgetFactory implements WidgetFactory {
public FormToolkit getWidgetFactory() {
return this.widgetFactory;
}
+
+ public void dispose() {
+ this.widgetFactory.dispose();
+ }
} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java
deleted file mode 100644
index 82313fb..0000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-
-/**
- * This <code>WidgetFactory</code> is responsible to create the widgets using
- * <code>TabbedPropertySheetWidgetFactory</code> in order use the form style
- * (flat-style) look and feel.
- *
- * @see TabbedPropertySheetWidgetFactory
- *
- * @version 2.0
- * @since 2.0
- */
-public class PropertySheetWidgetFactory
- extends FormWidgetFactory
-{
- /**
- * Creates a new <code>PropertySheetWidgetFactory</code>.
- */
- public PropertySheetWidgetFactory() {
- this(new TabbedPropertySheetWidgetFactory());
- }
-
- /**
- * Creates a new <code>PropertySheetWidgetFactory</code>.
- */
- public PropertySheetWidgetFactory(TabbedPropertySheetWidgetFactory widgetFactory) {
- super(widgetFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Composite createComposite(Composite parent) {
- return getWidgetFactory().createComposite(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Group createGroup(Composite parent, String title) {
- return getWidgetFactory().createGroup(parent, title);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TabbedPropertySheetWidgetFactory getWidgetFactory() {
- return (TabbedPropertySheetWidgetFactory) super.getWidgetFactory();
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java
index b608803..4c37dbf 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java
@@ -49,6 +49,7 @@ import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -59,9 +60,9 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.MultiPageEditorSite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
/**
@@ -117,8 +118,11 @@ public class JpaXmlEditor
/**
* The factory used to create the various widgets.
+ * The widgetFactory wraps the editor's toolkit, is created
+ * when the editor's toolkit is {@link #createToolkit(Display) created}
+ * and disposed, when the editor is {@link #dispose() disposed}.
*/
- private final WidgetFactory widgetFactory;
+ private WidgetFactory widgetFactory;
/**
* The local resource manager, used to create/destroy Images
@@ -129,15 +133,15 @@ public class JpaXmlEditor
public JpaXmlEditor() {
super();
this.localResourceManager = new LocalResourceManager(JFaceResources.getResources());
- this.widgetFactory = this.buildWidgetFactory();
this.structuredTextEditor = new StructuredTextEditor();
this.structuredTextEditor.setEditorPart(this);
}
- private WidgetFactory buildWidgetFactory() {
- return new FormWidgetFactory(
- new TabbedPropertySheetWidgetFactory()
- );
+ @Override
+ protected FormToolkit createToolkit(Display display) {
+ FormToolkit toolkit = super.createToolkit(display);
+ this.widgetFactory = new FormWidgetFactory(toolkit);
+ return toolkit;
}
@Override
@@ -365,6 +369,7 @@ public class JpaXmlEditor
this.editorInputModel.setValue(null);
this.localResourceManager.dispose();
this.rootStructureNodeModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.rootStructureNodeListener);
+ this.widgetFactory.dispose();
super.dispose();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java
index fc375f9..9d36dff 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java
@@ -10,13 +10,14 @@
package org.eclipse.jpt.jpa.ui.internal.views;
import java.util.HashMap;
-import org.eclipse.jpt.common.ui.internal.widgets.PropertySheetWidgetFactory;
+
+import org.eclipse.jpt.common.ui.internal.widgets.FormWidgetFactory;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.ui.details.JpaDetailsPageManager;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
@@ -28,6 +29,8 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
@@ -48,8 +51,12 @@ public class JpaDetailsView
/**
* The factory used by the details view and its page managers
* to create the their widgets.
+ * The widgetFactory is created when the view's control is
+ * {@link #createPartControl(Composite) created}
+ * and disposed, if necessary, when the view is
+ * {@link #dispose() disposed}.
*/
- private final PropertySheetWidgetFactory widgetFactory = new PropertySheetWidgetFactory();
+ private FormWidgetFactory widgetFactory;
/**
* The scrolled form that holds the {@link #pageBook page book}.
@@ -102,7 +109,8 @@ public class JpaDetailsView
@Override
public void createPartControl(Composite parent) {
- this.scrolledForm = this.widgetFactory.getWidgetFactory().createScrolledForm(parent);
+ this.widgetFactory = new FormWidgetFactory(new FormToolkit(parent.getDisplay()));
+ this.scrolledForm = this.widgetFactory.createScrolledForm(parent);
JptJpaUiPlugin.instance().controlAffectsJavaSource(this.scrolledForm);
this.scrolledForm.getBody().setLayout(new GridLayout());
@@ -245,6 +253,9 @@ public class JpaDetailsView
@Override
public void dispose() {
+ if (this.widgetFactory != null) {
+ this.widgetFactory.dispose();
+ }
if (this.manager != null) {
this.dispose_();
}