Author: akazakov
Date: 2008-04-30 05:41:51 -0400 (Wed, 30 Apr 2008)
New Revision: 7904
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditor.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2127 Fixed
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-04-30
09:40:17 UTC (rev 7903)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-04-30
09:41:51 UTC (rev 7904)
@@ -13,14 +13,22 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Widget;
import org.jboss.tools.seam.ui.SeamUIMessages;
/**
@@ -31,11 +39,13 @@
public abstract class BaseFieldEditor implements IFieldEditor {
PropertyChangeSupport pcs = new PropertyChangeSupport(this);
-
+
+ Set<DisposeListener> disposeListeners = new HashSet<DisposeListener>();
+
private Object value = new Object();
-
+
private String labelText = SeamUIMessages.BASE_FIELD_EDITOR_NO_LABEL;
-
+
private String nameText = null;
Label labelControl = null;
@@ -64,10 +74,18 @@
Assert.isTrue(parent instanceof Composite,
SeamUIMessages.BASE_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
Assert.isTrue(((Composite)parent).getLayout() instanceof
GridLayout,SeamUIMessages.BASE_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
Composite aComposite = (Composite) parent;
- getEditorControls(aComposite);
+ final Control[] controls = (Control[])getEditorControls(aComposite);
GridLayout gl = (GridLayout)((Composite)parent).getLayout();
doFillIntoGrid(aComposite,gl.numColumns);
+ if(controls.length>0) {
+ controls[0].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
}
/**
@@ -84,7 +102,7 @@
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
-
+
/**
*
*/
@@ -219,9 +237,10 @@
public String getName() {
return nameText;
}
-
- /**
- *
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose()
*/
public void dispose() {
PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
@@ -231,6 +250,34 @@
}
}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose(org.eclipse.swt.events.DisposeEvent)
+ */
+ public void dispose(DisposeEvent e) {
+ dispose();
+ for (DisposeListener disposeListener : disposeListeners) {
+ disposeListener.widgetDisposed(e);
+ }
+ disposeListeners.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#addDisposeListener(org.eclipse.swt.events.DisposeListener)
+ */
+ public void addDisposeListener(DisposeListener listener) {
+ disposeListeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#removeDisposeListener(org.eclipse.swt.events.DisposeListener)
+ */
+ public void removeDisposeListener(DisposeListener listener) {
+ disposeListeners.remove(listener);
+ }
+
/**
*
* @return
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2008-04-30
09:40:17 UTC (rev 7903)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2008-04-30
09:41:51 UTC (rev 7904)
@@ -16,6 +16,9 @@
import java.util.List;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.seam.ui.widget.field.ComboBoxField;
@@ -47,6 +50,13 @@
if(comboField == null) {
comboField = new ComboBoxField(composite,values,getValue(),editable);
comboField.addPropertyChangeListener(this);
+ final Combo combo =comboField.getComboControl();
+ combo.addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose(e);
+ combo.removeDisposeListener(this);
+ }
+ });
} else if(composite!=null) {
Assert.isTrue(comboField.getControl().getParent()==composite);
}
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-04-30
09:40:17 UTC (rev 7903)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-04-30
09:41:51 UTC (rev 7904)
@@ -19,6 +19,8 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@@ -44,9 +46,9 @@
SeamUIMessages.COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
Composite aComposite = (Composite) parent;
- Control[] controls = (Control[]) getEditorControls(aComposite);
+ final Control[] controls = (Control[]) getEditorControls(aComposite);
GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
-
+
for (int i = 0; i < controls.length; i++) {
GridData gd = new GridData();
gd.horizontalSpan = i == 1 ? gl.numColumns - controls.length + 1 : 1;
@@ -59,7 +61,16 @@
controls[i].setLayoutData(gd);
controls[i].setEnabled(isEnabled());
- }
+
+ if(i==0) {
+ controls[i].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
+ }
}
List<Control> controls = new ArrayList<Control>();
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditor.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditor.java 2008-04-30
09:40:17 UTC (rev 7903)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditor.java 2008-04-30
09:41:51 UTC (rev 7904)
@@ -12,6 +12,10 @@
import java.beans.PropertyChangeListener;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Listener;
+
public interface IFieldEditor extends INamedElement {
/**
@@ -48,6 +52,18 @@
*
* @param listener
*/
+ public void addDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void removeDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
public void removePropertyChangeListener(PropertyChangeListener listener);
/**
@@ -85,6 +101,11 @@
*/
public void dispose();
+ /**
+ *
+ * @param e
+ */
+ public void dispose(DisposeEvent e);
/**
* Sets the application defined property of this editor
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2008-04-30
09:40:17 UTC (rev 7903)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2008-04-30
09:41:51 UTC (rev 7904)
@@ -26,6 +26,8 @@
import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizardCategoryFilter;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.dialogs.PropertyDialog;
import org.hibernate.console.ConsoleConfiguration;
@@ -40,6 +42,7 @@
import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor;
+import org.jboss.tools.seam.ui.widget.editor.ComboFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
@@ -197,7 +200,7 @@
* @param canBeEmpty
* @return
*/
- public static IFieldEditor createConnectionProfileSelectionFieldEditor(Object
defaultValue, IValidator validator, boolean canBeEmpty) {
+ public static IFieldEditor createConnectionProfileSelectionFieldEditor(Object
defaultValue, IValidator validator, final boolean canBeEmpty) {
EditConnectionProfileAction editAction = new EditConnectionProfileAction(validator);
NewConnectionProfileAction newAction = new NewConnectionProfileAction(validator);
List<String> profiles = getConnectionProfileNameList();
@@ -224,6 +227,34 @@
}
});
}
+ final ComboFieldEditor comboEditor =
((ComboFieldEditor)((CompositeEditor)connProfileSelEditor).getEditors().get(1));
+ final IProfileListener profileListener = new IProfileListener() {
+ private void update() {
+ List<String> profiles = getConnectionProfileNameList();
+ if(canBeEmpty) {
+ profiles.add(0, "");
+ }
+ comboEditor.setTags((profiles.toArray(new String[0])));
+ }
+
+ public void profileAdded(IConnectionProfile profile) {
+ update();
+ }
+
+ public void profileChanged(IConnectionProfile profile) {
+ update();
+ }
+
+ public void profileDeleted(IConnectionProfile profile) {
+ update();
+ }
+ };
+ ProfileManager.getInstance().addProfileListener(profileListener);
+ comboEditor.addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ ProfileManager.getInstance().removeProfileListener(profileListener);
+ }
+ });
return connProfileSelEditor;
}