diff options
author | gkessler | 2008-09-02 17:37:55 +0000 |
---|---|---|
committer | gkessler | 2008-09-02 17:37:55 +0000 |
commit | 44acd1036a1b632ebfb8e9751bc99eed8fb21b85 (patch) | |
tree | 85916d2d0b19b73887d33c75545da7a92795fa9f | |
parent | e0dbfa32273c0607e38753e8598c0da32b0b3351 (diff) | |
download | webtools.jsf-44acd1036a1b632ebfb8e9751bc99eed8fb21b85.tar.gz webtools.jsf-44acd1036a1b632ebfb8e9751bc99eed8fb21b85.tar.xz webtools.jsf-44acd1036a1b632ebfb8e9751bc99eed8fb21b85.zip |
[Bug 233506] [hotbug_request] SWTException in Faces config. file editor
[Bug 244486] [hotbug_request] JSF Tools: widget disposed exception, when model shared with other editors
24 files changed, 715 insertions, 406 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java index ed0513de0..f39845b62 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java @@ -126,7 +126,12 @@ public class FacesConfigEditor extends FormEditor implements * This editor's ID. TODO: this should prob be in plugin.properties? */ public static final String EDITOR_ID = "org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor"; //$NON-NLS-1$ - + + + /** + * Page id for Source page. Used for testing only. + */ + public static final String SOURCE_PAGE_ID = "SourcePageId"; //$NON-NLS-1$ /** * editing domain that is used to track all changes to the model */ @@ -447,7 +452,8 @@ public class FacesConfigEditor extends FormEditor implements */ public synchronized void removeWaitPage() { - if (_waitPage != null) + if (_waitPage != null + && !_waitPage.getPartControl().isDisposed()) { int index = _waitPage.getIndex(); @@ -640,16 +646,10 @@ public class FacesConfigEditor extends FormEditor implements /* * @see org.eclipse.ui.ISaveablePart#isDirty() */ - public boolean isDirty() { - final boolean[] result = new boolean[1]; - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = ((BasicCommandStack) editingDomain.getCommandStack()) + public boolean isDirty() { + return ((BasicCommandStack) editingDomain.getCommandStack()) .isSaveNeeded() - || FacesConfigEditor.super.isDirty(); - } - }); - return result[0]; + || super.isDirty(); } /** @@ -1320,6 +1320,8 @@ public class FacesConfigEditor extends FormEditor implements setActivePage(componentsPageID); } else if (pageID.equals(OthersPage.PAGE_ID)) { setActivePage(othersPageID); + } else if (pageID.equals(SOURCE_PAGE_ID)) { + setActivePage(sourcePageId); } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java index 8a8224005..0ff441a9c 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java @@ -88,6 +88,17 @@ public abstract class FacesConfigMasterDetailPage extends FormPage implements super(editor, id, title); } + public void dispose() { + for(int i=0; i < facesConfigMasterSections.length;i++) { + FacesConfigMasterSection master = facesConfigMasterSections[i]; + if (master != null) + master.dispose(); + } + + selectionChangedListeners.clear(); + + super.dispose(); + } public EditingDomain getEditingDomain() { return ((FacesConfigEditor) getEditor()).getEditingDomain(); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java index cc092c041..19fbd5f9b 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java @@ -63,6 +63,13 @@ public class ManagedBeanPage extends FacesConfigMasterDetailPage { EditorMessages.FacesConfigEditor_ManagedBeans_TabName); } + public void dispose() { + if (contentOutlinePage != null) { + contentOutlinePage.dispose(); + contentOutlinePage = null; + } + super.dispose(); + } protected FacesConfigMasterSection[] createMasterSections( Composite composite, IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java index 641c7ceb0..4bbaa0c2d 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl; @@ -40,9 +41,9 @@ import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; import org.eclipse.jst.jsf.facesconfig.emf.FactoryType; import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType; +import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; import org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection; import org.eclipse.jst.jsf.facesconfig.ui.section.ApplicationSection; import org.eclipse.jst.jsf.facesconfig.ui.section.FactorySection; @@ -98,6 +99,8 @@ public class OthersPage extends FormPage implements IFacesConfigPage, private ISelection currentSelection; + private FacesConfigOthersAdapter _facesConfigOthersAdapter; + /** * Constructor of OthersPage; * @@ -130,6 +133,22 @@ public class OthersPage extends FormPage implements IFacesConfigPage, list.add(section); } + public void dispose() { + disposeFormSections(rightSections); + disposeFormSections(leftSections); + removeAdapterFromInput(getInput()); + getSite().setSelectionProvider(null); + super.dispose(); + } + + private void disposeFormSections(List sections) { + for (int i=0; i < sections.size();i++) { + OthersPageBaseSection section = (OthersPageBaseSection) sections.get(i); + section.removeSelectionChangedListener(this); + section.dispose(); + } + } + private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { Composite body = managedForm.getForm().getBody(); @@ -293,13 +312,26 @@ public class OthersPage extends FormPage implements IFacesConfigPage, if (input instanceof FacesConfigType) { this.input = input; FacesConfigType facesConfig = (FacesConfigType) input; - facesConfig.eAdapters().add(new FacesConfigOthersAdapter()); + facesConfig.eAdapters().add(getFacesConfigAdapter()); setInputForApplicationSections(facesConfig); setInputForFactorySections(facesConfig); setInputForLifecycleSections(facesConfig); } } + private void removeAdapterFromInput(Object input) { + if (_facesConfigOthersAdapter != null && input != null && input instanceof FacesConfigType) { + ((FacesConfigType)input).eAdapters().remove(_facesConfigOthersAdapter); + } + } + + private Adapter getFacesConfigAdapter() { + if (_facesConfigOthersAdapter == null) { + _facesConfigOthersAdapter = new FacesConfigOthersAdapter(); + } + return _facesConfigOthersAdapter; + } + public boolean isEditor() { return true; } @@ -444,31 +476,41 @@ public class OthersPage extends FormPage implements IFacesConfigPage, */ class FacesConfigOthersAdapter extends AdapterImpl { public void notifyChanged(Notification msg) { - if(getPartControl().isDisposed()) { - return; - } if (msg.getEventType() == Notification.REMOVE || msg.getEventType() == Notification.ADD) { if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getFacesConfigType_Application()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - resetApplicationInput(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + resetApplicationInput(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + resetApplicationInput(); + } + }); + } } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getFacesConfigType_Factory()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - resetFactoryInput(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + resetFactoryInput(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + resetFactoryInput(); + } + }); + } } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getFacesConfigType_Lifecycle()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - resetLifecycleInput(); } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + resetLifecycleInput(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + resetLifecycleInput(); + } + }); + } } } } @@ -701,7 +743,7 @@ public class OthersPage extends FormPage implements IFacesConfigPage, if (ss.isEmpty()) return; - EObject object = (EObject) ss.getFirstElement(); + final EObject object = (EObject) ss.getFirstElement(); OthersPageBaseSection section = null; if (FacesConfigPackage.eINSTANCE.getActionListenerType() @@ -754,19 +796,33 @@ public class OthersPage extends FormPage implements IFacesConfigPage, section = (OthersPageBaseSection) rightSections.get(4); } if (section != null) { - if (!section.getSection().isExpanded()) { - this.closeOtherSections(section); - GridData gd = new GridData(GridData.FILL_BOTH); - section.getSection().setLayoutData(gd); - section.getSection().setExpanded(true); - } - IStructuredSelection newselection = new StructuredSelection( - object); - section.getTableViewer().setSelection(newselection); + if ((Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())) { + setSelectionInSection(section, object); + } + else { + final OthersPageBaseSection baseSection = section; + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + setSelectionInSection(baseSection, object); + } + }); + } } } } + private void setSelectionInSection(final OthersPageBaseSection section, final Object object) { + if (!section.getSection().isExpanded()) { + this.closeOtherSections(section); + GridData gd = new GridData(GridData.FILL_BOTH); + section.getSection().setLayoutData(gd); + section.getSection().setExpanded(true); + } + IStructuredSelection newselection = new StructuredSelection( + object); + section.getTableViewer().setSelection(newselection); + } + /* * (non-Javadoc) * diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java index adab23118..b0f7923ff 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java @@ -40,6 +40,12 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; public class OverviewPage extends FormPage implements ISelectionProvider, IFacesConfigPage { + + /** + * The id of this page in the faces-config editor. + */ + public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.page.OverviewPage"; + private static final int LAYOUT_MARGIN_HEIGHT = 2; private static final int LAYOUT_MARGIN_WIDTH = 2; @@ -230,4 +236,13 @@ public class OverviewPage extends FormPage implements ISelectionProvider, public void setSelection(ISelection selection) { // do not support change in selection } + + public void dispose() { + beanSection.dispose(); + componentsSection.dispose(); + generalSection.dispose(); + navigationSection.dispose(); + otherSection.dispose(); + super.dispose(); + } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java index 6d0cff7bc..83590a129 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java @@ -20,6 +20,7 @@ import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowContainerE import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowXYLayoutEditPolicy; import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; +import org.eclipse.ui.PlatformUI; /** * abstract class for pageflow container. @@ -70,10 +71,10 @@ abstract class PageflowContainerEditPart extends PageflowElementEditPart { case Notification.ADD_MANY: case Notification.REMOVE: case Notification.REMOVE_MANY: - refreshChildren(); + refreshChildrenOnUIThread(); break; case Notification.SET: - refreshVisuals(); + refreshVisualsOnUIThread(); break; } super.notifyChanged(notification); @@ -81,4 +82,27 @@ abstract class PageflowContainerEditPart extends PageflowElementEditPart { }; } + private void refreshChildrenOnUIThread() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshChildren(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshChildren(); + } + }); + } + } + + private void refreshVisualsOnUIThread() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshVisuals(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshVisuals(); + } + }); + } + } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java index 0ff56f2e9..3f3a80f7a 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java @@ -51,6 +51,7 @@ import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; +import org.eclipse.ui.PlatformUI; /** * The container editr part for the whole pageflow, which uses the @@ -188,17 +189,52 @@ public class PageflowEditPart extends PageflowContainerEditPart implements case Notification.ADD_MANY: case Notification.REMOVE: case Notification.REMOVE_MANY: - refreshChildren(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshChildren(); + } + else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + + public void run() { + refreshChildren(); + } + + }); + } break; case Notification.SET: - refreshChildren(); - refreshVisuals(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshChildren(); + refreshVisuals(); + } + else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + + public void run() { + refreshChildren(); + refreshVisuals(); + } + + }); + } break; case FC2PFTransformer.MY_NOTIFICATION_TYPE1: restore((Pageflow) getModel()); - refreshChildren(); - refreshVisuals(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshChildren(); + refreshVisuals(); + } + else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + + public void run() { + refreshChildren(); + refreshVisuals(); + } + + }); + } break; // restore all children case FC2PFTransformer.MY_NOTIFICATION_TYPE: @@ -283,6 +319,7 @@ public class PageflowEditPart extends PageflowContainerEditPart implements * @see com.sybase.stf.jmt.editors.pageflow.editparts.ILayerPanePreference#setConnectionRouterStyle(int) */ public void setConnectionRouterStyle(int style) { + //TODO does this need to be execed on UI thread only??? connectionStyle = style; ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER); if (style == ILayerPanePreference.LINE_ROUTING_MANHATTAN) { diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java index 1f3269285..b897c5e24 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java @@ -36,6 +36,7 @@ import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PageflowElementPro import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.views.properties.IPropertySource; /** @@ -196,17 +197,32 @@ public abstract class PageflowElementEditPart extends AbstractGraphicalEditPart */ protected void refreshVisuals() { if (getParent() != null) { - Point loc = new Point(getPageflowElement().getX(), - getPageflowElement().getY()); - Dimension size = new Dimension(getPageflowElement().getWidth(), - getPageflowElement().getHeight()); - Rectangle r = new Rectangle(loc, size); - - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, - getFigure(), r); + final AbstractGraphicalEditPart part = this; + //ensure that this is executed on the UI thread + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshVisuals(part); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + + public void run() { + refreshVisuals(part); + } + }); + } } } - + + private void refreshVisuals(AbstractGraphicalEditPart part) { + Point loc = new Point(getPageflowElement().getX(), + getPageflowElement().getY()); + Dimension size = new Dimension(getPageflowElement().getWidth(), + getPageflowElement().getHeight()); + Rectangle r = new Rectangle(loc, size); + + ((GraphicalEditPart) getParent()).setLayoutConstraint(part, + getFigure(), r); + } + /* * (non-Javadoc) * diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java index 075cd244c..9336e11e9 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java @@ -174,19 +174,16 @@ public class PageflowElementTreeEditPart extends AbstractTreeEditPart implements case Notification.ADD_MANY: case Notification.REMOVE: case Notification.REMOVE_MANY: - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refreshChildren(); - } - }); - break; - case Notification.SET: - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refreshVisuals(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshVisuals(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshVisuals(); + } + }); + } break; } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java index 3e77961da..32cd665ff 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java @@ -43,6 +43,7 @@ import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.views.properties.IPropertySource; /** @@ -164,8 +165,8 @@ public class PageflowLinkEditPart extends AbstractConnectionEditPart implements PageflowAnnotationUtil .validateLink(PageflowLinkEditPart.this); } - - refreshVisuals(); + + refreshVisualsOnUIThread(); break; } } @@ -247,7 +248,19 @@ public class PageflowLinkEditPart extends AbstractConnectionEditPart implements refreshBendpoints(); } } - + + private void refreshVisualsOnUIThread() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshVisuals(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshVisuals(); + } + }); + } + } + /** * set the bendpoint constraints of the pflink connection * @@ -366,12 +379,17 @@ public class PageflowLinkEditPart extends AbstractConnectionEditPart implements * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#undecorateEditPart() */ public void removeAnnotation() { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - ((PFLinkFigure) getFigure()).clearIcon(); - resetLabel(); - } - }); + if (Thread.currentThread() == getViewer().getControl().getDisplay().getThread()) { + ((PFLinkFigure) getFigure()).clearIcon(); + resetLabel(); + } else { + getViewer().getControl().getDisplay().asyncExec(new Runnable() { + public void run() { + ((PFLinkFigure) getFigure()).clearIcon(); + resetLabel(); + } + }); + } } private void resetLabel() { diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java index e28f040dd..8eac668e8 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java @@ -47,6 +47,8 @@ import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; + /** * The base class for the applications EditParts that represent @@ -201,9 +203,19 @@ public class PageflowNodeEditPart extends PageflowElementEditPart implements case Notification.REMOVE: case Notification.REMOVE_MANY: if (notification.getNewValue() instanceof PageflowLink) { - refreshTargetConnections(); - refreshSourceConnections(); - validate(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshTargetConnections(); + refreshSourceConnections(); + validate(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshTargetConnections(); + refreshSourceConnections(); + validate(); + } + }); + } } break; @@ -213,7 +225,15 @@ public class PageflowNodeEditPart extends PageflowElementEditPart implements if (needValidation(featureId)) { validate(); } - refreshVisuals(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshVisuals(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ + public void run() { + refreshVisuals(); + } + }); + } break; } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java index 6efc897af..d30e7d133 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java @@ -44,11 +44,15 @@ public abstract class PFBatchAdapter extends AdapterImpl { final public void notifyChanged(final Notification msg) { if (!isNeedPostpone(msg)) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - doNotifyChanged(msg); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) + doNotifyChanged(msg); + else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + doNotifyChanged(msg); + } + }); + } } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java index 8d4748938..393ece2f8 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java @@ -41,6 +41,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.forms.widgets.Section; + /** * The abstract implementation of IFacesConfigSection. * @@ -94,6 +95,12 @@ public abstract class AbstractFacesConfigSection extends SectionPart implements this.helpTooltip = helpTooltip; } + public void dispose() { + selectionChangedListeners.clear(); + if (input != null) + removeAdaptersFromInput(input); + super.dispose(); + } /** * */ diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java index 31971bf08..7469d7fd9 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java @@ -246,46 +246,46 @@ public class ComponentGeneralSection extends AbstractFacesConfigSection { * Refresh the content on this section. */ public void refresh() { - if(getSection() == null || getSection().isDisposed()) { - return; - } super.refresh(); Object input = this.getInput(); - if (input instanceof ComponentType) { - ComponentType component = (ComponentType) input; - - if (component.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) component - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } + if (input instanceof ComponentType) { + final ComponentType component = (ComponentType) input; + refreshControls(component); + } + } - if (component.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) component - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil.unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } + private void refreshControls(ComponentType component) { + if (component.getDisplayName().size() > 0) { + DisplayNameType displayName = (DisplayNameType) component + .getDisplayName().get(0); + displayNameField.setTextWithoutUpdate(displayName + .getTextContent()); + } else { + displayNameField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (component.getComponentType() != null) { - componentTypeField.setTextWithoutUpdate(component - .getComponentType().getTextContent()); - } else { - componentTypeField.setTextWithoutUpdate(""); - } + if (component.getDescription().size() > 0) { + DescriptionType description = (DescriptionType) component + .getDescription().get(0); + String descriptionString = description.getTextContent(); + descriptionString = ModelUtil.unEscapeEntities(descriptionString); + descriptionField.setTextWithoutUpdate(descriptionString); + } else { + descriptionField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (component.getComponentClass() != null) { - componentClassField.setTextWithoutUpdate(component - .getComponentClass().getTextContent()); - } else { - componentClassField.setTextWithoutUpdate(""); - } + if (component.getComponentType() != null) { + componentTypeField.setTextWithoutUpdate(component + .getComponentType().getTextContent()); + } else { + componentTypeField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } + + if (component.getComponentClass() != null) { + componentClassField.setTextWithoutUpdate(component + .getComponentClass().getTextContent()); + } else { + componentClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ } } @@ -394,20 +394,28 @@ public class ComponentGeneralSection extends AbstractFacesConfigSection { .getComponentType_DisplayName() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getComponentType_Description()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getDisplayNameType_TextContent() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getDescriptionType_TextContent()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } } } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java index 5db889b47..0e740503a 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java @@ -304,58 +304,56 @@ public class ConverterGeneralSection extends AbstractFacesConfigSection { * */ public void refresh() { - if(getSection() == null || getSection().isDisposed()) { - return; - } super.refresh(); Object input = this.getInput(); if (input instanceof ConverterType) { - ConverterType Converter = (ConverterType) input; - - if (Converter.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Converter - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } + final ConverterType converter = (ConverterType) input; + refreshControls(converter); + } + } - if (Converter.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Converter - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } + private void refreshControls(ConverterType converter) { + if (converter.getDisplayName().size() > 0) { + DisplayNameType displayName = (DisplayNameType) converter + .getDisplayName().get(0); + displayNameField.setTextWithoutUpdate(displayName + .getTextContent()); + } else { + displayNameField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (Converter.getConverterId() != null) { - converterIdField.setTextWithoutUpdate(Converter - .getConverterId().getTextContent()); - } else { - converterIdField.setTextWithoutUpdate(""); - } + if (converter.getDescription().size() > 0) { + DescriptionType description = (DescriptionType) converter + .getDescription().get(0); + String descriptionString = description.getTextContent(); + descriptionString = ModelUtil + .unEscapeEntities(descriptionString); + descriptionField.setTextWithoutUpdate(descriptionString); + } else { + descriptionField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (Converter.getConverterForClass() != null) { - converterForClassField.setTextWithoutUpdate(Converter - .getConverterForClass().getTextContent()); - } else { - converterForClassField.setTextWithoutUpdate(""); - } + if (converter.getConverterId() != null) { + converterIdField.setTextWithoutUpdate(converter + .getConverterId().getTextContent()); + } else { + converterIdField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (Converter.getConverterClass() != null) { - converterClassField.setTextWithoutUpdate(Converter - .getConverterClass().getTextContent()); - } else { - converterClassField.setTextWithoutUpdate(""); - } + if (converter.getConverterForClass() != null) { + converterForClassField.setTextWithoutUpdate(converter + .getConverterForClass().getTextContent()); + } else { + converterForClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } + if (converter.getConverterClass() != null) { + converterClassField.setTextWithoutUpdate(converter + .getConverterClass().getTextContent()); + } else { + converterClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ } } - /** * Add ConverterGeneralAdapter onto <converter> and the first <display-name> * and <description> elements. @@ -463,20 +461,28 @@ public class ConverterGeneralSection extends AbstractFacesConfigSection { .getConverterType_Description() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getConverterType_DisplayName()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getDisplayNameType_TextContent() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getDescriptionType_TextContent()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } } } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java index baa845c72..91b11c749 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java @@ -66,6 +66,11 @@ public abstract class FacesConfigMasterSection extends AbstractFacesConfigSectio super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); } + public void dispose() { + structuredViewer.removeSelectionChangedListener(this); + super.dispose(); + } + /** * */ diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java index 876947483..3ac917a82 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java @@ -16,6 +16,7 @@ import java.util.List; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.ecore.EClass; @@ -53,6 +54,8 @@ import org.eclipse.ui.forms.widgets.FormToolkit; */ public class LocaleConfigSection extends ApplicationSection implements ICheckStateListener { + private LocaleConfigAdapter _localeConfigAdapter; + /** * * @param componentClass @@ -83,6 +86,10 @@ public class LocaleConfigSection extends ApplicationSection implements this(componentClass, parent, managedForm, page, toolkit, null, null); } + public void dispose() { + ((CheckboxTableViewer)tableViewer).removeCheckStateListener(this); + super.dispose(); + } /** * create a CheckboxTableViewer for this section. */ @@ -321,6 +328,34 @@ public class LocaleConfigSection extends ApplicationSection implements } } + @Override + protected void addAdaptersOntoInput(Object input) { + super.addAdaptersOntoInput(input); + if (input != null && input instanceof ApplicationType) { + ApplicationType application = (ApplicationType) input; + if (EcoreUtil.getExistingAdapter(application, + LocaleConfigSection.class) == null) { + application.eAdapters().add(getLocaleConfigAdapter()); + } + } + } + + private Adapter getLocaleConfigAdapter() { + if (_localeConfigAdapter == null) { + _localeConfigAdapter = new LocaleConfigAdapter(); + } + return _localeConfigAdapter; + } + + @Override + protected void removeAdaptersFromInput(Object input) { + if (input != null && input instanceof ApplicationType && _localeConfigAdapter != null) { + ApplicationType application = (ApplicationType) input; + application.eAdapters().remove(_localeConfigAdapter); + } + super.removeAdaptersFromInput(input); + } + /** * set the structuredViewer's input. Set the first LocaleConfig as input. * @@ -329,10 +364,6 @@ public class LocaleConfigSection extends ApplicationSection implements protected void setViewerInput(Object input) { if (input instanceof ApplicationType) { ApplicationType application = (ApplicationType) input; - if (EcoreUtil.getExistingAdapter(application, - LocaleConfigSection.class) == null) { - application.eAdapters().add(new LocaleConfigAdapter()); - } if (application.getLocaleConfig().size() > 0) { tableViewer.setInput(application.getLocaleConfig().get(0)); } else @@ -372,14 +403,15 @@ public class LocaleConfigSection extends ApplicationSection implements * section to reset it's input. */ - if(getSection() == null || getSection().isDisposed()) { - return; + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + setInput(getInput()); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + setInput(getInput()); + } + }); } - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - setInput(getInput()); - } - }); } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java index 68c8ad09c..e99bbeb75 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java @@ -233,39 +233,39 @@ public class ManagedBeanGeneralSection extends AbstractFacesConfigSection { * */ public void refresh() { - if(getSection() == null || getSection().isDisposed()) { - return; - } super.refresh(); Object input = this.getInput(); if (input instanceof ManagedBeanType) { - ManagedBeanType component = (ManagedBeanType) input; + final ManagedBeanType component = (ManagedBeanType) input; + refreshControls(component); + } + } - if (component.getManagedBeanName() != null) { - mbNameField.setTextWithoutUpdate(component.getManagedBeanName() - .getTextContent()); - } else { - mbNameField.setTextWithoutUpdate(""); - } + private void refreshControls(ManagedBeanType component) { + if (component.getManagedBeanName() != null) { + mbNameField.setTextWithoutUpdate(component.getManagedBeanName() + .getTextContent()); + } else { + mbNameField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (component.getManagedBeanClass() != null) { - mbClassField.setTextWithoutUpdate(component - .getManagedBeanClass().getTextContent()); - } else { - mbClassField.setTextWithoutUpdate(""); - } + if (component.getManagedBeanClass() != null) { + mbClassField.setTextWithoutUpdate(component + .getManagedBeanClass().getTextContent()); + } else { + mbClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (component.getManagedBeanScope() != null) { - mbScopeField.setTextWithoutUpdate(component - .getManagedBeanScope().getTextContent()); - } else { - // defaultly set it's scope to "session"; - mbScopeField - .setTextWithoutUpdate(IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION); - } + if (component.getManagedBeanScope() != null) { + mbScopeField.setTextWithoutUpdate(component + .getManagedBeanScope().getTextContent()); + } else { + // defaultly set it's scope to "session"; + mbScopeField + .setTextWithoutUpdate(IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION); } + } - protected void addAdaptersOntoInput(Object newInput) { super.addAdaptersOntoInput(newInput); ManagedBeanType managedBean = (ManagedBeanType) newInput; @@ -312,11 +312,15 @@ public class ManagedBeanGeneralSection extends AbstractFacesConfigSection { .getManagedBeanType_ManagedBeanClass() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getManagedBeanType_ManagedBeanScope()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } } } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java index 1289f413e..e7fe32d3f 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java @@ -229,8 +229,7 @@ public class ManagedBeanMasterSection extends FacesConfigMasterSection { } } - protected void removeAdaptersFromInput(Object oldInput) { - super.removeAdaptersFromInput(oldInput); + protected void removeAdaptersFromInput(Object oldInput) { FacesConfigType facesConfig = (FacesConfigType) oldInput; if (EcoreUtil.getExistingAdapter(facesConfig, ManagedBeanMasterSection.class) != null) { @@ -249,6 +248,7 @@ public class ManagedBeanMasterSection extends FacesConfigMasterSection { getManagedBeanMasterSectionAdapter()); } } + super.removeAdaptersFromInput(oldInput); } private ManagedBeanMasterSectionAdapter getManagedBeanMasterSectionAdapter() { @@ -279,38 +279,55 @@ public class ManagedBeanMasterSection extends FacesConfigMasterSection { mbean.eAdapters().add( getManagedBeanMasterSectionAdapter()); } - - Runnable run = new Runnable() { - - public void run() { - getStructuredViewer().refresh(true); - IStructuredSelection selection = new StructuredSelection( - mbean); - getStructuredViewer().setSelection(selection); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + getStructuredViewer().refresh(true); + IStructuredSelection selection = new StructuredSelection( + mbean); + getStructuredViewer().setSelection(selection); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + getStructuredViewer().refresh(true); + IStructuredSelection selection = new StructuredSelection( + mbean); + getStructuredViewer().setSelection(selection); + } + }); + } } else if (msg.getEventType() == Notification.REMOVE) { + final EObject mbean = (EObject) msg.getOldValue(); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + getStructuredViewer().refresh(true); + if (EcoreUtil.getExistingAdapter(mbean, + ManagedBeanMasterSection.class) == null) { + + mbean.eAdapters().remove( + getManagedBeanMasterSectionAdapter()); + } + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + getStructuredViewer().refresh(true); + if (EcoreUtil.getExistingAdapter(mbean, + ManagedBeanMasterSection.class) == null) { + + mbean.eAdapters().remove( + getManagedBeanMasterSectionAdapter()); + } + } + }); + } - Runnable run = new Runnable() { - public void run() { - getStructuredViewer().refresh(true); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); - } - - else if (msg.getEventType() == Notification.SET) { + } else if (msg.getEventType() == Notification.SET) { final Object mbean = msg.getNewValue(); - Runnable run = new Runnable() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + getStructuredViewer().refresh(mbean, true); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { getStructuredViewer().refresh(mbean, true); } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); + }); } } @@ -320,35 +337,39 @@ public class ManagedBeanMasterSection extends FacesConfigMasterSection { .getManagedBeanType_ManagedBeanName()) { final Object bean = msg.getNotifier(); - - Runnable run = new Runnable() { - - public void run() { - getStructuredViewer().refresh(bean, true); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + getStructuredViewer().refresh(bean, true); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + getStructuredViewer().refresh(bean, true); + } + }); + } + } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getManagedBeanType_ManagedBeanScope()) { final Object mbean = msg.getNotifier(); - - Runnable run1 = new Runnable() { - - public void run() { - getStructuredViewer().refresh(); - IStructuredSelection selection = new StructuredSelection( - mbean); - getStructuredViewer().setSelection(selection); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run1); + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + getStructuredViewer().refresh(); + IStructuredSelection selection = new StructuredSelection( + mbean); + getStructuredViewer().setSelection(selection); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + getStructuredViewer().refresh(); + IStructuredSelection selection = new StructuredSelection( + mbean); + getStructuredViewer().setSelection(selection); + } + }); + } } - } } + } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java index 1d1d31243..4eeca6993 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java @@ -81,6 +81,11 @@ public abstract class OthersPageBaseSection extends AbstractFacesConfigSection { this(parent, managedForm, page, toolkit, null, null); } + public void dispose() { + tableViewer.removeSelectionChangedListener(this); + tableViewer = null; + super.dispose(); + } /* * (non-Javadoc) * diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java index b04de92d8..ae4bd8a84 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java @@ -104,16 +104,16 @@ public class OverviewNavigationSection extends AbstractOverviewSection { case 0: return ((NavigationRuleType) navigationCase.eContainer()) - .getFromViewId() == null ? "" + .getFromViewId() == null ? "" //$NON-NLS-1$ : ((NavigationRuleType) navigationCase.eContainer()) .getFromViewId().getTextContent(); case 1: - return navigationCase.getFromOutcome() == null ? "" + return navigationCase.getFromOutcome() == null ? "" //$NON-NLS-1$ : navigationCase.getFromOutcome().getTextContent(); case 2: - return navigationCase.getToViewId() == null ? "" + return navigationCase.getToViewId() == null ? "" //$NON-NLS-1$ : navigationCase.getToViewId().getTextContent(); } return null; @@ -188,10 +188,7 @@ public class OverviewNavigationSection extends AbstractOverviewSection { * * @see org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection#refreshAll() */ - public void refreshAll() { - if(getSection() == null || getSection().isDisposed()) { - return; - } + public void refreshAll() { List navigationCaseList = new ArrayList(); if (getInput() instanceof FacesConfigType) { List navigationRules = ((FacesConfigType) getInput()) @@ -252,11 +249,10 @@ public class OverviewNavigationSection extends AbstractOverviewSection { * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#removeAdaptersFromInput(java.lang.Object) */ protected void removeAdaptersFromInput(Object oldInput) { - super.removeAdaptersFromInput(oldInput); - + super.removeAdaptersFromInput(oldInput); FacesConfigType facesConfig = (FacesConfigType) oldInput; removeOverviewNavigationSectionAdapter(facesConfig); - + for (Iterator it = facesConfig.getNavigationRule().iterator(); it .hasNext();) { NavigationRuleType navigationRule = (NavigationRuleType) it.next(); @@ -295,9 +291,9 @@ public class OverviewNavigationSection extends AbstractOverviewSection { } } - + private void removeOverviewNavigationSectionAdapter(EObject object) { - if (EcoreUtil.getExistingAdapter(object, + if (object != null && EcoreUtil.getExistingAdapter(object, OverviewNavigationSection.class) != null) { object.eAdapters().remove(getOverviewNavigationSectionAdapter()); } @@ -337,12 +333,16 @@ public class OverviewNavigationSection extends AbstractOverviewSection { if (msg.getEventType() == Notification.ADD || msg.getEventType() == Notification.REMOVE || msg.getEventType() == Notification.SET) - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refreshAll(); - } - }); - return; + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshAll(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refreshAll(); + } + }); + } + return; } if (msg.getFeature() == FacesConfigPackage.eINSTANCE @@ -362,15 +362,9 @@ public class OverviewNavigationSection extends AbstractOverviewSection { || msg.getEventType() == Notification.REMOVE || msg.getEventType() == Notification.SET) { - final NavigationCaseType navigationCase = (NavigationCaseType) msg + NavigationCaseType navigationCase = (NavigationCaseType) msg .getNotifier(); - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - if(!tableViewer.getControl().isDisposed()) { - tableViewer.refresh(navigationCase); - } - } - }); + refreshViewerOnUIThread(navigationCase); } return; } @@ -383,19 +377,27 @@ public class OverviewNavigationSection extends AbstractOverviewSection { if (msg.getEventType() == Notification.ADD || msg.getEventType() == Notification.REMOVE || msg.getEventType() == Notification.SET) { - final NavigationCaseType navigationCase = (NavigationCaseType) ((EObject) msg + NavigationCaseType navigationCase = (NavigationCaseType) ((EObject) msg .getNotifier()).eContainer(); - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - if(!tableViewer.getControl().isDisposed()) { - tableViewer.refresh(navigationCase); - } - } - }); + refreshViewerOnUIThread(navigationCase); } return; } } + + private void refreshViewerOnUIThread(final NavigationCaseType navigationCase) { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + tableViewer.refresh(navigationCase); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + tableViewer.refresh(navigationCase); + } + }); + } + + } } + } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java index 2cf904fb2..a1179bc79 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java @@ -344,14 +344,18 @@ public class OverviewOthersSection extends AbstractOverviewSection { if (msg.getEventType() == Notification.ADD || msg.getEventType() == Notification.REMOVE || msg.getEventType() == Notification.SET) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refreshAll(); - } - }); + + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refreshAll(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refreshAll(); + } + }); + } } } - } } } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java index 2242f73ca..58e83e7e4 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java @@ -241,50 +241,50 @@ public class RenderkitGeneralSection extends AbstractFacesConfigSection { * */ public void refresh() { - if(getSection() == null || getSection().isDisposed()) { - return; - } super.refresh(); Object input = this.getInput(); if (input instanceof RenderKitType) { - RenderKitType Renderkit = (RenderKitType) input; - - if (Renderkit.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Renderkit - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } + final RenderKitType renderkit = (RenderKitType) input; + refreshControls(renderkit); + } + } - if (Renderkit.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Renderkit - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } + private void refreshControls(RenderKitType renderkit) { + if (renderkit.getDisplayName().size() > 0) { + DisplayNameType displayName = (DisplayNameType) renderkit + .getDisplayName().get(0); + displayNameField.setTextWithoutUpdate(displayName + .getTextContent()); + } else { + displayNameField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (Renderkit.getRenderKitId() != null) { - renderkitIdField.setTextWithoutUpdate(Renderkit - .getRenderKitId().getTextContent()); - } else { - renderkitIdField.setTextWithoutUpdate(""); - } + if (renderkit.getDescription().size() > 0) { + DescriptionType description = (DescriptionType) renderkit + .getDescription().get(0); + String descriptionString = description.getTextContent(); + descriptionString = ModelUtil + .unEscapeEntities(descriptionString); + descriptionField.setTextWithoutUpdate(descriptionString); + } else { + descriptionField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (Renderkit.getRenderKitClass() != null) { - renderkitClassField.setTextWithoutUpdate(Renderkit - .getRenderKitClass().getTextContent()); - } else { - renderkitClassField.setTextWithoutUpdate(""); - } + if (renderkit.getRenderKitId() != null) { + renderkitIdField.setTextWithoutUpdate(renderkit + .getRenderKitId().getTextContent()); + } else { + renderkitIdField.setTextWithoutUpdate(""); //$NON-NLS-1$ } - } + if (renderkit.getRenderKitClass() != null) { + renderkitClassField.setTextWithoutUpdate(renderkit + .getRenderKitClass().getTextContent()); + } else { + renderkitClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } + + } /** * Add RenderKitGeneralAdapter onto <render-kit> and the first * <display-name> and <description> elements. @@ -390,23 +390,27 @@ public class RenderkitGeneralSection extends AbstractFacesConfigSection { .getRenderKitType_Description() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getRenderKitType_DisplayName()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); - + refreshInUIThread(); } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getDisplayNameType_TextContent() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getDescriptionType_TextContent()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + refreshInUIThread(); } } } + + private void refreshInUIThread() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } + } } + } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java index 2a1001519..3b478ec78 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java @@ -242,48 +242,49 @@ public class ValidatorGeneralSection extends AbstractFacesConfigSection { * */ public void refresh() { - if(getSection() == null || getSection().isDisposed()) { - return; - } super.refresh(); Object input = this.getInput(); if (input instanceof ValidatorType) { - ValidatorType validator = (ValidatorType) input; - - if (validator.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) validator - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } + final ValidatorType validator = (ValidatorType) input; + refreshControls(validator); + } + } + + private void refreshControls(final ValidatorType validator) { + if (validator.getDisplayName().size() > 0) { + DisplayNameType displayName = (DisplayNameType) validator + .getDisplayName().get(0); + displayNameField.setTextWithoutUpdate(displayName + .getTextContent()); + } else { + displayNameField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (validator.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) validator - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } + if (validator.getDescription().size() > 0) { + DescriptionType description = (DescriptionType) validator + .getDescription().get(0); + String descriptionString = description.getTextContent(); + descriptionString = ModelUtil + .unEscapeEntities(descriptionString); + descriptionField.setTextWithoutUpdate(descriptionString); + } else { + descriptionField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (validator.getValidatorId() != null) { - validatorIDField.setTextWithoutUpdate(validator - .getValidatorId().getTextContent()); - } else { - validatorIDField.setTextWithoutUpdate(""); - } + if (validator.getValidatorId() != null) { + validatorIDField.setTextWithoutUpdate(validator + .getValidatorId().getTextContent()); + } else { + validatorIDField.setTextWithoutUpdate(""); //$NON-NLS-1$ + } - if (validator.getValidatorClass() != null) { - validatorClassField.setTextWithoutUpdate(validator - .getValidatorClass().getTextContent()); - } else { - validatorClassField.setTextWithoutUpdate(""); - } + if (validator.getValidatorClass() != null) { + validatorClassField.setTextWithoutUpdate(validator + .getValidatorClass().getTextContent()); + } else { + validatorClassField.setTextWithoutUpdate(""); //$NON-NLS-1$ } + } /** @@ -391,22 +392,25 @@ public class ValidatorGeneralSection extends AbstractFacesConfigSection { .getValidatorType_Description() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getValidatorType_DisplayName()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + refreshInUIThread(); } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE .getDisplayNameType_TextContent() || msg.getFeature() == FacesConfigPackage.eINSTANCE .getDescriptionType_TextContent()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - refresh(); - } - }); + refreshInUIThread(); } } } + private void refreshInUIThread() { + if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) { + refresh(); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + refresh(); + } + }); + } + } } } |