Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkchong2005-10-19 23:06:51 +0000
committerkchong2005-10-19 23:06:51 +0000
commit07e18e983da520275575eb9f79fa96dc0b952a4e (patch)
tree73a3e1598e4b3bf73d1095b8bc65b489d7eb4cce /bundles/org.eclipse.wst.wsdl.ui
parent5a357eda4799f3a48ab46d980d1a8adb47583ac0 (diff)
downloadwebtools.webservices-07e18e983da520275575eb9f79fa96dc0b952a4e.tar.gz
webtools.webservices-07e18e983da520275575eb9f79fa96dc0b952a4e.tar.xz
webtools.webservices-07e18e983da520275575eb9f79fa96dc0b952a4e.zip
[112883] Get rid of WSDLTextEditor (no subclassing of StructuredTextEditor allowed)
Diffstat (limited to 'bundles/org.eclipse.wst.wsdl.ui')
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/plugin.xml6
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/StructuredTextViewerConfigurationWSDL.java41
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java1010
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlink.java106
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlinkDetector.java131
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLTextEditor.java17
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java2
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java3
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java295
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlineConfiguration.java320
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java5
11 files changed, 1362 insertions, 574 deletions
diff --git a/bundles/org.eclipse.wst.wsdl.ui/plugin.xml b/bundles/org.eclipse.wst.wsdl.ui/plugin.xml
index 2c43f2718..2d1c6f671 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.wsdl.ui/plugin.xml
@@ -184,6 +184,12 @@
type="preferencepages"
value="org.eclipse.wst.wsdl.ui.internal.util.WSDLPreferencePage"
target="org.eclipse.wst.wsdl.ui.internal.WSDLEditor.source" />
+ <sourceViewerConfiguration
+ class="org.eclipse.wst.wsdl.ui.internal.StructuredTextViewerConfigurationWSDL"
+ target="org.eclipse.wst.wsdl.wsdlsource" />
+ <contentOutlineConfiguration
+ class="org.eclipse.wst.wsdl.ui.internal.outline.WSDLContentOutlineConfiguration"
+ target="org.eclipse.wst.wsdl.wsdlsource" />
<!--
<propertySheetConfiguration
class="org.eclipse.wst.wsdl.ui.internal.properties.WSDLPropertySheetConfiguration"
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/StructuredTextViewerConfigurationWSDL.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/StructuredTextViewerConfigurationWSDL.java
new file mode 100644
index 000000000..744bd43a4
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/StructuredTextViewerConfigurationWSDL.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ */
+package org.eclipse.wst.wsdl.ui.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
+
+public class StructuredTextViewerConfigurationWSDL extends StructuredTextViewerConfigurationXML {
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+ return null;
+
+ List allDetectors = new ArrayList(0);
+ // add WSDL Hyperlink detector
+ allDetectors.add(new WSDLHyperlinkDetector());
+
+ IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
+ for (int m = 0; m < superDetectors.length; m++) {
+ IHyperlinkDetector detector = superDetectors[m];
+ if (!allDetectors.contains(detector)) {
+ allDetectors.add(detector);
+ }
+ }
+ return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
+ }
+}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java
index 9907c9846..f2140f201 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java
@@ -10,8 +10,18 @@
*******************************************************************************/
package org.eclipse.wst.wsdl.ui.internal;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IPostSelectionProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -21,6 +31,8 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -32,455 +44,599 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextSelectionNavigationLocation;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.wsdl.Binding;
import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.WSDLElement;
import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
+import org.eclipse.wst.wsdl.internal.generator.BindingGenerator;
import org.eclipse.wst.wsdl.ui.internal.actions.WSDLMenuActionContributor;
+import org.eclipse.wst.wsdl.ui.internal.dialogs.GenerateBindingOnSaveDialog;
import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension;
import org.eclipse.wst.wsdl.ui.internal.graph.WSDLGraphViewer;
import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLEditPartFactory;
import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject;
import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory;
-import org.eclipse.wst.wsdl.ui.internal.outline.ExtensibleOutlineProvider;
import org.eclipse.wst.wsdl.ui.internal.outline.ModelAdapterContentProvider;
import org.eclipse.wst.wsdl.ui.internal.outline.ModelAdapterLabelProvider;
+import org.eclipse.wst.wsdl.ui.internal.properties.section.WSDLTabbedPropertySheetPage;
import org.eclipse.wst.wsdl.ui.internal.text.WSDLModelAdapter;
import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil;
+import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil;
import org.eclipse.wst.wsdl.ui.internal.util.WSDLNodeAssociationProvider;
import org.eclipse.wst.wsdl.ui.internal.util.WSDLResourceUtil;
import org.eclipse.wst.wsdl.ui.internal.viewers.WSDLDetailsViewer;
import org.eclipse.wst.wsdl.ui.internal.viewers.WSDLDetailsViewerProvider;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
-// public class WSDLEditor extends StructuredTextMultiPageEditorPart implements
+// public class WSDLEditor extends StructuredTextMultiPageEditorPart
+// implements
// INavigationLocationProvider
-public class WSDLEditor extends WSDLMultiPageEditorPart implements INavigationLocationProvider
-{
- protected ExtensibleOutlineProvider extensibleOutlineProvider;
- protected WSDLTextEditor textEditor;
- protected WSDLGraphViewer graphViewer;
- protected WSDLDetailsViewer detailsViewer;
- protected WSDLSelectionManager selectionManager;
- protected SashForm sashForm;
- int graphPageIndex;
- protected WSDLModelAdapter modelAdapter;
- protected WSDLEditorResourceChangeHandler resourceChangeHandler;
- // Used for Cut, Copy, Paste actions. This acts as a copy, cut, paste
- // clipboard
- protected WSDLElement clipboardElement;
-
- public WSDLEditor()
- {
- selectionManager = new WSDLSelectionManager();
- }
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException
- {
- super.init(site, input);
- try
- {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- {
- page.showView("org.eclipse.ui.views.PropertySheet");
- }
- }
- catch (PartInitException partInitException)
- {
- }
- catch (Exception exception)
- {
- }
- }
-
- public Object getAdapter(Class key)
- {
- Object result = null;
- if (key == ISelectionProvider.class)
- {
- result = selectionManager;
- }
- else
- {
- result = super.getAdapter(key);
- }
- return result;
- }
-
- public void dispose()
- {
- // call the extensibleOutlineProvider's inputChanged method a null viewer
- // so that the outline's contentprovider/adapters don't attempt to update
- // the viewer
- // after the editor closes
- extensibleOutlineProvider.inputChanged(null, null, null);
- if (resourceChangeHandler != null)
- {
- resourceChangeHandler.dispose();
- }
- super.dispose();
- }
-
- public WSDLSelectionManager getSelectionManager()
- {
- return selectionManager;
- }
-
- public ExtensibleOutlineProvider getExtensibleOutlineProvider()
- {
- if (extensibleOutlineProvider == null)
- {
- extensibleOutlineProvider = new ExtensibleOutlineProvider(this);
- }
- return extensibleOutlineProvider;
- }
-
- public WSDLTextEditor getWSDLTextEditor()
- {
- return textEditor;
- }
-
- public WSDLGraphViewer getGraphViewer()
- {
- return graphViewer;
- }
-
- public IStructuredModel getStructuredModel()
- {
- return textEditor.getModel();
-// IDocument doc = textEditor.getDocumentProvider().getDocument(getEditorInput());
-// IModelManager modelManager = ModelManagerImpl.getInstance();
-// return modelManager.getModelForRead((IStructuredDocument) doc);
- }
-
- public Document getXMLDocument()
- {
- return ((IDOMModel) getStructuredModel()).getDocument();
- }
-
- public Definition getDefinition()
- {
- return modelAdapter != null ? modelAdapter.getDefinition() : null;
- }
-
- /**
- * Creates the pages of this multi-page editor.
- * <p>
- * Subclasses of <code>MultiPageEditor</code> must implement this method.
- * </p>
- */
- protected void createPages()
- {
- try
- {
- if (resourceChangeHandler == null)
- {
- resourceChangeHandler = new WSDLEditorResourceChangeHandler(this);
- resourceChangeHandler.attach();
- }
- createSourcePage();
- addSourcePage();
- // create the wsdl model
- //
- lookupOrCreateWSDLModel();
- createAndAddGraphPage();
- // get the type of page and set the active page to show
- int pageIndexToShow = getDefaultPageIndex();
- setActivePage(pageIndexToShow);
- getSelectionManager().setSelection(new StructuredSelection(getDefinition()));
- }
- catch (PartInitException e)
- {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- // TODO: add a catch block here for any exception the design page throws and
- // convert it into a more informative message.
- }
-
- protected void lookupOrCreateWSDLModel()
- {
- try
- {
- Document document = ((IDOMModel) getModel()).getDocument();
- if (document instanceof INodeNotifier)
- {
- INodeNotifier notifier = (INodeNotifier) document;
- modelAdapter = (WSDLModelAdapter) notifier.getAdapterFor(WSDLModelAdapter.class);
- if (modelAdapter == null)
- {
- modelAdapter = new WSDLModelAdapter();
- notifier.addAdapter(modelAdapter);
- modelAdapter.createDefinition(document.getDocumentElement());
- }
- }
- }
- catch (Exception e)
- {
- }
- }
-
- protected int getDefaultPageIndex()
- {
- if (WSDLEditorPlugin.getInstance().getDefaultPage().equals(WSDLEditorPlugin.GRAPH_PAGE))
- {
- if (graphPageIndex != -1)
- {
- return graphPageIndex;
- }
- }
- return sourcePageIndex;
- }
-
- /**
- * @see org.eclipse.wst.wsdl.ui.WSDLMultiPageEditorPart#createTextEditor()
- */
- protected StructuredTextEditor createTextEditor()
- {
- textEditor = new WSDLTextEditor(this);
- return textEditor;
- }
-
- /**
- * create our own
- */
- protected void createSourcePage() throws PartInitException
- {
- super.createSourcePage();
- textEditor = (WSDLTextEditor) getTextEditor();
- }
- int sourcePageIndex = -1;
-
- /**
- * Adds the source page of the multi-page editor.
- */
- protected void addSourcePage() throws PartInitException
- {
- sourcePageIndex = addPage(textEditor, getEditorInput());
- setPageText(sourcePageIndex, WSDLEditorPlugin.getWSDLString("_UI_TAB_SOURCE"));
- // the update's critical, to get viewer selection manager and highlighting to
- // work
- textEditor.update();
- }
-
- int[] weights;
-
- public void setDesignWeights(int[] weights, boolean updateSourceDesign)
- {
- this.weights = weights;
- if (updateSourceDesign)
- {
- sashForm.setWeights(weights);
- }
- }
-
- protected void pageChange(int arg)
- {
- super.pageChange(arg);
- if (getPageText(arg).equals(WSDLEditorPlugin.getWSDLString("_UI_TAB_SOURCE"))) // TRANSLATE
- // !
- {
- // update the input
- }
- else if (getPageText(arg).equals(WSDLEditorPlugin.getWSDLString("_UI_TAB_GRAPH"))) // TRANSLATE
- // !
- {
- // update the input
- }
- }
- static private Color dividerColor;
-
- /**
- * Creates the graph page and adds it to the multi-page editor.
- */
- protected void createAndAddGraphPage() throws PartInitException
- {
- // create the graph page
- sashForm = new SashForm(getContainer(), SWT.BORDER);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
- sashForm.setOrientation(SWT.VERTICAL);
- graphPageIndex = addPage(sashForm);
- setPageText(graphPageIndex, WSDLEditorPlugin.getWSDLString("_UI_TAB_GRAPH"));
- // create the graph viewer
- graphViewer = new WSDLGraphViewer(this);
- graphViewer.createControl(sashForm);
- // detailsViewer = new WSDLDetailsViewer(this);
- // detailsViewer.createControl(sashForm);
- //
- // sashForm.setWeights(weights);
- if (dividerColor == null)
- {
- dividerColor = new Color(getContainer().getDisplay(), 143, 141, 138);
- }
- getContainer().addPaintListener(new PaintListener()
- {
- /**
- * @see org.eclipse.swt.events.PaintListener#paintControl(PaintEvent)
- */
- public void paintControl(PaintEvent e)
- {
- Object source = e.getSource();
- if (source instanceof Composite)
- {
- Composite comp = (Composite) source;
- Rectangle boundary = comp.getClientArea();
- e.gc.setForeground(dividerColor);
- e.gc.drawLine(boundary.x, boundary.y, boundary.x + boundary.width, boundary.y);
- setDesignWeights(sashForm.getWeights(), true);
- }
- }
- });
- }
-
- public void setFocus()
- {
- super.setFocus();
- int activePage = getActivePage();
- if (activePage == sourcePageIndex)
- {
- WSDLEditorPlugin.getInstance().setDefaultPage(WSDLEditorPlugin.SOURCE_PAGE);
- }
- else
- {
- WSDLEditorPlugin.getInstance().setDefaultPage(WSDLEditorPlugin.GRAPH_PAGE);
- }
- }
- //
- //
- public static class BuiltInWSDLEditorExtension implements WSDLEditorExtension
- {
- public boolean isExtensionTypeSupported(int type)
- {
- return type == OUTLINE_TREE_CONTENT_PROVIDER || type == OUTLINE_LABEL_PROVIDER || type == EDIT_PART_FACTORY || type == DETAILS_VIEWER_PROVIDER || type == MENU_ACTION_CONTRIBUTOR
- || type == NODE_RECONCILER || type == NODE_ASSOCIATION_PROVIDER;
- }
-
- public boolean isApplicable(Object object)
- {
- return (object instanceof WSDLElement && !(object instanceof XSDSchemaExtensibilityElement)) || (object instanceof WSDLGroupObject);
- }
-
- public Object createExtensionObject(int type, WSDLEditor wsdlEditor)
- {
- Object result = null;
- switch (type)
- {
- case OUTLINE_TREE_CONTENT_PROVIDER : {
- result = new ModelAdapterContentProvider(WSDLModelAdapterFactory.getWSDLModelAdapterFactory());
- break;
- }
- case OUTLINE_LABEL_PROVIDER : {
- result = new ModelAdapterLabelProvider(WSDLModelAdapterFactory.getWSDLModelAdapterFactory());
- break;
- }
- case DETAILS_VIEWER_PROVIDER : {
- result = new WSDLDetailsViewerProvider();
- break;
- }
- case MENU_ACTION_CONTRIBUTOR : {
- result = new WSDLMenuActionContributor(wsdlEditor);
- break;
- }
- case NODE_ASSOCIATION_PROVIDER : {
- result = new WSDLNodeAssociationProvider();
- break;
- }
- case EDIT_PART_FACTORY : {
- result = new WSDLEditPartFactory();
- break;
- }
- }
- return result;
- }
- }
-
- public void reloadDependencies()
- {
- try
- {
- getGraphViewer().getComponentViewer().setPreserveExpansionEnabled(true);
- Definition definition = getDefinition();
- if (definition != null)
- {
- WSDLResourceUtil.reloadDirectives(definition);
- ComponentReferenceUtil.updateBindingReferences(definition);
- ComponentReferenceUtil.updatePortTypeReferences(definition);
- ComponentReferenceUtil.updateMessageReferences(definition);
- ComponentReferenceUtil.updateSchemaReferences(definition);
- // the line below simply causes a notification in order to update our
- // views
- //
- definition.setDocumentationElement(definition.getDocumentationElement());
- }
- }
- finally
- {
- getGraphViewer().getComponentViewer().setPreserveExpansionEnabled(false);
- }
- }
-
- public void openOnSelection(String specification)
- {
- EObject eObject = getDefinition().eResource().getEObject(specification);
- if (eObject != null)
- {
- getSelectionManager().setSelection(new StructuredSelection(eObject));
- }
- }
-
- public INavigationLocation createEmptyNavigationLocation()
- {
- return new InternalTextSelectionNavigationLocation(textEditor, false);
- }
-
- public INavigationLocation createNavigationLocation()
- {
- return new InternalTextSelectionNavigationLocation(textEditor, true);
- }
- static class InternalTextSelectionNavigationLocation extends TextSelectionNavigationLocation
- {
- public InternalTextSelectionNavigationLocation(ITextEditor part, boolean initialize)
- {
- super(part, initialize);
- }
-
- protected IEditorPart getEditorPart()
- {
- IEditorPart part = super.getEditorPart();
- if (part instanceof WSDLEditor)
- {
- part = ((WSDLEditor) part).getTextEditor();
- }
- return part;
- }
-
- public String getText()
- {
- IEditorPart part = getEditorPart();
- if (part instanceof WSDLTextEditor)
- {
- return ((WSDLTextEditor) part).getWSDLEditor().getTitle();
- }
- else
- {
- return super.getText();
- }
- }
- }
-
- // Returns the element currently on the copy, cut, paste clipboard
- public WSDLElement getClipboardContents()
- {
- return clipboardElement;
- }
-
- public void setClipboardContents(WSDLElement element)
- {
- clipboardElement = element;
- }
+public class WSDLEditor extends WSDLMultiPageEditorPart implements INavigationLocationProvider, ITabbedPropertySheetPageContributor {
+ protected StructuredTextEditor textEditor;
+ protected WSDLGraphViewer graphViewer;
+ protected WSDLDetailsViewer detailsViewer;
+ protected WSDLSelectionManager selectionManager;
+ protected SashForm sashForm;
+ int graphPageIndex;
+ protected WSDLModelAdapter modelAdapter;
+ protected WSDLEditorResourceChangeHandler resourceChangeHandler;
+ // Used for Cut, Copy, Paste actions. This acts as a copy, cut, paste
+ // clipboard
+ protected WSDLElement clipboardElement;
+ private IPropertySheetPage fPropertySheetPage;
+ private SourceEditorSelectionListener fSourceEditorSelectionListener;
+ private WSDLSelectionManagerSelectionListener fWSDLSelectionListener;
+
+ /**
+ * Listener on SSE's source editor's selections that converts DOM
+ * selections into wsdl selections and notifies WSDL selection manager
+ */
+ private class SourceEditorSelectionListener implements ISelectionChangedListener {
+ /**
+ * Determines WSDL node based on object (DOM node)
+ *
+ * @param object
+ * @return
+ */
+ private Object getWSDLNode(Object object) {
+ // get the element node
+ Element element = null;
+ if (object instanceof Node) {
+ Node node = (Node) object;
+ if (node != null) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ element = (Element) node;
+ }
+ else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ element = ((Attr) node).getOwnerElement();
+ }
+ }
+ }
+ Object o = element;
+ if (element != null) {
+ Object modelObject = WSDLEditorUtil.getInstance().findModelObjectForElement(getDefinition(), element);
+ if (modelObject != null) {
+ o = modelObject;
+ }
+ }
+ return o;
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ List wsdlSelections = new ArrayList();
+ for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
+ Object domNode = i.next();
+ Object wsdlNode = getWSDLNode(domNode);
+ if (wsdlNode != null) {
+ wsdlSelections.add(wsdlNode);
+ }
+ }
+
+ if (!wsdlSelections.isEmpty()) {
+ StructuredSelection wsdlSelection = new StructuredSelection(wsdlSelections);
+ getSelectionManager().setSelection(wsdlSelection, getTextEditor().getSelectionProvider());
+ }
+ }
+ }
+ }
+
+ /**
+ * Listener on WSDL's selection manager's selections that converts WSDL
+ * selections into DOM selections and notifies SSE's selection provider
+ */
+ private class WSDLSelectionManagerSelectionListener implements ISelectionChangedListener {
+ /**
+ * Determines DOM node based on object (wsdl node)
+ *
+ * @param object
+ * @return
+ */
+ private Object getObjectForOtherModel(Object object) {
+ Node node = null;
+
+ if (object instanceof Node) {
+ node = (Node) object;
+ }
+ else {
+ node = WSDLEditorUtil.getInstance().getNodeForObject(object);
+ }
+
+ // the text editor can only accept sed nodes!
+ //
+ if (!(node instanceof IDOMNode)) {
+ node = null;
+ }
+ return node;
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ // do not fire selection in source editor if selection event came
+ // from source editor
+ if (event.getSource() != getTextEditor().getSelectionProvider()) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ List otherModelObjectList = new ArrayList();
+ for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
+ Object modelObject = i.next();
+ Object otherModelObject = getObjectForOtherModel(modelObject);
+ if (otherModelObject != null) {
+ otherModelObjectList.add(otherModelObject);
+ }
+ }
+ if (!otherModelObjectList.isEmpty()) {
+ StructuredSelection nodeSelection = new StructuredSelection(otherModelObjectList);
+ getTextEditor().getSelectionProvider().setSelection(nodeSelection);
+ }
+ }
+ }
+ }
+ }
+
+ public WSDLEditor() {
+ selectionManager = new WSDLSelectionManager();
+ }
+
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+ try {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ page.showView("org.eclipse.ui.views.PropertySheet");
+ }
+ }
+ catch (PartInitException partInitException) {
+ }
+ catch (Exception exception) {
+ }
+ }
+
+ public Object getAdapter(Class key) {
+ Object result = null;
+ if (key == ISelectionProvider.class) {
+ result = selectionManager;
+ }
+ else if (IPropertySheetPage.class.equals(key)) {
+ if (fPropertySheetPage == null || fPropertySheetPage.getControl() == null || fPropertySheetPage.getControl().isDisposed()) {
+ fPropertySheetPage = new WSDLTabbedPropertySheetPage(this, this);
+ ((WSDLTabbedPropertySheetPage) fPropertySheetPage).setSelectionManager(getSelectionManager());
+
+ }
+
+ return fPropertySheetPage;
+ }
+ else {
+ result = super.getAdapter(key);
+ }
+ return result;
+ }
+
+ public void dispose() {
+ // call the extensibleOutlineProvider's inputChanged method a null
+ // viewer
+ // so that the outline's contentprovider/adapters don't attempt to
+ // update
+ // the viewer
+ // after the editor closes
+ // extensibleOutlineProvider.inputChanged(null, null, null);
+ if (resourceChangeHandler != null) {
+ resourceChangeHandler.dispose();
+ }
+
+ ISelectionProvider provider = getTextEditor().getSelectionProvider();
+ if (provider instanceof IPostSelectionProvider) {
+ ((IPostSelectionProvider) provider).removePostSelectionChangedListener(fSourceEditorSelectionListener);
+ }
+ else {
+ provider.removeSelectionChangedListener(fSourceEditorSelectionListener);
+ }
+ getSelectionManager().removeSelectionChangedListener(fWSDLSelectionListener);
+ super.dispose();
+ }
+
+ public WSDLSelectionManager getSelectionManager() {
+ return selectionManager;
+ }
+
+ public WSDLGraphViewer getGraphViewer() {
+ return graphViewer;
+ }
+
+ public IStructuredModel getStructuredModel() {
+ return textEditor.getModel();
+ // IDocument doc =
+ // textEditor.getDocumentProvider().getDocument(getEditorInput());
+ // IModelManager modelManager = ModelManagerImpl.getInstance();
+ // return modelManager.getModelForRead((IStructuredDocument) doc);
+ }
+
+ public Document getXMLDocument() {
+ return ((IDOMModel) getStructuredModel()).getDocument();
+ }
+
+ public Definition getDefinition() {
+ return modelAdapter != null ? modelAdapter.getDefinition() : null;
+ }
+
+ /**
+ * Creates the pages of this multi-page editor.
+ * <p>
+ * Subclasses of <code>MultiPageEditor</code> must implement this
+ * method.
+ * </p>
+ */
+ protected void createPages() {
+ try {
+ if (resourceChangeHandler == null) {
+ resourceChangeHandler = new WSDLEditorResourceChangeHandler(this);
+ resourceChangeHandler.attach();
+ }
+ createSourcePage();
+ addSourcePage();
+ // create the wsdl model
+ //
+ lookupOrCreateWSDLModel();
+ createAndAddGraphPage();
+
+ // get the type of page and set the active page to show
+ int pageIndexToShow = getDefaultPageIndex();
+ setActivePage(pageIndexToShow);
+ getSelectionManager().setSelection(new StructuredSelection(getDefinition()));
+
+ // added selection listeners after setting selection to avoid
+ // navigation exception
+ ISelectionProvider provider = getTextEditor().getSelectionProvider();
+ fSourceEditorSelectionListener = new SourceEditorSelectionListener();
+ if (provider instanceof IPostSelectionProvider) {
+ ((IPostSelectionProvider) provider).addPostSelectionChangedListener(fSourceEditorSelectionListener);
+ }
+ else {
+ provider.addSelectionChangedListener(fSourceEditorSelectionListener);
+ }
+ fWSDLSelectionListener = new WSDLSelectionManagerSelectionListener();
+ getSelectionManager().addSelectionChangedListener(fWSDLSelectionListener);
+ }
+ catch (PartInitException e) {
+ // log for now, unless we find reason not to
+ Logger.log(Logger.INFO, e.getMessage());
+ }
+ // TODO: add a catch block here for any exception the design page
+ // throws and
+ // convert it into a more informative message.
+ }
+
+ protected void lookupOrCreateWSDLModel() {
+ try {
+ Document document = ((IDOMModel) getModel()).getDocument();
+ if (document instanceof INodeNotifier) {
+ INodeNotifier notifier = (INodeNotifier) document;
+ modelAdapter = (WSDLModelAdapter) notifier.getAdapterFor(WSDLModelAdapter.class);
+ if (modelAdapter == null) {
+ modelAdapter = new WSDLModelAdapter();
+ notifier.addAdapter(modelAdapter);
+ modelAdapter.createDefinition(document.getDocumentElement());
+ }
+ }
+ }
+ catch (Exception e) {
+ }
+ }
+
+ protected int getDefaultPageIndex() {
+ if (WSDLEditorPlugin.getInstance().getDefaultPage().equals(WSDLEditorPlugin.GRAPH_PAGE)) {
+ if (graphPageIndex != -1) {
+ return graphPageIndex;
+ }
+ }
+ return sourcePageIndex;
+ }
+
+ /**
+ * @see org.eclipse.wst.wsdl.ui.WSDLMultiPageEditorPart#createTextEditor()
+ */
+ protected StructuredTextEditor createTextEditor() {
+ textEditor = new StructuredTextEditor();
+ return textEditor;
+ }
+
+ /**
+ * create our own
+ */
+ protected void createSourcePage() throws PartInitException {
+ super.createSourcePage();
+ textEditor = getTextEditor();
+ }
+
+ int sourcePageIndex = -1;
+
+ /**
+ * Adds the source page of the multi-page editor.
+ */
+ protected void addSourcePage() throws PartInitException {
+ sourcePageIndex = addPage(textEditor, getEditorInput());
+ setPageText(sourcePageIndex, WSDLEditorPlugin.getWSDLString("_UI_TAB_SOURCE"));
+ // the update's critical, to get viewer selection manager and
+ // highlighting to
+ // work
+ textEditor.update();
+ }
+
+ int[] weights;
+
+ public void setDesignWeights(int[] weights, boolean updateSourceDesign) {
+ this.weights = weights;
+ if (updateSourceDesign) {
+ sashForm.setWeights(weights);
+ }
+ }
+
+ protected void pageChange(int arg) {
+ super.pageChange(arg);
+ if (getPageText(arg).equals(WSDLEditorPlugin.getWSDLString("_UI_TAB_SOURCE"))) // TRANSLATE
+ // !
+ {
+ // update the input
+ }
+ else if (getPageText(arg).equals(WSDLEditorPlugin.getWSDLString("_UI_TAB_GRAPH"))) // TRANSLATE
+ // !
+ {
+ // update the input
+ }
+ }
+
+ static private Color dividerColor;
+
+ /**
+ * Creates the graph page and adds it to the multi-page editor.
+ */
+ protected void createAndAddGraphPage() throws PartInitException {
+ // create the graph page
+ sashForm = new SashForm(getContainer(), SWT.BORDER);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ sashForm.setOrientation(SWT.VERTICAL);
+ graphPageIndex = addPage(sashForm);
+ setPageText(graphPageIndex, WSDLEditorPlugin.getWSDLString("_UI_TAB_GRAPH"));
+ // create the graph viewer
+ graphViewer = new WSDLGraphViewer(this);
+ graphViewer.createControl(sashForm);
+ // detailsViewer = new WSDLDetailsViewer(this);
+ // detailsViewer.createControl(sashForm);
+ //
+ // sashForm.setWeights(weights);
+ if (dividerColor == null) {
+ dividerColor = new Color(getContainer().getDisplay(), 143, 141, 138);
+ }
+ getContainer().addPaintListener(new PaintListener() {
+ /**
+ * @see org.eclipse.swt.events.PaintListener#paintControl(PaintEvent)
+ */
+ public void paintControl(PaintEvent e) {
+ Object source = e.getSource();
+ if (source instanceof Composite) {
+ Composite comp = (Composite) source;
+ Rectangle boundary = comp.getClientArea();
+ e.gc.setForeground(dividerColor);
+ e.gc.drawLine(boundary.x, boundary.y, boundary.x + boundary.width, boundary.y);
+ setDesignWeights(sashForm.getWeights(), true);
+ }
+ }
+ });
+ }
+
+ public void setFocus() {
+ super.setFocus();
+ int activePage = getActivePage();
+ if (activePage == sourcePageIndex) {
+ WSDLEditorPlugin.getInstance().setDefaultPage(WSDLEditorPlugin.SOURCE_PAGE);
+ }
+ else {
+ WSDLEditorPlugin.getInstance().setDefaultPage(WSDLEditorPlugin.GRAPH_PAGE);
+ }
+ }
+
+ //
+ //
+ public static class BuiltInWSDLEditorExtension implements WSDLEditorExtension {
+ public boolean isExtensionTypeSupported(int type) {
+ return type == OUTLINE_TREE_CONTENT_PROVIDER || type == OUTLINE_LABEL_PROVIDER || type == EDIT_PART_FACTORY || type == DETAILS_VIEWER_PROVIDER || type == MENU_ACTION_CONTRIBUTOR || type == NODE_RECONCILER || type == NODE_ASSOCIATION_PROVIDER;
+ }
+
+ public boolean isApplicable(Object object) {
+ return (object instanceof WSDLElement && !(object instanceof XSDSchemaExtensibilityElement)) || (object instanceof WSDLGroupObject);
+ }
+
+ public Object createExtensionObject(int type, WSDLEditor wsdlEditor) {
+ Object result = null;
+ switch (type) {
+ case OUTLINE_TREE_CONTENT_PROVIDER : {
+ result = new ModelAdapterContentProvider(WSDLModelAdapterFactory.getWSDLModelAdapterFactory());
+ break;
+ }
+ case OUTLINE_LABEL_PROVIDER : {
+ result = new ModelAdapterLabelProvider(WSDLModelAdapterFactory.getWSDLModelAdapterFactory());
+ break;
+ }
+ case DETAILS_VIEWER_PROVIDER : {
+ result = new WSDLDetailsViewerProvider();
+ break;
+ }
+ case MENU_ACTION_CONTRIBUTOR : {
+ result = new WSDLMenuActionContributor(wsdlEditor);
+ break;
+ }
+ case NODE_ASSOCIATION_PROVIDER : {
+ result = new WSDLNodeAssociationProvider();
+ break;
+ }
+ case EDIT_PART_FACTORY : {
+ result = new WSDLEditPartFactory();
+ break;
+ }
+ }
+ return result;
+ }
+ }
+
+ public void reloadDependencies() {
+ try {
+ getGraphViewer().getComponentViewer().setPreserveExpansionEnabled(true);
+ Definition definition = getDefinition();
+ if (definition != null) {
+ WSDLResourceUtil.reloadDirectives(definition);
+ ComponentReferenceUtil.updateBindingReferences(definition);
+ ComponentReferenceUtil.updatePortTypeReferences(definition);
+ ComponentReferenceUtil.updateMessageReferences(definition);
+ ComponentReferenceUtil.updateSchemaReferences(definition);
+ // the line below simply causes a notification in order to
+ // update our
+ // views
+ //
+ definition.setDocumentationElement(definition.getDocumentationElement());
+ }
+ }
+ finally {
+ getGraphViewer().getComponentViewer().setPreserveExpansionEnabled(false);
+ }
+ }
+
+ public void openOnSelection(String specification) {
+ EObject eObject = getDefinition().eResource().getEObject(specification);
+ if (eObject != null) {
+ getSelectionManager().setSelection(new StructuredSelection(eObject));
+ }
+ }
+
+ public INavigationLocation createEmptyNavigationLocation() {
+ return new InternalTextSelectionNavigationLocation(textEditor, false);
+ }
+
+ public INavigationLocation createNavigationLocation() {
+ return new InternalTextSelectionNavigationLocation(textEditor, true);
+ }
+
+ static class InternalTextSelectionNavigationLocation extends TextSelectionNavigationLocation {
+ public InternalTextSelectionNavigationLocation(ITextEditor part, boolean initialize) {
+ super(part, initialize);
+ }
+
+ protected IEditorPart getEditorPart() {
+ IEditorPart part = super.getEditorPart();
+ if (part instanceof WSDLEditor) {
+ part = ((WSDLEditor) part).getTextEditor();
+ }
+ return part;
+ }
+
+ public String getText() {
+ // ISSUE: how to get title?
+ // IEditorPart part = getEditorPart();
+ // if (part instanceof WSDLTextEditor) {
+ // return ((WSDLTextEditor) part).getWSDLEditor().getTitle();
+ // }
+ // else {
+ // return super.getText();
+ // }
+ return super.getText();
+ }
+ }
+
+ // Returns the element currently on the copy, cut, paste clipboard
+ public WSDLElement getClipboardContents() {
+ return clipboardElement;
+ }
+
+ public void setClipboardContents(WSDLElement element) {
+ clipboardElement = element;
+ }
+
+ /**
+ * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor#getContributorId()
+ */
+ public String getContributorId() {
+ return "org.eclipse.wst.wsdl.ui.internal.WSDLTextEditor";
+ // return getSite().getId();
+ }
+
+ /*
+ * We override this method so we can hook in our automatic Binding
+ * generation. We will generate the Binding after a save is executed (If
+ * this preference has been set to true).
+ */
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ // Display prompt message
+ boolean continueRegeneration = false;
+ if (WSDLEditorPlugin.getInstance().getPluginPreferences().getBoolean("Prompt Regenerate Binding on save")) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ GenerateBindingOnSaveDialog dialog = new GenerateBindingOnSaveDialog(shell);
+
+ int rValue = dialog.open();
+ if (rValue == SWT.YES) {
+ continueRegeneration = true;
+ }
+ else if (rValue == SWT.NO) {
+ continueRegeneration = false;
+ }
+ else if (rValue == SWT.CANCEL) {
+ return;
+ }
+ else {
+ System.out.println("\nNothing: " + rValue);
+ }
+ }
+ else {
+ continueRegeneration = WSDLEditorPlugin.getInstance().getPluginPreferences().getBoolean(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_AUTO_REGENERATE_BINDING"));
+ }
+
+ if (continueRegeneration) {
+ Iterator bindingsIt = getDefinition().getEBindings().iterator();
+ while (bindingsIt.hasNext()) {
+ Binding binding = (Binding) bindingsIt.next();
+ BindingGenerator generator = new BindingGenerator(binding.getEnclosingDefinition(), binding);
+ generator.setOverwrite(false);
+ generator.generateBinding();
+ }
+
+ // Little hack to 'redraw' connecting lines in the graph
+ // viewer
+ getDefinition().setQName(getDefinition().getQName());
+ }
+ }
+ catch (Exception e) {
+ // e.printStackTrace();
+ }
+ super.doSave(monitor);
+ }
}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlink.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlink.java
new file mode 100644
index 000000000..f07b0752f
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlink.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ */
+package org.eclipse.wst.wsdl.ui.internal;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * WSDL Hyperlink that knows how to open links from wsdl files
+ */
+public class WSDLHyperlink implements IHyperlink {
+ private IRegion fRegion;
+ private String fResource;
+ private String fSpec;
+
+ public WSDLHyperlink(IRegion region, String resource, String spec) {
+ fRegion = region;
+ fResource = resource;
+ fSpec = spec;
+ }
+
+ public IRegion getHyperlinkRegion() {
+ return fRegion;
+ }
+
+ public String getTypeLabel() {
+ return null;
+ }
+
+ public String getHyperlinkText() {
+ return null;
+ }
+
+ public void open() {
+ /*
+ * ISSUE: There are cleaner ways to find the right file based on a URI
+ * string and cleaner ways to find which editor to open for the file.
+ * See other IHyperlink and IHyperlinkDetector implementors for
+ * examples.
+ */
+ String pattern = "platform:/resource";
+ if (fResource != null && fResource.startsWith(pattern)) {
+ try {
+ Path path = new Path(fResource.substring(pattern.length()));
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+
+ IWorkbenchPage workbenchPage = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editorPart = workbenchPage.getActiveEditor();
+
+ if (editorPart.getEditorInput() instanceof IFileEditorInput && ((IFileEditorInput) editorPart.getEditorInput()).getFile().equals(file)) {
+ workbenchPage.getNavigationHistory().markLocation(editorPart);
+ }
+ else {
+ try {
+ if (fResource.endsWith("xsd")) {
+ editorPart = workbenchPage.openEditor(new FileEditorInput(file), WSDLEditorPlugin.XSD_EDITOR_ID);
+ }
+ else {
+ // Since we are already in the wsdleditor
+ editorPart = workbenchPage.openEditor(new FileEditorInput(file), editorPart.getEditorSite().getId());
+ }
+ }
+ catch (PartInitException initEx) {
+ }
+ }
+
+ /*
+ * ISSUE: This just does not look like a safe thing to do. One
+ * simple solution would be to have an interface for
+ * openOnSelection that your editors can implement. Or, java
+ * editor has something like a utility that is able to find
+ * the offset/location for a given element in a file. Once you
+ * have offset/location, you can just call setSelection.
+ */
+ Class theClass = editorPart.getClass();
+ Class[] methodArgs = {String.class};
+ Method method = theClass.getMethod("openOnSelection", methodArgs);
+ Object args[] = {fSpec};
+ method.invoke(editorPart, args);
+ workbenchPage.getNavigationHistory().markLocation(editorPart);
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlinkDetector.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlinkDetector.java
new file mode 100644
index 000000000..1e6aa0b31
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlinkDetector.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ */
+package org.eclipse.wst.wsdl.ui.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ui.internal.text.WSDLModelAdapter;
+import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Node;
+
+/**
+ * Detects hyperlinks for WSDL files
+ */
+public class WSDLHyperlinkDetector implements IHyperlinkDetector {
+ /**
+ * Gets the definition from document
+ *
+ * @param document
+ * @return Definition
+ */
+ private Definition getDefinition(IDocument document) {
+ Definition definition = null;
+ IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ if (model != null) {
+ try {
+ if (model instanceof IDOMModel) {
+ IDOMDocument domDoc = ((IDOMModel) model).getDocument();
+ if (domDoc != null) {
+ WSDLModelAdapter modelAdapter = (WSDLModelAdapter) domDoc.getAdapterFor(WSDLModelAdapter.class);
+
+ /*
+ * ISSUE: if adapter does not already exist for domDoc
+ * getAdapterFor will create one. So why is this null
+ * check/creation needed?
+ */
+ if (modelAdapter == null) {
+ modelAdapter = new WSDLModelAdapter();
+ domDoc.addAdapter(modelAdapter);
+ modelAdapter.createDefinition(domDoc.getDocumentElement());
+ }
+
+ definition = modelAdapter.getDefinition();
+ }
+ }
+ }
+ finally {
+ model.releaseFromRead();
+ }
+ }
+ return definition;
+ }
+
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
+ // for now, only capable of creating 1 hyperlink
+ List hyperlinks = new ArrayList(0);
+
+ if (region != null && textViewer != null) {
+ IDocument document = textViewer.getDocument();
+ Node node = getCurrentNode(document, region.getOffset());
+
+ if (node != null) {
+ Definition definition = getDefinition(textViewer.getDocument());
+ OpenOnSelectionHelper helper = new OpenOnSelectionHelper(definition);
+ String[] array = helper.computeSpecification(node);
+ if (array != null) {
+ IRegion nodeRegion = region;
+ if (node instanceof IndexedRegion) {
+ IndexedRegion indexed = (IndexedRegion) node;
+ nodeRegion = new Region(indexed.getStartOffset(), indexed.getLength());
+ }
+ hyperlinks.add(new WSDLHyperlink(nodeRegion, array[0], array[1]));
+ }
+ }
+ }
+ if (hyperlinks.size() == 0)
+ return null;
+ return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
+ }
+
+ /**
+ * Returns the node the cursor is currently on in the document. null if no
+ * node is selected
+ *
+ * @param offset
+ * @return Node either element, doctype, text, or null
+ */
+ private Node getCurrentNode(IDocument document, int offset) {
+ // get the current node at the offset (returns either: element,
+ // doctype, text)
+ IndexedRegion inode = null;
+ IStructuredModel sModel = null;
+ try {
+ sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ inode = sModel.getIndexedRegion(offset);
+ if (inode == null)
+ inode = sModel.getIndexedRegion(offset - 1);
+ }
+ finally {
+ if (sModel != null)
+ sModel.releaseFromRead();
+ }
+
+ if (inode instanceof Node) {
+ return (Node) inode;
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLTextEditor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLTextEditor.java
index 726b74e24..8b9ac3e42 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLTextEditor.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLTextEditor.java
@@ -36,6 +36,7 @@ import org.eclipse.wst.sse.ui.internal.view.events.NodeSelectionChangedEvent;
import org.eclipse.wst.wsdl.Binding;
import org.eclipse.wst.wsdl.internal.generator.BindingGenerator;
import org.eclipse.wst.wsdl.ui.internal.dialogs.GenerateBindingOnSaveDialog;
+import org.eclipse.wst.wsdl.ui.internal.outline.ExtensibleOutlineProvider;
import org.eclipse.wst.wsdl.ui.internal.outline.WSDLContentOutlinePage;
import org.eclipse.wst.wsdl.ui.internal.properties.section.WSDLTabbedPropertySheetPage;
import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper;
@@ -46,7 +47,9 @@ import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-
+/**
+ * @deprecated use StructuredTextEditor directly instead
+ */
public class WSDLTextEditor extends StructuredTextEditor implements INodeSelectionListener, ISelectionChangedListener, ITabbedPropertySheetPageContributor
{
protected WSDLEditor wsdlEditor;
@@ -54,6 +57,7 @@ public class WSDLTextEditor extends StructuredTextEditor implements INodeSelecti
protected WSDLSelectionManager wsdlSelectionManager;
protected InternalSelectionProvider internalSelectionProvider = new InternalSelectionProvider();
private IPropertySheetPage fPropertySheetPage;
+ private ExtensibleOutlineProvider fExtensibleOutlineProvider;
public WSDLTextEditor(WSDLEditor wsdlEditor)
{
@@ -155,8 +159,8 @@ public class WSDLTextEditor extends StructuredTextEditor implements INodeSelecti
if ((outlinePage == null) || outlinePage.getControl() == null || (outlinePage.getControl().isDisposed()))
{
outlinePage = new WSDLContentOutlinePage(wsdlEditor);
- outlinePage.setContentProvider(wsdlEditor.getExtensibleOutlineProvider());
- outlinePage.setLabelProvider(wsdlEditor.getExtensibleOutlineProvider());
+ outlinePage.setContentProvider(getExtensibleOutlineProvider());
+ outlinePage.setLabelProvider(getExtensibleOutlineProvider());
outlinePage.setModel(wsdlEditor.getDefinition()); //XMLDocument());
getViewerSelectionManager().addNodeSelectionListener(this);
@@ -316,4 +320,11 @@ public class WSDLTextEditor extends StructuredTextEditor implements INodeSelecti
public InternalSelectionProvider getInternalSelectionProvider() {
return internalSelectionProvider;
}
+
+ public ExtensibleOutlineProvider getExtensibleOutlineProvider() {
+ if (fExtensibleOutlineProvider == null) {
+ fExtensibleOutlineProvider = new ExtensibleOutlineProvider(getWSDLEditor());
+ }
+ return fExtensibleOutlineProvider;
+ }
}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java
index d9dc7430d..1ac3e788a 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java
@@ -87,7 +87,7 @@ public class WSDLActionBarContributor extends SourceEditorActionBarContributor
textEditor = null;
if (activeEditor instanceof WSDLEditor)
{
- textEditor = ((WSDLEditor) activeEditor).getWSDLTextEditor();
+ textEditor = ((WSDLEditor) activeEditor).getTextEditor();
}
updateAction(ActionFactory.UNDO.getId(), ITextEditorActionConstants.UNDO, true);
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java
index 8b4d54b28..c7e0972f0 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java
@@ -33,7 +33,6 @@ import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.WSDLElement;
import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
import org.eclipse.wst.wsdl.ui.internal.WSDLEditor;
-import org.eclipse.wst.wsdl.ui.internal.WSDLTextEditor;
import org.eclipse.wst.wsdl.ui.internal.actions.CopyGlobalAction;
import org.eclipse.wst.wsdl.ui.internal.actions.DeleteWSDLAndXSDAction;
import org.eclipse.wst.wsdl.ui.internal.actions.PasteGlobalAction;
@@ -197,7 +196,7 @@ public class WSDLGraphViewer implements ISelectionChangedListener
}
}
- if (event.getSource() != internalSelectionAdapter && event.getSource() != ((WSDLTextEditor)editor.getTextEditor()).getInternalSelectionProvider())
+ if (event.getSource() != internalSelectionAdapter && event.getSource() != (editor.getTextEditor()).getSelectionProvider())
{
boolean isEmptySelectionRequired = true;
if (event.getSelection() instanceof IStructuredSelection)
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java
index b1ca64908..03db5966b 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java
@@ -15,148 +15,163 @@ import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.ui.internal.WSDLEditor;
import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension;
import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry;
-
-
-public class ExtensibleOutlineProvider implements ITreeContentProvider, ILabelProvider
-{
- protected WSDLEditorExtension[] treeContentProviderExtensions;
- protected ITreeContentProvider[] treeContentProviders;
-
- protected WSDLEditorExtension[] labelProviderExtensions;
- protected ILabelProvider[] labelProviders;
-
- protected final static Object[] EMPTY_ARRAY = {};
-
- public ExtensibleOutlineProvider(WSDLEditor wsdlEditor)
- {
- WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry();
-
- treeContentProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.OUTLINE_TREE_CONTENT_PROVIDER);
- treeContentProviders = new ITreeContentProvider[treeContentProviderExtensions.length];
- for (int i = 0; i < treeContentProviderExtensions.length; i++)
- {
- treeContentProviders[i] = (ITreeContentProvider)treeContentProviderExtensions[i].createExtensionObject(WSDLEditorExtension.OUTLINE_TREE_CONTENT_PROVIDER, wsdlEditor);
- }
-
- labelProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER);
- labelProviders = new ILabelProvider[labelProviderExtensions.length];
- for (int i = 0; i < labelProviderExtensions.length; i++)
- {
- labelProviders[i] = (ILabelProvider)labelProviderExtensions[i].createExtensionObject(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER, wsdlEditor);
- }
- }
-
-
- protected ITreeContentProvider getApplicableTreeContentProvider(Object object)
- {
- ITreeContentProvider provider = null;
- for (int i = 0; i < treeContentProviderExtensions.length; i++)
- {
- if (treeContentProviderExtensions[i].isApplicable(object))
- {
- provider = treeContentProviders[i];
- if (provider != null)
- {
- break;
- }
- }
- }
- return provider;
- }
-
-
- protected ILabelProvider getApplicableLabelProvider(Object object)
- {
- ILabelProvider provider = null;
- for (int i = 0; i < labelProviderExtensions.length; i++)
- {
- if (labelProviderExtensions[i].isApplicable(object))
- {
- provider = labelProviders[i];
- if (provider != null)
- {
- break;
- }
- }
- }
- return provider;
- }
-
- // implements ITreeContentProvider
- //
- public Object[] getChildren(Object parentElement)
- {
- ITreeContentProvider provider = getApplicableTreeContentProvider(parentElement);
- //System.out.println("getElements " + provider);
- return provider != null ? provider.getChildren(parentElement) : EMPTY_ARRAY;
- }
-
- public Object getParent(Object element)
- {
- ITreeContentProvider provider = getApplicableTreeContentProvider(element);
- return provider != null ? provider.getParent(element) : null;
- }
-
- public boolean hasChildren(Object element)
- {
- ITreeContentProvider provider = getApplicableTreeContentProvider(element);
- return provider != null ? provider.hasChildren(element) : false;
- }
-
- public Object[] getElements(Object inputElement)
- {
- ITreeContentProvider provider = getApplicableTreeContentProvider(inputElement);
- //System.out.println("getElements " + provider);
- return provider != null ? provider.getElements(inputElement) : EMPTY_ARRAY;
- }
-
- public void dispose()
- {
- // TODO... call dispose dispose the created label and content providers
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- for (int i = 0; i < treeContentProviders.length; i++)
- {
- treeContentProviders[i].inputChanged(viewer, oldInput, newInput);
- }
- }
-
- // implements ILabelProvider
- //
- public Image getImage(Object element)
- {
- ILabelProvider provider = getApplicableLabelProvider(element);
- return provider != null ? provider.getImage(element) : null;
- }
-
- public String getText(Object element)
- {
- String result = null;
- if (element != null)
- {
- ILabelProvider provider = getApplicableLabelProvider(element);
- result = provider != null ? provider.getText(element) : (element.toString() + "noProviderForClass=" + element.getClass().getName());
- }
- return result != null ? result : "";
- }
-
- public void addListener(ILabelProviderListener listener)
- {
- }
-
- public void removeListener(ILabelProviderListener listener)
- {
- }
-
- public boolean isLabelProperty(Object element, String property)
- {
- return false;
- }
+import org.eclipse.wst.wsdl.ui.internal.text.WSDLModelAdapter;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+
+public class ExtensibleOutlineProvider implements ITreeContentProvider, ILabelProvider {
+ protected WSDLEditorExtension[] treeContentProviderExtensions;
+ protected ITreeContentProvider[] treeContentProviders;
+
+ protected WSDLEditorExtension[] labelProviderExtensions;
+ protected ILabelProvider[] labelProviders;
+
+ protected final static Object[] EMPTY_ARRAY = {};
+
+ public ExtensibleOutlineProvider(WSDLEditor wsdlEditor) {
+ WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry();
+
+ treeContentProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.OUTLINE_TREE_CONTENT_PROVIDER);
+ treeContentProviders = new ITreeContentProvider[treeContentProviderExtensions.length];
+ for (int i = 0; i < treeContentProviderExtensions.length; i++) {
+ treeContentProviders[i] = (ITreeContentProvider) treeContentProviderExtensions[i].createExtensionObject(WSDLEditorExtension.OUTLINE_TREE_CONTENT_PROVIDER, wsdlEditor);
+ }
+
+ labelProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER);
+ labelProviders = new ILabelProvider[labelProviderExtensions.length];
+ for (int i = 0; i < labelProviderExtensions.length; i++) {
+ labelProviders[i] = (ILabelProvider) labelProviderExtensions[i].createExtensionObject(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER, wsdlEditor);
+ }
+ }
+
+
+ protected ITreeContentProvider getApplicableTreeContentProvider(Object object) {
+ ITreeContentProvider provider = null;
+ for (int i = 0; i < treeContentProviderExtensions.length; i++) {
+ if (treeContentProviderExtensions[i].isApplicable(object)) {
+ provider = treeContentProviders[i];
+ if (provider != null) {
+ break;
+ }
+ }
+ }
+ return provider;
+ }
+
+
+ protected ILabelProvider getApplicableLabelProvider(Object object) {
+ ILabelProvider provider = null;
+ for (int i = 0; i < labelProviderExtensions.length; i++) {
+ if (labelProviderExtensions[i].isApplicable(object)) {
+ provider = labelProviders[i];
+ if (provider != null) {
+ break;
+ }
+ }
+ }
+ return provider;
+ }
+
+ // implements ITreeContentProvider
+ //
+ public Object[] getChildren(Object parentElement) {
+ ITreeContentProvider provider = getApplicableTreeContentProvider(parentElement);
+ // System.out.println("getElements " + provider);
+ return provider != null ? provider.getChildren(parentElement) : EMPTY_ARRAY;
+ }
+
+ public Object getParent(Object element) {
+ ITreeContentProvider provider = getApplicableTreeContentProvider(element);
+ return provider != null ? provider.getParent(element) : null;
+ }
+
+ public boolean hasChildren(Object element) {
+ ITreeContentProvider provider = getApplicableTreeContentProvider(element);
+ return provider != null ? provider.hasChildren(element) : false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ // inputElement is initially a structured model, so turn it into a
+ // definition
+ Definition definition = getDefinition(inputElement);
+ ITreeContentProvider provider = getApplicableTreeContentProvider(definition);
+ // System.out.println("getElements " + provider);
+ return provider != null ? provider.getElements(definition) : EMPTY_ARRAY;
+ }
+
+ public void dispose() {
+ // TODO... call dispose dispose the created label and content
+ // providers
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ Definition definition = getDefinition(newInput);
+ for (int i = 0; i < treeContentProviders.length; i++) {
+ treeContentProviders[i].inputChanged(viewer, oldInput, definition);
+ }
+ }
+
+ // implements ILabelProvider
+ //
+ public Image getImage(Object element) {
+ ILabelProvider provider = getApplicableLabelProvider(element);
+ return provider != null ? provider.getImage(element) : null;
+ }
+
+ public String getText(Object element) {
+ String result = null;
+ if (element != null) {
+ ILabelProvider provider = getApplicableLabelProvider(element);
+ result = provider != null ? provider.getText(element) : (element.toString() + "noProviderForClass=" + element.getClass().getName());
+ }
+ return result != null ? result : "";
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ /**
+ * Gets the definition from model
+ *
+ * @param model
+ * (of type Object but really should be IStructuredModel)
+ * @return Definition
+ */
+ private Definition getDefinition(Object model) {
+ Definition definition = null;
+
+ if (model instanceof IDOMModel) {
+ IDOMDocument domDoc = ((IDOMModel) model).getDocument();
+ if (domDoc != null) {
+ WSDLModelAdapter modelAdapter = (WSDLModelAdapter) domDoc.getAdapterFor(WSDLModelAdapter.class);
+
+ /*
+ * ISSUE: if adapter does not already exist for domDoc
+ * getAdapterFor will create one. So why is this null
+ * check/creation needed?
+ */
+ if (modelAdapter == null) {
+ modelAdapter = new WSDLModelAdapter();
+ domDoc.addAdapter(modelAdapter);
+ modelAdapter.createDefinition(domDoc.getDocumentElement());
+ }
+
+ definition = modelAdapter.getDefinition();
+ }
+ }
+ return definition;
+ }
}
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlineConfiguration.java
new file mode 100644
index 000000000..c8cbcc5b1
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlineConfiguration.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ */
+package org.eclipse.wst.wsdl.ui.internal.outline;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ui.internal.WSDLEditor;
+import org.eclipse.wst.wsdl.ui.internal.WSDLSelectionManager;
+import org.eclipse.wst.wsdl.ui.internal.actions.WSDLMenuListener;
+import org.eclipse.wst.wsdl.ui.internal.text.WSDLModelAdapter;
+import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper;
+import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class WSDLContentOutlineConfiguration extends ContentOutlineConfiguration {
+ class TreeSelectionChangeListener implements ISelectionChangedListener, IDoubleClickListener {
+ private TreeViewer fViewer = null;
+ private WSDLSelectionManager fSelectionManager = null;
+
+ public TreeSelectionChangeListener(TreeViewer viewer, WSDLSelectionManager manager) {
+ fViewer = viewer;
+ fSelectionManager = manager;
+ }
+
+ private WSDLSelectionManager getSelectionManager() {
+ if (fSelectionManager == null && getWSDLEditor() != null) {
+ fSelectionManager = getWSDLEditor().getSelectionManager();
+ }
+ return fSelectionManager;
+ }
+
+ private ISelection getWSDLSelection(ISelection selection) {
+ ISelection sel = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object o = structuredSelection.getFirstElement();
+
+ // TODO ...
+ // we need to implement a selectionManagerMapping
+ // extension point
+ // so that extensions can specify how they'd like to map
+ // view objects
+ // to selection objects
+ //
+ // if (o instanceof Element)
+ // {
+ // try
+ // {
+ // Object modelObject =
+ // WSDLEditorUtil.getInstance().findModelObjectForElement(wsdlEditor.getDefinition(),
+ // (Element)o);
+ // if (modelObject != null && !(modelObject instanceof
+ // UnknownExtensibilityElement))
+ // {
+ // o = modelObject;
+ // }
+ // }
+ // catch (Exception e)
+ // {
+ // }
+ // }
+ if (o != null)
+ sel = new StructuredSelection(o);
+ }
+ return sel;
+ }
+
+ public void doubleClick(DoubleClickEvent event) {
+ /*
+ * Selection in outline tree changed so set outline tree's
+ * selection into editor's selection and say it came from outline
+ * tree
+ */
+ if (getSelectionManager() != null) {
+ ISelection selection = getWSDLSelection(event.getSelection());
+ if (selection != null) {
+ getSelectionManager().setSelection(selection, fViewer);
+ }
+ }
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ /*
+ * Selection in outline tree changed so set outline tree's
+ * selection into editor's selection and say it came from outline
+ * tree
+ */
+ if (getSelectionManager() != null) {
+ ISelection selection = getWSDLSelection(event.getSelection());
+ if (selection != null) {
+ getSelectionManager().setSelection(selection, fViewer);
+ }
+ }
+ }
+ }
+
+ private ExtensibleOutlineProvider fOutlineProvider = null;
+ private KeyListener[] fKeyListeners = null;
+ private IMenuListener fMenuListener = null;
+ private TreeSelectionChangeListener fTreeListener = null;
+ private WSDLEditor fEditor = null;
+
+ private ExtensibleOutlineProvider getOutlineProvider() {
+ if (fOutlineProvider == null) {
+ // ISSUE: what happens if cannot get WSDL Editor? (See
+ // getWSDLEditor comment)
+ fOutlineProvider = new ExtensibleOutlineProvider(getWSDLEditor());
+ }
+ return fOutlineProvider;
+ }
+
+ public IContentProvider getContentProvider(TreeViewer viewer) {
+ return getOutlineProvider();
+ }
+
+ public IDoubleClickListener getDoubleClickListener(TreeViewer viewer) {
+ if (fTreeListener == null) {
+ if (getWSDLEditor() != null)
+ fTreeListener = new TreeSelectionChangeListener(viewer, getWSDLEditor().getSelectionManager());
+ else
+ fTreeListener = new TreeSelectionChangeListener(viewer, null);
+ }
+ return fTreeListener;
+ }
+
+ public ILabelProvider getLabelProvider(TreeViewer viewer) {
+ return getOutlineProvider();
+ }
+
+ public KeyListener[] getKeyListeners(TreeViewer viewer) {
+ if (fKeyListeners == null) {
+ final TreeViewer finalViewer = viewer;
+ KeyAdapter keyListener = new KeyAdapter() {
+ public void keyReleased(KeyEvent e) {
+ if (e.keyCode == SWT.F3 && getWSDLEditor() != null) {
+ ISelection selection = getWSDLEditor().getSelectionManager().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof EObject) {
+ OpenOnSelectionHelper helper = new OpenOnSelectionHelper(getDefinition(finalViewer));
+ helper.openEditor((EObject) object);
+ }
+ }
+ }
+ }
+ };
+ fKeyListeners = new KeyListener[]{keyListener};
+ }
+
+ return fKeyListeners;
+ }
+
+ public IMenuListener getMenuListener(TreeViewer viewer) {
+ if (fMenuListener == null) {
+ // ISSUE: what happens if cannot get WSDL Editor? (See
+ // getWSDLEditor comment)
+ if (getWSDLEditor() != null)
+ fMenuListener = new WSDLMenuListener(getWSDLEditor(), getWSDLEditor().getSelectionManager());
+ }
+ return fMenuListener;
+ }
+
+ public ISelection getSelection(TreeViewer viewer, ISelection selection) {
+ ISelection sel = selection;
+
+ if (selection instanceof IStructuredSelection) {
+ List wsdlSelections = new ArrayList();
+ for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
+ Object domNode = i.next();
+ Object wsdlNode = getWSDLNode(domNode, viewer);
+ if (wsdlNode != null) {
+ wsdlSelections.add(wsdlNode);
+ }
+ }
+
+ if (!wsdlSelections.isEmpty()) {
+ sel = new StructuredSelection(wsdlSelections);
+ }
+ }
+ return sel;
+ }
+
+ public ISelectionChangedListener getSelectionChangedListener(TreeViewer viewer) {
+ if (fTreeListener == null) {
+ if (getWSDLEditor() != null)
+ fTreeListener = new TreeSelectionChangeListener(viewer, getWSDLEditor().getSelectionManager());
+ else
+ fTreeListener = new TreeSelectionChangeListener(viewer, null);
+ }
+ return fTreeListener;
+ }
+
+ /**
+ * Gets the definition from treeviewer's input
+ *
+ * @param model
+ * (of type Object but really should be IStructuredModel)
+ * @return Definition
+ */
+ private Definition getDefinition(TreeViewer viewer) {
+ Definition definition = null;
+ Object model = null;
+ if (viewer != null)
+ model = viewer.getInput();
+
+ if (model instanceof IDOMModel) {
+ IDOMDocument domDoc = ((IDOMModel) model).getDocument();
+ if (domDoc != null) {
+ WSDLModelAdapter modelAdapter = (WSDLModelAdapter) domDoc.getAdapterFor(WSDLModelAdapter.class);
+
+ /*
+ * ISSUE: if adapter does not already exist for domDoc
+ * getAdapterFor will create one. So why is this null
+ * check/creation needed?
+ */
+ if (modelAdapter == null) {
+ modelAdapter = new WSDLModelAdapter();
+ domDoc.addAdapter(modelAdapter);
+ modelAdapter.createDefinition(domDoc.getDocumentElement());
+ }
+
+ definition = modelAdapter.getDefinition();
+ }
+ }
+ return definition;
+ }
+
+ // ISSUE: There are some cases where outline comes up before editor
+ private WSDLEditor getWSDLEditor() {
+ if (fEditor == null) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ IEditorPart editor = page.getActiveEditor();
+ if (editor instanceof WSDLEditor)
+ fEditor = (WSDLEditor) editor;
+ }
+ }
+ }
+ }
+ return fEditor;
+ }
+
+ public void unconfigure(TreeViewer viewer) {
+ super.unconfigure(viewer);
+ fEditor = null;
+ }
+
+ /**
+ * Determines WSDL node based on object (DOM node)
+ *
+ * @param object
+ * @return
+ */
+ private Object getWSDLNode(Object object, TreeViewer viewer) {
+ // get the element node
+ Element element = null;
+ if (object instanceof Node) {
+ Node node = (Node) object;
+ if (node != null) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ element = (Element) node;
+ }
+ else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ element = ((Attr) node).getOwnerElement();
+ }
+ }
+ }
+ Object o = element;
+ if (element != null) {
+ Object modelObject = WSDLEditorUtil.getInstance().findModelObjectForElement(getDefinition(viewer), element);
+ if (modelObject != null) {
+ o = modelObject;
+ }
+ }
+ return o;
+ }
+}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java
index 07d2fb669..23059ccd7 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java
@@ -31,7 +31,10 @@ import org.eclipse.wst.wsdl.ui.internal.WSDLSelectionManager;
import org.eclipse.wst.wsdl.ui.internal.actions.WSDLMenuListener;
import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper;
-
+/**
+ * @deprecated Using SSE's ConfiguratbleContentOutlinePage
+ * instead via WSDLContentOutlineCOnfiguration
+ */
public class WSDLContentOutlinePage extends ContentOutlinePage
{
protected WSDLEditor wsdlEditor;

Back to the top