diff options
Diffstat (limited to 'bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse')
327 files changed, 0 insertions, 43071 deletions
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/Logger.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/Logger.java deleted file mode 100644 index c554e6079..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/Logger.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal; - -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -/** - * Small convenience class to log messages to plugin's log file and also, if - * desired, the console. This class should only be used by classes in this - * plugin. Other plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.wsdl.ui"; //$NON-NLS-1$ - - public static final int ERROR = IStatus.ERROR; // 4 - public static final int ERROR_DEBUG = 200 + ERROR; - public static final int INFO = IStatus.INFO; // 1 - public static final int INFO_DEBUG = 200 + INFO; - - public static final int OK = IStatus.OK; // 0 - - public static final int OK_DEBUG = 200 + OK; - - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - public static final int WARNING = IStatus.WARNING; // 2 - public static final int WARNING_DEBUG = 200 + WARNING; - - /** - * Adds message to log. - * - * @param level - * severity level of the message (OK, INFO, WARNING, ERROR, - * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message - * text to add to the log - * @param exception - * exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) - return; - } - - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG : - case INFO : - severity = IStatus.INFO; - break; - case WARNING_DEBUG : - case WARNING : - severity = IStatus.WARNING; - break; - case ERROR_DEBUG : - case ERROR : - severity = IStatus.ERROR; - } - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * - * @param message - * text to print - * @param category - * category of the message, to be compared with - * /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - /** - * Determines if currently tracing a category - * - * @param category - * @return true if tracing category, false otherwise - */ - public static boolean isTracing(String category) { - if (!isDebugging()) - return false; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - return true; - } - } - } - return false; - } - - public static void log(int level, String message) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } -} 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 deleted file mode 100644 index bf9327fa8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/StructuredTextViewerConfigurationWSDL.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -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 deleted file mode 100644 index 91d66e573..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditor.java +++ /dev/null @@ -1,774 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -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.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -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; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -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; -import org.eclipse.ui.INavigationLocation; -import org.eclipse.ui.INavigationLocationProvider; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -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.contentoutline.IContentOutlinePage; -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.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage; -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.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 -// INavigationLocationProvider -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 IContentOutlinePage fContentOutlinePage; - private SourceEditorSelectionListener fSourceEditorSelectionListener; - private WSDLSelectionManagerSelectionListener fWSDLSelectionListener; - - /** - * Listener on SSE's outline page's selections that converts DOM - * selections into wsdl selections and notifies WSDL selection manager - */ - class OutlineTreeSelectionChangeListener implements ISelectionChangedListener, IDoubleClickListener { - private ISelectionProvider fProvider = null; - - public OutlineTreeSelectionChangeListener() { - super(); - } - - void connect(IContentOutlinePage provider) { - fProvider = provider; - fProvider.addSelectionChangedListener(OutlineTreeSelectionChangeListener.this); - if (provider instanceof ConfigurableContentOutlinePage) { - ((ConfigurableContentOutlinePage) provider).addDoubleClickListener(OutlineTreeSelectionChangeListener.this); - } - } - - void disconnect() { - fProvider.removeSelectionChangedListener(OutlineTreeSelectionChangeListener.this); - if (fProvider instanceof ConfigurableContentOutlinePage) { - ((ConfigurableContentOutlinePage) fProvider).removeDoubleClickListener(OutlineTreeSelectionChangeListener.this); - } - fProvider = null; - } - - 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 && getSelectionManager().enableNotify) { - ISelection selection = getWSDLSelection(event.getSelection()); - if (selection != null) { - getSelectionManager().setSelection(selection, fProvider); - } - - if(getTextEditor() != null && selection instanceof IStructuredSelection) { - int start = -1; - int length = 0; - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o != null) - o = WSDLEditorUtil.getInstance().getNodeForObject(o); - if (o instanceof IndexedRegion) { - start = ((IndexedRegion) o).getStartOffset(); - length = ((IndexedRegion) o).getEndOffset() - start; - } - if(start > -1) { - getTextEditor().selectAndReveal(start, length); - } - } - } - } - - 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 && getSelectionManager().enableNotify) { - ISelection selection = getWSDLSelection(event.getSelection()); - if (selection != null) { - getSelectionManager().setSelection(selection, fProvider); - } - } - } - } - private OutlineTreeSelectionChangeListener fOutlineTreeListener = null; - - /** - * 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 if (IContentOutlinePage.class.equals(key)) { - if (fContentOutlinePage == null || fContentOutlinePage.getControl() == null || fContentOutlinePage.getControl().isDisposed()) { - fContentOutlinePage = (IContentOutlinePage) super.getAdapter(key); - if (fContentOutlinePage != null) { - fOutlineTreeListener = new OutlineTreeSelectionChangeListener(); - fOutlineTreeListener.connect(fContentOutlinePage); - } - } - result = fContentOutlinePage; - } - 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); - } - if (fOutlineTreeListener != null) { - fOutlineTreeListener.disconnect(); - fOutlineTreeListener = null; - } - 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); - Definition definition = getDefinition(); - if (definition != null) { - getSelectionManager().setSelection(new StructuredSelection(definition)); - } else { - getSelectionManager().setSelection(new StructuredSelection()); - } - - // 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(), document); - } - } - } - 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.WSDLEditor"; - // 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/WSDLEditorPlugin.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditorPlugin.java deleted file mode 100644 index f9e5dfb6c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditorPlugin.java +++ /dev/null @@ -1,588 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal; - -import java.io.IOException; -import java.net.URL; -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Hashtable; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.ExtensibilityItemTreeProviderRegistry; -import org.eclipse.wst.wsdl.ui.internal.extension.NSKeyedExtensionRegistry; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; - -public class WSDLEditorPlugin extends AbstractUIPlugin //, IPluginHelper -{ - public static final String DEFAULT_PAGE = "org.eclipse.wst.wsdl.ui.internal.defaultpage"; - public static final String GRAPH_PAGE = "org.eclipse.wst.wsdl.ui.internal.graphpage"; - public static final String SOURCE_PAGE = "org.eclipse.wst.wsdl.ui.internal.sourcepage"; - - public final static String PLUGIN_ID = "org.eclipse.wst.wsdl.ui"; - public final static String XSD_EDITOR_ID = "org.eclipse.wst.xsd.ui.XSDEditor"; - - public final static String DEFAULT_TARGET_NAMESPACE = "http://www.example.org"; - - public static int DEPENDECIES_CHANGED_POLICY_PROMPT = 0; - public static int DEPENDECIES_CHANGED_POLICY_IGNORE = 1; - public static int DEPENDECIES_CHANGED_POLICY_RELOAD = 2; - - protected static WSDLEditorPlugin instance; - // protected XMLSchemaPackage xmlschemaPackage; -// private static MsgLogger myMsgLogger; - - private WSDLEditorExtensionRegistry wsdlEditorExtensionRegistry; - private NSKeyedExtensionRegistry extensiblityElementFilterRegistry; - private ExtensibilityItemTreeProviderRegistry treeProviderRegistry; - private NSKeyedExtensionRegistry propertyDescriptorProviderRegistry; - private NSKeyedExtensionRegistry propertySourceProviderRegistry; - private NSKeyedExtensionRegistry propertySectionDescriptorProviderRegistry; - private NSKeyedExtensionRegistry detailsViewerProviderRegistry; - //private static Hashtable grayedImageMap = new Hashtable(); - private int dependenciesChangedPolicy = DEPENDECIES_CHANGED_POLICY_RELOAD; - - - public static void logMessage(String message) - { - } - - /** - * Resources helper. - */ - - public WSDLEditorPlugin(IPluginDescriptor descriptor) - { - super(descriptor); - instance = this; - - // TODO... remove this code when we add 'dependenciesChangedPolicy' - // to an editor preferences page - try - { - String string = getWSDLString("_DEBUG_UPDATE_POLICY"); - int policy = Integer.parseInt(string); - if (policy >= 0 && policy <= DEPENDECIES_CHANGED_POLICY_RELOAD) - { - dependenciesChangedPolicy = policy; - } - } - catch (Exception e) - { - } - } - - public WSDLEditorExtensionRegistry getWSDLEditorExtensionRegistry() - { - if (wsdlEditorExtensionRegistry == null) - { - wsdlEditorExtensionRegistry = new WSDLEditorExtensionRegistry(); - new InternalEditorExtensionRegistryReader(wsdlEditorExtensionRegistry).readRegistry(); - } - return wsdlEditorExtensionRegistry; - } - - public NSKeyedExtensionRegistry getDetailsViewerProviderRegistry() - { - if (detailsViewerProviderRegistry == null) - { - detailsViewerProviderRegistry = new NSKeyedExtensionRegistry(); - new DetailsViewerProviderRegistryReader(detailsViewerProviderRegistry).readRegistry(); - } - return detailsViewerProviderRegistry; - } - - public NSKeyedExtensionRegistry getExtensiblityElementFilterRegistry() - { - if (extensiblityElementFilterRegistry == null) - { - extensiblityElementFilterRegistry = new NSKeyedExtensionRegistry(); - new ElementContentFilterExtensionRegistryReader(extensiblityElementFilterRegistry).readRegistry(); - } - return extensiblityElementFilterRegistry; - } - - public ExtensibilityItemTreeProviderRegistry getExtensibilityItemTreeProviderRegistry() - { - if (treeProviderRegistry == null) - { - treeProviderRegistry = new ExtensibilityItemTreeProviderRegistry(); - new ExtensibilityItemTreeProviderRegistryReader(treeProviderRegistry).readRegistry(); - } - return treeProviderRegistry; - } - - public NSKeyedExtensionRegistry getPropertyDescriptorProviderRegistry() - { - if (propertyDescriptorProviderRegistry == null) - { - propertyDescriptorProviderRegistry = new NSKeyedExtensionRegistry(); - new PropertyDescriptorProviderRegistryReader(propertyDescriptorProviderRegistry).readRegistry(); - } - return propertyDescriptorProviderRegistry; - } - - public NSKeyedExtensionRegistry getPropertySourceProviderRegistry() - { - if (propertySourceProviderRegistry == null) - { - propertySourceProviderRegistry = new NSKeyedExtensionRegistry(); - new PropertySourceProviderRegistryReader(propertySourceProviderRegistry).readRegistry(); - } - return propertySourceProviderRegistry; - } - - public NSKeyedExtensionRegistry getPropertySectionDescriptorProviderRegistry() - { - if (propertySectionDescriptorProviderRegistry == null) - { - propertySectionDescriptorProviderRegistry = new NSKeyedExtensionRegistry(); - new PropertySectionDescriptorProviderRegistry(propertySectionDescriptorProviderRegistry).readRegistry(); - } - return propertySectionDescriptorProviderRegistry; - } - - /** - * Get the Install URL - */ - public static URL getInstallURL() - { - return getInstance().getDescriptor().getInstallURL(); - } - - /** - * Get resource string - */ - public static String getWSDLString(String key) - { - return Platform.getResourceBundle(Platform.getBundle(PLUGIN_ID)).getString(key); - } - - /** - * Get resource string - */ - public static String getWSDLString(String key, String arg0) - { - return MessageFormat.format(getWSDLString(key), new Object [] { arg0 }); - } - - /** - * Get resource string - */ - public static String getWSDLString(String key, String arg0, String arg1) - { - return MessageFormat.format(getWSDLString(key), new Object [] { arg0, arg1 }); - } - - /** - * Return the plugin physical directory location - */ - public static IPath getPluginLocation() - { - try - { - IPath installPath = new Path(getInstallURL().toExternalForm()).removeTrailingSeparator(); - String installStr = Platform.asLocalURL(new URL(installPath.toString())).getFile(); - return new Path(installStr); - } - catch (IOException e) - { - //System.out.println("WSDLEditorPlugin.getPluginLocation() exception.." + e); - } - return null; - } - - protected Hashtable imageDescriptorCache = new Hashtable(); - - protected ImageDescriptor internalGetImageDescriptor(String key) - { - ImageDescriptor imageDescriptor = (ImageDescriptor) imageDescriptorCache.get(key); - if (imageDescriptor == null) - { - imageDescriptor = ImageDescriptor.createFromFile(WSDLEditorPlugin.class, key); - if (imageDescriptor != null) - { - imageDescriptorCache.put(key, imageDescriptor); - } - } - return imageDescriptor; - } - - public static ImageDescriptor getImageDescriptor(String key) - { - return getInstance().internalGetImageDescriptor(key); - } - - public Image getImage(String iconName) - { - ImageRegistry imageRegistry = getImageRegistry(); - - if (imageRegistry.get(iconName) != null) - { - return imageRegistry.get(iconName); - } - else - { - imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName)); - return imageRegistry.get(iconName); - } - } - - /* - public Image getImage(String key, boolean isGrayed) - { - Image image = null; - if (!isGrayed) - { - image = super.getImage(key); - } - else - { - image = (Image)grayedImageMap.get(key); - if (image == null) - { - Image colorImage = super.getImage(key); - if (colorImage != null) - { - image = new Image(Display.getCurrent(), colorImage, SWT.IMAGE_GRAY);//SWT.IMAGE_DISABLE); - grayedImageMap.put(key, image); - } - } - } - return image; - } - */ - - /** - * Get the metadata directory for this plugin - */ - public static String getMetaDataDirectory() - { - return getInstance().getStateLocation().toOSString(); - } - - /** - * Get the singleton instance. - */ - public static WSDLEditorPlugin getInstance() - { - return instance; - } - - public IWorkspace getWorkspace() - { - return ResourcesPlugin.getWorkspace(); - } - - public static Shell getShell() - { - return getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore) - */ - protected void initializeDefaultPreferences(IPreferenceStore store) - { - store.setDefault(DEFAULT_PAGE, GRAPH_PAGE); - - // WSDLPreferencePage prefs - store.setDefault(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE"), DEFAULT_TARGET_NAMESPACE); - store.setDefault(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_AUTO_REGENERATE_BINDING"), false); - store.setDefault("Prompt Regenerate Binding on save", false); // TODO: Externalize - // Do we need this preference below? Look at WSDLPreferencePage.java -// store.setDefault("Defualt Location:", "http://www.example.com"); - } - - /** - * setDefaultPage - * Set the default page to open when the editor starts. Maintains the state - * when WSAD is shutdown and restarted. - * @param page - */ - public void setDefaultPage(String page) - { - getPreferenceStore().setValue(DEFAULT_PAGE, page); - } - - public String getDefaultPage() - { - return getPreferenceStore().getString(DEFAULT_PAGE); - } - - public int getDependenciesChangedPolicy() - { - //return getPreferenceStore().getInt(DEPENDECIES_CHANGED_POLICY); - return dependenciesChangedPolicy; - } -} - -class BaseRegistryReader -{ - protected static final String PLUGIN_ID = "org.eclipse.wst.wsdl.ui"; - - /** - * read from plugin registry and parse it. - */ - public void readRegistry(String extensionPointId) - { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, extensionPointId); - - if (point != null) - { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) - { - readElement(elements[i]); - } - } - } - - protected void readElement(IConfigurationElement element) - { - } -} - -/** - * This class reads the plugin manifests and registers each internal editor extension - */ -class InternalEditorExtensionRegistryReader extends BaseRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "internalEditorExtensions"; - protected static final String TAG_NAME = "internalEditorExtension"; - protected static final String ATT_CLASS = "class"; - protected WSDLEditorExtensionRegistry registry; - - public InternalEditorExtensionRegistryReader(WSDLEditorExtensionRegistry registry) - { - this.registry = registry; - } - - /** - * read from plugin registry and parse it. - */ - public void readRegistry() - { - super.readRegistry(EXTENSION_POINT_ID); - } - - /** - * readElement() - */ - protected void readElement(IConfigurationElement element) - { - if (element.getName().equals(TAG_NAME)) - { - String className = element.getAttribute(ATT_CLASS); - if (className != null) - { - try - { - ClassLoader pluginClsLoader = element.getDeclaringExtension().getDeclaringPluginDescriptor().getPlugin().getClass().getClassLoader(); - registry.add(pluginClsLoader, className); - } - catch (Exception e) - { - } - } - } - } -} - -/** - * - */ -abstract class NSKeyedExtensionRegistryReader extends BaseRegistryReader -{ - protected static final String ATT_NAME_SPACE = "namespace"; - protected String extensionPointId; - protected String tagName; - protected String[] attributeNames; - protected NSKeyedExtensionRegistry nsKeyedExtensionRegistry; - - private NSKeyedExtensionRegistryReader(String extensionPointId, String tagName, NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - this.extensionPointId = extensionPointId; - this.tagName = tagName; - this.nsKeyedExtensionRegistry = nsKeyedExtensionRegistry; - } - - public NSKeyedExtensionRegistryReader(String extensionPointId, String tagName, String attributeName, NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - this(extensionPointId, tagName, nsKeyedExtensionRegistry); - attributeNames = new String[1]; - attributeNames[0] = attributeName; - } - - public NSKeyedExtensionRegistryReader(String extensionPointId, String tagName, String[] attributeNames, NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - this(extensionPointId, tagName, nsKeyedExtensionRegistry); - this.attributeNames = attributeNames; - } - /** - * read from plugin registry and parse it. - */ - public void readRegistry() - { - super.readRegistry(extensionPointId); - } - - /** - * readElement() - */ - protected void readElement(IConfigurationElement element) - { - if (element.getName().equals(tagName)) - { - String namespace = element.getAttribute(ATT_NAME_SPACE); - if (namespace != null) - { - ClassLoader pluginClasssLoader = element.getDeclaringExtension().getDeclaringPluginDescriptor().getPluginClassLoader(); - if (attributeNames.length == 1) - { - String className = element.getAttribute(attributeNames[0]); - if (className != null) - { - nsKeyedExtensionRegistry.put(namespace, className, pluginClasssLoader); - } - } - else - { - HashMap map = new HashMap(); - for (int i = 0; i < attributeNames.length; i++) - { - String attributeName = attributeNames[i]; - String className = element.getAttribute(attributeName); - if (className != null && className.length() > 0) - { - map.put(attributeName, className); - } - } - nsKeyedExtensionRegistry.put(namespace, map, pluginClasssLoader); - } - } - } - } -} - -/** - * This class reads the plugin manifests and registers each extensibility item tree provider - */ -class ExtensibilityItemTreeProviderRegistryReader extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "extensibilityItemTreeProviders"; - protected static final String TAG_NAME = "extensibilityItemTreeProvider"; - protected static final String[] ATT_NAMES = { "labelProviderClass", "contentProviderClass" }; - - public ExtensibilityItemTreeProviderRegistryReader(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, ATT_NAMES, nsKeyedExtensionRegistry); - } -} - -/** - * - */ -class ElementContentFilterExtensionRegistryReader extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "extensibilityElementFilter"; - protected static final String TAG_NAME = "extensibilityElementFilter"; - - public ElementContentFilterExtensionRegistryReader(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, "class", nsKeyedExtensionRegistry); - } -} - -/** - * - */ -class PropertyDescriptorProviderRegistryReader extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "propertyDescriptorProvider"; - protected static final String TAG_NAME = "propertyDescriptorProvider"; - - public PropertyDescriptorProviderRegistryReader(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, "class", nsKeyedExtensionRegistry); - } - - protected void readElement(IConfigurationElement element) - { - super.readElement(element); - } -} - -class PropertySourceProviderRegistryReader extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "propertySourceProvider"; - protected static final String TAG_NAME = "propertySourceProvider"; - - public PropertySourceProviderRegistryReader(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, "class", nsKeyedExtensionRegistry); - } - - protected void readElement(IConfigurationElement element) - { - super.readElement(element); - } -} - -class PropertySectionDescriptorProviderRegistry extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "propertySectionDescriptorProvider"; - protected static final String TAG_NAME = "propertySectionDescriptorProvider"; - - public PropertySectionDescriptorProviderRegistry(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, "class", nsKeyedExtensionRegistry); - } - - protected void readElement(IConfigurationElement element) - { - super.readElement(element); - } -} - -/** - * - */ -class DetailsViewerProviderRegistryReader extends NSKeyedExtensionRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "detailsViewerProviders"; - protected static final String TAG_NAME = "detailsViewerProvider"; - - public DetailsViewerProviderRegistryReader(NSKeyedExtensionRegistry nsKeyedExtensionRegistry) - { - super(EXTENSION_POINT_ID, TAG_NAME, "class", nsKeyedExtensionRegistry); - } - - protected void readElement(IConfigurationElement element) - { - super.readElement(element); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditorResourceChangeHandler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditorResourceChangeHandler.java deleted file mode 100644 index 9eb610bb5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLEditorResourceChangeHandler.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.wsdl.Definition; - - -public class WSDLEditorResourceChangeHandler -{ - protected WSDLEditor wsdlEditor; - protected boolean isUpdateRequired; - protected InternalResourceChangeListener resourceChangeListener; - protected InternalPartListener partListener; - - public WSDLEditorResourceChangeHandler(WSDLEditor wsdlEditor) - { - this.wsdlEditor = wsdlEditor; - resourceChangeListener = new InternalResourceChangeListener(); - partListener = new InternalPartListener(); - } - - public void attach() - { - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener); - wsdlEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(partListener); - } - - public void dispose() - { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - wsdlEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(partListener); - } - - protected Map computeDependencyMap() - { - Map map = new HashMap(); - Definition definition = wsdlEditor.getDefinition(); - ResourceSet resourceSet = definition.eResource().getResourceSet(); - for (Iterator i = resourceSet.getResources().iterator(); i.hasNext();) - { - Resource resource = (Resource)i.next(); - if (resource != definition.eResource()) - { - String uri = resource.getURI().toString(); - if (map.get(uri) == null) - { - map.put(uri, uri); - } - } - } - return map; - } - - public void performReload() - { - boolean doReload = false; - int policy = WSDLEditorPlugin.getInstance().getDependenciesChangedPolicy(); - - if (policy == WSDLEditorPlugin.DEPENDECIES_CHANGED_POLICY_PROMPT) - { - doReload = MessageDialog.openQuestion(wsdlEditor.getSite().getShell(), WSDLEditorPlugin.getWSDLString("_UI_DEPENDENCIES_CHANGED"), WSDLEditorPlugin.getWSDLString("_UI_DEPENDENCIES_CHANGED_REFRESH")); - } - else if (policy == WSDLEditorPlugin.DEPENDECIES_CHANGED_POLICY_RELOAD) - { - doReload = true; - } - - if (doReload) - { - wsdlEditor.reloadDependencies(); - } - } - - public boolean isListeningToResourceChanges() - { - int policy = WSDLEditorPlugin.getInstance().getDependenciesChangedPolicy(); - return policy == WSDLEditorPlugin.DEPENDECIES_CHANGED_POLICY_PROMPT || - policy == WSDLEditorPlugin.DEPENDECIES_CHANGED_POLICY_RELOAD; - } - - - class InternalResourceChangeListener implements IResourceChangeListener, IResourceDeltaVisitor - { - protected List list = new ArrayList(); - protected boolean isPending = false; - protected int count = 0; - - public void resourceChanged(IResourceChangeEvent event) - { - Display display = Display.getCurrent(); - - if (display != null && isListeningToResourceChanges() && !isUpdateRequired) - { - if (event.getType() == IResourceChangeEvent.POST_CHANGE) - { - IResourceDelta[] deltas = event.getDelta().getAffectedChildren(); - for (int i = 0; i < deltas.length; i++) - { - try - { - deltas[i].accept(this); - } - catch (Exception e) - { - } - } - } - if (list.size() > 0) - { - if (!isPending) - { - isPending = true; - display.timerExec(2000, new TimerEvent()); - } - } - } - } - - public boolean visit(IResourceDelta delta) throws CoreException - { - IResource resource = delta.getResource(); - if (resource.getType() == IResource.FILE) - { - if (!list.contains(resource)) - { - list.add(resource); - } - } - return true; - } - - class TimerEvent implements Runnable - { - public TimerEvent() - { - //System.out.println("NewTimerEvent(" + wsdlEditor.getDefinition().eResource().getURI() + ") " + count); - } - - public void run() - { -// for (Iterator i = list.iterator(); i.hasNext();) -// { -// IResource resource = (IResource)i.next(); -// String platformPath = URI.createPlatformResourceURI(resource.getFullPath().toString()).toString(); -// } - - Map dependencyMap = computeDependencyMap(); - - for (Iterator i = list.iterator(); i.hasNext();) - { - IResource resource = (IResource)i.next(); - String platformPath = URI.createPlatformResourceURI(resource.getFullPath().toString()).toString(); - if (dependencyMap.get(platformPath) != null) - { - isUpdateRequired = true; - if (wsdlEditor.getSite().getWorkbenchWindow().getPartService().getActivePart() == wsdlEditor) - { - isUpdateRequired = false; - performReload(); - } - } - } - - isPending = false; - list = new ArrayList(); - } - } - } - - class InternalPartListener implements IPartListener - { - public void partActivated(IWorkbenchPart part) - { - if (part == wsdlEditor) - { - if (isUpdateRequired) - { - isUpdateRequired = false; - performReload(); - } - } - } - - public void partBroughtToTop(IWorkbenchPart part) - { - } - - public void partClosed(IWorkbenchPart part) - { - } - - - public void partDeactivated(IWorkbenchPart part) - { - } - - public void partOpened(IWorkbenchPart part) - { - } - } - - -} - -/* -class DependencyVisitor -{ - public void visitImport(Import theImport) - { - if (theImport.getEDefinition() != null) - { - visitDefinition(theImport.getEDefinition()); - } - else if (theImport.getESchema() != null) - { - visitSchema(theImport.getESchema()); - } - } - - public void visitXSDSchemaDirective(XSDSchemaDirective directive) - { - XSDSchema referencedSchema = directive.getResolvedSchema(); - if (referencedSchema != null) - { - visitSchema(referencedSchema); - } - } - - public void visitDefinition(Definition definition) - { - if (definition != null) - { - for (Iterator i = definition.getEImports().iterator(); i.hasNext();) - { - visitImport((Import)i.next()); - } - Types types = definition.getETypes(); - if (types != null) - { - - for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement e = (XSDSchemaExtensibilityElement)o; - if (e.getEXSDSchema() != null) - { - visitSchema(e.getEXSDSchema()); - } - } - } - } - } - } - - public void visitSchema(XSDSchema schema) - { - for (Iterator i = schema.getContents().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaDirective) - { - visitXSDSchemaDirective((XSDSchemaDirective)o); - } - } - } -} - -class ReloadDependencyVisitor extends DependencyVisitor -{ - public void visitImport(Import theImport) - { - ComponentHandler handler = WSDLReconciler.getReconciler(theImport); - Element element = WSDLUtil.getInstance().getElementForObject(theImport); - if (element != null && handler != null) - { - handler.reconcile(wsdlEditor.getDefinition(), theImport, element); - } - } - - public void visitXSDSchemaDirective(XSDSchemaDirective directive) - { - - } -}*/
\ No newline at end of file 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 deleted file mode 100644 index 61088f511..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlink.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -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 deleted file mode 100644 index 0309b0ed3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLHyperlinkDetector.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -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(), domDoc); - } - - 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/WSDLMultiPageEditorPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLMultiPageEditorPart.java deleted file mode 100644 index 32e4c1fd8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLMultiPageEditorPart.java +++ /dev/null @@ -1,653 +0,0 @@ - -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal; - -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextInputListener; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IGotoMarker; -import org.eclipse.wst.common.ui.provisional.editors.PostMultiPageEditorSite; -import org.eclipse.wst.common.ui.provisional.editors.PostSelectionMultiPageEditorPart; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.xml.core.internal.provisional.IXMLPreferenceNames; -import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML; -import org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorMessages; - -public class WSDLMultiPageEditorPart extends PostSelectionMultiPageEditorPart implements IPropertyListener { - - /** - * - */ - public WSDLMultiPageEditorPart() { - super(); - } - - /** - * Internal part activation listener - */ - class PartListener extends ShellAdapter implements IPartListener { - private IWorkbenchPart fActivePart; - private boolean fIsHandlingActivation = false; - - private void handleActivation() { - - if (fIsHandlingActivation) - return; - - if (fActivePart == WSDLMultiPageEditorPart.this) { - fIsHandlingActivation = true; - try { - safelySanityCheckState(); - } - finally { - fIsHandlingActivation = false; - } - } - } - - /** - * @see IPartListener#partActivated(IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - fActivePart = part; - handleActivation(); - } - - /** - * @see IPartListener#partBroughtToTop(IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) { - } - - /** - * @see IPartListener#partClosed(IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - } - - /** - * @see IPartListener#partDeactivated(IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) { - fActivePart = null; - } - - /** - * @see IPartListener#partOpened(IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) { - } - - /* - * @see ShellListener#shellActivated(ShellEvent) - */ - public void shellActivated(ShellEvent e) { - handleActivation(); - } - } - - class TextInputListener implements ITextInputListener { - public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { - } - - public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { - } - } - - /** The source page index. */ - private int fSourcePageIndex; - /** The text editor. */ - private StructuredTextEditor fTextEditor; - - private PartListener partListener; - - - /* - * This method is just to make firePropertyChanged accessbible from some - * (anonomous) inner classes. - */ - protected void _firePropertyChange(int property) { - super.firePropertyChange(property); - } - - /** - * Adds the source page of the multi-page editor. - */ - protected void addSourcePage() throws PartInitException { - try { - fSourcePageIndex = addPage(fTextEditor, getEditorInput()); - setPageText(fSourcePageIndex, WSDLEditorPlugin.getWSDLString("_UI_TAB_SOURCE")); //$NON-NLS-1$ - // the update's critical, to get viewer selection manager and - // highlighting to work - fTextEditor.update(); - - firePropertyChange(PROP_TITLE); - - // Changes to the Text Viewer's document instance should also - // force an - // input refresh - fTextEditor.getTextViewer().addTextInputListener(new TextInputListener()); - } - catch (PartInitException e) { - // dispose editor - dispose(); - - // log for now, unless we find reason not to - Logger.log(Logger.INFO, e.getMessage()); - } - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.MultiPageEditorPart#createPages() - */ - protected void createPages() { - try { - // source page MUST be created before design page, now - createSourcePage(); - addSourcePage(); - setActivePage(); - - // future_TODO: add a catch block here for any exception the - // design - // page throws and convert it into a more informative message. - } - catch (PartInitException e) { - throw new RuntimeException(e); - } - } - - /** - * @see org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclipse.ui.IEditorPart) - */ - protected IEditorSite createSite(IEditorPart editor) { - IEditorSite site = null; - if (editor == fTextEditor) { - site = new PostMultiPageEditorSite(this, editor) { - /** - * @see org.eclipse.ui.part.MultiPageEditorSite#getActionBarContributor() - */ - public IEditorActionBarContributor getActionBarContributor() { - IEditorActionBarContributor contributor = super.getActionBarContributor(); -// IEditorActionBarContributor multiContributor = WSDLMultiPageEditorPart.this.getEditorSite().getActionBarContributor(); - // if (multiContributor instanceof - // XMLMultiPageEditorActionBarContributor) { - // contributor = ((XMLMultiPageEditorActionBarContributor) - // multiContributor).sourceViewerActionContributor; - // } - return contributor; - } - - public String getId() { - // sets this id so nested editor is considered xml source - // page - return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$; - } - }; - } - else { - site = super.createSite(editor); - } - return site; - } - - /** - * Creates the source page of the multi-page editor. - */ - protected void createSourcePage() throws PartInitException { - fTextEditor = createTextEditor(); - fTextEditor.setEditorPart(this); - - // Set the SourceViewerConfiguration now so the text editor won't use - // the default configuration first - // and switch to the StructuredTextViewerConfiguration later. - // DMW removed setSourceViewerConfiguration 3/26/2003 since added - // createPartControl to our text editor. - // fTextEditor.setSourceViewerConfiguration(); - fTextEditor.addPropertyListener(this); - } - - /** - * Method createTextEditor. - * - * @return StructuredTextEditor - */ - protected StructuredTextEditor createTextEditor() { - return new StructuredTextEditor(); - } - - public void dispose() { - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - window.getPartService().removePartListener(partListener); - window.getShell().removeShellListener(partListener); - - getSite().getPage().removePartListener(partListener); - if (fTextEditor != null) { - fTextEditor.removePropertyListener(this); - } - - // moved to last when added window ... seems like - // we'd be in danger of losing some data, like site, - // or something. - super.dispose(); - } - - /* - * (non-Javadoc) Saves the contents of this editor. <p> Subclasses must - * override this method to implement the open-save-close lifecycle for an - * editor. For greater details, see <code> IEditorPart </code></p> - * - * @see IEditorPart - */ - public void doSave(IProgressMonitor monitor) { - fTextEditor.doSave(monitor); - // // this is a temporary way to force validation. - // // when the validator is a workbench builder, the following lines - // can be removed - // if (fDesignViewer != null) - // fDesignViewer.saveOccurred(); - - } - - /* - * (non-Javadoc) Saves the contents of this editor to another object. <p> - * Subclasses must override this method to implement the open-save-close - * lifecycle for an editor. For greater details, see <code> IEditorPart - * </code></p> - * - * @see IEditorPart - */ - public void doSaveAs() { - fTextEditor.doSaveAs(); - // 253619 - // following used to be executed here, but is - // now called "back" from text editor (since - // mulitiple paths to the performSaveAs in StructuredTextEditor. - // doSaveAsForStructuredTextMulitPagePart(); - } - - private void editorInputIsAcceptable(IEditorInput input) throws PartInitException { - if (input instanceof IFileEditorInput) { - // verify that it can be opened - CoreException[] coreExceptionArray = new CoreException[1]; - if (fileDoesNotExist((IFileEditorInput) input, coreExceptionArray)) { - CoreException coreException = coreExceptionArray[0]; - if (coreException.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) { - // I'm assuming this is always 'does not exist' - // we'll refresh local go mimic behavior of default - // editor, where the - // troublesome file is refreshed (and will cause it to - // 'disappear' from Navigator. - try { - ((IFileEditorInput) input).getFile().refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); - } - catch (CoreException ce) { - // very unlikely - Logger.logException(ce); - } - throw new PartInitException(NLS.bind(XMLEditorMessages.Resource__does_not_exist, (new Object[]{input.getName()}))); - } - else { - throw new PartInitException(NLS.bind(XMLEditorMessages.Editor_could_not_be_open, (new Object[]{input.getName()}))); - } - } - } - else if (input instanceof IStorageEditorInput) { - InputStream contents = null; - try { - contents = ((IStorageEditorInput) input).getStorage().getContents(); - } - catch (CoreException noStorageExc) { - } - if (contents == null) { - throw new PartInitException(NLS.bind(XMLEditorMessages.Editor_could_not_be_open, (new Object[]{input.getName()}))); - } - else { - try { - contents.close(); - } - catch (IOException e) { - } - } - } - } - - // void doSaveAsForStructuredTextMulitPagePart() { - // setPageText(getActivePage(), fTextEditor.getTitle()); - // setInput(fTextEditor.getEditorInput()); - // if (fDesignViewer != null) { - // //fDesignViewer.setEditorInput(fTextEditor.getEditorInput()); - // fDesignViewer.setModel(getModel()); - // fDesignViewer.saveAsOccurred(); - // } - // // even though we've set title etc., several times already! - // // only now is all prepared for it. - // firePropertyChange(IWorkbenchPart.PROP_TITLE); - // firePropertyChange(PROP_DIRTY); - // } - /* - * (non-Javadoc) Initializes the editor part with a site and input. <p> - * Subclasses of <code> EditorPart </code> must implement this method. - * Within the implementation subclasses should verify that the input type - * is acceptable and then save the site and input. Here is sample code: - * </p><pre> if (!(input instanceof IFileEditorInput)) throw new - * PartInitException("Invalid Input: Must be IFileEditorInput"); - * setSite(site); setInput(editorInput); </pre> - */ - protected boolean fileDoesNotExist(IFileEditorInput input, Throwable[] coreException) { - boolean result = false; - InputStream inStream = null; - if ((!(input.exists())) || (!(input.getFile().exists()))) { - result = true; - } - else { - try { - inStream = input.getFile().getContents(true); - } - catch (CoreException e) { - // very likely to be file not found - result = true; - coreException[0] = e; - } - finally { - if (input != null) { - try { - if (inStream != null) { - inStream.close(); - } - } - catch (IOException e) { - - } - } - } - } - return result; - } - - public Object getAdapter(Class key) { - Object result = null; - - // DMW: I'm bullet-proofing this because - // its been reported (on 4.03 version) a null pointer sometimes - // happens here on startup, when an editor has been left - // open when workbench shutdown. - if (fTextEditor != null) { - result = fTextEditor.getAdapter(key); - } - return result; - } - - public IEditorPart getEditorPart() { - return this; - } - - protected IStructuredModel getModel() { - IStructuredModel model = null; - if (fTextEditor != null) { - model = fTextEditor.getModel(); -// IDocument doc = fTextEditor.getDocumentProvider().getDocument(getEditorInput()); -// IModelManager modelManager = ModelManagerImpl.getInstance(); -// model = modelManager.getModelForRead((IStructuredDocument) doc); - } - - return model; - } - - protected IPreferenceStore getPreferenceStore() { - return WSDLEditorPlugin.getInstance().getPreferenceStore(); - } - - public StructuredTextEditor getTextEditor() { - return fTextEditor; - } - - /* - * (non-Javadoc) Method declared on IWorkbenchPart. - */ - public String getTitle() { - String title = null; - if (getTextEditor() == null) { - if (getEditorInput() != null) { - title = getEditorInput().getName(); - } - } - else { - title = getTextEditor().getTitle(); - } - if (title == null) { - title = getPartName(); - } - return title; - } - - /* - * (non-Javadoc) Sets the cursor and selection state for this editor to - * the passage defined by the given marker. <p> Subclasses may override. - * For greater details, see <code> IEditorPart </code></p> - * - * @see IEditorPart - */ - public void gotoMarker(IMarker marker) { - // (pa) 20020217 this was null when opening an editor that was - // already open - if (fTextEditor != null) { - IGotoMarker markerGotoer = (IGotoMarker) fTextEditor.getAdapter(IGotoMarker.class); - markerGotoer.gotoMarker(marker); - } - } - - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - editorInputIsAcceptable(input); - try { - super.init(site, input); - if (partListener == null) { - partListener = new PartListener(); - } - // getSite().getPage().addPartListener(partListner); - // we want to listen for our own activation - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - window.getPartService().addPartListener(partListener); - window.getShell().addShellListener(partListener); - } - catch (Exception e) { - // log for now, unless we find reason not to - Logger.log(Logger.INFO, e.getMessage()); - } - setPartName(input.getName()); - } - - /* - * (non-Javadoc) Returns whether the "save as" operation is supported by - * this editor. <p> Subclasses must override this method to implement the - * open-save-close lifecycle for an editor. For greater details, see - * <code> IEditorPart </code></p> - * - * @see IEditorPart - */ - public boolean isSaveAsAllowed() { - return fTextEditor != null && fTextEditor.isSaveAsAllowed(); - } - - /* - * (non-Javadoc) Returns whether the contents of this editor should be - * saved when the editor is closed. <p> This method returns <code> true - * </code> if and only if the editor is dirty ( <code> isDirty </code> ). - * </p> - */ - public boolean isSaveOnCloseNeeded() { - // overriding super class since it does a lowly isDirty! - if (fTextEditor != null) - return fTextEditor.isSaveOnCloseNeeded(); - return isDirty(); - } - - /** - * Notifies this multi-page editor that the page with the given id has - * been activated. This method is called when the user selects a different - * tab. - * - * @param newPageIndex - * the index of the activated page - */ - protected void pageChange(int newPageIndex) { - super.pageChange(newPageIndex); - - saveLastActivePageIndex(newPageIndex); - } - - /** - * Posts the update code "behind" the running operation. - */ - protected void postOnDisplayQue(Runnable runnable) { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); - if (windows != null && windows.length > 0) { - Display display = windows[0].getShell().getDisplay(); - display.asyncExec(runnable); - } - else - runnable.run(); - } - - /** - * Indicates that a property has changed. - * - * @param source - * the object whose property has changed - * @param propId - * the id of the property which has changed; property ids are - * generally defined as constants on the source class - */ - public void propertyChanged(Object source, int propId) { - switch (propId) { - // had to implement input changed "listener" so that - // strucutedText could tell it containing editor that - // the input has change, when a 'resource moved' event is - // found. - case IEditorPart.PROP_INPUT : - case IEditorPart.PROP_DIRTY : { - if (source == fTextEditor) { - if (fTextEditor.getEditorInput() != getEditorInput()) { - setInput(fTextEditor.getEditorInput()); - // title should always change when input changes. - // create runnable for following post call - Runnable runnable = new Runnable() { - public void run() { - _firePropertyChange(IWorkbenchPart.PROP_TITLE); - } - }; - // Update is just to post things on the display queue - // (thread). We have to do this to get the dirty - // property to get updated after other things on the - // queue are executed. - postOnDisplayQue(runnable); - } - } - break; - } - case IWorkbenchPart.PROP_TITLE : { - // update the input if the title is changed - if (source == fTextEditor) { - if (fTextEditor.getEditorInput() != getEditorInput()) { - setInput(fTextEditor.getEditorInput()); - } - } - break; - } - default : { - // propagate changes. Is this needed? Answer: Yes. - if (source == fTextEditor) { - firePropertyChange(propId); - } - break; - } - } - - } - - protected void safelySanityCheckState() { - // If we're called before editor is created, simply ignore since we - // delegate this function to our embedded TextEditor - if (getTextEditor() == null) - return; - - getTextEditor().safelySanityCheckState(getEditorInput()); - - } - - protected void saveLastActivePageIndex(int newPageIndex) { - // save the last active page index to preference manager - getPreferenceStore().setValue(IXMLPreferenceNames.LAST_ACTIVE_PAGE, newPageIndex); - } - - /** - * Sets the currently active page. - */ - protected void setActivePage() { - // retrieve the last active page index from preference manager - int activePageIndex = getPreferenceStore().getInt(IXMLPreferenceNames.LAST_ACTIVE_PAGE); - - // We check this range since someone could hand edit the XML - // preference file to an invalid value ... which I know from - // experience :( ... if they do, we'll reset to default and continue - // rather than throw an assertion error in the setActivePage(int) - // method. - if (activePageIndex < 0 || activePageIndex >= getPageCount()) { - activePageIndex = fSourcePageIndex; - } - setActivePage(activePageIndex); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) - */ - protected void setInput(IEditorInput input) { - // If driven from the Source page, it's "model" may not be up to date - // with the input just yet. We'll rely on later notification from the - // TextViewer to set us straight - super.setInput(input); - setPartName(input.getName()); - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLSelectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLSelectionManager.java deleted file mode 100644 index 55a4d8377..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/WSDLSelectionManager.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; - -public class WSDLSelectionManager implements ISelectionProvider, ISelectionChangedListener -{ - protected List listenerList = new ArrayList(); - protected ISelection currentSelection; - protected boolean enableNotify = true; - - public void setSelection(ISelection selection, ISelectionProvider source) - { - if (enableNotify) - { - currentSelection = selection; - enableNotify = false; - try - { - SelectionChangedEvent event = new SelectionChangedEvent(source, selection); - List copyOfListenerList = new ArrayList(listenerList); - for (Iterator i = copyOfListenerList.iterator(); i.hasNext(); ) - { - ISelectionChangedListener listener = (ISelectionChangedListener)i.next(); - listener.selectionChanged(event); - } - } - finally - { - enableNotify = true; - } - } - } - - // implements ISelectionProvider - // - public void setSelection(ISelection selection) - { - setSelection(selection, this); - } - - public ISelection getSelection() - { - return currentSelection; - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.remove(listener); - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.add(listener); - } - - // implements ISelectionChangedListener - // - public void selectionChanged(SelectionChangedEvent event) - { - if (enableNotify) - { - setSelection(event.getSelection(), event.getSelectionProvider()); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddEEMenuActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddEEMenuActionContributor.java deleted file mode 100644 index a8bb5d65b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddEEMenuActionContributor.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.UnknownExtensibilityElement; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.IMenuActionContributor; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilder; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilderImpl; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper; -import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.eclipse.wst.xml.ui.internal.actions.MenuBuilder; -import org.eclipse.wst.xml.ui.internal.util.XMLCommonResources; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -/** - * TODO... there are likely several places where we can refactor code from AbstractNodeActionManager - */ -public class AddEEMenuActionContributor implements IMenuActionContributor -{ - protected MenuBuilder menuBuilder = new MenuBuilder(); - - public void contributeMenuActions(final IMenuManager menu, Node node, Object object) - { - boolean isSubmenuRequired = false; - Element element = null; - - if (object instanceof WSDLElement) - { - WSDLSwitch wsdlSwitch = new WSDLSwitch() - { - public Object caseBinding(Binding binding) - { - return Boolean.TRUE; - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - return Boolean.TRUE; - } - - public Object caseBindingInput(BindingInput bindingInput) - { - return Boolean.TRUE; - } - - public Object caseBindingOutput(BindingOutput bindingOutput) - { - return Boolean.TRUE; - } - - public Object caseBindingFault(BindingFault bindingFault) - { - return Boolean.TRUE; - } - - public Object caseDefinition(Definition definition) - { - return Boolean.TRUE; - } - - public Object casePort(Port port) - { - return Boolean.TRUE; - } - public Object caseUnknownExtensibilityElement(UnknownExtensibilityElement unknownExtensibilityElement) - { - if (getExtensibilityElementActions(unknownExtensibilityElement.getElement()).size() > 0) - { - return Boolean.TRUE; - } - else - { - return Boolean.FALSE; - } - } - }; - isSubmenuRequired = wsdlSwitch.doSwitch((WSDLElement)object) != null; - element = WSDLEditorUtil.getInstance().getElementForObject(object); - } - else if (object instanceof WSDLGroupObject) - { - WSDLGroupObject groupObject = (WSDLGroupObject)object; - - switch (groupObject.getType()) - { - case WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP : - { - isSubmenuRequired = true; - element = WSDLEditorUtil.getInstance().getElementForObject(groupObject.getDefinition()); - break; - } - } - } - - if (isSubmenuRequired) - { - MenuManager submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ADD_EXTENSIBILITY_ELEMENT")); //$NON-NLS-1$ - // here I'm attempting to add the menu item in a 'good' place in the exisiting menu - // todo add menu groups to avoid the need for this test - // -// if (menu.find("addchild") != null) -// { -// menu.insertAfter("addchild", submenu); -// } -// else -// { -// menu.add(submenu); -// } - menu.add(submenu); - if (element != null && element instanceof IDOMNode) - { - addExtensibilityElementActions(submenu, element); - } - } - } - - public void addExtensibilityElementActions(IMenuManager menu, Element element) - { - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element); - - if (ed != null) - { - addActionHelper(menu, getExtensibilityElementActions(element)); - } - } - - public List getExtensibilityElementActions(Element element) { - List modelQueryActionList = new ArrayList(); - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element); - - if (ed != null) - { - // add insert child node actions - // - int ic = ModelQuery.INCLUDE_CHILD_NODES; - int vc = ModelQuery.VALIDITY_STRICT; - - modelQuery.getInsertActions(element, ed, -1, ic, vc, modelQueryActionList); - } - - return modelQueryActionList; - } - - - protected void addActionHelper(IMenuManager menu, List modelQueryActionList) - { - List actionList = new Vector(); - - for (Iterator i = modelQueryActionList.iterator(); i.hasNext(); ) - { - ModelQueryAction action = (ModelQueryAction)i.next(); - CMNode cmnode = action.getCMNode(); - if (cmnode != null) - { - boolean isOtherNamespace = false; - CMDocument cmDocument = (CMDocument)cmnode.getProperty("CMDocument"); - if (cmDocument != null) - { - String namespaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); - isOtherNamespace = namespaceURI != null && !namespaceURI.equals(WSDLConstants.WSDL_NAMESPACE_URI); - } - - if (isOtherNamespace) - { - int cmNodeType = cmnode.getNodeType(); - if (action.getKind() == ModelQueryAction.INSERT) - { - switch (cmNodeType) - { - case CMNode.ELEMENT_DECLARATION : - { - actionList.add(new AddNodeAction((CMElementDeclaration)cmnode, action.getParent(), action.getStartIndex())); - break; - } - } - } - } - } - } - menuBuilder.populateMenu(menu, actionList, false); - } - - /** - * AddNodeAction - */ - public class AddNodeAction extends BaseNodeAction - { - protected String description; - protected String undoDescription; - protected CMNode cmnode; - protected int index; - protected Node parent; - - - public AddNodeAction(CMNode cmnode, Node parent, int index) - { - this.cmnode = cmnode; - this.parent = parent; - this.index = index; - - String text = getLabel(parent, cmnode); - setText(text); - description = text; - undoDescription = XMLCommonResources.getInstance().getString("_UI_MENU_ADD") + " " + text; - //setImageDescriptor(imageDescriptorCache.getImageDescriptor(cmnode)); - } - - public String getLabel(Node parent, CMNode cmnode) - { - String result = "?" + cmnode + "?"; - if (cmnode != null) - { - result = DOMNamespaceHelper.computeName(cmnode, parent, null); - } - return result; - } - - public Node getNode() - { - return parent; - } - - public String getUndoDescription() - { - return undoDescription; - } - - public void run() - { - beginRecording(); - - if (cmnode != null && parent != null) - { - Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document)parent : parent.getOwnerDocument(); - - DOMContentBuilder builder = new DOMContentBuilderImpl(document); - builder.setProperty(DOMContentBuilder.PROPERTY_BUILD_BLANK_TEXT_NODES, Boolean.TRUE); - builder.setBuildPolicy(DOMContentBuilder.BUILD_ONLY_REQUIRED_CONTENT); - builder.build(parent, cmnode); - insertNodesAtIndex(parent, builder.getResult(), index, true); - } - - endRecording(); - } - - public void insertNodesAtIndex(Node parent, List list, int index, boolean format) - { - NodeList nodeList = parent.getChildNodes(); - if (index == -1) - { - index = nodeList.getLength(); - } - Node refChild = (index < nodeList.getLength()) ? nodeList.item(index) : null; - - // here we consider the case where the previous node is a 'white space' Text node - // we should really do the insert before this node - // - int prevIndex = index - 1; - Node prevChild = (prevIndex < nodeList.getLength()) ? nodeList.item(prevIndex) : null; - if (isWhitespaceTextNode(prevChild)) - { - refChild = prevChild; - } - - for (Iterator i = list.iterator(); i.hasNext(); ) - { - Node newNode = (Node)i.next(); - - if (newNode.getNodeType() == Node.ATTRIBUTE_NODE) - { - Element parentElement = (Element)parent; - parentElement.setAttributeNode((Attr)newNode); - } - else - { - parent.insertBefore(newNode, refChild); - } - } - - for (Iterator i = list.iterator(); i.hasNext(); ) - { - Node newNode = (Node)i.next(); - if (format) - { - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)newNode); - } - } - //setViewerSelection(list); - } - - protected boolean isWhitespaceTextNode(Node node) - { - return (node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().trim().length() == 0); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementAction.java deleted file mode 100644 index 12a1f6b3d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementAction.java +++ /dev/null @@ -1,329 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.HashMap; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentDialog; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class AddElementAction extends BaseNodeAction { - protected Node parentNode; - protected String prefix; - protected String nodeName; - protected Element newElement; - protected Node relativeNode = null; - protected IEditorPart editorPart; - protected Definition definition; - protected Document document; - protected boolean computeTopLevelRefChild; - - protected boolean selectNewlyCreatedObject = true; // We should not be - // selecting the - // object in the - // action..... TODO - - public AddElementAction(String text, String imageDescriptorKey, Node parentNode, String nodeName) { - setText(text); - setImageDescriptor(WSDLEditorPlugin.getImageDescriptor(imageDescriptorKey)); - this.parentNode = parentNode; - this.nodeName = nodeName; - } - - public AddElementAction(String text, String imageDescriptorKey, Node parentNode, String prefix, String localName) { - setText(text); - setImageDescriptor(WSDLEditorPlugin.getImageDescriptor(imageDescriptorKey)); - this.parentNode = parentNode; - this.prefix = prefix; - this.nodeName = localName; - } - - public AddElementAction(String text, Node parentNode, String prefix, String localName) { - setText(text); - setImageDescriptor(null); - this.parentNode = parentNode; - this.prefix = prefix; - this.nodeName = localName; - } - - public AddElementAction(Node parentNode, String prefix, String localName, Node relativeNode) { - this.parentNode = parentNode; - this.prefix = prefix; - this.nodeName = localName; - this.relativeNode = relativeNode; - } - - public void setComputeTopLevelRefChild(boolean isEnabled) { - computeTopLevelRefChild = isEnabled; - } - - protected void setEditorPart(IEditorPart editorPart) { - this.editorPart = editorPart; - } - - protected boolean showDialog() { - return true; - } - - public void run() { - boolean ok = showDialog(); - if (ok) { - beginRecording(); - performAddElement(); - endRecording(); - } - } - - protected void performAddElement() { - if (parentNode != null) { - newElement = createElement(nodeName); - addAttributes(newElement); - if (relativeNode == null && computeTopLevelRefChild) { - relativeNode = computeTopLevelRefChild(newElement); - } - - if (relativeNode == null) { - parentNode.appendChild(newElement); - } - else { - parentNode.insertBefore(newElement, relativeNode); - } - // format(parentNode); - format(newElement); - // Ugly..... We should not be selecting the object in the graph - // view in the Action. - // This should be refactored out. We add this boolean check - // because WSDLSetTypeDialog.java - // uses AddImportAction.java but we should not be selecting the - // newly created import.... - if (selectNewlyCreatedObject) { - selectObjectForNewElement(); - } - } - } - - // Ugly..... We should not be selecting the object in the graph view in - // the Action. - // This should be refactored out. We add this boolean check because - // WSDLSetTypeDialog.java - // uses AddImportAction.java but we should not be selecting the newly - // created import.... - // We should call this method before calling run() - public void selectObjectForNewElement(boolean select) { - selectNewlyCreatedObject = select; - } - - public Node getNode() { - if (parentNode != null) { - return parentNode; - } - else { - return document; - } - } - - - public String getUndoDescription() { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD"); - } - - - protected Element createElement(String nodeName) { - Document document = parentNode.getOwnerDocument(); - - Element element = (prefix != null && prefix.length() > 0) ? document.createElement(prefix + ":" + nodeName) : document.createElement(nodeName); - - return element; - } - - protected void addAttributes(Element newElement) { - } - - - protected void format(Node parentNode) { - if (parentNode instanceof IDOMNode) { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode) parentNode); - - } - } - - protected Element getDefinitionElement(Element parentElement) { - Element definitionElement = null; - - for (Node node = parentElement.getOwnerDocument().getFirstChild(); node != null; node = node.getNextSibling()) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - if (WSDLEditorUtil.getInstance().getWSDLType(element) == WSDLConstants.DEFINITION) { - definitionElement = element; - break; - } - } - } - return definitionElement; - } - - public Element getNewElement() { - return newElement; - } - - public void setDefinition(Definition definition) { - this.definition = definition; - } - - public void selectObjectForNewElement() { - if (editorPart == null) { - editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } - if (editorPart != null && definition != null) { - Object object = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, newElement); - if (object != null) { - ISelectionProvider selectionProvider = (ISelectionProvider) editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) { - selectionProvider.setSelection(new StructuredSelection(object)); - } - } - } - } - - public void selectObject(WSDLElement object) { - if (editorPart == null) { - editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } - if (editorPart != null && definition != null) { - if (object != null) { - ISelectionProvider selectionProvider = (ISelectionProvider) editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) { - selectionProvider.setSelection(new StructuredSelection(object)); - } - } - } - } - - public String showDialogHelper(String title, String defaultName, List usedNames) { - String result = defaultName; - NewComponentDialog dialog = new NewComponentDialog(WSDLEditorPlugin.getShell(), title, defaultName, usedNames); - int rc = dialog.createAndOpen(); - if (rc == IDialogConstants.OK_ID) { - result = dialog.getName(); - } - else { - result = null; - } - return result; - } - - protected Node computeTopLevelRefChild(Node nodeToAdd) { - Node result = null; - int a = getPrecedence(nodeToAdd); - - for (Node node = parentNode.getFirstChild(); node != null; node = node.getNextSibling()) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - int b = getPrecedence(node); - if (b > a) { - result = node; - break; - } - } - } - return result; - } - - protected void createDefinitionStub() { - if (document != null) { - // Create the Definitions element with proper namespace - Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences(); - String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - if (charSet == null || charSet.trim().equals("")) { - charSet = "UTF-8"; - } - document.appendChild(document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + charSet + "\"")); - Element root = document.createElement("wsdl:definitions"); - document.appendChild(root); - - // Add various namespace attributes here. - root.setAttribute("xmlns:soap", "http://schemas.xmlsoap.org/wsdl/soap/"); - root.setAttribute("xmlns:tns", getDefaultNamespace()); - root.setAttribute("xmlns:wsdl", "http://schemas.xmlsoap.org/wsdl/"); - root.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); - root.setAttribute("name", getFileName()); - root.setAttribute("targetNamespace", getDefaultNamespace()); - - definition.setElement(root); - parentNode = root; - prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - } - } - - private String getDefaultNamespace() { - String namespace = WSDLEditorPlugin.getInstance().getPreferenceStore().getString(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE")); - if (!namespace.endsWith("/")) { - namespace = namespace.concat("/"); - } - - namespace += getFileName() + "/"; - - return namespace; - } - - private String getFileName() { - String fileLocation = definition.getLocation(); - IPath filePath = new Path(fileLocation); - return filePath.removeFileExtension().lastSegment().toString(); - } - - protected static HashMap precedenceMap = createPrecedenceMap(); - - protected static int getPrecedence(Node node) { - int result = 2; - String localName = node.getLocalName(); - if (localName != null) { - Integer integer = (Integer) precedenceMap.get(localName); - if (integer != null) { - result = integer.intValue(); - } - } - return result; - } - - protected static HashMap createPrecedenceMap() { - HashMap hashMap = new HashMap(); - hashMap.put(WSDLConstants.DOCUMENTATION_ELEMENT_TAG, new Integer(1)); - hashMap.put(WSDLConstants.IMPORT_ELEMENT_TAG, new Integer(3)); - hashMap.put(WSDLConstants.TYPES_ELEMENT_TAG, new Integer(4)); - hashMap.put(WSDLConstants.MESSAGE_ELEMENT_TAG, new Integer(5)); - hashMap.put(WSDLConstants.PORT_TYPE_ELEMENT_TAG, new Integer(6)); - hashMap.put(WSDLConstants.BINDING_ELEMENT_TAG, new Integer(7)); - hashMap.put(WSDLConstants.SERVICE_ELEMENT_TAG, new Integer(8)); - return hashMap; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementDeclarationAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementDeclarationAction.java deleted file mode 100644 index 8bdee2f46..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddElementDeclarationAction.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - -public class AddElementDeclarationAction extends Action -{ - protected Definition definition; - protected String namespace; - protected String prefix; - - public AddElementDeclarationAction(Definition definition, String namespace, String suggestedPrefix) - { - this.definition = definition; - this.namespace = namespace; - this.prefix = suggestedPrefix; - } - - public void run() - { - String existingPrefix = definition.getPrefix(namespace); - if (existingPrefix != null) - { - prefix = existingPrefix; - } - else - { - prefix = NameUtil.buildUniquePrefix(definition, prefix); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - if (definitionElement != null) - { - definitionElement.setAttribute("xmlns:" + prefix, namespace); - } - } - } - - public String getPrefix() - { - return prefix; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddImportAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddImportAction.java deleted file mode 100644 index fc85352be..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddImportAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.ui.IEditorPart; -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.util.WSDLEditorUtil; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class AddImportAction extends AddElementAction -{ - protected String namespace; - protected String location; - protected String elementDeclarationNamespacePrefix; - - public AddImportAction(IEditorPart part, Definition definition, Node parentNode, String prefix) - { - this(part, definition, parentNode, prefix, null, null); - } - - public AddImportAction(IEditorPart part, Definition definition, Node parentNode, String prefix, String namespace, String location) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_IMPORT"), "icons/import_obj.gif", parentNode, prefix, "import"); - setDefinition(definition); - setComputeTopLevelRefChild(true); - this.namespace = namespace; - this.location = location; - setEditorPart(part); - - if (part instanceof WSDLEditor) { - document = ((WSDLEditor) part).getXMLDocument(); - } - } - - protected Element createElement(String nodeName) - { - if (elementDeclarationNamespacePrefix != null && namespace != null) - { - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - if (definitionElement != null) - { - definitionElement.setAttribute("xmlns:" + elementDeclarationNamespacePrefix, namespace); - } - } - return super.createElement(nodeName); - } - - public void setElementDeclarationNamespacePrefix(String nsPrefix) - { - this.elementDeclarationNamespacePrefix = nsPrefix; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("namespace", namespace != null ? namespace : ""); - newElement.setAttribute("location", location != null ? location : ""); - } - - public void performAddElement() { - if (parentNode == null || (document != null && document.getChildNodes().getLength() == 0)) { - createDefinitionStub(); - } - - super.performAddElement(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddMessageUIAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddMessageUIAction.java deleted file mode 100644 index 7e39d867d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddMessageUIAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentDialog; -import org.eclipse.wst.wsdl.util.WSDLConstants; - - - -public final class AddMessageUIAction extends WSDLElementUIAction -{ - private Definition definition; - private String name; - - public AddMessageUIAction - (Definition definition, - String name, - boolean createPart) - { - super - (new AddMessageCommand(definition,name,createPart), - WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD"), - WSDLConstants.MESSAGE_ELEMENT_TAG, - WSDLEditorPlugin.getImageDescriptor("icons/message_obj.gif")); - - this.definition = definition; - this.name = name; - } - - protected boolean showDialog() - { - name = NameUtil.buildUniqueMessageName(definition, name); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_MESSAGE"), name); - return name != null; - } - - protected String showDialogHelper(String title, String defaultName) - { - String result = defaultName; - NewComponentDialog dialog = new NewComponentDialog(WSDLEditorPlugin.getShell(), title, defaultName); - int rc = dialog.createAndOpen(); - if (rc == IDialogConstants.OK_ID) - { - result = dialog.getName(); - } - else - { - result = null; - } - return result; - } - - protected void preRun() - { - ((AddMessageCommand)super.modelAction).setLocalName(name); - } - - protected WSDLElement getOwner() - { - return definition; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddNamespaceDeclarationsAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddNamespaceDeclarationsAction.java deleted file mode 100644 index b352e34c3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddNamespaceDeclarationsAction.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Hashtable; - -import org.eclipse.jface.action.Action; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; - -public class AddNamespaceDeclarationsAction extends Action -{ - protected Element ownerElement; - protected String[] namespaceNames; - protected String[] preferredPrefixes; - - public AddNamespaceDeclarationsAction(Element ownerElement, String[] namespaceNames, String[] preferredPrefixes) - { - this.ownerElement = ownerElement; - this.namespaceNames = namespaceNames; - this.preferredPrefixes = preferredPrefixes; - } - - public AddNamespaceDeclarationsAction(Element ownerElement, String namespaceName, String preferredPrefix) - { - this.ownerElement = ownerElement; - namespaceNames = new String[1]; - namespaceNames[0] = namespaceName; - - preferredPrefixes = new String[1]; - preferredPrefixes[0] = preferredPrefix; - } - - public void run() - { - if (ownerElement != null) - { - NamedNodeMap map = ownerElement.getAttributes(); - Hashtable table = new Hashtable(); - Hashtable prefixTable = new Hashtable(); - - int mapLength = map.getLength(); - for (int i = 0; i < mapLength; i++) - { - Attr attribute = (Attr) map.item(i); - String attributeName = attribute.getName(); - if (attributeName.startsWith("xmlns:")) - { - table.put(attribute.getValue(), Boolean.TRUE); - prefixTable.put(attributeName.substring(6), Boolean.TRUE); - } - else if (attributeName.equals("xmlns")) - { - table.put(attribute.getValue(), Boolean.TRUE); - prefixTable.put("", Boolean.TRUE); - } - } - - for (int i = 0; i < namespaceNames.length; i++) - { - String namespace = namespaceNames[i]; - if (table.get(namespace) == null) - { - String prefix = (i < preferredPrefixes.length) ? preferredPrefixes[i] : "p0"; - if (prefixTable.get(prefix) != null) - { - prefix = computeUniquePrefix("p", prefixTable); - } - - String attributeName = prefix.length() > 0 ? "xmlns:" + prefix : "xmlns"; - ownerElement.setAttribute(attributeName, namespace); - } - } - } - } - - protected String computeUniquePrefix(String base, Hashtable table) - { - int i = 0; - String prefix = base; - while (true) - { - if (table.get(prefix) == null) - { - break; - } - else - { - prefix = base + i; - i++; - } - } - return prefix; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddWSISchemaImportAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddWSISchemaImportAction.java deleted file mode 100644 index 182c6a42e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/AddWSISchemaImportAction.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -public class AddWSISchemaImportAction extends BaseNodeAction -{ - protected Definition definition; - protected Element definitionElement; - protected String namespace; - protected String location; - protected String elementDeclarationNamespacePrefix; - - public AddWSISchemaImportAction(Definition definition, String namespace, String location) - { - this.definition = definition; - this.namespace = namespace; - this.location = location; - definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - } - - public Node getNode() - { - return definitionElement; - } - - public String getUndoDescription() - { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_IMPORT"); - } - - protected Element getOrCreateTypesElement() - { - Element typesElement = null; - if (definition.getTypes() == null) - { - if (definitionElement != null) - { - AddElementAction addTypesAction = new AddElementAction("", "icons/xsd_obj.gif", definitionElement, definitionElement.getPrefix(), "types"); - addTypesAction.setComputeTopLevelRefChild(true); - addTypesAction.run(); - typesElement = addTypesAction.getNewElement(); - format(typesElement); - } - } - else - { - typesElement = WSDLEditorUtil.getInstance().getElementForObject(definition.getTypes()); - } - return typesElement; - } - - protected Element getImportHolderElement(Element typesElement) { - Element importHolderElement = null; - NodeList nodeList = typesElement.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) - { - Node node = nodeList.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element) node; - if ("schema".equals(element.getLocalName()) && element.getAttribute("targetNamespace") == null) - { - importHolderElement = element; - break; - } - } - } - - return importHolderElement; - } - - public Element getOrCreateImportHolderElement(Element typesElement) - { - Element importHolderElement = getImportHolderElement(typesElement); - if (importHolderElement == null) - { - AddElementAction addImportHolderAction = new AddElementAction("", "icons/xsd_obj.gif", typesElement, "xsd", "schema") - { - protected void addAttributes(Element newElement) - { - newElement.setAttribute("xmlns:xsd", WSDLConstants.XSD_NAMESPACE_URI); - } - }; - addImportHolderAction.run(); - importHolderElement = addImportHolderAction.getNewElement(); - format(importHolderElement); - } - return importHolderElement; - } - - // We don't want to add the import if it's already there - protected boolean importNotAlreadyExists() { - boolean notExists = true; - - if (definition.getTypes() != null) { - Element typesElement = WSDLEditorUtil.getInstance().getElementForObject(definition.getTypes()); - Element schemaElement = getImportHolderElement(typesElement); - - if (schemaElement != null) { - // Collect children - Node node = schemaElement.getFirstChild(); - java.util.Vector schemaChildren = new java.util.Vector(); - if (node != null) { - Node child = node; - - if (!(child instanceof org.eclipse.wst.xml.core.internal.document.TextImpl)) { - schemaChildren.addElement(child); - } - - while (child.getNextSibling() != null) { - child = child.getNextSibling(); - if (!(child instanceof org.eclipse.wst.xml.core.internal.document.TextImpl)) { - schemaChildren.addElement(child); - } - } - - for (int index = 0; index < schemaChildren.size(); index++) { - Element schemaChild = (Element) schemaChildren.elementAt(index); - String schemaLocation = schemaChild.getAttribute("schemaLocation"); - String schemaNamespace = schemaChild.getAttribute("namespace"); - - if (schemaLocation != null && namespace != null && - schemaLocation.equals(location) && schemaNamespace.equals(namespace)) { - notExists = false; - break; - } - } - } - } - } - - return notExists; - } - - public void run() - { - if (definitionElement != null && importNotAlreadyExists()) - { - beginRecording(); - performAddElement(); - endRecording(); - } - } - public void performAddElement() - { - try - { - Element typesElement = getOrCreateTypesElement(); - Element importHolderElement = getOrCreateImportHolderElement(typesElement); - - AddElementAction addImportAction = new AddElementAction("", "icons/xsd_obj.gif", importHolderElement, importHolderElement.getPrefix(), "import") - { - protected void addAttributes(Element newElement) - { - newElement.setAttribute("namespace", namespace); - newElement.setAttribute("schemaLocation", location); - } - }; - addImportAction.run(); - Element newElement = addImportAction.getNewElement(); - format(newElement); - } - catch (Exception e) - { - } - } - - public void setElementDeclarationNamespacePrefix(String nsPrefix) - { - this.elementDeclarationNamespacePrefix = nsPrefix; - } - - protected static void format(Node parentNode) - { - if (parentNode instanceof IDOMNode) - { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)parentNode); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/BaseNodeAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/BaseNodeAction.java deleted file mode 100644 index e7fc8def9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/BaseNodeAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Node; - -public abstract class BaseNodeAction extends Action -{ - public abstract Node getNode(); - public abstract String getUndoDescription(); - - public void beginRecording() - { - Node node = getNode(); - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().beginRecording(this, getUndoDescription()); - } - } - - public void endRecording() - { - Node node = getNode(); - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().endRecording(this); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyGlobalAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyGlobalAction.java deleted file mode 100644 index ba45fdeb7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyGlobalAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class CopyGlobalAction extends Action { - private IEditorPart editor; - private WSDLElement selection; - - public CopyGlobalAction(WSDLElement selection, IEditorPart editor) { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_COPY")); - this.selection = selection; - this.editor = editor; - setEnabledState(); - } - - public void run() { - if (editor instanceof WSDLEditor) { - ((WSDLEditor) editor).setClipboardContents(selection); - - ((WSDLEditor) editor).getSelectionManager().setSelection(new StructuredSelection(selection)); - } - } - - public void setSelection(WSDLElement newSelection) { - selection = newSelection; - setEnabledState(); - } - - protected void setEnabledState() { - if (selection instanceof Operation) { - setEnabled(true); - } - else { - setEnabled(false); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyWSDLElementAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyWSDLElementAction.java deleted file mode 100644 index 3f3d8affb..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CopyWSDLElementAction.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOperationCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.WSDLElementCommand; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Node; - -/* - * Class which copies a WSDLElement and it's 'children' elements. - * For example, a copy command on a Operation will result in a copy - * of the operation and it's input/output/faults, and it's message - * and parts. - */ -public class CopyWSDLElementAction extends WSDLDragAction { - WSDLElement element, parent; - Node parentNode; - WSDLElementCommand wsdlElementCommand; - EditPartViewer editPartViewer; - - /* - * element = The WSDLElement being copied - * parent = The Parent of the 'new' WSDLElement - * parentNode = ElementImpl (for undo) - */ - public CopyWSDLElementAction(EditPartViewer editPartViewer, WSDLElement element, WSDLElement parent, Node parentNode) { - setText("Copy WSDLElement"); // Do not Translate This - this.element = element; - this.parent = parent; - this.parentNode = parentNode; - this.editPartViewer = editPartViewer; - } - - public boolean canExecute() { - if (element instanceof Operation){ - if(parent instanceof PortType) { - PortType pt = (PortType) parent; - Operation op = (Operation) element; - wsdlElementCommand = new AddOperationCommand(pt, op, NameUtil.buildUniqueOperationName(pt, op.getName()), true); - } - } - /* - else if (element instanceof MessageReference) { - - } - else if (element instanceof Input) { - - } - else if (element instanceof Output) { - - } - else if (element instanceof Fault) { - - } - else if (element instanceof Message) { - - } - */ - - if (wsdlElementCommand != null) { - return true; - } - else { - return false; - } - } - - public void run() { - if (wsdlElementCommand == null) { - if (canExecute()) { - runCommand(); - } - } - else { - runCommand(); - } - } - - private void runCommand() { - this.beginRecording(); - wsdlElementCommand.run(); - selectWSDLElement(wsdlElementCommand.getWSDLElement()); - this.endRecording(); - } - - private void selectWSDLElement(WSDLElement element) { - // Select the newly created element - // Expand all the associated elements 'below' the given element - Map editPartMap = editPartViewer.getEditPartRegistry(); - WSDLTreeNodeEditPart wsdlEditPart = (WSDLTreeNodeEditPart) editPartMap.get(element); - if (wsdlEditPart != null) { - editPartViewer.select(wsdlEditPart); - expandEditParts(element, true); - } - } - - private void expandEditParts(Object element, boolean expandChildren) { - if (element != null) { - Map editPartMap = editPartViewer.getEditPartRegistry(); - WSDLTreeNodeEditPart wsdlEditPart = (WSDLTreeNodeEditPart) editPartMap.get(element); - wsdlEditPart.setExpanded(true); - - if (expandChildren) { - Iterator iterator = WSDLEditorUtil.getModelGraphViewChildren(element).iterator(); - - while (iterator.hasNext()) { - expandEditParts(iterator.next(), expandChildren); - } - } - } - } - - // Inherited classes from BaseNodeAction - public Node getNode() { - return parentNode; - } - - public String getUndoDescription() { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_COPY"); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CreateDocActionDelegate.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CreateDocActionDelegate.java deleted file mode 100644 index 4e4b9c538..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/CreateDocActionDelegate.java +++ /dev/null @@ -1,324 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.io.File; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.ActionDelegate; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.WizardNewFolderMainPage; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -public class CreateDocActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ - protected IFile iFile; - protected IEditorPart editorPart; - - protected final static String WSDLEDITOR_DOCGEN_PLUGIN_ID = "org.eclipse.wst.wsdl.ui.internal.docgen"; //$NON-NLS-1$ - protected final static String VALIDATE_WSDL_PLUGIN_ID = "org.eclipse.wst.validate.wsdl"; //$NON-NLS-1$ - - protected IWorkspaceRoot workspaceRoot = null; - - public CreateDocActionDelegate() - { - } - - public void setFile(IFile iFile) - { - this.iFile = iFile; - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - - public void run(IAction action) - { -// TODO: Uncomment when validation is checked into corona -// ISharedService validateSharedService = ExtensionPlugin.getSharedService("ValidateWSDLSharedService"); //$NON-NLS-1$ -// System.out.println(validateSharedService); -// if (validateSharedService != null) -// { -// try -// { -// Boolean rc = (Boolean) validateSharedService.run(iFile); -// if (rc.booleanValue()) -// { - NewWSDLDocFolderWizard wiz = new NewWSDLDocFolderWizard(); - NewWSDLDocDialog dlg = new NewWSDLDocDialog(WSDLEditorPlugin.getShell(), wiz); - dlg.open(); -// } -// else -// { -// MessageDialog.openError(Display.getCurrent().getActiveShell(), WSDLEditorPlugin.getWSDLString("_UI_ERROR_INVALID_WSDL"), //$NON-NLS-1$ -// WSDLEditorPlugin.getWSDLString("_UI_ERROR_INVALID_WSDL_DESC")); //$NON-NLS-1$ -// } -// } -// catch (Exception e) -// { -// } -// } -// else -// { -// MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", //$NON-NLS-1$ -// "Cannot find validator"); //$NON-NLS-1$ -// } - } - - class GenHTMLOperation extends WorkspaceModifyOperation - { - IFile iFile; - String outputLocation; - public GenHTMLOperation(IFile iFile) - { - super(); - this.iFile = iFile; - } - - public void setOutputLocation(String outputLocation) - { - this.outputLocation = outputLocation; - } - - protected void execute(IProgressMonitor monitor) throws CoreException - { - /* - monitor.beginTask(WSDLEditorPlugin.getWSDLString("_UI_LABEL_CREATING_HTML_FILES"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - WSDLDoc doc = new WSDLDoc(new WSDLDocFileWriter()); - - try - { - Plugin plugin = Platform.getPlugin("org.eclipse.wst.wsdl.ui.internal.docgen"); //$NON-NLS-1$ - IPath installPath = new Path(plugin.getDescriptor().getInstallURL().toExternalForm()).removeTrailingSeparator(); - String installStr = Platform.asLocalURL(new URL(installPath.toString())).getFile(); - Path docgenPath = new Path(installStr); - - doc.setTemplateLocation(docgenPath.toOSString() + "template" + File.separator); //$NON-NLS-1$ - doc.setOptions(iFile.getRawLocation().removeLastSegments(1).toOSString(), outputLocation, ""); - - doc.addFile(iFile.getName()); - doc.doBuildStep(); - } - catch (Exception e) - { - // e.printStackTrace(); - } - finally - { - monitor.done(); - } - */ - } - } - - class WSDLDocNewFolderMainPage extends WizardNewFolderMainPage - { - public WSDLDocNewFolderMainPage(String pageName) - { - super(pageName, new StructuredSelection(iFile)); - setDescription(WSDLEditorPlugin.getWSDLString("_UI_LABEL_CREATE_FOLDER_FOR_DOCS")); //$NON-NLS-1$ - } - } - - class NewWSDLDocFolderWizard extends Wizard - { - IFolder folder; - - private WSDLDocNewFolderMainPage newFolderPage; - - public NewWSDLDocFolderWizard() - { - super(); - setNeedsProgressMonitor(true); - } - - public boolean performFinish() - { - folder = newFolderPage.createNewFolder(); - if (folder == null) - { - MessageDialog.openError(WSDLEditorPlugin.getShell(), WSDLEditorPlugin.getWSDLString("_UI_ERROR_ERROR"), //$NON-NLS-1$ - WSDLEditorPlugin.getWSDLString("_UI_ERROR_FOLDER_NOT_CREATED")); //$NON-NLS-1$ - return false; - } - - GenHTMLOperation op = new GenHTMLOperation(iFile); - op.setOutputLocation(folder.getLocation().toOSString()); - - try - { - op.execute(new NullProgressMonitor()); - - // refresh folder and open index.html in web browser - folder.refreshLocal(IResource.DEPTH_INFINITE, null); - String indexHtmlFile = folder.getLocation().toOSString() + File.separator + "index.html"; //$NON-NLS-1$ - IFile indexHtmlIFile = getWorkspaceFileFromLocalLocation(indexHtmlFile); - if (indexHtmlIFile != null && indexHtmlIFile.exists()) - { - revealSelection(new StructuredSelection(indexHtmlIFile)); - - openEditor(indexHtmlIFile, "org.eclipse.webbrowser"); //$NON-NLS-1$ - } - else - { - MessageDialog.openError(Display.getCurrent().getActiveShell(), WSDLEditorPlugin.getWSDLString("_UI_ERROR_ERROR"), //$NON-NLS-1$ - WSDLEditorPlugin.getWSDLString("_UI_ERROR_CREATING_HTML_FILES")); //$NON-NLS-1$ - } - } - catch (CoreException ce) - { - // ce.printStackTrace(); - } - catch (Exception e) - { - // e.printStackTrace(); - } - return true; - } - - protected void revealSelection(final ISelection selection) - { - if (selection != null) - { - IWorkbench workbench = WSDLEditorPlugin.getInstance().getWorkbench(); - final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - final IWorkbenchPart focusPart = workbenchWindow.getActivePage().getActivePart(); - if (focusPart instanceof ISetSelectionTarget) - { - Display.getCurrent().asyncExec - (new Runnable() - { - public void run() - { - ((ISetSelectionTarget)focusPart).selectReveal(selection); - } - }); - } - } - } - - protected void openEditor(final IFile iFile, final String editorId) - { - if (iFile != null) - { - IWorkbench workbench = WSDLEditorPlugin.getInstance().getWorkbench(); - final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - - Display.getDefault().asyncExec - (new Runnable() - { - public void run() - { - try - { - workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), editorId); - } - catch (PartInitException ex) - { -// B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception encountered when attempting to open file: " + iFile + "\n\n" + ex); - } - } - }); - } - } - - protected IFile getWorkspaceFileFromLocalLocation(String fileName) - { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - if (workspace != null) - { - IFile iFile = workspace.getRoot().getFileForLocation(new Path(fileName)); - if (iFile != null) - { - return iFile; - } - } - return null; - } - - public void addPages() - { - newFolderPage = new WSDLDocNewFolderMainPage(WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_FOLDER")); //$NON-NLS-1$ - addPage(newFolderPage); - } - - public boolean canFinish() - { - if (newFolderPage.isPageComplete()) - { - return true; - } - return false; - } - - public IFolder getFolder() - { - return folder; - } - } - - class NewWSDLDocDialog extends WizardDialog - { - public NewWSDLDocDialog(Shell parentShell, IWizard newWizard) - { - super(parentShell, newWizard); - } - } - - public void setActiveEditor(IAction action, IEditorPart targetEditor) - { - editorPart = targetEditor; - iFile = null; - if (editorPart != null) - { - IEditorInput input = targetEditor.getEditorInput(); - if (input instanceof IFileEditorInput) - { - iFile = ((IFileEditorInput) input).getFile(); - } - } - } - - public void selectionChanged(IAction action, ISelection selection) - { - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteAction.java deleted file mode 100644 index b9b0612d8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteAction.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class DeleteAction extends BaseNodeAction { - protected List list; - protected String deleteString = WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE") + " "; //$NON-NLS-1$ -// private Object object; -// private Node node; - - public DeleteAction(Object object, Node node) { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE")); //$NON-NLS-1$ - list = new Vector(); - list.add(object); - } - - public DeleteAction(List deleteList) { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE")); //$NON-NLS-1$ - list = deleteList; - } - - private Vector getReferencedMessages(Operation operation) { - Vector messages = new Vector(); - messages.addAll(getMessages(operation.getEFaults())); - - if (operation.getEInput() != null && operation.getEInput().getEMessage() != null) - messages.addElement(operation.getEInput().getEMessage()); - if (operation.getEOutput() != null && operation.getEOutput().getEMessage() != null) - messages.addElement(operation.getEOutput().getEMessage()); - - return messages; - } - - public void run() { - // We want to delete Operations first. So we need to sort the list - List sortedList = new ArrayList(list.size()); - Iterator listIterator = list.iterator(); - - while (listIterator.hasNext()) { - Object unsortedObject = listIterator.next(); - if (unsortedObject instanceof Operation) { - sortedList.add(0, unsortedObject); - } - else { - sortedList.add(unsortedObject); - } - } - - Node recordingNode = null; - if (sortedList.size() > 1) { - recordingNode = getElement(sortedList.get(0)); - beginRecording(recordingNode, WSDLEditorPlugin.getWSDLString("_UI_ACTION_MULTIPLE_DELETE")); - } - - Iterator iterator = sortedList.iterator(); - while (iterator.hasNext()) { - Object object = iterator.next(); - - if (object instanceof Operation) { - deleteOperation((Operation) object); - } - else if (object instanceof Part) { - deletePart((Part) object); - } - else { - DeleteNodeAction deleteNodeAction = new DeleteNodeAction(getElement(object)); - deleteNodeAction.run(); - } - } - - if (recordingNode != null) { - endRecording(recordingNode); - } - } - - private Vector getMessages(List faults) { - Vector v = new Vector(); - Iterator it = faults.iterator(); - - while (it.hasNext()) { - Fault fault = (Fault) it.next(); - if (fault.getEMessage() != null) { - v.addElement(fault.getEMessage()); - } - } - - return v; - } - - private Vector getParts(Vector messages) { - Vector parts = new Vector(); - Iterator it = messages.iterator(); - - while (it.hasNext()) { - Message message = (Message) it.next(); - - if (message.getEParts() != null) { - parts.addAll(message.getEParts()); - } - } - - return parts; - } - - public Node getNode() - { - return list.size() > 0 ? (Node) getElement(list.get(0)) : null; - } - - public String getUndoDescription() - { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE"); //$NON-NLS-1$ - } - - private void deleteOperation(Operation operation) { - DeleteOperationDialog dialog = new DeleteOperationDialog(WSDLEditorPlugin.getShell(), operation.getName()); - int returnCode = dialog.createAndOpen(); - - if (returnCode == IDialogConstants.OK_ID) { - if (dialog.deleteMessagesAndParts()) { - // Get all associated messages - Vector messages = getReferencedMessages(operation); - - // Determine which Messages are referenced from 'outside' this operation - Vector referencedMessages = new Vector(); - if (operation.getEnclosingDefinition().getEPortTypes() != null) { - Iterator portTypeIterator = operation.getEnclosingDefinition().getEPortTypes().iterator(); - Vector operations = new Vector(); - - while (portTypeIterator.hasNext()) { - PortType portType = (PortType) portTypeIterator.next(); - - if (portType.getEOperations() != null) { - Iterator operationIterator = portType.getEOperations().iterator(); - while (operationIterator.hasNext()) { - Operation nextOperation = (Operation) operationIterator.next(); - if (!nextOperation.equals(operation)) - operations.add(nextOperation); - } - } - } - - for (int index = 0; index < operations.size(); index++) { - referencedMessages.addAll(getReferencedMessages((Operation) operations.elementAt(index))); - } - - // Filter which Messages need to be deleted - for (int index = 0; index < messages.size(); index++) { - int foundIndex = referencedMessages.indexOf(messages.elementAt(index)); - - if (foundIndex != -1) { - // Message is referenced elsewhere. Do not delete - messages.remove(index); - } - } - } - - // Get all associated parts - Vector parts = getParts(messages); - - // Remove our list of Messages and Parts - PortType portType = (PortType) operation.eContainer(); - Node recordingNode = portType.getEnclosingDefinition().getElement(); - beginRecording(recordingNode, deleteString + WSDLEditorPlugin.getWSDLString("_UI_LABEL_OPERATION")); - - for (int index = 0; index < messages.size(); index++) { - Message message = (Message) messages.elementAt(index); - Definition definition = (Definition) message.eContainer(); - definition.getEMessages().remove(message); - } - - for (int index = 0; index < parts.size(); index++) { - Part part = (Part) parts.elementAt(index); - Message message = (Message) part.eContainer(); - message.getEParts().remove(part); - } - - // Delete the Operation - portType.getEOperations().remove(operation); - - endRecording(recordingNode); - } - else { - // Only delete the Operation - PortType portType = (PortType) operation.eContainer(); - Node recordingNode = portType.getElement(); - - beginRecording(recordingNode, deleteString + WSDLEditorPlugin.getWSDLString("_UI_LABEL_OPERATION")); // Translate this!!! - portType.getEOperations().remove(operation); - endRecording(recordingNode); - } - } - } - - private void deletePart(Part part) { - Message message = (Message) part.eContainer(); - if (message != null) { - beginRecording(message.getElement(), deleteString + WSDLEditorPlugin.getWSDLString("_UI_LABEL_PART")); - message.getEParts().remove(part); - endRecording(message.getElement()); - } - } - - private Element getElement(Object object) { - Element element = null; - if (object instanceof WSDLElement) { - element = ((WSDLElement) object).getElement(); - } - else if (object instanceof XSDSchema) { - element = ((XSDSchema) object).getElement(); - } - - return element; - } - - /* - * The following method should be used to begin recording changes. - * This should eventually replace BaseNodeAction.beginRecording() - * when all deletes are model driven. - */ - private void beginRecording(Node node, String undoDescription) - { - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().beginRecording(this, undoDescription); - } - } - - /* - * The following method should be used to begin recording changes. - * This should eventually replace BaseNodeAction.beginRecording() - * when all deletes are model driven. - */ - public void endRecording(Node node) - { - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().endRecording(this); - } - } - - private class DeleteOperationDialog extends Dialog implements SelectionListener{ - private Button checkButton = null; - private boolean deleteMessagesAndParts = true; - private String operationName; - - public DeleteOperationDialog(Shell shell, String name) { - super(shell); - operationName = name; - } - - protected Control createDialogArea(Composite parent) - { - Composite dialogArea = (Composite)super.createDialogArea(parent); - - Composite composite = new Composite(dialogArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.verticalSpacing = 0; - - composite.setLayout(layout); - - GridData gdFill= new GridData(); - gdFill.horizontalAlignment= GridData.FILL; - gdFill.grabExcessHorizontalSpace= true; - gdFill.verticalAlignment= GridData.FILL; - gdFill.grabExcessVerticalSpace= true; - composite.setLayoutData(gdFill); - - Label label = new Label(composite, SWT.NONE); - label.setText(operationName); -// label.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_OPERATION") + " " + operationName); - GridData labelData = new GridData(); - labelData.horizontalSpan = 2; - - label.setLayoutData(labelData); - - Label emptyLabel = new Label(composite, SWT.NONE); - GridData emptyData = new GridData(); - emptyData.horizontalSpan = 2; - emptyLabel.setLayoutData(emptyData); - - checkButton = new Button(composite, SWT.CHECK); - checkButton.setSelection(deleteMessagesAndParts); - checkButton.addSelectionListener(this); - Label nameLabel = new Label(composite, SWT.NONE); - nameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_DELETE_ASSOCIATED_MSG_AND_PARTS")); - - return dialogArea; - } - - public boolean deleteMessagesAndParts() { - return deleteMessagesAndParts; - } - - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - if (e.widget == checkButton) { - if (checkButton.getSelection()) { - deleteMessagesAndParts = true; - } - else { - deleteMessagesAndParts = false; - } - } - } - - public int createAndOpen() { - create(); - getShell().setText(WSDLEditorPlugin.getWSDLString("_UI_DELETE_OPERATION_TITLE")); - setBlockOnOpen(true); - return open(); - } - - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteInterfaceAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteInterfaceAction.java deleted file mode 100644 index 176428702..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteInterfaceAction.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.List; - -public interface DeleteInterfaceAction { - - public void setDeleteList(List list); - - public void run(); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteNodeAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteNodeAction.java deleted file mode 100644 index f4e29319c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteNodeAction.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.w3c.dom.Attr; -import org.w3c.dom.Node; - - -public class DeleteNodeAction extends BaseNodeAction -{ - protected List list; - - public DeleteNodeAction(Node node) - { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE")); //$NON-NLS-1$ - list = new Vector(); - list.add(node); - } - - public DeleteNodeAction(List nodeList) - { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE")); //$NON-NLS-1$ - list = new Vector(); - Iterator it = nodeList.iterator(); - while (it.hasNext()) { - list.add(it.next()); - } - } - - public void run() - { - beginRecording(); - - for (Iterator i = list.iterator(); i.hasNext(); ) - { - Node node = (Node)i.next(); - if (node.getNodeType() == Node.ATTRIBUTE_NODE) - { - Attr attr = (Attr)node; - attr.getOwnerElement().removeAttributeNode(attr); - } - else - { - Node parent = node.getParentNode(); - if (parent != null) - { - Node previousSibling = node.getPreviousSibling(); - if (previousSibling != null && isWhitespaceTextNode(previousSibling)) - { - parent.removeChild(previousSibling); - } - parent.removeChild(node); - } - } - } - - endRecording(); - } - - protected boolean isWhitespaceTextNode(Node node) - { - return (node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().trim().length() == 0); - } - - public Node getNode() - { - return list.size() > 0 ? (Node)list.get(0) : null; - } - - public String getUndoDescription() - { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE"); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteWSDLAndXSDAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteWSDLAndXSDAction.java deleted file mode 100644 index 731b0aae7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/DeleteWSDLAndXSDAction.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -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; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Node; - - -/** - * This class handles delete with the WSDL Editor's graph view. the object for - * deletion could be a WSDL 'object' or an XSD 'object'. We need to make this - * distinction because we have two different Delete classes. One to handle - * WSDL and another to handle XSD. - */ -public class DeleteWSDLAndXSDAction extends BaseNodeAction { - List list; - Node recordingNode; - WSDLEditor wsdlEditor; - - public DeleteWSDLAndXSDAction(List deleteList, Node recordingNode, WSDLEditor wsdlEditor) { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE")); - list = deleteList; - this.recordingNode = recordingNode; - this.wsdlEditor = wsdlEditor; - } - - public void run() { - Iterator it = list.iterator(); - List wsdlDeleteList = new ArrayList(); - List xsdDeleteList = new ArrayList(); - - while (it.hasNext()) { - Object object = it.next(); - - if (object instanceof WSDLElement || object instanceof XSDSchema) { - wsdlDeleteList.add(object); - } - else { - xsdDeleteList.add(object); - } - } - - Object newSelection = null; - Object topLevelObject = null; - if (wsdlDeleteList.size() > 0 || xsdDeleteList.size() > 0) - { - try - { - beginRecording(); - - - // Delete WSDL objects - if (wsdlDeleteList.size() > 0) { - Object wsdlObject = wsdlDeleteList.get(0); - if (wsdlObject instanceof WSDLElement) { - newSelection = ((WSDLElement) wsdlObject).eContainer(); - topLevelObject = getTopLevelWSDLObject((WSDLElement) wsdlObject); - } - - DeleteAction wsdlDelete = new DeleteAction(wsdlDeleteList); - wsdlDelete.run(); - } - - // Delete XSD objects - if (xsdDeleteList.size() > 0) { - Object xsdObject = xsdDeleteList.get(0); - if (xsdObject instanceof XSDConcreteComponent) { - newSelection = ((XSDConcreteComponent) xsdObject).getContainer(); - topLevelObject = getTopLevelXSDObject((XSDConcreteComponent) xsdObject); - } - - DeleteInterfaceAction xsdDelete = (DeleteInterfaceAction) getXSDDelete(); - xsdDelete.setDeleteList(xsdDeleteList); - xsdDelete.run(); - // Hack to force a refresh of all components of the Graph View. This is needed - // for the case where we delete a XSD Element (View input == Definition). The XSD - // Element EditPart visual would not be removed from the view. - wsdlEditor.getDefinition().setQName(wsdlEditor.getDefinition().getQName()); - } - } - finally - { - endRecording(); - } - // Make our selection after our Deletions - ISelectionProvider selectionProvider = (ISelectionProvider)wsdlEditor.getSelectionManager(); - if (selectionProvider != null) - { - if (newSelection instanceof XSDParticle) - { - newSelection = ((XSDParticle) newSelection).getContainer(); - } - - if (newSelection == null) { - newSelection = getNewSelection(); - } - if (newSelection != null) { - // We have a newSelection, but it may also be deleted by the user. In this case, select the top level object - if (list.contains(newSelection) && topLevelObject != null) { - newSelection = topLevelObject; - } - - selectionProvider.setSelection(new StructuredSelection(newSelection)); - } - } - } - } - - public Node getNode() - { - return recordingNode; - } - - public String getUndoDescription() - { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_DELETE"); //$NON-NLS-1$ - } - - private Object getXSDDelete() { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - WSDLEditorExtension[] extensions = registry.getRegisteredExtensions(WSDLEditorExtension.MENU_ACTION_CONTRIBUTOR); - Object xsdDelete = null; - - for (int i = 0; i < extensions.length; i++) - { -// xsdDelete = extensions[i].createExtensionObject(WSDLEditorExtension.XSD_DELETE_ACTION, wsdlEditor); - xsdDelete = extensions[i].createExtensionObject(WSDLEditorExtension.XSD_DELETE_ACTION, null); - if (xsdDelete != null) { - break; - } - } - - return xsdDelete; - } - - private Object getNewSelection() { - // Hack using wsdleditor.... This situation occurs when we delete the Schema from the Types group.... We - // usually get the container of the object being deleted... however, in this situation, the container would - // be null because the object being deleted is a Schema...... - Object selection; - try { - selection = wsdlEditor.getGraphViewer().getComponentViewer().getInput(); - if (selection == null) { - selection = wsdlEditor.getDefinition(); - } - } - catch (Exception e) { - selection = wsdlEditor.getDefinition(); - } - - return selection; - } - - private WSDLElement getTopLevelWSDLObject(WSDLElement element) { - WSDLElement topObject = (WSDLElement) element.eContainer(); - - while (topObject != null && !(topObject instanceof Definition)) { - topObject = (WSDLElement) topObject.eContainer(); - } - - return topObject; - } - - private XSDConcreteComponent getTopLevelXSDObject(XSDConcreteComponent component) { - XSDConcreteComponent topObject = component.getContainer(); - - while (topObject != null && !(topObject instanceof XSDSchema)) { - topObject = (XSDConcreteComponent) topObject.eContainer(); - } - - return topObject; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/EditNamespacesAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/EditNamespacesAction.java deleted file mode 100644 index d84926fe8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/EditNamespacesAction.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.nsedit.EditNamespacesDialog; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -import org.w3c.dom.Element; - - -public class EditNamespacesAction extends Action -{ - protected Definition definition; - - public EditNamespacesAction(Definition definition) - { - setText(WSDLEditorPlugin.getWSDLString("_UI_EDIT_NAMESPACES")); - this.definition = definition; - } - - public void run() - { - DOMNamespaceInfoManager namespaceInfoManager = new DOMNamespaceInfoManager(); - Element element = WSDLEditorUtil.getInstance().getElementForObject(definition); - if (element != null) - { - List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element); -// List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList); - - // here we store a copy of the old info for each NamespaceInfo - // this info will be used in createPrefixMapping() to figure out how to update the document - // in response to these changes - for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) - { - NamespaceInfo info = (NamespaceInfo) i.next(); - NamespaceInfo oldCopy = new NamespaceInfo(info); - info.setProperty("oldCopy", oldCopy); - } - - IPath path = new Path(definition.getDocumentBaseURI()); - EditNamespacesDialog dialog = new EditNamespacesDialog(WSDLEditorPlugin.getShell(), path, WSDLEditorPlugin.getWSDLString("_UI_EDIT_NAMESPACES_DIALOG_TITLE"), definition.getTargetNamespace(), namespaceInfoList); - int rc = dialog.createAndOpen(); - if (rc == IDialogConstants.OK_ID) - { - element.setAttribute("targetNamespace", dialog.getTargetNamespace()); - - List newInfoList = dialog.getNamespaceInfoList(); - namespaceInfoManager.removeNamespaceInfo(element); - namespaceInfoManager.addNamespaceInfo(element, newInfoList, false); - -/* - // see if we need to rename any prefixes - Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList); - if (prefixMapping.size() > 0) - { - //manager.getModel().aboutToChangeModel(); - ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(element, prefixMapping); - replacePrefixAction.run(); - //manager.getModel().changedModel(); - } -*/ - } - } - } - - protected Map createPrefixMapping(List oldList, List newList) - { - Map map = new Hashtable(); - - Hashtable oldURIToPrefixTable = new Hashtable(); - for (Iterator i = oldList.iterator(); i.hasNext();) - { - NamespaceInfo oldInfo = (NamespaceInfo) i.next(); - oldURIToPrefixTable.put(oldInfo.uri, oldInfo); - } - - for (Iterator i = newList.iterator(); i.hasNext();) - { - NamespaceInfo newInfo = (NamespaceInfo) i.next(); - NamespaceInfo oldInfo = (NamespaceInfo) oldURIToPrefixTable.get(newInfo.uri != null ? newInfo.uri : ""); - - // if oldInfo is non null ... there's a matching URI in the old set - // we can use its prefix to detemine out mapping - // - // if oldInfo is null ... we use the 'oldCopy' we stashed away - // assuming that the user changed the URI and the prefix - if (oldInfo == null) - { - oldInfo = (NamespaceInfo) newInfo.getProperty("oldCopy"); - } - - if (oldInfo != null) - { - String newPrefix = newInfo.prefix != null ? newInfo.prefix : ""; - String oldPrefix = oldInfo.prefix != null ? oldInfo.prefix : ""; - if (!oldPrefix.equals(newPrefix)) - { - map.put(oldPrefix, newPrefix); - } - } - } - return map; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ExtensibleMenuActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ExtensibleMenuActionContributor.java deleted file mode 100644 index 7020db630..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ExtensibleMenuActionContributor.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.IMenuActionContributor; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; -import org.w3c.dom.Node; - - -public class ExtensibleMenuActionContributor implements IMenuActionContributor -{ - protected WSDLEditor wsdlEditor; - protected IMenuActionContributor[] menuActionContributors; - - public ExtensibleMenuActionContributor(WSDLEditor wsdlEditor) - { - this.wsdlEditor = wsdlEditor; - - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - - WSDLEditorExtension[] extensions = registry.getRegisteredExtensions(WSDLEditorExtension.MENU_ACTION_CONTRIBUTOR); - menuActionContributors = new IMenuActionContributor[extensions.length]; - - for (int i = 0; i < menuActionContributors.length; i++) - { - menuActionContributors[i] = (IMenuActionContributor)extensions[i].createExtensionObject(WSDLEditorExtension.MENU_ACTION_CONTRIBUTOR, wsdlEditor); - } - } - - public void contributeMenuActions(IMenuManager manager, Node node, Object object) - { - for (int i = 0; i < menuActionContributors.length; i++) - { - if (menuActionContributors[i] != null) - { - menuActionContributors[i].contributeMenuActions(manager, node, object); - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/IDesignViewerActionBarContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/IDesignViewerActionBarContributor.java deleted file mode 100644 index 428695cd6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/IDesignViewerActionBarContributor.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.ui.IActionBars; -import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor; - -public interface IDesignViewerActionBarContributor extends ISourceViewerActionBarContributor { - public void initViewerSpecificContributions(IActionBars bars); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/PasteGlobalAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/PasteGlobalAction.java deleted file mode 100644 index ef249c57d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/PasteGlobalAction.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.w3c.dom.Node; - -public class PasteGlobalAction extends Action { - private IEditorPart editor; - private WSDLElement selection; - private Node selectionNode; - - public PasteGlobalAction(WSDLElement selection, IEditorPart editor) { - setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_PASTE")); // Translate This - this.selection = selection; - this.editor = editor; - selectionNode = selection.getElement(); - setEnabledState(); - } - - public void run() { - if (editor instanceof WSDLEditor) { - WSDLEditor wsdlEditor = (WSDLEditor) editor; - CopyWSDLElementAction copyAction = new CopyWSDLElementAction(wsdlEditor.getGraphViewer().getComponentViewer(), wsdlEditor.getClipboardContents(), selection, selectionNode); - copyAction.run(); - } - } - - public void setSelection(WSDLElement newSelection) { - selection = newSelection; - setEnabledState(); - } - - protected void setEnabledState() { - WSDLElement parentElement = null; - if ((parentElement = showPasteAction((WSDLElement) selection, editor)) != null) { - selection = parentElement; - setEnabled(true); - } - else { - setEnabled(false); - } - } - - private WSDLElement showPasteAction(WSDLElement element, IEditorPart ePart) { - WSDLElement parentElement = null; - - if (ePart instanceof WSDLEditor) { - WSDLElement clipboardElement = ((WSDLEditor) ePart).getClipboardContents(); - - if (element instanceof PortType) { - if (clipboardElement instanceof Operation) { - parentElement = element; - } - } - if (element instanceof Operation) { - if (clipboardElement instanceof Operation) { - parentElement = (WSDLElement) ((Operation) element).eContainer(); - } - } - } - - return parentElement; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ReloadDependenciesActionDelegate.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ReloadDependenciesActionDelegate.java deleted file mode 100644 index 6a04631c6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/ReloadDependenciesActionDelegate.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionDelegate; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; - -public class ReloadDependenciesActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ - private WSDLEditor wsdlEditor; - - public void setActiveEditor(IAction action, IEditorPart targetEditor) - { - wsdlEditor = (targetEditor instanceof WSDLEditor) ? (WSDLEditor)targetEditor : null; - } - - public void run(IAction action) - { - if (wsdlEditor != null) - { - try - { - wsdlEditor.reloadDependencies(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/RenameAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/RenameAction.java deleted file mode 100644 index f6826e871..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/RenameAction.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -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.visitor.BindingRenamer; -import org.eclipse.wst.wsdl.ui.internal.visitor.MessageRenamer; -import org.eclipse.wst.wsdl.ui.internal.visitor.PortTypeRenamer; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -//import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class RenameAction //extends BaseNodeAction implements Runnable -{ - protected Object modelObject; - protected String newName; - protected Node node; - - public RenameAction(Object modelObject, String newName) - { - this.modelObject = modelObject; - this.newName = newName; - this.node = WSDLEditorUtil.getInstance().getNodeForObject(modelObject); - } - - /* - public Node getNode() - { - return node; - } - */ - - /* - public String getUndoDescription() - { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_RENAME"); //$NON-NLS-1$ - } - */ - - public void run() - { - if (modelObject instanceof Operation) - { - renameOperationHelper((Operation)modelObject); - } - else if (modelObject instanceof Input || - modelObject instanceof Output || - modelObject instanceof Fault) - { - renameIOFHelper((WSDLElement)modelObject); - } - else - { - renameModelObjectHelper(modelObject, newName); - } - } - - protected void renameModelObjectHelper(Object modelObject, String theNewName) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(modelObject); - if (element != null) - { - element.setAttribute("name", theNewName); - } - - if (modelObject instanceof Message) - { - MessageRenamer renamer = new MessageRenamer((Message)modelObject, theNewName); - renamer.visitBindings(); - } - else if (modelObject instanceof PortType) - { - PortTypeRenamer renamer = new PortTypeRenamer((PortType)modelObject, theNewName); - renamer.visitBindings(); - } - else if (modelObject instanceof Binding) - { - BindingRenamer renamer = new BindingRenamer((Binding)modelObject, theNewName); - renamer.visitServices(); - } - } - - protected void renameOperationHelper(Operation operation) - { - renameModelObjectHelper(operation, newName); - } - - - protected void renameIOFHelper(WSDLElement object) - { - Definition definition = object.getEnclosingDefinition(); - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - - List list = null; - - if (object instanceof Input) - { - list = util.getBindingInputs((Input)object); - } - else if (object instanceof Output) - { - list = util.getBindingOutputs((Output)object); - } - else // fault - { - list = util.getBindingFaults((Fault)object); - } - - if (list != null) - { - for (Iterator i = list.iterator(); i.hasNext(); ) - { - Object bindingObject = i.next(); - renameModelObjectHelper(bindingObject, newName); - } - } - - renameModelObjectHelper(object, newName); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetExistingComponentAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetExistingComponentAction.java deleted file mode 100644 index 3ff35e49e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetExistingComponentAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.dialogs.InvokeSetDialog; -import org.w3c.dom.Node; - - - -public class SetExistingComponentAction extends AddElementAction -{ - Object input; - protected IEditorPart editorPart; - protected String kind; - - public SetExistingComponentAction( - String text, - Node parentNode, - String prefix, - String localName, - Object input) - { - super(text, parentNode, prefix, localName); - this.input = input; - } - - public void setEditor(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - - public void setReferenceKind(String kind) - { - this.kind = kind; - } - - protected void performAddElement() - { - InvokeSetDialog dialog = new InvokeSetDialog(); - if (input instanceof Part) - { - dialog.setReferenceKind(kind); - } - dialog.run(input, editorPart); - - // We shouldn't know about the editor in this class - WSDLEditor editor = (WSDLEditor) editorPart; - editor.getSelectionManager().setSelection(new StructuredSelection(input)); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetNewComponentAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetNewComponentAction.java deleted file mode 100644 index f775e431a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SetNewComponentAction.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants; -import org.eclipse.wst.wsdl.internal.generator.BindingGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDElementDeclarationCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDTypeDefinitionCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.WSDLElementCommand; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.CreateWSDLElementHelper; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentDialog; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/* - * TODO: Need to clean up this class.... We probably don't use quite a few of these - * methods/instance variables. - */ -public class SetNewComponentAction extends AddElementAction -{ - Object input; - protected IEditorPart editorPart; - protected String kind; - private String typeKind = "complex"; // TODO: Refactor code to handle this better - - public SetNewComponentAction( - String text, - Node parentNode, - String prefix, - String localName, - Object input) - { - super(text, parentNode, prefix, localName); - this.input = input; - } - - public void setEditor(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - - public void setReferenceKind(String kind) - { - this.kind = kind; - } - - public void setTypeKind(String typeKind) - { - this.typeKind = typeKind; - } - - // TODO: Clean up next methods below!!! - private WSDLElementCommand command; - private String newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_COMPONENT"); - - protected void performAddElement() - { - Shell shell = Display.getCurrent().getActiveShell(); - String defaultName = getDefaultName(); - NewComponentDialog dialog = new NewComponentDialog(shell, newDialogTitle, defaultName, getUsedNames()); - - int dialogCode = dialog.createAndOpen(); - - if (dialogCode == Window.OK) { - if (input instanceof Port) { - Definition definition = ((Port) input).getEnclosingDefinition(); - String newName = dialog.getName(); - - // TODO: We should be smarter in choosing some default options/settings for generating a new Binding -// BindingGenerator bindingGenerator = new BindingGenerator(definition); -// bindingGenerator.setName(newName); -// bindingGenerator.setProtocol("SOAP"); -// bindingGenerator.generate(); - BindingGenerator bindingGenerator = new BindingGenerator(definition, null, SOAPConstants.SOAP_NAMESPACE_URI); - bindingGenerator.setName(newName); - bindingGenerator.generateBinding(); - - String itemPrefix = definition.getPrefix(definition.getTargetNamespace()); - if (itemPrefix == null) - { - itemPrefix = ""; - } - org.w3c.dom.Element wsdlElement = WSDLEditorUtil.getInstance().getElementForObject((WSDLElement) input); - wsdlElement.setAttribute("binding", itemPrefix.length() == 0 ? newName : itemPrefix + ":" + newName); - - } - else if (input instanceof Binding) { - Definition definition = ((Binding) input).getEnclosingDefinition(); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - - String newName = dialog.getName(); - String prefix = definitionElement.getPrefix(); - // Use AddMessageAction in WSDLMenuActionContributor - AddElementAction addPortTypeAction = new AddElementAction("", "icons/message_obj.gif", definitionElement, prefix, "portType"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - addPortTypeAction.setComputeTopLevelRefChild(true); - addPortTypeAction.run(); - org.w3c.dom.Element newMessage = addPortTypeAction.getNewElement(); - newMessage.setAttribute("name", newName); //$NON-NLS-1$ - // need to get the prefix for the item - // could get list of updated messages and then select but currently we only have the local name - String itemPrefix = definition.getPrefix(definition.getTargetNamespace()); - if (itemPrefix == null) - { - itemPrefix = ""; //$NON-NLS-1$ - } - String portTypeValue = itemPrefix.length() == 0 ? newName : itemPrefix + ":" + newName; //$NON-NLS-1$ //$NON-NLS-2$ - - // Set the component - if (input != null && portTypeValue != null) { - org.w3c.dom.Element wsdlElement = WSDLEditorUtil.getInstance().getElementForObject((WSDLElement) input); - wsdlElement.setAttribute("type", portTypeValue); - } - } - else if (input instanceof Input || input instanceof Output || input instanceof Fault) { - Definition definition = ((MessageReference) input).getEnclosingDefinition(); - String newName = dialog.getName(); - - AddMessageCommand action = new AddMessageCommand(definition, newName); - action.run(); - Message message = (Message) action.getWSDLElement(); - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.getPartInfo(message); - CreateWSDLElementHelper.createPart(message); - - // need to get the prefix for the item - // could get list of updated messages and then select but currently we only have the local name - String itemPrefix = definition.getPrefix(definition.getTargetNamespace()); - if (itemPrefix == null) - { - itemPrefix = ""; //$NON-NLS-1$ - } - org.w3c.dom.Element wsdlElement = WSDLEditorUtil.getInstance().getElementForObject((WSDLElement) input); - wsdlElement.setAttribute("message", itemPrefix.length() == 0 ? newName : itemPrefix + ":" + newName); //$NON-NLS-1$ //$NON-NLS-2$ - } - else if (input instanceof Part) { - Definition definition = ((Part) input).getEnclosingDefinition(); - String referencingPrefix = definition.getPrefix(definition.getTargetNamespace()); - String newName = dialog.getName(); - - if (kind.equalsIgnoreCase("type")) { - if (typeKind.equalsIgnoreCase("complex")) { - ((AddXSDTypeDefinitionCommand) command).isComplexType(true); - } - else { - ((AddXSDTypeDefinitionCommand) command).isComplexType(false); - } - ((AddXSDTypeDefinitionCommand) command).run(newName); - ComponentReferenceUtil.setComponentReference((Part) input, true, referencingPrefix.equals("") ? newName : referencingPrefix + ":" + newName); - } - else if (kind.equalsIgnoreCase("element")) { - ((AddXSDElementDeclarationCommand) command).run(newName); - ComponentReferenceUtil.setComponentReference((Part) input, false, referencingPrefix.equals("") ? newName : referencingPrefix + ":" + newName); - } - } - - // We shouldn't know about the editor in this class - WSDLEditor editor = (WSDLEditor) editorPart; - editor.getSelectionManager().setSelection(new StructuredSelection(input)); - } - } - - private List getUsedNames() { - if (input instanceof Port) { - Definition definition = ((Port) input).getEnclosingDefinition(); - return NameUtil.getUsedBindingNames(definition); - } - else if (input instanceof Binding) { - Definition definition = ((Binding) input).getEnclosingDefinition(); - return NameUtil.getUsedPortTypeNames(definition); - } - else if (input instanceof Input || input instanceof Output || input instanceof Fault) { - Definition definition = ((MessageReference) input).getEnclosingDefinition(); - return NameUtil.getUsedMessageNames(definition); - } - else if (input instanceof Part) { - Definition definition = ((Part) input).getEnclosingDefinition(); - if (kind.equalsIgnoreCase("element")) { - if (command == null) { - command = new AddXSDElementDeclarationCommand(definition, "NewElement"); - } - XSDSchema parentSchema = ((AddXSDElementDeclarationCommand) command).getSchema(); - - return getUsedElementNames(parentSchema); - } - else if (kind.equalsIgnoreCase("type")) { - if (command == null) { - command = new AddXSDTypeDefinitionCommand(definition, "NewType"); - } - XSDSchema parentSchema = ((AddXSDTypeDefinitionCommand) command).getSchema(); - - List usedNames; - if (typeKind.equalsIgnoreCase("complex")) { - usedNames = getUsedComplexTypeNames(parentSchema); - } - else { - usedNames = getUsedSimpleTypeNames(parentSchema); - } - - return usedNames; - } - } - - return (new ArrayList()); - } - - private String getDefaultName() { - if (input instanceof Port) { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_BINDING"); // TODO: Ugly Hack... remove - Definition def = ((Port) input).getEnclosingDefinition(); - return NameUtil.getUniqueNameHelper("NewBinding", NameUtil.getUsedBindingNames(def)); - } - else if (input instanceof Binding) { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_PORTTYPE"); // TODO: Ugly Hack... remove - Definition def = ((Binding) input).getEnclosingDefinition(); - return NameUtil.getUniqueNameHelper("NewPortType", NameUtil.getUsedPortTypeNames(def)); - } - else if (input instanceof Input || input instanceof Output || input instanceof Fault) { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_MESSAGE"); // TODO: Ugly Hack... remove - Definition def = ((MessageReference) input).getEnclosingDefinition(); - return NameUtil.getUniqueNameHelper("NewMessage", NameUtil.getUsedMessageNames(def)); - } - else if (input instanceof Part) { - Definition def = ((Part) input).getEnclosingDefinition(); - - if (kind.equalsIgnoreCase("element")) { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_ELEMENT"); // TODO: Ugly Hack... remove - if (command == null) { - command = new AddXSDElementDeclarationCommand(def, "NewElement"); - } - XSDSchema parentSchema = ((AddXSDElementDeclarationCommand) command).getSchema(); - - List usedNames = getUsedElementNames(parentSchema); - return NameUtil.getUniqueNameHelper("NewElement", usedNames); - } - else if (kind.equalsIgnoreCase("type")) { - if (command == null) { - command = new AddXSDTypeDefinitionCommand(def, "NewType"); - } - XSDSchema parentSchema = ((AddXSDTypeDefinitionCommand) command).getSchema(); - - String newItemName = "NewComplexType"; - List usedNames = null; - if (typeKind.equalsIgnoreCase("complex")) { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_COMPLEX_TYPE"); // TODO: Ugly Hack... remove - usedNames = getUsedComplexTypeNames(parentSchema); - } - else { - newDialogTitle = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NEW_SIMPLE_TYPE"); // TODO: Ugly Hack... remove - usedNames = getUsedSimpleTypeNames(parentSchema); - newItemName = "NewSimpleType"; - } - - return newItemName = NameUtil.getUniqueNameHelper(newItemName, usedNames); - } - } - - return "NewComponent"; - } - - private List getUsedSimpleTypeNames(XSDSchema schema) { - List namesList = new ArrayList(); - - Iterator typesIt = schema.getTypeDefinitions().iterator(); - while (typesIt.hasNext()) { - XSDTypeDefinition type = (XSDTypeDefinition) typesIt.next(); - if (type instanceof XSDSimpleTypeDefinition) { - namesList.add(type.getName()); - } - } - - return namesList; - } - - private List getUsedComplexTypeNames(XSDSchema schema) { - List namesList = new ArrayList(); - - Iterator typesIt = schema.getTypeDefinitions().iterator(); - while (typesIt.hasNext()) { - XSDTypeDefinition type = (XSDTypeDefinition) typesIt.next(); - if (type instanceof XSDComplexTypeDefinition) { - namesList.add(type.getName()); - } - } - - return namesList; - } - - private List getUsedElementNames(XSDSchema schema) { - List namesList = new ArrayList(); - - Iterator elementsIt = schema.getElementDeclarations().iterator(); - while (elementsIt.hasNext()) { - XSDElementDeclaration element = (XSDElementDeclaration) elementsIt.next(); - namesList.add(element.getName()); - } - - return namesList; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SmartRenameAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SmartRenameAction.java deleted file mode 100644 index 32fc403ee..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SmartRenameAction.java +++ /dev/null @@ -1,551 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.xsd.XSDElementDeclaration; -import org.w3c.dom.Node; - - -/* - * This class renames 'related' WSDLElements. The scenario is as follows: - * The user renames a WSDLElement in the editor, say a Message. This class - * will find the 'related' elements to this Message and rename them as well. - * It will only rename a 'related' element if the element name (or part of it) - * is generated. - * - * See NameUtil.java - */ -public class SmartRenameAction extends BaseNodeAction implements Runnable { - protected Object element; - protected String newName; - private List messageReferences; // This variable should be accessed by method getAllMessageReferences() - protected Node node; - - public SmartRenameAction(Object element, String newName) { - setText("Smart Rename Action"); // Do not translate - this.element = element; - this.newName = newName; - this.node = WSDLEditorUtil.getInstance().getNodeForObject(element); - } - - public Node getNode() { - return node; - } - - public String getUndoDescription() { - return WSDLEditorPlugin.getWSDLString("_UI_ACTION_RENAME"); //$NON-NLS-1$ - } - - public void run() { - RenameAction renamer; - String oldName; - - beginRecording(); - if (element instanceof Operation) { - Operation operation = (Operation) element; - oldName = operation.getName(); - - if (oldName.equals(newName)) { - return; - } - - // Rename Operation - renamer = new RenameAction(operation, newName); - renamer.run(); - - // Rename Input - Input input = operation.getEInput(); - /* - if (input != null && isInputOutputNameGenerated(oldName, input.getName())) { - renamer = new RenameAction(input, newName); - renamer.run(); - } - */ - - // Rename Output - Output output = operation.getEOutput(); - /* - if (output != null && isInputOutputNameGenerated(oldName, output.getName())) { - renamer = new RenameAction(output, newName); - renamer.run(); - } - */ - - // Rename Messages and Parts - Message msg; - - // Input - if (input != null && input.getEMessage() != null) { - msg = input.getEMessage(); - String oldMessageName = ""; - - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - - if (isMessageNameGenerated(oldMessageName, oldName, "Request")) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - } - } - - // Output - if (output != null && output.getMessage() != null) { - msg = output.getEMessage(); - String oldMessageName = ""; - - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - - if (isMessageNameGenerated(oldMessageName, oldName, "Response")) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - - } - } - - // Faults - List faults = operation.getEFaults(); - if (faults != null) { - Iterator it = faults.iterator(); - while (it.hasNext()) { - Fault fault = (Fault) it.next(); - msg = fault.getEMessage(); - String oldMessageName = ""; - - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - - if (isMessageNameGenerated(oldMessageName, oldName, fault.getName())) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - } - } - } - } - else if (element instanceof Input) { - Input input = (Input) element; - oldName = input.getName(); - if (oldName == null) { - oldName = ""; - } - - if (oldName.equals(newName)) { - return; - } - - input.setName(newName); - -// Rename Messages and Parts - Message msg; - - // Input - if (input != null && input.getEMessage() != null) { - msg = input.getEMessage(); - String oldMessageName = ""; - - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - - if (isMessageNameGenerated(oldMessageName, oldName, "Request")) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - } - } - } - else if (element instanceof Output) { - Output output = (Output) element; - oldName = output.getName(); - if (oldName == null) { - oldName = ""; - } - - if (oldName.equals(newName)) { - return; - } - - output.setName(newName); - -// Rename Messages and Parts - Message msg; - - // Output - if (output != null && output.getMessage() != null) { - msg = output.getEMessage(); - String oldMessageName = ""; - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - if (isMessageNameGenerated(oldMessageName, oldName, "Response")) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - } - } - } - else if (element instanceof Fault) { - Fault fault = (Fault) element; - Message msg = fault.getEMessage(); - String oldMessageName = ""; - oldName = fault.getName(); - - if (oldName.equals(newName)) { - return; - } - - // Rename the Fault - renamer = new RenameAction(fault, newName); - renamer.run(); - - // Rename the Message and Parts - if (msg != null) { - oldMessageName = msg.getQName().getLocalPart(); - - Operation op = (Operation) fault.eContainer(); - if (isMessageNameGenerated(oldMessageName, op.getName(), oldName)) { - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renameFaultParts(msg.getEParts(), op.getName(), oldName, newName); - } - } - } - else if (element instanceof Message) { - Message msg = (Message) element; - oldName = msg.getQName().getLocalPart(); - String oldMessageName = msg.getQName().getLocalPart(); - - if (oldName.equals(newName)) { - return; - } - - renameMessageHelper(msg, computeNewMessageName(msg, oldName, newName)); - - if (msg.getEParts() != null) - renamePartsHelper(msg.getEParts(), oldMessageName, msg.getQName().getLocalPart(), true); - } - else if (element instanceof Part) { - Part part = (Part) element; - String oldPartName = part.getName(); - - if (oldPartName.equals(newName)) { - return; - } - - renamer = new RenameAction(element, newName); - renamer.run(); - -// Rename Elements - renameXSDElement(part, oldPartName, newName); - } - else if (element instanceof Port) { - Port port = (Port) element; - String oldPortName = port.getName(); - - renamer = new RenameAction(element, newName); - renamer.run(); - -// Rename Binding - Binding binding = port.getEBinding(); - if (binding != null && binding.getQName().getLocalPart().equals(oldPortName)) { - renamer = new RenameAction(binding, newName); - renamer.run(); - } - } - endRecording(); - } - - // boolean isInputOutput should be set to true if the part is an Input or Output. - // Set false if the part is a Fault. - private void renamePartsHelper(List partsList, String oldSubString, String newSubString, boolean isInputOutput) { - RenameAction renamer; - - if (partsList != null) { - Iterator pIt = partsList.iterator(); - while (pIt.hasNext()) { - Part part = (Part) pIt.next(); - String oldPartName = part.getName(); - - if (isPartNameGenerated(oldPartName, oldSubString)) { - String newPartName; - if (isInputOutput) { - newPartName = computeNewPartName(part, oldSubString, newSubString); - } - else { - newPartName = computeNewFaultPartName(part, oldSubString, newSubString); - } - - renamer = new RenameAction(part, newPartName); - renamer.run(); - - // Rename Elements - renameXSDElement(part, oldPartName, newPartName); - } - } - } - } - - // This method is used to update the Part name when the Fault name is changed. Only - // change the Part name if the part name is a generated name. - // Compare to renamePartsHelper(). The renamePartsHelper() method is called when a Fault - // has NOT been renamed, rather, it is triggered by some other naming (ex. Operation - // renaming). It will updat Input/Output, AND Fault Parts. - private void renameFaultParts(List partsList, String baseName, String oldSubString, String newSubString) { - RenameAction renamer; - - if (partsList != null) { - Iterator pIt = partsList.iterator(); - while (pIt.hasNext()) { - Part part = (Part) pIt.next(); - String oldPartName = part.getName(); - - if (isPartNameGenerated(oldPartName, baseName, oldSubString)) { - String newPartName; - newPartName = computeNewFaultPartName(part, oldSubString, newSubString); - renamer = new RenameAction(part, newPartName); - renamer.run(); - - // Rename Elements - renameXSDElement(part, oldPartName, newPartName); - } - } - } - } - - private String computeNewMessageName(Message message, String oldSubString, String newSubString) { - String string = message.getQName().getLocalPart(); - return replaceSectionWithSubString(string, oldSubString, newSubString, 0); - } - -// private String computeNewFaultMessageName(Message message, String oldSubString, String newSubString) { -// String string = message.getQName().getLocalPart(); -// return replaceSectionWithSubString(string, oldSubString, newSubString, 1); -// } - - // Method for Input, Output, and Fault Parts - // See computeNewFaultPartName() for comparison - private String computeNewPartName(Part part, String oldSubString, String newSubString) { - String string = part.getName(); - return replaceSectionWithSubString(string, oldSubString, newSubString, 0); - } - - // Method for Fault Parts - // This method behaves in the exact same way as computeNewPartName() except it starts searching for a match - // after the first character. This method is intended for users who wish to rename a generated (Fault) part - // where the Fault name has changed. We start our search after the first character because the generated name - // of the part is built by appending the Fault name after the Operation name. - private String computeNewFaultPartName(Part part, String oldSubString, String newSubString) { - String string = part.getName(); - return replaceSectionWithSubString(string, oldSubString, newSubString, 1); - } - - private String replaceSectionWithSubString(String fullString, String oldSubString, String newSubString, int startSearchIndex) { - StringBuffer fullSB = new StringBuffer(fullString); - int index = fullSB.indexOf(oldSubString, startSearchIndex); - if (index >= 0) { - return fullSB.replace(index, index + oldSubString.length(), newSubString).toString(); - } - - return ""; - } - - //////////////////////////////////////////////////////////////////////////////////////// - - private static boolean commonNameGeneratorCheck(String targetName, String baseName, String appendName) { - // First criteria is targetName must start with the baseName - if (!targetName.startsWith(baseName)) - return false; - - if (appendName.trim().length() > 0) { - // Second criteria. The appended name must be in the targetName and begin right - // after the baseName location - if (!targetName.startsWith(appendName, baseName.length())) - return false; - } - - // Third criteria (if necessary). If baseName + appendName is shorter than targetName, - // then there must be 'extra' characters at the end of targetName. These characters must - // make up an integer. If not, it is not a generated string. - int subLength = baseName.length() + appendName.length(); - if (targetName.length() > subLength) { - // We have 'extra' characters - String extras = targetName.substring(subLength); - - if(!isDigit(extras)) - return false; - } - - return true; - } - - public static boolean isOperationNameGenerated(String opName, String name) { - return opName.equals(name); - } - - public static boolean isMessageNameGenerated(String msgName, String baseName, String appendName) { - return commonNameGeneratorCheck(msgName, baseName, appendName); - } - - public static boolean isInputOutputNameGenerated(String inOutName, String name) { - return inOutName.equals(name); - } - - public static boolean isFaultNameGenerated(String faultName, String name) { - return faultName.equals(name); - } - - public static boolean isPartNameGenerated(String partName, String baseName) { - return commonNameGeneratorCheck(partName, baseName, ""); - } - - private boolean isPartNameGenerated(String partName, String baseName, String appendName) { - return commonNameGeneratorCheck(partName, baseName, appendName); - } - - private static boolean isDigit(String string) { - boolean rValue = true; - char[] chars = string.toCharArray(); - - for (int index = 0; index < chars.length; index++) { - if (!Character.isDigit(chars[index])) { - rValue = false; - break; - } - } - - return rValue; - } - - /* - * The following classes aid in renaming a message - */ - private void renameMessageHelper(Message msg, String newName) { - List messageRefs = getReferencingMessageReferences(msg, getAllMessageReferences()); - - RenameAction renamer = new RenameAction(msg, newName); - renamer.run(); - - Iterator iterator = messageRefs.iterator(); - while (iterator.hasNext()) { - MessageReference messageReference = (MessageReference) iterator.next(); - messageReference.setEMessage(msg); - } - } - - private List getReferencingMessageReferences(Message msg, List messageRefs) { - Vector referencesVector = new Vector(); - QName messageQName = msg.getQName(); - Iterator iterator = messageRefs.iterator(); - - while (iterator.hasNext()) { - MessageReference messageReference = (MessageReference) iterator.next(); - if (messageReference.getEMessage() != null && messageQName.equals(messageReference.getEMessage().getQName())) { - referencesVector.addElement(messageReference); - } - } - - return referencesVector; - } - - private List getAllMessageReferences() { - if (messageReferences == null) { - messageReferences = new Vector(); - Definition definition = ((WSDLElement) element).getEnclosingDefinition(); - List portTypes = definition.getEPortTypes(); - - if (portTypes != null) { - Iterator portTypeIterator = portTypes.iterator(); - while (portTypeIterator.hasNext()) { - List operationsList = ((PortType) portTypeIterator.next()).getEOperations(); - - if (operationsList != null) { - Iterator operationsIterator = operationsList.iterator(); - while (operationsIterator.hasNext()) { - messageReferences.addAll(getAllMessageReferences((Operation) operationsIterator.next())); - } - } - } - } - } - - return messageReferences; - } - - private Vector getAllMessageReferences(Operation operation) { - Vector iofs = new Vector(); - Iterator it = operation.getEFaults().iterator(); - while (it.hasNext()) { - iofs.addElement(it.next()); - } - - if (iofs == null) - iofs = new Vector(); - - if (operation.getEInput() != null) - iofs.addElement(operation.getEInput()); - - if (operation.getEOutput() != null) - iofs.addElement(operation.getEOutput()); - - return iofs; - } - - private void renameXSDElement(Part part, String oldXSDName, String newXSDName) { - XSDElementDeclaration elementDeclaration = part.getElementDeclaration(); - if (elementDeclaration != null && oldXSDName.equals(elementDeclaration.getName())) { - renameElementDeclarationHelper(elementDeclaration, oldXSDName, newXSDName); - - // Here we rename the element reference. - // - QName qname = new QName(part.getElementName().getNamespaceURI(), newXSDName); - part.setElementName(qname); - } - } - - private void renameElementDeclarationHelper(XSDElementDeclaration elementDeclaration, String oldXSDName, String newXSDName) { - if (elementDeclaration != null && elementDeclaration.getName().equals(oldXSDName)) { - elementDeclaration.setName(newXSDName); - } - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourceEditorActionBarContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourceEditorActionBarContributor.java deleted file mode 100644 index 472ca0db3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourceEditorActionBarContributor.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.part.MultiPageEditorActionBarContributor; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.sse.ui.internal.ExtendedEditorActionBuilder; -import org.eclipse.wst.sse.ui.internal.IExtendedContributor; -import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor; -import org.eclipse.wst.wsdl.ui.internal.WSDLMultiPageEditorPart; - -public class SourceEditorActionBarContributor extends MultiPageEditorActionBarContributor implements IExtendedContributor { - - protected IEditorActionBarContributor designViewerActionBarContributor = null; - protected IEditorActionBarContributor sourceViewerActionContributor = null; - protected WSDLMultiPageEditorPart multiPageEditor = null; - - // EditorExtension - private static final String EDITOR_ID = "org.eclipse.wst.wsdl.ui.internal.actions.XMLMultiPageEditorPart"; //$NON-NLS-1$ - private IExtendedContributor extendedContributor; - - public SourceEditorActionBarContributor() { - super(); - - sourceViewerActionContributor = new SourcePageActionContributor(); - - // Read action extensions. - ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder(); - extendedContributor = builder.readActionExtensions(EDITOR_ID); - } - - public void init(IActionBars actionBars) { - super.init(actionBars); - - if (actionBars != null) { - initDesignViewerActionBarContributor(actionBars); - initSourceViewerActionContributor(actionBars); - } - } - - protected void initDesignViewerActionBarContributor(IActionBars actionBars) { - if (designViewerActionBarContributor != null) - designViewerActionBarContributor.init(actionBars, getPage()); - } - - protected void initSourceViewerActionContributor(IActionBars actionBars) { - if (sourceViewerActionContributor != null) - sourceViewerActionContributor.init(actionBars, getPage()); - } - - public void dispose() { - super.dispose(); - - if (designViewerActionBarContributor != null) - designViewerActionBarContributor.dispose(); - - if (sourceViewerActionContributor != null) - sourceViewerActionContributor.dispose(); - - if (extendedContributor != null) - extendedContributor.dispose(); - } - - /** - * @see EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public final void contributeToMenu(IMenuManager menu) { - super.contributeToMenu(menu); - - addToMenu(menu); - - if (extendedContributor != null) - extendedContributor.contributeToMenu(menu); - } - - protected void addToMenu(IMenuManager menu) { - } - - /** - * @see IExtendedContributor#contributeToPopupMenu(IMenuManager) - */ - public final void contributeToPopupMenu(IMenuManager menu) { - - addToPopupMenu(menu); - - if (extendedContributor != null) - extendedContributor.contributeToPopupMenu(menu); - } - - protected void addToPopupMenu(IMenuManager menu) { - } - - /** - * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public final void contributeToToolBar(IToolBarManager toolBarManager) { - super.contributeToToolBar(toolBarManager); - - addToToolBar(toolBarManager); - - if (extendedContributor != null) - extendedContributor.contributeToToolBar(toolBarManager); - } - - protected void addToToolBar(IToolBarManager toolBarManager) { - } - - /** - * @see EditorActionBarContributor#contributeToStatusLine(IStatusLineManager) - */ - public final void contributeToStatusLine(IStatusLineManager manager) { - super.contributeToStatusLine(manager); - - addToStatusLine(manager); - - if (extendedContributor != null) - extendedContributor.contributeToStatusLine(manager); - } - - protected void addToStatusLine(IStatusLineManager manager) { - } - - /** - * @see IExtendedContributor#updateToolbarActions() - */ - public void updateToolbarActions() { - if (extendedContributor != null) - extendedContributor.updateToolbarActions(); - } - - public void setActiveEditor(IEditorPart targetEditor) { - // save multiPageEditor before calling super.setActiveEditor(targetEditor) - // super.setActiveEditor will call setActivePage(IEditorPart activeEditor) - // multiPageEditor is needed in setActivePage(IEditorPart activeEditor) - if (targetEditor instanceof WSDLMultiPageEditorPart) - multiPageEditor = (WSDLMultiPageEditorPart) targetEditor; - - super.setActiveEditor(targetEditor); - - updateToolbarActions(); - - if (extendedContributor != null) - extendedContributor.setActiveEditor(targetEditor); - } - - public void setActivePage(IEditorPart activeEditor) { - // This contributor is designed for StructuredTextMultiPageEditorPart. - // To safe-guard this from problems caused by unexpected usage by other editors, the following - // check is added. - if (multiPageEditor != null) { - if (activeEditor != null && activeEditor instanceof StructuredTextEditor) - activateSourcePage(activeEditor); - else - activateDesignPage(activeEditor); - } - - updateToolbarActions(); - - IActionBars actionBars = getActionBars(); - if (actionBars != null) { - // update menu bar and tool bar - actionBars.updateActionBars(); - } - } - - protected void activateDesignPage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { - designViewerActionBarContributor.setActiveEditor(multiPageEditor); - } - - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { - // if design page is not really an IEditorPart, activeEditor == null, so pass in multiPageEditor instead (d282414) - if (activeEditor == null) { - sourceViewerActionContributor.setActiveEditor(multiPageEditor); - } - else { - sourceViewerActionContributor.setActiveEditor(activeEditor); - } - ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false); - } - } - - protected void activateSourcePage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { - designViewerActionBarContributor.setActiveEditor(multiPageEditor); - } - - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { - sourceViewerActionContributor.setActiveEditor(activeEditor); - ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true); - } - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourcePageActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourcePageActionContributor.java deleted file mode 100644 index 84b6bd753..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/SourcePageActionContributor.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.ui.IActionBars; -import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML; - - -/** - * SourcePageActionContributor - * - * This class is for multi page editor's source page contributor. - * - * Use WSDLEditorActionContributor for single page editor - * */ -public class SourcePageActionContributor extends ActionContributorXML { - - private IActionBars fBars; - - /** - * This method calls: - * <ul> - * <li><code>contributeToMenu</code> with <code>bars</code>' menu manager</li> - * <li><code>contributeToToolBar</code> with <code>bars</code>' tool bar - * manager</li> - * <li><code>contributeToStatusLine</code> with <code>bars</code>' status line - * manager</li> - * </ul> - * The given action bars are also remembered and made accessible via - * <code>getActionBars</code>. - * - * @param bars the action bars - * - */ - public void init(IActionBars bars) { - fBars = bars; - contributeToMenu(bars.getMenuManager()); - contributeToToolBar(bars.getToolBarManager()); - contributeToStatusLine(bars.getStatusLineManager()); - } - - /** - * Returns this contributor's action bars. - * - * @return the action bars - */ - public IActionBars getActionBars() { - return fBars; - } -}
\ No newline at end of file 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 deleted file mode 100644 index 1ac3e788a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLActionBarContributor.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; - -public class WSDLActionBarContributor extends SourceEditorActionBarContributor -{ - protected ITextEditor textEditor; - - /** - * Constructor for WSDLActionBarContributor. - */ - public WSDLActionBarContributor() - { - super(); - } - - public void setActivePage(IEditorPart activeEditor) - { - super.setActivePage(activeEditor); - - // always enable undo/redo regardless of which page we're on. The undo/redo comes from the editor - // - updateAction(ActionFactory.UNDO.getId(), ITextEditorActionConstants.UNDO, true); - updateAction(ActionFactory.REDO.getId(), ITextEditorActionConstants.REDO, true); - - // turn these off so that the actionhandler will handle it for us - // - //updateAction(IWorkbenchActionConstants.CUT, ITextEditorActionConstants.CUT, false); - //updateAction(IWorkbenchActionConstants.COPY, ITextEditorActionConstants.COPY, false); - //updateAction(IWorkbenchActionConstants.PASTE, ITextEditorActionConstants.PASTE, false); - - getActionBars().updateActionBars(); - } - - protected void updateAction(String globalActionId, String textEditorActionId, boolean enable) - { - getActionBars().setGlobalActionHandler(globalActionId, enable ? getAction(textEditor, textEditorActionId) : null); - } - - /** - * Returns the action registed with the given text editor. - * @return IAction or null if editor is null. - */ - protected IAction getAction(ITextEditor editor, String actionID) - { - try - { - return (editor == null ? null : editor.getAction(actionID)); - } - catch (Exception e) - { - return null; - } - } - - /** - * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public void addToToolBar(IToolBarManager toolBarManager) - { - super.addToToolBar(toolBarManager); - toolBarManager.add(new GroupMarker("WSDLEditor")); - } - - - public void setActiveEditor(IEditorPart activeEditor) - { - super.setActiveEditor(activeEditor); - textEditor = null; - if (activeEditor instanceof WSDLEditor) - { - textEditor = ((WSDLEditor) activeEditor).getTextEditor(); - } - - updateAction(ActionFactory.UNDO.getId(), ITextEditorActionConstants.UNDO, true); - updateAction(ActionFactory.REDO.getId(), ITextEditorActionConstants.REDO, true); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragAction.java deleted file mode 100644 index 6425160ad..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; -import org.w3c.dom.Node; - -public abstract class WSDLDragAction extends BaseNodeAction { - protected WSDLTreeNodeEditPart movingChildEditPart; - protected Point pointerLocation; - - /* - * Sub-classes should override this method. - */ - public boolean canExecute() { - return false; - } - - public void execute() { - run(); - } - - /* - * Sub-classes should override this method. - */ - public String getUndoDescription() { - return ""; - } - - /* - * Sub-classes should override this method. - */ - public Node getNode() { - return null; - } - - /* - * Sub-classes should override this method. - */ - public IFigure getFeedbackFigure() { - return null; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragReorderAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragReorderAction.java deleted file mode 100644 index 1cff3c81e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragReorderAction.java +++ /dev/null @@ -1,424 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.wsdl.OperationType; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Polyline; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.OperationImpl; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; - - -public class WSDLDragReorderAction extends WSDLDragAction -{ - protected WSDLEditor wsdlEditor; - protected WSDLElement movingChild; - protected WSDLElement newParent; - protected WSDLTreeNodeEditPart leftSiblingEditPart; - protected WSDLTreeNodeEditPart rightSiblingEditPart; - protected WSDLElement leftSibElement; - protected WSDLElement rightSibElement; - protected boolean canNeverExecute = false; - - public WSDLDragReorderAction(WSDLTreeNodeEditPart movingChildEditPart, EditPart pointerEditPart, Point pointerLocation) { - this.movingChildEditPart = movingChildEditPart; - this.pointerLocation = pointerLocation; - - EditPart possibleParent = getParentEditPart(pointerEditPart); - - if (!(possibleParent instanceof WSDLTreeNodeEditPart)) { - canNeverExecute = true; - return; - } - - WSDLTreeNodeEditPart targetParentEditPart = (WSDLTreeNodeEditPart) possibleParent; - wsdlEditor = ((WSDLComponentViewer) possibleParent.getViewer()).getWSDLEditor(); - - if (pointerEditPart.getParent() != null) { - // Sort the siblings (and itself) - List targetEditPartSiblings = pointerEditPart.getParent().getChildren(); - Collections.sort(targetEditPartSiblings, new VerticalEditPartComparator()); - - // Get 'left' and 'right' siblings - leftSiblingEditPart = getVerticalLeftSibling(targetEditPartSiblings, movingChildEditPart, pointerLocation); - rightSiblingEditPart = getVerticalRightSibling(targetEditPartSiblings, movingChildEditPart, pointerLocation); - - if (movingChildEditPart != null) - movingChild = (WSDLElement) movingChildEditPart.getModel(); - if (leftSiblingEditPart != null) - leftSibElement = (WSDLElement) leftSiblingEditPart.getModel(); - if (rightSiblingEditPart != null) - rightSibElement = (WSDLElement) rightSiblingEditPart.getModel(); - - newParent = (WSDLElement) targetParentEditPart.getModel(); - } - else { - newParent = (WSDLElement) targetParentEditPart.getModel(); - leftSibElement = null; - rightSibElement= null; - } - } - - public boolean canExecute() - { - boolean result = false; - - if (canNeverExecute || newParent == null || movingChild == null) { - return false; - } - - if (movingChild instanceof Input) { - if (!(leftSibElement instanceof Fault) && newParent.equals(movingChild.eContainer())) { - result = true; - } - } - else if (movingChild instanceof Output) { - if (!(leftSibElement instanceof Fault) && newParent.equals(movingChild.eContainer())) { - result = true; - } - } - else if (movingChild instanceof Part) { - if (newParent instanceof Message && newParent.equals(movingChild.eContainer())) { - result = true; - } - } - - return result; - } - - - /* - * @see IAction#run() - */ - public void run() - { -// beginRecording(); - if (canExecute()) { - if (movingChild instanceof Input) { - Input input = (Input) movingChild; - OperationImpl operation = (OperationImpl) input.eContainer(); - - if (leftSiblingEditPart == null) { - // Input/Output style - setInputOutputOrder(operation, true); - } - else { - // Output/Input style - setInputOutputOrder(operation, false); - } - } - else if (movingChild instanceof Output) { - Output output = (Output) movingChild; - OperationImpl operation = (OperationImpl) output.eContainer(); - - if (leftSiblingEditPart == null) { - // Output/Input style - setInputOutputOrder(operation, false); - } - else { - // Input/Output style - setInputOutputOrder(operation, true); - } - } - else if (movingChild instanceof Part) { - Message message = (Message) newParent; - List parts = message.getEParts(); - - parts.remove(movingChild); - - int leftIndex = -1, rightIndex = -1; - if (leftSibElement != null) { - leftIndex = parts.indexOf(leftSibElement); - } - if (rightSibElement != null) { - rightIndex = parts.indexOf(rightSibElement); - } - - if (leftIndex == -1) { - // Add moving child to the front - parts.add(0, movingChild); - } - else if (rightIndex == -1) { - // Add moving child to the end - parts.add(movingChild); - } - else { - // Add moving child after the occurence of the left sibling - parts.add(leftIndex + 1, movingChild); - } - } - wsdlEditor.getSelectionManager().setSelection(new StructuredSelection(movingChild)); - } -// endRecording(); - } - - public IFigure getFeedbackFigure() { - IFigure feedbackFigure = null; - if (feedbackFigure == null && movingChildEditPart instanceof WSDLTreeNodeEditPart) - { - feedbackFigure = new Polyline(); -// polyLine.setLineStyle(Graphics.LINE_DASHDOT); - ((Polyline)feedbackFigure).setLineWidth(2); - drawLines((Polyline) feedbackFigure); - } - - return feedbackFigure; - } - - /* Return a PointList which will be used to add a feedback figure. The feedback figure will be a - * Polyline composed of the Points in the PointList - */ - private PointList drawLines(Polyline polyLine) { - PointList pointList = new PointList(); - - if (leftSiblingEditPart != null) { - Rectangle leftRectangle = leftSiblingEditPart.getFigure().getBounds(); - int xCoord = leftRectangle.x + 15; - int yCoord = leftRectangle.y; - int height = leftRectangle.height; - int width = leftRectangle.width - 15; - - // Draw left end line - addLineToPolyline(polyLine, xCoord, yCoord + height + 3, xCoord, yCoord + height - 3); - addLineToPolyline(polyLine, xCoord, yCoord + height - 3, xCoord, yCoord + height); - - // Draw horizontal line - addLineToPolyline(polyLine, xCoord, yCoord + height, xCoord + width, yCoord + height); - - // Draw right end line - addLineToPolyline(polyLine, xCoord + width, yCoord + height, xCoord + width, yCoord + height - 3); - addLineToPolyline(polyLine, xCoord + width, yCoord + height, xCoord + width, yCoord + height + 3); - } - else if (rightSiblingEditPart != null) { - Rectangle rightRectangle = rightSiblingEditPart.getFigure().getBounds(); - int xCoord = rightRectangle.x + 15; - int yCoord = rightRectangle.y; - int width = rightRectangle.width - 15; - - // Draw left end line - addLineToPolyline(polyLine, xCoord, yCoord + 3, xCoord, yCoord - 3); - addLineToPolyline(polyLine, xCoord, yCoord - 3, xCoord, yCoord); - - // Draw horizontal line - addLineToPolyline(polyLine, xCoord, yCoord, xCoord + width, yCoord); - - // Draw right end line - addLineToPolyline(polyLine, xCoord + width, yCoord, xCoord + width, yCoord - 3); - addLineToPolyline(polyLine, xCoord + width, yCoord, xCoord + width, yCoord + 3); - } - - return pointList; - } - - protected Polyline addLineToPolyline(Polyline polyline, int x1, int y1, int x2, int y2) { - polyline.addPoint(new Point(x1, y1)); - polyline.addPoint(new Point(x2, y2)); - - return polyline; - } - - /* - * Pre-condition: The List siblings should be sorted by it's y-coordinate - */ - private WSDLTreeNodeEditPart getVerticalRightSibling(List siblings, WSDLTreeNodeEditPart movingEditPart, Point pointerLocation) { - WSDLTreeNodeEditPart rightSibling = null; - int pointerYLocation = pointerLocation.y; - - for (int index = 0; index < siblings.size(); index++) { - WSDLTreeNodeEditPart sibling = (WSDLTreeNodeEditPart) siblings.get(index); - int siblingYLocation = sibling.getSelectionFigure().getBounds().getCenter().y; - - if (siblingYLocation > pointerYLocation) { - rightSibling = sibling; - break; - } - } - - return rightSibling; - } - - /* - * Pre-condition: The List siblings should be sorted by it's y-coordinate - */ - private WSDLTreeNodeEditPart getVerticalLeftSibling(List siblings, WSDLTreeNodeEditPart movingEditPart, Point pointerLocation) { - WSDLTreeNodeEditPart leftSibling = null; - int pointerYLocation = pointerLocation.y; - - int index; - for (index = 0; index < siblings.size(); index++) { - WSDLTreeNodeEditPart sibling = (WSDLTreeNodeEditPart) siblings.get(index); - int siblingYLocation = sibling.getSelectionFigure().getBounds().getCenter().y; - - if (siblingYLocation > pointerYLocation) { - if (index > 0) { - leftSibling = (WSDLTreeNodeEditPart) siblings.get(index - 1); - } - - break; - } - } - - if (index == siblings.size()) { - leftSibling = (WSDLTreeNodeEditPart) siblings.get(index - 1); - } - - return leftSibling; - } - - protected EditPart getParentEditPart(EditPart target) - { - return target.getParent(); - } - - // boolean inputFirst = true if the Input is the first in the order of Input and Output - private void setInputOutputOrder(OperationImpl operation, boolean inputFirst) { - // We need to determine more info before we can set the style - if (inputFirst && operation.getEInput() != null) { - // Check if there is an Output - if (operation.getEOutput() != null) { - // Order is: Input, Output -/* - Node operationNode = operation.getElement(); - NodeList childNodeList = operationNode.getChildNodes(); - - Node inputNode = operation.getEInput().getElement(); - Node outputNode = operation.getEOutput().getElement(); - - Node inputTextNode = inputNode.getNextSibling(); - Node outputTextNode = outputNode.getNextSibling(); - - int inputNodeIndex = getNodeIndex(childNodeList, inputNode); - int outputNodeIndex = getNodeIndex(childNodeList, outputNode); - - if (inputNodeIndex > outputNodeIndex) { - // We need to swap Input and Output - operationNode.removeChild(inputNode); - operationNode.removeChild(outputNode); - - operationNode.insertBefore(inputNode, outputTextNode); - operationNode.insertBefore(outputNode, inputTextNode); - } -*/ - - setOperationStyle(operation, OperationType.REQUEST_RESPONSE); - } - /* - else { - // Order is: Input - setOperationStyle(operation, OperationType.ONE_WAY); - } - */ - } - else if (operation.getEOutput() != null) { - // Check if there is an Input - if (operation.getEInput() != null) { - // Order is: Output, Input -/* - Node operationNode = operation.getElement(); - NodeList childNodeList = operationNode.getChildNodes(); - - Node inputNode = operation.getEInput().getElement(); - Node outputNode = operation.getEOutput().getElement(); - - Node inputTextNode = inputNode.getNextSibling(); - Node outputTextNode = outputNode.getNextSibling(); - - int inputNodeIndex = getNodeIndex(childNodeList, inputNode); - int outputNodeIndex = getNodeIndex(childNodeList, outputNode); - - if (outputNodeIndex > inputNodeIndex) { - // We need to swap Input and Output - operationNode.removeChild(inputNode); - operationNode.removeChild(outputNode); - - operationNode.insertBefore(inputNode, outputTextNode); - operationNode.insertBefore(outputNode, inputTextNode); - } -*/ - setOperationStyle(operation, OperationType.SOLICIT_RESPONSE); - } - /* - else { - // Order is: Output - setOperationStyle(operation, OperationType.NOTIFICATION); - } - */ - } - } - -/* - * return -1 if node is not found in the given nodeList - */ -// private int getNodeIndex(NodeList nodeList, Node node) { -// int index = 0; -// while (index < nodeList.getLength() && !(nodeList.item(index).equals(node))) { -// index++; -// } -// -// if (index >= nodeList.getLength()) { -// index = -1; -// } -// -// return index; -// } - - private void setOperationStyle(OperationImpl operation, OperationType operationType) { - // If there is no style to begin with, don't set one now - if (operation.getStyle() == null) { - return; - } - - operation.setStyle(operationType); - } - - private class VerticalEditPartComparator implements Comparator { - - public VerticalEditPartComparator() { - } - - public int compare(Object part1, Object part2) { - int compareValue = 0; - - if (part1 instanceof WSDLTreeNodeEditPart && part2 instanceof WSDLTreeNodeEditPart) { - WSDLTreeNodeEditPart editPart1 = (WSDLTreeNodeEditPart) part1; - WSDLTreeNodeEditPart editPart2 = (WSDLTreeNodeEditPart) part2; - - int editPart1Y = editPart1.getSelectionFigure().getBounds().getCenter().y; - int editPart2Y = editPart2.getSelectionFigure().getBounds().getCenter().y; - - Integer integerPart1 = new Integer(editPart1Y); - Integer integerPart2 = new Integer(editPart2Y); - - compareValue = integerPart1.compareTo(integerPart2); - } - - return compareValue; - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragSetMessageAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragSetMessageAction.java deleted file mode 100644 index 9aa7d4802..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLDragSetMessageAction.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Polyline; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.GroupEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectedFigure; - -public class WSDLDragSetMessageAction extends WSDLDragAction { - protected EditPart pointerEditPart; - protected WSDLElement movingChild; - protected WSDLElement pointerModelElement; - - public WSDLDragSetMessageAction(WSDLTreeNodeEditPart movingChildEditPart, EditPart pointerEditPart, Point pointerLocation) { - this.movingChildEditPart = movingChildEditPart; - this.pointerEditPart = pointerEditPart; - this.pointerLocation = pointerLocation; - - movingChild = (WSDLElement) movingChildEditPart.getModel(); - pointerModelElement = (WSDLElement) pointerEditPart.getModel(); - - // Allow the user to hover over a Part (of a Message) to set the Message - if (pointerModelElement instanceof Part) { - this.pointerEditPart = pointerEditPart.getParent(); - pointerModelElement = (WSDLElement) this.pointerEditPart.getModel(); - } - } - - public boolean canExecute() { - boolean result = false; - - if (pointerModelElement == null || movingChild == null) { - return false; - } - - if (movingChild instanceof Input || movingChild instanceof Output || movingChild instanceof Fault) { - if (pointerModelElement instanceof Message) { - result = true; - } - } - - return result; - } - - public void run() { - if (canExecute()) { - MessageReference messageReference = (MessageReference) movingChild; - messageReference.setEMessage((Message) pointerModelElement); - ((WSDLElementImpl) messageReference).updateElement(true); - - WSDLEditor wsdlEditor = ((WSDLComponentViewer) pointerEditPart.getViewer()).getWSDLEditor(); - wsdlEditor.getSelectionManager().setSelection(new StructuredSelection(movingChild)); - } - } - - public IFigure getFeedbackFigure() { - Polyline polyfigure = new Polyline(); - GroupEditPart leftGroupEditPart = getGroupEditPart(movingChildEditPart); - GroupEditPart rightGroupEditPart = getGroupEditPart(pointerEditPart); - int mx = rightGroupEditPart.getFigure().getBounds().x - 5; - - drawLine(polyfigure, leftGroupEditPart.outputConnection.getFigure(), ((AbstractGraphicalEditPart) pointerEditPart).getFigure(), mx); - - return polyfigure; - } - - protected void drawLine(Polyline feedbackFigure, IFigure a, IFigure b, int mx) - { - Rectangle r1 = getConnectionBounds(a); - Rectangle r2 = getConnectionBounds(b); - int x1 = r1.x + r1.width; - int y1 = r1.y + r1.height / 2; - int x2 = r2.x - 1; - int y2 = r2.y + 8; - - // draw horizontal line - addLineToPolyline(feedbackFigure, x1, y1, mx, y1); - - // draw horizontal line - addLineToPolyline(feedbackFigure, mx, y2, x2 - 1, y2); - - // draw the arrow head - addLineToPolyline(feedbackFigure, x2 - 1, y2, x2 - 4, y2 - 3); - addLineToPolyline(feedbackFigure, x2 - 1, y2, x2 - 4, y2 + 3); - } - - protected Rectangle getConnectionBounds(IFigure figure) - { - Rectangle r = null; - if (figure instanceof IConnectedFigure) - { - IConnectedFigure connectedFigure = (IConnectedFigure)figure; - r = connectedFigure.getConnectionFigure().getBounds(); - } - else - { - r = figure.getBounds(); - } - return r; - } - - protected Polyline addLineToPolyline(Polyline polyline, int x1, int y1, int x2, int y2) { - polyline.addPoint(new Point(x1, y1)); - polyline.addPoint(new Point(x2, y2)); - polyline.setLineWidth(1); - //polyline.setLineStyle(Graphics.LINE_DOT); - - return polyline; - } - - private GroupEditPart getGroupEditPart(EditPart editPart) { - EditPart parentPart = editPart.getParent(); - - if (parentPart == null) { - return null; - } - if (!(parentPart instanceof GroupEditPart)) { - parentPart = getGroupEditPart(parentPart); - } - - return (GroupEditPart) parentPart; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementAction.java deleted file mode 100644 index e2f287c10..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementAction.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.commands.WSDLElementCommand; -import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentDialog; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.w3c.dom.Node; - -public abstract class WSDLElementAction extends Action -{ - protected WSDLElementCommand modelCommand; - private IEditorPart editorPart; - - public WSDLElementAction - (WSDLElementCommand command, - String undoDescription, - String label, - ImageDescriptor image) - { - super(label,image); - modelCommand = command; - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } -/* - private String getUndoDescription() - { - return undoDescription; - } -*/ - abstract protected WSDLElement getOwner(); - - abstract protected boolean showDialog(); - - public void run() - { - boolean ok = showDialog(); - if (ok) - { - preRun(); - modelCommand.run(); - format(); - selectObject(); - postRun(); - } - } - - protected void preRun() - { - } - - protected void postRun() - { - } -/* - private void beginRecording() - { - Node node = null; - if (getOwner() != null) - node = getOwner().getElement(); - - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().beginRecording(this, getUndoDescription()); - } - } - - private void endRecording() - { - Node node = null; - if (getOwner() != null) - node = getOwner().getElement(); - - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().endRecording(this); - } - } -*/ - protected WSDLElement getWSDLElement() - { - return modelCommand.getWSDLElement(); - } - - private void format() - { - Node parentNode = null; - if (getOwner() != null) - parentNode = getOwner().getElement(); - - if (parentNode instanceof IDOMNode) - { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)parentNode); - } - } - - private void selectObject() - { - if (editorPart != null && getOwner() != null) - { - Object object = getWSDLElement(); - if (object != null) - { - ISelectionProvider selectionProvider = (ISelectionProvider)editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) - { - selectionProvider.setSelection(new StructuredSelection(object)); - } - } - } - } - - protected String showDialogHelper(String title, String defaultName) - { - String result = defaultName; - NewComponentDialog dialog = new NewComponentDialog(WSDLEditorPlugin.getShell(), title, defaultName); - int rc = dialog.createAndOpen(); - if (rc == IDialogConstants.OK_ID) - { - result = dialog.getName(); - } - else - { - result = null; - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementUIAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementUIAction.java deleted file mode 100644 index 23822090c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLElementUIAction.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.commands.WSDLElementCommand; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.w3c.dom.Node; - -public abstract class WSDLElementUIAction extends Action -{ - protected WSDLElementCommand modelAction; - private IEditorPart editorPart; - - public WSDLElementUIAction - (WSDLElementCommand action, - String undoDescription, - String label, - ImageDescriptor image) - { - super(label,image); - modelAction = action; - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - - private Node getOwnerNode() - { - if (getOwner() != null) - return getOwner().getElement(); - else - return null; - } - - abstract protected WSDLElement getOwner(); - - abstract protected boolean showDialog(); - - public void run() - { - boolean ok = showDialog(); - if (ok) - { - preRun(); - modelAction.run(); - format(); - selectObject(); - postRun(); - } - } - - protected void preRun() - { - } - - protected void postRun() - { - } -/* - private void beginRecording() - { - Node node = getOwnerNode(); - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().beginRecording(this, getUndoDescription()); - } - } - - private void endRecording() - { - Node node = getOwnerNode(); - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().endRecording(this); - } - } -*/ - protected WSDLElement getWSDLElement() - { - return modelAction.getWSDLElement(); - } - - private void format() - { - Node parentNode = getOwnerNode(); - if (parentNode instanceof IDOMNode) - { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)parentNode); - } - } - - private void selectObject() - { - if (editorPart != null && getOwner() != null) - { - Object object = getWSDLElement(); - if (object != null) - { - ISelectionProvider selectionProvider = (ISelectionProvider)editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) - { - selectionProvider.setSelection(new StructuredSelection(object)); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuActionContributor.java deleted file mode 100644 index ce494be67..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuActionContributor.java +++ /dev/null @@ -1,1148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.commands.AddInputCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOperationCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOutputCommand; -import org.eclipse.wst.wsdl.ui.internal.extension.IMenuActionContributor; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.CreateWSDLElementHelper; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentWithChildDialog; -import org.eclipse.wst.wsdl.ui.internal.wizards.BindingWizard; -import org.eclipse.wst.wsdl.ui.internal.wizards.PortWizard; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -public class WSDLMenuActionContributor implements IMenuActionContributor -{ - protected AddEEMenuActionContributor addEEMenuActionContributor; - IEditorPart editorPart; - - public WSDLMenuActionContributor(IEditorPart editorPart) - { - addEEMenuActionContributor = new AddEEMenuActionContributor(); - this.editorPart = editorPart; - } - - protected static List createList(Action action) - { - List list = new ArrayList(); - list.add(action); - return list; - } - - private class OpenSchemaOnSelectionHelper extends Action { - Object object; - - public OpenSchemaOnSelectionHelper(Object object) { - setText(WSDLEditorPlugin.getWSDLString("_UI_OPEN_IMPORT")); - this.object = object; - - if (object instanceof Import) { - String location = ((Import) object).getLocationURI(); - - if (location == null || location.trim().equals("")) - setEnabled(false); - } - } - - public void run() { - Definition definition = ((WSDLElement) object).getEnclosingDefinition(); - org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper helper = new org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper(definition); - helper.openEditor((org.eclipse.emf.ecore.EObject) object); - } - } - - public void contributeMenuActions(final IMenuManager menu, final Node node, Object object) - { - final IMenuManager addMenu; - boolean addEditAction = false; - final boolean isEditable = (node instanceof IDOMNode); - if (object instanceof WSDLElement && node != null && isEditable) - { - addEditAction = true; - addMenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_CHILD"), "addchild"); //$NON-NLS-1$ //$NON-NLS-2$ - menu.add(addMenu); - Definition definition = ((WSDLElement) object).getEnclosingDefinition(); - - final String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - - if (object instanceof Import) { - menu.add(new OpenSchemaOnSelectionHelper(object)); - } - - WSDLSwitch wsdlSwitch = new WSDLSwitch() - { - public Object caseBinding(Binding binding) - { - if (isEditable) - { - menu.add(new AddBindingOperationAction(node, "NewBindingOperation", prefix)); //$NON-NLS-1$ - menu.add(new Separator()); - } - - menu.add(createSetPortTypeMenu(binding, isEditable)); - menu.add(new GenerateBindingContentAction(binding, isEditable)); - return null; - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - if (isEditable) - { - menu.add(new AddBindingInputAction(editorPart, node, prefix)); - menu.add(new AddBindingOutputAction(editorPart, node, prefix)); - menu.add(new AddBindingFaultAction(node, prefix)); - } - return null; - } - - public Object caseDefinition(Definition definition) - { - menu.add(new EditNamespacesAction(definition)); - menu.add(new Separator()); - - if (isEditable) - { - menu.add(new AddMessageAction(definition, null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - menu.add(new AddServiceAction(definition, null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - menu.add(new AddPortTypeAction(definition, null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - menu.add(new AddBindingAction(definition, ((WSDLEditor) editorPart).getXMLDocument()));//, null, node, prefix)); - menu.add(new AddImportAction(editorPart, definition, node, prefix)); - } - return null; - } - - public Object caseFault(Fault fault) - { - menu.add(createSetMessageMenu(fault, isEditable)); - //menu.add(createAddBindingMenuForIOF(fault)); - return null; - } - - public Object caseInput(Input input) - { - menu.add(createSetMessageMenu(input, isEditable)); - //menu.add(createAddBindingMenuForIOF(input)); - return null; - } - - public Object caseOutput(Output output) - { - menu.add(createSetMessageMenu(output, isEditable)); - //menu.add(createAddBindingMenuForIOF(output)); - return null; - } - - public Object caseMessage(Message message) - { - if (isEditable) - { - menu.add(new AddPartAction(editorPart, message, node, prefix)); - } - return null; - } - - public Object caseOperation(Operation operation) - { - if (isEditable) - { - menu.add(new AddInputAction(editorPart, node, operation, prefix)); - menu.add(new AddOutputAction(editorPart, node, operation, prefix)); - menu.add(new AddFaultAction(editorPart, node, operation, prefix)); - } - //menu.add(createAddBindingMenuForOperation(operation)); - return null; - } - - public Object casePart(Part part) - { - menu.add(createSetPartMenu(part, (Element) node, "element", isEditable)); //$NON-NLS-1$ - menu.add(createSetPartMenu(part, (Element) node, "type", isEditable)); //$NON-NLS-1$ - return null; - } - - public Object casePort(Port port) - { - if (node instanceof Element) - { - menu.add(createSetBindingMenu(port, (Element) node, isEditable)); - if (port.getEBinding() != null) - { - menu.add(createSetPortTypeMenu(port.getEBinding(), isEditable)); - } - } - return null; - } - - public Object casePortType(PortType portType) - { - if (isEditable) - { - menu.add(new AddOperationAction(editorPart, portType, node, prefix)); - } - return null; - } - - public Object caseService(Service service) - { - if (isEditable) - { - menu.add(new AddPortAction(service)); - } - return null; - } - - //public Object caseTypes(Types types) - //{ - // return createTypesAdapter(); - // } - }; - wsdlSwitch.doSwitch((WSDLElement) object); - } - else if (object instanceof WSDLGroupObject) - { - addMenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_CHILD"), "addchild"); //$NON-NLS-1$ //$NON-NLS-2$ - menu.add(addMenu); - - WSDLGroupObject groupObject = (WSDLGroupObject) object; - Definition definition = groupObject.getDefinition(); - - final String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - - //for (Iterator i = actionList.iterator(); i.hasNext(); ) - //{ - // Action action = (Action)i.next(); - // manager.add(action); - //} - - switch (groupObject.getType()) - { - case WSDLGroupObject.MESSAGES_GROUP : - { - menu.add(new AddMessageAction(groupObject.getDefinition(), null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - break; - } - case WSDLGroupObject.SERVICES_GROUP : - { - menu.add(new AddServiceAction(groupObject.getDefinition(), null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - break; - } - case WSDLGroupObject.PORT_TYPES_GROUP : - { - menu.add(new AddPortTypeAction(groupObject.getDefinition(), null, node, prefix, ((WSDLEditor) editorPart).getXMLDocument())); - break; - } - case WSDLGroupObject.BINDINGS_GROUP : - { - menu.add(new AddBindingAction(groupObject.getDefinition(), ((WSDLEditor) editorPart).getXMLDocument()));//, null, node, prefix)); - break; - } - case WSDLGroupObject.IMPORTS_GROUP : - { - menu.add(new AddImportAction(editorPart, groupObject.getDefinition(), node, prefix)); - break; - } - } - } - - menu.add(new Separator()); - - addEEMenuActionContributor.contributeMenuActions(menu, node, object); - - menu.add(new Separator()); - - if (object instanceof WSDLElement && node != null && addEditAction && node != null && isEditable) - { - //////////////////////////////////////// Currently, only allow Copy and Paste on Operations - if (object instanceof Operation) { - // Add Cut, Copy Actions - // Note: The Cut, Copy, Paste Actions are Model Driven. The Delete Action is still - // currently DOM driven. - // menu.add(new CutAction((WSDLElement) object, editorPart)); - menu.add(new CopyGlobalAction((WSDLElement) object, editorPart)); - } - - Action pasteAction = new PasteGlobalAction((WSDLElement) object, editorPart); - if (pasteAction.isEnabled()) { - menu.add(pasteAction); - } - - menu.add(new Separator()); - //////////////////////////////////////// Currently, only allow Copy and Paste on Operations - - // Get the list of selected elements. Use this list for the DeleteAction. - IStructuredSelection selectionList = (IStructuredSelection) ((WSDLEditor) editorPart).getSelectionManager().getSelection(); - Action deleteAtion = new DeleteWSDLAndXSDAction(selectionList.toList(), node, (WSDLEditor) editorPart); - menu.add(deleteAtion); - deleteAtion.setEnabled(isEditable); - } - - // insertion point for popupMenus extension - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - /* - protected MenuManager createAddBindingMenuForOperation(Operation operation) - { - MenuManager subMenu = new MenuManager("Add Binding"); - - Definition definition = operation.getEnclosingDefinition(); - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - - String operationName = operation.getName(); - if (operationName != null) - { - for (Iterator i = util.getBindings(operation).iterator(); i.hasNext(); ) - { - Binding binding = (Binding)i.next(); - - BindingOperation matchingBindingOperation = null; - - for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext(); ) - { - BindingOperation bindingOperation = (BindingOperation)j.next(); - if (operationName.equals(bindingOperation.getName())) - { - matchingBindingOperation = bindingOperation; - break; - } - } - - if (matchingBindingOperation == null) - { - Element bindingElement = WSDLUtil.getInstance().getElementForObject(binding); - subMenu.add(new AddBindingOperationAction(bindingElement, operation, prefix)); - } - } - } - return subMenu; - }*/ - - /* - protected MenuManager createAddBindingMenuForIOF(WSDLElement iof) - { - MenuManager subMenu = new MenuManager("Add Binding"); - - Definition definition = iof.getEnclosingDefinition(); - Operation operation = (Operation)iof.eContainer(); - - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - - String operationName = operation.getName(); - if (operationName != null) - { - for (Iterator i = util.getBindings(operation).iterator(); i.hasNext(); ) - { - Binding binding = (Binding)i.next(); - - boolean hasName = false; - for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext(); ) - { - BindingOperation bindingOperation = (BindingOperation)j.next(); - if (operationName.equals(bindingOperation.getName())) - { - hasName = true; - break; - } - } - - if (!hasName) - { - // TODO... should we add the operation to all of the bindings? - // - Element bindingElement = WSDLUtil.getInstance().getElementForObject(binding); - subMenu.add(new AddBindingOperationAction(bindingElement, operationName)); - } - } - } - return subMenu; - } - */ - - protected MenuManager createSetBindingMenu(Port port, Element portElement, boolean isEditable) - { - MenuManager submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_SET_BINDING")); - - Definition definition = port.getEnclosingDefinition(); - String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - - SetNewComponentAction setNewAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_BINDING"), definitionElement, prefix, "binding", port); - setNewAction.setEditor(editorPart); - setNewAction.setEnabled(true); - submenu.add(setNewAction); - - SetExistingComponentAction action = new SetExistingComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_EXISTING_BINDING"), definitionElement, prefix, "binding", port); - action.setEditor(editorPart); - action.setEnabled(isEditable); - submenu.add(action); - - return submenu; - } - - protected MenuManager createSetPortTypeMenu(Binding binding, boolean isEditable) - { - MenuManager submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_SET_PORTTYPE")); - - if (binding != null) - { - Definition definition = binding.getEnclosingDefinition(); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - - SetNewComponentAction setNewAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_PORTTYPE"), definitionElement, prefix, "portType", binding); - setNewAction.setEditor(editorPart); - setNewAction.setEnabled(true); - submenu.add(setNewAction); - - SetExistingComponentAction action = new SetExistingComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_EXISTING_PORTTYPE"), definitionElement, prefix, "portType", binding); - action.setEditor(editorPart); - action.setEnabled(isEditable); - submenu.add(action); - } - return submenu; - } - - protected MenuManager createSetMessageMenu(WSDLElement wsdlElement, boolean isEditable) - { - Definition definition = wsdlElement.getEnclosingDefinition(); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - Element referencingElement = WSDLEditorUtil.getInstance().getElementForObject(wsdlElement); - - MenuManager submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_SET_MESSAGE")); - if (definitionElement != null && referencingElement != null) - { - String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - - SetNewComponentAction setNewAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_MESSAGE"), definitionElement, prefix, "message", wsdlElement); - setNewAction.setEditor(editorPart); - setNewAction.setEnabled(true); - submenu.add(setNewAction); - - SetExistingComponentAction action = new SetExistingComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_EXISTING_MESSAGE"), definitionElement, prefix, "message", wsdlElement); - action.setEditor(editorPart); - action.setEnabled(isEditable); - submenu.add(action); - } - - return submenu; - } - - protected MenuManager createSetPartMenu(Part part, Element portElement, String referenceKind, boolean isEditable) - { - Definition definition = part.getEnclosingDefinition(); - String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - - String actionName; - MenuManager submenu = null; - if (referenceKind.equalsIgnoreCase("element")) // NON NLS - { - actionName = WSDLEditorPlugin.getWSDLString("_UI_ACTION_EXISTING_ELEMENT"); - submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_SET_ELEMENT")); - - SetNewComponentAction setNewElementAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_ELEMENT"), definitionElement, prefix, "element", part); - setNewElementAction.setEditor(editorPart); - setNewElementAction.setEnabled(true); - setNewElementAction.setReferenceKind(referenceKind); - submenu.add(setNewElementAction); - } - else - { - actionName = WSDLEditorPlugin.getWSDLString("_UI_ACTION_EXISTING_TYPE"); - submenu = new MenuManager(WSDLEditorPlugin.getWSDLString("_UI_ACTION_SET_TYPE")); - - SetNewComponentAction setNewComplexAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_COMPLEX_TYPE"), definitionElement, prefix, "complex type", part); - setNewComplexAction.setEditor(editorPart); - setNewComplexAction.setEnabled(true); - setNewComplexAction.setReferenceKind(referenceKind); - setNewComplexAction.setTypeKind("complex"); - Image image = XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"); - setNewComplexAction.setImageDescriptor(ImageDescriptor.createFromImage(image)); - submenu.add(setNewComplexAction); - - SetNewComponentAction setNewSimpleAction = new SetNewComponentAction(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_SIMPLE_TYPE"), definitionElement, prefix, "simple type", part); - setNewSimpleAction.setEditor(editorPart); - setNewSimpleAction.setEnabled(true); - setNewSimpleAction.setReferenceKind(referenceKind); - setNewSimpleAction.setTypeKind("simple"); - image = XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif"); - setNewSimpleAction.setImageDescriptor(ImageDescriptor.createFromImage(image)); - - submenu.add(setNewSimpleAction); - } - - - SetExistingComponentAction action = new SetExistingComponentAction(actionName, definitionElement, prefix, actionName, part); - action.setReferenceKind(referenceKind); - action.setEditor(editorPart); - action.setEnabled(isEditable); - submenu.add(action); - - return submenu; - } - -// private WSDLElement showPasteAction(WSDLElement element, IEditorPart ePart) { -// WSDLElement parentElement = null; -// -// if (ePart instanceof WSDLEditor) { -// WSDLElement clipboardElement = ((WSDLEditor) ePart).getClipboardContents(); -// -// if (element instanceof PortType) { -// if (clipboardElement instanceof Operation) { -// parentElement = element; -// } -// } -// if (element instanceof Operation) { -// if (clipboardElement instanceof Operation) { -// parentElement = (WSDLElement) ((Operation) element).eContainer(); -// } -// } -// } -// -// return parentElement; -// } -} - -class AddBindingOperationAction extends AddElementAction -{ - protected String name; - protected Operation operation; - - public AddBindingOperationAction(Node parentNode, String name, String prefix) - { - // super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD") + " " + WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_OPERATION"), "icons/operationbinding_obj.gif", parentNode, prefix, "operation"); - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_BINDING_OPERATION"), "icons/operationbinding_obj.gif", parentNode, prefix, "operation"); - this.name = name; - } - - public AddBindingOperationAction(Node parentNode, Operation operation, String prefix) - { - this(parentNode, operation.getName(), prefix); - this.operation = operation; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("name", name); - } - - protected void performAddElement() - { - super.performAddElement(); - - if (operation != null) - { - if (operation.getInput() != null) - { - new AddBindingInputAction(editorPart, newElement, prefix).run(); - } - if (operation.getOutput() != null) - { - new AddBindingOutputAction(editorPart, newElement, prefix).run(); - } - for (Iterator i = operation.getEFaults().iterator(); i.hasNext();) - { - Fault fault = (Fault) i.next(); - new AddBindingFaultAction(newElement, fault, prefix).run(); - } - format(operation.getElement()); - } - } -} - - -class AddOperationAction extends AddElementAction -{ - protected String name = "NewOperation"; - protected PortType portType; - protected boolean createSubComponents = false; - - public AddOperationAction(IEditorPart editorPart, PortType portType, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_OPERATION"), "icons/operation_obj.gif", parentNode, prefix, "operation"); - setEditorPart(editorPart); - setDefinition(portType.getEnclosingDefinition()); - this.portType = portType; - } - - public boolean showDialog() - { - name = NameUtil.buildUniqueOperationName(portType); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_OPERATION"), name, NameUtil.getUsedOperationNames(portType)); - return name != null; - } - -// protected void addAttributes(Element newElement) -// { -// newElement.setAttribute("name", name); -// } - - protected void performAddElement() - { - if (createSubComponents) { - CreateWSDLElementHelper.operationName = name; - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.getPartInfo(portType); - Operation operation = CreateWSDLElementHelper.createOperation(portType); - format(operation.getElement()); - selectObject(operation); - expandEditParts(operation,true); - } - else { - // Add Operation - AddOperationCommand opAction = new AddOperationCommand(portType, name); - opAction.run(); - Operation operation = (Operation) opAction.getWSDLElement(); - - // Add Output - AddOutputCommand outAction = new AddOutputCommand(operation, NameUtil.buildUniqueInputName(portType, operation.getName(), "")); - outAction.run(); - - // Add Input - AddInputCommand inAction = new AddInputCommand(operation, NameUtil.buildUniqueOutputName(portType, operation.getName(), "")); - inAction.run(); - - format(operation.getElement()); - - selectObject(operation); - expandEditParts(operation, true); - } - } - - private void expandEditParts(Object element, boolean expandChildren) { - if (element != null) { - EditPartViewer editPartViewer = ((WSDLEditor) editorPart).getGraphViewer().getComponentViewer(); - Map editPartMap = editPartViewer.getEditPartRegistry(); - WSDLTreeNodeEditPart wsdlEditPart = (WSDLTreeNodeEditPart) editPartMap.get(element); - wsdlEditPart.setExpanded(true); - - if (expandChildren) { - Iterator iterator = WSDLEditorUtil.getModelGraphViewChildren(element).iterator(); - - while (iterator.hasNext()) { - expandEditParts(iterator.next(), expandChildren); - } - } - } - } - - public String showDialogHelper(String title, String defaultName, List usedNames) - { - String result = defaultName; - NewComponentWithChildDialog dialog = new NewComponentWithChildDialog(WSDLEditorPlugin.getShell(), title, defaultName, usedNames); - int rc = dialog.createAndOpen(); - if (rc == IDialogConstants.OK_ID) - { - result = dialog.getName(); - createSubComponents = dialog.createSubComponents(); - } - else - { - result = null; - } - return result; - } -} - -abstract class AddIOFAction extends AddElementAction -{ - protected Operation operation; - - public AddIOFAction(IEditorPart editorPart, String text, String imageDescriptorKey, Node parentNode, String prefix, String localName, Operation operation) - { - super(text, imageDescriptorKey, parentNode, prefix, localName); - this.operation = operation; - setEditorPart(editorPart); - setDefinition(operation.getEnclosingDefinition()); - } - - abstract protected void performAddElementToBindingOperation(BindingOperation bindingOperation, Element bindingOperationElement); - - /* - protected void addAttributes(Element newElement) - { - newElement.setAttribute("message", ""); - } - */ - - protected void performAddElement() - { - if (operation != null) - { - Definition definition = operation.getEnclosingDefinition(); - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - - for (Iterator i = util.getBindingOperations(operation).iterator(); i.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) i.next(); - Element bindingOperationElement = WSDLEditorUtil.getInstance().getElementForObject(bindingOperation); - if (bindingOperationElement != null) - { - performAddElementToBindingOperation(bindingOperation, bindingOperationElement); - } - } - format(operation.getElement()); - } - } -} - -class AddInputAction extends AddIOFAction -{ - public AddInputAction(IEditorPart editorPart, Node parentNode, Operation operation, String prefix) - { - super(editorPart, WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_INPUT"), "icons/input_obj.gif", parentNode, prefix, "input", operation); - } - - protected void performAddElementToBindingOperation(BindingOperation bindingOperation, Element bindingOperationElement) - { - if (bindingOperation.getBindingInput() == null) - { - new AddBindingInputAction(editorPart, bindingOperationElement, prefix).run(); - } - } - - protected void performAddElement() { - PortType portType = (PortType) ((WSDLElementImpl) operation).getContainer(); - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.getPartInfo(portType); - Input input = CreateWSDLElementHelper.createInput(portType, operation, null); - format(input.getElement()); - selectObject(input); - } -} - -class AddOutputAction extends AddIOFAction -{ - public AddOutputAction(IEditorPart editorPart, Node parentNode, Operation operation, String prefix) - { - super(editorPart, WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_OUTPUT"), "icons/output_obj.gif", parentNode, prefix, "output", operation); - } - - protected void performAddElementToBindingOperation(BindingOperation bindingOperation, Element bindingOperationElement) - { - if (bindingOperation.getBindingOutput() == null) - { - new AddBindingOutputAction(editorPart, bindingOperationElement, prefix).run(); - } - } - - protected void performAddElement() { - // Determine Part info - PortType portType = (PortType) ((WSDLElementImpl) operation).getContainer(); - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.getPartInfo(portType); - Output output = CreateWSDLElementHelper.createOutput(portType, operation); - format(output.getElement()); - selectObject(output); - } -} - -class AddFaultAction extends AddIOFAction -{ - protected String name = "NewFault"; - public AddFaultAction(IEditorPart editorPart, Node parentNode, Operation operation, String prefix) - { - super(editorPart, WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_FAULT"), "icons/fault_obj.gif", parentNode, prefix, "fault", operation); - name = NameUtil.buildUniqueFaultName(operation); - } - - public boolean showDialog() - { - name = NameUtil.buildUniqueFaultName(operation); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_FAULT"), name, NameUtil.getUsedFaultNames(operation)); - return name != null; - } - - /* - protected void addAttributes(Element newElement) - { - newElement.setAttribute("message", ""); - newElement.setAttribute("name", name); - } - */ - - protected void performAddElementToBindingOperation(BindingOperation bindingOperation, Element bindingOperationElement) - { - if (bindingOperation.getBindingFault(name) == null) - { - new AddBindingFaultAction(bindingOperationElement, prefix).run(); - } - } - - protected void performAddElement() { - CreateWSDLElementHelper.faultName = name; - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.getPartInfo(operation); - Fault fault = CreateWSDLElementHelper.createFault(operation); - format(fault.getElement()); - selectObject(fault); - } -} - -class AddBindingInputAction extends AddElementAction -{ - public AddBindingInputAction(IEditorPart editorPart, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_INPUT"), "icons/input_obj.gif", parentNode, prefix, "input"); - setEditorPart(editorPart); - } -} - -class AddBindingOutputAction extends AddElementAction -{ - public AddBindingOutputAction(IEditorPart editorPart, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_OUTPUT"), "icons/output_obj.gif", parentNode, prefix, "output"); - setEditorPart(editorPart); - } -} - -class AddBindingFaultAction extends AddElementAction -{ - protected Fault fault; - - public AddBindingFaultAction(Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_FAULT"), "icons/fault_obj.gif", parentNode, prefix, "fault"); - } - - public AddBindingFaultAction(Node parentNode, Fault fault, String prefix) - { - this(parentNode, prefix); - this.fault = fault; - } - - protected void addAttributes(Element newElement) - { - if (fault == null) - { - newElement.setAttribute("name", "NewFault"); - } - else - { - newElement.setAttribute("name", fault.getName()); - } - } -} - -class AddMessageAction extends AddElementAction -{ - protected Definition definition; - protected String name; - - public AddMessageAction(Definition definition, String name, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_MESSAGE"), "icons/message_obj.gif", parentNode, prefix, "message"); - this.definition = definition; - this.name = name; - setComputeTopLevelRefChild(true); - } - - public AddMessageAction(Definition definition, String name, Node parentNode, String prefix, Document document) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_MESSAGE"), "icons/message_obj.gif", parentNode, prefix, "message"); - this.definition = definition; - this.name = name; - this.setDefinition(definition); - this.document = document; - setComputeTopLevelRefChild(true); - } - - public boolean showDialog() - { - name = NameUtil.buildUniqueMessageName(definition, name); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_MESSAGE"), name, NameUtil.getUsedMessageNames(definition)); - return name != null; - } - -// protected void addAttributes(Element newElement) -// { -// newElement.setAttribute("name", name); -// } - - protected void performAddElement() { - NodeList list = document.getChildNodes(); - if (parentNode == null|| list.getLength() == 0) { - createDefinitionStub(); - } - - AddMessageCommand action = new AddMessageCommand(definition, name); - action.run(); - Message message = (Message) action.getWSDLElement(); - CreateWSDLElementHelper.createPart(message); - format(message.getElement()); - selectObject(message); - } - - public String getName() - { - return name; - } -} - -class AddPartAction extends AddElementAction -{ - protected Message message; - protected String name; - - public AddPartAction(IEditorPart editorPart, Message message, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_PART"), "icons/part_obj.gif", parentNode, prefix, "part"); - this.message = message; - setEditorPart(editorPart); - setDefinition(message.getEnclosingDefinition()); - } - - public boolean showDialog() - { - name = NameUtil.buildUniquePartName(message, message.getQName().getLocalPart()); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_PART"), name, NameUtil.getUsedPartNames(message)); - return name != null; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("name", name); - String xsdPrefix = message.getEnclosingDefinition().getPrefix(WSDLConstants.XSD_NAMESPACE_URI); - if (xsdPrefix == null) - { - Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(message.getEnclosingDefinition()); - new AddNamespaceDeclarationsAction(definitionElement, WSDLConstants.XSD_NAMESPACE_URI, "xsd").run(); - xsdPrefix = message.getEnclosingDefinition().getPrefix(WSDLConstants.XSD_NAMESPACE_URI); - } - - String defaultTypeName = "string"; - if (xsdPrefix != null && xsdPrefix.length() > 0) - { - defaultTypeName = xsdPrefix + ":" + defaultTypeName; - } - newElement.setAttribute("type", defaultTypeName); - } -} - -class AddServiceAction extends AddElementAction -{ - protected String name; - protected Definition definition; - - public AddServiceAction(Definition definition, String name, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_SERVICE"), "icons/service_obj.gif", parentNode, prefix, "service"); - this.definition = definition; - this.name = name; - setComputeTopLevelRefChild(true); - } - - public AddServiceAction(Definition definition, String name, Node parentNode, String prefix, Document document) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_SERVICE"), "icons/service_obj.gif", parentNode, prefix, "service"); - this.definition = definition; - this.name = name; - this.setDefinition(definition); - this.document = document; - setComputeTopLevelRefChild(true); - } - - public boolean showDialog() - { - if (name == null) - { - name = NameUtil.buildUniqueServiceName(definition); - } - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_SERVICE"), name, NameUtil.getUsedServiceNames(definition)); - return name != null; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("name", name); - } - - protected void performAddElement() { - NodeList list = document.getChildNodes(); - if (parentNode == null || list.getLength() == 0) { - createDefinitionStub(); - } - - super.performAddElement(); - } -} - -class AddPortTypeAction extends AddElementAction -{ - protected String name; - protected Definition definition; - - public AddPortTypeAction(Definition definition, String name, Node parentNode, String prefix) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_PORTTYPE"), "icons/porttype_obj.gif", parentNode, prefix, "portType"); - this.definition = definition; - this.name = name; - setComputeTopLevelRefChild(true); - } - - public AddPortTypeAction(Definition definition, String name, Node parentNode, String prefix, Document document) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_PORTTYPE"), "icons/porttype_obj.gif", parentNode, prefix, "portType"); - this.definition = definition; - this.name = name; - this.setDefinition(definition); - this.document = document; - setComputeTopLevelRefChild(true); - } - - public boolean showDialog() - { - name = NameUtil.buildUniquePortTypeName(definition, name); - name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_PORTTYPE"), name, NameUtil.getUsedPortTypeNames(definition)); - return name != null; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("name", name); - } - - public String getPortTypeName() - { - return name; - } - - protected void performAddElement() { - NodeList list = document.getChildNodes(); - if (parentNode == null || list.getLength() == 0) { - createDefinitionStub(); - } - - super.performAddElement(); - } -} - -class AddBindingAction extends Action -{ - protected Definition definition; - protected Document document; - - public AddBindingAction(Definition definition, Document document) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_BINDING"), ImageDescriptor.createFromFile(WSDLEditorPlugin.class, "icons/binding_obj.gif")); //$NON-NLS-1$ - //setToolTipText(WSDLEditorPlugin.getInstance().getWSDLString("_UI_LABEL_BINDING_WIZARD")); //$NON-NLS-1$ - this.definition = definition; - this.document = document; - } - - public void run() - { - BindingWizard wizard = new BindingWizard(definition, document); - WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard); - wizardDialog.create(); - - int result = wizardDialog.open(); - - if (result == Window.OK) - { - //todo... - } - } -} - -class AddPortAction extends Action -{ - protected Service service; - - public AddPortAction(Service service) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_PORT"), ImageDescriptor.createFromFile(WSDLEditorPlugin.class, "icons/binding_obj.gif")); //$NON-NLS-1$ - //setToolTipText(WSDLEditorPlugin.getInstance().getWSDLString("_UI_LABEL_BINDING_WIZARD")); //$NON-NLS-1$ - this.service = service; - } - - public void run() - { - PortWizard wizard = new PortWizard(service); - WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard); - wizardDialog.create(); - - int result = wizardDialog.open(); - if (result == Window.OK) - { - //todo... - } - } -} - -class GenerateBindingContentAction extends Action -{ - protected Binding binding; - public GenerateBindingContentAction(Binding binding, boolean isEditable) - { - super(WSDLEditorPlugin.getWSDLString("_UI_GENERATE_BINDING_CONTENT")); - this.binding = binding; - setEnabled(isEditable); - } - - public void run() - { - BindingWizard wizard = new BindingWizard(binding.getEnclosingDefinition(), binding, BindingWizard.KIND_REGENERATE_BINDING); - wizard.setBindingName(ComponentReferenceUtil.getName(binding)); - wizard.setPortTypeName(ComponentReferenceUtil.getPortTypeReference(binding)); - WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard); - wizardDialog.create(); - wizardDialog.open(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuListener.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuListener.java deleted file mode 100644 index a71c2389f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/actions/WSDLMenuListener.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.actions; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.w3c.dom.Node; - - -public class WSDLMenuListener implements IMenuListener -{ - protected ISelectionProvider selectionProvider; - protected ExtensibleMenuActionContributor extensibleMenuActionContributor; - - public WSDLMenuListener(WSDLEditor editor, ISelectionProvider selectionProvider) - { - super(); - this.extensibleMenuActionContributor = new ExtensibleMenuActionContributor(editor); - this.selectionProvider = selectionProvider; - } - - protected Object getSelectedObject() - { - ISelection selection = selectionProvider.getSelection(); - return selection.isEmpty() ? null : ((IStructuredSelection)selection).getFirstElement(); - } - - public void menuAboutToShow(IMenuManager manager) - { - Object object = getSelectedObject(); - Node node = null; - if (object instanceof Node) - { - node = (Node)object; - } - else if (object instanceof WSDLElement) - { - node = ((WSDLElement)object).getElement(); - } - else if (object instanceof WSDLGroupObject) - { - node = ((WSDLGroupObject)object).getDefinition().getElement(); - } - extensibleMenuActionContributor.contributeMenuActions(manager, node, object); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingCommand.java deleted file mode 100644 index 899817a0d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - - -public final class AddBindingCommand extends WSDLElementCommand -{ - private Definition definition; - private String localName; - private Binding binding; - - public AddBindingCommand - (Definition definition, - String localName) - { - this.definition = definition; - this.localName = localName; - } - - public WSDLElement getWSDLElement() - { - return binding; - } - - public void run() - { - binding = WSDLFactory.eINSTANCE.createBinding(); - binding.setQName(new QName(definition.getTargetNamespace(),localName)); - binding.setEnclosingDefinition(definition); - definition.addBinding(binding); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingFaultCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingFaultCommand.java deleted file mode 100644 index c8e02ae2c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingFaultCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddBindingFaultCommand extends WSDLElementCommand -{ - BindingFault bindingFault; - BindingOperation bindingOperation; - String name; - - public AddBindingFaultCommand(BindingOperation bindingOperation, String name) - { - this.bindingOperation = bindingOperation; - this.name = name; - } - - public void run() - { - bindingFault = WSDLFactory.eINSTANCE.createBindingFault(); - bindingFault.setName(name); - bindingFault.setEnclosingDefinition(bindingOperation.getEnclosingDefinition()); - bindingOperation.addBindingFault((BindingFault)bindingFault); - } - - public WSDLElement getWSDLElement() - { - return bindingFault; - } -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingInputCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingInputCommand.java deleted file mode 100644 index 5303b444a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingInputCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddBindingInputCommand extends WSDLElementCommand -{ - BindingInput bindingInput; - BindingOperation bindingOperation; - String name; - - public AddBindingInputCommand(BindingOperation bindingOperation, String name) - { - this.bindingOperation = bindingOperation; - this.name = name; - } - - public void run() - { - bindingInput = WSDLFactory.eINSTANCE.createBindingInput(); - bindingInput.setName(name); - bindingInput.setEnclosingDefinition(bindingOperation.getEnclosingDefinition()); - bindingOperation.setBindingInput((BindingInput)bindingInput); - } - - public WSDLElement getWSDLElement() - { - return bindingInput; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOperationCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOperationCommand.java deleted file mode 100644 index 45e0f9617..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOperationCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddBindingOperationCommand extends WSDLElementCommand -{ - private Binding binding; - - private String name; - private String bindingInputName = ""; - private String bindingOutputName = ""; - private String bindingFaultName =""; - - private BindingOperation bindingOperation; - - private boolean createBindingInput = false; - private boolean createBindingOutput = false; - private boolean createBindingFault = false; - - public AddBindingOperationCommand(Binding binding,String name) - { - this.binding = binding; - this.name = name; - } - - public AddBindingOperationCommand - (Binding binding, - String name, - boolean createBindingInput, - boolean createBindingOutput, - boolean createBindingFault) - { - this.binding = binding; - this.name = name; - this.createBindingInput = createBindingInput; - this.createBindingOutput = createBindingOutput; - this.createBindingFault = createBindingFault; - } - - public void run() - { - bindingOperation = WSDLFactory.eINSTANCE.createBindingOperation(); - bindingOperation.setName(name); - bindingOperation.setEnclosingDefinition(binding.getEnclosingDefinition()); - binding.addBindingOperation(bindingOperation); - - WSDLElementCommand command = null; - if (createBindingInput) - { - command = new AddBindingInputCommand(bindingOperation,bindingInputName); - command.run(); - } - - if (createBindingOutput) - { - command = new AddBindingOutputCommand(bindingOperation,bindingOutputName); - command.run(); - } - - if (createBindingFault) - { - command = new AddBindingFaultCommand(bindingOperation,bindingFaultName); - command.run(); - } - } - - public WSDLElement getWSDLElement() - { - return bindingOperation; - } - - public void setName(String name) - { - this.name = name; - } - - public void setBindingInputName(String name) - { - this.bindingInputName = name; - } - - public void setBindingOutputName(String name) - { - this.bindingOutputName = name; - } - - public void setBindingFaultName(String name) - { - this.bindingFaultName = name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOutputCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOutputCommand.java deleted file mode 100644 index 4286b6c2f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddBindingOutputCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddBindingOutputCommand extends WSDLElementCommand -{ - BindingOutput bindingOutput; - BindingOperation bindingOperation; - String name; - - public AddBindingOutputCommand(BindingOperation bindingOperation, String name) - { - this.bindingOperation = bindingOperation; - this.name = name; - } - - public void run() - { - bindingOutput = WSDLFactory.eINSTANCE.createBindingOutput(); - bindingOutput.setName(name); - bindingOutput.setEnclosingDefinition(bindingOperation.getEnclosingDefinition()); - bindingOperation.setBindingOutput((BindingOutput)bindingOutput); - } - - public WSDLElement getWSDLElement() - { - return bindingOutput; - } -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddFaultCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddFaultCommand.java deleted file mode 100644 index deb638a2a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddFaultCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; - - -public final class AddFaultCommand extends AddMessageReferenceCommand -{ - private Fault originalFault; - - public AddFaultCommand(Operation operation, String name) - { - super(operation,name); - } - - public AddFaultCommand(Operation operation, String name, boolean createMessage) - { - super(operation,name,createMessage); - } - - /* - * Constructor used to create a Fault based on the given Fault. In essence, this will - * create a copy of the given Fault. - */ - public AddFaultCommand(Operation operation, Fault originalFault, String name) { - super(operation, name, false); - - this.originalFault = originalFault; - } - - public void run() - { - messageReference = WSDLFactory.eINSTANCE.createFault(); - messageReference.setName(name); - messageReference.setEnclosingDefinition(operation.getEnclosingDefinition()); - operation.addFault((Fault)messageReference); - - // TBD - add binding fault - - if (originalFault == null) { - if (createMessage) - createMessage(); - } - else { - // Do necessary copying of data from original Fault to new Fault - if (originalFault.getEMessage() != null) { -// String originalMsgName = originalFault.getEMessage().getQName().getLocalPart(); -// -// boolean gened = false; -// if (originalFault.eContainer() instanceof Operation) -// gened = SmartRenameAction.isMessageNameGenerated(originalMsgName, ((Operation) originalFault.eContainer()).getName(), ""); -// -// String newMsgName = ""; -// if (gened) { -// newMsgName = NameUtil.buildUniqueMessageName(operation.getEnclosingDefinition(), messageReference); -// } -// else { -// Definition definition = operation.getEnclosingDefinition(); -// Message tMessage = originalFault.getEMessage(); -// newMsgName = NameUtil.buildUniqueMessageName(definition, tMessage.getQName().getLocalPart()); -// } - - createMessage(originalFault, NameUtil.buildUniqueMessageName(operation.getEnclosingDefinition(), messageReference)); - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddImportCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddImportCommand.java deleted file mode 100644 index 7fc4eb62a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddImportCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddImportCommand extends WSDLElementCommand -{ - private Definition definition; - private String namespace; - private String location; - private Import importElement; - - public AddImportCommand - (Definition definition, - String namespace, - String location) - { - this.definition = definition; - this.namespace = namespace; - this.location = location; - } - - public WSDLElement getWSDLElement() - { - return importElement; - } - - public void run() - { - importElement = WSDLFactory.eINSTANCE.createImport(); - importElement.setNamespaceURI(namespace); - importElement.setLocationURI(location); - importElement.setEnclosingDefinition(definition); - definition.addImport(importElement); - } - - public void setNamespaceURI(String namespace) - { - this.namespace = namespace; - } - - public void setLocationURI(String location) - { - this.location = location; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddInputCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddInputCommand.java deleted file mode 100644 index 0e33b7176..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddInputCommand.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; - - -public final class AddInputCommand extends AddMessageReferenceCommand -{ - private Input originalInput; - - public AddInputCommand(Operation operation, String name) - { - super(operation,name); - } - - public AddInputCommand(Operation operation, String name, boolean createMessage) - { - super(operation,name,createMessage); - } - - /* - * Constructor used to create an Input based on the given Input. In essence, this will - * create a copy of the given Input. - */ - public AddInputCommand(Operation operation, Input originalInput, String name) { - super(operation, name, false); - - this.originalInput = originalInput; - } - - public void run() - { - messageReference = WSDLFactory.eINSTANCE.createInput(); - // messageReference.setName(name); - messageReference.setEnclosingDefinition(operation.getEnclosingDefinition()); - operation.setInput((Input)messageReference); - - // TBD - add binding input - - if (originalInput == null) { - if (createMessage) - createMessage(); - } - else { - // Do necessary copying of data from original Input to new Input - if (originalInput.getEMessage() != null) { - String originalMsgName = originalInput.getEMessage().getQName().getLocalPart(); - - boolean gened = false; - if (originalInput.eContainer() instanceof Operation) - gened = SmartRenameAction.isMessageNameGenerated(originalMsgName, ((Operation) originalInput.eContainer()).getName(), "Request"); - - String newMsgName = ""; - if (gened) { - newMsgName = NameUtil.buildUniqueMessageName(operation.getEnclosingDefinition(), messageReference); - } - else { - Definition definition = operation.getEnclosingDefinition(); - Message tMessage = originalInput.getEMessage(); - newMsgName = NameUtil.buildUniqueMessageName(definition, tMessage.getQName().getLocalPart()); - } - - createMessage(originalInput, newMsgName); - } - } - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageCommand.java deleted file mode 100644 index 907972465..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageCommand.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; - - -public final class AddMessageCommand extends WSDLElementCommand -{ - private Definition definition; - private String localName; - private Message message; - private Message originalMessage; - - private boolean createPart = false; - private final String DEFAULT_PART_NAME = "NewPart"; - - public AddMessageCommand - (Definition definition, - String localName) - { - this.definition = definition; - this.localName = localName; - } - - public AddMessageCommand - (Definition definition, - String localName, - boolean createPart) - { - this.definition = definition; - this.localName = localName; - this.createPart = createPart; - } - - /* - * Constructor used to create a Message based on the given Message. In essence, this will - * create a copy of the given Message. - */ - public AddMessageCommand(Definition definition, Message originalMessage, String localName, boolean copyPart) { - this.definition = definition; - this.localName = localName; - this.createPart = copyPart; - this.originalMessage = originalMessage; - } - - public void run() - { - message = WSDLFactory.eINSTANCE.createMessage(); - message.setQName(new QName(definition.getTargetNamespace(),localName)); - message.setEnclosingDefinition(definition); - definition.addMessage(message); - - if (originalMessage == null) { - if (createPart) - { - AddPartCommand command = - new AddPartCommand(message,DEFAULT_PART_NAME,WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001,"string",true); - command.run(); - } - } - else { - if (originalMessage.getEParts() != null) { - Iterator it = originalMessage.getEParts().iterator(); - - while (it.hasNext()) { - Part part = (Part) it.next(); - AddPartCommand command; - if (SmartRenameAction.isPartNameGenerated(part.getName(), originalMessage.getQName().getLocalPart())) - command = new AddPartCommand(message, part, NameUtil.buildUniquePartName(message, message.getQName().getLocalPart())); - else - command = new AddPartCommand(message, part, part.getName()); - - - command.run(); - } - } - } - } - - public void setLocalName(String name) - { - this.localName = name; - } - - public WSDLElement getWSDLElement() - { - return message; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageReferenceCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageReferenceCommand.java deleted file mode 100644 index 1ec11ea4f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddMessageReferenceCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.WSDLElement; - -abstract public class AddMessageReferenceCommand extends WSDLElementCommand -{ - protected String name; - protected MessageReference messageReference; - protected Operation operation; - protected boolean createMessage = false; - private final String DEFAULT_MESSAGE_NAME = "NewMessage"; - - public AddMessageReferenceCommand(Operation operation, String name) - { - this.operation = operation; - this.name = name; - } - - public AddMessageReferenceCommand(Operation operation, String name, boolean createMessage) - { - this.operation = operation; - this.name = name; - this.createMessage = createMessage; - } - - protected void createMessage() - { - Definition definition = operation.getEnclosingDefinition(); - AddMessageCommand command = - new AddMessageCommand(definition,DEFAULT_MESSAGE_NAME,createMessage); - command.run(); - messageReference.setEMessage((Message)command.getWSDLElement()); - } - - /* - * Overloaded createMessage(arg) method. Similar to to createMessage() but takes in a MessageReference. - * Method used to create a copy of the original Message (contained in the passed in MessageReference). - */ - protected void createMessage(MessageReference originalMRef, String newMessageRefName) { - Definition definition = operation.getEnclosingDefinition(); - Message tMessage = originalMRef.getEMessage(); - AddMessageCommand command = - new AddMessageCommand(definition, tMessage, newMessageRefName, true); - command.run(); - messageReference.setEMessage((Message)command.getWSDLElement()); - } - - public WSDLElement getWSDLElement() - { - return messageReference; - } - - public void setName(String name) - { - this.name = name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOperationCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOperationCommand.java deleted file mode 100644 index 8059fc2c7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOperationCommand.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; - -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; - - -public final class AddOperationCommand extends WSDLElementCommand -{ - private PortType portType; - private String name; - private Operation operation; - private Operation originalOperation; - private boolean copyInOutFault; - - private boolean createInput = false; - private boolean createOutput = false; - private boolean createFault = false; - - private final String DEFAULT_INPUT_NAME = ""; - private final String DEFAULT_OUTPUT_NAME = ""; - private final String DEFAULT_FAULT_NAME = ""; - - public AddOperationCommand - (PortType portType, - String name) - { - this.portType = portType; - this.name = name; - } - - public AddOperationCommand - (PortType portType, - String name, - boolean createInput, - boolean createOutput, - boolean createFault) - { - this.portType = portType; - this.name = name; - this.createInput = createInput; - this.createOutput = createOutput; - this.createFault = createFault; - } - - /* - * Constructor used to create an Operation based on the given Operation. In essence, this will - * create a copy of the given Operation. - */ - public AddOperationCommand(PortType portType, Operation originalOperation, String name, boolean copyInOutFault) { - this.portType = portType; - this.originalOperation = originalOperation; - this.name = name; - this.copyInOutFault = copyInOutFault; - } - - public void run() - { - operation = WSDLFactory.eINSTANCE.createOperation(); - operation.setName(name); - operation.setEnclosingDefinition(portType.getEnclosingDefinition()); - portType.addOperation(operation); - - if (originalOperation == null) { - WSDLElementCommand command = null; - if (createInput) - { - command = new AddInputCommand(operation,DEFAULT_INPUT_NAME,true); - command.run(); - } - - if (createOutput) - { - command = new AddOutputCommand(operation,DEFAULT_OUTPUT_NAME,true); - command.run(); - } - - if (createFault) - { - command = new AddFaultCommand(operation,DEFAULT_FAULT_NAME,true); - command.run(); - } - } - else { - // Do necessary copying of data from original operation to new operation - // Paramater ordering? Documentation? This part still needs to be worked on - // Copy 'kids' if necessary - if (copyInOutFault) { - WSDLElementCommand command = null; - - if (originalOperation.getEOutput() != null) - { - Output output = originalOperation.getEOutput(); - command = new AddOutputCommand(operation, output, NameUtil.buildUniqueOutputName(portType, operation.getName(), "")); - command.run(); - } - - if (originalOperation.getEInput() != null) - { - Input input = originalOperation.getEInput(); - command = new AddInputCommand(operation, input, NameUtil.buildUniqueInputName(portType, operation.getName(), "")); - command.run(); - } - - if (originalOperation.getEFaults() != null) - { - Iterator it = originalOperation.getEFaults().iterator(); - while (it.hasNext()) { - Fault fault = (Fault) it.next(); - command = new AddFaultCommand(operation, fault, NameUtil.buildUniqueFaultName(originalOperation, fault.getName())); - command.run(); - } - } - - } - } - } - - public WSDLElement getWSDLElement() - { - return operation; - } - - public void setName(String name) - { - this.name = name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOutputCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOutputCommand.java deleted file mode 100644 index 5c57c5831..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddOutputCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; - - -public final class AddOutputCommand extends AddMessageReferenceCommand -{ - private Output originalOutput; - - public AddOutputCommand(Operation operation, String name) - { - super(operation,name); - } - - public AddOutputCommand(Operation operation, String name, boolean createMessage) - { - super(operation,name,createMessage); - } - - /* - * Constructor used to create an Output based on the given Output. In essence, this will - * create a copy of the given Output. - */ - public AddOutputCommand(Operation operation, Output originalOutput, String name) { - super(operation, name, false); - - this.originalOutput = originalOutput; - } - - public void run() - { - messageReference = WSDLFactory.eINSTANCE.createOutput(); -// messageReference.setName(name); - messageReference.setEnclosingDefinition(operation.getEnclosingDefinition()); - operation.setOutput((Output)messageReference); - - // TBD - add binding output - - if (originalOutput == null) { - if (createMessage) - createMessage(); - } - else { - // Do necessary copying of data from original Output to new Output - if (originalOutput.getEMessage() != null) { - String originalMsgName = originalOutput.getEMessage().getQName().getLocalPart(); - - boolean gened = false; - if (originalOutput.eContainer() instanceof Operation) - gened = SmartRenameAction.isMessageNameGenerated(originalMsgName, ((Operation) originalOutput.eContainer()).getName(), "Response"); - - String newMsgName = ""; - if (gened) { - newMsgName = NameUtil.buildUniqueMessageName(operation.getEnclosingDefinition(), messageReference); - } - else { - Definition definition = operation.getEnclosingDefinition(); - Message tMessage = originalOutput.getEMessage(); - newMsgName = NameUtil.buildUniqueMessageName(definition, tMessage.getQName().getLocalPart()); - } - - createMessage(originalOutput, newMsgName); - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPartCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPartCommand.java deleted file mode 100644 index 2ed9d68c2..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPartCommand.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.internal.impl.PartImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; - - -public final class AddPartCommand extends WSDLElementCommand -{ - private Message message; - private String name; - private Part part; - private Part originalPart; - - private QName typeOrElementName; - private boolean useType = true; - - public AddPartCommand - (Message message, - String name) - { - this.message = message; - this.name = name; - } - - public AddPartCommand - (Message message, - String name, - String namespace, - String localName, - boolean useType) - { - this.message = message; - this.name = name; - this.useType = useType; - typeOrElementName = new QName(namespace,localName); - } - - /* - * Constructor used to create a Part based on the given Part. In essence, this will - * create a copy of the given Part. - */ - public AddPartCommand - (Message message, - Part originalPart, - String name) - { - this.message = message; - this.name = name; - this.originalPart = originalPart; - } - - /** - * @deprecated - */ - public AddPartCommand - (Message message, - String name, - String namespace, - String localName) - { - this.message = message; - this.name = name; - typeOrElementName = new QName(namespace,localName); - } - - public void setName(String name) - { - this.name = name; - } - - public WSDLElement getWSDLElement() - { - return part; - } - - public void run() - { - if (typeOrElementName == null) - typeOrElementName = createDefaultTypeName(); - - // Add namespace to the Definitions if it is not there yet. - addNamespaceDeclaration(); - - part = WSDLFactory.eINSTANCE.createPart(); - part.setName(name); - - if (originalPart == null) { - if (useType) - part.setTypeName(typeOrElementName); - else - part.setElementName(typeOrElementName); - } - else { - if (originalPart.getTypeName() != null) - part.setTypeName(originalPart.getTypeName()); - - String newElementName = null; - if (originalPart.getElementName() != null) { - - boolean createNewElement = true; - if (originalPart.getElementDeclaration() != null && originalPart.getElementDeclaration().getElement() != null) { - if (!(originalPart.getElementDeclaration().getElement() instanceof IDOMNode)) { - createNewElement = false; - } - } - - if (createNewElement) { - newElementName = getNewNameHelper(name, originalPart.getEnclosingDefinition(), false); - part.setElementName(new QName(originalPart.getElementName().getNamespaceURI(), newElementName)); - - if (originalPart.getEnclosingDefinition() != null) { - if (newElementName == null) { - newElementName = getNewNameHelper(name, originalPart.getEnclosingDefinition(), false); - } - - AddXSDElementDeclarationCommand elementAction = new AddXSDElementDeclarationCommand(originalPart.getEnclosingDefinition(), newElementName); - elementAction.run(); - } - } - else { - part.setElementName(new QName(originalPart.getElementName().getNamespaceURI(), originalPart.getElementName().getLocalPart())); - } - } - } - - part.setEnclosingDefinition(message.getEnclosingDefinition()); - ((PartImpl)part).reconcileReferences(false); - message.addPart(part); - } - - private void addNamespaceDeclaration() - { - Definition definition = message.getEnclosingDefinition(); - if (!definition.getNamespaces().containsValue(typeOrElementName.getNamespaceURI())) - { - definition.addNamespace("p",typeOrElementName.getNamespaceURI()); - ((WSDLElementImpl)definition).updateElement(false); - } - } - - private QName createDefaultTypeName() - { - QName qname = new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001,"string"); - return qname; - } - - private String getNewNameHelper(String base, Definition def, boolean isType) - { - String name = base; - int count = 0; - - // Ugly.... Redo this... - // Get a list of Elements... - List elementList = null; - if (def.getETypes() != null) { - List xsdsList = def.getETypes().getEExtensibilityElements(); - if (xsdsList != null) { - Iterator xsdsIterator = xsdsList.iterator(); - XSDSchemaExtensibilityElement xsdElement = (XSDSchemaExtensibilityElement) xsdsIterator.next(); - XSDSchema schema = xsdElement.getSchema(); - if (schema != null) { - elementList = schema.getElementDeclarations(); - } - } - } - - if (elementList != null) { - int index = 0; - while (index < elementList.size()) { - XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) elementList.get(index); - - if (name.equals(elementDeclaration.getName())) { - count++; - name = name + count; - index = 0; - } - else { - index++; - } - } - } - - return name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortCommand.java deleted file mode 100644 index a647c5215..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -public final class AddPortCommand extends WSDLElementCommand -{ - private Service service; - private String name; - private Port port; - - public AddPortCommand - (Service service, - String name) - { - this.service = service; - this.name = name; - } - - public void setName(String name) - { - this.name = name; - } - - public WSDLElement getWSDLElement() - { - return port; - } - - public void run() - { - port = WSDLFactory.eINSTANCE.createPort(); - port.setName(name); - port.setEnclosingDefinition(service.getEnclosingDefinition()); - service.addPort(port); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortTypeCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortTypeCommand.java deleted file mode 100644 index 5eb4d5a15..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddPortTypeCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - - -public final class AddPortTypeCommand extends WSDLElementCommand -{ - private Definition definition; - private String localName; - private PortType portType; - - private boolean createOperation = false; - private final String DEFAULT_OPERATION_NAME = "NewOperation"; - - public AddPortTypeCommand - (Definition definition, - String localName) - { - this.definition = definition; - this.localName = localName; - } - - public AddPortTypeCommand - (Definition definition, - String localName, - boolean createOperation) - { - this.definition = definition; - this.localName = localName; - this.createOperation = createOperation; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.ui.internal.commands.WSDLElementAction#getWSDLElement() - */ - public WSDLElement getWSDLElement() - { - return portType; - } - - public void run() - { - portType = WSDLFactory.eINSTANCE.createPortType(); - portType.setQName(new QName(definition.getTargetNamespace(),localName)); - portType.setEnclosingDefinition(definition); - definition.addPortType(portType); - - if (createOperation) - { - AddOperationCommand command = - new AddOperationCommand(portType,DEFAULT_OPERATION_NAME,true,true,false); - command.run(); - } - } - - public void setLocalName(String name) - { - localName = name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddServiceCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddServiceCommand.java deleted file mode 100644 index d9fed45f7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddServiceCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - - -public final class AddServiceCommand extends WSDLElementCommand -{ - private Definition definition; - private String localName; - private Service service; - - private boolean createPort = false; - private final String DEFAULT_PORT_NAME = "NewPort"; - - public AddServiceCommand - (Definition definition, - String localName) - { - this.definition = definition; - this.localName = localName; - } - - public AddServiceCommand - (Definition definition, - String localName, - boolean createPort) - { - this.definition = definition; - this.localName = localName; - this.createPort = createPort; - } - - public WSDLElement getWSDLElement() - { - return service; - } - - public void run() - { - service = WSDLFactory.eINSTANCE.createService(); - service.setQName(new QName(definition.getTargetNamespace(),localName)); - service.setEnclosingDefinition(definition); - definition.addService(service); - - if (createPort) - { - AddPortCommand command = - new AddPortCommand(service,DEFAULT_PORT_NAME); - command.run(); - } - } - - public void setLocalName(String name) - { - localName = name; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddTypesCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddTypesCommand.java deleted file mode 100644 index b568fd150..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddTypesCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; - -// Definition must not have "types" element to run this command. -public final class AddTypesCommand extends WSDLElementCommand -{ - private Definition definition; - private Types types; - - public AddTypesCommand(Definition definition) - { - this.definition = definition; - } - - public void run() - { - if ((types = definition.getETypes()) != null) - return; // "types" already exists. - - types = WSDLFactory.eINSTANCE.createTypes(); - types.setEnclosingDefinition(definition); - definition.setTypes(types); - } - - public WSDLElement getWSDLElement() - { - return types; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddUnknownExtensibilityElementCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddUnknownExtensibilityElementCommand.java deleted file mode 100644 index ab3352dba..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddUnknownExtensibilityElementCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.ExtensibleElement; -import org.eclipse.wst.wsdl.UnknownExtensibilityElement; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.internal.impl.UnknownExtensibilityElementImpl; - -public final class AddUnknownExtensibilityElementCommand extends WSDLElementCommand -{ - private ExtensibleElement extensibleElement; - private String namespaceURI; - private String localName; - private UnknownExtensibilityElement extensibilityElement; - private Map properties; - - public AddUnknownExtensibilityElementCommand - (ExtensibleElement extensibleElement, - String namespaceURI, - String localName) - { - this.extensibleElement = extensibleElement; - this.namespaceURI = namespaceURI; - this.localName = localName; - } - - public AddUnknownExtensibilityElementCommand - (ExtensibleElement extensibleElement, - String namespaceURI, - String localName, - Map properties) - { - this.extensibleElement = extensibleElement; - this.namespaceURI = namespaceURI; - this.localName = localName; - this.properties = properties; - } - - public WSDLElement getWSDLElement() - { - return extensibilityElement; - } - - public void run() - { - extensibilityElement = WSDLFactory.eINSTANCE.createUnknownExtensibilityElement(); - extensibilityElement.setElementType(new QName(namespaceURI,localName)); - - if (properties != null) - { - Iterator iterator = properties.entrySet().iterator(); - Map.Entry entry = null; - while (iterator.hasNext()) - { - entry = (Map.Entry)iterator.next(); - String attribute = (String)entry.getKey(); - String value = (String)entry.getValue(); - ((UnknownExtensibilityElementImpl)extensibilityElement).setAttribute(attribute,value); - } - } - - extensibilityElement.setEnclosingDefinition(extensibleElement.getEnclosingDefinition()); - extensibleElement.addExtensibilityElement(extensibilityElement); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDElementDeclarationCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDElementDeclarationCommand.java deleted file mode 100644 index 5fce11ee8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDElementDeclarationCommand.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - - -// This class is used to create a new XSDElementDeclaration in the targetNamespace. -public final class AddXSDElementDeclarationCommand extends WSDLElementCommand -{ - private Definition definition; - private String targetNamespace; - private String elementName; - private XSDSchema schema; - private XSDElementDeclaration xsdElement; - - /** - * TODO: - * We have a potential problem here.... What if the definition targetnamespace is null.... - */ - public AddXSDElementDeclarationCommand(Definition definition, String elementName) - { - this.definition = definition; - this.targetNamespace = definition.getTargetNamespace(); - this.elementName = elementName; - } - - /** - * @deprecated - * Use AddXSDElementDeclarationCommand(Definition definition, String typeName) - */ - public AddXSDElementDeclarationCommand - (Definition definition, - String targetNamespace, - String elementName) - { - this.definition = definition; - this.targetNamespace = targetNamespace; - this.elementName = elementName; - } - - public void run() - { - XSDSchema xsdSchema = getSchema(); - XSDElementDeclaration elementDecl = - XSDFactory.eINSTANCE.createXSDElementDeclaration(); - elementDecl.setName(elementName); - - XSDSimpleTypeDefinition simpleTypeDefinition = getXSDStringType(xsdSchema); - elementDecl.setTypeDefinition(simpleTypeDefinition); - xsdSchema.getContents().add(elementDecl); - - xsdElement = elementDecl; - } - - public void run(String newElementName) { - elementName = newElementName; - run(); - } - - /* - * Specify which Schema to use when creating the Type. - * Call this method before calling run(). Otherwise it will use the first - * Schema it finds. - */ - public void setSchema(XSDSchema schema) { - this.schema = schema; - } - - /* - * Return the Schema used to create the Type - */ - public XSDSchema getSchema() { - if (schema == null) { - return getXSDSchema(targetNamespace); - } - else { - return schema; - } - } - - private XSDSimpleTypeDefinition getXSDStringType(XSDSchema schema) - { - return schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"); - } - - private XSDSchema getXSDSchema(String targetNamespace) - { - XSDSchema xsdSchema; - - // Do we have a schema already? - Iterator iterator = getTypes().getSchemas(targetNamespace).iterator(); - if (iterator.hasNext()) - { - xsdSchema = (XSDSchema)iterator.next(); // Get the first one. - return xsdSchema; - } - else - { - // Create a new schema because there's none. - AddXSDSchemaCommand command = new AddXSDSchemaCommand(definition,targetNamespace); - command.run(); - return ((XSDSchemaExtensibilityElement)command.getWSDLElement()).getSchema(); - } - } - - private Types getTypes() - { - // Types is created if it does not exist yet. - Types types = (Types)definition.getTypes(); - if (types != null) - return types; - else - { - AddTypesCommand command = new AddTypesCommand(definition); - command.run(); - return (Types)command.getWSDLElement(); - } - } - - public WSDLElement getWSDLElement() - { - return null; - } - - public XSDElementDeclaration getXSDElement() - { - return xsdElement; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDSchemaCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDSchemaCommand.java deleted file mode 100644 index 73bd1fdf8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDSchemaCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; - - - -public final class AddXSDSchemaCommand extends WSDLElementCommand -{ - private Definition definition; - private XSDSchemaExtensibilityElement extensibilityElement; - private String targetNamespace; - - public AddXSDSchemaCommand(Definition definition) - { - this.definition = definition; - this.targetNamespace = definition.getTargetNamespace(); - } - - public AddXSDSchemaCommand(Definition definition, String targetNamespace) - { - this.definition = definition; - this.targetNamespace = targetNamespace; - } - - public void run() - { - extensibilityElement = WSDLFactory.eINSTANCE.createXSDSchemaExtensibilityElement(); - extensibilityElement.setEnclosingDefinition(definition); - - XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema(); - xsdSchema.setSchemaForSchemaQNamePrefix("xsd"); - xsdSchema.setTargetNamespace(targetNamespace); - // Choose the prefix Choose the prefix used for this schema's namespace and the schema for schema's namespace. - // - java.util.Map qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap(); -// qNamePrefixToNamespaceMap.put("p", xsdSchema.getTargetNamespace()); - qNamePrefixToNamespaceMap.put - (xsdSchema.getSchemaForSchemaQNamePrefix(),org.eclipse.xsd.util.XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); - extensibilityElement.setSchema(xsdSchema); - - // TBD - Check if multiple schemas with the same targetNamespace can co-exist. - Types types = getTypes(); - types.addExtensibilityElement(extensibilityElement); - } - - private Types getTypes() - { - // Types is created if it does not exist. - Types types = (Types)definition.getTypes(); - if (types != null) - return types; - else - { - AddTypesCommand command = new AddTypesCommand(definition); - command.run(); - return (Types)command.getWSDLElement(); - } - } - - public WSDLElement getWSDLElement() - { - return extensibilityElement; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDTypeDefinitionCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDTypeDefinitionCommand.java deleted file mode 100644 index e0ec076c1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/AddXSDTypeDefinitionCommand.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import java.util.Iterator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; - -// This class is used to create a new XSDTypeDefinition in the targetNamespace. -public final class AddXSDTypeDefinitionCommand extends WSDLElementCommand -{ - private Definition definition; - private String targetNamespace; - private String typeName; - private XSDSchema schema; - private XSDTypeDefinition xsdType; - private boolean isComplexType = true; - - /** - * TODO: - * We have a potential problem here.... What if the definition targetnamespace is null.... - */ - public AddXSDTypeDefinitionCommand(Definition definition, String typeName) - { - this.definition = definition; - this.targetNamespace = definition.getTargetNamespace(); - this.typeName = typeName; - } - - public AddXSDTypeDefinitionCommand(Definition definition, String typeName, boolean isComplexType) - { - this(definition, typeName); - this.isComplexType = isComplexType; - } - - /** - * @deprecated - * Use AddXSDTypeDefinitionCommand(Definition definition, String typeName) - */ - public AddXSDTypeDefinitionCommand - (Definition definition, - String targetNamespace, - String typeName) - { - this.definition = definition; - this.targetNamespace = targetNamespace; - this.typeName = typeName; - } - - public void run() - { - XSDSchema xsdSchema = getSchema(); - XSDTypeDefinition typeDef; - - if (isComplexType) { - typeDef = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - } - else { - typeDef = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - } - - typeDef.setName(typeName); - xsdSchema.getContents().add(typeDef); - - xsdType = typeDef; - } - - public void run(String newTypeName) { - typeName = newTypeName; - run(); - } - - /* - * Specifiy if we should create a complex or simple type. This should should be - * called before run(). - * Overrides the value set when the constructor - * AddXSDTypeDefinitionCommand(Definition definition, String typeName, boolean isComplexType) - * is used. - */ - public void isComplexType(boolean isComplexType) { - this.isComplexType = isComplexType; - } - - /* - * Specify which Schema to use when creating the Type. - * Call this method before calling run(). Otherwise it will use the first - * Schema it finds. - */ - public void setSchema(XSDSchema schema) { - this.schema = schema; - } - - /* - * Return the Schema used to create the Type - */ - public XSDSchema getSchema() { - if (schema == null) { - return getXSDSchema(targetNamespace); - } - else { - return schema; - } - } - - private XSDSchema getXSDSchema(String targetNamespace) - { - XSDSchema xsdSchema; - - // Do we have a schema already? - Iterator iterator = getTypes().getSchemas(targetNamespace).iterator(); - if (iterator.hasNext()) - { - xsdSchema = (XSDSchema)iterator.next(); // Get the first one. - return xsdSchema; - } - else - { - // Create a new schema because there's none. - AddXSDSchemaCommand command = new AddXSDSchemaCommand(definition,targetNamespace); - command.run(); - return ((XSDSchemaExtensibilityElement)command.getWSDLElement()).getSchema(); - } - } - - private Types getTypes() - { - // Types is created if it does not exist yet. - Types types = (Types)definition.getTypes(); - if (types != null) - return types; - else - { - AddTypesCommand command = new AddTypesCommand(definition); - command.run(); - return (Types)command.getWSDLElement(); - } - } - - public WSDLElement getWSDLElement() - { - return null; - } - - public XSDTypeDefinition getXSDElement() - { - return xsdType; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/WSDLElementCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/WSDLElementCommand.java deleted file mode 100644 index 3fc9c24b9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/commands/WSDLElementCommand.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.commands; - -import org.eclipse.wst.wsdl.WSDLElement; - -public abstract class WSDLElementCommand -{ - public abstract WSDLElement getWSDLElement(); - public abstract void run(); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ContentGenerator.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ContentGenerator.java deleted file mode 100644 index ff3bfc750..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ContentGenerator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.w3c.dom.Element; - - - -public interface ContentGenerator -{ - - public static String ADDRESS_LOCATION = "http://tempuri.org/"; - public void init(Definition definition, Object generator, Object[] options); - - public String[] getRequiredNamespaces(); - - public String[] getPreferredNamespacePrefixes(); - - // generates the 'address' extensiblity element for a port - // - public void generatePortContent(Element portElement, Port port); - - public void generateBindingContent(Element bindingElement, PortType portType); - - public void generateBindingOperationContent(Element bindingOperationElement, Operation operation); - - public void generateBindingInputContent(Element bindingInputElement, Input input); - - public void generateBindingOutputContent(Element bindingOutputElement, Output output); - - public void generateBindingFaultContent(Element bindingFaultElement, Fault fault); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/HttpContentGenerator.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/HttpContentGenerator.java deleted file mode 100644 index 3599cef78..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/HttpContentGenerator.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.w3c.dom.Element; - - -public class HttpContentGenerator implements ContentGenerator -{ - protected Definition definition; - protected boolean isPost; - protected String addressLocation = ContentGenerator.ADDRESS_LOCATION; - - protected final static String[] requiredNamespaces = { "http://schemas.xmlsoap.org/wsdl/mime/", "http://schemas.xmlsoap.org/wsdl/http/" }; - protected final static String[] preferredNamespacePrefixes = { "mime", "http" }; - - public void init(Definition definition, Object generator, Object[] options) - { - this.definition = definition; - - if (options != null) - { - if (options.length > 0 && options[0] != null) - { - Boolean isPostOption = (Boolean) options[0]; - isPost = isPostOption.booleanValue(); - } - if (options.length > 1 && options[1] != null) - { - addressLocation = (String) options[1]; - } - } - } - - public String[] getRequiredNamespaces() - { - return requiredNamespaces; - } - - public String[] getPreferredNamespacePrefixes() - { - return preferredNamespacePrefixes; - } - - public void generatePortContent(Element portElement, Port port) - { - Element element = createElement(portElement, "http", "address"); - element.setAttribute("location", addressLocation); - } - - public void generateBindingContent(Element bindingElement, PortType portType) - { - Element element = createElement(bindingElement, "http", "binding"); - element.setAttribute("verb", isPost ? "POST" : "GET"); - } - - public void generateBindingOperationContent(Element bindingOperationElement, Operation operation) - { - Element element = createElement(bindingOperationElement, "http", "operation"); - element.setAttribute("location", "/" + operation.getName()); - } - - public void generateBindingInputContent(Element bindingInputElement, Input input) - { - if (isPost) - { - Element element = createElement(bindingInputElement, "mime", "content"); - element.setAttribute("type", "application/x-www-form-urlencoded"); - } - else - { - createElement(bindingInputElement, "http", "urlEncoded"); - } - } - - public void generateBindingOutputContent(Element bindingOutputElement, Output output) - { - Element element = createElement(bindingOutputElement, "mime", "content"); - element.setAttribute("type", "text/xml"); - } - - public void generateBindingFaultContent(Element bindingFaultElement, Fault fault) - { - //TODO!! - } - - protected Element createElement(Element parentElement, String prefix, String elementName) - { - String name = prefix != null ? (prefix + ":" + elementName) : elementName; - Element result = parentElement.getOwnerDocument().createElement(name); - parentElement.appendChild(result); - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/SoapContentGenerator.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/SoapContentGenerator.java deleted file mode 100644 index d928c338a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/SoapContentGenerator.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.w3c.dom.Element; - - -public class SoapContentGenerator implements ContentGenerator -{ - private final int DOCUMENT_LITERAL = 1; - private final int RPC_LITERAL = 2; - private final int RPC_ENCODED = 3; - - protected int bindingOption = DOCUMENT_LITERAL; - protected String namespaceValue = ""; - protected String addressLocation = ContentGenerator.ADDRESS_LOCATION; - protected Definition definition; - - protected final static String[] requiredNamespaces = {"http://schemas.xmlsoap.org/wsdl/soap/"}; - protected final static String[] preferredNamespacePrefixes = {"soap"}; - - - public void init(Definition definition, Object generator, Object[] options) - { - this.definition = definition; - - if (options != null) - { - bindingOption = computeBindingOption(options); - - if (options.length > 1 && options[1] != null) - { - addressLocation = (String)options[1]; - } - } - if (definition.getTargetNamespace() != null) - { - namespaceValue = definition.getTargetNamespace(); - } - } - - private int computeBindingOption(Object[] options) { - int option = DOCUMENT_LITERAL; - if (options.length > 0 && options[0] != null) - { - boolean isDocumentLiteralOption = ((Boolean)options[0]).booleanValue(); - if (isDocumentLiteralOption) - option = DOCUMENT_LITERAL; - else - option = RPC_ENCODED; - - if (options.length >= 3 && options[2] != null) { - // Extra info sent in - if (((Boolean)options[2]).booleanValue()) - option = RPC_LITERAL; - } - } - - return option; - } - - public String[] getRequiredNamespaces() - { - return requiredNamespaces; - } - - public String[] getPreferredNamespacePrefixes() - { - return preferredNamespacePrefixes; - } - - public void generatePortContent(Element portElement, Port port) - { - Element element = createElement(portElement, "soap", "address"); - element.setAttribute("location", addressLocation); - } - - public void generateBindingContent(Element bindingElement, PortType portType) - { - Element element = createElement(bindingElement, "soap", "binding"); - element.setAttribute("style", (bindingOption == DOCUMENT_LITERAL) ? "document" : "rpc"); - element.setAttribute("transport", "http://schemas.xmlsoap.org/soap/http"); - } - - public void generateBindingOperationContent(Element bindingOperationElement, Operation operation) - { - Element element = createElement(bindingOperationElement, "soap", "operation"); - - String soapActionValue = namespaceValue; - if (!soapActionValue.endsWith("/")) - { - soapActionValue += "/"; - } - soapActionValue += operation.getName(); - element.setAttribute("soapAction", soapActionValue); - } - - public void generateBindingInputContent(Element bindingInputElement, Input input) - { - generateSoapBody(bindingInputElement); - } - - public void generateBindingOutputContent(Element bindingOutputElement, Output output) - { - generateSoapBody(bindingOutputElement); - } - - public void generateBindingFaultContent(Element bindingFaultElement, Fault fault) - { - Element element = createElement(bindingFaultElement, "soap", "fault"); - element.setAttribute("name", fault.getName()); - element.setAttribute("use", (bindingOption == RPC_ENCODED) ? "encoded" : "literal"); - if (bindingOption == RPC_ENCODED) - { - element.setAttribute("encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/"); - element.setAttribute("namespace", namespaceValue); - } - else if (bindingOption == RPC_LITERAL) { - element.setAttribute("namespace", namespaceValue); - } - } - - protected void generateSoapBody(Element parentElement) - { - Element element = createElement(parentElement, "soap", "body"); - element.setAttribute("use", (bindingOption == RPC_ENCODED) ? "encoded" : "literal"); - if (bindingOption == RPC_ENCODED) - { - element.setAttribute("encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/"); - element.setAttribute("namespace", namespaceValue); - } - else if (bindingOption == RPC_LITERAL) { - element.setAttribute("namespace", namespaceValue); - } - } - - protected Element createElement(Element parentElement, String prefix, String elementName) - { - String name = prefix != null ? (prefix + ":" + elementName) : elementName; - Element result = parentElement.getOwnerDocument().createElement(name); - parentElement.appendChild(result); - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/ContentGeneratorOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/ContentGeneratorOptionsPage.java deleted file mode 100644 index bca40e98d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/ContentGeneratorOptionsPage.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; - -public interface ContentGeneratorOptionsPage -{ - public void init(BaseGenerator baseGenerator); - public Composite createControl(Composite parent); - public Composite getControl(); - - // TODO can this go into init? - // - public void setOptionsOnGenerator(); - public boolean isOverwriteApplicable(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpBindingOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpBindingOptionsPage.java deleted file mode 100644 index 1e355e35d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpBindingOptionsPage.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibilityElement; -import org.eclipse.wst.wsdl.binding.http.internal.generator.HTTPContentGenerator; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - - -public class HttpBindingOptionsPage implements ContentGeneratorOptionsPage, SelectionListener -{ - protected Button getButton; - protected Button postButton; - protected Composite control; - protected BaseGenerator generator; - protected HTTPContentGenerator httpGenerator; - - public HttpBindingOptionsPage() - { - } - - public void init(BaseGenerator generator) - { - this.generator = generator; - if (generator.getContentGenerator() instanceof HTTPContentGenerator) { - httpGenerator = (HTTPContentGenerator) generator.getContentGenerator(); - } - } - - public Composite createControl(Composite parent) - { - control = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - control.setLayout(layout); - - Label separator = new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - - separator.setLayoutData(gd); - - Label optionsHeading = new Label(control, SWT.NONE); - optionsHeading.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_HTTP_BINDING_OPTIONS")); - - getButton = new Button(control, SWT.RADIO); - getButton.setText("HTTP GET"); - getButton.setSelection(true); - - postButton = new Button(control, SWT.RADIO); - postButton.setText("HTTP POST"); - - if (generator.getName() != null) - { - Definition definition = generator.getDefinition(); - QName qname = new QName(definition.getTargetNamespace(), generator.getName()); - Binding binding = (Binding) definition.getBinding(qname); - if (binding != null) - { - List eeList = binding.getEExtensibilityElements(); - if (eeList.size() > 0) - { - ExtensibilityElement ee = (ExtensibilityElement) eeList.get(0); - Element element = WSDLEditorUtil.getInstance().getElementForObject(ee); - String verb = element.getAttribute("verb"); - if ("POST".equals(verb)) - { - getButton.setSelection(false); - postButton.setSelection(true); - } - } - } - } - - postButton.addSelectionListener(this); - getButton.addSelectionListener(this); - computeOptions(); - - return control; - } - - public Composite getControl() { - return control; - } - - public boolean isOverwriteApplicable() - { - return true; - } - - public void widgetSelected(SelectionEvent event) - { - computeOptions(); - } - - protected void computeOptions() - { - if (generator.getContentGenerator() instanceof HTTPContentGenerator) { - HTTPContentGenerator httpGenerator = (HTTPContentGenerator) generator.getContentGenerator(); - - if (postButton.getSelection()) { - httpGenerator.setVerb(HTTPContentGenerator.VERB_POST); - } - else if (getButton.getSelection()) { - httpGenerator.setVerb(HTTPContentGenerator.VERB_GET); - } - } - } - - public void setOptionsOnGenerator() { - computeOptions(); - } - - public void widgetDefaultSelected(SelectionEvent event) - { - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpPortOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpPortOptionsPage.java deleted file mode 100644 index 28ea27ac4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/HttpPortOptionsPage.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.wsdl.binding.http.internal.generator.HTTPContentGenerator; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -public class HttpPortOptionsPage implements ContentGeneratorOptionsPage, ModifyListener -{ - protected Text addressField; - protected Composite control; - protected BaseGenerator generator; - - public HttpPortOptionsPage() - { - } - - public void init(BaseGenerator generator) - { - this.generator = generator; - } - - public Composite createControl(Composite parent) - { - control = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - control.setLayout(layout); - control.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label separator = new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - separator.setLayoutData(gd); - - Label optionsHeading = new Label(control, SWT.NONE); - optionsHeading.setText(WSDLEditorPlugin.getWSDLString("_UI_HTTP_PORT_DETAILS")); - - Composite nameValueGroup = new Composite(control, SWT.NONE); - nameValueGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout2 = new GridLayout(2, false); - layout2.marginWidth = 0; - nameValueGroup.setLayout(layout2); - - Label addressLabel = new Label(nameValueGroup, SWT.NONE); - addressLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LOCATION") + " "); - addressField = new Text(nameValueGroup, SWT.BORDER); - addressField.setText("http://example.com/"); - addressField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - addressField.addModifyListener(this); - - return control; - } - - public boolean isOverwriteApplicable() - { - return false; - } - - public void modifyText(ModifyEvent e) - { - computeOptions(); - } - - private void computeOptions() { - if (generator.getContentGenerator() instanceof HTTPContentGenerator) { - ((HTTPContentGenerator) generator.getContentGenerator()).setAddressLocation(addressField.getText()); - } - } - - public void setOptionsOnGenerator() { - computeOptions(); - } - - public Composite getControl() { - return control; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapBindingOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapBindingOptionsPage.java deleted file mode 100644 index a9e32d253..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapBindingOptionsPage.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibilityElement; -import org.eclipse.wst.wsdl.binding.soap.internal.generator.SOAPContentGenerator; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - - -public class SoapBindingOptionsPage implements ContentGeneratorOptionsPage, SelectionListener -{ - protected Button docLiteral; - protected Button rpcLiteral; - protected Button rpcEncoded; - protected Composite control; - protected BaseGenerator generator; - - public SoapBindingOptionsPage() - { - } - - public void init(BaseGenerator generator) - { - this.generator = generator; - } - - public Composite createControl(Composite parent) - { - control = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - control.setLayout(layout); - - Label separator = new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - separator.setLayoutData(gd); - - Label optionsHeading = new Label(control, SWT.NONE); - optionsHeading.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_SOAP_BINDING_OPTIONS")); - - docLiteral = new Button(control, SWT.RADIO); - docLiteral.setText(WSDLEditorPlugin.getWSDLString("_UI_RADIO_DOCUMENT_LITERAL")); - docLiteral.setSelection(true); - - rpcLiteral = new Button(control, SWT.RADIO); - rpcLiteral.setText(WSDLEditorPlugin.getWSDLString("_UI_RADIO_RPC_LITERAL")); - - rpcEncoded = new Button(control, SWT.RADIO); - rpcEncoded.setText(WSDLEditorPlugin.getWSDLString("_UI_RADIO_RPC_ENCODED")); - - if (generator.getName() != null) - { - Definition definition = generator.getDefinition(); - QName qname = new QName(definition.getTargetNamespace(), generator.getName()); - Binding binding = (Binding) definition.getBinding(qname); - - if (binding != null) - { - List eeList = binding.getEExtensibilityElements(); - if (eeList.size() > 0) - { - ExtensibilityElement ee = (ExtensibilityElement) eeList.get(0); - - Element element = WSDLEditorUtil.getInstance().getElementForObject(ee); - String style = element.getAttribute("style"); - - if ("rpc".equals(style)) - { - // Try to determine if it's RPC Literal or RPC Encoded - String use = "encoded"; - List operations = binding.getEBindingOperations(); - if (operations.size() > 0) { - element = null; - BindingOperation operation = (BindingOperation) operations.get(0); - if (operation.getEBindingInput() != null && operation.getEBindingInput().getEExtensibilityElements().size() > 0) { - Object object = operation.getEBindingInput().getEExtensibilityElements().get(0); - element = WSDLEditorUtil.getInstance().getElementForObject(object); - } - else if (operation.getEBindingOutput() != null && operation.getEBindingOutput().getEExtensibilityElements().size() > 0) { - Object object = operation.getEBindingOutput().getEExtensibilityElements().get(0); - element = WSDLEditorUtil.getInstance().getElementForObject(object); - } - else if (operation.getEBindingFaults().size() > 0) { - BindingFault fault = (BindingFault) operation.getEBindingFaults().get(0); - List faultEE = fault.getExtensibilityElements(); - - if (faultEE.size() > 0) { - element = WSDLEditorUtil.getInstance().getElementForObject(faultEE.get(0)); - } - } - - if (element != null) { - use = element.getAttribute("use"); - } - } - - if (use != null && "literal".equals(use)) { - docLiteral.setSelection(false); - rpcLiteral.setSelection(true); - rpcEncoded.setSelection(false); - } - else { - docLiteral.setSelection(false); - rpcLiteral.setSelection(false); - rpcEncoded.setSelection(true); - } - } - } - } - } - - docLiteral.addSelectionListener(this); - rpcLiteral.addSelectionListener(this); - rpcEncoded.addSelectionListener(this); - computeOptions(); - - return control; - } - - public Composite getControl() { - return control; - } - - public boolean isOverwriteApplicable() - { - return true; - } - - public void widgetSelected(SelectionEvent event) - { - computeOptions(); - } - - protected void computeOptions() - { - if (generator.getContentGenerator() instanceof SOAPContentGenerator) { - SOAPContentGenerator soapGenerator = (SOAPContentGenerator) generator.getContentGenerator(); - if (docLiteral.getSelection()) { - soapGenerator.setStyle(SOAPContentGenerator.STYLE_DOCUMENT); - soapGenerator.setUse(SOAPContentGenerator.USE_LITERAL); - } - else if (rpcLiteral.getSelection()) { - soapGenerator.setStyle(SOAPContentGenerator.STYLE_RPC); - soapGenerator.setUse(SOAPContentGenerator.USE_LITERAL); - } - else if (rpcEncoded.getSelection()) { - soapGenerator.setStyle(SOAPContentGenerator.STYLE_RPC); - soapGenerator.setUse(SOAPContentGenerator.USE_ENCODED); - } - } - } - - public void setOptionsOnGenerator() { - computeOptions(); - } - - public void widgetDefaultSelected(SelectionEvent event) - { - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapPortOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapPortOptionsPage.java deleted file mode 100644 index 137394f27..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/contentgenerator/ui/SoapPortOptionsPage.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.wsdl.binding.soap.internal.generator.SOAPContentGenerator; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -public class SoapPortOptionsPage implements ContentGeneratorOptionsPage, ModifyListener -{ - protected Text addressField; - protected Composite control; - protected BaseGenerator generator; - - public SoapPortOptionsPage() - { - } - - public void init(BaseGenerator generator) - { - this.generator = generator; - } - - public Composite createControl(Composite parent) - { - control = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - control.setLayout(layout); - control.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label separator = new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - separator.setLayoutData(gd); - - Label optionsHeading = new Label(control, SWT.NONE); - optionsHeading.setText(WSDLEditorPlugin.getWSDLString("_UI_SOAP_PORT_DETAILS")); - - Composite nameValueGroup = new Composite(control, SWT.NONE); - nameValueGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout2 = new GridLayout(2, false); - layout2.marginWidth = 0; - nameValueGroup.setLayout(layout2); - - Label addressLabel = new Label(nameValueGroup, SWT.NONE); - addressLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LOCATION") + " "); - addressField = new Text(nameValueGroup, SWT.BORDER); - addressField.setText("http://example.com/"); - addressField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - addressField.addModifyListener(this); - - return control; - } - - public boolean isOverwriteApplicable() - { - return false; - } - - public void modifyText(ModifyEvent e) - { - computeOptions(); - } - - private void computeOptions() { - if (generator.getContentGenerator() instanceof SOAPContentGenerator) { - ((SOAPContentGenerator) generator.getContentGenerator()).setAddressLocation(addressField.getText()); - } - } - - public void setOptionsOnGenerator() { - computeOptions(); - } - - public Composite getControl() { - return control; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/GenerateBindingOnSaveDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/GenerateBindingOnSaveDialog.java deleted file mode 100644 index 23634b902..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/GenerateBindingOnSaveDialog.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class GenerateBindingOnSaveDialog extends MessageDialog implements SelectionListener { - private static String dialogTitle = "Regenerate Bindings On Save"; // TODO: Translations needed.... - private static String dialogMessage = "Regenerate Bindings On Save?"; - private static String[] buttons = new String[]{"Yes", "No", "Cancel"}; - - private Button rememberDecisionBox; - private boolean rememberDecision = false; - - public GenerateBindingOnSaveDialog(Shell shell) { - super(shell, dialogTitle, null, dialogMessage, MessageDialog.QUESTION, buttons, 0); - } - - - protected Control createCustomArea(Composite parent) { - Composite comp = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - comp.setLayout(layout); - comp.setData(new GridData()); - - // Spacer - new Label(comp, SWT.NONE); - new Label(comp, SWT.NONE); - - rememberDecisionBox = new Button(comp, SWT.CHECK); - rememberDecisionBox.setText("Remember my decision"); // TODO: Externalize... - rememberDecisionBox.addSelectionListener(this); - - return parent; - } - - private void storePromptPreference(int swtValue) { - // Store the new preference for displaying this dialog. - if (rememberDecision) { - WSDLEditorPlugin.getInstance().getPluginPreferences().setValue("Prompt Regenerate Binding on save", false); - - String generateID = WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_AUTO_REGENERATE_BINDING"); - if (swtValue == SWT.YES) { - WSDLEditorPlugin.getInstance().getPluginPreferences().setValue(generateID, true); - } - else if (swtValue == SWT.NO) { - WSDLEditorPlugin.getInstance().getPluginPreferences().setValue(generateID, false); - } - } - } - - public int open() { - int rValue = super.open(); - - if (rValue ==0) { - storePromptPreference(SWT.YES); - return SWT.YES; - } - else if (rValue == 1) { - storePromptPreference(SWT.NO); - return SWT.NO; - } - else if (rValue == 2) { - storePromptPreference(SWT.CANCEL); - return SWT.CANCEL; - } - - return rValue; - } - - public void widgetSelected(SelectionEvent e) { - if (e.widget == rememberDecisionBox) { - rememberDecision = rememberDecisionBox.getSelection(); - } - } - - public void widgetDefaultSelected(SelectionEvent e) {} -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/ImportAddResourceListener.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/ImportAddResourceListener.java deleted file mode 100644 index b696cad54..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/ImportAddResourceListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs; - -import java.util.Collection; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; - -public class ImportAddResourceListener implements IResourceChangeListener, IResourceDeltaVisitor -{ - Vector importedFiles; - - ImportAddResourceListener() - { - importedFiles = new Vector(); - } - - public void resourceChanged(IResourceChangeEvent event) - { - IResourceDelta resourceDelta = event.getDelta(); - - try - { - if (resourceDelta != null) - { - resourceDelta.accept(this); - } - } - catch (Exception e) - { -// B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception caught during resource change" + e); -// B2BGUIPlugin.getPlugin().getMsgLogger().writeCurrentThread(); - } - } - - public boolean visit(IResourceDelta delta) - { - if (delta.getKind() == IResourceDelta.ADDED) - { - if (delta.getResource() instanceof IFile) - importedFiles.add(delta.getResource()); - } - return true; - } - - public Collection getImportedFiles() - { - return importedFiles; - } - - // This returns the first imported file in the list of imported files - public IFile getImportedFile() - { - if (importedFiles.isEmpty() == false) - return (IFile)importedFiles.firstElement(); - - return null; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/InvokeSetDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/InvokeSetDialog.java deleted file mode 100644 index ba1e63027..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/InvokeSetDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.dialogs.types.WSDLComponentSelectionDialog; -import org.eclipse.wst.wsdl.ui.internal.dialogs.types.WSDLComponentSelectionProvider; -import org.eclipse.wst.wsdl.ui.internal.dialogs.types.WSDLSetComponentHelper; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; - -public class InvokeSetDialog -{ - String kind; - String newValue = ""; - - public void setReferenceKind(String kind) - { - this.kind = kind; - } - - public String getValue() - { - return newValue; - } - - public void run(Object input, IEditorPart editorPart) - { - WSDLComponentSelectionDialog dialog = null; - Shell shell = Display.getCurrent().getActiveShell(); - IFile iFile = ((IFileEditorInput) editorPart.getEditorInput()).getFile(); - Definition definition = ((WSDLElement) input).getEnclosingDefinition(); - String property = ""; - - if (input instanceof Binding) - { - String dialogTitle = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_PORTTYPE"); - - WSDLComponentSelectionProvider provider = new WSDLComponentSelectionProvider(iFile, definition, WSDLConstants.PORT_TYPE); - dialog = new WSDLComponentSelectionDialog(shell, dialogTitle, provider); - provider.setDialog(dialog); - property = "type"; - } - else if (input instanceof Port) - { - String dialogTitle = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_BINDING"); - - WSDLComponentSelectionProvider provider = new WSDLComponentSelectionProvider(iFile, definition, WSDLConstants.BINDING); - dialog = new WSDLComponentSelectionDialog(shell, dialogTitle, provider); - provider.setDialog(dialog); - property = "binding"; - } - else if (input instanceof Part) - { - List validExtensions = new ArrayList(2); - validExtensions.add("wsdl"); - validExtensions.add("xsd"); - WSDLComponentSelectionProvider provider = null; - if (kind.equalsIgnoreCase("type")) { - property = ""; - String dialogTitle = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_TYPE"); - - provider = new WSDLComponentSelectionProvider(iFile, definition, WSDLEditorUtil.TYPE, validExtensions); - dialog = new WSDLComponentSelectionDialog(shell, dialogTitle, provider); - } - else { - property = ""; - String dialogTitle = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_ELEMENT"); - - provider = new WSDLComponentSelectionProvider(iFile, definition, WSDLEditorUtil.ELEMENT, validExtensions); - dialog = new WSDLComponentSelectionDialog(shell, dialogTitle, provider); - } - provider.setDialog(dialog); - } - else if (input instanceof Input || input instanceof Output || input instanceof Fault) - { - String dialogTitle = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_MESSAGE"); - - WSDLComponentSelectionProvider provider = new WSDLComponentSelectionProvider(iFile, definition, WSDLConstants.MESSAGE); - dialog = new WSDLComponentSelectionDialog(shell, dialogTitle, provider); - provider.setDialog(dialog); - property = "message"; - } - - dialog.setBlockOnOpen(true); - dialog.create(); - - if (dialog.open() == Window.OK) { - WSDLSetComponentHelper helper = new WSDLSetComponentHelper(iFile, definition); - if (kind != null && kind.equalsIgnoreCase("type")) { - helper.setXSDTypeComponent((Part) input, dialog.getSelection()); - } - else if (kind != null && kind.equalsIgnoreCase("element")){ - helper.setXSDElementComponent((Part) input, dialog.getSelection()); - } - else { - helper.setWSDLComponent((WSDLElement) input, property, dialog.getSelection()); - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentFinder.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentFinder.java deleted file mode 100644 index 297501c2c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentFinder.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs.types; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLQuickScan; - -public class WSDLComponentFinder extends XMLComponentFinder { - List lookupTagPaths; - - public WSDLComponentFinder(List tagPaths) { - lookupTagPaths = new ArrayList(); - lookupTagPaths.addAll(tagPaths); - } - - public List getWorkbenchResourceComponents(int scope) { - List components = new ArrayList(); - List filePaths = new ArrayList(); - - // We don't want to search through the current file we're working on. - if (currentIFile != null) { - excludeFiles.add(currentIFile.getLocation().toOSString()); - } - - // Find files matching the search criteria specified in List extensions and - // List excludeFiles. - switch (scope) { - case ENCLOSING_PROJECT_SCOPE: - filePaths = getEnclosingProjectFiles(); - break; - - case ENTIRE_WORKSPACE_SCOPE: - filePaths = getWorkspaceFiles(); - break; - - default: - break; - } - - // Search for the components in each of the files specified in the path. - List attributes = new ArrayList(); - String[] nameAttr = new String[1]; - nameAttr[0] = "name"; - attributes.add(nameAttr); - attributes.add(nameAttr); - attributes.add(nameAttr); - attributes.add(nameAttr); - - Iterator pathsIterator = filePaths.iterator(); - while (pathsIterator.hasNext()) { -// String stringPath = ((Path) pathsIterator.next()).toOSString(); - String stringPath = ((Path) pathsIterator.next()).toString(); - components.addAll(XMLQuickScan.getTagInfo(stringPath, lookupTagPaths, attributes)); - } - - return components; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionDialog.java deleted file mode 100644 index 885640f42..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionDialog.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs.types; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentSelectionProvider; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionDialog; - -public class WSDLComponentSelectionDialog extends XMLComponentSelectionDialog { - - public WSDLComponentSelectionDialog(Shell shell, String dialogTitle, IComponentSelectionProvider provider) { - super(shell, dialogTitle, provider); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionProvider.java deleted file mode 100644 index 9ef24c009..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLComponentSelectionProvider.java +++ /dev/null @@ -1,609 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs.types; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.internal.impl.ImportImpl; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentList; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionDialog; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionProvider; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaContent; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.impl.XSDImportImpl; -import org.eclipse.xsd.util.XSDConstants; - -public class WSDLComponentSelectionProvider extends XMLComponentSelectionProvider { - public static final String BUILT_IN_TYPE = "BUILT_IN_TYPE"; - - private WSDLComponentFinder wsdlComponentFinder; - private WSDLComponentSelectionDialog dialog; - private WSDLComponentLabelProvider labelProvider; - private Definition definition; - private List lookupTagPaths; - private int kind; - - /* - * Takes in the IFile we are currently editing. - */ - public WSDLComponentSelectionProvider(IFile file, Definition definition, int kind) { - this.kind = kind; - List validExt = new ArrayList(1); - validExt.add("wsdl"); - this.lookupTagPaths = getLookupTagPath(); - wsdlComponentFinder = new WSDLComponentFinder(lookupTagPaths); - wsdlComponentFinder.setFile(file); - wsdlComponentFinder.setValidExtensions(validExt); - this.definition = definition; - labelProvider = new WSDLComponentLabelProvider(); - } - - protected List getLookupTagPath() - { - List list = new ArrayList(); - switch (kind) - { - case WSDLConstants.BINDING : - { - list.add("/definitions/binding"); - break; - } - case WSDLConstants.PORT_TYPE : - { - list.add("/definitions/portType"); - break; - } - case WSDLConstants.MESSAGE : - { - list.add("/definitions/message"); - break; - } - case WSDLEditorUtil.TYPE : - { - list.add("/definitions/types/schema/simpleType"); - list.add("/definitions/types/schema/complexType"); - list.add("/schema/complexType"); - list.add("/schema/simpleType"); - break; - } - case WSDLEditorUtil.ELEMENT : - { - list.add("/definitions/types/schema/element"); - list.add("/schema/element"); - break; - } - } - return list; - } - - public WSDLComponentSelectionProvider(IFile file, Definition definition, int kind, List validExt) { - this(file, definition, kind); - wsdlComponentFinder.setValidExtensions(validExt); - } - - public void setDialog(WSDLComponentSelectionDialog dialog) { - this.dialog = dialog; - } - - public String getType(Object element) { - return null; - } - - private void createWSDLComponentObjects(IComponentList list, List inputComponents, String tagPath) { - Iterator it = inputComponents.iterator(); - while (it.hasNext()) { - WSDLElement wsdlElement = (WSDLElement) it.next(); - XMLComponentSpecification spec = new XMLComponentSpecification(tagPath); - spec.addAttributeInfo("name", wsdlElement.getElement().getAttribute("name")); - spec.setTargetNamespace(wsdlElement.getEnclosingDefinition().getTargetNamespace()); - - String normalizedFile = getNormalizedLocation(wsdlElement.getEnclosingDefinition().getLocation()); - spec.setFileLocation(normalizedFile); - - addDataItemToTreeNode(list, spec); - } - } - - private void createXSDComponentObjects(IComponentList list, List inputComponents, String tagPath) { - Iterator it = inputComponents.iterator(); - while (it.hasNext()) { - XSDNamedComponent xsdElement = (XSDNamedComponent) it.next(); - XMLComponentSpecification spec = new XMLComponentSpecification(tagPath); - spec.addAttributeInfo("name", xsdElement.getName()); - spec.setTargetNamespace(xsdElement.getTargetNamespace()); - - String normalizedFile = getNormalizedLocation(xsdElement.getSchema().getSchemaLocation()); - spec.setFileLocation(normalizedFile); - - addDataItemToTreeNode(list, spec); - } - } - - public void getComponents(IComponentList list, boolean quick) { - if (quick) { - Iterator tags = lookupTagPaths.iterator(); - while (tags.hasNext()) { - getComponentsQuick(list, (String) tags.next()); - } - } - else { - // Grab components from workspace locations - String scope = ""; - if (dialog != null) { - scope = dialog.getSearchScope(); - } - - List comps = new ArrayList(); - if (scope.equals(XMLComponentSelectionDialog.SCOPE_ENCLOSING_PROJECT)) { - comps = wsdlComponentFinder.getWorkbenchResourceComponents(XMLComponentFinder.ENCLOSING_PROJECT_SCOPE); - } - else if (scope.equals(XMLComponentSelectionDialog.SCOPE_WORKSPACE)) { - comps = wsdlComponentFinder.getWorkbenchResourceComponents(XMLComponentFinder.ENTIRE_WORKSPACE_SCOPE); - } - - Iterator compsIt = comps.iterator(); - while (compsIt.hasNext()) { - XMLComponentSpecification item = (XMLComponentSpecification) compsIt.next(); - addDataItemToTreeNode(list, item); - } - } - } - - private void getComponentsQuick(IComponentList list, String tagPath) { - // Grab components within the file - if (tagPath.equals("/definitions/binding")) { - // Grab explictly defined components - createWSDLComponentObjects(list, definition.getEBindings(), tagPath); - - // Grab directly imported components - Iterator importsIt = getWSDLFileImports(definition.getEImports()).iterator(); - while (importsIt.hasNext()) { - Import importItem = (Import) importsIt.next(); - Definition importDefinition = importItem.getEDefinition(); - List importedComponents = importDefinition.getEBindings(); - - createWSDLComponentObjects(list, importedComponents, tagPath); - } - } - else if (tagPath.equals("/definitions/portType")) { - // Grab explictly defined components - createWSDLComponentObjects(list, definition.getEPortTypes(), tagPath); - - // Grab directly imported components - Iterator importsIt = getWSDLFileImports(definition.getEImports()).iterator(); - while (importsIt.hasNext()) { - Import importItem = (Import) importsIt.next(); - Definition importDefinition = importItem.getEDefinition(); - List importedComponents = importDefinition.getEPortTypes(); - - createWSDLComponentObjects(list, importedComponents, tagPath); - } - } - else if (tagPath.equals("/definitions/message")) { - // Grab explictly defined components - createWSDLComponentObjects(list, definition.getEMessages(), tagPath); - - // Grab directly imported components - Iterator importsIt = getWSDLFileImports(definition.getEImports()).iterator(); - while (importsIt.hasNext()) { - Import importItem = (Import) importsIt.next(); - Definition importDefinition = importItem.getEDefinition(); - List importedComponents = importDefinition.getEMessages(); - - createWSDLComponentObjects(list, importedComponents, tagPath); - } - } - else if (tagPath.equals("/definitions/types/schema/complexType")) { - createXSDInlineTypesObjects(list, tagPath); - } - else if (tagPath.equals("/definitions/types/schema/simpleType")) { - createXSDInlineTypesObjects(list, tagPath); - } - else if (tagPath.equals("/definitions/types/schema/element")) { - createXSDElementObjects(list, tagPath); - createRegularImportXSDElementObjects(list); - } - else if (tagPath.equals("/schema/complexType")) { - createXSDInlineWrapperTypeObjects(list, tagPath); - - createXSDBuiltInTypeObjects(list); - createRegularImportXSDTypeObjects(list); - } - else if (tagPath.equals("/schema/simpleType")) { - createXSDInlineWrapperTypeObjects(list, tagPath); - } - else if (tagPath.equals("/schema/element")) { - createXSDInlineWrapperElementObjects(list, tagPath); - } - } - - private List getWSDLFileImports(List wsdlImports) { - List list = new ArrayList(); - Iterator it = wsdlImports.iterator(); - while (it.hasNext()) { - ImportImpl importItem = (ImportImpl) it.next(); - importItem.importDefinitionOrSchema(); // Load if necessary - if (importItem.getESchema() == null) { - list.add(importItem); - } - } - - return list; - } - - private void createXSDBuiltInTypeObjects(IComponentList list) { - for (int i = 0; i < XSDDOMHelper.dataType.length; i++) { - String builtIn = XSDDOMHelper.dataType[i][0]; - XMLComponentSpecification spec = new XMLComponentSpecification(BUILT_IN_TYPE); - spec.addAttributeInfo("name", builtIn); - spec.setTargetNamespace(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); - -// String normalizedFile = getNormalizedLocation(definition.getLocation()); -// spec.setFileLocation(normalizedFile); - spec.setFileLocation("Built-in"); - - addDataItemToTreeNode(list, spec); - } - } - - private void createRegularImportXSDTypeObjects(IComponentList list) { - // Handle regular imports(xsd and wsdl). - Iterator imports = definition.getEImports().iterator(); - while (imports.hasNext()) { - Import importItem = (Import) imports.next(); - ((ImportImpl) importItem).importDefinitionOrSchema(); - List schemas = new ArrayList(); - String complexPath = ""; - String simplePath = ""; - - if (importItem.getESchema() != null) { - // Import is a xsd file - schemas.add(importItem.getESchema()); - complexPath = "/schema/complexType"; - simplePath = "/schema/simpleType"; - } - else if (importItem.getEDefinition() != null) { - // Import is a wsdl file - Definition definition = importItem.getEDefinition(); - if (definition.getETypes() != null) { - Iterator schemaIt = definition.getETypes().getEExtensibilityElements().iterator(); - while (schemaIt.hasNext()) { - XSDSchemaExtensibilityElement eeElement = (XSDSchemaExtensibilityElement) schemaIt.next(); - schemas.add(eeElement.getSchema()); - complexPath = "/definitions/types/schema/complexType"; - simplePath = "/definitions/types/schema/simpleType"; - } - } - } - - if (schemas.size() > 0) { - Iterator schemaIt = schemas.iterator(); - while (schemaIt.hasNext()) { - Iterator typesIt = ((XSDSchema) schemaIt.next()).getTypeDefinitions().iterator(); - List complexList = new ArrayList(); - List simpleList = new ArrayList(); - while (typesIt.hasNext()) { - Object component = typesIt.next(); - if (component instanceof XSDComplexTypeDefinition) { - complexList.add(component); - } - else if (component instanceof XSDSimpleTypeDefinition) { - simpleList.add(component); - } - } - - createXSDComponentObjects(list, complexList, complexPath); - createXSDComponentObjects(list, simpleList, simplePath); - } - } - } - } - - private void createRegularImportXSDElementObjects(IComponentList list) { - // Handle regular imports(xsd and wsdl). - Iterator imports = definition.getEImports().iterator(); - while (imports.hasNext()) { - Import importItem = (Import) imports.next(); - ((ImportImpl) importItem).importDefinitionOrSchema(); - List schemas = new ArrayList(); - String path = ""; - - if (importItem.getESchema() != null) { - // Import is a xsd file - schemas.add(importItem.getESchema()); - path = "/schema/element"; - } - else if (importItem.getEDefinition() != null) { - // Import is a wsdl file - Definition definition = importItem.getEDefinition(); - if (definition.getETypes() != null) { - Iterator schemaIt = definition.getETypes().getEExtensibilityElements().iterator(); - while (schemaIt.hasNext()) { - XSDSchemaExtensibilityElement eeElement = (XSDSchemaExtensibilityElement) schemaIt.next(); - schemas.add(eeElement.getSchema()); - path = "/definitions/types/schema/element"; - } - } - } - - if (schemas.size() > 0) { - Iterator schemaIt = schemas.iterator(); - while (schemaIt.hasNext()) { - List elementList = ((XSDSchema) schemaIt.next()).getElementDeclarations(); - createXSDComponentObjects(list, elementList, path); - } - } - } - } - - private void createXSDInlineTypesObjects(IComponentList list, String tagPath) { - // Handle inline schemas - if (definition.getETypes() == null) { - return; - } - - Iterator inlineSchemasIt = definition.getETypes().getSchemas().iterator(); - while (inlineSchemasIt.hasNext()) { - XSDSchema schema = (XSDSchema) inlineSchemasIt.next(); - - if (schema.getTargetNamespace() != null && !schema.getTargetNamespace().equals("")) { - List keepTypes = new ArrayList(); - Iterator typeIterator = schema.getTypeDefinitions().iterator(); - // Filter out unwanted Types - if (tagPath.equals("/definitions/types/schema/complexType")) { - while (typeIterator.hasNext()) { - Object type = typeIterator.next(); - if (type instanceof XSDComplexTypeDefinition && - ((XSDComplexTypeDefinition) type).getSchema().equals(schema)) { - keepTypes.add(type); - } - } - } - else if (tagPath.equals("/definitions/types/schema/simpleType")) { - while (typeIterator.hasNext()) { - Object type = typeIterator.next(); - if (type instanceof XSDSimpleTypeDefinition && - ((XSDSimpleTypeDefinition) type).getSchema().equals(schema)) { - keepTypes.add(type); - } - } - } - - createXSDComponentObjects(list, keepTypes, tagPath); - } - } - } - - private void createXSDElementObjects(IComponentList list, String tagPath) { - if (definition.getETypes() == null) { - return; - } - - Iterator inlineSchemasIt = definition.getETypes().getSchemas().iterator(); - while (inlineSchemasIt.hasNext()) { - XSDSchema schema = (XSDSchema) inlineSchemasIt.next(); - - List keepElements = new ArrayList(); - if (schema.getTargetNamespace() != null && !schema.getTargetNamespace().equals("")) { - Iterator elementIt = schema.getElementDeclarations().iterator(); - while (elementIt.hasNext()) { - // Only look for elements explicitly defined in the Schema (not through imports). - XSDElementDeclaration xsdElement = (XSDElementDeclaration) elementIt.next(); - if (xsdElement.getSchema().equals(schema)) { - keepElements.add(xsdElement); - } - } - - createXSDComponentObjects(list, keepElements, tagPath); - } - } - } - - private void createXSDInlineWrapperTypeObjects(IComponentList list, String tagPath) { - // Handle inline schemas - if (definition.getETypes() == null) { - return; - } - - Iterator inlineSchemasIt = definition.getETypes().getSchemas().iterator(); - while (inlineSchemasIt.hasNext()) { - XSDSchema schema = (XSDSchema) inlineSchemasIt.next(); - - if (schema.getTargetNamespace() == null || schema.getTargetNamespace().equals("")) { - List keepTypes = new ArrayList(); - - List imports = new ArrayList(); - Iterator contents = schema.getContents().iterator(); - while (contents.hasNext()) { - XSDSchemaContent content = (XSDSchemaContent) contents.next(); - if (content instanceof XSDImport) { - imports.add(content); - } - } - - Iterator importIterator = imports.iterator(); - while (importIterator.hasNext()) { - XSDImport importObject = (XSDImport) importIterator.next(); - XSDSchema importSchema = ((XSDImportImpl) importObject).importSchema(); - Iterator typesIt = importSchema.getTypeDefinitions().iterator(); - while (typesIt.hasNext()) { - Object typeObject = typesIt.next(); - if (tagPath.equals("/schema/complexType") && - typeObject instanceof XSDComplexTypeDefinition) { - keepTypes.add(typeObject); - } - else if (tagPath.equals("/schema/simpleType") && - typeObject instanceof XSDSimpleTypeDefinition) { - keepTypes.add(typeObject); - } - } - - } - - createXSDComponentObjects(list, keepTypes, tagPath); - } - } - } - - private void createXSDInlineWrapperElementObjects(IComponentList list, String tagPath) { - if (definition.getETypes() == null) { - return; - } - - Iterator inlineSchemasIt = definition.getETypes().getSchemas().iterator(); - while (inlineSchemasIt.hasNext()) { - XSDSchema schema = (XSDSchema) inlineSchemasIt.next(); - - if (schema.getTargetNamespace() == null || schema.getTargetNamespace().equals("")) { - Iterator contents = schema.getContents().iterator(); - List imports = new ArrayList(); - while (contents.hasNext()) { - XSDSchemaContent content = (XSDSchemaContent) contents.next(); - if (content instanceof XSDImport) { - imports.add(content); - } - } - - Iterator importIterator = imports.iterator(); - while (importIterator.hasNext()) { - XSDImport importObject = (XSDImport) importIterator.next(); - XSDSchema importSchema = ((XSDImportImpl) importObject).importSchema(); - - createXSDComponentObjects(list, importSchema.getElementDeclarations(), tagPath); - } - } - } - } - -// private ITypeSystemProvider getTypeSystemProvider() { -// ITypeSystemProvider provider = WSDLEditorUtil.getInstance().getTypeSystemProvider(definition); -// if (provider instanceof ExtensibleTypeSystemProvider) { -// provider = (ExtensibleTypeSystemProvider) provider; -// } -// else { -// return null; -// } -// -// return provider; -// } - - - - public ILabelProvider getLabelProvider() { - return labelProvider; - } - - public String getListTitle() { - - switch (kind) - { - case WSDLConstants.BINDING : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MATCHING_BINDINGS"); - } - case WSDLConstants.PORT_TYPE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MATCHING_PORTTYPES"); - } - case WSDLConstants.MESSAGE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MATCHING_MESSAGES"); - } - case WSDLEditorUtil.TYPE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MATCHING_TYPES"); - } - case WSDLEditorUtil.ELEMENT : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MATCHING_ELEMENTS"); - } - } - return null; - } - - public String getNameFieldTitle() { - switch (kind) - { - case WSDLConstants.BINDING : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_NAME"); - } - case WSDLConstants.PORT_TYPE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORTTYPE_NAME"); - } - case WSDLConstants.MESSAGE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE_NAME"); - } - case WSDLEditorUtil.TYPE : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE_NAME"); - } - case WSDLEditorUtil.ELEMENT : - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT_NAME"); - } - } - return null; - } - public class WSDLComponentLabelProvider extends XMLComponentSelectionLabelProvider { - public Image getImage(Object element) { - XMLComponentTreeObject specification = (XMLComponentTreeObject) element; - XMLComponentSpecification spec = (XMLComponentSpecification) specification.getXMLComponentSpecification().get(0); - if (spec.getTagPath().equals("/definitions/binding")) { - return WSDLEditorPlugin.getInstance().getImage("icons/binding_obj.gif"); - } - else if (spec.getTagPath().equals("/definitions/portType")) { - return WSDLEditorPlugin.getInstance().getImage("icons/port_obj.gif"); - } - else if (spec.getTagPath().equals("/definitions/message")) { - return WSDLEditorPlugin.getInstance().getImage("icons/message_obj.gif"); - } - else if (spec.getTagPath().equals("/definitions/types/schema/complexType") || - spec.getTagPath().equals("/schema/complexType")) { - return XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"); - } - else if (spec.getTagPath().equals("/definitions/types/schema/simpleType") || - spec.getTagPath().equals("/schema/simpleType") || - spec.getTagPath().equals("BUILT_IN_TYPE")) { - return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif"); - } - else if (spec.getTagPath().equals("/definitions/types/schema/element") || - spec.getTagPath().equals("/schema/element")) { - return XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"); - } - - return null; - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLSetComponentHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLSetComponentHelper.java deleted file mode 100644 index f14c6b1a4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/dialogs/types/WSDLSetComponentHelper.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.dialogs.types; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.actions.AddElementDeclarationAction; -import org.eclipse.wst.wsdl.ui.internal.actions.AddImportAction; -import org.eclipse.wst.wsdl.ui.internal.actions.AddWSISchemaImportAction; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaContent; - - -public class WSDLSetComponentHelper { - private Definition definition; - private IFile currentIFile; - - public WSDLSetComponentHelper(IFile iFile, Definition definition) { - currentIFile = iFile; - this.definition = definition; - } - - public void setWSDLComponent(WSDLElement inputElement, String property, XMLComponentSpecification spec) { - addImportIfNecessary(spec); - String componentObject = getPrefixedComponentName(spec); - - org.w3c.dom.Element wsdlElement = inputElement.getElement(); - - wsdlElement.setAttribute(property, componentObject); //$NON-NLS-1$ - } - - public void setXSDTypeComponent(Part part, XMLComponentSpecification spec) { - if (!spec.getTagPath().equals(WSDLComponentSelectionProvider.BUILT_IN_TYPE)) { - addImportIfNecessary(spec); - } - String componentObject = getPrefixedComponentName(spec); - - ComponentReferenceUtil.setComponentReference((Part) part, true, componentObject); - } - - public void setXSDElementComponent(Part part, XMLComponentSpecification spec) { - addImportIfNecessary(spec); - String componentObject = getPrefixedComponentName(spec); - - ComponentReferenceUtil.setComponentReference((Part) part, false, componentObject); - } - - /* - * Return the prefixed component name described by the given - * XMLComponentSpecification object. - */ - public String getPrefixedComponentName(XMLComponentSpecification spec) { - String name = (String) spec.getAttributeInfo("name"); - List prefixes = getPrefixes(definition, spec.getTargetNamespace()); - if (prefixes.size() > 0) { - name = prefixes.get(0) + ":" + name; - } - - return name; - } - - private List getPrefixes(Definition definition, String namespace) { - List list = new ArrayList(); - Map map = definition.getNamespaces(); - for (Iterator i = map.keySet().iterator(); i.hasNext();) { - String prefix = (String) i.next(); - String theNamespace = (String) map.get(prefix); - if (theNamespace != null && theNamespace.equals(namespace)) { - list.add(prefix); - } - } - return list; - } - - - private void addImportIfNecessary(XMLComponentSpecification spec) { - boolean foundMatch = false; - - // Check itself - String currentFileLocation = currentIFile.getLocation().toString(); - if (currentFileLocation.equals(spec.getFileLocation())) { - foundMatch = true; - } - - // Check regular Imports - if (!foundMatch) { - Iterator importsIt = definition.getEImports().iterator(); - - while (importsIt.hasNext()) { - String importLocation = ""; - Import importItem = (Import) importsIt.next(); - if (importItem.getESchema() != null) { - XSDSchema schema = importItem.getESchema(); - importLocation = getNormalizedLocation(schema.getSchemaLocation()); - } - else { - Definition importDefinition = importItem.getEDefinition(); - importLocation = getNormalizedLocation(importDefinition.getLocation()); - } - - if (importLocation.equals(spec.getFileLocation())) { - foundMatch = true; - break; - } - } - } - - // Check inline Schemas - if (!foundMatch) { - List imports = new ArrayList(); - - if (definition.getETypes() != null) { - Iterator it = definition.getETypes().getEExtensibilityElements().iterator(); - while (it.hasNext()) { - XSDSchemaExtensibilityElement eeElement = (XSDSchemaExtensibilityElement) it.next(); - XSDSchema schema = eeElement.getSchema(); - if (schema.getTargetNamespace() == null || schema.getTargetNamespace().equals("")) { - Iterator contents = schema.getContents().iterator(); - while (contents.hasNext()) { - XSDSchemaContent content = (XSDSchemaContent) contents.next(); - if (content instanceof XSDImport) { - imports.add(content); - } - } - } - } - } - - Iterator importIt = imports.iterator(); - while (importIt.hasNext()) { - XSDImport importItem = (XSDImport) importIt.next(); - XSDSchema resolvedSchema = importItem.getResolvedSchema(); - String resolvedString = resolvedSchema.getSchemaLocation(); - String importLocation = getNormalizedLocation(resolvedString); - - if (importLocation.equals(spec.getFileLocation())) { - foundMatch = true; - break; - } - } - } - - if (!foundMatch) { - boolean wsiStyleImport = isXSDSchemaFile(spec); - if (wsiStyleImport) { - AddElementDeclarationAction action = new AddElementDeclarationAction(definition, spec.getTargetNamespace(), "xsd"); - action.run(); - - String location = URIHelper.getRelativeURI(new Path(spec.getFileLocation()), currentIFile.getLocation()); - AddWSISchemaImportAction addImport = new AddWSISchemaImportAction(definition, spec.getTargetNamespace(), location); - addImport.run(); - } - else { - String newSelectedFileLoc = spec.getFileLocation(); - String currentFileLoc = getNormalizedLocation(definition.getLocation()); - String relativeLoc = ComponentReferenceUtil.computeRelativeURI(newSelectedFileLoc, currentFileLoc, true); - - org.w3c.dom.Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - String prefix = definition.getPrefix(WSDLConstants.WSDL_NAMESPACE_URI); - String namespace = spec.getTargetNamespace(); - - AddImportAction addImportAction = new AddImportAction(null, definition, definitionElement, prefix, namespace, relativeLoc); - addImportAction.run(); - - String uniquePrefix = getUniquePrefix(definition, prefix); - definitionElement.setAttribute("xmlns:" + uniquePrefix, namespace); - } - } - } - /* - * Try to determine if the passed in XMLComponentSpecification refers to - * an XSD or WSDL file. If it's an XSD, return true. - */ - private boolean isXSDSchemaFile(XMLComponentSpecification spec) { - String fileLocation = spec.getFileLocation(); - int periodIndex = fileLocation.lastIndexOf("."); - - if (periodIndex > 0) { - String extension = fileLocation.substring(periodIndex + 1); - if (extension.equalsIgnoreCase("xsd")) { - return true; - } - } - - return false; - } - - private String getUniquePrefix(Definition definition, String initPrefix) { - String uniquePrefix; - Map map = definition.getNamespaces(); - - if (definition.getNamespace(initPrefix) == null) { - uniquePrefix = initPrefix; - } - else {// if used, then try to create a unique one - String tempPrefix = initPrefix; - int i = 1; - while(map.containsKey(tempPrefix + i)) { - i++; - } - uniquePrefix = tempPrefix + i; - } - return uniquePrefix; - } - - private String getNormalizedLocation(String location) { - try { - URL url = new URL(location); - URL resolvedURL = Platform.resolve(url); - location = resolvedURL.getPath(); - } - catch (Exception e) { - e.printStackTrace(); - } - - return location; - } - - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ExtensibilityItemTreeProviderRegistry.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ExtensibilityItemTreeProviderRegistry.java deleted file mode 100644 index 326428bea..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ExtensibilityItemTreeProviderRegistry.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.jface.viewers.ILabelProvider; - -/** - * This class reads the plugin manifests and registers each extensibility item tree provider - */ -public class ExtensibilityItemTreeProviderRegistry extends NSKeyedExtensionRegistry -{ - protected static final String LABEL_PROVIDER_PROPERTY = "labelProviderClass"; - protected static final String CONTENT_PROVIDER_PROPERTY = "contentProviderClass"; - protected static final String[] ATT_NAMES = { "labelProviderClass", "contentProviderClass" }; - - public ILabelProvider getLabelProvider(String namespace) - { - return (ILabelProvider) getProperty(namespace, LABEL_PROVIDER_PROPERTY); - } - - public ITreeChildProvider getContentProvider(String namespace) - { - return (ITreeChildProvider) getProperty(namespace, CONTENT_PROVIDER_PROPERTY); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IDetailsViewerProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IDetailsViewerProvider.java deleted file mode 100644 index d1f474f69..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IDetailsViewerProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; - -public interface IDetailsViewerProvider -{ - public Object getViewerKey(Object modelObject); - public Viewer createViewer(Object modelObject, Composite parent, IEditorPart editorPart); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IEditPartProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IEditPartProvider.java deleted file mode 100644 index 01c82370c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IEditPartProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.jface.action.IMenuManager; -import org.w3c.dom.Node; - -public interface IEditPartProvider -{ - public void contributeMenuActions(IMenuManager manager, Node node, Object object); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IMenuActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IMenuActionContributor.java deleted file mode 100644 index a1ff91571..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IMenuActionContributor.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.jface.action.IMenuManager; -import org.w3c.dom.Node; - -public interface IMenuActionContributor -{ - public void contributeMenuActions(IMenuManager manager, Node node, Object object); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IModelQueryContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IModelQueryContributor.java deleted file mode 100644 index 95d9a75fa..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/IModelQueryContributor.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -// Note this class will likely be removed in the future when the ModelQuery's extension mechanism is updated -// -public interface IModelQueryContributor -{ - public void setModel(IDOMModel xmlModel); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeAssociationProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeAssociationProvider.java deleted file mode 100644 index ee956ceaf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeAssociationProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public interface INodeAssociationProvider -{ - public Object getModelObject(Object parentModelObject, Element[] elementChain, int start, int[] end); - public Node getNode(Object modelObject); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeReconciler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeReconciler.java deleted file mode 100644 index 86cfebbb2..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/INodeReconciler.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.w3c.dom.Element; - - -public interface INodeReconciler -{ - public void notifyChanged(Object modelObject, Element element, int eventType, Object feature, Object oldValue, Object newValue, int index); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITreeChildProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITreeChildProvider.java deleted file mode 100644 index aac380ebd..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITreeChildProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -/** - * This class allows extension writers to provide specialize tree content behaviour. - * It is intended to behave similar to the org.eclipse.jface.viewers.ITreeContentProvider. - * The major difference is that this class is simplified so that only one method is involved. - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ -public interface ITreeChildProvider -{ - public Object[] getChildren(Object object); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITypeSystemProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITypeSystemProvider.java deleted file mode 100644 index 4700edef6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/ITypeSystemProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import java.util.List; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.xsd.XSDSchema; - -public interface ITypeSystemProvider -{ - public static final int UNKNOWN_TYPE = 0x0; - public static final int BUILT_IN_TYPE = 0x1; - public static final int USER_DEFINED_SIMPLE_TYPE = 0x2; - public static final int USER_DEFINED_COMPLEX_TYPE = 0x4; - - public List getAvailableTypeNames(Definition definition, int typeNameCategory); - public List getAvailableElementNames(Definition definition); - public List getAvailableTypes(Definition definition, XSDSchema schema, int typeNameCategory); - public int getCategoryForTypeName(Definition definition, String typeName); - public List getPrefixedNames(Definition definition, String namespace, String localName); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/NSKeyedExtensionRegistry.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/NSKeyedExtensionRegistry.java deleted file mode 100644 index 03b7ea4af..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/NSKeyedExtensionRegistry.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import java.util.HashMap; - -public class NSKeyedExtensionRegistry -{ - protected HashMap map = new HashMap(); - private static final String PLUGIN_LOADING_ERROR = "PLUGIN_LOADING_ERROR"; - - public NSKeyedExtensionRegistry() - { - } - - public void put(String namespaceURI, String className, ClassLoader classLoader) - { - ExtensionInfo info = (ExtensionInfo) map.get(namespaceURI); - if (info == null) - { - info = new SinglePropertyExtensionInfo(className, classLoader); - map.put(namespaceURI, info); - } - } - - public void put(String namespaceURI, HashMap propertyToClassNameMap, ClassLoader classLoader) - { - ExtensionInfo info = (ExtensionInfo) map.get(namespaceURI); - if (info == null) - { - info = new MultiPropertyExtensionInfo(propertyToClassNameMap, classLoader); - map.put(namespaceURI, info); - } - } - - /** - * - * @deprecated - */ - public Object get(String namespaceURI) - { - ExtensionInfo info = (ExtensionInfo) map.get(namespaceURI); - return info != null ? info.getObject("") : null; - } - - public Object getProperty(String namespaceURI, String property) - { - ExtensionInfo info = (ExtensionInfo) map.get(namespaceURI); - return info != null ? info.getObject(property) : null; - } - - private abstract class ExtensionInfo - { - protected ClassLoader classLoader; - - public ExtensionInfo(ClassLoader classLoader) - { - this.classLoader = classLoader; - } - - public abstract Object getObject(String property); - } - - private class SinglePropertyExtensionInfo extends ExtensionInfo - { - protected String className; - protected Object object; - protected boolean error; - - public SinglePropertyExtensionInfo(String className, ClassLoader classLoader) - { - super(classLoader); - this.className = className; - } - - public Object getObject(String property) - { - if (object == null) - { - try - { - Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className); - object = theClass.newInstance(); - } - catch (Exception e) - { - object = PLUGIN_LOADING_ERROR; - e.printStackTrace(); - } - } - return object != PLUGIN_LOADING_ERROR ? object : null; - } - } - - private class MultiPropertyExtensionInfo extends ExtensionInfo - { - protected HashMap propertyToClassNameTable; - protected HashMap propertyToObjectTable = new HashMap(); - - public MultiPropertyExtensionInfo(HashMap propertToClassNameTable, ClassLoader classLoader) - { - super(classLoader); - this.propertyToClassNameTable = propertToClassNameTable; - } - - public Object getObject(String property) - { - Object result = null; - String className = (String) propertyToClassNameTable.get(property); - if (className != null) - { - result = propertyToObjectTable.get(property); - if (result == null) - { - try - { - Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className); - result = theClass.newInstance(); - propertyToObjectTable.put(property, result); - } - catch (Exception e) - { - propertyToObjectTable.put(property, PLUGIN_LOADING_ERROR); - result = PLUGIN_LOADING_ERROR; - e.printStackTrace(); - } - } - } - return result != PLUGIN_LOADING_ERROR ? result : null; - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtension.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtension.java deleted file mode 100644 index 5bbaf6c82..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtension.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; - -public interface WSDLEditorExtension -{ - public static final int OUTLINE_TREE_CONTENT_PROVIDER = 1; // req'd for model based ext - public static final int OUTLINE_LABEL_PROVIDER = 2; // req'd for model based ext - - public static final int MENU_ACTION_CONTRIBUTOR = 3; // node - public static final int DETAILS_VIEWER_PROVIDER = 4; // node - - public static final int EDIT_PART_FACTORY = 5; // req'd for model based ext - public static final int TYPE_SYSTEM_PROVIDER = 6; // req'd for type system ext - public static final int NODE_RECONCILER = 7; // req'd for model based ext - public static final int NODE_ASSOCIATION_PROVIDER = 8; // req'd for model based ext - public static final int MODEL_QUERY_CONTRIBUTOR = 9; // req'd for model based ext - - public static final int PROPERTY_SOURCE_PROVIDER = 10; // req'd for model based ext - public static final int PROPERTY_SECTION_DESCRIPTOR_PROVIDER = 11; // req'd for model based ext - public static final int XSD_DELETE_ACTION = 12; - - boolean isExtensionTypeSupported(int type); - boolean isApplicable(Object modelObject); - Object createExtensionObject(int type, WSDLEditor wsdlEditor); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtensionRegistry.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtensionRegistry.java deleted file mode 100644 index f8e2435bc..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/extension/WSDLEditorExtensionRegistry.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.extension; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; - -public class WSDLEditorExtensionRegistry -{ - //protected List classNameClassLoaderPairList = new ArrayList(); - //protected HashMap treeProviderMap = new HashMap(); - protected List registeredExtensionList = new ArrayList(); - - public WSDLEditorExtensionRegistry() - { - add(new WSDLEditor.BuiltInWSDLEditorExtension()); - } - - //public ExtensibilityItemTreeProvider getExtensibilityItemTreeProvider(String namespaceURI) - //{ - // return (ExtensibilityItemTreeProvider)treeProviderMap.get(namespaceURI); - //} - - //public void putExtensibilityItemTreeProvider(String namespaceURI, ExtensibilityItemTreeProvider treeProvider) - //{ - // treeProviderMap.put(namespaceURI, treeProvider); - //} - - public List getRegisteredExtensions() - { - return registeredExtensionList; - } - - public WSDLEditorExtension getApplicableExtension(int type, Object object) - { - WSDLEditorExtension result = null; - for (Iterator i = getRegisteredExtensions().iterator(); i.hasNext(); ) - { - WSDLEditorExtension extension = (WSDLEditorExtension)i.next(); - if (extension.isExtensionTypeSupported(type) && extension.isApplicable(object)) - { - result = extension; - break; - } - } - return result; - } - - public WSDLEditorExtension[] getRegisteredExtensions(int type) - { - List list = new ArrayList(); - for (Iterator i = getRegisteredExtensions().iterator(); i.hasNext(); ) - { - WSDLEditorExtension extension = (WSDLEditorExtension)i.next(); - if (extension.isExtensionTypeSupported(type)) - { - list.add(extension); - } - } - - WSDLEditorExtension[] result = new WSDLEditorExtension[list.size()]; - int count = 0; - for (Iterator i = list.iterator(); i.hasNext(); ) - { - WSDLEditorExtension extension = (WSDLEditorExtension)i.next(); - result[count] = extension; - count++; - } - return result; - } - - public void addAsFirst(WSDLEditorExtension extension) - { - getRegisteredExtensions().add(0, extension); - } - - public void add(WSDLEditorExtension extension) - { - getRegisteredExtensions().add(extension); - } - - public void add(ClassLoader classLoader, String className) - { - // TODO... consider defered instantiation of WSDLEditorExtensions - try - { - Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className); - WSDLEditorExtension extension = (WSDLEditorExtension)theClass.newInstance(); - registeredExtensionList.add(extension); - } - catch (Exception e) - { - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/ExtensiblityElementFilter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/ExtensiblityElementFilter.java deleted file mode 100644 index 61bf0d273..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/ExtensiblityElementFilter.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.filter; - -import org.w3c.dom.Element; - -public interface ExtensiblityElementFilter -{ - public boolean isValidContext(Element parentElement, String localName); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/HttpExtensiblityElementFilter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/HttpExtensiblityElementFilter.java deleted file mode 100644 index 859259cd1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/HttpExtensiblityElementFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.filter; - -import org.w3c.dom.Element; - - -public class HttpExtensiblityElementFilter implements ExtensiblityElementFilter -{ - public HttpExtensiblityElementFilter() - { - } - - public boolean isValidContext(Element parentElement, String localName) - { - boolean result = false; - - String parentElementName = parentElement.getLocalName(); - if (parentElementName.equals("binding")) - { - result = localName.equals("binding"); - } - else if (parentElementName.equals("operation")) - { - result = localName.equals("operation"); - } - else if (parentElementName.equals("input") || - parentElementName.equals("output")) - { - result = localName.equals("body") || - localName.equals("header"); - } - else if (parentElementName.equals("fault")) - { - result = localName.equals("fault"); - } - else if (parentElementName.equals("port")) - { - result = localName.equals("address"); - } - - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/MimeExtensiblityElementFilter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/MimeExtensiblityElementFilter.java deleted file mode 100644 index eaa701fa4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/MimeExtensiblityElementFilter.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.filter; - -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; - - -public class MimeExtensiblityElementFilter implements ExtensiblityElementFilter -{ - private static final String MIME_NAMESPACE_URI="http://schemas.xmlsoap.org/wsdl/mime/"; - public MimeExtensiblityElementFilter() - { - } - - public boolean isValidContext(Element parentElement, String localName) - { - boolean result = false; - - String parentElementName = parentElement.getLocalName(); - String parentElementNamespace = parentElement.getNamespaceURI(); - - if (WSDLConstants.WSDL_NAMESPACE_URI.equals(parentElementNamespace)) - { - if (parentElementName.equals("input") || parentElementName.equals("output")) - { - result = localName.equals("content") || - localName.equals("multipartRelated") || - localName.equals("mimeXml"); - } - } - else if (MIME_NAMESPACE_URI.equals(parentElementNamespace)) - { - result = true; - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/SoapExtensiblityElementFilter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/SoapExtensiblityElementFilter.java deleted file mode 100644 index fbfe95ce0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/SoapExtensiblityElementFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.filter; - -import org.w3c.dom.Element; - -public class SoapExtensiblityElementFilter implements ExtensiblityElementFilter -{ - public SoapExtensiblityElementFilter() - { - } - - public boolean isValidContext(Element parentElement, String localName) - { - boolean result = false; - - String parentElementName = parentElement.getLocalName(); - if (parentElementName.equals("binding")) - { - result = localName.equals("binding"); - } - else if (parentElementName.equals("operation")) - { - result = localName.equals("operation"); - } - else if (parentElementName.equals("input") || - parentElementName.equals("output")) - { - result = localName.equals("body") || - localName.equals("header"); - } - else if (parentElementName.equals("fault")) - { - result = localName.equals("fault"); - } - else if (parentElementName.equals("port")) - { - result = localName.equals("address"); - } - - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/XSDExtensiblityElementFilter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/XSDExtensiblityElementFilter.java deleted file mode 100644 index c9d3aecc1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/filter/XSDExtensiblityElementFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.filter; - -import org.w3c.dom.Element; - -public class XSDExtensiblityElementFilter implements ExtensiblityElementFilter -{ - public XSDExtensiblityElementFilter() - { - } - - public boolean isValidContext(Element parentElement, String localName) - { - boolean result = false; - String parentElementName = parentElement.getLocalName(); - if (parentElementName.equals("types")) - { - result = localName.equals("schema"); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/InteractorHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/InteractorHelper.java deleted file mode 100644 index 4709c16b6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/InteractorHelper.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.editparts; - -import java.util.Iterator; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LayoutManager; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.wst.wsdl.ui.internal.gef.util.figures.Interactor; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IExpandable; - - -// hooks up an interactor with an edit part and the figure that needs to be expanded and collapsed -// -public class InteractorHelper implements MouseListener -{ - protected boolean needToPerformDefaultExpansion = true; - protected EditPart editPart; - protected Interactor interactor; - protected IExpandable expandable; - - public InteractorHelper(EditPart editPart, Interactor interactor, IExpandable expandable) - { - this.editPart = editPart; - this.interactor = interactor; - this.expandable = expandable; - interactor.addMouseListener(this); - expandable.setExpanded(interactor.isExpanded()); - } - - public void setExpanded(boolean isExpanded) - { - interactor.setExpanded(isExpanded); - interactorExpansionChanged(isExpanded); - } - - protected void interactorExpansionChanged(boolean isInteractorExpanded) - { - expandable.setExpanded(isInteractorExpanded); - expandable.setVisible(isInteractorExpanded); - - editPart.refresh(); - - EditPart root = editPart.getRoot(); - if (root instanceof AbstractGraphicalEditPart) - { - IFigure rootFigure = ((AbstractGraphicalEditPart)root).getFigure(); - invalidateAll(rootFigure); - rootFigure.validate(); - rootFigure.repaint(); - } - } - - - protected void invalidateAll(IFigure figure) - { - figure.invalidate(); - LayoutManager manager = figure.getLayoutManager(); - if (manager != null) - { - manager.invalidate(); - } - for (Iterator i = figure.getChildren().iterator(); i.hasNext(); ) - { - IFigure child = (IFigure)i.next(); - invalidateAll(child); - } - } - - - // implements MouseListener - // - public void mouseDoubleClicked(MouseEvent me) - { - } - - public void mousePressed(MouseEvent me) - { - boolean newExpansionState = !interactor.isExpanded(); - interactor.setExpanded(newExpansionState); - interactorExpansionChanged(newExpansionState); - } - - public void mouseReleased(MouseEvent me) - { - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/MultiContentPaneEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/MultiContentPaneEditPart.java deleted file mode 100644 index 115179acb..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editparts/MultiContentPaneEditPart.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.editparts; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - - -public abstract class MultiContentPaneEditPart extends AbstractGraphicalEditPart -{ - protected IFigure[] contentPanes; - protected int[] contentPaneIndexAdjustment; - - protected IFigure[] initContentPanes() - { - return null; - } - - protected int getContentPane(Object model) - { - return 0; - } - - protected List sortByContentPane(List list) - { - return list; - } - - - protected void setFigure(IFigure figure) - { - super.setFigure(figure); - contentPanes = initContentPanes(); - if (contentPanes != null) - { - contentPaneIndexAdjustment = new int[contentPanes.length]; - } - } - - - protected void updateContentPaneInfoIndexAdjustment(List list) - { - int index = 0; - int listSize = list.size(); - - for (int j = 0; j < contentPanes.length; j++) - { - contentPaneIndexAdjustment[j] = index; - while (index < listSize) - { - Object model = list.get(index); - if (getContentPane(model) != j) - { - break; - } - index++; - } - } - } - - - protected void refreshChildren() - { - if (contentPanes != null) - { - List sortedList = sortByContentPane(getModelChildren()); - updateContentPaneInfoIndexAdjustment(sortedList); - } - super.refreshChildren(); - } - - - protected void addChildVisual(EditPart childEditPart, int index) - { - if (contentPanes != null) - { - int j = getContentPane(childEditPart.getModel()); - if (contentPaneIndexAdjustment.length > j) - { - int adjustedIndex = index - contentPaneIndexAdjustment[j]; - if (adjustedIndex >= 0) - { - IFigure child = ((GraphicalEditPart)childEditPart).getFigure(); - contentPanes[j].add(child, adjustedIndex); - } - } - } - else - { - super.addChildVisual(childEditPart, index); - } - } - - - protected void removeChildVisual(EditPart childEditPart) - { - if (contentPanes != null) - { - int j = getContentPane(childEditPart.getModel()); - IFigure child = ((GraphicalEditPart)childEditPart).getFigure(); - contentPanes[j].remove(child); - } - else - { - super.removeChildVisual(childEditPart); - } - } - - protected void reorderChild(EditPart editpart, int index) - { - removeChildVisual(editpart); - List children = getChildren(); - children.remove(editpart); - children.add(index, editpart); - addChildVisual(editpart, index); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/IDirectEditPolicyDelegate.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/IDirectEditPolicyDelegate.java deleted file mode 100644 index e2a84e899..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/IDirectEditPolicyDelegate.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.editpolicies; - -import org.eclipse.jface.viewers.CellEditor; - -public interface IDirectEditPolicyDelegate -{ - public void performEdit(CellEditor cellEditor); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/TextCellEditorManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/TextCellEditorManager.java deleted file mode 100644 index 7bac729ac..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/editpolicies/TextCellEditorManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.editpolicies; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -public abstract class TextCellEditorManager extends DirectEditManager implements IDirectEditPolicyDelegate -{ - protected Label label; - - public TextCellEditorManager(GraphicalEditPart source, Label label) - { - super(source, TextCellEditor.class, new InternalCellEditorLocator(label)); - this.label = label; - } - - protected void initCellEditor() - { - String initialLabelText = label.getText(); - getCellEditor().setValue(initialLabelText); - Text text = (Text)getCellEditor().getControl(); - text.setFont(label.getFont()); - text.setForeground(label.getForegroundColor()); - text.setBackground(label.getBackgroundColor()); - text.selectAll(); - } - - protected abstract void performModify(String value); - - public static class InternalCellEditorLocator implements CellEditorLocator - { - protected Label label; - - public InternalCellEditorLocator(Label label) - { - this.label = label; - } - - public void relocate(CellEditor celleditor) - { - Text text = (Text)celleditor.getControl(); - Point sel = text.getSelection(); - Point pref = text.computeSize(-1, -1); - Rectangle rect = label.getTextBounds().getCopy(); - label.translateToAbsolute(rect); - text.setBounds(rect.x-4, rect.y-1, pref.x+1, pref.y+1); - text.setSelection(0); - text.setSelection(sel); - } - } - - // implements DirectEditPolicyDelegate - // - public void performEdit(CellEditor cellEditor) - { - performModify((String)cellEditor.getValue()); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/CenterLayout.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/CenterLayout.java deleted file mode 100644 index f83f38572..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/CenterLayout.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.figures; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AbstractLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; - - -/** - * Figures using the StackLayout as their layout manager have - * their children placed on top of one another. Order of - * placement is determined by the order in which the children - * were added, first child added placed on the bottom. - */ -public class CenterLayout extends AbstractLayout -{ - public static final int ALIGNMENT_TOP = 1; - public static final int ALIGNMENT_CENTER = 2; - public static final int ALIGNMENT_BOTTOM = 3; - - protected int spacing; - protected int verticalAlignment = ALIGNMENT_CENTER; - - public CenterLayout(){} - public CenterLayout(int spacing){ this.spacing = spacing; } - - - /** - * Calculates and returns the preferred size of the input container. - * This is the size of the largest child of the container, as all - * other children fit into this size. - * - * @param figure Container figure for which preferred size is required. - * @return The preferred size of the input figure. - */ -// protected Dimension calculatePreferredSize(IFigure figure) - protected Dimension calculatePreferredSize(IFigure figure, int width, int height) - { - Dimension d = calculatePreferredClientAreaSize(figure); -// d.expand(figure.getInsets().getWidth(), -// figure.getInsets().getHeight()); - d.expand(width, height); - d.union(getBorderPreferredSize(figure)); - return d; - } - - protected Dimension calculatePreferredClientAreaSize(IFigure figure) - { - Dimension d = new Dimension(); - List children = figure.getChildren(); - for (Iterator i = children.iterator(); i.hasNext(); ) - { - IFigure child = (IFigure)i.next(); - Dimension childSize = child.getPreferredSize(); - d.height += childSize.height; - d.width = Math.max(childSize.width, d.width); - } - int childrenSize = children.size(); - if (childrenSize > 0) - { - d.height += spacing * children.size() - 1; - } - return d; - } - - /* - * Returns the minimum size required by the input container. - * This is the size of the largest child of the container, as all - * other children fit into this size. - */ - // TODO GEF PORT - public Dimension getMinimumSize(IFigure figure, int width, int height) - { - Dimension d = new Dimension(); - List children = figure.getChildren(); - IFigure child; - for (int i=0; i < children.size(); i++) - { - child = (IFigure)children.get(i); - d.union(child.getMinimumSize()); - } - d.expand(figure.getInsets().getWidth(), figure.getInsets().getHeight()); - return d; - } - // TODO GEF PORT - public Dimension getPreferredSize(IFigure figure, int width, int height) - { - return calculatePreferredSize(figure, figure.getInsets().getWidth(), figure.getInsets().getHeight()); - } - - - public void layout(IFigure figure) - { - Rectangle r = figure.getClientArea(); - List children = figure.getChildren(); - - Dimension preferredClientAreaSize = calculatePreferredClientAreaSize(figure); - - int x = r.x + (r.width - preferredClientAreaSize.width) / 2; - int y = 0; - - switch (getVerticalAlignment()) - { - case ALIGNMENT_TOP : - { - y = r.y; - break; - } - case ALIGNMENT_CENTER : - { - y = r.y + (r.height - preferredClientAreaSize.height) / 2; - break; - } - case ALIGNMENT_BOTTOM : - { - y = r.y + (r.height - preferredClientAreaSize.height); - break; - } - } - - for (Iterator i = children.iterator(); i.hasNext(); ) - { - IFigure child = (IFigure)i.next(); - Dimension childSize = child.getPreferredSize(); - child.setBounds(new Rectangle(x, y, childSize.width, childSize.height)); - y += childSize.height + spacing; - } - } - - /** - * @param verticalAlignment The verticalAlignment to set. - */ - public void setVerticalAlignment(int verticalAlignment) - { - this.verticalAlignment = verticalAlignment; - } - - protected int getVerticalAlignment() - { - return verticalAlignment; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/IGraphNodeFigure.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/IGraphNodeFigure.java deleted file mode 100644 index bd9d85ad9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/IGraphNodeFigure.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.figures; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; - -public interface IGraphNodeFigure extends IFigure -{ - public static final int UP_CONNECTION = 1; - public static final int DOWN_CONNECTION = 2; - public static final int LEFT_CONNECTION = 3; - public static final int RIGHT_CONNECTION = 4; - - public IFigure getSelectionFigure(); - public IFigure getConnectionFigure(); - public List getConnectedFigures(int type); - public int getConnectionType(); - public void addConnectedFigure(IGraphNodeFigure figure); - public void removeConnectedFigure(IGraphNodeFigure figure); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/Interactor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/Interactor.java deleted file mode 100644 index 3e27c0379..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/Interactor.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.figures; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * Interactor the +/- control commonly found in trees - */ -public class Interactor extends RectangleFigure -{ - protected boolean isExpanded; - - public Interactor() - { - super(); - setPreferredSize(new Dimension(9, 9)); - } - - public void setExpanded(boolean isExpanded) - { - this.isExpanded = isExpanded; - repaint(); - } - - public boolean isExpanded() - { - return isExpanded; - } - - protected void fillShape(Graphics g) - { - super.fillShape(g); - Rectangle r = getBounds(); - int mx = r.x + r.width / 2; - int my = r.y + r.height / 2; - int s = 2; - g.drawLine(r.x + s, my, r.x + r.width - s - 1, my); - if (!isExpanded) - { - g.drawLine(mx, r.y + s, mx, r.y + r.height - s -1); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/RoundedLineBorder.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/RoundedLineBorder.java deleted file mode 100644 index b1bfad47d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/gef/util/figures/RoundedLineBorder.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.gef.util.figures; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.swt.graphics.Color; - -public class RoundedLineBorder extends LineBorder -{ - protected int arcLength; - protected int lineStyle = Graphics.LINE_SOLID; - - public RoundedLineBorder(Color c, int width, int arcLength) - { - super(c, width); - this.arcLength = arcLength; - } - - public RoundedLineBorder(int width, int arcLength) - { - super(width); - this.arcLength = arcLength; - } - - public RoundedLineBorder(Color c, int width, int arcLength, int lineStyle) - { - super(c, width); - this.arcLength = arcLength; - this.lineStyle = lineStyle; - } - - public RoundedLineBorder(int width, int arcLength, int lineStyle) - { - super(width); - this.arcLength = arcLength; - this.lineStyle = lineStyle; - } - - public void paint(IFigure figure, Graphics graphics, Insets insets) - { - tempRect.setBounds(getPaintRectangle(figure, insets)); - int width = getWidth(); - Color color = getColor(); - if (width%2 == 1) - { - tempRect.width--; - tempRect.height--; - } - tempRect.shrink(width/2,width/2); - graphics.setLineWidth(width); - graphics.setLineStyle(lineStyle); - if (color != null) - graphics.setForegroundColor(color); - graphics.drawRoundRectangle(tempRect, arcLength, arcLength); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/FigureCanvasKeyboardHandler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/FigureCanvasKeyboardHandler.java deleted file mode 100644 index e861ddf2b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/FigureCanvasKeyboardHandler.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; - -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.RangeModel; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Widget; - -public class FigureCanvasKeyboardHandler extends KeyAdapter -{ - public static final int H_SCROLL_INCREMENT = 5; - public static final int V_SCROLL_INCREMENT = 30; - - /** - * Constructor for FigureCanvasKeyboardHandler. - */ - public FigureCanvasKeyboardHandler() - { - super(); - } - - public void keyPressed(KeyEvent e) - { - Widget w = e.widget; - if (w instanceof FigureCanvas) - { - processKey(e.keyCode, (FigureCanvas)w); - } - } - - private void processKey(int keyCode, FigureCanvas figureCanvas) - { - switch (keyCode) - { - case SWT.ARROW_DOWN : - scrollVertical(figureCanvas, false); - break; - case SWT.ARROW_UP : - scrollVertical(figureCanvas, true); - break; - case SWT.ARROW_LEFT : - scrollHorizontal(figureCanvas, true); - break; - case SWT.ARROW_RIGHT : - scrollHorizontal(figureCanvas, false); - break; - case SWT.PAGE_UP : - scrollPage(figureCanvas, true); - break; - case SWT.PAGE_DOWN : - scrollPage(figureCanvas, false); - break; - } - } - - private int verifyScrollBarOffset(RangeModel model, int value) - { - value = Math.max(model.getMinimum(), value); - return Math.min(model.getMaximum() - model.getExtent(), value); - } - - private void scrollVertical(FigureCanvas figureCanvas, boolean up) - { - Point location = figureCanvas.getViewport().getViewLocation(); - int vOffset = up ? -V_SCROLL_INCREMENT : V_SCROLL_INCREMENT; - int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x); - int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y + vOffset); - figureCanvas.scrollSmoothTo(x, y); - } - - private void scrollHorizontal(FigureCanvas figureCanvas, boolean left) - { - Point location = figureCanvas.getViewport().getViewLocation(); - int hOffset = left ? -H_SCROLL_INCREMENT : H_SCROLL_INCREMENT; - int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x + hOffset); - int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y); - figureCanvas.scrollSmoothTo(x, y); - } - - private void scrollPage(FigureCanvas figureCanvas, boolean up) - { - Rectangle clientArea = figureCanvas.getClientArea(); - int increment = up ? -clientArea.height : clientArea.height; - Point location = figureCanvas.getViewport().getViewLocation(); - int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x); - int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y + increment); - figureCanvas.scrollSmoothTo(x, y); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphViewToolBar.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphViewToolBar.java deleted file mode 100644 index 5fec3a0b1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphViewToolBar.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ViewForm; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; -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.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; - - -public class GraphViewToolBar extends ViewForm -{ - ToolBar graphToolBar; // the toolbar at the top of the graph view - //ToolItem toolItem; // the view tool item - Composite frameBar; // The composite that contains the toolbar - WSDLEditor editor; - - ToolItem showBindingsButton; // the view tool item - ToolItem backButton; - - public GraphViewToolBar(WSDLEditor wsdlEditor, Composite c, int style) - { - super(c, style); - this.editor = wsdlEditor; - frameBar = new Composite(this, SWT.NONE); - /* - CLabel label = new CLabel(frameBar, SWT.NONE); - label.setText("View :"); - */ - org.eclipse.swt.layout.GridLayout frameLayout = new org.eclipse.swt.layout.GridLayout(); - frameLayout.numColumns = 3; - frameLayout.horizontalSpacing = 0; - frameLayout.marginWidth = 0; - frameLayout.marginHeight = 0; - - frameBar.setLayout(frameLayout); - - graphToolBar = new ToolBar(frameBar, SWT.FLAT); - graphToolBar.addTraverseListener(new TraverseListener() - { - public void keyTraversed(TraverseEvent e) - { - if (e.detail == SWT.TRAVERSE_MNEMONIC) - e.doit = false; - } - }); - - - backButton = new ToolItem(graphToolBar, SWT.PUSH); - backButton.setImage(WSDLEditorPlugin.getInstance().getImage("icons/back.gif")); - // backButton.setToolTipText(WSDLEditorPlugin.getWSDLString("_UI_BACK_TO", "Definition")); - backButton.setToolTipText(WSDLEditorPlugin.getWSDLString("_UI_BACK")); - backButton.setEnabled(false); - backButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - Object object = editor.getGraphViewer().getComponentViewer().getInput(); - if (object instanceof XSDSchema) - { - editor.getGraphViewer().setInput(editor.getDefinition()); - } - else if (object instanceof XSDConcreteComponent) - { - // Need to common this up with xsdeditor's BackAction code - XSDSchema xsdSchema = ((XSDConcreteComponent)object).getSchema(); - boolean flag = true; - while (flag) - { - List list = xsdSchema.getReferencingDirectives(); - if (list.size() > 0) - { - XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)list.get(0); - if (xsdSchemaDirective.getSchema() != null) - { - xsdSchema = xsdSchemaDirective.getSchema(); - } - else - { - flag = false; - } - } - else - { - flag = false; - } - } - - editor.getGraphViewer().setInput(xsdSchema); - } - else - { - editor.getGraphViewer().setInput(editor.getDefinition()); - } - } - }); - - // hack to make the button look like a toggle button. SWT.TOGGLE is not an allowed style - // for a ToolItem, but SWT.RADIO is. SWT.RADIO makes it look like a toggle....... - showBindingsButton = new ToolItem(graphToolBar, SWT.RADIO); - showBindingsButton.setImage(WSDLEditorPlugin.getInstance().getImage("icons/hidebinding.gif")); - showBindingsButton.setToolTipText(WSDLEditorPlugin.getWSDLString("_UI_HIDE_BINDINGS")); - showBindingsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() - { - private boolean currentlySelected = false; - - public void widgetSelected(SelectionEvent e) - { - ViewMode vm = WSDLGraphModelAdapterFactory.getViewMode((Definition)editor.getDefinition()); - vm.setBindingVisible(!vm.isBindingVisible()); - - // hack to make the button look like a toggle button - ToolItem item = (ToolItem) e.widget; - if (currentlySelected) { - item.setSelection(false); - currentlySelected = false; - } - else { - currentlySelected = true; - } - } - }); - - setTopLeft(frameBar); - } - - public void setBackButtonEnabled(boolean state) - { - backButton.setEnabled(state); - } - - -// public void updateHoverHelp(Object object) -// { -// if (object instanceof XSDSchema) -// { -// backButton.setToolTipText(WSDLEditorPlugin.getWSDLString("_UI_BACK_TO", "Definition")); -// } -// else if (object instanceof XSDConcreteComponent) -// { -// backButton.setToolTipText(WSDLEditorPlugin.getWSDLString("_UI_BACK_TO", "XML Schema")); -// } -// } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphicsConstants.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphicsConstants.java deleted file mode 100644 index 8170eba7d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/GraphicsConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; - -/** - * A collection of color and font related constants. - */ -public interface GraphicsConstants -{ - public final static Display display = Display.getDefault(); - - public final static Color groupBorderColor = new Color(null, 118, 134, 164); - public final static Color groupHeaderColor = new Color(null, 232, 240, 248); - - public final static Color elementBorderColor = new Color(null, 120, 152, 184); - public final static Color elementBackgroundColor = new Color(null, 232, 240, 248); - public final static Color elementLabelColor = new Color(null, 80, 102, 144); - public final static Color readOnlyBorderColor = new Color(null, 164, 164, 164); - public final static Color red = new Color(null, 255, 0, 0); - - public final static Color readOnlyBackgroundColor = ColorConstants.white; - - public final static Font smallBoldFont = new Font(Display.getCurrent(), "Tahoma", 8, SWT.BOLD); - public final static Font mediumFont = new Font(Display.getCurrent(), "Tahoma", 10, SWT.NONE); - public final static Font mediumBoldFont = new Font(Display.getCurrent(), "Tahoma", 10, SWT.BOLD); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/ViewMode.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/ViewMode.java deleted file mode 100644 index 6275daf4f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/ViewMode.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class ViewMode -{ - public static final int BINDING = 1; - public static final int MESSAGE = 2; - public static final int PORT_TYPE = 3; - public static final int SERVICE = 4; - public static final int TYPES = 5; - - public static final String BINDING_DESCRIPTION = WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING"); - public static final String MESSAGE_DESCRIPTION = WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE"); - public static final String PORT_TYPE_DESCRIPTION = WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORTTYPE"); - public static final String SERVICE_DESCRIPTION = WSDLEditorPlugin.getWSDLString("_UI_LABEL_SERVICE"); - public static final String TYPES_DESCRIPTION = WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPES"); - - - protected boolean isBindingVisible = true; - protected int mode = SERVICE; - protected List listenerList = new ArrayList(); - - public ViewMode() - { - } - - public void setBindingVisible(boolean isVisible) - { - if (isBindingVisible != isVisible) - { - isBindingVisible = isVisible; - fireChangeNotification(); - } - } - - public boolean isBindingVisible() - { - return isBindingVisible; - } - - public static int getModeForDescription(String description) - { - int result = SERVICE; - if (description.equals(BINDING_DESCRIPTION)) - { - result = BINDING; - } - else if (description.equals(MESSAGE_DESCRIPTION)) - { - result = MESSAGE; - } - else if (description.equals(PORT_TYPE_DESCRIPTION)) - { - result = PORT_TYPE; - } - else if (description.equals(SERVICE_DESCRIPTION)) - { - result = SERVICE; - } - else if (description.equals(TYPES_DESCRIPTION)) - { - result = TYPES; - } - return result; - } - - public static String getDescriptionForMode(int mode) - { - String result = SERVICE_DESCRIPTION; - switch (mode) - { - case BINDING : - { - result = BINDING_DESCRIPTION; - break; - } - case MESSAGE : - { - result = MESSAGE_DESCRIPTION; - break; - } - case PORT_TYPE : - { - result = PORT_TYPE_DESCRIPTION; - break; - } - case SERVICE : - { - result = SERVICE_DESCRIPTION; - break; - } - case TYPES : - { - result = TYPES_DESCRIPTION; - break; - } - } - return result; - } - - public interface Listener - { - public void viewModeChanged(ViewMode mode); - } - - public void setMode(int mode) - { - this.mode = mode; - fireChangeNotification(); - } - - public void setMode(String description) - { - this.mode = getModeForDescription(description); - fireChangeNotification(); - } - - public int getMode() - { - return mode; - } - - public String getModeDescription() - { - return getDescriptionForMode(mode); - } - - public void addListener(Listener listener) - { - if (!listenerList.contains(listener)) - { - listenerList.add(listener); - } - } - - public void removeListener(Listener listener) - { - listenerList.remove(listener); - } - - public void fireChangeNotification() - { - for (Iterator i = listenerList.iterator(); i.hasNext(); ) - { - Listener listener = (Listener)i.next(); - listener.viewModeChanged(this); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLComponentViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLComponentViewer.java deleted file mode 100644 index b551a22a6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLComponentViewer.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; - -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.EditDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.tools.SelectionTool; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IEditorSite; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.actions.ExtensibleMenuActionContributor; -import org.eclipse.wst.wsdl.ui.internal.gef.util.figures.CenterLayout; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.ComponentViewerRootEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.figures.MyConnectionRenderingHelper; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ConnectionRenderingFigure; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectionRenderingViewer; -import org.w3c.dom.Node; - -public class WSDLComponentViewer extends ScrollingGraphicalViewer implements IConnectionRenderingViewer -{ - protected EditDomain editDomain; - protected WSDLEditor editor; - protected ISelectionProvider menuSelectionProvider; - protected ComponentViewerRootEditPart componentViewerRootEditPart; - protected ConnectionRenderingFigure connectionRenderingFigure; - protected boolean isPreserveExpansionEnabled; - - public WSDLComponentViewer(WSDLEditor editor, ISelectionProvider menuSelectionProvider) - { - super(); - this.editor = editor; - this.menuSelectionProvider = menuSelectionProvider; - } - - public void setPreserveExpansionEnabled(boolean isPreserveExpansionEnabled) - { - this.isPreserveExpansionEnabled = isPreserveExpansionEnabled; - } - - public boolean isPreserveExpansionEnabled() - { - return isPreserveExpansionEnabled; - } - - public ConnectionRenderingFigure getConnectionRenderingFigure() - { - return connectionRenderingFigure; - } - - public Object getInput() - { - return componentViewerRootEditPart.getModel(); - } - - public void setInput(Object object) - { - componentViewerRootEditPart.setInput(object); - - if (object instanceof Definition) - { - editor.getGraphViewer().setBackButtonEnabled(false); - } - else - { - editor.getGraphViewer().setBackButtonEnabled(true); - } - - // todo.. revisit this to understand why we don't get a set input - // when drilling down into a schema element or type - // - int layoutAlignment = (object instanceof Definition) ? - CenterLayout.ALIGNMENT_TOP : - CenterLayout.ALIGNMENT_CENTER; - - ScalableRootEditPart graphicalRootEditPart = (ScalableRootEditPart)getRootEditPart(); - CenterLayout centerLayout = (CenterLayout)graphicalRootEditPart.getLayer(LayerConstants.PRIMARY_LAYER).getLayoutManager(); - centerLayout.setVerticalAlignment(layoutAlignment); - } - - //public void setSelection(Object object) - //{ - //} - - protected void hookControl() - { - super.hookControl(); - - getControl().setBackground(ColorConstants.white); - - editDomain = new DefaultEditDomain(null); - ((DefaultEditDomain)editDomain).setDefaultTool(new SelectionTool()); - editDomain.loadDefaultTool(); - editDomain.addViewer(this); - - componentViewerRootEditPart = new ComponentViewerRootEditPart(); - - KeyAdapter keyListener = new KeyAdapter() - { - public void keyReleased(KeyEvent e) - { - if (e.keyCode == SWT.F3) - { - ISelection selection = editor.getSelectionManager().getSelection(); - if (selection instanceof IStructuredSelection) - { - Object object = ((IStructuredSelection)selection).getFirstElement(); - if (object instanceof EObject) - { - OpenOnSelectionHelper helper = new OpenOnSelectionHelper(editor.getDefinition()); - helper.openEditor((EObject)object); - } - } - - } - } - }; - getControl().addKeyListener(keyListener); - - setContents(componentViewerRootEditPart); - //getFigureCanvas().addKeyListener(new FigureCanvasKeyboardHandler(editor)); - getRootEditPart().activate(); - - componentViewerRootEditPart.setInput(editor.getDefinition()); - - ScalableRootEditPart graphicalRootEditPart = (ScalableRootEditPart)getRootEditPart(); - - // set the layout for the primary layer so that the children are always centered - // - CenterLayout centerLayout = new CenterLayout(); - centerLayout.setVerticalAlignment(CenterLayout.ALIGNMENT_TOP); - graphicalRootEditPart.getLayer(LayerConstants.PRIMARY_LAYER).setLayoutManager(centerLayout); //new ContainerLayout());// - - ContextMenuProvider menuProvider = new InternalContextMenuProvider(this, editor); - setContextMenu(menuProvider); - - // add context menu to the graph - MenuManager manager = new MenuManager("#popup"); - manager.addMenuListener(menuProvider); - manager.setRemoveAllWhenShown(true); - Menu menu = manager.createContextMenu(getControl()); - getControl().setMenu(menu); - - // enable popupMenus extension - ((IEditorSite) editor.getSite()).registerContextMenu("org.eclipse.wst.wsdl.ui.popup.graph", manager, menuSelectionProvider, false); - - // add the ConnectionFigure which is responsible for drawing all of the lines in the view - // - IFigure figure = graphicalRootEditPart.getLayer(LayerConstants.CONNECTION_LAYER); - figure.setLayoutManager(new StackLayout()); - - final MyConnectionRenderingHelper connectionRenderingHelper = new MyConnectionRenderingHelper(this); - - connectionRenderingFigure = new ConnectionRenderingFigure(graphicalRootEditPart.getLayer(LayerConstants.PRIMARY_LAYER)) - { - protected void fillShape(Graphics graphics) - { - super.fillShape(graphics); - connectionRenderingHelper.fillShapeHelper(graphics); - } - }; - figure.add(connectionRenderingFigure); - figure.validate(); - } - - public WSDLEditor getWSDLEditor() { - return editor; - } - - public class InternalContextMenuProvider extends ContextMenuProvider - { - protected EditPartViewer viewer; - protected ExtensibleMenuActionContributor extensibleMenuActionContributor; - - public InternalContextMenuProvider(EditPartViewer viewer, WSDLEditor editor) - { - super(viewer); - this.viewer = viewer; - extensibleMenuActionContributor = new ExtensibleMenuActionContributor(editor); - } - - public void buildContextMenu(IMenuManager menu) - { - List list = getSelectedEditParts(); - if (list.size() > 0) - { - EditPart editPart = (EditPart)list.get(0); - Object object = editPart.getModel(); - - //if (editPart instanceof PropertyEditPart) - //{ - // object = ((PropertyEditPart)editPart).getOwnerModel(); - //} - - if (object != null) - { - Node node = null; - if (object instanceof Node) - { - node = (Node)object; - } - else if (object instanceof WSDLElement) - { - node = ((WSDLElement)object).getElement(); - } - else if (object instanceof WSDLGroupObject) - { - node = ((WSDLGroupObject)object).getDefinition().getElement(); - } - extensibleMenuActionContributor.contributeMenuActions(menu, node, object); - } - } - } - } -} 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 deleted file mode 100644 index b6a7ddfac..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/WSDLGraphViewer.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.jface.action.Action; -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.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionFactory; -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.actions.CopyGlobalAction; -import org.eclipse.wst.wsdl.ui.internal.actions.DeleteWSDLAndXSDAction; -import org.eclipse.wst.wsdl.ui.internal.actions.PasteGlobalAction; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.ComponentViewerRootEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.GroupEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.TreeNodeEditPart; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.SelectionAdapter; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class WSDLGraphViewer implements ISelectionChangedListener -{ - protected Control componentViewerControl; - protected WSDLComponentViewer componentViewer; - protected Definition definition; - protected WSDLEditor editor; - protected InternalSelectionAdapter internalSelectionAdapter = new InternalSelectionAdapter(); - - GraphViewToolBar form; // Tool bar view form - - public WSDLGraphViewer(WSDLEditor editor) - { - super(); - this.editor = editor; - } - - public void setDefinition(Definition definition) - { - this.definition = definition; - } - - public ISelectionProvider getSelectionProvider() - { - return internalSelectionAdapter; - } - - public Control createControl(Composite parent) - { - componentViewer = new WSDLComponentViewer(editor, editor.getSelectionManager()); - - componentViewer.addSelectionChangedListener(internalSelectionAdapter); - internalSelectionAdapter.addSelectionChangedListener(editor.getSelectionManager()); - - form = new GraphViewToolBar(editor, parent, SWT.NONE); - - componentViewerControl = componentViewer.createControl(form); - form.setContent(componentViewerControl); - - editor.getSelectionManager().addSelectionChangedListener(this); - - componentViewerControl.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.character == SWT.DEL) { - List selections = ((IStructuredSelection) editor.getSelectionManager().getSelection()).toList(); - DeleteWSDLAndXSDAction deleteAction = new DeleteWSDLAndXSDAction(selections, editor.getDefinition().getElement(), editor); - deleteAction.run(); - } - } - }); - - return componentViewerControl; - } - - public WSDLComponentViewer getComponentViewer() - { - return componentViewer; - } - - - Node inputNode; - public void setInput(Object object) - { - componentViewer.setInput(object); - } - - public void setBackButtonEnabled(boolean state) - { - form.setBackButtonEnabled(state); - } - - //protected boolean isDeleted(Object object) - //} - - - // this is called when selection changes in the selection manager - // - - - - protected Object getInputComponentForNode(Node node) - { - // TODO... logic to get WSDLElement or other object (e.g. XSD or extension for the Node) - // TODO... consider case where the model is simply a chunk of DOM - return null; - } - - protected Object getSelectionComponentForNode(Node node) - { - // TODO... logic to get WSDLElement or other object (e.g. XSD or extension for the Node) - // TODO... consider case where the model is simply a chunk of DOM - return null; - } - - protected class InternalSelectionAdapter extends SelectionAdapter implements ISelectionChangedListener - { - public Object getObjectForOtherModel(Object object) - { - Object result = null; - if (object instanceof EditPart) - { - // fix for defect 4294 ... this test prevents selection from changing - // when a component is renamed which indirectly causes it to be removed and - // re-added from the 'sorted' list - // - if (!(object instanceof ComponentViewerRootEditPart)) - { - EditPart editPart = (EditPart)object; - result = editPart.getModel(); - } - } - return result; - } - - public void selectionChanged(SelectionChangedEvent event) - { - setSelection(event.getSelection()); - } - } - - // this gets called when the selection changes within the selection manager - // - public void selectionChanged(SelectionChangedEvent event) - { - //System.out.println("WSDLGraphViewer.selectionChanged( " + event.getSource() + ")"); - - IStructuredSelection selectionObject = (IStructuredSelection)event.getSelection(); - Object modelObject = selectionObject.getFirstElement(); - if (modelObject instanceof WSDLElement) { - Element node = ((WSDLElement) modelObject).getElement(); - boolean isEditable = (node instanceof IDOMNode); - - Action copyAction = new CopyGlobalAction((WSDLElement) modelObject, editor); - Action pasteAction = new PasteGlobalAction((WSDLElement) modelObject, editor); - - IActionBars actionBars = editor.getEditorSite().getActionBars(); - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction); - actionBars.updateActionBars(); - - if (!isEditable) { - copyAction.setEnabled(false); - pasteAction.setEnabled(false); - } - } - - if (event.getSource() != internalSelectionAdapter && event.getSource() != (editor.getTextEditor()).getSelectionProvider()) - { - boolean isEmptySelectionRequired = true; - if (event.getSelection() instanceof IStructuredSelection) - { - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - Object model = selection.getFirstElement(); - - if (model != null) - { - EditPart editPart = getEditPart(componentViewer.getRootEditPart(), model); - if (editPart == null) - { - editPart = expandToReveal(componentViewer.getRootEditPart(), model); - } - if (editPart == null) - { - if (model instanceof XSDConcreteComponent) { - model = getTopLevelComponent((XSDConcreteComponent) model); - - if (model instanceof XSDElementDeclaration || - model instanceof XSDComplexTypeDefinition || - model instanceof XSDModelGroupDefinition || - model instanceof XSDSchema) { - componentViewer.setInput(model); - } - } - else if (model instanceof WSDLElement || model instanceof WSDLGroupObject) { - // We need to switch the output to Definition - componentViewer.setInput(editor.getDefinition()); - editPart = getEditPart(componentViewer.getRootEditPart(), model); - if (editPart == null) - { - editPart = expandToReveal(componentViewer.getRootEditPart(), model); - } - } - else - { - // bad hack to convert xsd editor category to xsd object - // see also WSDLTabbedPropertySheetPage - Node node = WSDLEditorUtil.getInstance().getNodeForObject(model); - Object o = WSDLEditorUtil.getInstance().findModelObjectForElement(editor.getDefinition(), (Element)node); - if (o instanceof XSDSchemaExtensibilityElement) - { - Object obj = ((XSDSchemaExtensibilityElement)o).getSchema(); - componentViewer.setInput(obj); - } - } - } - if (editPart != null) - { - isEmptySelectionRequired = false; - componentViewer.setSelection(new StructuredSelection(editPart)); - scrollIntoView(editPart); - } - } - } - if (isEmptySelectionRequired) - { - componentViewer.setSelection(new StructuredSelection()); - } - } - } - - protected XSDConcreteComponent getTopLevelComponent(XSDConcreteComponent component) - { - XSDConcreteComponent prev = component; - XSDConcreteComponent container = component; - while ( container != null && !(container instanceof XSDSchema)) - { - prev = container; - container = container.getContainer(); - } - return container != null ? prev : null; - } - - protected EditPart getEditPart(EditPart editPart, Object model) - { - EditPart result = null; - if (editPart.getModel() == model) - { - result = editPart; - } - else - { - for (Iterator i = editPart.getChildren().iterator(); i.hasNext(); ) - { - result = getEditPart((EditPart)i.next(), model); - if (result != null) - { - break; - } - } - } - return result; - } - - - public EditPart expandToReveal(EditPart editPart, Object model) - { - // here we create the parent list - // - List parentList = new ArrayList(); - for (Object o = model; o != null; o = getParent(o)) - { - parentList.add(0, o); - } - EditPart result = expandToRevealHelper(editPart, parentList, 0); - - return result; - } - - - public EditPart expandToRevealHelper(EditPart editPart, List parentList, int index) - { - EditPart result = null; - int parentListSize = parentList.size(); - Object model = index < parentListSize ? parentList.get(index) : null; - if (model != null && editPart != null) - { - // search editpart and its descendants to find a match for this model object - // - result = getEditPart(editPart, model); - //System.out.println("getEditPart(" + index + ", " + model + ") = " + result); - } - - if (result != null) - { - if (index < (parentListSize - 1)) - { - // we've found the editPart for the item in the parentList - // now we need to find the next item - if (result instanceof TreeNodeEditPart) - { - ((TreeNodeEditPart)result).setExpanded(true); - } - result = expandToRevealHelper(result, parentList, index + 1); - } - } - return result; - } - - - protected Object getParent(Object model) - { - Object parent = null; - if (model instanceof EObject) - { - parent = ((EObject)model).eContainer(); - } - return parent; - } - - - public void scrollIntoView(EditPart editPart) - { - for (EditPart parent = editPart.getParent(); parent != null; parent = parent.getParent()) - { - if (parent instanceof GroupEditPart) - { - GroupEditPart groupEditPart = (GroupEditPart)parent; - groupEditPart.scrollToRevealEditPart(editPart); - break; - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/AbstractConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/AbstractConnectionManager.java deleted file mode 100644 index 6f84aaa07..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/AbstractConnectionManager.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class AbstractConnectionManager implements IConnectionManager -{ - public static final int PROPAGATE_FORWARD = 0; - public static final int PROPAGATE_BACK = 1; - public static final int SELECTED = 2; - - protected GroupEditPart groupEditPart; - - public AbstractConnectionManager(GroupEditPart groupEditPart) - { - this.groupEditPart = groupEditPart; - } - - protected WSDLSwitch createSwitch(int selectionType) - { - return new WSDLSwitch(); - } - - public void propagateForward(Object model) - { - if (model instanceof WSDLElement) - { - WSDLSwitch theSwitch = createSwitch(PROPAGATE_FORWARD); - theSwitch.doSwitch((EObject)model); - groupEditPart.scrollToRevealInputConnection(); - } - else - { - removeConnections(); - } - propagateForwardToNext(model); - } - - public void propagateBack(Object model) - { - if (model instanceof WSDLElement) - { - WSDLSwitch theSwitch = createSwitch(PROPAGATE_BACK); - theSwitch.doSwitch((EObject)model); - groupEditPart.scrollToRevealOutputConnection(); - } - else - { - removeConnections(); - } - propagateBackToPrevious(model); - } - - public void setSelectedModelObject(Object model) - { - if (model instanceof Node) - { - Node node = (Node)model; - //Definition definition = groupEditPart.getDefinition(); - while(node != null) - { - if (WSDLConstants.WSDL_NAMESPACE_URI.equals(node.getNamespaceURI())) - { - break; - } - else - { - node = node.getParentNode(); - } - } - if (node instanceof Element) - { - model = WSDLEditorUtil.getInstance().findModelObjectForElement( groupEditPart.getDefinition(), (Element)node); - } - } - - if (model instanceof WSDLElement) - { - WSDLSwitch theSwitch = createSwitch(SELECTED); - theSwitch.doSwitch((EObject)model); - } - else - { - removeConnections(); - } - propagateForwardToNext(model); - propagateBackToPrevious(model); - } - - - protected void removeConnections() - { - groupEditPart.setEmphasizedModelObject(null); - groupEditPart.setInputConnectionModelObject(null); - groupEditPart.setOutputConnectionModelObject(null); - } - - protected void propagateForwardToNext(Object model) - { - GroupEditPart group = groupEditPart.getNext(); - if (group != null) - { - IConnectionManager connectionManager = group.getConnectionManager(); - if (connectionManager != null) - { - connectionManager.propagateForward(model); - } - } - } - - protected void propagateBackToPrevious(Object model) - { - GroupEditPart group = groupEditPart.getPrevious(); - if (group != null) - { - IConnectionManager connectionManager = group.getConnectionManager(); - if (connectionManager != null) - { - connectionManager.propagateBack(model); - } - } - } - - protected Binding getEnclosingBinding(EObject object) - { - Binding binding = null; - if (object instanceof Binding) - { - binding = (Binding)object; - } - else if (object instanceof BindingOperation) - { - binding = (Binding)object.eContainer(); - } - else if (object instanceof BindingInput || - object instanceof BindingOutput || - object instanceof BindingFault) - { - binding = (Binding)object.eContainer().eContainer(); - } - return binding; - } - - protected PortType getEnclosingPortType(EObject object) - { - PortType portType = null; - if (object instanceof Operation) - { - portType = (PortType)object.eContainer(); - } - else if (object instanceof Input || - object instanceof Output || - object instanceof Fault) - { - - portType = object.eContainer() != null ? (PortType)object.eContainer().eContainer() : null; - } - else if (object instanceof PortType) - { - portType = (PortType)object; - } - return portType; - } - - protected Operation getEnclosingOperation(EObject object) - { - Operation operation = null; - if (object instanceof Operation) - { - operation = (Operation)object; - } - else if (object instanceof Input || - object instanceof Output || - object instanceof Fault) - { - operation = (Operation)object.eContainer(); - } - return operation; - } - - protected EObject getMessageReference(EObject object) - { - return (object instanceof Input || - object instanceof Output || - object instanceof Fault) ? object : null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/BindingsGroupConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/BindingsGroupConnectionManager.java deleted file mode 100644 index 61ce315b0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/BindingsGroupConnectionManager.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - - -public class BindingsGroupConnectionManager extends AbstractConnectionManager -{ - public BindingsGroupConnectionManager(GroupEditPart groupEditPart) - { - super(groupEditPart); - } - - - class InternalWSDLSwitch extends WSDLSwitch - { - protected ComponentReferenceUtil util = new ComponentReferenceUtil(groupEditPart.getDefinition()); - - public Object caseBinding(Binding binding) - { - groupEditPart.setEmphasizedModelObject(binding); - groupEditPart.setInputConnectionModelObject(binding); - groupEditPart.setOutputConnectionModelObject(binding); - return Boolean.TRUE; - } - - public Object caseBindingFault(BindingFault bindingFault) - { - groupEditPart.setEmphasizedModelObject(getEnclosingBinding(bindingFault)); - groupEditPart.setInputConnectionModelObject(getEnclosingBinding(bindingFault)); - groupEditPart.setOutputConnectionModelObject(bindingFault); - return Boolean.TRUE; - } - - public Object caseBindingInput(BindingInput bindingInput) - { - groupEditPart.setEmphasizedModelObject(getEnclosingBinding(bindingInput)); - groupEditPart.setInputConnectionModelObject(getEnclosingBinding(bindingInput)); - groupEditPart.setOutputConnectionModelObject(bindingInput); - return Boolean.TRUE; - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - groupEditPart.setEmphasizedModelObject(getEnclosingBinding(bindingOperation)); - groupEditPart.setInputConnectionModelObject(getEnclosingBinding(bindingOperation)); - groupEditPart.setOutputConnectionModelObject(bindingOperation); - return Boolean.TRUE; - } - - public Object caseBindingOutput(BindingOutput bindingOutput) - { - groupEditPart.setEmphasizedModelObject(getEnclosingBinding(bindingOutput)); - groupEditPart.setInputConnectionModelObject(getEnclosingBinding(bindingOutput)); - groupEditPart.setOutputConnectionModelObject(bindingOutput); - return Boolean.TRUE; - } - - public Object caseFault(Fault fault) - { - handleInterfaceHelper(fault); - return Boolean.TRUE; - } - - public Object caseInput(Input input) - { - - handleInterfaceHelper(input); - return Boolean.TRUE; - } - - public Object caseOperation(Operation operation) - { - handleInterfaceHelper(operation); - return Boolean.TRUE; - } - - public Object caseOutput(Output output) - { - handleInterfaceHelper(output); - return Boolean.TRUE; - } - - public Object casePortType(PortType portType) - { - handleInterfaceHelper(portType); - return Boolean.TRUE; - } - - public Object casePort(Port port) - { - Binding binding = port.getEBinding(); - groupEditPart.setEmphasizedModelObject(binding); - groupEditPart.setInputConnectionModelObject(binding); - groupEditPart.setOutputConnectionModelObject(binding); - return Boolean.TRUE; - } - - public Object defaultCase(EObject object) - { - groupEditPart.setEmphasizedModelObject(null); - groupEditPart.setInputConnectionModelObject(null); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - protected Binding getPreviousMatchingBinding(PortType portType) - { - Binding result = null; - Object previousContext = groupEditPart.getOutputConnectionModelObject(); - if (previousContext == null) - { - previousContext = groupEditPart.getEmphasizedModelObject(); - } - if (previousContext instanceof EObject) - { - Binding binding = getEnclosingBinding((EObject)previousContext); - if (binding != null && binding.getEPortType() == portType) - { - result = binding; - } - } - return result; - } - - protected void handleInterfaceHelper(EObject interfaceObject) - { - Binding binding = null; - PortType portType = getEnclosingPortType(interfaceObject); - if (portType != null) - { - binding = getPreviousMatchingBinding(portType); - if (binding == null) - { - List list = util.getBindings(portType); - binding = list.size() > 0 ? (Binding)list.get(0) : null; - } - if (binding != null) - { - groupEditPart.setEmphasizedModelObject(binding); - groupEditPart.setInputConnectionModelObject(binding); - EObject bindingObject = util.getBindingObject(interfaceObject, binding); - groupEditPart.setOutputConnectionModelObject(bindingObject); - } - } - if (binding == null) - { - defaultCase(null); - } - } - } - - protected WSDLSwitch createSwitch(int selectionType) - { - return new InternalWSDLSwitch(); - } - - protected void propagateBackToPrevious(Object model) - { - super.propagateBackToPrevious(groupEditPart.getInputConnectionModelObject()); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ComponentViewerRootEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ComponentViewerRootEditPart.java deleted file mode 100644 index a014114e5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ComponentViewerRootEditPart.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.Panel; -import org.eclipse.gef.EditPart; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.xsd.ui.internal.gef.util.editparts.AbstractComponentViewerRootEditPart; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerLayout; - - -public class ComponentViewerRootEditPart extends AbstractComponentViewerRootEditPart -{ - protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER"; - protected Object input; - - public void setInput(Object newInput) - { - input = newInput; - setModel(input); - refreshChildren(); - } - - protected IFigure createFigure() - { - Panel panel = new Panel(); - panel.setBorder(new MarginBorder(30, 30, 30, 30)); - //panel.setBackgroundColor(GraphicsConstants.red); - - ContainerLayout layout = new ContainerLayout(); - layout.setHorizontal(false); - panel.setLayoutManager(layout); - return panel; - } - - - protected EditPart createChild(Object model) - { - EditPart editPart = null; - if (model == MESSAGE_PLACE_HOLDER) - { - editPart = new NotAvailableMessageEditPart(); - editPart.setModel(model); - } - else - { - editPart = ExtensibleEditPartFactory.getInstance().createEditPart(this, model); - } - return editPart; - } - - - protected List getModelChildren() - { - List result = new ArrayList(); - - if (input != null) - { - result.add(input); - } - else - { - result.add(MESSAGE_PLACE_HOLDER); - } - - return result; - } - - - public void propertyChanged(Object object, String property) - { - if (property == ModelAdapter.CHILDREN_PROPERTY) - { - refreshChildren(); - } - else if (property == ModelAdapter.DETAIL_PROPERTY) - { - refreshVisuals(); - } - else - { - refreshChildren(); - refreshVisuals(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DefinitionEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DefinitionEditPart.java deleted file mode 100644 index b7cf86655..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DefinitionEditPart.java +++ /dev/null @@ -1,417 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -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.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.gef.util.figures.RoundedLineBorder; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.OpenOnSelectionHelper; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerLayout; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout; - -public class DefinitionEditPart extends WSDLEditPart implements ISelectionChangedListener //, ModelAdapterListener -{ - protected Label label; - protected ContainerFigure outlined; - - protected ContainerFigure rightContentPane; - protected ContainerFigure topContentPane; - protected ContainerFigure middleContentPane; - protected ContainerFigure bottomContentPane; - protected static final String SELECTED_EDIT_PART_REFERENCE = "SELECTED_EDIT_PART_REFERENCE"; - - public void activate() - { - super.activate(); - getViewer().addSelectionChangedListener(this); - } - /** - * Apart from the deactivation done in super, the source - * and target connections are deactivated, and the visual - * part of the this is removed. - * - * @see #activate() - */ - public void deactivate() - { - getViewer().removeSelectionChangedListener(this); - super.deactivate(); - } - - protected IFigure[] initContentPanes() - { - IFigure[] contentPanes = new IFigure[4]; - contentPanes[0] = rightContentPane; - contentPanes[1] = topContentPane; - contentPanes[2] = middleContentPane; - contentPanes[3] = bottomContentPane; - return contentPanes; - } - - protected int getContentPane(Object model) - { - int result = 0; - - if (model == SELECTED_EDIT_PART_REFERENCE) - { - result = 0; - } - else if (model instanceof WSDLGroupObject) - { - WSDLGroupObject groupObject = (WSDLGroupObject)model; - switch (groupObject.getType()) - { - case WSDLGroupObject.IMPORTS_GROUP : - case WSDLGroupObject.TYPES_GROUP : - //case WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP : - { - result = 1; - break; - } - case WSDLGroupObject.BINDINGS_GROUP : - case WSDLGroupObject.MESSAGES_GROUP : - case WSDLGroupObject.PORT_TYPES_GROUP : - case WSDLGroupObject.SERVICES_GROUP : - { - result = 2; - break; - } - case WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP : - { - result = 3; - break; - } - } - } - return result; - } - - protected EditPart createChild(Object model) - { - EditPart editPart = null; - if (model == SELECTED_EDIT_PART_REFERENCE) - { - editPart = new PartReferenceSectionEditPart(); - editPart.setModel(model); - editPart.setParent(this); - } - else - { - editPart = super.createChild(model); - } - return editPart; - } - - protected IFigure createFigure() - { - ContainerFigure outer = new ContainerFigure(); - ContainerLayout anchoredLayout = new ContainerLayout() - { - protected int alignFigure(IFigure parent, IFigure child) - { - return (child == outlined) ? 0 : -1; - } - }; - outer.setLayoutManager(anchoredLayout); - /* - ContainerFigure outer = new ConnectedEditPartFigure(this) - { - public IFigure getConnectionFigure() - { - return selectedPartEditPart != null ? selectedPartEditPart.getFigure() : this; - } - };*/ - outer.getContainerLayout().setHorizontal(true); - //outer.setBorder(new MarginBorder(0, 20, 0, 0)); - - outlined = new ContainerFigure(); - outer.add(outlined); - //outlined.getContainerLayout().setHorizontal(false); - outlined.setLayoutManager(new FillLayout()); - outlined.setBorder(new RoundedLineBorder(1, 6)); - outlined.setForegroundColor(groupBorderColor); - - ContainerFigure rightPane = new ContainerFigure(); - rightPane.setBorder(new MarginBorder(0, 0, 0, 300)); - rightPane.getContainerLayout().setHorizontal(false); - outer.add(rightPane); - - //RectangleFigure spacer = new RectangleFigure(); - //rightPane.add(spacer); - //spacer.setPreferredSize(new Dimension(450, 200)); - - rightContentPane = new ContainerFigure(); - rightPane.add(rightContentPane); - rightContentPane.setBorder(new MarginBorder(15, 20, 15, 15)); - - ContainerFigure labelHolder = new ContainerFigure(); - outlined.add(labelHolder); - - label = new Label(); - labelHolder.add(label); - label.setBorder(new MarginBorder(2, 5, 0, 5)); - label.setFont(mediumFont); - label.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_DEFINITION")); - label.setForegroundColor(ColorConstants.black); - - topContentPane = new ContainerFigure(); - outlined.add(topContentPane); - - FillLayout fillLayout = new FillLayout(15); - fillLayout.setHorizontal(true); - topContentPane.setLayoutManager(fillLayout); - topContentPane.setBorder(new MarginBorder(10, 10, 10, 10)); - - middleContentPane = new ContainerFigure(); - outlined.add(middleContentPane); - fillLayout = new FillLayout(15); - fillLayout.setHorizontal(true); - middleContentPane.setLayoutManager(fillLayout); - middleContentPane.setBorder(new MarginBorder(0, 10, 10, 10)); - - bottomContentPane = new ContainerFigure(); - outlined.add(bottomContentPane); - bottomContentPane.setLayoutManager(new FillLayout()); - bottomContentPane.setBorder(new MarginBorder(0, 10, 10, 10)); - - return outer; - } - - //public IFigure getContentPane() - //{ - // return contentPane; - //} - public PartReferenceSectionEditPart getPartReferenceSectionEditPart() - { - PartReferenceSectionEditPart result = null; - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - EditPart editPart = (EditPart)i.next(); - if (editPart.getModel() == SELECTED_EDIT_PART_REFERENCE) - { - result = (PartReferenceSectionEditPart)editPart; - break; - } - } - return result; - } - - public GroupEditPart getGroupEditPart(int type) - { - GroupEditPart result = null; - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof GroupEditPart) - { - GroupEditPart groupEditPart = (GroupEditPart)o; - if (groupEditPart.getType() == type) - { - result = groupEditPart; - break; - } - } - } - return result; - } - - public List getModelChildren() - { - List list = new ArrayList(); - list.add(SELECTED_EDIT_PART_REFERENCE); - list.addAll(super.getModelChildren()); - return list; - } - - public void handleOpenRequest(EditPart editPart) - { - GroupEditPart groupEditPart = null; - if (editPart.getModel() instanceof Import) - { - Import theImport = (Import)editPart.getModel(); - Definition definition = (Definition)getModel(); - OpenOnSelectionHelper helper = new OpenOnSelectionHelper(definition); - helper.openEditor(theImport); - } - else - { - for (EditPart parent = (EditPart)editPart.getParent(); parent != null; parent = parent.getParent()) - { - if (parent instanceof GroupEditPart) - { - groupEditPart = (GroupEditPart)parent; - break; - } - } - - if (groupEditPart != null) - { - GroupEditPart nextGroupEditPart = groupEditPart.getNext(); - if (nextGroupEditPart != null) - { - if (nextGroupEditPart.inputConnection instanceof TreeNodeEditPart) - { - ((TreeNodeEditPart) (nextGroupEditPart.inputConnection)).setExpanded(true); - } - } - GroupEditPart prevGroupEditPart = groupEditPart.getPrevious(); - if (prevGroupEditPart != null) - { - if (prevGroupEditPart.outputConnection instanceof TreeNodeEditPart) - { - ((TreeNodeEditPart) (prevGroupEditPart.outputConnection)).setExpanded(true); - } - } - } - updateConnections(); - } - } - - public void selectionChanged(SelectionChangedEvent event) - { - updateConnections(); - } - - public void updateConnections() - { - // todo - if (isActive()) - { - try - { - final AbstractGraphicalEditPart selectedEditPart = getSelectedEditPart(getViewer().getSelection()); - GroupEditPart group = getContainingGroup(selectedEditPart); - if (group != null && group.getConnectionManager() != null) - { - group.getConnectionManager().setSelectedModelObject(selectedEditPart.getModel()); - } - else if (!isAncestor(getPartReferenceSectionEditPart(), selectedEditPart)) - { - group = getGroupEditPart(WSDLGroupObject.PORT_TYPES_GROUP); - group.getConnectionManager().setSelectedModelObject(null); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - - public GroupEditPart getContainingGroup(AbstractGraphicalEditPart editPart) - { - GroupEditPart result = null; - for (EditPart parent = editPart.getParent(); parent != null; parent = parent.getParent()) - { - if (parent instanceof GroupEditPart) - { - result = (GroupEditPart)parent; - break; - } - } - return result; - } - - public GroupEditPart getNextGroupEditPart(GroupEditPart groupEditPart) - { - GroupEditPart result = null; - GroupEditPart prev = null; - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof GroupEditPart) - { - GroupEditPart editPart = (GroupEditPart)o; - if (prev == groupEditPart) - { - result = editPart; - break; - } - prev = editPart; - } - } - return result; - } - - public GroupEditPart getPreviousGroupEditPart(GroupEditPart groupEditPart) - { - GroupEditPart prev = null; - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof GroupEditPart) - { - GroupEditPart editPart = (GroupEditPart)o; - if (editPart == groupEditPart) - { - break; - } - prev = editPart; - } - } - return prev; - } - - protected AbstractGraphicalEditPart getSelectedEditPart(ISelection selection) - { - AbstractGraphicalEditPart editPart = null; - if (selection instanceof IStructuredSelection) - { - IStructuredSelection s = (IStructuredSelection)selection; - Object first = s.getFirstElement(); - if (first instanceof AbstractGraphicalEditPart) - { - editPart = (AbstractGraphicalEditPart)first; - } - } - return editPart; - } - - public void refreshChildren() - { - super.refreshChildren(); - updateConnections(); - } - - public boolean isAncestor(EditPart ancestor, EditPart child) - { - boolean result = false; - if (ancestor != null && child != null) - { - for (EditPart editPart = child; editPart != null; editPart = editPart.getParent()) - { - if (editPart == ancestor) - { - result = true; - break; - } - } - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DrillDownEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DrillDownEditPart.java deleted file mode 100644 index 07207c3c8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/DrillDownEditPart.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy; -import org.eclipse.gef.handles.MoveHandle; -import org.eclipse.gef.handles.MoveHandleLocator; -import org.eclipse.gef.requests.LocationRequest; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; - -public class DrillDownEditPart extends AbstractGraphicalEditPart -{ - protected Label drillDownButtonLabel; - protected Label label; - - protected IFigure createFigure() - { - ContainerFigure figure = new ContainerFigure(); - drillDownButtonLabel = new Label(); - drillDownButtonLabel.setIcon(WSDLEditorPlugin.getInstance().getImage("icons/forward.gif")); - figure.add(drillDownButtonLabel); - label = new Label(); - label.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_UNKNOWN")); - -// evil hack to provide underlines - boolean isLinux = java.io.File.separator.equals("/"); - if (!isLinux) - { - Font underlineFont = new Font(Display.getCurrent(), "Tahoma", 8, SWT.NONE); - FontData oldData = underlineFont.getFontData()[0]; - FontData fontData = new FontData(oldData.getName(), oldData.getHeight(), SWT.NONE); - try - { - // TODO... clean this awful code up... we seem to be leaking here too - // we can't call this directly since the methods are OS dependant - // fontData.data.lfUnderline = 1 - // so instead we use reflection - Object data = fontData.getClass().getField("data").get(fontData); - System.out.println("data" + data.getClass()); - data.getClass().getField("lfUnderline").setByte(data, (byte)1); - Font font = new Font(Display.getCurrent(), fontData); - label.setFont(font); - } - catch (Exception e) - { - } - } - figure.add(label); - - return figure; - } - - - protected void createEditPolicies() - { - DrillDownEditPartSelectionHandlesEditPolicy policy = new DrillDownEditPartSelectionHandlesEditPolicy(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy); - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT || - request.getType() == RequestConstants.REQ_OPEN) - { - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest)request; - Point p = locationRequest.getLocation(); - - if (hitTest(drillDownButtonLabel, p) || hitTest(label, p)) - { - performDrillDownAction(); - } - } - } - } - - protected EditPart createChild(Object model) - { - return null; - } - - protected List getModelChildren() - { - return Collections.EMPTY_LIST; - } - - public boolean hitTest(IFigure target, Point location) - { - Rectangle b = target.getBounds().getCopy(); - target.translateToAbsolute(b); - return b.contains(location); - } - - protected void performDrillDownAction() - { - Runnable runnable = new Runnable() - { - public void run() - { - ((WSDLComponentViewer)getViewer()).setInput(getModel()); - } - }; - Display.getCurrent().asyncExec(runnable); - } - - private class DrillDownEditPartSelectionHandlesEditPolicy extends SelectionHandlesEditPolicy { - protected List createSelectionHandles() - { - List list = new ArrayList(); - EditPart editPart = getHost(); - - if (editPart instanceof GraphicalEditPart) - { - GraphicalEditPart graphicalEditPart = (GraphicalEditPart)editPart; - IFigure figure = graphicalEditPart.getFigure(); - - MoveHandleLocator loc = new MoveHandleLocator(figure); - MoveHandle moveHandle = new MoveHandle(graphicalEditPart, loc); - list.add(moveHandle); - } - - return list; - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ExtensibleEditPartFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ExtensibleEditPartFactory.java deleted file mode 100644 index 7783b1c3c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ExtensibleEditPartFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -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 ExtensibleEditPartFactory implements EditPartFactory -{ - protected WSDLEditorExtension[] extensions; - protected EditPartFactory[] editPartFactories; - - protected static ExtensibleEditPartFactory instance; - - public static ExtensibleEditPartFactory getInstance() - { - if (instance == null) - { - instance = new ExtensibleEditPartFactory(); - } - return instance; - } - - public ExtensibleEditPartFactory() - { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - - extensions = registry.getRegisteredExtensions(WSDLEditorExtension.EDIT_PART_FACTORY); - editPartFactories = new EditPartFactory[extensions.length]; - for (int i = 0; i < extensions.length; i++) - { - editPartFactories[i] = (EditPartFactory)extensions[i].createExtensionObject(WSDLEditorExtension.EDIT_PART_FACTORY, null); - } - } - - protected EditPartFactory getApplicableEditPartFactory(Object object) - { - EditPartFactory result = null; - for (int i = 0; i < extensions.length; i++) - { - if (extensions[i].isApplicable(object)) - { - result = editPartFactories[i]; - if (result != null) - { - break; - } - } - } - - return result; - } - - public EditPart createEditPart(EditPart parent, Object model) - { - EditPart result = null; - EditPartFactory factory = getApplicableEditPartFactory(model); - if (factory != null) - { - result = factory.createEditPart(parent, model); - } - else - { - result = new UnknownObjectEditPart(); - result.setModel(model); - result.setParent(parent); - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/GroupEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/GroupEditPart.java deleted file mode 100644 index 5d11eeee5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/GroupEditPart.java +++ /dev/null @@ -1,479 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.ScrollPane; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.ViewportLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.gef.util.figures.RoundedLineBorder; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerLayout; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout; - -public class GroupEditPart extends WSDLEditPart -{ - protected ScrollPane scrollpane; - protected Label label; - - protected Object emphasizedModelObject; - protected Object inputConnectionModelObject; - protected Object outputConnectionModelObject; - - public WSDLTreeNodeEditPart emphasizedEditPart; - public AbstractGraphicalEditPart inputConnection; - public AbstractGraphicalEditPart outputConnection; - - public GroupEditPart nextGroupEditPart; - public IConnectionManager connectionManager; - - protected InternalFigureListener figureListener = new InternalFigureListener(); - - class InternalFigureListener implements FigureListener - { - public void figureMoved(IFigure source) - { - ScalableRootEditPart root = (ScalableRootEditPart)getViewer().getRootEditPart(); - root.getLayer(LayerConstants.CONNECTION_LAYER).repaint(); - } - } - - public Object getEmphasizedModelObject() - { - return emphasizedModelObject; - } - - public Definition getDefinition() - { - return ((WSDLGroupObject)getModel()).getDefinition(); - } - - //protected void setEmphasizedObject(EditPart editPart) - //{ - // UnknownObjectEditPart ep = null; - // if (editPart instanceof UnknownObjectEditPart) - // { - // ep = (UnknownObjectEditPart)editPart; - // } - // - // if (emphasizedEditPart != null) - // { - // emphasizedEditPart.setEmphasized(false); - // } - // if (ep != null) - // { - // emphasizedEditPart = ep; - // emphasizedEditPart.setEmphasized(true); - // } - //} - - public void setEmphasizedModelObject(Object model) - { - emphasizedModelObject = model; - - if (emphasizedEditPart != null) - { - emphasizedEditPart.setEmphasized(false); - } - - EditPart editPart = getMatchingChildEditPart(model); - emphasizedEditPart = (editPart instanceof WSDLTreeNodeEditPart) ? (WSDLTreeNodeEditPart)editPart : null; - - if (emphasizedEditPart != null) - { - emphasizedEditPart.setEmphasized(true); - } - } - - public void scrollToRevealEditPart(EditPart editPart) - { - if (editPart instanceof AbstractGraphicalEditPart) - { - scrollToEditPart((AbstractGraphicalEditPart)editPart); - } - } - - public void scrollToRevealInputConnection() - { - if (inputConnection != null) - { - scrollToEditPart(inputConnection); - } - } - - public void scrollToRevealOutputConnection() - { - if (outputConnection != null) - { - scrollToEditPart(outputConnection); - } - } - - public void setInputConnectionModelObject(Object model) - { - inputConnection = getMatchingChildEditPart(model); - inputConnectionModelObject = model; - } - - public Object getInputConnectionModelObject() - { - return inputConnectionModelObject; - } - - public Object getOutputConnectionModelObject() - { - return outputConnectionModelObject; - } - - public void setOutputConnectionModelObject(Object model) - { - outputConnection = getMatchingChildEditPart(model); - outputConnectionModelObject = model; - } - - protected void createConnectionManager() - { - switch (getType()) - { - case WSDLGroupObject.MESSAGES_GROUP : - { - connectionManager = new MessagesGroupConnectionManager(this); - break; - } - case WSDLGroupObject.SERVICES_GROUP : - { - connectionManager = new ServicesGroupConnectionManager(this); - break; - } - case WSDLGroupObject.BINDINGS_GROUP : - { - connectionManager = new BindingsGroupConnectionManager(this); - break; - } - case WSDLGroupObject.PORT_TYPES_GROUP : - { - connectionManager = new PortTypesGroupConnectionManager(this); - break; - } - } - } - - public IConnectionManager getConnectionManager() - { - return connectionManager; - } - - public ContainerFigure outerPane; - - public IFigure createFigure() - { - createConnectionManager(); - - outerPane = new ContainerFigure(); - outerPane.setBorder(new RoundedLineBorder(1, 6)); - outerPane.setForegroundColor(groupBorderColor); - - ContainerFigure r = new ContainerFigure(); - //r.setCornerDimensions(new Dimension(4, 4)); - r.setOutline(false); - r.setMinimumSize(new Dimension(0, 0)); - - r.setFill(true); - - r.setBackgroundColor(groupHeaderColor); - outerPane.add(r); - - //ContainerFigure labelHolder = new ContainerFigure(); - //labelHolder.add(label); - label = new Label(); - label.setForegroundColor(ColorConstants.black); - label.setBorder(new MarginBorder(2, 4, 2, 4)); - r.add(label); //Holder); - - RectangleFigure line = new RectangleFigure(); - line.setPreferredSize(20, 1); - outerPane.add(line); - - int minHeight = 250; - switch (getType()) - { - case WSDLGroupObject.IMPORTS_GROUP : - case WSDLGroupObject.TYPES_GROUP : - { - minHeight = 50; - break; - } - case WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP : - { - minHeight = 150; - break; - } - } - - final int theMinHeight = minHeight; - FillLayout outerLayout = new FillLayout() - { - protected Dimension calculatePreferredSize(IFigure parent, int width, int height) - { - Dimension d = super.calculatePreferredSize(parent, width, height); - d.union(new Dimension(100, theMinHeight)); - return d; - } - }; - outerLayout.setHorizontal(false); - //layout.setSpacing(5); - outerPane.setLayoutManager(outerLayout); - - scrollpane = new ScrollPane(); - scrollpane.setForegroundColor(ColorConstants.black); - scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC); //ScrollPane.ALWAYS); - outerPane.add(scrollpane); - - ContainerFigure pane = new ContainerFigure(); - pane.setBorder(new MarginBorder(5, 8, 5, 8)); - ContainerLayout layout = new ContainerLayout(); - layout.setHorizontal(false); - layout.setSpacing(0); - pane.setLayoutManager(layout); - - Viewport viewport = new Viewport(); - viewport.setContentsTracksHeight(true); - ViewportLayout viewportLayout = new ViewportLayout() - { - protected Dimension calculatePreferredSize(IFigure parent, int width, int height) - { - Dimension d = super.calculatePreferredSize(parent, width, height); - d.height = Math.min(d.height, theMinHeight - 25); //getViewer().getControl().getBounds().height); - return d; - } - }; - viewport.setLayoutManager(viewportLayout); - - scrollpane.setViewport(viewport); - scrollpane.setContents(pane); - pane.addFigureListener(figureListener); - - return outerPane; - } - - protected void refreshVisuals() - { - ModelAdapter adapter = getModelAdapter(getModel()); - if (adapter != null) - { - label.setText((String)adapter.getProperty(getModel(), ModelAdapter.LABEL_PROPERTY)); - //label.setIcon((Image)adapter.getProperty(getModel(), ModelAdapter.IMAGE_PROPERTY)); - } - super.refreshVisuals(); - } - - protected void createEditPolicies() - { - } - - public IFigure getContentPane() - { - return scrollpane.getContents(); - } - - protected void scrollToEditPart(final AbstractGraphicalEditPart targetEditPart) - { - Runnable r = new Runnable() - { - public void run() - { - scrollToEditPartHelper(targetEditPart); - } - }; - Display.getCurrent().asyncExec(r); - } - - protected void scrollToEditPartHelper(AbstractGraphicalEditPart targetEditPart) - { - if (targetEditPart != null) - { - Rectangle r1 = targetEditPart.getFigure().getBounds(); - Rectangle r2 = getContentPane().getBounds(); - scrollpane.scrollVerticalTo((r1.y - r2.y) - scrollpane.getBounds().height / 2); - } - } - - public AbstractGraphicalEditPart getMatchingChildEditPart(Object model) - { - List list = new ArrayList(); - for (Object o = model; o != null && !(o instanceof Definition); o = getParent(o)) - { - list.add(0, o); - } - return getMatchingChildEditPart(this, list, 0, true); - } - - protected Object getParent(Object model) - { - Object parent = null; - if (model instanceof EObject) - { - parent = ((EObject)model).eContainer(); - } - return parent; - } - - protected AbstractGraphicalEditPart getMatchingChildEditPart(AbstractGraphicalEditPart editPart, List list, int index, boolean getUnexpandedParent) - { - AbstractGraphicalEditPart result = (getUnexpandedParent && editPart != this) ? editPart : null; - Object model = list.size() > index ? list.get(index) : null; - if (model != null && editPart != null) - { - for (Iterator i = editPart.getChildren().iterator(); i.hasNext();) - { - AbstractGraphicalEditPart child = (AbstractGraphicalEditPart)i.next(); - if (child.getModel() == model) - { - result = child; - break; - } - } - index++; - if (index < list.size()) - { - result = getMatchingChildEditPart(result, list, index, getUnexpandedParent); - } - } - return result; - } - - public int getType() - { - return ((WSDLGroupObject)getModel()).getType(); - } - - public GroupEditPart getNext() - { - return ((DefinitionEditPart)getParent()).getNextGroupEditPart(this); - } - - public GroupEditPart getPrevious() - { - return ((DefinitionEditPart)getParent()).getPreviousGroupEditPart(this); - } - - private void _refreshChildren() - { - int i; - EditPart editPart; - Object model; - - Map modelToEditPart = new HashMap(); - List children = getChildren(); - - for (i = 0; i < children.size(); i++) - { - editPart = (EditPart)children.get(i); - modelToEditPart.put(editPart.getModel(), editPart); - } - - List modelObjects = getModelChildren(); - - for (i = 0; i < modelObjects.size(); i++) - { - model = modelObjects.get(i); - - //Do a quick check to see if editPart[i] == model[i] - if (i < children.size()) - { - editPart = (EditPart)children.get(i); - Object editPartModel = editPart.getModel(); - if (editPartModel == model) - { - continue; - } - else if (editPartModel.getClass() == model.getClass()) - { - modelToEditPart.remove(editPartModel); - - if (isActive()) - editPart.deactivate(); - - editPart.setModel(model); - - if (isActive()) - { - editPart.activate(); - editPart.refresh(); - } - continue; - } - } - - //Look to see if the EditPart is already around but in the wrong location - editPart = (EditPart)modelToEditPart.get(model); - - if (editPart != null) - reorderChild(editPart, i); - else - { - //An editpart for this model doesn't exist yet. Create and insert one. - editPart = createChild(model); - addChild(editPart, i); - } - } - List trash = new ArrayList(); - for (; i < children.size(); i++) - trash.add(children.get(i)); - for (i = 0; i < trash.size(); i++) - { - EditPart ep = (EditPart)trash.get(i); - removeChild(ep); - } - } - - public void refreshChildren() - { - boolean reuseChildren = false; - if (getViewer() instanceof WSDLComponentViewer) - { - WSDLComponentViewer wsdlComponentViewer = (WSDLComponentViewer)getViewer(); - reuseChildren = wsdlComponentViewer.isPreserveExpansionEnabled(); - } - - if (reuseChildren) - { - _refreshChildren(); - } - else - { - super.refreshChildren(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IConnectionManager.java deleted file mode 100644 index bd0d0a8c0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IConnectionManager.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -public interface IConnectionManager -{ - public void propagateForward(Object model); - public void propagateBack(Object model); - public void setSelectedModelObject(Object model); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IFeedbackHandler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IFeedbackHandler.java deleted file mode 100644 index b6ac2b5f0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/IFeedbackHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -public interface IFeedbackHandler -{ - public void addFeedback(); - public void removeFeedback(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/MessagesGroupConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/MessagesGroupConnectionManager.java deleted file mode 100644 index 231455d01..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/MessagesGroupConnectionManager.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; - - -public class MessagesGroupConnectionManager extends AbstractConnectionManager -{ - public MessagesGroupConnectionManager(GroupEditPart groupEditPart) - { - super(groupEditPart); - } - - class InternalWSDLSwitch extends WSDLSwitch - { - public Object caseFault(Fault fault) - { - groupEditPart.setEmphasizedModelObject(fault.getEMessage()); - groupEditPart.setInputConnectionModelObject(fault.getEMessage()); - groupEditPart.setOutputConnectionModelObject(getFirstPart(fault.getEMessage())); - return Boolean.TRUE; - } - - public Object caseInput(Input input) - { - groupEditPart.setEmphasizedModelObject(input.getEMessage()); - groupEditPart.setInputConnectionModelObject(input.getEMessage()); - groupEditPart.setOutputConnectionModelObject(getFirstPart(input.getEMessage())); - return Boolean.TRUE; - } - - public Object caseMessage(Message message) - { - groupEditPart.setEmphasizedModelObject(message); - groupEditPart.setInputConnectionModelObject(message); - groupEditPart.setOutputConnectionModelObject(getFirstPart(message)); - return Boolean.TRUE; - } - - public Object caseOutput(Output output) - { - groupEditPart.setEmphasizedModelObject(output.getEMessage()); - groupEditPart.setInputConnectionModelObject(output.getEMessage()); - groupEditPart.setOutputConnectionModelObject(getFirstPart(output.getEMessage())); - return Boolean.TRUE; - } - - public Object casePart(Part part) - { - groupEditPart.setEmphasizedModelObject(part.eContainer()); - groupEditPart.setInputConnectionModelObject(part.eContainer()); - groupEditPart.setOutputConnectionModelObject(part); - return Boolean.TRUE; - } - - public Object defaultCase(EObject object) - { - groupEditPart.setEmphasizedModelObject(null); - groupEditPart.setInputConnectionModelObject(null); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object doSwitch(EObject theEObject) - { - Object result = super.doSwitch(theEObject); - ((DefinitionEditPart)groupEditPart.getParent()).getPartReferenceSectionEditPart().setInput(groupEditPart.getOutputConnectionModelObject()); - return result; - } - } - - protected WSDLSwitch createSwitch(int selectionType) - { - return new InternalWSDLSwitch(); - } - - protected Part getFirstPart(Message message) - { - Part result = null; - if (message != null) - { - List parts = message.getEParts(); - result = (parts.size() > 0) ? (Part)parts.get(0) : null; - } - return result; - } - - protected void propagateBackToPrevious(Object model) - { - model = (model instanceof Part) ?((Part)model).eContainer() : model; - super.propagateBackToPrevious(model); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/NotAvailableMessageEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/NotAvailableMessageEditPart.java deleted file mode 100644 index 6a4a500a4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/NotAvailableMessageEditPart.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - - -public class NotAvailableMessageEditPart extends AbstractGraphicalEditPart -{ - public NotAvailableMessageEditPart() - { - } - - protected IFigure createFigure() - { - Label label = new Label(WSDLEditorPlugin.getWSDLString("_UI_LABEL_VIEW_NOT_AVAILABLE")); - return label; - } - - protected List getModelChildren() - { - return Collections.EMPTY_LIST; - } - - protected EditPart createChild(Object model) - { - return null; - } - - protected void createEditPolicies() - { - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PartReferenceSectionEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PartReferenceSectionEditPart.java deleted file mode 100644 index 8ab8deebe..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PartReferenceSectionEditPart.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; -import org.eclipse.xsd.XSDElementDeclaration; - - -public class PartReferenceSectionEditPart extends AbstractGraphicalEditPart implements ModelAdapterListener -{ - protected Object input; - protected Definition definition; - - protected IFigure createFigure() - { - ContainerFigure outer = new ContainerFigure(); - return outer; - } - - protected void setInput(Object object) - { - if (input != null) - { - removeModelAdapterListener(input, this); - removeModelAdapterListener(definition, this); - } - input = object; - if (input != null) - { - addModelAdapterListener(input, this); - definition = getParent() != null ? (Definition)getParent().getModel() : null; - addModelAdapterListener(definition, this); - } - refresh(); - getFigure().repaint(); - } - - public void deactivate() - { - if (input != null) - { - removeModelAdapterListener(input, this); - removeModelAdapterListener(definition, this); - } - super.deactivate(); - } - - protected List getModelChildren() - { - List list = new ArrayList(); - if (input instanceof Part) - { - Part part = (Part)input; - Object component = part.getTypeDefinition(); - if (component != null) - { - // TODO... i'm pulling a fast one here.... we should call the extension - // to see if he wants to show a child here - if (component instanceof org.eclipse.xsd.XSDComplexTypeDefinition) - { - list.add(component); - } - } - else - { - // This is before the new org.eclipse.wst.wsdl model - // where it handled DOM nodes - // component = part.getElement(); - XSDElementDeclaration ed = part.getElementDeclaration(); - if (ed != null && ed.getContainer() != null) - { - list.add(ed); - } - } - } - return list; - } - - protected void createEditPolicies() - { - } - - protected EditPart createChild(Object model) - { - return getEditPartFactory().createEditPart(this, model); - } - - protected EditPartFactory getEditPartFactory() - { - return ExtensibleEditPartFactory.getInstance(); - } - - public void propertyChanged(Object object, String property) - { - refreshChildren(); - } - - protected ModelAdapter getModelAdapter(Object modelObject) - { - return WSDLGraphModelAdapterFactory.getWSDLGraphModelAdapterFactory().getAdapter(modelObject); - } - - protected void addModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - protected void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.removeListener(listener); - } - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PortTypesGroupConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PortTypesGroupConnectionManager.java deleted file mode 100644 index d6520e2a7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/PortTypesGroupConnectionManager.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.Iterator; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - - -public class PortTypesGroupConnectionManager extends AbstractConnectionManager -{ - public PortTypesGroupConnectionManager(GroupEditPart groupEditPart) - { - super(groupEditPart); - } - - - class InternalWSDLSwitch extends WSDLSwitch - { - public boolean isBindingGroupShowing() - { - GroupEditPart prevGroupEditPart = groupEditPart.getPrevious(); - return prevGroupEditPart != null && prevGroupEditPart.getType() == WSDLGroupObject.BINDINGS_GROUP; - } - - public Object caseBinding(Binding binding) - { - Object portType = getPortTypeForBindingObject(binding); - groupEditPart.setEmphasizedModelObject(portType); - groupEditPart.setInputConnectionModelObject(portType); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object caseBindingFault(BindingFault bindingFault) - { - groupEditPart.setEmphasizedModelObject(getPortTypeForBindingObject(bindingFault)); - Fault fault = ComponentReferenceUtil.computeFault(bindingFault); - groupEditPart.setInputConnectionModelObject(fault); - groupEditPart.setOutputConnectionModelObject(fault); - return Boolean.TRUE; - } - - public Object caseBindingInput(BindingInput bindingInput) - { - groupEditPart.setEmphasizedModelObject(getPortTypeForBindingObject(bindingInput)); - Input input = ComponentReferenceUtil.computeInput(bindingInput); - groupEditPart.setInputConnectionModelObject(input); - groupEditPart.setOutputConnectionModelObject(input); - return Boolean.TRUE; - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - groupEditPart.setEmphasizedModelObject(getPortTypeForBindingObject(bindingOperation)); - groupEditPart.setInputConnectionModelObject(ComponentReferenceUtil.computeOperation(bindingOperation)); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object caseBindingOutput(BindingOutput bindingOutput) - { - groupEditPart.setEmphasizedModelObject(getPortTypeForBindingObject(bindingOutput)); - Output output = ComponentReferenceUtil.computeOutput(bindingOutput); - groupEditPart.setInputConnectionModelObject(output); - groupEditPart.setOutputConnectionModelObject(output); - return Boolean.TRUE; - } - - public Object caseFault(Fault fault) - { - groupEditPart.setEmphasizedModelObject(getEnclosingPortType(fault)); - if (isBindingGroupShowing()) - { - groupEditPart.setInputConnectionModelObject(fault); - } - else - { - groupEditPart.setInputConnectionModelObject(getEnclosingPortType(fault)); - } - groupEditPart.setOutputConnectionModelObject(fault); - return Boolean.TRUE; - } - - public Object caseInput(Input input) - { - groupEditPart.setEmphasizedModelObject(getEnclosingPortType(input)); - if (isBindingGroupShowing()) - { - groupEditPart.setInputConnectionModelObject(input); - } - else - { - groupEditPart.setInputConnectionModelObject(getEnclosingPortType(input)); - } - groupEditPart.setOutputConnectionModelObject(input); - return Boolean.TRUE; - } - - public Object caseMessage(Message message) - { - Object previousContext = groupEditPart.getOutputConnectionModelObject(); - if (previousContext == null) - { - previousContext = groupEditPart.getEmphasizedModelObject(); - } - - EObject messageReference = null; - if (previousContext == null || previousContext instanceof EObject) - { - messageReference = getMessageReference(message, (EObject)previousContext); - } - - if (messageReference != null) - { - doSwitch(messageReference); - } - else - { - defaultCase(null); - } - return Boolean.TRUE; - } - - public Object caseOperation(Operation operation) - { - groupEditPart.setEmphasizedModelObject(getEnclosingPortType(operation)); - if (isBindingGroupShowing()) - { - groupEditPart.setInputConnectionModelObject(operation); - } - else - { - groupEditPart.setInputConnectionModelObject(getEnclosingPortType(operation)); - } - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object caseOutput(Output output) - { - groupEditPart.setEmphasizedModelObject(getEnclosingPortType(output)); - if (isBindingGroupShowing()) - { - groupEditPart.setInputConnectionModelObject(output); - } - else - { - groupEditPart.setInputConnectionModelObject(getEnclosingPortType(output)); - } - groupEditPart.setOutputConnectionModelObject(output); - return Boolean.TRUE; - } - - public Object casePortType(PortType portType) - { - groupEditPart.setEmphasizedModelObject(portType); - groupEditPart.setInputConnectionModelObject(portType); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object casePort(Port port) - { - Binding binding = port.getEBinding(); - PortType portType = binding != null ? binding.getEPortType() : null; - groupEditPart.setEmphasizedModelObject(portType); - groupEditPart.setInputConnectionModelObject(portType); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - public Object defaultCase(EObject object) - { - groupEditPart.setEmphasizedModelObject(null); - groupEditPart.setInputConnectionModelObject(null); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - } - - protected WSDLSwitch createSwitch(int selectionType) - { - return new InternalWSDLSwitch(); - } - - protected PortType getPortTypeForBindingObject(EObject object) - { - Binding binding = getEnclosingBinding(object); - return binding.getEPortType(); - } - - public void propagateForward(Object model) - { - if (model instanceof WSDLElement) - { - WSDLSwitch theSwitch = createSwitch(PROPAGATE_FORWARD); - theSwitch.doSwitch((EObject)model); - groupEditPart.scrollToRevealInputConnection(); - } - else - { - removeConnections(); - } - - Object o = groupEditPart.getOutputConnectionModelObject(); - propagateForwardToNext(o != null ? o : model); - } - - protected void propagateBackToPrevious(Object model) - { - model = (model instanceof Message) ? groupEditPart.getInputConnectionModelObject() : model; - super.propagateBackToPrevious(model); - } - - - protected Message getReferencedMessage(EObject o) - { - Message result = null; - if (o instanceof Input) - { - result = ((Input)o).getEMessage(); - } - else if (o instanceof Output) - { - result = ((Output)o).getEMessage(); - } - else if (o instanceof Fault) - { - result = ((Fault)o).getEMessage(); - } - return result; - } - - protected boolean isMatchingMessageReference(EObject messageReference, Message message) - { - Message m = getReferencedMessage(messageReference); - return (m != null) && (m == messageReference); - } - - public EObject getMessageReference(Message message, EObject prevContext) - { - EObject result = null; - - PortType prevPortType = getEnclosingPortType(prevContext); - Operation prevOperation = getEnclosingOperation(prevContext); - EObject prevMessageReference = getMessageReference(prevContext); - - if (prevPortType != null) - { - result = getMessageReference(message, prevPortType, prevOperation, prevMessageReference); - } - if (result == null) - { - Definition definition = groupEditPart.getDefinition(); - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - for (Iterator i = util.getPortTypes().iterator(); i.hasNext(); ) - { - PortType portType = (PortType)i.next(); - result = getMessageReference(message, portType, null, null); - - if (result != null) - { - break; - } - } - } - return result; - } - - public EObject getMessageReference(Message message, PortType portType, Operation prevOperation, EObject prevMessageReference) - { - EObject result = null; - if (prevMessageReference != null && isMatchingMessageReference(prevMessageReference, message)) - { - result = prevMessageReference; - } - - if (result == null && prevOperation != null) - { - result = getMessageReference(message, prevOperation); - } - - if (result == null) - { - for (Iterator i = portType.getOperations().iterator(); i.hasNext();) - { - Operation operation = (Operation)i.next(); - result = getMessageReference(message, operation); - if (result != null) - { - break; - } - } - } - return result; - } - - public EObject getMessageReference(Message message, Operation operation) - { - EObject result = null; - Input input = operation.getEInput(); - Output output = operation.getEOutput(); - if (input != null && input.getMessage() == message) - { - result = input; - } - else if (output != null && output.getMessage() == message) - { - result = output; - } - if (result == null) - { - for (Iterator i = operation.getEFaults().iterator(); i.hasNext();) - { - Fault fault = (Fault)i.next(); - if (fault.getMessage() == message) - { - result = fault; - break; - } - } - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ServicesGroupConnectionManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ServicesGroupConnectionManager.java deleted file mode 100644 index cc9543d60..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/ServicesGroupConnectionManager.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - - -public class ServicesGroupConnectionManager extends AbstractConnectionManager -{ - public ServicesGroupConnectionManager(GroupEditPart groupEditPart) - { - super(groupEditPart); - } - - protected class InternalWSDLSwitch extends WSDLSwitch - { - public Object caseBinding(Binding binding) - { - handleBindingHelper(binding); - return Boolean.TRUE; - } - - public Object caseBindingFault(BindingFault bindingFault) - { - handleBindingHelper(getEnclosingBinding(bindingFault)); - return Boolean.TRUE; - } - - public Object caseBindingInput(BindingInput bindingInput) - { - handleBindingHelper(getEnclosingBinding(bindingInput)); - return Boolean.TRUE; - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - handleBindingHelper(getEnclosingBinding(bindingOperation)); - return Boolean.TRUE; - } - - public Object caseBindingOutput(BindingOutput bindingOutput) - { - handleBindingHelper(getEnclosingBinding(bindingOutput)); - return Boolean.TRUE; - } - - public Object caseFault(Fault fault) - { - handlePortTypeHelper(getEnclosingPortType(fault)); - return Boolean.TRUE; - } - - public Object caseInput(Input input) - { - handlePortTypeHelper(getEnclosingPortType(input)); - return Boolean.TRUE; - } - - public Object caseOperation(Operation operation) - { - handlePortTypeHelper(getEnclosingPortType(operation)); - return Boolean.TRUE; - } - - public Object caseOutput(Output output) - { - handlePortTypeHelper(getEnclosingPortType(output)); - return Boolean.TRUE; - } - - public Object casePort(Port port) - { - groupEditPart.setEmphasizedModelObject(port); - groupEditPart.setOutputConnectionModelObject(port); - return Boolean.TRUE; - } - - public Object casePortType(PortType portType) - { - handlePortTypeHelper(portType); - return Boolean.TRUE; - } - - public Object defaultCase(EObject object) - { - groupEditPart.setEmphasizedModelObject(null); - groupEditPart.setOutputConnectionModelObject(null); - return Boolean.TRUE; - } - - // - protected void handlePortTypeHelper(PortType portType) - { - if (portType != null) - { - Port port = null; - Object previousContext = groupEditPart.getOutputConnectionModelObject(); - if (previousContext == null) - { - previousContext = groupEditPart.getEmphasizedModelObject(); - } - if (previousContext instanceof Port) - { - Port previousPort = (Port)previousContext; - if (previousPort.getEBinding() != null && previousPort.getEBinding().getEPortType() == portType) - { - port = previousPort; - } - } - - if (port == null) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(groupEditPart.getDefinition()); - List list = util.getPortsForPortType(portType); - if (list.size() > 0) - { - port = (Port)list.get(0); - } - } - - groupEditPart.setEmphasizedModelObject(port); - groupEditPart.setOutputConnectionModelObject(port); - } - } - - protected void handleBindingHelper(Binding binding) - { - if (binding != null) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(groupEditPart.getDefinition()); - List list = util.getPortsForBinding(binding); - Port port = null; - if (list.size() > 0) - { - port = (Port)list.get(0); - } - groupEditPart.setEmphasizedModelObject(port); - groupEditPart.setOutputConnectionModelObject(port); - } - } - } - - protected WSDLSwitch createSwitch(int selectionType) - { - return new InternalWSDLSwitch(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/TreeNodeEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/TreeNodeEditPart.java deleted file mode 100644 index cd66aab54..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/TreeNodeEditPart.java +++ /dev/null @@ -1,343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editpolicies.SelectionEditPolicy; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.gef.util.editparts.InteractorHelper; -import org.eclipse.wst.wsdl.ui.internal.graph.GraphicsConstants; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.wsdl.ui.internal.graph.editpolicies.WSDLSelectionHandlesEditPolicyImpl; -import org.eclipse.wst.wsdl.ui.internal.graph.figures.TreeNodeContentFigure; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; - -public abstract class TreeNodeEditPart extends AbstractGraphicalEditPart implements ModelAdapterListener, GraphicsConstants, IFeedbackHandler -{ - protected Label label; - protected Label label2; - protected ContainerFigure labelHolder = new ContainerFigure(); - protected TreeNodeContentFigure contentFigure; - protected InteractorHelper interactorHelper; - protected boolean isSelected = false; - protected boolean isReadOnly = false; - - public void activate() - { - super.activate(); - addModelAdapterListener(getModel(), this); - //viewer = getViewer(); - } - - int removeNotifyCount = 0; - - public void removeNotify() - { - removeNotifyCount++; - if (removeNotifyCount == 1) - { - super.removeNotify(); - } - } - - /** - * Apart from the deactivation done in super, the source - * and target connections are deactivated, and the visual - * part of the this is removed. - * - * @see #activate() - */ - public void deactivate() - { - removeModelAdapterListener(getModel(), this); - super.deactivate(); - } - - protected void createEditPolicies() - { - //SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl(); - //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy); - - SelectionEditPolicy feedBackSelectionEditPolicy = new WSDLSelectionHandlesEditPolicyImpl(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, feedBackSelectionEditPolicy); - } - - protected EditPart createChild(Object model) - { - return getEditPartFactory().createEditPart(this, model); - } - - public void propertyChanged(Object object, String property) - { - if (property == ModelAdapter.CHILDREN_PROPERTY) - { - refreshChildren(); - } - else if (property == ModelAdapter.DETAIL_PROPERTY) - { - refreshVisuals(); - } - else - { - refreshChildren(); - refreshVisuals(); - } - } - - protected IFigure createFigure() - { - createContentFigure(); - createFigureContent(); - return contentFigure; - } - - protected void createContentFigure() - { - contentFigure = new TreeNodeContentFigure(); - } - - protected void createFigureContent() - { - // add a bit of space between the interactor and icon - // - RectangleFigure space = new RectangleFigure(); - space.setVisible(false); - space.setPreferredSize(new Dimension(3, 3)); - contentFigure.getIconArea().add(space); - - labelHolder = new ContainerFigure(); - labelHolder.setFill(true); - contentFigure.getIconArea().add(labelHolder); - - label = new Label(WSDLEditorPlugin.getWSDLString("_UI_LABEL_UNKNOWN_OBJECT")); - label.setForegroundColor(ColorConstants.black); - labelHolder.add(label); - - interactorHelper = new InteractorHelper(this, contentFigure.getInteractor(), contentFigure.getInnerContentArea()); - } - - public IFigure getContentPane() - { - return contentFigure.getInnerContentArea(); - } - - public Color computeLabelColor() - { - Color color = ColorConstants.black; - if (isSelected) - { - color = ColorConstants.white; - } - else if (isReadOnly) - { - color = ColorConstants.gray; - } - return color; - } - - public void refreshVisuals() - { - ModelAdapter adapter = getModelAdapter(getModel()); - if (adapter != null) - { - isReadOnly = Boolean.TRUE.equals(adapter.getProperty(getModel(), "isReadOnly")); - label.setForegroundColor(computeLabelColor()); - label.setText((String)adapter.getProperty(getModel(), ModelAdapter.LABEL_PROPERTY)); - label.setIcon((Image)adapter.getProperty(getModel(), ModelAdapter.IMAGE_PROPERTY)); - } - else - { - label.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_UNKNOWN_NODE") + getModel().getClass().getName()); - } - } - - private void _refreshChildren() - { - int i; - EditPart editPart; - Object model; - - Map modelToEditPart = new HashMap(); - List children = getChildren(); - - for (i = 0; i < children.size(); i++) - { - editPart = (EditPart)children.get(i); - modelToEditPart.put(editPart.getModel(), editPart); - } - - List modelObjects = getModelChildren(); - - for (i = 0; i < modelObjects.size(); i++) - { - model = modelObjects.get(i); - - //Do a quick check to see if editPart[i] == model[i] - if (i < children.size()) - { - editPart = (EditPart)children.get(i); - Object editPartModel = editPart.getModel(); - if (editPartModel == model) - { - continue; - } - else if (editPartModel.getClass() == model.getClass()) - { - modelToEditPart.remove(editPartModel); - - if (isActive()) - editPart.deactivate(); - - editPart.setModel(model); - - if (isActive()) - { - editPart.activate(); - editPart.refresh(); - } - continue; - } - } - - //Look to see if the EditPart is already around but in the wrong location - editPart = (EditPart)modelToEditPart.get(model); - - if (editPart != null) - reorderChild(editPart, i); - else - { - //An editpart for this model doesn't exist yet. Create and insert one. - editPart = createChild(model); - addChild(editPart, i); - } - } - List trash = new ArrayList(); - for (; i < children.size(); i++) - trash.add(children.get(i)); - for (i = 0; i < trash.size(); i++) - { - EditPart ep = (EditPart)trash.get(i); - removeChild(ep); - } - } - - public void refreshChildren() - { - - boolean reuseChildren = false; - if (getViewer() instanceof WSDLComponentViewer) - { - WSDLComponentViewer wsdlComponentViewer = (WSDLComponentViewer)getViewer(); - reuseChildren = wsdlComponentViewer.isPreserveExpansionEnabled(); - } - - if (reuseChildren) - { - _refreshChildren(); - } - else - { - super.refreshChildren(); - } - - contentFigure.getInteractor().setVisible(hasChildren()); - } - - public List getModelChildren() - { - return contentFigure.getInteractor().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST; - } - - protected List getModelChildrenHelper() - { - List result = null; - ModelAdapter modelAdapter = getModelAdapter(getModel()); - if (modelAdapter != null) - { - result = (List)modelAdapter.getProperty(getModel(), ModelAdapter.CHILDREN_PROPERTY); - } - return result != null ? result : Collections.EMPTY_LIST; - } - - protected boolean hasChildren() - { - return getModelChildrenHelper().size() > 0; - } - - protected abstract ModelAdapter getModelAdapter(Object model); - - protected EditPartFactory getEditPartFactory() - { - return ExtensibleEditPartFactory.getInstance(); - } - - protected void addModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - protected void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.removeListener(listener); - } - } - - public void addFeedback() - { - isSelected = true; - labelHolder.setBackgroundColor(ColorConstants.black); - label.setForegroundColor(computeLabelColor()); - labelHolder.setFill(true); - } - - public void removeFeedback() - { - isSelected = false; - labelHolder.setBackgroundColor(null); - label.setForegroundColor(computeLabelColor()); - labelHolder.setFill(false); - } - - public boolean isExpanded() - { - return contentFigure.getInteractor().isExpanded(); - } - - public void setExpanded(boolean arg) - { - interactorHelper.setExpanded(arg); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/UnknownObjectEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/UnknownObjectEditPart.java deleted file mode 100644 index 2354fbf7c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/UnknownObjectEditPart.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; - - -public class UnknownObjectEditPart extends TreeNodeEditPart -{ - protected ModelAdapter getModelAdapter(Object model) - { - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPart.java deleted file mode 100644 index a8872a4ce..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPart.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.editpolicies.SelectionEditPolicy; -import org.eclipse.wst.wsdl.ui.internal.gef.util.editparts.MultiContentPaneEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.GraphicsConstants; -import org.eclipse.wst.wsdl.ui.internal.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; - - -public abstract class WSDLEditPart extends MultiContentPaneEditPart implements ModelAdapterListener, GraphicsConstants -{ - /** - * Activates the <code>EditPart</code> by setting the - * appropriate flags, and activating its children. - * activation signals to the EditPart that is should start observing - * it's model, and that is should support editing at this time. - * An EditPart will have a parent prior to activiation. - * @see #deactivate() - */ - public void activate() - { - super.activate(); - addModelAdapterListener(getModel(), this); - } - /** - * Apart from the deactivation done in super, the source - * and target connections are deactivated, and the visual - * part of the this is removed. - * - * @see #activate() - */ - public void deactivate() - { - removeModelAdapterListener(getModel(), this); - super.deactivate(); - } - - protected void createEditPolicies() - { - SelectionEditPolicy policy = new SelectionEditPolicy() - { - protected void hideSelection() - { - EditPart editPart = getHost(); - if (editPart instanceof IFeedbackHandler) - { - ((IFeedbackHandler)editPart).removeFeedback(); - } - } - - protected void showSelection() - { - EditPart editPart = getHost(); - if (editPart instanceof IFeedbackHandler) - { - ((IFeedbackHandler)editPart).addFeedback(); - } - } - }; - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy); - } - - protected EditPart createChild(Object model) - { - return getEditPartFactory().createEditPart(this, model); - } - - public void propertyChanged(Object object, String property) - { - if (property == ModelAdapter.CHILDREN_PROPERTY) - { - refreshChildren(); - } - else if (property == ModelAdapter.DETAIL_PROPERTY) - { - refreshVisuals(); - } - else - { - refreshChildren(); - refreshVisuals(); - } - } - - protected List getModelChildren() - { - List result = null; - ModelAdapter modelAdapter = getModelAdapter(getModel()); - if (modelAdapter != null) - { - result = (List)modelAdapter.getProperty(getModel(), ModelAdapter.CHILDREN_PROPERTY); - } - return result != null ? result : Collections.EMPTY_LIST; - } - - protected EditPartFactory getEditPartFactory() - { - return ExtensibleEditPartFactory.getInstance(); - } - - protected ModelAdapter getModelAdapter(Object modelObject) - { - // TODO : port check - return WSDLGraphModelAdapterFactory.getWSDLGraphModelAdapterFactory().getAdapter(modelObject); -// return WSDLGraphModelAdapterFactory.EcoreUtil.getAdapter(getWSDLGraphModelAdapterFactory().eAdapters(),modelObject); - } - - protected void addModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - protected void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getModelAdapter(modelObject); - if (adapter != null) - { - adapter.removeListener(listener); - } - } - - public boolean hitTest(IFigure target, Point location) - { - Rectangle b = target.getBounds().getCopy(); - target.translateToAbsolute(b); - return b.contains(location); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPartFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPartFactory.java deleted file mode 100644 index 62e4a2c6e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLEditPartFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; - - -public class WSDLEditPartFactory implements EditPartFactory -{ - protected static WSDLEditPartFactory instance; - - public static WSDLEditPartFactory getInstance() - { - if (instance == null) - { - instance = new WSDLEditPartFactory(); - } - return instance; - } - - - - public EditPart createEditPart(final EditPart parent, Object model) - { - WSDLSwitch wsdlSwitch = new WSDLSwitch() - { - public Object caseWSDLElement(WSDLElement wsdlElement) - { - return new WSDLTreeNodeEditPart(); - } - - public Object caseDefinition(Definition definition) - { - return new DefinitionEditPart(); - } - - public Object defaultCase(EObject object) - { - return new WSDLTreeNodeEditPart(); - } - }; - - - EditPart editPart = null; - if (model instanceof EObject) - { - editPart = (EditPart)wsdlSwitch.doSwitch((EObject)model); - } - else if (model instanceof WSDLGroupObject) - { - editPart = new GroupEditPart(); - } - - if (editPart != null) - { - editPart.setModel(model); - editPart.setParent(parent); - } - else - { - System.out.println("can't create editPart for " + model); - Thread.dumpStack(); - } - return editPart; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLTreeNodeEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLTreeNodeEditPart.java deleted file mode 100644 index a6c9339db..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editparts/WSDLTreeNodeEditPart.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editparts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.swt.graphics.Color; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.graph.editpolicies.WSDLDragAndDropEditPolicy; -import org.eclipse.wst.wsdl.ui.internal.graph.editpolicies.WSDLGraphNodeDragTracker; -import org.eclipse.wst.wsdl.ui.internal.graph.editpolicies.WSDLSelectionHandlesEditPolicyImpl; -import org.eclipse.wst.wsdl.ui.internal.graph.figures.TreeNodeContentFigure; -import org.eclipse.wst.wsdl.ui.internal.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - -public class WSDLTreeNodeEditPart extends TreeNodeEditPart -{ - protected Label label2; - protected boolean isEmphasized = false; - - protected static final Color emphasisColor = new Color(null, 238, 238, 238); - protected static final Color label2ForegroundColor = new Color(null, 82, 82, 158); - protected static final Color label2ForegroundColorSelected = new Color(null, 182, 182, 255); - - protected ModelAdapter getModelAdapter(Object modelObject) - { - return WSDLGraphModelAdapterFactory.getWSDLGraphModelAdapterFactory().getAdapter(modelObject); - } - - protected void createContentFigure() - { - contentFigure = new TreeNodeContentFigure() - { - public IFigure getConnectionFigure() - { - return isTopLevel() ? outlinedArea : iconArea; - } - }; - } - - protected boolean isTopLevel() - { - return getParent() instanceof GroupEditPart; - } - - protected void createFigureContent() - { - super.createFigureContent(); - - if (getModel() instanceof Part) - { - label2 = new Label(); - labelHolder.add(label2); - label2.setBorder(new MarginBorder(0, 5, 0, 0)); - label2.setForegroundColor(label2ForegroundColor); - } - } - - public void setEmphasized(boolean isEmphasized) - { - this.isEmphasized = isEmphasized; - refreshVisuals(); - } - - protected void updateEmphasis() - { - boolean isEmphasisShowing = isEmphasized && (!isSelected || getModelChildren().size() > 0); - if (isEmphasisShowing) - { - contentFigure.getOutlinedArea().setBackgroundColor(emphasisColor); - } - - contentFigure.getOutlinedArea().setFill(isEmphasisShowing); - contentFigure.getOutlinedArea().setOutlined(isEmphasisShowing); - contentFigure.setForegroundColor(elementBorderColor); - } - - public void refreshVisuals() - { - updateEmphasis(); - - super.refreshVisuals(); - - if (label2 != null) - { - Part part = (Part)getModel(); - //String label = ComponentReferenceUtil.isType(part) ? "type" : "element"; - String value = ComponentReferenceUtil.getPartReferenceValue(part); - label2.setText("(" + value + ")"); - } - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_OPEN) - { - for (EditPart parent = (EditPart)getParent(); parent != null; parent = parent.getParent()) - { - if (parent instanceof DefinitionEditPart) - { - ((DefinitionEditPart)parent).handleOpenRequest(this); - break; - } - } - } - //else if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) - //{ - // performDirectEdit(); - //} - } - - public void addFeedback() - { - super.addFeedback(); - if (label2 != null) - { - label2.setForegroundColor(label2ForegroundColorSelected); - } - updateEmphasis(); - } - - public void removeFeedback() - { - super.removeFeedback(); - if (label2 != null) - { - label2.setForegroundColor(label2ForegroundColor); - } - updateEmphasis(); - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - selectionHandlesEditPolicy = new WSDLSelectionHandlesEditPolicyImpl(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new WSDLDragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy)); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy); - } - - WSDLSelectionHandlesEditPolicyImpl selectionHandlesEditPolicy; - - public IFigure getSelectionFigure() - { - return getFigure(); - } - - public DragTracker getDragTracker(Request request) - { - return new WSDLGraphNodeDragTracker((EditPart)this); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/EditUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/EditUtil.java deleted file mode 100644 index 69bcb3f7d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/EditUtil.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.w3c.dom.Element; - -//import org.eclipse.wst.wsdl.ui.internal.reconciler.WSDLToDOMElementUtil; - - -public class EditUtil -{ - public static List getPossiblePropertyValues(Object model, String propertyName) - { - List list = null; - if (model instanceof Port) - { - Port port = (Port)model; - ComponentReferenceUtil util = new ComponentReferenceUtil(port.getEnclosingDefinition()); - list = util.getBindingNames(); - } - else if (model instanceof Binding) - { - Binding binding = (Binding)model; - ComponentReferenceUtil util = new ComponentReferenceUtil(binding.getEnclosingDefinition()); - list = util.getPortTypeNames(); - } - else if (model instanceof Part) - { - Part part = (Part)model; - boolean isType = ComponentReferenceUtil.isType(part); - list = ComponentReferenceUtil.getComponentNameList(part, isType); - } - else if (model instanceof Input || - model instanceof Output || - model instanceof Fault) - { - WSDLElement wsdlElement = (WSDLElement)model; - ComponentReferenceUtil util = new ComponentReferenceUtil(wsdlElement.getEnclosingDefinition()); - list = util.getMessageNames(); - } - - if (list == null) - { - list = new ArrayList(); - list.add("A"); - list.add("B"); - list.add("C"); - } - return list; - } - - public static void setPropertyValue(Object model, String propertyName, String value) - { - if (model instanceof Part) - { - Part part = (Part)model; - boolean isType = ComponentReferenceUtil.isType(part); - ComponentReferenceUtil.setComponentReference(part, isType, value); - } - else if (model instanceof Port) - { - Element element = ((WSDLElement)model).getElement(); - element.setAttribute("binding", value); - } - else if (model instanceof Binding) - { - Element element = ((WSDLElement)model).getElement(); - element.setAttribute("type", value); - } - else if (model instanceof Input || - model instanceof Output || - model instanceof Fault) - { - Element element = ((WSDLElement)model).getElement(); - element.setAttribute("message", value); - } - } - - public static String getPropertyValue(Object model, String propertyName) - { - String result = null; - - if (model instanceof Part) - { - Element element = ((WSDLElement)model).getElement(); - result = element.getAttribute(propertyName); - } - else if (model instanceof Port) - { - Element element = ((WSDLElement)model).getElement(); - result = element.getAttribute("binding"); - } - else if (model instanceof Binding) - { - Element element = ((WSDLElement)model).getElement(); - result = element.getAttribute("type"); - } - else if (model instanceof Input || - model instanceof Output || - model instanceof Fault) - { - Element element = ((WSDLElement)model).getElement(); - result = element.getAttribute("message"); - } - return result; - } - - public static void setName(Object model, String value) - { - if (model instanceof WSDLElement) - { - Element element = ((WSDLElement)model).getElement(); - element.setAttribute("name", value); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/NameDirectEditManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/NameDirectEditManager.java deleted file mode 100644 index 7619958a3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/NameDirectEditManager.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import org.eclipse.draw2d.Label; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; -import org.eclipse.wst.wsdl.ui.internal.gef.util.editpolicies.TextCellEditorManager; - -public class NameDirectEditManager extends TextCellEditorManager -{ - protected Object model; - - public NameDirectEditManager(GraphicalEditPart source, Label label, Object model) - { - super(source, label); - this.model = model; - } - - public void performModify(final String value) - { - Display.getCurrent().asyncExec(new SmartRenameAction(model, value)); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropCommand.java deleted file mode 100644 index 5792516c1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropCommand.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.actions.CopyWSDLElementAction; -import org.eclipse.wst.wsdl.ui.internal.actions.WSDLDragAction; -import org.eclipse.wst.wsdl.ui.internal.actions.WSDLDragReorderAction; -import org.eclipse.wst.wsdl.ui.internal.actions.WSDLDragSetMessageAction; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; - - -public class WSDLDragAndDropCommand extends Command //AbstractCommand -{ - protected EditPartViewer viewer; - protected ChangeBoundsRequest request; - protected Point location; - protected WSDLDragAction dragAction; - protected boolean canExecute = false; - - public WSDLDragAndDropCommand(EditPartViewer viewer, ChangeBoundsRequest request) - { - this.viewer = viewer; - this.request = request; - - location = request.getLocation(); - EditPart targetEditPart = viewer.findObjectAt(location); - - // Only support drag and drop for WSDLTreeNodeEditPart - if (targetEditPart instanceof WSDLTreeNodeEditPart) { - WSDLElement wsdlElement = (WSDLElement) targetEditPart.getModel(); - if (wsdlElement.getElement() instanceof IDOMNode) { - ((GraphicalEditPart)viewer.getRootEditPart()).getFigure().translateToRelative(location); - WSDLTreeNodeEditPart movingChildEditPart; - Vector dragActions = new Vector(); - - if (request.getType().equals(RequestConstants.REQ_ADD)) { // This really shouldn't be REQ_ADD.... - List list = request.getEditParts(); - if (list.size() <= 0) { - canExecute = false; - return; - } - - // Grabbing the fist selection - movingChildEditPart = (WSDLTreeNodeEditPart) list.get(0); - Object model = movingChildEditPart.getModel(); - EditPart pointerEditPart = viewer.findObjectAt(location); - - if (model instanceof Input || model instanceof Output) { - dragActions.add(new WSDLDragReorderAction(movingChildEditPart, pointerEditPart, getPointerLocation(location))); - dragActions.add(new WSDLDragSetMessageAction(movingChildEditPart, pointerEditPart, location)); - } - else if (model instanceof Part) { - dragActions.add(new WSDLDragReorderAction(movingChildEditPart, pointerEditPart, getPointerLocation(location))); - } - else if (model instanceof Fault) { - dragActions.add(new WSDLDragSetMessageAction(movingChildEditPart, pointerEditPart, location)); - } - } - else if (request.getType().equals(RequestConstants.REQ_CLONE)) { - List list = request.getEditParts(); - if (list.size() > 0) - { - // Grabbing the fist selection - movingChildEditPart = (WSDLTreeNodeEditPart) list.get(0); - - dragActions.add(new CopyWSDLElementAction(viewer, - (WSDLElement) movingChildEditPart.getModel(), - (WSDLElement) targetEditPart.getModel(), - null)); - } - } - - Iterator it = dragActions.iterator(); - while (it.hasNext()) { - dragAction = (WSDLDragAction) it.next(); - canExecute = dragAction.canExecute(); - if (canExecute) - break; - } - } - } - } - - public boolean canExecute() - { - return canExecute; - } - - public void execute() { - if (canExecute) - { - dragAction.run(); - } - } - - public IFigure getFeedbackFigure() { - if (dragAction != null) { - return dragAction.getFeedbackFigure(); - } - else { - return null; - } - } - - /* - * This method compensates for the current scroll position - */ - private Point getPointerLocation(Point origPointerLocation) { - Point compensatedLocation = origPointerLocation; - FigureCanvas figureCanvas = (FigureCanvas) viewer.getControl(); - int yOffset = figureCanvas.getViewport().getVerticalRangeModel().getValue(); - compensatedLocation.y = compensatedLocation.y + yOffset; - - return compensatedLocation; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropEditPolicy.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropEditPolicy.java deleted file mode 100644 index b5dddbc37..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLDragAndDropEditPolicy.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.ChangeBoundsRequest; - -public class WSDLDragAndDropEditPolicy extends org.eclipse.gef.editpolicies.GraphicalEditPolicy -{ - protected EditPartViewer viewer; - protected WSDLSelectionHandlesEditPolicyImpl selectionHandlesEditPolicy; - - public WSDLDragAndDropEditPolicy(EditPartViewer viewer, WSDLSelectionHandlesEditPolicyImpl selectionHandlesEditPolicy) - { - this.viewer = viewer; - this.selectionHandlesEditPolicy = selectionHandlesEditPolicy; - } - - public boolean understandsRequest(Request req) - { - return true; - } - - public org.eclipse.gef.commands.Command getCommand(Request request) - { - WSDLDragAndDropCommand command = null; - if (request instanceof ChangeBoundsRequest) - { - command = new WSDLDragAndDropCommand(viewer, (ChangeBoundsRequest)request); - selectionHandlesEditPolicy.setDragAndDropCommand(command); - } - return command; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLGraphNodeDragTracker.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLGraphNodeDragTracker.java deleted file mode 100644 index 182b93978..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLGraphNodeDragTracker.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.tools.DragEditPartsTracker; - -public class WSDLGraphNodeDragTracker extends DragEditPartsTracker -{ - protected EditPart editPart; - - public WSDLGraphNodeDragTracker(EditPart editPart) - { - super(editPart); - this.editPart = editPart; - } - - protected Command getCommand() - { - Request request = getTargetRequest(); - return editPart.getCommand(request); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLSelectionHandlesEditPolicyImpl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLSelectionHandlesEditPolicyImpl.java deleted file mode 100644 index b038d9af4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/editpolicies/WSDLSelectionHandlesEditPolicyImpl.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.editpolicies; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy; -import org.eclipse.gef.handles.MoveHandle; -import org.eclipse.gef.handles.MoveHandleLocator; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.IFeedbackHandler; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.WSDLTreeNodeEditPart; - -public class WSDLSelectionHandlesEditPolicyImpl extends SelectionHandlesEditPolicy -{ - protected IFigure feedback; - protected Rectangle originalLocation; - protected WSDLDragAndDropCommand dragAndDropCommand; - - protected List createSelectionHandles() - { - List list = new ArrayList(); - EditPart editPart = getHost(); - - if (editPart instanceof GraphicalEditPart) - { - GraphicalEditPart graphicalEditPart = (GraphicalEditPart)editPart; - IFigure figure = (graphicalEditPart instanceof WSDLTreeNodeEditPart) ? - ((WSDLTreeNodeEditPart)graphicalEditPart).getSelectionFigure() : - graphicalEditPart.getFigure(); - - MoveHandleLocator loc = new MoveHandleLocator(figure); - MoveHandle moveHandle = new MoveHandle(graphicalEditPart, loc); - list.add(moveHandle); - } - - return list; - } - - - public boolean understandsRequest(Request request) - { - boolean result = false; - - if (REQ_MOVE.equals(request.getType())) - { - result = false; // return false to disable move for now - } - else - { - result = super.understandsRequest(request); - } - return result; - } - - - public org.eclipse.gef.commands.Command getCommand(Request request) - { - return null; - } - - public void setDragAndDropCommand(WSDLDragAndDropCommand dragAndDropCommand) - { - this.dragAndDropCommand = dragAndDropCommand; - } - - protected org.eclipse.gef.commands.Command getMoveCommand(ChangeBoundsRequest request) - { - ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_MOVE_CHILDREN); - req.setEditParts(getHost()); - - req.setMoveDelta(request.getMoveDelta()); - req.setSizeDelta(request.getSizeDelta()); - req.setLocation(request.getLocation()); - - return getHost().getParent().getCommand(req); - } - - public void showSourceFeedback(Request request) - { - eraseChangeBoundsFeedback(null); - - if (dragAndDropCommand != null && dragAndDropCommand.canExecute()) { - if (REQ_MOVE.equals(request.getType()) || REQ_ADD.equals(request.getType())) { - showMoveChangeBoundsFeedback((ChangeBoundsRequest) request); - } - else if (REQ_CLONE.equals(request.getType())) { - showCopyChangeBoundsFeedback((ChangeBoundsRequest) request); - } - } - } - - protected void showMoveChangeBoundsFeedback(ChangeBoundsRequest request) - { - if (dragAndDropCommand != null && dragAndDropCommand.getFeedbackFigure() != null) { - feedback = dragAndDropCommand.getFeedbackFigure(); - addFeedback(feedback); - } - } - - protected void showCopyChangeBoundsFeedback(ChangeBoundsRequest request) - { - /* - IFigure p = getDragSourceFeedbackFigure(); - Rectangle r = originalLocation.getTranslated(request.getMoveDelta()); - Dimension resize = request.getSizeDelta(); - r.width += resize.width; - r.height+= resize.height; - - ((GraphicalEditPart)getHost()).getFigure().translateToAbsolute(r); - p.translateToRelative(r); - - Rectangle pBounds = r.getCopy(); - - if (dragAndDropCommand != null && dragAndDropCommand.canExecute()) - { - int size = request.getEditParts().size(); - if (size > 0 && request.getEditParts().get(size - 1) == getHost()) - { - PointList pointList = dragAndDropCommand.getConnectionPoints(r); - if (pointList != null && pointList.size() > 0) - { - polyLine.setPoints(pointList); - - Point firstPoint = pointList.getFirstPoint(); - if (firstPoint != null) - { - pBounds = pBounds.getUnion(new Rectangle(firstPoint.x, firstPoint.y, 1, 1)); - } - } - } - } - p.setBounds(pBounds); - ghostShape.setBounds(r); - p.validate(); - */ - } -/* - protected IFigure getDragSourceFeedbackFigure() - { - EditPart editPart = getHost(); - if (feedback == null && editPart instanceof WSDLTreeNodeEditPart) - { - WSDLTreeNodeEditPart baseEditPart = (WSDLTreeNodeEditPart)editPart; - originalLocation = new Rectangle(baseEditPart.getSelectionFigure().getBounds()); - feedback = createDragSourceFeedbackFigure(baseEditPart.getSelectionFigure()); - } - return feedback; - } - - protected IFigure createDragSourceFeedbackFigure(IFigure draggedFigure) - { - Polyline polyLine = new Polyline(); -// polyLine.setLineStyle(Graphics.LINE_DASHDOT); - polyLine.setLineWidth(1); - addFeedback(polyLine); - - return polyLine; - } - */ - - public void deactivate() - { - if (feedback != null) - { - removeFeedback(feedback); - feedback = null; - } - hideFocus(); - super.deactivate(); - } - - /** - * Erase feedback indicating that the receiver object is - * being dragged. This method is called when a drag is - * completed or cancelled on the receiver object. - * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag. - */ - protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request) - { - if (feedback != null) - { - removeFeedback(feedback); - } - feedback = null; - originalLocation = null; - } - - /** - * Erase feedback indicating that the receiver object is - * being dragged. This method is called when a drag is - * completed or cancelled on the receiver object. - * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag. - */ - public void eraseSourceFeedback(Request request) - { - if (REQ_MOVE.equals(request.getType()) || REQ_ADD.equals(request.getType())) - { - eraseChangeBoundsFeedback((ChangeBoundsRequest)request); - } - } - - protected void hideSelection() - { - EditPart editPart = getHost(); - if (editPart instanceof IFeedbackHandler) - { - ((IFeedbackHandler)editPart).removeFeedback(); - } - } - - protected void showSelection() - { - EditPart editPart = getHost(); - if (editPart instanceof IFeedbackHandler) - { - ((IFeedbackHandler)editPart).addFeedback(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/ExpandableGraphNodeContentFigure.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/ExpandableGraphNodeContentFigure.java deleted file mode 100644 index 0120df36a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/ExpandableGraphNodeContentFigure.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.figures; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.wst.wsdl.ui.internal.gef.util.figures.Interactor; - - - - -// -------------------------------------------- -// | ExpandableGraphNodeContentFigure | -// | | -// | ---------------------------------- | -// | | verticalGroup | | -// | | | | -// | | ----------------------------- | | -// | | | horizontalGroup | | | -// | | | | | | -// | | | --------------------- | | | -// | | | | outlinedArea | | | | -// | | | | ----------------- | | | | -// | | | | |[+]iconArea | | | | | -// | | | | ----------------- | | | | -// | | | | ----------------- | | | | -// | | | | | innerContent | | | | | -// | | | | ----------------- | | | | -// | | | --------------------- | | | -// | | ----------------------------- | | -// | | | | -// | ---------------------------------- | -// -------------------------------------------- - -public class ExpandableGraphNodeContentFigure extends GraphNodeContentFigure -{ - protected Interactor interactor; - //protected ContainerFigure occurenceArea; - - public ExpandableGraphNodeContentFigure() - { - super(); - } - - public Interactor getInteractor() - { - return interactor; - } - - - protected void createFigure() - { - //createPreceedingSpace(this); - createVerticalGroup(this); - createOutlinedArea(verticalGroup); - createInteractor(iconArea); - innerContentArea.setBorder(new MarginBorder(0, 10, 0, 0)); - //createOccurenceArea(verticalGroup); - } - - - - protected void createInteractor(IFigure parent) - { - interactor = new Interactor(); - interactor.setBorder(new MarginBorder(0, 0, 0, 5)); - interactor.setForegroundColor(ColorConstants.black); - interactor.setBackgroundColor(ColorConstants.white); - parent.add(interactor); - } - - - protected void createPreceedingSpace(IFigure parent) - { - // create a small space - RectangleFigure space = new RectangleFigure(); - space.setVisible(false); - space.setPreferredSize(new Dimension(10, 10)); - parent.add(space); - } - - - //protected void createOccurenceArea(IFigure parent) - //{ - // occurenceArea = new ContainerFigure(); - // parent.add(occurenceArea); - //} -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/GraphNodeContentFigure.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/GraphNodeContentFigure.java deleted file mode 100644 index 94af5a419..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/GraphNodeContentFigure.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.figures; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectedFigure; - - -// ------------------------------ -// | GraphNodeContentFigure | -// | | -// | ------------------------- | -// | | vertical group | | -// | | --------------------- | | -// | | | outlined area | | | -// | | | ----------------- | | | -// | | | | icon area | | | | -// | | | ----------------- | | | -// | | | ----------------- | | | -// | | | | inner content | | | | -// | | | ----------------- | | | -// | | --------------------- | | -// | ------------------------- | -// ------------------------------ - -public class GraphNodeContentFigure extends ContainerFigure implements IConnectedFigure -{ - protected ContainerFigure verticalGroup; - protected ContainerFigure outlinedArea; - protected ContainerFigure iconArea; - protected ContainerFigure innerContentArea; - - public GraphNodeContentFigure() - { - createFigure(); - } - - protected void createFigure() - { - //getContainerLayout().setHorizontal(true); - //setLayoutManager(new FillLayout()); - createVerticalGroup(this); - createOutlinedArea(verticalGroup); - } - - protected void createVerticalGroup(IFigure parent) - { - verticalGroup = new ContainerFigure(); - verticalGroup.getContainerLayout().setHorizontal(false); - ///verticalGroup.setLayoutManager(new FillLayout()); - parent.add(verticalGroup); - } - - protected void createOutlinedArea(IFigure parent) - { - outlinedArea = new ContainerFigure(); - //outlinedArea.setLayoutManager(new FillLayout()); - outlinedArea.getContainerLayout().setHorizontal(false); - parent.add(outlinedArea); - - iconArea = new ContainerFigure(); - iconArea.getContainerLayout().setHorizontal(true); - outlinedArea.add(iconArea); - - innerContentArea = new ContainerFigure(); - //innerContentArea.setLayoutManager(new FillLayout()); - innerContentArea.getContainerLayout().setHorizontal(false); - outlinedArea.add(innerContentArea); - } - - public ContainerFigure getIconArea() - { - return iconArea; - } - - public ContainerFigure getOutlinedArea() - { - return outlinedArea; - } - - public ContainerFigure getInnerContentArea() - { - return innerContentArea; - } - - public IFigure getConnectionFigure() - { - return outlinedArea; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/MyConnectionRenderingHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/MyConnectionRenderingHelper.java deleted file mode 100644 index af8537da6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/MyConnectionRenderingHelper.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.figures; - -import java.util.Iterator; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.DefinitionEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.GroupEditPart; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.PartReferenceSectionEditPart; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectedFigure; - - -public class MyConnectionRenderingHelper //implements ISelectionChangedListener -{ - protected boolean isOutlined = true; - protected EditPartViewer viewer; - - public MyConnectionRenderingHelper(EditPartViewer viewer) - { - this.viewer = viewer; - //viewer.addSelectionChangedListener(this); - //setFocusTraversable(false); - //setEnabled(false); - } - - //public void selectionChanged(SelectionChangedEvent event) - //{ - //} - - public void fillShapeHelper(Graphics graphics) - { - drawLines(graphics, viewer.getRootEditPart()); - } - - protected Rectangle getConnectionBounds(IFigure figure) - { - Rectangle r = null; - if (figure instanceof IConnectedFigure) - { - IConnectedFigure connectedFigure = (IConnectedFigure)figure; - r = connectedFigure.getConnectionFigure().getBounds(); - } - else - { - r = figure.getBounds(); - } - return r; - } - - final static int DOTTED_LINE_HEIGHT = 20; - protected int getClippedY(int y, Rectangle bounds) - { - if (bounds != null) - { - if (y < bounds.y) - { - y = bounds.y; - } - if (y > (bounds.y + bounds.height)) - { - y = bounds.y + bounds.height; - } - } - return y; - } - - protected void drawLine(Graphics graphics, IFigure a, IFigure b, int mx, Rectangle bounds) - { - Rectangle r1 = getConnectionBounds(a); - Rectangle r2 = getConnectionBounds(b); - int x1 = r1.x + r1.width; - int y1 = r1.y + r1.height / 2; - int x2 = r2.x - 1; - int y2 = r2.y + r2.height / 2; - - int clippedY1 = getClippedY(y1, bounds); - int clippedY2 = getClippedY(y2, bounds); - - graphics.setForegroundColor(ColorConstants.black); - - if (clippedY1 == y1 || clippedY2 == y2) - { - if (clippedY1 == y1) - { - // draw horizontal line - graphics.drawLine(x1, y1, mx, y1); - } - - if (clippedY2 == y2) - { - // draw horizontal line - graphics.drawLine(mx, y2, x2 - 1, y2); - - // draw the arrow head - // - graphics.drawLine(x2 - 1, y2, x2 - 4, y2 - 3); - graphics.drawLine(x2 - 1, y2, x2 - 4, y2 + 3); - } - - - // draw the vertical line including dotted ends - // - int lowClippedY = Math.min(clippedY1, clippedY2); - int highClippedY = Math.max(clippedY1, clippedY2); - int lowY = Math.min(y1, y2); - int highY = Math.max(y1, y2); - - if (lowY == lowClippedY && highY == highClippedY) - { - graphics.drawLine(mx, lowClippedY, mx, highClippedY); - } - else - { - int dottedLineLength = Math.min(DOTTED_LINE_HEIGHT, (highY - lowY)/3); - if (lowY != lowClippedY) - { - graphics.setLineStyle(Graphics.LINE_DOT); - int dottedY = lowClippedY + dottedLineLength; - graphics.drawLine(mx, lowClippedY, mx, dottedY); - graphics.setLineStyle(Graphics.LINE_SOLID); - graphics.drawLine(mx, dottedY, mx, highClippedY); - } - else //if (highY != highClippedY) - { - graphics.setLineStyle(Graphics.LINE_DOT); - int dottedY = highClippedY - dottedLineLength; - graphics.drawLine(mx, highClippedY, mx, dottedY); - graphics.setLineStyle(Graphics.LINE_SOLID); - graphics.drawLine(mx, dottedY, mx, lowClippedY); - } - } - } - } - - protected void drawLines(Graphics graphics, EditPart editPart) - { - if (editPart instanceof GroupEditPart) - { - GroupEditPart leftGroupEditPart = (GroupEditPart)editPart; - GroupEditPart rightGroupEditPart = leftGroupEditPart.getNext(); - - if (leftGroupEditPart != null && rightGroupEditPart != null) - { - if (leftGroupEditPart.outputConnection != null && rightGroupEditPart.inputConnection != null) - { - int mx = rightGroupEditPart.getFigure().getBounds().x - 5; - - Rectangle l = leftGroupEditPart.outerPane.getBounds(); - Rectangle r = leftGroupEditPart.outerPane.getBounds(); - - // here we compute the union of the group bounds... rectangle.union() doesn't seem to work - // - int ux1 = Math.min(l.x, r.x); - int uy1 = Math.min(l.y, r.y); - int ux2 = Math.max(l.x + l.width, r.x + r.width); - int uy2 = Math.max(l.y + l.height, r.y + r.height); - Rectangle bounds = new Rectangle(ux1, uy1, ux2 - ux1, uy2 - uy1); - drawLine(graphics, leftGroupEditPart.outputConnection.getFigure(), rightGroupEditPart.inputConnection.getFigure(), mx, bounds); - } - } - } - else if (editPart instanceof PartReferenceSectionEditPart) - { - AbstractGraphicalEditPart child = (editPart.getChildren().size() > 0) ? - (AbstractGraphicalEditPart)editPart.getChildren().get(0) : - null; - if (child != null) - { - DefinitionEditPart def = (DefinitionEditPart)editPart.getParent(); - GroupEditPart groupEditPart = def.getGroupEditPart(WSDLGroupObject.MESSAGES_GROUP); - if (groupEditPart != null && groupEditPart.outputConnection != null) - { - int mx = child.getFigure().getBounds().x - 12; - drawLine(graphics, groupEditPart.outputConnection.getFigure(), child.getFigure(), mx, null); - } - } - } - else - { - for (Iterator i = editPart.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - drawLines(graphics, child); - } - } - } -} - -/* - /* - List children = figure.getChildren(); - for (Iterator i = children.iterator(); i.hasNext(); ) - { - IFigure child = (IFigure)i.next(); - drawLines(graphics, child); - } */ - /* - List connectedFigures = graphNodeFigure.getConnectedFigures(IConnectedEditPartFigure.RIGHT_CONNECTION); - int connectedFiguresSize = connectedFigures.size(); - - if (connectedFiguresSize > 0) - { - IConnectedEditPartFigure firstGraphNodeFigure = (IConnectedEditPartFigure)connectedFigures.get(0); - Rectangle r = graphNodeFigure.getConnectionFigure().getBounds(); - - int x1 = r.x + r.width; - int y1 = r.y + r.height/2; - - int startOfChildBox = firstGraphNodeFigure.getConnectionFigure().getBounds().x; - int x2 = x1 + (startOfChildBox - x1) / 3; - int y2 = y1; - - if (connectedFiguresSize == 1) - { - graphics.drawLine(x1, y1, startOfChildBox, y2); - } - else // (connectedFigures.length > 1) - { - graphics.drawLine(x1, y1, x2, y2); - - int minY = Integer.MAX_VALUE; - int maxY = -1; - - for (Iterator i = connectedFigures.iterator(); i.hasNext(); ) - { - IConnectedEditPartFigure connectedFigure = (IConnectedEditPartFigure)i.next(); - Rectangle childConnectionRectangle = connectedFigure.getConnectionFigure().getBounds(); - int y = childConnectionRectangle.y + childConnectionRectangle.height / 2; - minY = Math.min(minY, y); - maxY = Math.max(maxY, y); - graphics.drawLine(x2, y, childConnectionRectangle.x, y); - } - graphics.drawLine(x2, minY, x2, maxY); - } - } - } - - //boolean visitChildren = true; - List children = figure.getChildren(); - for (Iterator i = children.iterator(); i.hasNext(); ) - { - IFigure child = (IFigure)i.next(); - drawLines(graphics, child); - } -*/ diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/TreeNodeContentFigure.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/TreeNodeContentFigure.java deleted file mode 100644 index 628b79863..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/figures/TreeNodeContentFigure.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.figures; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MarginBorder; - - -public class TreeNodeContentFigure extends ExpandableGraphNodeContentFigure -{ - protected void createOutlinedArea(IFigure parent) - { - super.createOutlinedArea(parent); - outlinedArea.setBorder(new MarginBorder(0,2,0,2)); - } - - public IFigure getConnectionFigure() - { - return outlinedArea; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/model/WSDLGraphModelAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/model/WSDLGraphModelAdapterFactory.java deleted file mode 100644 index c336ce0b4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/graph/model/WSDLGraphModelAdapterFactory.java +++ /dev/null @@ -1,394 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.graph.model; - -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.Notifier; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.graph.ViewMode; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - - -public class WSDLGraphModelAdapterFactory extends WSDLModelAdapterFactory -{ - protected static WSDLGraphModelAdapterFactory wsdlGraphModelAdapterFactoryInstance; - - public static WSDLGraphModelAdapterFactory getWSDLGraphModelAdapterFactory() - { - if (wsdlGraphModelAdapterFactoryInstance == null) - { - wsdlGraphModelAdapterFactoryInstance = new WSDLGraphModelAdapterFactory(); - } - return wsdlGraphModelAdapterFactoryInstance; - } - - protected AdapterFactory createAdapterFactory() - { - return new GraphAdapterFactory(); - } - - //protected boolean isExtensibilityElementConsideredChild() - //{ - // return false; - //} - - - // There are many adapters associated with this factory. Each DOM Node has its own adapter. - // - protected class GraphAdapterFactory extends WSDLAdapterFactoryImpl - { - - public Adapter createDefinitionAdapter() - { - return new GraphDefinitionAdapter(); - } - - public Adapter createBindingAdapter() - { - return new GraphBindingAdapter(); - } - - public Adapter createPartAdapter() - { - return new GraphPartAdapter(); - } - - //public Adapter createPortAdapter() - //{ - // return new GraphPortAdapter(); - //} - - public Adapter createPortTypeAdapter() - { - return new GraphPortTypeAdapter(); - } - - //public Adapter createInputAdapter() - //{ - // return new GraphInputAdapter(); - //} - - //public Adapter createOutputAdapter() - //{ - // return new GraphOutputAdapter(); - //} - - //public Adapter createFaultAdapter() - //{ - // return new GraphFaultAdapter(); - //} - - public Adapter createTypesAdapter() - { - return new GraphTypesAdapter(); - } - } - - - - protected class GraphDefinitionAdapter extends DefinitionAdapter implements ViewMode.Listener - { - protected ViewMode viewMode = new ViewMode(); - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - viewMode.addListener(this); - } - - protected List getChildren() - { - List list = new ArrayList(); - list.add(permanentWSDLGroupObjectList.get(0)); - list.add(permanentWSDLGroupObjectList.get(1)); - list.add(permanentWSDLGroupObjectList.get(5)); - if (viewMode.isBindingVisible()) - { - list.add(permanentWSDLGroupObjectList.get(4)); - } - list.add(permanentWSDLGroupObjectList.get(3)); - list.add(permanentWSDLGroupObjectList.get(2)); - if (extensibilityElementsGroup.getChildren().size() > 0) - { - list.add(extensibilityElementsGroup); - } - return list; - } - - - public void viewModeChanged(ViewMode mode) - { - firePropertyChangedHelper(); - } - - public ViewMode getViewMode() - { - return viewMode; - } - - protected ModelAdapterFactory getModelAdapterFactory() - { - return getWSDLGraphModelAdapterFactory(); - } - } - - - - - protected class GraphBindingAdapter extends BindingAdapter - { /* - protected List getChildren() - { - List list = new ArrayList(); - if (binding.getPortType() != null) - { - list.add(binding.getPortType()); - } - return list; - }*/ - } - - - protected class GraphPartAdapter extends PartAdapter - { /* - protected List getChildren() - { - List list = new ArrayList(); - - Object component = part.getType(); - if (component != null) - { - // TODO... i'm pulling a fast one here.... we should call the extension - // to see if he wants to show a child here - if (component instanceof org.eclipse.xsd.XSDComplexTypeDefinition) - { - list.add(component); - } - } - else - { - component = part.getElement(); - if (component != null) - { - list.add(component); - } - } - - return list; - }*/ - } - - protected class GraphPortTypeAdapter extends PortTypeAdapter - { - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals("bindings")) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(portType.getEnclosingDefinition()); - result = util.getBindings(portType); - } - else - { - result = super.getProperty(modelObject, propertyName); - } - return result; - } - } - - protected class GraphPortAdapter extends PortAdapter implements ModelAdapterListener - { - protected List getChildren() - { - List list = new ArrayList(); - - Binding binding = (Binding)port.getBinding(); - - if (binding != null) - { - list.add(binding); - } - - return list; - } - - // propagate changes to the binding object - // - public void propertyChanged(Object object, String property) - { - firePropertyChanged(port, null); - } - } - - - protected class GraphInputAdapter extends InputAdapter - { - protected List getChildren() - { - List list = new ArrayList(); - if (input.getMessage() != null) - { - list.add(input.getMessage()); - } - return list; - } - - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals("bindings")) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(input.getEnclosingDefinition()); - result = util.getBindingInputs(input); - } - else - { - result = super.getProperty(modelObject, propertyName); - } - return result; - } - } - - - protected class GraphOutputAdapter extends OutputAdapter - { - protected List getChildren() - { - List list = new ArrayList(); - if (output.getMessage() != null) - { - list.add(output.getMessage()); - } - return list; - } - - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals("bindings")) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(output.getEnclosingDefinition()); - result = util.getBindingOutputs(output); - } - else - { - result = super.getProperty(modelObject, propertyName); - } - return result; - } - } - - protected class GraphFaultAdapter extends FaultAdapter - { - protected List getChildren() - { - List list = new ArrayList(); - if (fault.getMessage() != null) - { - list.add(fault.getMessage()); - } - return list; - } - - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals("bindings")) - { - ComponentReferenceUtil util = new ComponentReferenceUtil(fault.getEnclosingDefinition()); - result = util.getBindingFaults(fault); - } - else - { - result = super.getProperty(modelObject, propertyName); - } - return result; - } - } - - public class GraphTypesAdapter extends TypesAdapter - { - protected List getChildren() - { - List list = new ArrayList(); - for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext(); ) - { - Object o = i.next(); - if (o instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement s = (XSDSchemaExtensibilityElement)o; - Object schema = s.getSchema(); - if (schema != null) - { - list.add(schema); - } - } - else - { - list.add(o); - } - } - return list; - } - } - /* - protected class GraphBindingAdapter extends BindingAdapter - { - protected List getChildren() - { - List list = new ArrayList(); - if (binding.getPortType() != null) - { - list.add(binding.getPortType()); - } - return list; - } - }*/ - - // convenience methods - // - public static void addModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { -// TODO: port check - ModelAdapter adapter = getWSDLGraphModelAdapterFactory().getAdapter(modelObject); -// ModelAdapter adapter = EcoreUtil.getAdapter(getWSDLGraphModelAdapterFactory().eAdapters(),modelObject); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - public static void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { - ModelAdapter adapter = getWSDLGraphModelAdapterFactory().getAdapter(modelObject); - if (adapter != null) - { - adapter.removeListener(listener); - } - } - - public static ViewMode getViewMode(Definition definition) - { - GraphDefinitionAdapter adapter = (GraphDefinitionAdapter)getWSDLGraphModelAdapterFactory().getAdapter(definition); - return adapter.getViewMode(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/back.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/back.gif Binary files differdeleted file mode 100644 index 24d1a279e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/back.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/binding_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/binding_obj.gif Binary files differdeleted file mode 100644 index 896e2f055..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/binding_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/bindingheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/bindingheader_obj.gif Binary files differdeleted file mode 100644 index 1ffe54e33..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/bindingheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/browsebutton.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/browsebutton.gif Binary files differdeleted file mode 100644 index e2402f88f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/browsebutton.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/complextype_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/complextype_obj.gif Binary files differdeleted file mode 100644 index 007f8522a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/complextype_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/element_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/element_obj.gif Binary files differdeleted file mode 100644 index dd45f08fb..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/element_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/error_co.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/error_co.gif Binary files differdeleted file mode 100644 index 119dcccd5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/error_co.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fault_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fault_obj.gif Binary files differdeleted file mode 100644 index f228117f2..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fault_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/file_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/file_obj.gif Binary files differdeleted file mode 100644 index efa7a3801..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/file_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fldr_el.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fldr_el.gif Binary files differdeleted file mode 100644 index 801c13388..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/fldr_el.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/forward.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/forward.gif Binary files differdeleted file mode 100644 index eab699e38..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/forward.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/hidebinding.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/hidebinding.gif Binary files differdeleted file mode 100644 index c846cd8d8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/hidebinding.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpaddress_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpaddress_obj.gif Binary files differdeleted file mode 100644 index fb20c389d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpaddress_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpbinding_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpbinding_obj.gif Binary files differdeleted file mode 100644 index 4428ef395..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpbinding_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpoperation_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpoperation_obj.gif Binary files differdeleted file mode 100644 index 1c404181d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpoperation_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlencoded_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlencoded_obj.gif Binary files differdeleted file mode 100644 index ed5050f22..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlencoded_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlreplacement_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlreplacement_obj.gif Binary files differdeleted file mode 100644 index 273587ea9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/httpurlreplacement_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/import_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/import_obj.gif Binary files differdeleted file mode 100644 index b7275aa56..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/import_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/importheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/importheader_obj.gif Binary files differdeleted file mode 100644 index 6000cb80f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/importheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/input_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/input_obj.gif Binary files differdeleted file mode 100644 index fe6b34989..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/input_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/message_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/message_obj.gif Binary files differdeleted file mode 100644 index 2dce48373..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/message_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/messageheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/messageheader_obj.gif Binary files differdeleted file mode 100644 index 02a711cee..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/messageheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespace_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespace_obj.gif Binary files differdeleted file mode 100644 index 7e3f274d0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespace_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespacedecl_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespacedecl_obj.gif Binary files differdeleted file mode 100644 index 2b79d2749..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/namespacedecl_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/new_wsdl_wiz.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/new_wsdl_wiz.gif Binary files differdeleted file mode 100644 index d1087b9b1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/new_wsdl_wiz.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operation_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operation_obj.gif Binary files differdeleted file mode 100644 index 5818a3088..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operation_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operationbinding_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operationbinding_obj.gif Binary files differdeleted file mode 100644 index ae386c636..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/operationbinding_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_no.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_no.gif Binary files differdeleted file mode 100644 index f6b9f8a59..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_no.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_obj.gif Binary files differdeleted file mode 100644 index bd0918ce1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_yes.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_yes.gif Binary files differdeleted file mode 100644 index 9cacb96dc..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/output_yes.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/page_banner.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/page_banner.gif Binary files differdeleted file mode 100644 index aebc0b2a3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/page_banner.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/part_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/part_obj.gif Binary files differdeleted file mode 100644 index 5219dfa87..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/part_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/port_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/port_obj.gif Binary files differdeleted file mode 100644 index 379498b0a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/port_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttype_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttype_obj.gif Binary files differdeleted file mode 100644 index 21325ca77..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttype_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttypeheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttypeheader_obj.gif Binary files differdeleted file mode 100644 index 9afcc01e1..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/porttypeheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtcmplxpltyp_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtcmplxpltyp_obj.gif Binary files differdeleted file mode 100644 index db866437f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtcmplxpltyp_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtelemt_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtelemt_obj.gif Binary files differdeleted file mode 100644 index 782d108fe..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtelemt_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtsmpltyp_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtsmpltyp_obj.gif Binary files differdeleted file mode 100644 index 8ffc7c57b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/prtsmpltyp_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/service_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/service_obj.gif Binary files differdeleted file mode 100644 index 5216b3f2d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/service_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/serviceheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/serviceheader_obj.gif Binary files differdeleted file mode 100644 index 8b4814cb8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/serviceheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/simpletype_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/simpletype_obj.gif Binary files differdeleted file mode 100644 index e45dbb1d8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/simpletype_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soap_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soap_obj.gif Binary files differdeleted file mode 100644 index fd426ed2d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soap_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapaddress_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapaddress_obj.gif Binary files differdeleted file mode 100644 index 4880ba795..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapaddress_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapatt_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapatt_obj.gif Binary files differdeleted file mode 100644 index d0b366181..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapatt_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbinding_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbinding_obj.gif Binary files differdeleted file mode 100644 index 115f6bf2b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbinding_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbody_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbody_obj.gif Binary files differdeleted file mode 100644 index b2d01aad0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapbody_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapfault_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapfault_obj.gif Binary files differdeleted file mode 100644 index 856b1f7d4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapfault_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheader_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheader_obj.gif Binary files differdeleted file mode 100644 index f72ea3b20..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheader_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheaderfault_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheaderfault_obj.gif Binary files differdeleted file mode 100644 index 2f0e1906f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapheaderfault_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapoperation_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapoperation_obj.gif Binary files differdeleted file mode 100644 index bcc191469..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/soapoperation_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/types_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/types_obj.gif Binary files differdeleted file mode 100644 index d1f6f889d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/types_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/validate.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/validate.gif Binary files differdeleted file mode 100644 index 2b347ac45..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/validate.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/wsdl_file_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/wsdl_file_obj.gif Binary files differdeleted file mode 100644 index 75b1f92b4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/wsdl_file_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_file_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_file_obj.gif Binary files differdeleted file mode 100644 index 13dcfceaf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_file_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_obj.gif b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_obj.gif Binary files differdeleted file mode 100644 index 13dcfceaf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/icons/xsd_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapter.java deleted file mode 100644 index 0e53e7ecf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.model; - -public interface ModelAdapter -{ - public static final String CHILDREN_PROPERTY = "CHILDREN_PROPERTY"; - public static final String LABEL_PROPERTY = "LABEL_PROPERTY"; - public static final String IMAGE_PROPERTY = "IMAGE_PROPERTY"; - public static final String DETAIL_PROPERTY = "DETAIL_PROPERTY"; - - public void addListener(ModelAdapterListener l); - public void removeListener(ModelAdapterListener l); - public Object getProperty(Object modelObject, String propertyName); - public void firePropertyChanged(Object modelObject, String propertyName); -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterFactory.java deleted file mode 100644 index 9db0daaf2..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.model; - -public interface ModelAdapterFactory -{ - public ModelAdapter getAdapter(Object o); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterListener.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterListener.java deleted file mode 100644 index 1e3e851aa..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/ModelAdapterListener.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.model; - -public interface ModelAdapterListener -{ - public void propertyChanged(Object object, String property); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLGroupObject.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLGroupObject.java deleted file mode 100644 index 5d9abfa6e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLGroupObject.java +++ /dev/null @@ -1,414 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; - - - -// Note that the TYPES_GROUP group is just a place holder. If the Types obejct actually exists -// for the root WSDL document, it will be used instead of this model group -// -public class WSDLGroupObject implements ModelAdapter -{ - public static final int IMPORTS_GROUP = 1; - public static final int MESSAGES_GROUP = 2; - public static final int SERVICES_GROUP = 3; - public static final int PORT_TYPES_GROUP = 4; - public static final int BINDINGS_GROUP = 5; - public static final int TYPES_GROUP = 6; - public static final int EXTENSIBILITY_ELEMENTS_GROUP = 7; - - protected Definition definition; - protected int type; - protected List listenerList = new ArrayList(); - protected ModelAdapterFactory modelAdapterFactory; - - public WSDLGroupObject(Definition definition, int type) - { - this(definition, type, null); - } - - public WSDLGroupObject(Definition definition, int type, ModelAdapterFactory modelAdapterFactory) - { - this.definition = definition; - this.type = type; - this.modelAdapterFactory = modelAdapterFactory; - } - - public Definition getParent() - { - return definition; - } - - public Definition getDefinition() - { - return definition; - } - - - public int getType() - { - return type; - } - - public String getLabel() - { - String name = ""; - switch (type) - { - case IMPORTS_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_IMPORTS"); //$NON-NLS-1$ - break; - } - case MESSAGES_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_MESSAGES"); //$NON-NLS-1$ - break; - } - case SERVICES_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_SERVICES"); //$NON-NLS-1$ - break; - } - case BINDINGS_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_BINDINGS"); //$NON-NLS-1$ - break; - } - case PORT_TYPES_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_PORTTYPES"); //$NON-NLS-1$ - break; - } - case TYPES_GROUP : - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_TYPES"); //$NON-NLS-1$ - break; - } - case EXTENSIBILITY_ELEMENTS_GROUP: - { - name = WSDLEditorPlugin.getWSDLString("_UI_FOLDER_EXTENSIBILITY_ELEMENTS"); //$NON-NLS-1$ - break; - } - } - return name; - } - - - public Image getImage() - { - Image image = null; - switch (type) - { - case IMPORTS_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/importheader_obj.gif"); //$NON-NLS-1$ - break; - } - case MESSAGES_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/messageheader_obj.gif"); //$NON-NLS-1$ - break; - } - case SERVICES_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/serviceheader_obj.gif"); //$NON-NLS-1$ - break; - } - case PORT_TYPES_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/porttypeheader_obj.gif"); //$NON-NLS-1$ - break; - } - case BINDINGS_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/bindingheader_obj.gif"); //$NON-NLS-1$ - break; - } - case TYPES_GROUP : - { - image = WSDLEditorPlugin.getInstance().getImage("icons/types_obj.gif"); //$NON-NLS-1$ - break; - } - case EXTENSIBILITY_ELEMENTS_GROUP: - { - image = WSDLEditorPlugin.getInstance().getImage("icons/fldr_el.gif"); //$NON-NLS-1$ - break; - } - } - return image; - } - - - // implement ModelAdapter - public void addListener(ModelAdapterListener listener) - { - if (!listenerList.contains(listener)) - { - listenerList.add(listener); - } - } - - public void removeListener(ModelAdapterListener listener) - { - listenerList.remove(listener); - } - - - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals(CHILDREN_PROPERTY)) - { - result = getChildren(); - } - else if (propertyName.equals(LABEL_PROPERTY)) - { - result = getLabel(); - } - else if (propertyName.equals(IMAGE_PROPERTY)) - { - result = getImage(); - } - return result; - } - - - public void firePropertyChanged(Object notifier, String property) - { - List list = new ArrayList(); - list.addAll(listenerList); - for (Iterator i = list .iterator(); i.hasNext(); ) - { - ModelAdapterListener listener = (ModelAdapterListener)i.next(); - listener.propertyChanged(notifier, property); - } - } - - - public List getChildren() - { - List list = Collections.EMPTY_LIST; - - ComponentReferenceUtil util = new ComponentReferenceUtil(definition); - switch (getType()) - { - case WSDLGroupObject.IMPORTS_GROUP : - { - list = definition.getEImports(); - break; - } - case WSDLGroupObject.MESSAGES_GROUP : - { - try - { - list = sortMessages(util.getMessages()); - } - catch(Exception e) - { - list = util.getMessages(); - } - break; - } - case WSDLGroupObject.SERVICES_GROUP : - { - list = util.getServices(); - break; - } - case WSDLGroupObject.PORT_TYPES_GROUP : - { - list = util.getPortTypes(); - break; - } - case WSDLGroupObject.BINDINGS_GROUP : - { - list = util.getBindings(); - break; - } - case WSDLGroupObject.TYPES_GROUP : - { - Object types = definition.getETypes(); - if (types != null) - { - list = (List)modelAdapterFactory.getAdapter(types).getProperty(types, ModelAdapter.CHILDREN_PROPERTY); - } - break; - } - case WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP: - { - list = WSDLEditorUtil.getInstance().getExtensibilityElementNodes(definition); - break; - } - } - return list; - } - - private List initialSort(List inputList) { - List messageGroups = new ArrayList(); - Iterator iterator = inputList.iterator(); - - while (iterator.hasNext()) { - Message newMessage = (Message) iterator.next(); - - boolean messageAdded = false; - for (int index = 0; index < messageGroups.size(); index++) { - MessageGroup messageItem = (MessageGroup) messageGroups.get(index); - - if(messageItem.addMessage(newMessage)) { - messageAdded = true; - break; - } - } - - // Do we need to create a new MessageGroup object? - if (!messageAdded) { - MessageGroup msGroup = new MessageGroup(newMessage.getQName().getLocalPart()); - msGroup.addMessage(newMessage); - messageGroups.add(msGroup); - } - } - - return messageGroups; - } - - private List buildMessageList(List list) { - List sortedMessageList = new ArrayList(); - - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - MessageGroup mGroup = (MessageGroup) iterator.next(); - sortedMessageList.addAll(mGroup.getMessages()); - } - - return sortedMessageList; - } - - private List sortMessages(List inputList) { - List sortedList = new ArrayList(); - sortedList.addAll(inputList); - - // Get a sorted list of MessageGroups - sortedList = initialSort(inputList); - - Collections.sort(sortedList, new Comparator() { - public int compare(Object o1, Object o2) { - String name1 = ((MessageGroup) o1).getBaseName(); - String name2 = ((MessageGroup) o2).getBaseName(); - - return name1.compareToIgnoreCase(name2); - } - }); - - sortedList = buildMessageList(sortedList); - return sortedList; - } - - private class MessageGroup { - private String baseName; - private Vector messages; - - public MessageGroup(String name) { - this.baseName = computeBaseName(name); - messages = new Vector(); - } - - public boolean addMessage(Message newMessage) { - // do check if it belongs here?...... - String newMessageBaseName = computeBaseName(newMessage.getQName().getLocalPart()); - - if (newMessageBaseName.equalsIgnoreCase(getBaseName())) { - addToSortedList(newMessage); - - return true; - } - - return false; - } - - public Vector getMessages() { - return messages; - } - - public String getBaseName() { - return baseName; - } - - private int getFirstInstance(String subString) { - for (int index = 0; index < messages.size(); index++) { - Message message = (Message) messages.get(index); - String messageName = message.getQName().getLocalPart(); - - if (messageName.indexOf(subString, 1) > 0) { - return index; - } - } - - return -1; - } - - private void addToSortedList(Message message) { - // We need to add the new Message in the right position - int index = -1; - String name = message.getQName().getLocalPart(); - if (name.indexOf("Request", 1) > 0) { - // Add after first instance of 'Response' - index = getFirstInstance("Response"); - } - else if (name.indexOf("Response", 1) > 0) { - // Add after first instance of 'Request' - index = getFirstInstance("Request"); - if (index >= 0) - index++; - } - - if (index >= 0) { - messages.add(index, message); - } - else { - messages.add(message); - } - } - - private String computeBaseName(String name) { - int resReqIndex = name.indexOf("Request", 1); - int resReqLength; - if (resReqIndex == -1) { - resReqIndex = name.indexOf("Response", 1); - resReqLength = "Response".length(); - } - else { - resReqLength = "Request".length(); - } - - // Did we even find a Request/Response in both strings? - if (resReqIndex != -1) { - return name.substring(0, resReqIndex) + name.substring(resReqIndex + resReqLength, name.length()); - } - else { - return name; - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLModelAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLModelAdapterFactory.java deleted file mode 100644 index 8325e9e4d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/model/WSDLModelAdapterFactory.java +++ /dev/null @@ -1,1238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import javax.wsdl.OperationType; - -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.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibilityElement; -import org.eclipse.wst.wsdl.ExtensibleElement; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.UnknownExtensibilityElement; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.OperationImpl; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.ITreeChildProvider; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class WSDLModelAdapterFactory implements ModelAdapterFactory -{ - protected static WSDLModelAdapterFactory wsdlModelAdapterFactoryInstance; - - public AdapterFactory adapterFactory; - - public WSDLModelAdapterFactory() - { - adapterFactory = createAdapterFactory(); - } - - protected boolean isExtensibilityElementConsideredChild() - { - return true; - } - - protected void addExtensiblityElementChildren(List list, ExtensibleElement extensibleElement) - { - if (isExtensibilityElementConsideredChild()) - { - //list.addAll(WSDLEditorUtil.getInstance().getExtensibilityElementNodes(extensibleElement)); - list.addAll(WSDLEditorUtil.getInstance().getExtensibilityElementNodes(extensibleElement)); - } - } - - public static WSDLModelAdapterFactory getWSDLModelAdapterFactory() - { - if (wsdlModelAdapterFactoryInstance == null) - { - wsdlModelAdapterFactoryInstance = new WSDLModelAdapterFactory(); - } - return wsdlModelAdapterFactoryInstance; - } - - - protected AdapterFactory createAdapterFactory() - { - return new WSDLAdapterFactoryImpl(); - } - - - public ModelAdapter getAdapter(Object o) - { - ModelAdapter adapter = null; - if (o instanceof WSDLElement) - { - adapter = (ModelAdapter)adapterFactory.adapt((WSDLElement)o, adapterFactory); - } - else if (o instanceof WSDLGroupObject) - { - adapter = (WSDLGroupObject)o; - } - return adapter; - } - - // - // - // - public class WSDLAdapterFactoryImpl extends AdapterFactoryImpl - { - public Adapter createAdapter(Notifier target) - { - WSDLSwitch wsdlSwitch = new WSDLSwitch() - { - public Object caseWSDLElement(WSDLElement wsdlElement) - { - // note that the WSDLSwitch doesn't handle - // caseExtensibilityElement when the object - // comes from another package... that why - // we have an instanceof check here - if (wsdlElement instanceof ExtensibilityElement) - { - return createExtensibilityElementAdapter(); - } - else - { - return createWSDLElementAdapter(); - } - } - - public Object caseBinding(Binding binding) - { - return createBindingAdapter(); - } - - public Object caseBindingFault(BindingFault bindingFault) - { - return createBindingFaultAdapter(); - } - - public Object caseBindingInput(BindingInput bindingInput) - { - return createBindingInputAdapter(); - } - - public Object caseBindingOutput(BindingOutput bindingOutput) - { - return createBindingOutputAdapter(); - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - return createBindingOperationAdapter(); - } - - public Object caseDefinition(Definition definition) - { - return createDefinitionAdapter(); - } - - public Object caseFault(Fault fault) - { - return createFaultAdapter(); - } - - public Object caseImport(Import i) - { - return createImportAdapter(); - } - - public Object caseInput(Input input) - { - return createInputAdapter(); - } - - public Object caseOutput(Output output) - { - return createOutputAdapter(); - } - - public Object caseMessage(Message message) - { - return createMessageAdapter(); - } - - public Object caseOperation(Operation operation) - { - return createOperationAdapter(); - } - - public Object casePart(Part part) - { - return createPartAdapter(); - } - - public Object casePort(Port port) - { - return createPortAdapter(); - } - - public Object casePortType(PortType portType) - { - return createPortTypeAdapter(); - } - - public Object caseService(Service service) - { - return createServiceAdapter(); - } - - public Object caseTypes(Types types) - { - return createTypesAdapter(); - } - - public Object defaultCase(EObject object) - { - // note that the WSDLSwitch doesn't handle - // caseExtensibilityElement when the object - // comes from another package... that why - // we have an instanceof check here - if (object instanceof ExtensibilityElement) - { - return createExtensibilityElementAdapter(); - } - else - { - return null; - } - } - }; - - Object o = wsdlSwitch.doSwitch((EObject)target); - - - Adapter result = null; - if (o instanceof Adapter) - { - result = (Adapter)o; - } - else - { - System.out.println("did not create adapter for target : " + target); - Thread.dumpStack(); - } - return result; - } - - - public Adapter createWSDLElementAdapter() - { - return new WSDLElementAdapter(); - } - - public Adapter createBindingAdapter() - { - return new BindingAdapter(); - } - - public Adapter createBindingFaultAdapter() - { - return new BindingFaultAdapter(); - } - - public Adapter createBindingInputAdapter() - { - return new BindingInputAdapter(); - } - - public Adapter createBindingOutputAdapter() - { - return new BindingOutputAdapter(); - } - - public Adapter createBindingOperationAdapter() - { - return new BindingOperationAdapter(); - } - - public Adapter createDefinitionAdapter() - { - return new DefinitionAdapter(); - } - - public Adapter createFaultAdapter() - { - return new FaultAdapter(); - } - - public Adapter createImportAdapter() - { - return new ImportAdapter(); - } - - public Adapter createInputAdapter() - { - return new InputAdapter(); - } - - public Adapter createMessageAdapter() - { - return new MessageAdapter(); - } - - - public Adapter createOperationAdapter() - { - return new OperationAdapter(); - } - - public Adapter createOutputAdapter() - { - return new OutputAdapter(); - } - - public Adapter createPartAdapter() - { - return new PartAdapter(); - } - - public Adapter createPortAdapter() - { - return new PortAdapter(); - } - - public Adapter createPortTypeAdapter() - { - return new PortTypeAdapter(); - } - - public Adapter createServiceAdapter() - { - return new ServiceAdapter(); - } - - public Adapter createTypesAdapter() - { - return new TypesAdapter(); - } - - public Adapter createExtensibilityElementAdapter() - { - return new ExtensibilityElementAdapter(); - } - - - // convenience method - // - public Adapter adapt(Notifier target) - { - return adapt(target, this); - } - } - - // - // - // - protected class WSDLElementAdapter extends AdapterImpl implements ModelAdapter - { - protected List listenerList = new ArrayList(); - - - public WSDLElementAdapter() - { - } - - public boolean isAdapterForType(Object type) - { - return type == adapterFactory; - } - - public void addListener(ModelAdapterListener listener) - { - if (!listenerList.contains(listener)) - { - listenerList.add(listener); - } - } - - public void removeListener(ModelAdapterListener listener) - { - if (listenerList.contains(listener)) - { - listenerList.remove(listener); - } - } - - public void firePropertyChanged(Object notifier, String property) - { - List list = new ArrayList(); - list.addAll(listenerList); - for (Iterator i = list.iterator(); i.hasNext(); ) - { - ModelAdapterListener listener = (ModelAdapterListener)i.next(); - listener.propertyChanged(getTarget(), property); - } - } - - public void notifyChanged(Notification msg) - { - if (msg.getEventType() != Notification.RESOLVE) - { - firePropertyChanged(msg.getNotifier(), null); - } - } - - - public Object getProperty(Object modelObject, String propertyName) - { - Object result = null; - if (propertyName.equals(CHILDREN_PROPERTY)) - { - result = getChildren(); - } - else if (propertyName.equals(LABEL_PROPERTY)) - { - result = getLabel(); - } - else if (propertyName.equals(IMAGE_PROPERTY)) - { - result = getImage(); - } - else if (propertyName.equals("extensibilityElements")) - { - if (modelObject instanceof ExtensibleElement) - { - result = WSDLEditorUtil.getInstance().getExtensibilityElementNodes((ExtensibleElement)modelObject); - } - } - else if (propertyName.equals("isReadOnly")) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(target); - result = (element instanceof IDOMNode) ? Boolean.FALSE : Boolean.TRUE; - } - return result; - } - - protected List getChildren() - { - return Collections.EMPTY_LIST; - } - - protected String getLabel() - { - return "todo"; - } - - protected Image getImage() - { - return null; - } - } - - - protected class BindingAdapter extends WSDLElementAdapter - { - protected Binding binding; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.binding = (Binding)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - addExtensiblityElementChildren(list, binding); - List operationsList = binding.getEBindingOperations(); - List tempList = new ArrayList(); - tempList.addAll(operationsList); - - Collections.sort(tempList, new Comparator() { - public int compare(Object o1, Object o2) { - String s1 = ((BindingOperation) o1).getName(); - String s2 = ((BindingOperation) o2).getName(); - - if (s1 == null) { - s1 = ""; - } - if (s2 == null) { - s2 = ""; - } - - return s1.compareToIgnoreCase(s2); - } - }); - - list.addAll(tempList); - - return list; - } - - protected String getLabel() - { - return binding.getQName().getLocalPart(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/binding_obj.gif"); - } - } - - - protected class BindingFaultAdapter extends WSDLElementAdapter - { - protected BindingFault bindingFault; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.bindingFault = (BindingFault)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - addExtensiblityElementChildren(list, bindingFault); - return list; - } - - protected String getLabel() - { - return bindingFault.getName(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/fault_obj.gif"); - } - } - - - protected class BindingInputAdapter extends WSDLElementAdapter - { - protected BindingInput bindingInput; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.bindingInput = (BindingInput)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - addExtensiblityElementChildren(list, bindingInput); - return list; - } - - protected String getLabel() - { - return "input"; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/input_obj.gif"); - } - } - - - protected class BindingOutputAdapter extends WSDLElementAdapter - { - protected BindingOutput bindingOutput; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.bindingOutput = (BindingOutput)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - addExtensiblityElementChildren(list, bindingOutput); - return list; - } - - protected String getLabel() - { - return "output"; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/output_obj.gif"); - } - } - - - protected class BindingOperationAdapter extends WSDLElementAdapter - { - protected BindingOperation bindingOperation; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.bindingOperation = (BindingOperation)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - - addExtensiblityElementChildren(list, bindingOperation); - - if (bindingOperation.getBindingInput() != null) - { - list.add(bindingOperation.getBindingInput()); - } - if (bindingOperation.getBindingOutput() != null) - { - list.add(bindingOperation.getBindingOutput()); - } - list.addAll(bindingOperation.getEBindingFaults()); - - return list; - } - - - protected String getLabel() - { - return bindingOperation.getName(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/operationbinding_obj.gif"); - } - } - - // - // - // - protected class DefinitionAdapter extends WSDLElementAdapter implements ModelAdapterListener - { - protected List permanentWSDLGroupObjectList; - protected Definition definition; - - protected WSDLGroupObject typesGroup; - protected WSDLGroupObject extensibilityElementsGroup; - protected Types types; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.definition = (Definition)newTarget; - - // this group is added and removed from the child list dynamically - // dependant on the presence of an 'actual' types element - // - typesGroup = new WSDLGroupObject(definition, WSDLGroupObject.TYPES_GROUP, getModelAdapterFactory()); - - // these groups always exist in the child list - // - permanentWSDLGroupObjectList = new ArrayList(); - permanentWSDLGroupObjectList.add(new WSDLGroupObject(definition, WSDLGroupObject.IMPORTS_GROUP)); - permanentWSDLGroupObjectList.add(typesGroup); - permanentWSDLGroupObjectList.add(new WSDLGroupObject(definition, WSDLGroupObject.MESSAGES_GROUP)); - permanentWSDLGroupObjectList.add(new WSDLGroupObject(definition, WSDLGroupObject.PORT_TYPES_GROUP)); - permanentWSDLGroupObjectList.add(new WSDLGroupObject(definition, WSDLGroupObject.BINDINGS_GROUP)); - permanentWSDLGroupObjectList.add(new WSDLGroupObject(definition, WSDLGroupObject.SERVICES_GROUP)); - // we only add this group when it has content - // - extensibilityElementsGroup = new WSDLGroupObject(definition, WSDLGroupObject.EXTENSIBILITY_ELEMENTS_GROUP); - - updateTypes(); - } - - protected List getChildren() - { - List list = new ArrayList(); - list.addAll(permanentWSDLGroupObjectList); - //if (extensibilityElementsGroup.getChildren().size() > 0) - //{ - list.add(extensibilityElementsGroup); - //} - return list; - } - - public void notifyChanged(Notification msg) - { - if (msg.getEventType() != Notification.RESOLVE) - { - updateTypes(); - firePropertyChangedHelper(); - } - } - - protected void updateTypes() - { - if (types != definition.getETypes()) - { - if (types != null) - { - removeModelAdapterListener(types, this); - } - types = definition.getETypes(); - if (types != null) - { - addModelAdapterListener(types, this); - } - } - } - - protected void firePropertyChangedHelper() - { - firePropertyChanged(getTarget(), null); - - for (Iterator i = getChildren().iterator(); i.hasNext(); ) - { - ModelAdapter adapter = getAdapter(i.next()); - adapter.firePropertyChanged(adapter, null); - } - } - - // propagate changes to 'types' object - // - public void propertyChanged(Object object, String property) - { - typesGroup.firePropertyChanged(typesGroup, property); - } - - protected ModelAdapterFactory getModelAdapterFactory() - { - return getWSDLModelAdapterFactory(); - } - - protected String getLabel() - { - if (definition.getQName() != null) { - return definition.getQName().getLocalPart(); - } - return ""; - } - - protected Image getImage() - { - return null; - } - } - - - - protected class FaultAdapter extends WSDLElementAdapter - { - protected Fault fault; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.fault = (Fault)newTarget; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/fault_obj.gif"); - } - - protected String getLabel() - { - return fault.getName(); - } - } - - - // - // - // - protected class ImportAdapter extends WSDLElementAdapter - { - protected Import theImport; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.theImport = (Import)newTarget; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/import_obj.gif"); - } - - protected String getLabel() - { - String result = theImport.getLocationURI(); - if (result == null || result.length() == 0) - { - result = WSDLEditorPlugin.getWSDLString("_UI_NO_IMPORT_SPECIFIED"); - } - return result; - } - } - - - // - // - // - protected class InputAdapter extends WSDLElementAdapter - { - protected Input input; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.input = (Input)newTarget; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/input_obj.gif"); - } - - protected String getLabel() - { - return "input"; - } - } - - - - // - // - // - protected class MessageAdapter extends WSDLElementAdapter - { - protected Message message; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.message = (Message)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - list.addAll(message.getEParts()); - return list; - } - - protected String getLabel() - { - if (message.getQName() == null) return ""; // revisit...it shouldn't be null - return message.getQName().getLocalPart(); - - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/message_obj.gif"); - } - } - - - // - // - // - protected class OutputAdapter extends WSDLElementAdapter - { - protected Output output; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.output = (Output)newTarget; - } - - protected String getLabel() - { - return "output"; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/output_obj.gif"); - } - } - - // - // - // - protected class OperationAdapter extends WSDLElementAdapter - { - protected Operation operation; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.operation = (Operation)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - Input input = operation.getEInput(); - Output output = operation.getEOutput(); - - OperationType operationType = ((OperationImpl) operation).getStyle(); - if (operationType != null) { - if (operationType.equals(OperationType.REQUEST_RESPONSE) && input != null && output != null) { - // Input, Output - list.add(input); - list.add(output); - } - else if (operationType.equals(OperationType.SOLICIT_RESPONSE) && input != null && output != null) { - // Output, Input - list.add(output); - list.add(input); - } - else if (operationType.equals(OperationType.ONE_WAY) && input != null) { - // Input - list.add(input); - } - else if (operationType.equals(OperationType.NOTIFICATION) && output != null) { - //Output - list.add(output); - } - } - list.addAll(operation.getFaults().values()); - - return list; - } - -// private int getNodeIndex(NodeList nodeList, Node node) { -// int index = 0; -// while (index < nodeList.getLength() && !(nodeList.item(index).equals(node))) { -// index++; -// } -// -// if (index >= nodeList.getLength()) { -// index = -1; -// } -// -// return index; -// } - - protected String getLabel() - { - return operation.getName(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/operation_obj.gif"); - } - } - - - // - // - // - protected class PartAdapter extends WSDLElementAdapter - { - protected Part part; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.part = (Part)newTarget; - } - - protected String getLabel() - { - return part.getName(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/part_obj.gif"); - } - } - - // - // - // - protected class PortAdapter extends WSDLElementAdapter implements ModelAdapterListener - { - protected Port port; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.port = (Port)newTarget; - } - - protected String getLabel() - { - return port.getName(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/port_obj.gif"); - } - - protected List getChildren() - { - return WSDLEditorUtil.getInstance().getExtensibilityElementNodes(port); - } - // propagate changes to the binding object - // - public void propertyChanged(Object object, String property) - { - firePropertyChanged(port, property); - } - } - - protected class ExtensibilityElementAdapter extends WSDLElementAdapter implements ModelAdapterListener - { - protected ExtensibilityElement ee; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.ee = (ExtensibilityElement)newTarget; - } - - protected String getLabel() - { - String result = null; - Node node = (Node) ee.getElement(); - - ILabelProvider labelProvider = getExtensibilityLabelProvider(node); - if (labelProvider != null) - { - result = labelProvider.getText(node); - } - - if (result == null) - { - result = node.getNodeName(); - } - return result; - } - - protected Image getImage() - { - Image image = null; - Node node = (Node) ee.getElement(); - - ILabelProvider labelProvider = getExtensibilityLabelProvider(node); - if (labelProvider != null) - { - image = labelProvider.getImage(node); - } - - if (image == null) - { - image = WSDLEditorPlugin.getInstance().getImage("icons/element_obj.gif"); - } - return image; - } - - protected List getChildren() - { - List list = null; - //TODO... we need to push getChildren down the ExtensiblityElement - // for now let's just cast to UnkownExtensiblityElement - if (ee instanceof UnknownExtensibilityElement) - { - list = ((UnknownExtensibilityElement)ee).getChildren(); - } - return list; - } - - public void propertyChanged(Object object, String property) - { - firePropertyChanged(ee, property); - } - - protected ILabelProvider getExtensibilityLabelProvider(Node node) - { - ILabelProvider result = null; - String namespaceURI = node.getNamespaceURI(); - if (namespaceURI != null) - { - result = WSDLEditorPlugin.getInstance().getExtensibilityItemTreeProviderRegistry().getLabelProvider(namespaceURI); - } - return result; - } - - protected ITreeChildProvider getExtensibilityContentProvider(Node node) - { - ITreeChildProvider result = null; - String namespaceURI = node.getNamespaceURI(); - if (namespaceURI != null) - { - result = WSDLEditorPlugin.getInstance().getExtensibilityItemTreeProviderRegistry().getContentProvider(namespaceURI); - } - return result; - } - - boolean isReadOnly() - { - return true; - } - } - - - // - // - // - protected class PortTypeAdapter extends WSDLElementAdapter - { - protected PortType portType; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.portType = (PortType)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - list.addAll(portType.getOperations()); - - Collections.sort(list, new Comparator() - { - public int compare(Object o1, Object o2) - { - String o1Name = ((Operation) o1).getName(); - String o2Name = ((Operation) o2).getName(); - if (o1Name == null) o1Name = ""; - if (o2Name == null) o2Name = ""; - return (o1Name.compareToIgnoreCase(o2Name)); - } - }); - return list; - } - - protected String getLabel() - { - return portType.getQName().getLocalPart(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/porttype_obj.gif"); - } - } - - - protected class ServiceAdapter extends WSDLElementAdapter - { - protected Service service; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.service = (Service)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - list.addAll(service.getEPorts()); - return list; - } - - protected String getLabel() - { - return service.getQName().getLocalPart(); - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/service_obj.gif"); - } - } - - // - // - // - public class TypesAdapter extends WSDLElementAdapter - { - protected Types types; - - public void setTarget(Notifier newTarget) - { - super.setTarget(newTarget); - this.types = (Types)newTarget; - } - - protected List getChildren() - { - List list = new ArrayList(); - list.addAll(WSDLEditorUtil.getInstance().getExtensibilityElementNodes(types)); - return list; - } - - protected String getLabel() - { - return "Types"; - } - - protected Image getImage() - { - return WSDLEditorPlugin.getInstance().getImage("icons/types_obj.gif"); - } - } - - public static void addModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { -// TODO: port check - ModelAdapter adapter = getWSDLModelAdapterFactory().getAdapter(modelObject); -// ModelAdapter adapter = EcoreUtil.getAdapter(getWSDLModelAdapterFactory().eAdapters(),modelObject); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - public static void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener) - { -// TODO: port check - ModelAdapter adapter = getWSDLModelAdapterFactory().getAdapter(modelObject); -// ModelAdapter adapter = EcoreUtil.getAdapter(getWSDLModelAdapterFactory().eAdapters(),modelObject); - if (adapter != null) - { - adapter.removeListener(listener); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/nsedit/EditNamespacesDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/nsedit/EditNamespacesDialog.java deleted file mode 100644 index 60536f7ea..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/nsedit/EditNamespacesDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.nsedit; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesTargetFieldDialog; - -public class EditNamespacesDialog extends Dialog -{ - protected Button okButton; - protected String title; - protected String targetNamespace; - protected List namespaceInfoList; - protected CommonEditNamespacesTargetFieldDialog editWSDLNamespacesControl; - protected IPath resourceLocation; - // protected Label errorMessageLabel; - // protected String errorMessage; - - //protected Label errorMessageLabel; - - public EditNamespacesDialog(Shell parentShell, IPath resourceLocation, String title, String targetNamespace, List namespaceList) - { - super(parentShell); - this.resourceLocation = resourceLocation; - setShellStyle(getShellStyle() | SWT.RESIZE); - this.title = title; - this.targetNamespace = targetNamespace; - this.namespaceInfoList = namespaceList; - } - - public int createAndOpen() - { - create(); - getShell().setText(title); - setBlockOnOpen(true); - return open(); - } - - protected Control createContents(Composite parent) - { - Control control = super.createContents(parent); - updateErrorMessage(); - return control; - } - - protected void createButtonsForButtonBar(Composite parent) - { - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - protected Control createDialogArea(Composite parent) - { - Composite dialogArea = (Composite) super.createDialogArea(parent); - editWSDLNamespacesControl = new CommonEditNamespacesTargetFieldDialog(dialogArea, resourceLocation); - editWSDLNamespacesControl.setNamespaceInfoList(namespaceInfoList); - editWSDLNamespacesControl.setTargetNamespace(targetNamespace); - - return dialogArea; - } - - public void modifyText(ModifyEvent e) - { - updateErrorMessage(); - } - - protected String computeErrorMessage(String name) - { - return null; - } - - protected void updateErrorMessage() - { - String errorMessage = null; - /* - String name = nameField.getText().trim(); - if (name.length() > 0) - { - errorMessage = computeErrorMessage(name); - } - else - { - errorMessage = ""; - }*/ - - //errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); - okButton.setEnabled(errorMessage == null); - } - - protected void buttonPressed(int buttonId) - { - if (buttonId == IDialogConstants.OK_ID) - { - targetNamespace = editWSDLNamespacesControl.getTargetNamespace(); - } - super.buttonPressed(buttonId); - } - - public List getNamespaceInfoList() - { - return namespaceInfoList; - } - - public String getTargetNamespace() - { - return targetNamespace; - } -} 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 deleted file mode 100644 index ac204bf73..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ExtensibleOutlineProvider.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import org.eclipse.jface.viewers.ILabelProvider; -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; -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 - - for (int i = 0; i < treeContentProviders.length; i++) { - treeContentProviders[i].dispose(); - } - - for (int i = 0; i < labelProviderExtensions.length; i++) { - labelProviders[i].dispose(); - } - } - - 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(), domDoc); - } - - definition = modelAdapter.getDefinition(); - } - } - return definition; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/HTTPLabelProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/HTTPLabelProvider.java deleted file mode 100644 index 5afe4fe09..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/HTTPLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import java.util.HashMap; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.w3c.dom.Node; - - -public class HTTPLabelProvider extends LabelProvider -{ - protected final static String ADDRESS = "address"; - protected final static String BINDING = "binding"; - protected final static String OPERATION = "operation"; - protected final static String URL_ENCODED = "urlEncoded"; - protected final static String URL_REPLACEMENT = "urlReplacement"; - - protected HashMap map = new HashMap(); - - public HTTPLabelProvider() - { - map.put(ADDRESS, "icons/httpaddress_obj.gif"); - map.put(BINDING, "icons/httpbinding_obj.gif"); - map.put(OPERATION, "icons/httpoperation_obj.gif"); - map.put(URL_ENCODED, "icons/httpurlencoded_obj.gif"); - map.put(URL_REPLACEMENT, "icons/httpurlreplacement_obj.gif"); - } - - public Image getImage(Object object) - { - Node node = (Node)object; - String imageName = (String)map.get(node.getLocalName()); - return imageName != null ? WSDLEditorPlugin.getInstance().getImage(imageName) : null; - } - - public String getText(Object object) - { - Node node = (Node)object; - return node.getNodeName(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterContentProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterContentProvider.java deleted file mode 100644 index 7068aad06..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterContentProvider.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; - - - -public class ModelAdapterContentProvider implements ITreeContentProvider, ModelAdapterListener -{ - protected Viewer viewer; - protected ModelAdapterFactory adapterFactory; - - public ModelAdapterContentProvider(ModelAdapterFactory adapterFactory) - { - this.adapterFactory = adapterFactory; - } - - protected void attachListener(Object object) - { - ModelAdapter adapter = adapterFactory.getAdapter(object); -// TODO: port check -// ModelAdapter adapter = EcoreUtil.getAdapter(adapterFactory.eAdapters(),object); - if (adapter != null) - { - adapter.addListener(this); - } - } - - public void propertyChanged(Object object, String property) - { - if (viewer != null) - { - if (viewer instanceof StructuredViewer) - { - ((StructuredViewer)viewer).refresh(object); - } - else - { - viewer.refresh(); - } - } - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentObject) - { - attachListener(parentObject); - - List list = null; -// TODO: port check - ModelAdapter modelAdapter = adapterFactory.getAdapter(parentObject); -// ModelAdapter modelAdapter = EcoreUtil.getAdapter(adapterFactory.eAdapters(),parentObject); - if (modelAdapter != null) - { - list = (List)modelAdapter.getProperty(parentObject, ModelAdapter.CHILDREN_PROPERTY); - } - list = list != null ? list : Collections.EMPTY_LIST; - return list.toArray(); - } - - /* - * @see ITreeContentProvider#getParent(Object) - */ - public Object getParent(Object element) - { - return null; - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) - { - Object[] children = getChildren(element); - return children != null && children.length > 0; - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) - { - return getChildren(inputElement); - } - - /* - * @see IContentProvider#dispose() - */ - public void dispose() - { - viewer = null; - } - - /* - * @see IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - this.viewer = viewer; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterLabelProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterLabelProvider.java deleted file mode 100644 index 720c74ca9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/ModelAdapterLabelProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterFactory; - - - -public class ModelAdapterLabelProvider extends LabelProvider -{ - protected ModelAdapterFactory adapterFactory; - - public ModelAdapterLabelProvider(ModelAdapterFactory adapterFactory) - { - this.adapterFactory = adapterFactory; - } - - - public Image getImage(Object object) - { - Image result = null; -// TODO: port check - ModelAdapter modelAdapter = adapterFactory.getAdapter(object); -// ModelAdapter modelAdapter = EcoreUtil.getAdapter(adapterFactory.eAdapters(),object); - if (modelAdapter != null) - { - result = (Image)modelAdapter.getProperty(object, ModelAdapter.IMAGE_PROPERTY); - } - return result; - } - - - public String getText(Object object) - { - String result = null; -// TODO: port check - ModelAdapter modelAdapter = adapterFactory.getAdapter(object); -// ModelAdapter modelAdapter = EcoreUtil.getAdapter(adapterFactory.eAdapters(),object); - if (modelAdapter != null) - { - result = (String)modelAdapter.getProperty(object, ModelAdapter.LABEL_PROPERTY); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/SOAPLabelProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/SOAPLabelProvider.java deleted file mode 100644 index 93cefa40d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/SOAPLabelProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import java.util.HashMap; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.w3c.dom.Node; - - -public class SOAPLabelProvider extends LabelProvider -{ - protected final static String ADDRESS = "address"; - protected final static String BODY = "body"; - protected final static String BINDING = "binding"; - protected final static String FAULT = "fault"; - protected final static String HEADER = "header"; - protected final static String HEADER_FAULT = "headerfault"; - protected final static String OPERATION = "operation"; - - protected HashMap map = new HashMap(); - - public SOAPLabelProvider() - { - map.put(ADDRESS, "icons/soapaddress_obj.gif"); - map.put(BINDING, "icons/soapbinding_obj.gif"); - map.put(BODY, "icons/soapbody_obj.gif"); - map.put(FAULT, "icons/soapfault_obj.gif"); - map.put(HEADER, "icons/soapheader_obj.gif"); - map.put(HEADER_FAULT, "icons/soapheaderfault_obj.gif"); - map.put(OPERATION, "icons/soapoperation_obj.gif"); - } - - public Image getImage(Object object) - { - Node node = (Node)object; - String imageName = (String)map.get(node.getLocalName()); - return imageName != null ? WSDLEditorPlugin.getInstance().getImage(imageName) : null; - } - - public String getText(Object object) - { - Node node = (Node)object; - return node.getNodeName(); - } -}
\ No newline at end of file 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 deleted file mode 100644 index bb945f6bd..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlineConfiguration.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -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.IContentProvider; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -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.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 { - private ExtensibleOutlineProvider fOutlineProvider = null; - private KeyListener[] fKeyListeners = null; - private IMenuListener fMenuListener = 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 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; - } - - /** - * 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(), domDoc); - } - - 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 deleted file mode 100644 index ffa80ee2e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/outline/WSDLContentOutlinePage.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.outline; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.action.MenuManager; -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.ITreeContentProvider; -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.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -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.util.OpenOnSelectionHelper; - -/** - * @deprecated Using SSE's ConfiguratbleContentOutlinePage - * instead via WSDLContentOutlineCOnfiguration - */ -public class WSDLContentOutlinePage extends ContentOutlinePage -{ - protected WSDLEditor wsdlEditor; - protected int level = 0; - protected Object model; - protected ITreeContentProvider contentProvider; - protected ILabelProvider labelProvider; - protected WSDLSelectionManager selectionManager; - protected SelectionManagerSelectionChangeListener selectionManagerSelectionChangeListener = new SelectionManagerSelectionChangeListener(); - protected TreeSelectionChangeListener treeSelectionChangeListener = new TreeSelectionChangeListener(); - - public WSDLContentOutlinePage(WSDLEditor wsdlEditor) - { - this.wsdlEditor = wsdlEditor; - } - - - public void setContentProvider(ITreeContentProvider contentProvider) - { - this.contentProvider = contentProvider; - } - - - public void setLabelProvider(ILabelProvider labelProvider) - { - this.labelProvider = labelProvider; - } - - - // expose - public TreeViewer getTreeViewer() - { - return super.getTreeViewer(); - } - - public void createControl(Composite parent) - { - super.createControl(parent); - - getTreeViewer().setContentProvider(contentProvider); - getTreeViewer().setLabelProvider(labelProvider); - getTreeViewer().setInput(model); - getTreeViewer().addSelectionChangedListener(this); - - KeyAdapter keyListener = new KeyAdapter() - { - public void keyReleased(KeyEvent e) - { - if (e.keyCode == SWT.F3) - { - ISelection selection = selectionManager.getSelection(); - if (selection instanceof IStructuredSelection) - { - Object object = ((IStructuredSelection)selection).getFirstElement(); - if (object instanceof EObject) - { - OpenOnSelectionHelper helper = new OpenOnSelectionHelper(wsdlEditor.getDefinition()); - helper.openEditor((EObject)object); - } - } - } - } - }; - getTreeViewer().getTree().addKeyListener(keyListener); - - MenuManager menuManager = new MenuManager("#popup");//$NON-NLS-1$ - menuManager.setRemoveAllWhenShown(true); - Menu menu = menuManager.createContextMenu(getTreeViewer().getControl()); - getTreeViewer().getControl().setMenu(menu); - - WSDLMenuListener menuListener = new WSDLMenuListener(wsdlEditor, wsdlEditor.getSelectionManager());//, (XSDTextEditor)fTextEditor); - menuManager.addMenuListener(menuListener); - - setSelectionManager(wsdlEditor.getSelectionManager()); - - // enable popupMenus extension - Rich - this class is deprecated. TODO - change this - getSite().registerContextMenu("org.eclipse.wst.wsdl.ui.popup.outline", menuManager, wsdlEditor.getSelectionManager()); - } - - - public void setModel(Object object) - { - model = object; - } - - - public void setExpandToLevel(int i) - { - level = i; - } - - - public void setInput(Object value) - { - getTreeViewer().setInput(value); - getTreeViewer().expandToLevel(level); - } - - - public void setSelectionManager(WSDLSelectionManager newSelectionManager) - { - TreeViewer treeViewer = getTreeViewer(); - - // disconnect from old one - if (selectionManager != null) - { - selectionManager.removeSelectionChangedListener(selectionManagerSelectionChangeListener); - treeViewer.removeSelectionChangedListener(treeSelectionChangeListener); - } - - selectionManager = newSelectionManager; - - // connect to new one - if (selectionManager != null) - { - selectionManager.addSelectionChangedListener(selectionManagerSelectionChangeListener); - treeViewer.addSelectionChangedListener(treeSelectionChangeListener); - } - } - - class SelectionManagerSelectionChangeListener implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) - { - if (event.getSelectionProvider() != getTreeViewer()) - { - getTreeViewer().setSelection(event.getSelection(), true); - } - } - } - - class TreeSelectionChangeListener implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) - { - if (selectionManager != null) - { - ISelection selection = event.getSelection(); - 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) - { - selectionManager.setSelection(new StructuredSelection(o), getTreeViewer()); - } - else - { - selectionManager.setSelection(new StructuredSelection(), getTreeViewer()); - } - } - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddBaseParameterCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddBaseParameterCommand.java deleted file mode 100644 index bbe088389..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddBaseParameterCommand.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddPartCommand; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; - -public abstract class AddBaseParameterCommand { - public static int PART_ELEMENT_SEQ_ELEMENT = 0; - public static int PART_ELEMENT = 1; - public static int PART_COMPLEXTYPE_SEQ_ELEMENT = 2; - public static int PART_COMPLEXTYPE = 3; - - protected int style = 0; - protected Operation operation; - protected XSDElementDeclaration newXSDElement; - - protected String newAnonymousXSDElementName; - protected String newXSDElementName; - protected String newWSDLMessageName; - protected String newWSDLPartName; - - public abstract void run(); - - public AddBaseParameterCommand(Operation operation, int style) { - this.operation = operation; - this.style = style; - } - - public void setStyle(int style) { - this.style = style; - } - - public XSDElementDeclaration getXSDElementDeclaration() { - return newXSDElement; - } - - protected boolean isPartElementReference() { - if (style == PART_ELEMENT || style == PART_ELEMENT_SEQ_ELEMENT) { - return true; - } - - return false; - } - - protected XSDElementDeclaration createPartElementReferenceComponents(Part part) { - XSDElementDeclaration returnedXSDElement = null; - XSDElementDeclaration partElement = part.getElementDeclaration(); - - if (style == PART_ELEMENT_SEQ_ELEMENT) { - XSDElementDeclaration originalElement = null; - XSDElementDeclaration anonXSDElement = null; - - // Create the XSDElement (anonymous) referenced by the Part if necessary - if (partElement == null || partElement.getAnonymousTypeDefinition() == null) { - anonXSDElement = XSDComponentHelper.createAnonymousXSDElementDefinition(getAnonymousXSDElementBaseName(), part); -// part.setElementDeclaration(anonXSDElement); - String prefixedName = getPrefixedComponentName(part.getEnclosingDefinition(), anonXSDElement); - ComponentReferenceUtil.setComponentReference(part, false, prefixedName); - part.setTypeDefinition(null); - - if (partElement != null) { - originalElement = partElement; - // Remove the 'original' XSDElement as a Global Element - partElement.getSchema().getContents().remove(partElement); - } - } - else { - anonXSDElement = partElement; - } - - // Create a new XSDElement - XSDModelGroup modelGroup = XSDComponentHelper.getXSDModelGroup(anonXSDElement, part.getEnclosingDefinition()); - returnedXSDElement = XSDComponentHelper.createXSDElementDeclarationCommand(null, getNewXSDElementBaseName(), modelGroup); - - // Add the newly created XSDElement to the ModelGroup - XSDComponentHelper.addXSDElementToModelGroup(anonXSDElement, returnedXSDElement); - - // Add the 'original' XSDElement if it's type wasn't anonymous - if (originalElement != null) { - XSDComponentHelper.addXSDElementToModelGroup(anonXSDElement, originalElement); - } - } - else if (style == PART_ELEMENT) { - if (partElement == null) { - returnedXSDElement = XSDComponentHelper.createXSDElementDeclarationCommand(part.getEnclosingDefinition(), getNewXSDElementBaseName(), part); - } - else { - // TODO: What should we do here..... We can default to the PART_ELEMENT_SEQ_ELEMENT style - // since it handles 'multiple' XSDElements.... OR ..... we can 'overwrite and set a new - // XSDElement - } - - if (returnedXSDElement != null && !returnedXSDElement.equals(part.getElementDeclaration())) { -// part.setElementDeclaration(returnedXSDElement); - String prefixedName = getPrefixedComponentName(part.getEnclosingDefinition(), returnedXSDElement); - ComponentReferenceUtil.setComponentReference(part, false, prefixedName); - - } - } - - return returnedXSDElement; - } - - protected XSDElementDeclaration createPartComplexTypeReference(Part part) { - XSDElementDeclaration returnedXSDElement = null; - - if (style == PART_COMPLEXTYPE_SEQ_ELEMENT) { - XSDTypeDefinition originalType = null; - XSDComplexTypeDefinition topLevelType = null; - - // Create the ComplexType referenced by the Part if necessary - if (part.getTypeDefinition() == null || part.getTypeDefinition() instanceof XSDSimpleTypeDefinition) { - XSDSchema schema = XSDComponentHelper.getXSDSchema(part.getEnclosingDefinition()); - String topLevelName = WNameHelperUtil.getXSDComplexTypeName(part.getName(), schema); - topLevelType = XSDComponentHelper.createXSDComplexTypeDefiniion(topLevelName, part); - - if (part.getTypeDefinition() instanceof XSDSimpleTypeDefinition) { - originalType = part.getTypeDefinition(); - } - } - else if (part.getTypeDefinition() instanceof XSDComplexTypeDefinition){ - topLevelType = (XSDComplexTypeDefinition) part.getTypeDefinition(); - } - - // Create a new XSDElement - XSDModelGroup modelGroup = XSDComponentHelper.getXSDModelGroup(topLevelType); - returnedXSDElement = XSDComponentHelper.createXSDElementDeclarationCommand(null, getNewXSDElementBaseName(), modelGroup); - - // Add the 'original' XSDElement if it's type wasn't anonymous - if (originalType != null) { - // Create another new XSDElement to 'contain' the originally referenced XSDSimpleType - XSDElementDeclaration origXSDElement = XSDComponentHelper.createXSDElementDeclarationCommand(null, getNewXSDElementBaseName(), modelGroup); - origXSDElement.setTypeDefinition(originalType); - } - - // Change Part reference -// part.setTypeDefinition(topLevelType); - String prefixedName = getPrefixedComponentName(part.getEnclosingDefinition(), topLevelType); - ComponentReferenceUtil.setComponentReference(part, true, prefixedName); - - - } - else if (style == PART_COMPLEXTYPE) { - XSDComplexTypeDefinition complexType = null; - if (part.getTypeDefinition() == null) { - // Create a new ComplexType - XSDSchema schema = XSDComponentHelper.getXSDSchema(part.getEnclosingDefinition()); - String complexName = WNameHelperUtil.getXSDComplexTypeName(part.getName(), schema); - complexType = XSDComponentHelper.createXSDComplexTypeDefiniion(complexName, part); - - // Create an XSDElement for the ComplexType - XSDModelGroup xsdModelGroup = XSDComponentHelper.getXSDModelGroup(complexType); - returnedXSDElement = XSDComponentHelper.createXSDElementDeclarationCommand(null, getNewXSDElementBaseName(), xsdModelGroup); - } - else { - // TODO: What should we do here..... We can default to the PART_ELEMENT_SEQ_ELEMENT style - // since it handles 'multiple' XSDElements.... OR ..... we can 'overwrite and set a new - // XSDElement - } - - if (complexType != null && !complexType.equals(part.getTypeDefinition())) { -// part.setTypeDefinition(complexType); - String prefixedName = getPrefixedComponentName(part.getEnclosingDefinition(), complexType); - ComponentReferenceUtil.setComponentReference(part, true, prefixedName); - } - } - - return returnedXSDElement; - } - /* - * Create if necessary a Message and Part for the given MessageReference - * and return it's Part - */ - protected Part createWSDLComponents(MessageReference messageRef) { - Message message = messageRef.getEMessage(); - Part part = null; - - if (message == null) { - // Create Message - AddMessageCommand command = new AddMessageCommand(messageRef.getEnclosingDefinition(), getWSDLMessageName()); - command.run(); - message = (Message) command.getWSDLElement(); - messageRef.setEMessage(message); - } - - if (message.getEParts().size() == 0) { - // Create Part - AddPartCommand command = new AddPartCommand(message, getWSDLPartName()); - command.run(); - part = (Part) command.getWSDLElement(); - } - else { - part = (Part) message.getEParts().get(0); - } - - return part; - } - - protected XSDElementDeclaration createXSDObjects(Part part) { - XSDElementDeclaration returnedXSDElement = null; - if (isPartElementReference()) { - // Is a Part --> Element reference - returnedXSDElement = createPartElementReferenceComponents(part); - } - else { - // Is a Part --> Complex Type reference - returnedXSDElement = createPartComplexTypeReference(part); - } - - return returnedXSDElement; - } - - private String getPrefixedComponentName(Definition definition, XSDNamedComponent component) { - String name = component.getName(); - String tns = component.getTargetNamespace(); - List prefixes = getPrefixes(definition, tns); - if (prefixes.size() > 0) { - name = prefixes.get(0) + ":" + name; - } - - return name; - } - - private List getPrefixes(Definition definition, String namespace) { - List list = new ArrayList(); - Map map = definition.getNamespaces(); - for (Iterator i = map.keySet().iterator(); i.hasNext();) { - String prefix = (String) i.next(); - String theNamespace = (String) map.get(prefix); - if (theNamespace != null && theNamespace.equals(namespace)) { - list.add(prefix); - } - } - return list; - } - - protected abstract String getAnonymousXSDElementBaseName(); - protected abstract String getNewXSDElementBaseName(); - protected abstract String getWSDLMessageName(); - protected abstract String getWSDLPartName(); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddFaultParameterCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddFaultParameterCommand.java deleted file mode 100644 index d6e986e8b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddFaultParameterCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.commands.AddFaultCommand; - -public class AddFaultParameterCommand extends AddBaseParameterCommand { - protected Fault fault; - private String faultName; - - public AddFaultParameterCommand(Operation operation, Fault fault) { - super(operation, AddBaseParameterCommand.PART_ELEMENT); - this.fault = fault; - } - - /* - * - */ - public void run() { - if (fault == null) { - AddFaultCommand command = new AddFaultCommand(operation, getFaultName()); - command.run(); - fault = (Fault) command.getWSDLElement(); - } - - Part part = createWSDLComponents(fault); - - // Create necessary XSD Objects starting with the Part reference - newXSDElement = createXSDObjects(part); - } - - protected String getAnonymousXSDElementBaseName() { - if (newAnonymousXSDElementName == null) { - newAnonymousXSDElementName = operation.getName() + "_" + getFaultName(); - } - - return newAnonymousXSDElementName; - } - - protected String getNewXSDElementBaseName() { - if (newXSDElementName == null) { - newXSDElementName = operation.getName() + "_" + getFaultName(); - } - - return newXSDElementName; - } - - protected String getWSDLMessageName() { - if (newWSDLMessageName == null) { - newWSDLMessageName = operation.getName() + "_" + getFaultName() + "Msg"; - } - - return newWSDLMessageName; - } - - protected String getWSDLPartName() { - if (newWSDLPartName == null) { - newWSDLPartName = getFaultName(); - } - - return newWSDLPartName; - } - - private String getFaultName() { - if (faultName == null) { - if (fault != null) { - faultName = fault.getName(); - } - else { - faultName = WNameHelperUtil.getFaultName(operation); - } - } - - return faultName; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddInputParameterCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddInputParameterCommand.java deleted file mode 100644 index 3073f1cf6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddInputParameterCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.commands.AddInputCommand; - -public class AddInputParameterCommand extends AddBaseParameterCommand { - public AddInputParameterCommand(Operation operation, int style) { - super(operation, style); - } - - /* - * - */ - public void run() { - Part part = null; - if (operation.getEInput() != null) { - part = createWSDLComponents(operation.getEInput()); - } - else { - AddInputCommand command = new AddInputCommand(operation, null); - command.run(); - Input input = (Input) command.getWSDLElement(); - part = createWSDLComponents(input); - } - - // Create necessary XSD Objects starting with the Part reference - newXSDElement = createXSDObjects(part); - } - - protected String getAnonymousXSDElementBaseName() { - if (newAnonymousXSDElementName == null) { - newAnonymousXSDElementName = operation.getName() + "Request"; - } - - return newAnonymousXSDElementName; - } - - protected String getNewXSDElementBaseName() { - if (newXSDElementName == null) { - newXSDElementName = "input"; - } - - return newXSDElementName; - } - - protected String getWSDLMessageName() { - if (newWSDLMessageName == null) { - if (operation.getEInput() != null) { - newWSDLMessageName= WNameHelperUtil.getMessageName(operation.getEInput()); - } - } - - return newWSDLMessageName; - } - - protected String getWSDLPartName() { - if (newWSDLPartName == null) { - newWSDLPartName = WNameHelperUtil.getPartName(operation.getEInput()); - } - - return newWSDLPartName; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddOutputParameterCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddOutputParameterCommand.java deleted file mode 100644 index 4771bd1dd..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/AddOutputParameterCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOutputCommand; - -public class AddOutputParameterCommand extends AddBaseParameterCommand { - public AddOutputParameterCommand(Operation operation, int style) { - super(operation, style); - } - - /* - * - */ - public void run() { - Part part = null; - if (operation.getEOutput() != null) { - part = createWSDLComponents(operation.getEOutput()); - } - else { - AddOutputCommand command = new AddOutputCommand(operation, null); - command.run(); - Output output = (Output) command.getWSDLElement(); - part = createWSDLComponents(output); - } - - // Create necessary XSD Objects starting with the Part reference - newXSDElement = createXSDObjects(part); - } - - protected String getAnonymousXSDElementBaseName() { - if (newAnonymousXSDElementName == null) { - newAnonymousXSDElementName = operation.getName() + "Response"; - } - - return newAnonymousXSDElementName; - } - - protected String getNewXSDElementBaseName() { - if (newXSDElementName == null) { - newXSDElementName = "output"; - } - - return newXSDElementName; - } - - protected String getWSDLMessageName() { - if (newWSDLMessageName == null) { - if (operation.getEOutput() != null) { - newWSDLMessageName= WNameHelperUtil.getMessageName(operation.getEOutput()); - } - } - - return newWSDLMessageName; - } - - protected String getWSDLPartName() { - if (newWSDLPartName == null) { - newWSDLPartName = WNameHelperUtil.getPartName(operation.getEOutput()); - } - - return newWSDLPartName; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/WNameHelperUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/WNameHelperUtil.java deleted file mode 100644 index 593783f64..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/WNameHelperUtil.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; - -public class WNameHelperUtil { - public static String getMessageName(MessageReference messageRef) { - String messageName = "NewMessage"; - List messageNames = new ArrayList(); - Operation operation = (Operation) messageRef.getContainer(); - Iterator messageIt = operation.getEnclosingDefinition().getEMessages().iterator(); - while (messageIt.hasNext()) { - messageNames.add(((Message) messageIt.next()).getQName().getLocalPart()); - } - - String requestResponseString = getRequestOrResponse(messageRef) + "Msg"; - messageName = getUniqueName(operation.getName() + requestResponseString, messageNames); - - return messageName; - } - - public static String getPartName(MessageReference messageRef) { - String partName = "NewPart"; - Message message = messageRef.getEMessage(); - - Operation operation = (Operation) messageRef.getContainer(); -// Operation operation = (Operation) ((WOperation) ownerMessage.getOwnerOperation()).getModel(); - String operationName = operation.getName(); - String appendString = ""; - if (messageRef instanceof Input) { - appendString = "Parameters"; - } - else if (messageRef instanceof Output) { - appendString = "Result"; - } - else if (messageRef instanceof Fault) { - appendString = "Fault"; - } - partName = operationName + appendString; - - List usedPartNames = new ArrayList(); - if (message != null) { - Iterator partIt = message.getEParts().iterator(); - while (partIt.hasNext()) { - usedPartNames.add(((Part) partIt.next()).getName()); - } - } - - partName = getUniqueName(partName, usedPartNames); - - return partName; - } - - public static String getOperationName(PortType portType) { - String operationName = "NewOperation"; - Iterator operationIt = portType.getEOperations().iterator(); - List usedNames = new ArrayList(); - while (operationIt.hasNext()) { - usedNames.add(((Operation) operationIt.next()).getName()); - } - - operationName = getUniqueName("NewOperation", usedNames); - - return operationName; - } - - public static String getRequestOrResponse(MessageReference messageRef) { - if (messageRef instanceof Input) - { - return "Request"; - } - else if (messageRef instanceof Output) - { - return "Response"; - } - else if (messageRef instanceof Fault) - { - return "_Fault"; - } - - return ""; - } - - public static String getFaultName(Operation operation) { - String faultName = "fault"; - List nameList = new ArrayList(); - Iterator faultIt = operation.getEFaults().iterator(); - while (faultIt.hasNext()) { - nameList.add(((Fault) faultIt.next()).getName()); - } - - faultName = getUniqueName(faultName, nameList); - - return faultName; - } - - public static String getXSDElementName(String baseName, Object parent) { - String elementName = ""; - - if (parent instanceof XSDSchema) { - elementName = getUniqueName(baseName, getUsedElementNames((XSDSchema) parent)); - } - else if (parent instanceof XSDModelGroup) { - List existingNames = new ArrayList(); - XSDModelGroup modelGroup = (XSDModelGroup) parent; - Iterator modelGroupIt = modelGroup.getContents().iterator(); - while (modelGroupIt.hasNext()) { - Object item = modelGroupIt.next(); - if (item instanceof XSDParticle) { - XSDParticle existingParticle = (XSDParticle) item; - if (existingParticle.getContent() instanceof XSDElementDeclaration) { - existingNames.add(((XSDElementDeclaration) existingParticle.getContent()).getName()); - } - } - } - - elementName = getUniqueName(baseName, existingNames); - } - - return elementName; - } - - public static String getXSDComplexTypeName(String baseName, XSDSchema schema) { - String typeName = ""; - List existingNames = new ArrayList(); - - Iterator it = schema.getTypeDefinitions().iterator(); - while (it.hasNext()) { - Object item = it.next(); - if (item instanceof XSDComplexTypeDefinition) { - existingNames.add(((XSDComplexTypeDefinition) item).getName()); - } - } - - typeName = getUniqueName(baseName, existingNames); - return typeName; - } - - private static List getUsedElementNames(XSDSchema xsdSchema) { - List usedNames = new ArrayList(); - Iterator schemaIt = xsdSchema.getContents().iterator(); - while (schemaIt.hasNext()) { - Object item = schemaIt.next(); - if (item instanceof XSDElementDeclaration) { - usedNames.add(((XSDElementDeclaration) item).getName()); - } - } - - return usedNames; - } - - private static String getUniqueName(String baseName, List existingNames) { - int count = 1; - - if (!existingNames.contains(baseName)) { - return baseName; - } - - Iterator namesIt = existingNames.iterator(); - boolean foundMatch = true; - while (foundMatch) { - foundMatch = false; - while (namesIt.hasNext()) { - String name = (String) namesIt.next(); - if (name.equals(baseName + String.valueOf(count))) { - count++; - foundMatch = true; - break; - } - } - } - - return baseName + String.valueOf(count); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/XSDComponentHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/XSDComponentHelper.java deleted file mode 100644 index 7d9c87c3c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/parameters/XSDComponentHelper.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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 - */ -package org.eclipse.wst.wsdl.ui.internal.parameters; - -import java.util.Iterator; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDElementDeclarationCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDSchemaCommand; -import org.eclipse.wst.xsd.ui.internal.commands.AddElementDeclarationCommand; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -/** - * Input createInput(Operation operation, String style) --- create default message/part/etc. - * Object createInputParameter(Operation operation, Input input, Style style) -- - * - * Command getCreateInputParameterCommand(Operation operation, Input input, Style style) - * - * Message/part/Element - * Message/part/Element/sequence/Element - * (x) Message/part - */ -public class XSDComponentHelper { - /* - * Create an XSDElement with type anonymous. Set the given part to reference the newly created - * XSDElement. - */ - public static XSDElementDeclaration createAnonymousXSDElementDefinition(String baseName, Part part) { - XSDElementDeclaration anonElement = createXSDElementDeclarationCommand(part.getEnclosingDefinition(), baseName, part); - XSDComplexTypeDefinition newAnon = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - XSDParticle newXSDParticle = XSDFactory.eINSTANCE.createXSDParticle(); - XSDModelGroup newXSDModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); - newXSDModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - - anonElement.setAnonymousTypeDefinition(newAnon); - newXSDParticle.setContent(newXSDModelGroup); - newAnon.setContent(newXSDParticle); - - return anonElement; - } - - public static XSDElementDeclaration createXSDElementDeclarationCommand(Definition definition, String baseName, Object context) { - XSDElementDeclaration xsdElement = null; - - if (context instanceof Part) { - AddXSDElementDeclarationCommand command = new AddXSDElementDeclarationCommand(definition, ""); - - // Find a unique name - XSDSchema xsdSchema = command.getSchema(); - String name = WNameHelperUtil.getXSDElementName(baseName, xsdSchema); - command.run(name); - // The 'workaround' below is causing me to hang..... The latest WTP is needed. -// xsdElement = xsdSchema.resolveElementDeclaration(name); - xsdElement = command.getXSDElement(); - } - else if (context instanceof XSDModelGroup) { - XSDModelGroup modelGroup = (XSDModelGroup) context; - XSDParticle newParticle = XSDFactory.eINSTANCE.createXSDParticle(); - String name = WNameHelperUtil.getXSDElementName(baseName, modelGroup); - - AddElementDeclarationCommand command = new AddElementDeclarationCommand(modelGroup, name); - command.run(); - xsdElement = (XSDElementDeclaration) command.getModelObject(); - xsdElement.setTypeDefinition(getXSDStringType(modelGroup)); - - newParticle.setContent(xsdElement); - modelGroup.getContents().add(newParticle); - } - else { - AddElementDeclarationCommand command = new AddElementDeclarationCommand(null, baseName); - command.run(); - xsdElement = (XSDElementDeclaration) command.getModelObject(); - } - - return xsdElement; - } - - public static void addXSDElementToModelGroup(XSDElementDeclaration parent, XSDElementDeclaration child) { - if (parent.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) { - XSDComplexTypeDefinition anonType = (XSDComplexTypeDefinition) parent.getAnonymousTypeDefinition(); - if (anonType.getContent() instanceof XSDParticle) { - XSDParticle particle = (XSDParticle) anonType.getContent(); - if (particle.getContent() instanceof XSDModelGroup) { - // Create XSDParticle - XSDModelGroup modelGroup = (XSDModelGroup) particle.getContent(); - addXSDElementToModelGroup(modelGroup, child); - } - else { - // Create XSDModelGroup -- XSDParticle - addXSDElementToModelGroup(particle, child); - } - } - else { - // Create XSDParticle --> XSDModelGroup --> XSDParticle - XSDParticle newParticle = XSDFactory.eINSTANCE.createXSDParticle(); - anonType.setContent(newParticle); - addXSDElementToModelGroup(newParticle, child); - } - } - else { - // Create Anonymous Type --> XSDParticle --> XSDModelGroup --> XSDParticle - XSDComplexTypeDefinition newAnonType = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - parent.setAnonymousTypeDefinition(newAnonType); - - XSDParticle newParticle = XSDFactory.eINSTANCE.createXSDParticle(); - newAnonType.setContent(newParticle); - addXSDElementToModelGroup(newParticle, child); - } - } - - public static void addXSDElementToModelGroup(XSDParticle particle, XSDElementDeclaration child) { - XSDModelGroup newXSDModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); - newXSDModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(newXSDModelGroup); - addXSDElementToModelGroup(newXSDModelGroup, child); - } - - public static void addXSDElementToModelGroup(XSDModelGroup modelGroup, XSDElementDeclaration child) { - // Create XSDParticle - XSDParticle newParticle = XSDFactory.eINSTANCE.createXSDParticle(); - newParticle.setContent(child); - modelGroup.getContents().add(newParticle); - } - - /* - * Return it's XSDModelGroup. If one does not exist, create one - */ - public static XSDModelGroup getXSDModelGroup(XSDElementDeclaration xsdElement, Definition definition) { - XSDModelGroup modelGroup = null; - XSDComplexTypeDefinition anonType = null; - - if (xsdElement.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) { - anonType = (XSDComplexTypeDefinition) xsdElement.getAnonymousTypeDefinition(); - } - else { - // Create Anonymous Type - anonType = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - anonType.setName("NewComplexTypeName"); - getXSDSchema(definition).getContents().add(anonType); - xsdElement.setAnonymousTypeDefinition(anonType); - } - - if (anonType != null) { - modelGroup = getXSDModelGroup(anonType); - } - - return modelGroup; - } - - /* - * Return it's XSDModelGroup. If one does not exist, create one - */ - public static XSDModelGroup getXSDModelGroup(XSDComplexTypeDefinition xsdComplexType) { - XSDModelGroup modelGroup = null; - XSDParticle particle = null; - // Check for XSDParticle - if (xsdComplexType.getContent() instanceof XSDParticle) { - particle = (XSDParticle) xsdComplexType.getContent(); - } - else { - particle = XSDFactory.eINSTANCE.createXSDParticle(); - modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); - modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(modelGroup); - xsdComplexType.setContent(particle); - } - - // Check for XSDModelGroup - if (particle.getContent() instanceof XSDModelGroup) { - modelGroup = (XSDModelGroup) particle.getContent(); - } - else { - modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); - modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(modelGroup); - } - - return modelGroup; - } - - /* - * - */ - public static XSDComplexTypeDefinition createXSDComplexTypeDefiniion(String complexTypeName, Part part) { - XSDComplexTypeDefinition newComplexType = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - XSDParticle newXSDParticle = XSDFactory.eINSTANCE.createXSDParticle(); - XSDModelGroup newXSDModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); - newXSDModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - - newComplexType.setName(complexTypeName); - newComplexType.setContent(newXSDParticle); - newXSDParticle.setContent(newXSDModelGroup); - getXSDSchema(part.getEnclosingDefinition()).getContents().add(newComplexType); - - return newComplexType; - } - - public static void addXSDElementToModelGroup(XSDComplexTypeDefinition parent, XSDElementDeclaration child) { - if (parent.getContent() instanceof XSDParticle) { - XSDParticle particle = (XSDParticle) parent.getContent(); - if (particle.getContent() instanceof XSDModelGroup) { - // Create XSDParticle - XSDModelGroup modelGroup = (XSDModelGroup) particle.getContent(); - addXSDElementToModelGroup(modelGroup, child); - } - else { - // Create XSDModelGroup -- XSDParticle - addXSDElementToModelGroup(particle, child); - } - } - else { - // Create XSDParticle --> XSDModelGroup --> XSDParticle - XSDParticle newParticle = XSDFactory.eINSTANCE.createXSDParticle(); - parent.setContent(newParticle); - addXSDElementToModelGroup(newParticle, child); - } - } - - /* - * Return the inline XSDSchema associated with this WSDL. - * Look for the inline XSDSchema with the same namespace as the WSDL. - * If this inline XSDSchema does not exists, create it. - */ - public static XSDSchema getXSDSchema(Definition definition) { - XSDSchema schema = null; - String wsdlTargetNamespace = definition.getTargetNamespace(); - - Types types = (Types) definition.getTypes(); - if (types != null) { - - Iterator eeIt = types.getExtensibilityElements().iterator(); - while (eeIt.hasNext()) { - Object eeElement = eeIt.next(); - if (eeElement instanceof XSDSchemaExtensibilityElement) { - XSDSchemaExtensibilityElement ee = (XSDSchemaExtensibilityElement) eeElement; - if (ee.getSchema().getTargetNamespace().equals(wsdlTargetNamespace)) { - schema = ee.getSchema(); - break; - } - } - } - } - - if (schema == null) { - // We need to create the schema - AddXSDSchemaCommand command = new AddXSDSchemaCommand(definition); - command.run(); - XSDSchemaExtensibilityElement eeElement = (XSDSchemaExtensibilityElement) command.getWSDLElement(); - schema = eeElement.getSchema(); - } - - return schema; - } - - private static XSDSimpleTypeDefinition getXSDStringType(XSDComponent component) { - XSDSchema schema = component.getSchema(); - return schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSection.java deleted file mode 100644 index 2988ee289..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSection.java +++ /dev/null @@ -1,353 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.xml.core.internal.document.DocumentImpl; -import org.w3c.dom.Element; - -public class AbstractSection implements ISection, IPropertyChangeListener, Listener, SelectionListener -{ - private TabbedPropertySheetWidgetFactory factory; - private WSDLElement element; - protected boolean isReadOnly = false; - protected Composite composite; - protected int rightMarginSpace; - protected int tableMinimumWidth = 50; - - public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) - { - createControls(parent, tabbedPropertySheetPage.getWidgetFactory()); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory aFactory) - { - this.factory = aFactory; - GC gc = new GC(parent); - Point extent = gc.textExtent(" ... "); //$NON-NLS-1$ - rightMarginSpace = extent.x; - gc.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) - { - Assert.isTrue(selection instanceof IStructuredSelection); - Object input = ((IStructuredSelection)selection).getFirstElement(); - - if (input instanceof WSDLElement) - { - this.element = (WSDLElement)input; - ModelAdapter adapter = WSDLGraphModelAdapterFactory.getWSDLGraphModelAdapterFactory().getAdapter(input); - if (adapter != null) - { - isReadOnly = Boolean.TRUE.equals(adapter.getProperty(input, "isReadOnly")); //$NON-NLS-1$ - } - } - else if (input instanceof WSDLGroupObject) - { - this.element = ((WSDLGroupObject)input).getDefinition(); - } - refresh(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#aboutToBeShown() - */ - public void aboutToBeShown() - { - refresh(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#aboutToBeHidden() - */ - public void aboutToBeHidden() - { - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#dispose() - */ - public void dispose() - { - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#getMinimumHeight() - */ - public int getMinimumHeight() - { - return SWT.DEFAULT; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() - { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#refresh() - */ - public void refresh() - { - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - } - - public WSDLElement getElement() - { - return element; - } - - /** - * Get the widget factory. - * @return the widget factory. - */ - public TabbedPropertySheetWidgetFactory getWidgetFactory() { - return factory; - } - - public void propertyChange(PropertyChangeEvent event) - { - refresh(); - } - - - public void doWidgetDefaultSelected(SelectionEvent e) - {} - - public void doWidgetSelected(SelectionEvent e) - {} - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) - { - if (isListenerEnabled() && - getElement() != null && - !isInDoHandle) - { - isInDoHandle = true; - doWidgetDefaultSelected(e); - isInDoHandle = false; - } - - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) - { - if (isListenerEnabled() && - getElement() != null && - !isInDoHandle) - { - isInDoHandle = true; - doWidgetSelected(e); - isInDoHandle = false; - } - - } - - boolean listenerEnabled = true; - /** - * Get the value of listenerEnabled. - * @return value of listenerEnabled. - */ - public boolean isListenerEnabled() - { - return listenerEnabled; - } - - /** - * Set the value of listenerEnabled. - * @param v Value to assign to listenerEnabled. - */ - public void setListenerEnabled(boolean v) - { - this.listenerEnabled = v; - } - - public void handleEvent(Event event) - { - if (isListenerEnabled() && !isInDoHandle) - { - isInDoHandle = true; - startDelayedEvent(event); - isInDoHandle = false; - } // end of if () - } - - public void doHandleEvent(Event event) - { - - } - - protected DelayedEvent delayedTask; - - protected void startDelayedEvent(Event e) - { - if (delayedTask == null || - delayedTask.getEvent() == null) - { - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500,delayedTask); - } - else - { - Event delayedEvent = delayedTask.getEvent(); - - if (e.widget == delayedEvent.widget && - e.type == delayedEvent.type) - { - // same event, just different data, delay new event - delayedTask.setEvent(null); - } - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500,delayedTask); - } - } - - class DelayedEvent implements Runnable - { - protected Event event; - - /* - * @see Runnable#run() - */ - public void run() - { - if (event != null) - { - isInDoHandle = true; - doHandleEvent(event); - isInDoHandle = false; - event = null; - } - } - - /** - * Gets the event. - * @return Returns a Event - */ - public Event getEvent() - { - return event; - } - - /** - * Sets the event. - * @param event The event to set - */ - public void setEvent(Event event) - { - this.event = event; - } - - } - - boolean isInDoHandle; - /** - * Get the value of isInDoHandle. - * @return value of isInDoHandle. - */ - public boolean isInDoHandle() - { - return isInDoHandle; - } - - - static protected IEditorPart getActiveEditor() - { - IWorkbench workbench = WSDLEditorPlugin.getInstance().getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - - return editorPart; - } - - static protected IStatusLineManager getStatusLineManager(IEditorPart editorPart) - { - IStatusLineManager result = null; - try - { - EditorActionBarContributor contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor(); - result = contributor.getActionBars().getStatusLineManager(); - } - catch (Exception e) - { - } - return result; - } - - public DocumentImpl getDocument(Element element) - { - return (DocumentImpl) element.getOwnerDocument(); - } - - public void beginRecording(String description, Element element) - { - getDocument(element).getModel().beginRecording(this, description); - } - - public void endRecording(Element element) - { - DocumentImpl doc = (DocumentImpl) getDocument(element); - - doc.getModel().endRecording(this); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSectionDescriptor.java deleted file mode 100644 index f65456d8b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/AbstractSectionDescriptor.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; - -public class AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public AbstractSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return ""; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter() - */ - public ITypeMapper getFilter() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(WSDLElement.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof WSDLElement || object instanceof WSDLGroupObject) - { - return true; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() - { - return ""; - } - - public int getEnablesFor() - { - return ENABLES_FOR_ANY; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSection.java deleted file mode 100644 index 93fe1e61d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSection.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.ui.internal.actions.AddElementAction; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class DocumentationSection extends AbstractSection { - - Text docText; - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - composite = getWidgetFactory().createFlatFormComposite(parent); - - docText = getWidgetFactory().createText(composite, "", SWT.MULTI | SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL); //$NON-NLS-1$ - docText.addListener(SWT.Modify, this); - FormData data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.top = new FormAttachment(0, 0); - data.bottom = new FormAttachment(100, 0); - docText.setLayoutData(data); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - if (docText.isFocusControl()) - { - return; - } - setListenerEnabled(false); - docText.setText(""); - if (getElement() != null) - { - Element docNode = getElement().getDocumentationElement(); - if (docNode != null) - { - Node textNode = docNode.getFirstChild(); - if (textNode != null) - { - String docValue = textNode.getNodeValue(); - if (docValue != null) - { - docText.setText(docValue); - } - } - } - } - setListenerEnabled(true); - } - - public void doHandleEvent(Event event) - { - if (event.widget == docText) - { - String value = docText.getText(); - if (getElement() != null) - { - Element docNode = getElement().getDocumentationElement(); - if (docNode != null) - { - Node textNode = docNode.getFirstChild(); - if (textNode != null) - { - textNode.setNodeValue(value); - } - else - { - if (value.length() > 0) - { - Document document = docNode.getOwnerDocument(); - org.w3c.dom.Text newTextNode = document.createTextNode(value); - docNode.appendChild(newTextNode); - } - } - } - else - { - Element element = getElement().getElement(); - AddElementAction action = new AddElementAction(element, element.getPrefix(), "documentation", element.getFirstChild()); //$NON-NLS-1$ - action.run(); - Element newDocumentation = action.getNewElement(); - - Document document = newDocumentation.getOwnerDocument(); - org.w3c.dom.Text newTextNode = document.createTextNode(value); - newDocumentation.appendChild(newTextNode); - getElement().setDocumentationElement(newDocumentation); - } - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSectionDescriptor.java deleted file mode 100644 index 7213861e7..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/DocumentationSectionDescriptor.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.WSDLElement; - - -public class DocumentationSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public DocumentationSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.documentation"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - // TODO Auto-generated method stub - return new DocumentationSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - // TODO Auto-generated method stub - return "org.eclipse.wst.xmlwebservices.documentation"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof WSDLElement) - { - return true; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() - { - return "org.eclipse.wst.xmlwebservices.general"; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensibilityElementSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensibilityElementSectionDescriptor.java deleted file mode 100644 index 2022a8a37..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensibilityElementSectionDescriptor.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.ExtensibilityElement; - -public class ExtensibilityElementSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public ExtensibilityElementSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.extensibilityelement"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - // TODO Auto-generated method stub - return new ExtensiblityElementSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - // TODO Auto-generated method stub - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof ExtensibilityElement) - { - return true; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() - { - return ""; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensiblityElementSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensiblityElementSection.java deleted file mode 100644 index 62646e2f3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ExtensiblityElementSection.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.viewers.ExtensibilityElementViewer; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.AttributesTable; - -public class ExtensiblityElementSection extends AbstractSection implements ModelAdapterListener -{ - ExtensibilityElementViewer viewer; - protected AttributesTable attributesTable; - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - - composite = getWidgetFactory().createFlatFormComposite(parent); - -// viewer = new ExtensibilityElementViewer(composite, getActiveEditor(), true); - attributesTable = new AttributesTable(getActiveEditor(), composite); - FormData data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.top = new FormAttachment(0, 0); - data.bottom = new FormAttachment(100, 0); - attributesTable.getControl().setLayoutData(data); -// viewer.getControl().setLayoutData(data); - } - - public void propertyChanged(Object object, String property) - { - if (isListenerEnabled()) - { - setListenerEnabled(false); - refresh(); - setListenerEnabled(true); - } - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - attributesTable.setInput(getElement().getElement()); - - Runnable runnable = new Runnable() - { - public void run() - { - if (!attributesTable.getControl().isDisposed()) - { - attributesTable.refresh(); - } - } - }; - Display.getCurrent().asyncExec(runnable); - - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/IPropertyDescriptorProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/IPropertyDescriptorProvider.java deleted file mode 100644 index c5f1e93b6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/IPropertyDescriptorProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.w3c.dom.Element; - -public interface IPropertyDescriptorProvider -{ - //public void init(IEditorPart editor); - public IPropertyDescriptor getPropertyDescriptor(IEditorPart editor, Element ownerElement, String attributeNamespace, String attributeName); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSection.java deleted file mode 100644 index 75c3d3b02..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSection.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.internal.impl.ImportImpl; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -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.XMLQuickScan; -import org.w3c.dom.Element; - -public class ImportSection extends AbstractSection -{ - protected Text namespaceText, prefixText, locationText; - private String oldPrefixValue; - Button button; - IEditorPart editorPart; - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - Composite composite = getWidgetFactory().createFlatFormComposite(parent); - FormData data; - - namespaceText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - namespaceText.setEditable(false); -// namespaceText.addListener(SWT.Modify, this); - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(0, 0); - namespaceText.setLayoutData(data); - - CLabel namespaceLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAMESPACE")); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(namespaceText, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(namespaceText, 0, SWT.CENTER); - namespaceLabel.setLayoutData(data); - - prefixText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ -// prefixText.setEditable(false); - prefixText.addListener(SWT.Modify, this); - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(namespaceText, +ITabbedPropertyConstants.VSPACE); - prefixText.setLayoutData(data); - - CLabel prefixLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_PREFIX")); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(prefixText, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(prefixText, 0, SWT.CENTER); - prefixLabel.setLayoutData(data); - - locationText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - locationText.setEditable(false); -// locationText.addListener(SWT.Modify, this); - - CLabel locationLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_LOCATION")); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(locationText, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(locationText, 0, SWT.CENTER); - locationLabel.setLayoutData(data); - - button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$ - button.setImage(WSDLEditorPlugin.getInstance().getImage("icons/browsebutton.gif")); //$NON-NLS-1$ - - button.addSelectionListener(this); - data = new FormData(); - data.left = new FormAttachment(100, -rightMarginSpace + 2); - data.right = new FormAttachment(100,0); - data.top = new FormAttachment(locationText, 0, SWT.CENTER); - button.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(button, 0); - data.top = new FormAttachment(prefixText, +ITabbedPropertyConstants.VSPACE); - locationText.setLayoutData(data); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - Object obj = getElement(); - boolean refreshPrefixText = true; - boolean refreshLocationText = true; - boolean refreshNamespaceText = true; - if (prefixText.isFocusControl()) - { - refreshPrefixText = false; - } - if (locationText.isFocusControl()) - { - refreshLocationText = false; - } - if (namespaceText.isFocusControl()) - { - refreshNamespaceText = false; - } - - if (refreshPrefixText) - { - prefixText.setText(""); //$NON-NLS-1$ - } - if (refreshLocationText) - { - locationText.setText(""); //$NON-NLS-1$ - } - if (refreshNamespaceText) - { - namespaceText.setText(""); //$NON-NLS-1$ - } - if (obj instanceof Import) - { - Element element = ((Import)obj).getElement(); - if (refreshLocationText) - { - String locationValue = element.getAttribute("location"); //$NON-NLS-1$ - locationText.setText(locationValue != null ? locationValue : ""); //$NON-NLS-1$ - } - - String namespaceValue = element.getAttribute("namespace"); //$NON-NLS-1$ - if (refreshNamespaceText) - { - namespaceText.setText(namespaceValue != null ? namespaceValue : ""); //$NON-NLS-1$ - } - - if (refreshPrefixText) - { - String prefix = ((Import)obj).getEnclosingDefinition().getPrefix(namespaceValue); - prefixText.setText(prefix != null ? prefix : ""); //$NON-NLS-1$ - } - } - oldPrefixValue = prefixText.getText(); - setListenerEnabled(true); - } - - public void doHandleEvent(Event event) { - if (event.widget == prefixText && locationText.getText().length() > 0 && namespaceText.getText().length() > 0) { - Object input = getElement(); - Import importObj = (Import)input; -// org.w3c.dom.Element importElement = WSDLEditorUtil.getInstance().getElementForObject(importObj); - Map namespacesMap = importObj.getEnclosingDefinition().getNamespaces(); - - if (namespacesMap.containsKey(prefixText.getText())) { - // We should add error messages......... - // setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_PREFIX_EXISTS")); - } - else { - Element definitionElement = importObj.getEnclosingDefinition().getElement(); - definitionElement.removeAttribute("xmlns:"+oldPrefixValue); - definitionElement.setAttribute("xmlns:" + prefixText.getText(), namespaceText.getText()); - -// clearErrorMessage(); - oldPrefixValue = prefixText.getText(); - } - } - } - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == button) - { - Object input = getElement(); - - WSDLEditor editor = (WSDLEditor)editorPart; - IFile currentWSDLFile = ((IFileEditorInput)editor.getEditorInput()).getFile(); - - SelectSingleFileDialog dialog = new SelectSingleFileDialog(WSDLEditorPlugin.getShell(), null, true); - String [] filters = { "xsd", "wsdl" }; //$NON-NLS-1$ - IFile [] excludedFiles = { currentWSDLFile }; - - dialog.addFilterExtensions(filters, excludedFiles); - dialog.create(); - dialog.getShell().setText(WSDLEditorPlugin.getWSDLString("_UI_TITLE_SELECT")); //$NON-NLS-1$ - dialog.setTitle(WSDLEditorPlugin.getWSDLString("_UI_TITLE_SELECT_FILE")); //$NON-NLS-1$ - dialog.setMessage(WSDLEditorPlugin.getWSDLString("_UI_DESCRIPTION_SELECT_WSDL_OR_XSD")); //$NON-NLS-1$ - int rc = dialog.open(); - if (rc == IDialogConstants.OK_ID) - { - IFile selectedFile = dialog.getFile(); - - //if (selectedFile.getLocation().toOSString().equals(currentWSDLFile.getLocation().toOSString())) - //{ - // System.out.println("SAME FILE:" + currentWSDLFile.getLocation()); - //} - - String location = ComponentReferenceUtil.computeRelativeURI(selectedFile, currentWSDLFile, true); - - Import importObj = (Import)input; - org.w3c.dom.Element importElement = WSDLEditorUtil.getInstance().getElementForObject(importObj); - Definition definition = importObj.getEnclosingDefinition(); - org.w3c.dom.Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - - String importTargetNamespace = ""; //$NON-NLS-1$ - String prefix = prefixText.getText(); - String uniquePrefix = ""; //$NON-NLS-1$ - - URI uri = URI.createPlatformResourceURI(selectedFile.getFullPath().toString()); - - // note that the getTargetNamespaceURIForSchema works for both schema and wsdl files - // I should change the name of this convenience method - importTargetNamespace = XMLQuickScan.getTargetNamespaceURIForSchema(uri.toString()); - - if (prefix.trim().equals("")) //$NON-NLS-1$ - { - uniquePrefix = getUniquePrefix(definition, uri.fileExtension()); - } - else - { - uniquePrefix = prefix; - } - - - if (importTargetNamespace == null || - (importTargetNamespace != null && importTargetNamespace.trim().length() == 0)) - { - return; // what to do with no namespace docs? - } - - importObj.setLocationURI(location); - importObj.setNamespaceURI(importTargetNamespace); - ((ImportImpl) importObj).importDefinitionOrSchema(); - - definitionElement.setAttribute("xmlns:" + uniquePrefix, importTargetNamespace); //$NON-NLS-1$ - - namespaceText.setText(importTargetNamespace); - locationText.setText(location); - prefixText.setText(uniquePrefix); - } - - refresh(); - } - } - - - private String getUniquePrefix(Definition definition, String initPrefix) - { - String uniquePrefix; - Map map = definition.getNamespaces(); - - if (definition.getNamespace(initPrefix) == null) - { - uniquePrefix = initPrefix; - } - else // if used, then try to create a unique one - { - String tempPrefix = initPrefix; - int i = 1; - while(map.containsKey(tempPrefix + i)) - { - i++; - } - uniquePrefix = tempPrefix + i; - } - return uniquePrefix; - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSectionDescriptor.java deleted file mode 100644 index 012236932..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ImportSectionDescriptor.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.Import; - -public class ImportSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - ImportSection importSection; - /** - * - */ - public ImportSectionDescriptor() - { - super(); - importSection = new ImportSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.import"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(Import.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return importSection; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - importSection.setEditorPart(part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor()); - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof Import) - { - return true; - } - } - return false; - } - - public String getAfterSection() - { - return "org.eclipse.wst.wsdl.ui.internal.section.name"; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSection.java deleted file mode 100644 index 8a2f11c38..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSection.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import javax.xml.namespace.QName; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; - - -public class NameSection extends AbstractSection -{ - - Text nameText; - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent,TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - composite = getWidgetFactory().createFlatFormComposite(parent); - FormData data; - - - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(0, 0); - nameText.setLayoutData(data); - - CLabel nameLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAME") + ":"); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(nameText, 0, SWT.CENTER); - nameLabel.setLayoutData(data); - - nameText.addListener(SWT.Modify, this); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - if (nameText.isFocusControl()) - { - return; - } - setListenerEnabled(false); - nameText.setText(""); //$NON-NLS-1$ - if (getElement() != null) - { - if (getElement().getElement()!= null) - { - String name = getElement().getElement().getAttribute("name"); //$NON-NLS-1$ - if (name==null) name=""; - nameText.setText(name); - } - } - setListenerEnabled(true); - } - - public boolean shouldUseExtraSpace() - { - return false; - } - - public void doHandleEvent(Event event) - { - if (event.widget == nameText && !nameText.isDisposed()) { - String newValue = nameText.getText(); - Object wsdlElement = getElement(); - - if (wsdlElement instanceof Definition) { - Definition definition = (Definition) wsdlElement; - String uri = ""; - if (definition.getQName() != null) { - uri = definition.getQName().getNamespaceURI(); - } - definition.setQName(new QName(uri, newValue)); - } - else if (wsdlElement instanceof Service) { - Service service = (Service) wsdlElement; - String uri = service.getQName().getNamespaceURI(); - service.setQName(new QName(uri, newValue)); - } - else if (wsdlElement instanceof Port) { - new SmartRenameAction(wsdlElement, newValue).run(); -// ((Port) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof Binding) { - Binding binding = (Binding) wsdlElement; - String uri = binding.getQName().getNamespaceURI(); - binding.setQName(new QName(uri, newValue)); - } - else if (wsdlElement instanceof BindingOperation) { - ((BindingOperation) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof BindingInput) { - if(((BindingInput) wsdlElement).getName() == null && newValue.equals("")) //$NON-NLS-1$ - return; - - ((BindingInput) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof BindingOutput) { - if (((BindingOutput) wsdlElement).getName() == null && newValue.equals("")) //$NON-NLS-1$ - return; - - ((BindingOutput) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof BindingFault) { - ((BindingFault) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof PortType) { - PortType portType = (PortType) wsdlElement; - String uri = portType.getQName().getNamespaceURI(); - portType.setQName(new QName(uri, newValue)); - } - else if (wsdlElement instanceof Operation) { - new SmartRenameAction(wsdlElement, newValue).run(); -// ((Operation) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof MessageReference) { - if (((MessageReference) wsdlElement).getName() == null && newValue.equals("")) //$NON-NLS-1$ - return; - - new SmartRenameAction(wsdlElement, newValue).run(); -// ((MessageReference) wsdlElement).setName(newValue); - } - else if (wsdlElement instanceof Message) { -/* - Message message = (Message) wsdlElement; - String uri = message.getQName().getNamespaceURI(); - message.setQName(new QName(uri, newValue)); - */ - new SmartRenameAction(wsdlElement, newValue).run(); - } - else if (wsdlElement instanceof Part) { -// ((Part) wsdlElement).setName(newValue); - new SmartRenameAction(wsdlElement, newValue).run(); - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSectionDescriptor.java deleted file mode 100644 index b64135018..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NameSectionDescriptor.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibilityElement; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.WSDLElement; - - -public class NameSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public NameSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.name"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(WSDLElement.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return new NameSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof WSDLElement && - !(object instanceof ExtensibilityElement) && - !(object instanceof Import)) - { - if (object instanceof WSDLElement) { - Definition definition = ((WSDLElement) object).getEnclosingDefinition(); - if (definition.getElement() != null && !(object instanceof Definition)) { - return true; - } - - return false; - } - /* - else if (object instanceof WSDLGroupObject) { - Definition definition = ((WSDLGroupObject) object).getDefinition(); - if (definition.getElement() != null) { - return true; - } - - return false; - } - */ - } - } - return false; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSection.java deleted file mode 100644 index 93cc7715d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSection.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.EditNamespacesAction; -import org.eclipse.wst.xml.core.internal.document.AttrImpl; -import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesTargetFieldDialog; -import org.eclipse.wst.xml.ui.internal.nsedit.CommonNamespaceInfoTable; -import org.w3c.dom.Element; - -public class NamespaceSection extends AbstractSection -{ - protected String targetNamespace; - protected List namespaceInfoList; - protected CommonEditNamespacesTargetFieldDialog editWSDLNamespacesControl; - protected Button button; - - Text nameText; - Text prefixText; - Text targetNamespaceText; - protected CommonNamespaceInfoTable tableViewer; - private boolean handlingEvent; - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - composite = getWidgetFactory().createFlatFormComposite(parent); - - String nameString = WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAME") + ":"; - String prefixString = WSDLEditorPlugin.getWSDLString("_UI_LABEL_PREFIX") + ":"; - String namespaceString = WSDLEditorPlugin.getWSDLString("_UI_LABEL_TARGET_NAMESPACE"); - GC gc = new GC(parent); - int xoffset = Math.max(115, gc.textExtent(nameString).x + 20); // adds 20 due to borders - xoffset = Math.max(xoffset, gc.textExtent(prefixString).x + 20); // adds 20 due to borders - xoffset = Math.max(xoffset, gc.textExtent(namespaceString).x + 20); // adds 20 due to borders - gc.dispose(); - - // name - CLabel nameLabel = getWidgetFactory().createCLabel(composite, nameString); //$NON-NLS-1$ - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - - // prefix - CLabel prefixLabel = getWidgetFactory().createCLabel(composite, prefixString); //$NON-NLS-1$ - prefixText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - - // targetnamespace - CLabel targetNamespaceLabel = getWidgetFactory().createCLabel(composite, namespaceString); //$NON-NLS-1$ - targetNamespaceText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - - // Advanced button - button = getWidgetFactory().createButton(composite, WSDLEditorPlugin.getWSDLString("_UI_SECTION_ADVANCED_ATTRIBUTES") + "...", SWT.PUSH); //$NON-NLS-1$ - - - ///////////////////// Labels - // name layout - FormData dataNameLabel = new FormData(); - dataNameLabel.top = new FormAttachment(nameText, 0, SWT.CENTER); - nameLabel.setLayoutData(dataNameLabel); - - // prefix layout - FormData dataPrefixLabel = new FormData(); - dataPrefixLabel.left = new FormAttachment(0, 0); - dataPrefixLabel.top = new FormAttachment(prefixText, 0, SWT.CENTER); - prefixLabel.setLayoutData(dataPrefixLabel); - - // targetNamespaceLabel layout - FormData datatnsLabel = new FormData(); - datatnsLabel.left = new FormAttachment(0, 0); - datatnsLabel.right = new FormAttachment(targetNamespaceText, 0); - datatnsLabel.top = new FormAttachment(targetNamespaceText, 0, SWT.CENTER); - targetNamespaceLabel.setLayoutData(datatnsLabel); - - - ///////////////////// Text Fields - // name text field - FormData dataNameText = new FormData(); - dataNameText.left = new FormAttachment(0, xoffset); - dataNameText.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - dataNameText.top = new FormAttachment(0, 0); - nameText.setLayoutData(dataNameText); - nameText.addListener(SWT.Modify, this); - - // prefix text field - FormData dataPrefixText = new FormData(); - dataPrefixText.left = new FormAttachment(0, xoffset); - dataPrefixText.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - dataPrefixText.top = new FormAttachment(nameText, +ITabbedPropertyConstants.VSPACE); - prefixText.setLayoutData(dataPrefixText); - prefixText.addListener(SWT.Modify, this); - - // targetnamespace text field - FormData data = new FormData(); - data.left = new FormAttachment(0, xoffset); - data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(prefixText, +ITabbedPropertyConstants.VSPACE); - targetNamespaceText.setLayoutData(data); - targetNamespaceText.addListener(SWT.Modify, this); - - // Advanced button layout - FormData dataButton = new FormData(); -// dataButton.left = new FormAttachment(100, -rightMarginSpace + 2); - dataButton.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - dataButton.top = new FormAttachment(targetNamespaceText, +ITabbedPropertyConstants.VSPACE); -// dataButton.top = new FormAttachment(targetNamespaceText, 0, SWT.CENTER); - button.setLayoutData(dataButton); - button.addSelectionListener(this); - } - - public void doHandleEvent(Event event) - { - handlingEvent = true; - if (event.widget == nameText) { - Object obj = getElement(); - if (obj instanceof Definition) { - Definition definition = (Definition) obj; - String uri = ""; - if (definition.getQName() != null) { - uri = definition.getQName().getNamespaceURI(); - } - definition.setQName(new QName(uri, nameText.getText())); - } - } - else if (event.widget == prefixText) { - Object obj = getElement(); - if (obj instanceof Definition) { - Definition definition = (Definition) obj; - Element element = definition.getElement(); - - // Remove the old prefix - String oldPrefix = definition.getPrefix(definition.getTargetNamespace()); - element.removeAttribute("xmlns:"+oldPrefix); - - // Set the new prefix - element.setAttribute("xmlns:" + prefixText.getText(), definition.getTargetNamespace()); - } - } - else if (event.widget == targetNamespaceText) - { - Object obj = getElement(); - if (obj instanceof Definition) - { - Definition definition = (Definition)obj; - String newValue = targetNamespaceText.getText(); - String prefix = definition.getPrefix(definition.getTargetNamespace()); - definition.setTargetNamespace(newValue); - definition.getElement().setAttribute("xmlns:" + prefix, newValue); - } - } - handlingEvent = false; - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - - if (targetNamespaceText.isFocusControl() || handlingEvent) - { - return; - } - setListenerEnabled(false); - Object obj = getElement(); - if (obj instanceof Definition) - { - Definition definition = (Definition)obj; - String targetNS = definition.getTargetNamespace(); - - // set targetnamespace field and prefix field - if (targetNS != null) - { - targetNamespaceText.setText(targetNS); - - Element element = definition.getElement(); - - String newPrefix = definition.getPrefix(targetNS); - if (newPrefix == null) newPrefix = ""; - // TODO: remove this code - if (element != null) - { - for (int index = 0; index < element.getAttributes().getLength(); index++) { - AttrImpl attr = (AttrImpl) element.getAttributes().item(index); - String nodeName = attr.getNodeName(); - String nsValue = attr.getNodeValue(); - if (nsValue.equals(targetNS)) { - if (nodeName.indexOf(":") != -1) { - String xmlnsString = nodeName.substring(0, nodeName.indexOf(":")); - - if (xmlnsString.equals("xmlns")) { - newPrefix = attr.getLocalName(); - break; - } - } - } - } - } - prefixText.setText(newPrefix); - } - } - - // set name field - if (getElement() != null) - { - if (getElement().getElement()!= null) - { - String name = getElement().getElement().getAttribute("name"); //$NON-NLS-1$ - if (name==null) name=""; - nameText.setText(name); - } - } - - setListenerEnabled(true); - } - - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == button) - { - Object obj = getElement(); - if (obj instanceof Definition) - { - Definition definition = (Definition)obj; - EditNamespacesAction action = new EditNamespacesAction(definition); - action.run(); - refresh(); - } - } - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSectionDescriptor.java deleted file mode 100644 index eb0ffef34..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/NamespaceSectionDescriptor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; - -public class NamespaceSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public NamespaceSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.namespace"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(WSDLGroupObject.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return new NamespaceSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof WSDLGroupObject) - { - Definition definition = ((WSDLGroupObject) object).getDefinition(); - if (definition.getElement() != null) { - return true; - } - - return false; - } - else if (object instanceof org.eclipse.wst.wsdl.Definition) { - Definition definition = (Definition) object; - if (definition.getElement() != null) { - return true; - } - - return false; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() - { - return ""; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSection.java deleted file mode 100644 index c3936aac5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSection.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.dialogs.InvokeSetDialog; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; - - -public class PartSection extends AbstractSection -{ - CCombo componentNameCombo; - CCombo referenceKindCombo; - CLabel componentNameLabel; - Button button; - IEditorPart editorPart; - - public void handleEvent (Event event) - { - if (event.type == SWT.Modify) - { - if (event.widget == referenceKindCombo) - { - boolean isType = referenceKindCombo.getText().equals(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - ComponentReferenceUtil.setComponentReference((Part)getElement(), isType, null); - refresh(); - } - } - - } - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - composite = getWidgetFactory().createFlatFormComposite(parent); - - FormData data; - - referenceKindCombo = getWidgetFactory().createCCombo(composite); - referenceKindCombo.setBackground(composite.getBackground()); - referenceKindCombo.add(WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT")); //$NON-NLS-1$ - referenceKindCombo.add(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - - CLabel valueLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_REFERENCE_KIND")); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(referenceKindCombo, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(referenceKindCombo, 0, SWT.CENTER); - valueLabel.setLayoutData(data); - - componentNameCombo = getWidgetFactory().createCCombo(composite); - componentNameCombo.setBackground(composite.getBackground()); - componentNameCombo.addListener(SWT.Modify, this); - componentNameCombo.addSelectionListener(this); - - componentNameLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT") + ":"); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(componentNameCombo, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(componentNameCombo, 0, SWT.CENTER); - componentNameLabel.setLayoutData(data); - - button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$ - button.setImage(WSDLEditorPlugin.getInstance().getImage("icons/browsebutton.gif")); //$NON-NLS-1$ - - button.addSelectionListener(this); - data = new FormData(); - data.left = new FormAttachment(100, -rightMarginSpace + 2); - data.right = new FormAttachment(100, 0); - data.top = new FormAttachment(componentNameCombo, 0, SWT.CENTER); - button.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(0, 0); - referenceKindCombo.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(button, 0); - data.top = new FormAttachment(referenceKindCombo, +ITabbedPropertyConstants.VSPACE); - componentNameCombo.setLayoutData(data); - - referenceKindCombo.addListener(SWT.Modify, this); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - referenceKindCombo.removeListener(SWT.Modify, this); - if (((Part)getElement()).getTypeDefinition() != null) - { - referenceKindCombo.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - } - else - { - referenceKindCombo.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT")); //$NON-NLS-1$ - } - - try - { - Part part = (Part)getElement(); - boolean isType = ComponentReferenceUtil.isType(part); - String value = ComponentReferenceUtil.getPartComponentReference(part); - - // update the combo-box content - // - componentNameCombo.removeAll(); - List compList = ComponentReferenceUtil.getComponentNameList(part, isType); - if (compList != null) - { - for (Iterator iterator = compList.iterator(); iterator.hasNext();) - { - componentNameCombo.add((String)iterator.next()); - } - } - - if (isType) - { - referenceKindCombo.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - componentNameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE") + ":"); //$NON-NLS-1$ - componentNameCombo.setText(value != null ? value : ""); //$NON-NLS-1$ -// button.setReferenceKind("type"); - } - else - { - referenceKindCombo.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT")); //$NON-NLS-1$ - componentNameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT") + ":"); //$NON-NLS-1$ - componentNameCombo.setText(value != null ? value : ""); //$NON-NLS-1$ - -// button.setReferenceKind("element"); - } -// button.setInput(input); -// button.setEditor(editorPart); - - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - referenceKindCombo.addListener(SWT.Modify, this); - } - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) - { - Part part = (Part)getElement(); - boolean isType = referenceKindCombo.getText().equals(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - if (e.widget == componentNameCombo) - { - ComponentReferenceUtil.setComponentReference(part, isType, componentNameCombo.getText()); - refresh(); - } - else if (e.widget == button) - { - InvokeSetDialog dialog = new InvokeSetDialog(); - - if (getElement() instanceof Part) - { - dialog.setReferenceKind(referenceKindCombo.getText()); - } - dialog.setReferenceKind(referenceKindCombo.getText()); - dialog.run(getElement(), editorPart); - - WSDLEditor editor = (WSDLEditor) editorPart; - editor.getSelectionManager().setSelection(new StructuredSelection(getElement())); - } - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSectionDescriptor.java deleted file mode 100644 index 78f601215..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/PartSectionDescriptor.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.Part; - - -public class PartSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - PartSection partSection; - /** - * - */ - public PartSectionDescriptor() - { - super(); - partSection = new PartSection(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.part"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(Part.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return partSection; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - partSection.setEditorPart(part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor()); - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof Part) - { - return true; - } - } - return false; - } - - public String getAfterSection() - { - return "org.eclipse.wst.wsdl.ui.internal.section.name"; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSection.java deleted file mode 100644 index dffb3df1f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSection.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.List; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.dialogs.InvokeSetDialog; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.ComponentNameComboHelper; -import org.eclipse.wst.wsdl.util.WSDLConstants; - -public class ReferenceSection extends AbstractSection -{ - protected CCombo componentNameCombo; - protected ComponentNameComboHelper componentNameComboHelper; - Button button; - IEditorPart editorPart; - CLabel messageLabel; - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) - { - super.createControls(parent, factory); - composite = getWidgetFactory().createFlatFormComposite(parent); - FormData data; - - messageLabel = getWidgetFactory().createCLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE")); //$NON-NLS-1$ - componentNameCombo = getWidgetFactory().createCCombo(composite); - componentNameCombo.setBackground(composite.getBackground()); - button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$ - button.setImage(WSDLEditorPlugin.getInstance().getImage("icons/browsebutton.gif")); //$NON-NLS-1$ - button.addSelectionListener(this); - - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(componentNameCombo, -ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(componentNameCombo, 0, SWT.CENTER); - messageLabel.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(100, -rightMarginSpace + 2); - data.right = new FormAttachment(100,0); - data.top = new FormAttachment(componentNameCombo, 0, SWT.CENTER); - button.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(0, 100); - data.right = new FormAttachment(button, 0); - componentNameCombo.setLayoutData(data); - - componentNameCombo.addListener(SWT.Modify, this); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - setListenerEnabled(false); - componentNameCombo.removeListener(SWT.Modify, this); - Object obj = getElement(); - if (obj instanceof MessageReference) - { - messageLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE")); //$NON-NLS-1$ - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getMessageNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.MESSAGE_ATTRIBUTE; - } - }; - - } - else if (obj instanceof Binding) - { - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getPortTypeNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.TYPE_ATTRIBUTE; - } - }; - - messageLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORTTYPE")); //$NON-NLS-1$ - } - else if (obj instanceof Port) - { - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getBindingNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.BINDING_ATTRIBUTE; - } - }; - messageLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING")); //$NON-NLS-1$ - } - - componentNameComboHelper.update(getElement()); - setListenerEnabled(true); - componentNameCombo.addListener(SWT.Modify, this); - } - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == button) - { - InvokeSetDialog dialog = new InvokeSetDialog(); - dialog.run(getElement(), editorPart); - - WSDLEditor editor = (WSDLEditor) editorPart; - editor.getSelectionManager().setSelection(new StructuredSelection(getElement())); - } - } - - public void handleEvent(Event event) - { - componentNameComboHelper.handleEventHelper(getElement().getElement(), event); - } - - public void setEditorPart(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSectionDescriptor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSectionDescriptor.java deleted file mode 100644 index 7978dc9b8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/ReferenceSectionDescriptor.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Port; - - -public class ReferenceSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor -{ - ReferenceSection referenceSection; - - /** - * - */ - public ReferenceSectionDescriptor() - { - super(); - this.referenceSection = new ReferenceSection(); - } - - - /** - * - */ - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return "org.eclipse.wst.wsdl.ui.internal.section.reference"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(MessageReference.class); - list.add(Binding.class); - list.add(Port.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return referenceSection; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return "org.eclipse.wst.xmlwebservices.general"; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - referenceSection.setEditorPart(part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor()); - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof MessageReference || object instanceof Binding || object instanceof Port) - { - return true; - } - } - return false; - } - - public String getAfterSection() - { - return "org.eclipse.wst.wsdl.ui.internal.section.name"; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/TextChangeHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/TextChangeHelper.java deleted file mode 100644 index 124ed18cd..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/TextChangeHelper.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -/** - * TextChangeHelper notifies the listner of text lifecycle events - * on behalf of the widget(s) it listens to. - * - * @author Anthony Hunter - * <a href="mailto:anthonyh@ca.ibm.com">anthonyh@ca.ibm.com</a> - */ -public abstract class TextChangeHelper implements Listener { - - private boolean nonUserChange; - - /** - * Marks the start of a programmatic change to the widget contents. - * Clients must call startNonUserChange() before directly setting - * the widget contents to avoid unwanted lifecycle events. - * @throws IllegalArgumentException if a programmatic change is - * already in progress. - */ - public void startNonUserChange() { - if (nonUserChange) - throw new IllegalStateException("we already started a non user change");//$NON-NLS-1$ - nonUserChange = true; - } - - /** - * Clients who call startNonUserChange() should call - * finishNonUserChange() as soon as possible after the change is done. - * @throws IllegalArgumentException if no change is in progress. - */ - public void finishNonUserChange() { - if (!nonUserChange) - throw new IllegalStateException("we are not in a non user change");//$NON-NLS-1$ - nonUserChange = false; - } - - /** - * Returns true if a programmatic change is in progress. - */ - public boolean isNonUserChange() { - return nonUserChange; - } - - /** - * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) - */ - public void handleEvent(Event event) { - switch (event.type) { - case SWT.KeyDown : - if (event.character == SWT.CR) - textChanged((Control)event.widget); - break; - case SWT.FocusOut : - textChanged((Control)event.widget); - break; - } - } - - /** - * Abstract method notified when a text field has been changed. - * @param control - */ - public abstract void textChanged(Control control); - - /** - * Registers this helper with the given control to listen for events - * which indicate that a change is in progress (or done). - */ - public void startListeningTo(Control control) { - control.addListener(SWT.FocusOut, this); - control.addListener(SWT.Modify, this); - } - - /** - * Registers this helper with the given control to listen for the - * Enter key. When Enter is pressed, the change is considered done - * (this is only appropriate for single-line Text widgets). - */ - public void startListeningForEnter(Control control) { - // NOTE: KeyDown rather than KeyUp, because of similar usage in CCombo. - control.addListener(SWT.KeyDown, this); - } - - /** - * Unregisters this helper from a control previously passed to - * startListeningTo() and/or startListeningForEnter(). - */ - public void stopListeningTo(Control control) { - control.removeListener(SWT.FocusOut, this); - control.removeListener(SWT.Modify, this); - control.removeListener(SWT.KeyDown, this); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLLabelProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLLabelProvider.java deleted file mode 100644 index a5de0b653..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLLabelProvider.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.WSDLElement; -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; -import org.eclipse.wst.wsdl.ui.internal.graph.model.WSDLGraphModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; - -public class WSDLLabelProvider extends LabelProvider -{ - protected ModelAdapterFactory adapterFactory = new WSDLModelAdapterFactory(); - private WSDLTypeMapper typeMapper; - - protected WSDLEditorExtension[] labelProviderExtensions; - protected LabelProvider[] labelProviders; - IEditorPart editorPart; - - /** - * - */ - public WSDLLabelProvider() - { - super(); - typeMapper = new WSDLTypeMapper(); - editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - labelProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER); - labelProviders = new LabelProvider[labelProviderExtensions.length]; - for (int i = 0; i < labelProviderExtensions.length; i++) - { - labelProviders[i] = (LabelProvider)labelProviderExtensions[i].createExtensionObject(WSDLEditorExtension.OUTLINE_LABEL_PROVIDER, (WSDLEditor)editorPart); - } - } - - /** - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object object) - { - if (object == null || object.equals(StructuredSelection.EMPTY)) { - return null; - } - Image result = null; - if (object instanceof StructuredSelection) - { - Object selected = ((StructuredSelection)object).getFirstElement(); - selected = typeMapper.remapObject(selected); - for (int i = 0; i < labelProviders.length; i++) - { - result = labelProviders[i].getImage(selected); - if (result!=null) - break; - } -// if (result != null) -// { -// ModelAdapter modelAdapter = adapterFactory.getAdapter(selected); -// if (modelAdapter != null) -// { -// result = (Image)modelAdapter.getProperty(selected, ModelAdapter.IMAGE_PROPERTY); -// } -// } - } - return result; - } - - /** - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object object) - { - if (object == null || object.equals(StructuredSelection.EMPTY)) { - return "No items selected";//$NON-NLS-1$ - } - String result = null; - Object selected = null; - if (object instanceof StructuredSelection) - { - selected = ((StructuredSelection)object).getFirstElement(); - selected = typeMapper.remapObject(selected); - - // Override outline provider's getText for WSDLElements - if (selected instanceof WSDLElement) - { - if (((WSDLElement)selected).getElement() == null) { - return ""; - } - boolean isReadOnly = false; - ModelAdapter adapter = WSDLGraphModelAdapterFactory.getWSDLGraphModelAdapterFactory().getAdapter(selected); - if (adapter != null) - { - isReadOnly = Boolean.TRUE.equals(adapter.getProperty(selected, "isReadOnly")); - } - if (isReadOnly) - { - result = ((WSDLElement)selected).getElement().getLocalName() + " (" + WSDLEditorPlugin.getWSDLString("_UI_LABEL_READ_ONLY") + ")"; //$NON-NLS-1$ - } - else - { - result = ((WSDLElement)selected).getElement().getLocalName(); - } - return result; - } - else if (selected instanceof XSDConcreteComponent) - { - // Override for XSD Components - - Element element = ((XSDConcreteComponent)selected).getElement(); - if (element != null) - { - if (element instanceof IDOMNode) - { - return ((XSDConcreteComponent)selected).getElement().getLocalName(); - } - else - { - return ((XSDConcreteComponent)selected).getElement().getLocalName() + " (" + WSDLEditorPlugin.getWSDLString("_UI_LABEL_READ_ONLY") + ")"; //$NON-NLS-1$ - } - } - else - { - return "(" + WSDLEditorPlugin.getWSDLString("_UI_LABEL_READ_ONLY") + ")"; //$NON-NLS-1$ - } - - } - // otherwise get it from the extensions - for (int i = 0; i < labelProviders.length; i++) - { - result = labelProviders[i].getText(selected); - if (result!=null) - break; - } - } - else if (object instanceof TextSelection) - { - } - - - return result; - } - - /** - * Determine if a multiple object selection has been passed to the - * label provider. If the objects is a IStructuredSelection, see if - * all the objects in the selection are the same and if so, we want - * to provide labels for the common selected element. - * @param objects a single object or a IStructuredSelection. - * @param multiple first element in the array is true if there is multiple - * unequal selected elements in a IStructuredSelection. - * @return the object to get labels for. - */ -// private Object getObject(Object objects, boolean multiple[]) { -// Assert.isNotNull(objects); -// Object object = null; -// return object; -// } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLSectionDescriptorProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLSectionDescriptorProvider.java deleted file mode 100644 index 73d165899..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLSectionDescriptorProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider; -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 WSDLSectionDescriptorProvider implements ISectionDescriptorProvider -{ - protected WSDLEditorExtension[] propertySectionDescriptorProviderExtensions; - protected ISectionDescriptorProvider[] propertySectionDescriptorProviders; - - protected WSDLEditorExtension[] labelProviderExtensions; - - protected final static Object[] EMPTY_ARRAY = {}; - - IEditorPart editorPart; - - /** - * - */ - public WSDLSectionDescriptorProvider() - { - super(); - // TODO Check this - this.editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider#getSectionDescriptors() - */ - public ISectionDescriptor[] getSectionDescriptors() - { - List list = new ArrayList(); - - - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - - propertySectionDescriptorProviderExtensions = registry.getRegisteredExtensions(WSDLEditorExtension.PROPERTY_SECTION_DESCRIPTOR_PROVIDER); - propertySectionDescriptorProviders = new ISectionDescriptorProvider[propertySectionDescriptorProviderExtensions.length]; - for (int i = 0; i < propertySectionDescriptorProviderExtensions.length; i++) - { - propertySectionDescriptorProviders[i] = (ISectionDescriptorProvider)propertySectionDescriptorProviderExtensions[i].createExtensionObject(WSDLEditorExtension.PROPERTY_SECTION_DESCRIPTOR_PROVIDER, (WSDLEditor)editorPart); - - ISectionDescriptor [] extensionSectionDescriptors = propertySectionDescriptorProviders[i].getSectionDescriptors(); - for (int j = 0; j < extensionSectionDescriptors.length; j++) - { - list.add(extensionSectionDescriptors[j]); - } - } - - - list.add(new NameSectionDescriptor()); - list.add(new PartSectionDescriptor()); - list.add(new DocumentationSectionDescriptor()); - list.add(new ReferenceSectionDescriptor()); - list.add(new NamespaceSectionDescriptor()); - list.add(new ExtensibilityElementSectionDescriptor()); - list.add(new ImportSectionDescriptor()); - - ISectionDescriptor[] descriptors = new ISectionDescriptor[list.size()]; - list.toArray(descriptors); - - return descriptors; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTabbedPropertySheetPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTabbedPropertySheetPage.java deleted file mode 100644 index 9952f86b8..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTabbedPropertySheetPage.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.sse.ui.internal.view.events.INodeSelectionListener; -import org.eclipse.wst.sse.ui.internal.view.events.NodeSelectionChangedEvent; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLSelectionManager; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapter; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory; -import org.eclipse.xsd.XSDComponent; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class WSDLTabbedPropertySheetPage extends TabbedPropertySheetPage implements ISelectionChangedListener, INodeSelectionListener, ModelAdapterListener, org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapterListener -{ - private WSDLSelectionManager fViewerSelectionManager; - private WSDLEditor wsdlEditor; - private Object currentObject; - - /** - * @param tabbedPropertySheetPageContributor - */ - public WSDLTabbedPropertySheetPage(ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor, WSDLEditor editor) - { - super(tabbedPropertySheetPageContributor); - this.wsdlEditor = editor; - } - - public void createControl(Composite parent) { - super.createControl(parent); - wsdlEditor.getSelectionManager().setSelection(new StructuredSelection(wsdlEditor.getDefinition())); - } - - public void setSelectionManager(WSDLSelectionManager viewerSelectionManager) { - // disconnect from old one - if (fViewerSelectionManager != null) { - fViewerSelectionManager.removeSelectionChangedListener(this); - } - - fViewerSelectionManager = viewerSelectionManager; - - // connect to new one - if (fViewerSelectionManager != null) { - fViewerSelectionManager.addSelectionChangedListener(this); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) - { - if (!event.getSelection().isEmpty()) { - selectionChanged(getSite().getWorkbenchWindow().getActivePage().getActivePart(), event.getSelection()); - //super.selectionChanged(getSite().getWorkbenchWindow().getActivePage().getActivePart(), event.getSelection()); - } - } - - public void selectionChanged(IWorkbenchPart part, ISelection selection) - { - // override for category - if (selection != null) - { - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - if (structuredSelection.isEmpty()) - { - return; - } - Object obj = structuredSelection.getFirstElement(); - Node node = WSDLEditorUtil.getInstance().getNodeForObject(obj); - Object o = WSDLEditorUtil.getInstance().findModelObjectForElement(wsdlEditor.getDefinition(), (Element)node); - - // bad hack to get schema from category - // until we provide a better mechanism (selection manager extension) - // see also WSDLGraphViewer - if (o instanceof XSDSchemaExtensibilityElement) - { - obj = ((XSDSchemaExtensibilityElement)o).getSchema(); - selection = new StructuredSelection(obj); - } - - attachListener(o); - } - else if (selection instanceof TextSelection) - { - return; - } - } - - super.selectionChanged(wsdlEditor.getEditorPart(), selection); // event.getSelection()); - } - - protected void attachListener(Object object) - { - WSDLModelAdapterFactory adapterFactory = WSDLModelAdapterFactory.getWSDLModelAdapterFactory(); - ModelAdapter adapter = adapterFactory.getAdapter(object); - if (adapter != null) - { - // remove listener from the previously selected object - removeListener(currentObject); - - // add listener to the newly selected object - adapter.addListener(this); - currentObject = object; - } - else if (object instanceof XSDComponent && XSDModelAdapterFactory.getAdapter(object) != null) { - // Maybe it's an XSD Object - if (currentObject != null) { - org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapter xsdAdapter = (org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapter)XSDModelAdapterFactory.getAdapter(currentObject); - if (xsdAdapter != null) - xsdAdapter.removeListener(this); - } - - XSDModelAdapterFactory.getAdapter(object).addListener(this); - currentObject = object; - } - } - - protected void removeListener(Object object) - { - WSDLModelAdapterFactory adapterFactory = WSDLModelAdapterFactory.getWSDLModelAdapterFactory(); - ModelAdapter adapter = adapterFactory.getAdapter(object); - if (adapter != null) - { - adapter.removeListener(this); - currentObject = null; - } - else if (object instanceof XSDComponent && XSDModelAdapterFactory.getAdapter(object) != null) { - // Maybe it's an XSD Object - XSDModelAdapterFactory.getAdapter(object).removeListener(this); - currentObject = null; - } - } - public void dispose() { - // disconnect from the ViewerSelectionManager - if (fViewerSelectionManager != null) { - fViewerSelectionManager.removeSelectionChangedListener(this); - } - - // disconnect listener from the current object - if (currentObject != null) { - removeListener(currentObject); - } - - super.dispose(); - } - - - /* (non-Javadoc) - * @see org.eclipse.wst.sse.editor.view.events.INodeSelectionListener#nodeSelectionChanged(org.eclipse.wst.sse.editor.view.events.NodeSelectionChangedEvent) - */ - public void nodeSelectionChanged(NodeSelectionChangedEvent event) - { - } - - public void propertyChanged(Object object, String property) { - if (getCurrentTab() != null) { - refresh(); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTypeMapper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTypeMapper.java deleted file mode 100644 index 37ed0556c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/properties/section/WSDLTypeMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.properties.section; - -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; - -public class WSDLTypeMapper implements ITypeMapper -{ - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper#remapType(java.lang.Object, java.lang.Class) - */ - public Class remapType(Object object, Class effectiveType) - { - Class type = effectiveType; - - if (object instanceof WSDLGroupObject) { - type = ((WSDLGroupObject) object).getDefinition().getClass(); - } - - return type; - } - - public Object remapObject(Object object) - { - Object type = object; - - if (object instanceof WSDLGroupObject) - { - type = ((WSDLGroupObject) object).getDefinition(); - } - return type; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/DelegatingSourceValidatorForWSDL.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/DelegatingSourceValidatorForWSDL.java deleted file mode 100644 index f251731db..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/DelegatingSourceValidatorForWSDL.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.reconciler; - -import org.eclipse.wst.validation.internal.ValidationRegistryReader; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; -import org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidator; - -/** - * - */ -public class DelegatingSourceValidatorForWSDL extends DelegatingSourceValidator -{ - - final private static String VALIDATOR_CLASS = "org.eclipse.wst.wsdl.validation.internal.ui.eclipse.Validator"; - - public DelegatingSourceValidatorForWSDL() - { super(); - } - - protected IValidator getDelegateValidator() - { - try - { - ValidationRegistryReader registry = ValidationRegistryReader.getReader(); - return registry.getValidator(VALIDATOR_CLASS); - } - catch (Exception e) - { // - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/ExtensibleNodeReconciler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/ExtensibleNodeReconciler.java deleted file mode 100644 index 58a0759d0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/ExtensibleNodeReconciler.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.reconciler; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.INodeReconciler; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; -import org.w3c.dom.Element; - - - -// TODO.. we should probably be keying off of the node's qname (perhaps supporting 'null' as a wild card for local names) -// in order to compute an applicable reconciler -// -public class ExtensibleNodeReconciler -{ - protected WSDLEditorExtension[] extensions; - protected INodeReconciler[] reconcilers; - - public ExtensibleNodeReconciler() - { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - extensions = registry.getRegisteredExtensions(WSDLEditorExtension.NODE_RECONCILER); - reconcilers = new INodeReconciler[extensions.length]; - for (int i = 0; i < extensions.length; i++) - { - reconcilers[i] = (INodeReconciler)extensions[i].createExtensionObject(WSDLEditorExtension.NODE_RECONCILER, null); - } - } - - protected INodeReconciler getApplicableNodeReconciler(Object object) - { - INodeReconciler reconciler = null; - for (int i = 0; i < extensions.length; i++) - { - if (extensions[i].isApplicable(object)) - { - reconciler = reconcilers[i]; - if (reconciler != null) - { - break; - } - } - } - return reconciler; - } - - public void notifyChanged(Object modelObject, Element element, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - INodeReconciler reconciler = getApplicableNodeReconciler(modelObject); - if (reconciler != null) - { - reconciler.notifyChanged(modelObject, element, eventType, feature, oldValue, newValue, index); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/SEDDocumentAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/SEDDocumentAdapter.java deleted file mode 100644 index 10c5dd5cc..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/reconciler/SEDDocumentAdapter.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.reconciler; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.internal.impl.XSDSchemaExtensibilityElementImpl; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.impl.XSDSchemaImpl; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class SEDDocumentAdapter -{ - protected Document document; - protected Definition definition; - protected ExtensibleNodeReconciler extensibleNodeReconciler; - - public SEDDocumentAdapter(IStructuredModel model, Definition definition) - { - this.document = (model instanceof IDOMModel) ? ((IDOMModel)model).getDocument() : null; - this.definition = definition; - this.extensibleNodeReconciler = new ExtensibleNodeReconciler(); - new MyDocumentAdapter(document); - } - - - class MyDocumentAdapter extends DocumentAdapter - { -// private boolean isValidDefinition = true; - - MyDocumentAdapter(Document document) - { - super(document); - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - if (eventType == INodeNotifier.ADD) - { - if (newValue instanceof Element) - { - adapt((Element)newValue); - - // See Bug 5366 - // We need to sync up the Model and the DOM - Element newDocumentElement = (Element)newValue; - String wsdlPrefix = newDocumentElement.getPrefix(); - if (wsdlPrefix == null) wsdlPrefix = ""; - String ns = definition.getNamespace(wsdlPrefix); - if (ns != null && ns.equals(WSDLConstants.WSDL_NAMESPACE_URI) - && newDocumentElement.getLocalName().equals(WSDLConstants.DEFINITION_ELEMENT_TAG)) // && - // !isValidDefinition) - { -// System.out.println("****** Setting new definition"); - definition.setElement(newDocumentElement); - } - } - } - - switch (eventType) - { - // we make the assumption that reconciling will only be triggered by one of these notifications - // (ADD and REMOVE notifications are omitted) - // - case INodeNotifier.CHANGE: - case INodeNotifier.STRUCTURE_CHANGED: - case INodeNotifier.CONTENT_CHANGED: - { - if (notifier instanceof Element) - { - reconcileModelObjectForElement((Element)notifier, eventType, feature, oldValue, newValue, index); - } - else if (notifier instanceof Document) - { - Document document = (Document)notifier; - Element definitionElement = null; - - for (Node node = document.getFirstChild(); node != null; node = node.getNextSibling()) - { - if (node.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element)node; - if (WSDLEditorUtil.getInstance().getWSDLType(element) == WSDLConstants.DEFINITION) - { - definitionElement = element; - break; - } - } - } - - // TODO... revisit definition.removeAllContent() and who should call this? - // - if (definitionElement != null) - { -// isValidDefinition = true; -// System.out.println("VALID DEFINITION ELEMENT"); - ((DefinitionImpl)definition).elementChanged(definitionElement); - } - else - { -// System.out.println("INVALID DEFINITION ELEMENT"); -// isValidDefinition = false; - ((DefinitionImpl)definition).removeAll(); - } - } - break; - } - } - } - - protected void reconcileModelObjectForElement(Element element, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - Object modelObject = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, element); - if (modelObject != null) - { - if (modelObject instanceof XSDSchemaExtensibilityElementImpl) - { - XSDSchemaExtensibilityElementImpl ee = (XSDSchemaExtensibilityElementImpl)modelObject; - ((XSDSchemaImpl)ee.getSchema()).elementChanged(element); - ee.elementChanged(element); - } - else if (modelObject instanceof WSDLElementImpl) - { - ((WSDLElementImpl)modelObject).elementChanged(element); - } - else if (modelObject instanceof XSDConcreteComponent) - { - ((XSDConcreteComponent)modelObject).elementChanged(element); - extensibleNodeReconciler.notifyChanged(modelObject, element, eventType, feature, oldValue, newValue, index); - } - } - } - } - - - // An abstract adapter that ensures that the children of a new Node are also adapted - // - abstract class DocumentAdapter implements INodeAdapter - { - public DocumentAdapter(Document document) - { - ((INodeNotifier)document).addAdapter(this); - - for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) - { - if (child.getNodeType() == Node.ELEMENT_NODE) - { - adapt((Element)child); - } - } - } - - public void adapt(Element element) - { - if (element != null) - { - if (((INodeNotifier)element).getExistingAdapter(this) == null) - { - ((INodeNotifier)element).addAdapter(this); - - for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) - { - if (child.getNodeType() == Node.ELEMENT_NODE) - { - adapt((Element)child); - } - } - } - } - } - - public boolean isAdapterForType(Object type) - { - return type == this; - } - - abstract public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelAdapter.java deleted file mode 100644 index 42305d1c4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelAdapter.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.text; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLFactory; -import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl; -import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl; -import org.eclipse.wst.wsdl.ui.internal.typesystem.ExtensibleTypeSystemProvider; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLModelLocatorAdapterFactory; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaLocationResolverAdapterFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class WSDLModelAdapter implements INodeAdapter -{ - protected ResourceSet resourceSet; - protected Definition definition; - - public Definition getDefinition() - { - return definition; - } - - public void setDefinition(Definition definition) - { - this.definition = definition; - } - - public boolean isAdapterForType(Object type) - { - return type == WSDLModelAdapter.class; - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) - { - } - - public Definition createDefinition(Element element, Document document) - { - try - { - IDOMNode domNode = (IDOMNode)element; - String baseLocation = "blankWSDL.wsdl"; - if (domNode != null) { - baseLocation = domNode.getModel().getBaseLocation(); - } - else if (document instanceof IDOMNode){ - IDOMModel domModel = ((IDOMNode) document).getModel(); - baseLocation = domModel.getBaseLocation(); - } - - resourceSet = new ResourceSetImpl(); - resourceSet.getAdapterFactories().add(new WSDLModelLocatorAdapterFactory()); - resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory()); - - // TODO.. .revist the best approach to obtain a URI from the SSE model - // - URI uri = null; - if (baseLocation.startsWith("/")) - { - uri = URI.createPlatformResourceURI(baseLocation); - } - else - { - uri = URI.createFileURI(baseLocation); - } - - definition = WSDLFactory.eINSTANCE.createDefinition(); - definition.setDocumentBaseURI(uri.toString()); - definition.setDocument(document); - definition.setElement(element); - - WSDLResourceFactoryImpl resourceFactory = new WSDLResourceFactoryImpl(); - Resource resource = resourceFactory.createResource(uri); - resourceSet.getResources().add(resource); - resource.getContents().add(definition); - resource.setModified(false); - ((DefinitionImpl)definition).reconcileReferences(true); - - // attach an adapter to keep the WSDL model and DOM in sync - // - new WSDLModelReconcileAdapter(document, definition); - - // TODO... CS : revisit this line - // currently this is used to associate a 'type' system with the definition - // I suspect that this could be made a whole lot more simple - // - WSDLEditorUtil.getInstance().setTypeSystemProvider(definition, new ExtensibleTypeSystemProvider()); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - return definition; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelQueryExtension.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelQueryExtension.java deleted file mode 100644 index 5de5b5cd9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelQueryExtension.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.text; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.filter.ExtensiblityElementFilter; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xsd.ui.internal.text.XSDModelQueryExtension; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class WSDLModelQueryExtension extends XSDModelQueryExtension -{ - public WSDLModelQueryExtension() - { - } - - protected boolean isParentElementMessageReference(String parentElementName) - { - return parentElementName.equals("input") || parentElementName.equals("output") || parentElementName.equals("fault"); - } - - protected boolean isMessageReference(String elementName) - { - return elementName.equals("body") || elementName.equals("header") || elementName.equals("fault") || elementName.equals("urlReplacement") || elementName.equals("urlEncoded"); - } - - - public boolean isApplicableChildElement(Node parentNode, String namespace, String name) - { - boolean result = true; - if (parentNode.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element) parentNode; - String parentElementNamespaceURI = parentNode.getNamespaceURI(); - String parentElementName = parentNode.getLocalName(); - // only filter children for 'non-schema' elements - // - if (!WSDLConstants.XSD_NAMESPACE_URI.equals(parentElementNamespaceURI)) - { - if (parentElementName != null && name != null) - { - if (namespace != null) - { - // the following namespace are one that always should be filtered out - // for now this is hardcoded - // - if (namespace.equals("http://schemas.xmlsoap.org/soap/encoding/")) - { - // exclude soap-enc elements - // - result = false; - } - else if (namespace.equals(WSDLConstants.XSD_NAMESPACE_URI)) - { - // eclipse all schema elements, except for 'schema' withing wsdl types elements - result = parentElementName.equals("types") && name.equals("schema"); - } - else - { - // TODO.. we should investigate removing the ExtensiblityElementFilter extension point - // shouldn't this be a ModelQueryExtension defined on the extension languages? - // - ExtensiblityElementFilter filter = (ExtensiblityElementFilter) WSDLEditorPlugin.getInstance().getExtensiblityElementFilterRegistry().getProperty(namespace, ""); - if (filter != null) - { - result = filter.isValidContext(element, name); - } - } - } - } - } - } - return result; - } - - public String[] getAttributeValues(Element element, String namespace, String name) - { - if (WSDLConstants.WSDL_NAMESPACE_URI.equals(namespace)) - { - List list = new ArrayList(); - ComponentReferenceUtil util = new ComponentReferenceUtil(lookupOrCreateDefinition(element)); - String currentElementName = element.getLocalName(); - if (checkName(name, "message")) - { - list.addAll(util.getMessageNames()); - } - else if (checkName(name, "binding")) - { - list.addAll(util.getBindingNames()); - } - else if (checkName(name, "type")) - { - if (checkName(currentElementName, "binding")) - { - list.addAll(util.getPortTypeNames()); - } - else if (checkName(currentElementName, "part")) - { - list.addAll(util.getComponentNameList(true)); - } - } - else if (checkName(name, "element")) - { - if (checkName(currentElementName, "part")) - { - list.addAll(util.getComponentNameList(false)); - } - } - String[] result = new String[list.size()]; - list.toArray(result); - return result; - } - else - { - return super.getAttributeValues(element, namespace, name); - } - } - - - protected XSDSchema lookupOrCreateSchemaForElement(Element element) - { - XSDSchema schema = null; - Definition definition = lookupOrCreateDefinition(element); - Object o = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, element); - if (o instanceof XSDConcreteComponent) - { - schema = ((XSDConcreteComponent) o).getSchema(); - } - return schema; - } - - - protected Definition lookupOrCreateDefinition(Element element) - { - Definition definition = null; - Document document = element.getOwnerDocument(); - if (document instanceof INodeNotifier) - { - INodeNotifier notifier = (INodeNotifier) document; - WSDLModelAdapter adapter = (WSDLModelAdapter) notifier.getAdapterFor(WSDLModelAdapter.class); - if (adapter == null) - { - adapter = new WSDLModelAdapter(); - notifier.addAdapter(adapter); - adapter.createDefinition(document.getDocumentElement(), document); - } - definition = adapter.getDefinition(); - } - return definition; - } - - - protected TypesHelper getTypesHelper(final Element element) - { - XSDSchema schema = lookupOrCreateSchemaForElement(element); - return new TypesHelper(schema) - { - // TODO... it seems as though the model is not correctly - // mainting the list of prefixes for a given namespace - // must be a bug! - // - protected List getPrefixesForNamespace(String namespace) - { - List list = super.getPrefixesForNamespace(namespace); - Definition definition = lookupOrCreateDefinition(element); - if (definition != null) - { - Map map = definition.getNamespaces(); - for (Iterator i = map.keySet().iterator(); i.hasNext();) - { - String prefix = (String) i.next(); - String ns = (String) map.get(prefix); - if (ns != null && ns.equals(namespace)) - { - if (!list.contains(prefix)) - { - list.add(prefix); - } - } - } - } - return list; - } - }; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelReconcileAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelReconcileAdapter.java deleted file mode 100644 index dcb3b3e74..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/text/WSDLModelReconcileAdapter.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.text; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.internal.impl.XSDSchemaExtensibilityElementImpl; -import org.eclipse.wst.wsdl.ui.internal.reconciler.ExtensibleNodeReconciler; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.impl.XSDSchemaImpl; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -class WSDLModelReconcileAdapter extends DocumentAdapter -{ - protected Definition definition; - protected ExtensibleNodeReconciler extensibleNodeReconciler; - - public WSDLModelReconcileAdapter(Document document, Definition definition) - { - super(document); - this.definition = definition; - this.extensibleNodeReconciler = new ExtensibleNodeReconciler(); - } - - - public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - if (eventType == INodeNotifier.ADD) - { - if (newValue instanceof Element) - { - adapt((Element)newValue); - - // See Bug 5366 - // We need to sync up the Model and the DOM - Element newDocumentElement = (Element)newValue; - String wsdlPrefix = newDocumentElement.getPrefix(); - if (wsdlPrefix == null) wsdlPrefix = ""; - String ns = definition != null ? definition.getNamespace(wsdlPrefix) : ""; - if (ns != null && ns.equals(WSDLConstants.WSDL_NAMESPACE_URI) - && newDocumentElement.getLocalName().equals(WSDLConstants.DEFINITION_ELEMENT_TAG)) // && - // !isValidDefinition) - { -// System.out.println("****** Setting new definition"); - definition.setElement(newDocumentElement); - } - } - } - - switch (eventType) - { - // we make the assumption that reconciling will only be triggered by one of these notifications - // (ADD and REMOVE notifications are omitted) - // - case INodeNotifier.CHANGE: - case INodeNotifier.STRUCTURE_CHANGED: - case INodeNotifier.CONTENT_CHANGED: - { - if (notifier instanceof Element) - { - reconcileModelObjectForElement((Element)notifier, eventType, feature, oldValue, newValue, index); - } - else if (notifier instanceof Document) - { - Document document = (Document)notifier; - Element definitionElement = null; - - for (Node node = document.getFirstChild(); node != null; node = node.getNextSibling()) - { - if (node.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element)node; - if (WSDLEditorUtil.getInstance().getWSDLType(element) == WSDLConstants.DEFINITION) - { - definitionElement = element; - break; - } - } - } - - // TODO... revisit definition.removeAllContent() and who should call this? - // - if (definitionElement != null) - { -// isValidDefinition = true; -// System.out.println("VALID DEFINITION ELEMENT"); - WSDLModelAdapter modelAdapter = (WSDLModelAdapter) notifier.getAdapterFor(WSDLModelAdapter.class); - if (modelAdapter != null) { - definition = modelAdapter.getDefinition(); - if (definition == null) definition = modelAdapter.createDefinition(definitionElement, document); - } - ((DefinitionImpl)definition).elementChanged(definitionElement); - } - else - { -// System.out.println("INVALID DEFINITION ELEMENT"); -// isValidDefinition = false; - ((DefinitionImpl)definition).removeAll(); - } - } - break; - } - } - } - - protected void reconcileModelObjectForElement(Element element, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - Object modelObject = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, element); - if (modelObject != null) - { - if (modelObject instanceof XSDSchemaExtensibilityElementImpl) - { - XSDSchemaExtensibilityElementImpl ee = (XSDSchemaExtensibilityElementImpl)modelObject; - ((XSDSchemaImpl)ee.getSchema()).elementChanged(element); - ee.elementChanged(element); - } - else if (modelObject instanceof WSDLElementImpl) - { - ((WSDLElementImpl)modelObject).elementChanged(element); - } - else if (modelObject instanceof XSDConcreteComponent) - { - ((XSDConcreteComponent)modelObject).elementChanged(element); - extensibleNodeReconciler.notifyChanged(modelObject, element, eventType, feature, oldValue, newValue, index); - } - } - } -} - - -abstract class DocumentAdapter implements INodeAdapter -{ - Document document; - - public DocumentAdapter(Document document) - { - this.document = document; - ((INodeNotifier)document).addAdapter(this); - if (document.getDocumentElement() != null) adapt(document.getDocumentElement()); - } - - public void adapt(Element element) - { - if (((INodeNotifier)element).getExistingAdapter(this) == null) - { - ((INodeNotifier)element).addAdapter(this); - - for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) - { - if (child.getNodeType() == Node.ELEMENT_NODE) - { - adapt((Element)child); - } - } - } - } - - public boolean isAdapterForType(Object type) - { - return type == this; - } - - abstract public void notifyChanged - (INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/typesystem/ExtensibleTypeSystemProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/typesystem/ExtensibleTypeSystemProvider.java deleted file mode 100644 index d6bc54a0a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/typesystem/ExtensibleTypeSystemProvider.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.typesystem; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; -import org.eclipse.xsd.XSDSchema; - -public class ExtensibleTypeSystemProvider implements ITypeSystemProvider -{ - protected WSDLEditorExtension[] extensions; - protected ITypeSystemProvider[] typeSystemProviders; - - protected final static Object[] EMPTY_ARRAY = {}; - - public ExtensibleTypeSystemProvider() - { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - - extensions = registry.getRegisteredExtensions(WSDLEditorExtension.TYPE_SYSTEM_PROVIDER); - typeSystemProviders = new ITypeSystemProvider[extensions.length]; - for (int i = 0; i < extensions.length; i++) - { - typeSystemProviders[i] = (ITypeSystemProvider)extensions[i].createExtensionObject(WSDLEditorExtension.TYPE_SYSTEM_PROVIDER, null); - } - } - - public List getAvailableTypeNames(Definition definition, int typeNameCategory) - { - List list = new ArrayList(); - for (int i = 0; i < typeSystemProviders.length; i++) - { - list.addAll(typeSystemProviders[i].getAvailableTypeNames(definition, typeNameCategory)); - } - return list; - } - - public List getAvailableTypes(Definition definition, XSDSchema schema, int typeNameCategory) - { - List list = new ArrayList(); - for (int i = 0; i < typeSystemProviders.length; i++) - { - list.addAll(typeSystemProviders[i].getAvailableTypes(definition, schema, typeNameCategory)); - } - return list; - } - - public List getAvailableElementNames(Definition definition) - { - List list = new ArrayList(); - for (int i = 0; i < typeSystemProviders.length; i++) - { - list.addAll(typeSystemProviders[i].getAvailableElementNames(definition)); - } - return list; - } - - public int getCategoryForTypeName(Definition definition, String typeName) - { - int result = UNKNOWN_TYPE; - for (int i = 0; i < typeSystemProviders.length; i++) - { - result = typeSystemProviders[i].getCategoryForTypeName(definition, typeName); - if (result != UNKNOWN_TYPE) - { - break; - } - } - return result; - } - - public List getPrefixedNames(Definition definition, String namespace, String localName) { - List list = new ArrayList(); - for (int i = 0; i < typeSystemProviders.length; i++) - { - list.addAll(typeSystemProviders[i].getPrefixedNames(definition, namespace, localName)); - } - return list; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java deleted file mode 100644 index cbf51ae69..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java +++ /dev/null @@ -1,957 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.ImportImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class ComponentReferenceUtil -{ - protected Definition rootDefinition; - - public ComponentReferenceUtil(Definition rootDefinition) - { - this.rootDefinition = rootDefinition; - } - - protected static boolean isEqual(String a, String b) - { - boolean result = false; - if (a != null) - { - result = a.equals(b) || (a.length() == 0 && b == null); - } - else - { - result = (b == null || b.length() == 0); - } - return result; - } - - protected static boolean isEqualInputName(Operation operation, BindingOperation bindingOperation) - { - boolean result = false; - Input operationInput = operation.getEInput(); - BindingInput bindingOperationInput = bindingOperation.getEBindingInput(); - - if (operationInput != null && bindingOperationInput != null) - { - result = isEqual(operationInput.getName(), bindingOperationInput.getName()); - } - else if (operationInput == null && bindingOperationInput == null) - { - result = true; - } - return result; - } - - protected static boolean isEqualOutputName(Operation operation, BindingOperation bindingOperation) - { - boolean result = false; - Output operationOutput = operation.getEOutput(); - BindingOutput bindingOperationOutput = bindingOperation.getEBindingOutput(); - - if (operationOutput != null && bindingOperationOutput != null) - { - result = isEqual(operationOutput.getName(), bindingOperationOutput.getName()); - } - else if (operationOutput == null && bindingOperationOutput == null) - { - result = true; - } - return result; - } - - protected static boolean isMatchingBinding(Operation operation, BindingOperation bindingOperation) - { - return isEqual(operation.getName(), bindingOperation.getName()) && isEqualInputName(operation, bindingOperation) && isEqualOutputName(operation, bindingOperation); - } - - public List getPortsForPortType(PortType portType) - { - List list = new ArrayList(); - for (Iterator i = getServices().iterator(); i.hasNext();) - { - Service service = (Service) i.next(); - for (Iterator j = service.getEPorts().iterator(); j.hasNext();) - { - Port port = (Port) j.next(); - Binding binding = port.getEBinding(); - if (binding != null && binding.getEPortType() == portType) - { - list.add(port); - } - } - } - return list; - } - - public List getPortsForBinding(Binding binding) - { - List list = new ArrayList(); - for (Iterator i = getServices().iterator(); i.hasNext();) - { - Service service = (Service) i.next(); - for (Iterator j = service.getEPorts().iterator(); j.hasNext();) - { - Port port = (Port) j.next(); - if (port.getEBinding() == binding) - { - list.add(port); - } - } - } - return list; - } - - public List getBindingOperations(Operation operation) - { - List list = new ArrayList(); - String operationName = operation.getName(); - - if (operationName != null) - { - PortType portType = getEnclosingPortType(operation); - for (Iterator i = getBindings(portType).iterator(); i.hasNext();) - { - Binding binding = (Binding) i.next(); - BindingOperation bindingOperation = getBindingOperation(operation, binding); - if (bindingOperation != null) - { - list.add(bindingOperation); - } - } - } - return list; - } - - public BindingOperation getBindingOperation(Operation operation, Binding binding) - { - BindingOperation result = null; - for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) j.next(); - if (isMatchingBinding(operation, bindingOperation)) - { - result = bindingOperation; - break; - } - } - return result; - } - - public BindingInput getBindingInput(Input input, Binding binding) - { - BindingOperation bindingOperation = getBindingOperation((Operation) input.eContainer(), binding); - return bindingOperation != null ? bindingOperation.getEBindingInput() : null; - } - - public BindingOutput getBindingOutput(Output output, Binding binding) - { - BindingOperation bindingOperation = getBindingOperation((Operation) output.eContainer(), binding); - return bindingOperation != null ? bindingOperation.getEBindingOutput() : null; - } - - public BindingFault getBindingFault(Fault fault, Binding binding) - { - BindingFault result = null; - String faultName = fault.getName(); - if (faultName != null) - { - BindingOperation bindingOperation = getBindingOperation((Operation) fault.eContainer(), binding); - if (bindingOperation != null) - { - result = (BindingFault) bindingOperation.getBindingFault(faultName); - } - } - return result; - } - - public EObject getBindingObject(EObject interfaceObject, Binding binding) - { - EObject result = null; - if (interfaceObject instanceof Input) - { - result = getBindingInput((Input) interfaceObject, binding); - } - else if (interfaceObject instanceof Output) - { - result = getBindingOutput((Output) interfaceObject, binding); - } - else if (interfaceObject instanceof Fault) - { - result = getBindingFault((Fault) interfaceObject, binding); - } - else if (interfaceObject instanceof Operation) - { - result = getBindingOperation((Operation) interfaceObject, binding); - } - else if (interfaceObject instanceof PortType) - { - result = binding; - } - return result; - } - - public List getBindingInputs(Input input) - { - List list = new ArrayList(); - List operations = getBindingOperations((Operation) input.eContainer()); - for (Iterator i = operations.iterator(); i.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) i.next(); - if (bindingOperation.getBindingInput() != null) - { - list.add(bindingOperation.getBindingInput()); - } - } - return list; - } - - public List getBindingOutputs(Output output) - { - List list = new ArrayList(); - Operation operation = (Operation) output.eContainer(); - if (operation != null) - { - List operations = getBindingOperations(operation); - for (Iterator i = operations.iterator(); i.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) i.next(); - if (bindingOperation.getBindingOutput() != null) - { - list.add(bindingOperation.getBindingOutput()); - } - } - } - return list; - } - - public List getBindingFaults(Fault fault) - { - List list = new ArrayList(); - String faultName = fault.getName(); - if (faultName != null) - { - Operation operation = (Operation) fault.eContainer(); - if (operation != null) - { - List operations = getBindingOperations(operation); - for (Iterator i = operations.iterator(); i.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) i.next(); - BindingFault bindingFault = (BindingFault) bindingOperation.getBindingFault(faultName); - if (bindingFault != null) - { - list.add(bindingFault); - } - } - } - } - return list; - } - - protected PortType getEnclosingPortType(Operation operation) - { - return (PortType) operation.eContainer(); - } - - public List getBindings(Operation operation) - { - return getBindings(getEnclosingPortType(operation)); - } - - public List getBindings(PortType portType) - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - for (Iterator j = definition.getBindings().values().iterator(); j.hasNext();) - { - Binding binding = (Binding) j.next(); - if (portType == null || binding.getPortType() == portType) - { - list.add(binding); - } - } - } - return list; - } - - public List getBindingsWithoutOperation(PortType portType, String operationName) - { - List result = new ArrayList(); - if (operationName != null) - { - List bindings = getBindings(portType); - for (Iterator i = bindings.iterator(); i.hasNext();) - { - Binding binding = (Binding) i.next(); - boolean hasName = false; - for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext();) - { - BindingOperation bindingOperation = (BindingOperation) j.next(); - if (operationName.equals(bindingOperation.getName())) - { - hasName = true; - break; - } - } - if (!hasName) - { - result.add(binding); - } - } - } - return result; - } - - public List getBindings() - { - return getBindings((PortType) null); - } - - public List getBindingNames() - { - List list = new ArrayList(); - for (Iterator i = getBindings().iterator(); i.hasNext();) - { - Binding binding = (Binding) i.next(); - list.addAll(getPrefixedNames(binding.getQName())); - } - return list; - } - - public List getPortTypeNames() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - for (Iterator j = definition.getPortTypes().values().iterator(); j.hasNext();) - { - PortType portType = (PortType) j.next(); - list.addAll(getPrefixedNames(portType.getQName())); - } - } - return list; - } - - public List getServices() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - list.addAll(definition.getEServices()); - } - return list; - } - - public List getPortTypes() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - list.addAll(definition.getEPortTypes()); - } - return list; - } - - public List getMessages() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - list.addAll(definition.getEMessages()); - } - return list; - } - - public List getTypes() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - if (definition.getETypes() != null) - { - list.add(definition.getETypes()); - } - } - return list; - } - - public List getMessageNames() - { - List list = new ArrayList(); - for (Iterator i = getDefinitions().iterator(); i.hasNext();) - { - Definition definition = (Definition) i.next(); - for (Iterator j = definition.getMessages().values().iterator(); j.hasNext();) - { - Message message = (Message) j.next(); - list.addAll(getPrefixedNames(message.getQName())); - } - } - return list; - } - - public List getDefinitions() - { - List list = new ArrayList(); - addDefinition(rootDefinition, list); - return list; - } - - /** - * @deprecated -- we should always use getPrefixedNames - */ - public String getPrefixedName(QName qname) - { - String name = null; - if (qname != null) - { - String prefix = rootDefinition.getPrefix(qname.getNamespaceURI()); - if (prefix != null) - { - name = prefix + ":" + qname.getLocalPart(); - } - } - return name; - } - - public List getPrefixedNames(QName qname) - { - List list = new ArrayList(); - if (qname != null) - { - Map map = rootDefinition.getNamespaces(); - for (Iterator i = map.keySet().iterator(); i.hasNext();) - { - String prefix = (String) i.next(); - String namespace = (String) map.get(prefix); - if (namespace != null && namespace.equals(qname.getNamespaceURI())) - { - String name = prefix.length() > 0 ? prefix + ":" + qname.getLocalPart() : - qname.getLocalPart(); - list.add(name); - } - } - } - return list; - } - - protected void addDefinition(Definition definition, List list) - { - if (definition != null) - { - list.add(definition); - for (Iterator i = definition.getEImports().iterator(); i.hasNext();) - { - ImportImpl theImport = (ImportImpl) i.next(); - if (theImport.getLocationURI() != null && !theImport.getLocationURI().endsWith("xsd")) - { - theImport.importDefinitionOrSchema(); - Definition importedDefinition = (Definition) theImport.getEDefinition(); - if (importedDefinition != null && !list.contains(importedDefinition)) - { - addDefinition(importedDefinition, list); - } - } - } - } - } - - public static String getPortTypeReference(Binding binding) - { - String result = null; - Element element = WSDLEditorUtil.getInstance().getElementForObject(binding); - if (element != null) - { - result = element.getAttribute("type"); - } - return result; - } - - public static void setPortTypeReference(Binding binding, String portType) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(binding); - if (element != null) - { - element.setAttribute("type", portType); - } - } - - public static String getBindingReference(Port port) - { - String result = null; - Element element = WSDLEditorUtil.getInstance().getElementForObject(port); - if (element != null) - { - result = element.getAttribute("binding"); - } - return result; - } - - public static String getName(Binding binding) - { - String result = null; - Element element = WSDLEditorUtil.getInstance().getElementForObject(binding); - if (element != null) - { - result = element.getAttribute("name"); - } - return result; - } - - public static QName getPortTypeReferenceQName(Binding binding) - { - QName result = null; - Definition definition = binding.getEnclosingDefinition(); - String prefixedName = getPortTypeReference(binding); - if (prefixedName != null) - { - result = WSDLEditorUtil.createQName(definition, prefixedName); - } - return result; - } - - public static QName getBindingReferenceQName(Port port) - { - QName result = null; - Definition definition = port.getEnclosingDefinition(); - String prefixedName = getBindingReference(port); - if (prefixedName != null) - { - result = WSDLEditorUtil.createQName(definition, prefixedName); - } - return result; - } - - public static String getMessageReference(Input input) - { - return getMessageReferenceHelper(input); - } - - public static String getMessageReference(Output output) - { - return getMessageReferenceHelper(output); - } - - public static String getMessageReference(Fault fault) - { - return getMessageReferenceHelper(fault); - } - - public static QName getMessageReferenceQName(Input input) - { - return getMessageReferenceQNameHelper(input); - } - - public static QName getMessageReferenceQName(Output output) - { - return getMessageReferenceQNameHelper(output); - } - - public static QName getMessageReferenceQName(Fault fault) - { - return getMessageReferenceQNameHelper(fault); - } - - protected static String getMessageReferenceHelper(WSDLElement o) - { - String result = null; - Element element = WSDLEditorUtil.getInstance().getElementForObject(o); - if (element != null) - { - result = element.getAttribute("message"); - } - return result; - } - - public static QName getMessageReferenceQNameHelper(WSDLElement o) - { - QName result = null; - Definition definition = o.getEnclosingDefinition(); - String prefixedName = getMessageReferenceHelper(o); - if (prefixedName != null) - { - result = WSDLEditorUtil.createQName(definition, prefixedName); - } - return result; - } - - public static void updatePortTypeReferences(Definition definition) - { - for (Iterator i = definition.getBindings().values().iterator(); i.hasNext();) - { - Binding binding = (Binding) i.next(); - QName qname = ComponentReferenceUtil.getPortTypeReferenceQName(binding); - - PortType portType = (qname != null) ? (PortType) definition.getPortType(qname) : null; - - if (binding.getPortType() != portType) - { - binding.setPortType(portType); - } - } - } - - public static void updateBindingReferences(Definition definition) - { - for (Iterator i = definition.getServices().values().iterator(); i.hasNext();) - { - Service service = (Service) i.next(); - for (Iterator j = service.getEPorts().iterator(); j.hasNext();) - { - Port port = (Port) j.next(); - QName qname = ComponentReferenceUtil.getBindingReferenceQName(port); - - Binding binding = (qname != null) ? (Binding) definition.getBinding(qname) : null; - - if (port.getBinding() != binding) - { - port.setBinding(binding); - } - } - } - } - - public static void updateMessageReferences(Definition definition) - { - // for each port type - // - for (Iterator i = definition.getPortTypes().values().iterator(); i.hasNext();) - { - PortType portType = (PortType) i.next(); - - // for each operation - // - for (Iterator j = portType.getEOperations().iterator(); j.hasNext();) - { - Operation operation = (Operation) j.next(); - - // handle Input - // - Input input = (Input) operation.getInput(); - if (input != null) - { - QName qname = ComponentReferenceUtil.getMessageReferenceQName(input); - Message message = (qname != null) ? (Message) definition.getMessage(qname) : null; - if (input.getMessage() != message) - { - input.setMessage(message); - } - } - - // handle Output - // - Output output = (Output) operation.getOutput(); - if (output != null) - { - QName qname = ComponentReferenceUtil.getMessageReferenceQName(output); - Message message = (qname != null) ? (Message) definition.getMessage(qname) : null; - if (output.getMessage() != message) - { - output.setMessage(message); - } - } - - // handle Faults - // - for (Iterator k = operation.getEFaults().iterator(); k.hasNext();) - { - Fault fault = (Fault) k.next(); - - QName qname = ComponentReferenceUtil.getMessageReferenceQName(fault); - Message message = (qname != null) ? (Message) definition.getMessage(qname) : null; - if (fault.getMessage() != message) - { - fault.setMessage(message); - } - } - } - } - } - - public static void updateSchemaReferences(Definition definition) - { - for (Iterator i = definition.getEMessages().iterator(); i.hasNext();) - { - Message message = (Message) i.next(); - for (Iterator j = message.getEParts().iterator(); j.hasNext();) - { - Part part = (Part) j.next(); - Element element = WSDLEditorUtil.getInstance().getElementForObject(part); - if (element != null) - { - ((WSDLElementImpl)part).elementChanged(element); - } - } - } - } - - public static Operation getOperation(PortType portType, BindingOperation bindingOperation) - { - Operation result = null; - for (Iterator i = portType.getEOperations().iterator(); i.hasNext();) - { - Operation operation = (Operation) i.next(); - if (isMatchingBinding(operation, bindingOperation)) - { - result = operation; - break; - } - } - return result; - } - - public static void updateOperationReference(BindingOperation bindingOperation) - { - Operation operation = computeOperation(bindingOperation); - if (operation != bindingOperation.getOperation()) - { - bindingOperation.setOperation(operation); - } - } - - public List getComponentNameList(boolean isType) - { - List result = Collections.EMPTY_LIST; - ITypeSystemProvider typeSystemProvider = WSDLEditorUtil.getInstance().getTypeSystemProvider(rootDefinition); - if (typeSystemProvider != null) - { - result = isType ? typeSystemProvider.getAvailableTypeNames(rootDefinition, 0) : typeSystemProvider.getAvailableElementNames(rootDefinition); - } - return result; - } - - public static List getComponentNameList(Part part, boolean isType) - { - List result = Collections.EMPTY_LIST; - Definition definition = part.getEnclosingDefinition(); - ITypeSystemProvider typeSystemProvider = WSDLEditorUtil.getInstance().getTypeSystemProvider(definition); - if (typeSystemProvider != null) - { - result = isType ? typeSystemProvider.getAvailableTypeNames(definition, 0) : typeSystemProvider.getAvailableElementNames(definition); - } - return result; - } - - public static boolean isType(Part part) - { - //Element element = WSDLEditorUtil.getInstance().getElementForObject(part); - Element element = part.getElement(); - return !element.hasAttribute("element"); - } - - public static String getPartComponentReference(Part part) - { - //Element element = WSDLEditorUtil.getInstance().getElementForObject(part); - Element element = part.getElement(); - String result = null; - if (element.hasAttribute("type")) - { - result = element.getAttribute("type"); - } - else if (element.hasAttribute("element")) - { - result = element.getAttribute("element"); - } - return result; - } - - public static void setComponentReference(Part part, boolean isType, String componentName) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(part); - String newAttribute = isType ? "type" : "element"; - String oldAttribute = isType ? "element" : "type"; - element.removeAttribute(oldAttribute); - - String value = componentName != null ? componentName : element.getAttribute(newAttribute); - - if (value == null) - { - if (isType) - { - String xsdPrefix = part.getEnclosingDefinition().getPrefix(WSDLConstants.XSD_NAMESPACE_URI); - value = "string"; - if (xsdPrefix != null && xsdPrefix.length() > 0) - { - value = xsdPrefix + ":" + value; - } - } - else - { - List list = getComponentNameList(part, isType); - value = list.size() > 0 ? (String) list.get(0) : "some-element-name"; - } - } - element.setAttribute(newAttribute, value); - } - - public static Operation computeOperation(BindingOperation bindingOperation) - { - Operation result = null; - Binding binding = (Binding) bindingOperation.eContainer(); - PortType portType = (PortType) binding.getPortType(); - if (portType != null) - { - result = getOperation(portType, bindingOperation); - } - return result; - } - - public static Input computeInput(BindingInput bindingInput) - { - Operation operation = computeOperation((BindingOperation) bindingInput.eContainer()); - return operation != null ? operation.getEInput() : null; - } - - public static Output computeOutput(BindingOutput bindingOutput) - { - Operation operation = computeOperation((BindingOperation) bindingOutput.eContainer()); - return operation != null ? operation.getEOutput() : null; - } - - public static Fault computeFault(BindingFault bindingFault) - { - Fault result = null; - Operation operation = computeOperation((BindingOperation) bindingFault.eContainer()); - if (operation != null) - { - for (Iterator i = operation.getEFaults().iterator(); i.hasNext();) - { - Fault fault = (Fault) i.next(); - String faultName = fault.getName(); - if (faultName != null && faultName.equals(bindingFault.getName())) - { - result = fault; - break; - } - } - } - return result; - } - - public static String getPartReferenceValue(Part part) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(part); - String value = null; - if (element != null) - { - if (element.hasAttribute("type")) - { - value = element.getAttribute("type"); - } - else if (element.hasAttribute("element")) - { - value = element.getAttribute("element"); - } - } - return value != null ? value : ""; - } - - public Operation getBindingOperation(Element bindingOperationContent) - { - Operation operation = null; - Node parent = bindingOperationContent.getParentNode(); - if (parent instanceof Element) - { - Object object = WSDLEditorUtil.getInstance().findModelObjectForElement(rootDefinition, (Element) parent); - if (object instanceof BindingOperation) - { - operation = ComponentReferenceUtil.computeOperation((BindingOperation) object); - } - } - return operation; - } - - public Message getBindingOperationInputMessage(Element bindingOperationContent) - { - Message message = null; - Operation operation = getBindingOperation(bindingOperationContent); - if (operation != null) - { - Input input = operation.getEInput(); - if (input != null) - { - message = input.getEMessage(); - } - } - return message; - } - - public Message getBindingOperationOutputMessage(Element bindingOperationContent) - { - Message message = null; - Operation operation = getBindingOperation(bindingOperationContent); - if (operation != null) - { - Output output = operation.getEOutput(); - if (output != null) - { - message = output.getEMessage(); - } - } - return message; - } - - public static String computeRelativeURI(IFile referencedLocation, IFile baseLocation, boolean enableIEStyleReferences) - { - // TODO... we need some extension to allow IE folks to plugin logic to create an 'IE' style path - // TODO... consider using URI class in EMF - return URIHelper.getRelativeURI(referencedLocation.getLocation(), baseLocation.getLocation()); - } - - public static String computeRelativeURI(String referencedLocation, String baseLocation, boolean enableIEStyleReferences) - { - // TODO... we need some extension to allow IE folks to plugin logic to create an 'IE' style path - // TODO... consider using URI class in EMF - return URIHelper.getRelativeURI(referencedLocation, baseLocation); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java deleted file mode 100644 index 5e4eb0218..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.internal.impl.MessageReferenceImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.ui.internal.commands.AddBindingCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddFaultCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddInputCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOperationCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddOutputCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddPartCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddPortCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddPortTypeCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddServiceCommand; -import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDElementDeclarationCommand; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Element; - -public class CreateWSDLElementHelper { - // Constants used for getting Part information - public static final String PART_INFO_ELEMENT_DECLARATION = "ELEMENT_DECLARATION"; - public static final String PART_INFO_TYPE_DEFINITION = "TYPE_DEFINITION"; - - // The following variables should be set if a name other than the computed name is to be used. - public static String serviceName = null; - public static String portName = null; - public static String bindingName = null; - public static String portTypeName = null; - public static String operationName = null; - public static String inputName = null; - public static String outputName = null; - public static String faultName = null; - public static String messageName = null; - public static String partName = null; - - public static String PART_TYPE_OR_DEFINITION = PART_INFO_TYPE_DEFINITION; - public static boolean CREATE_DOWN_TO_PART = true; - -/* - * The following methods creates the 'specified' (by calling a certain method) WSDLElement - * and it's 'children' all the way to the PortType level. - */ - public static Service createService(Definition definition) { - if (serviceName == null || serviceName.trim().equals("")) - serviceName = NameUtil.buildUniqueServiceName(definition); - - CreateWSDLElementHelper.portTypeName = serviceName; - - AddServiceCommand addService = new AddServiceCommand(definition, serviceName, false); - addService.run(); - Service service = (Service) addService.getWSDLElement(); - CreateWSDLElementHelper.createPort(service); - - return service; - } - - public static Port createPort(Service service) { - if (portName == null || portName.trim().equals("")) - portName = NameUtil.buildUniquePortName(service, null); - - AddPortCommand addPort = new AddPortCommand(service, portName); - addPort.run(); - Port port = (Port) addPort.getWSDLElement(); - Binding binding = CreateWSDLElementHelper.createBinding(port.getEnclosingDefinition(), port); - - port.setBinding(binding); - - return port; - } - - public static Binding createBinding(Definition definition, Port port) { - bindingName = port.getName(); - if (bindingName == null || bindingName.trim().equals("")) - bindingName = NameUtil.buildUniqueBindingName(definition, null); - - AddBindingCommand addBinding = new AddBindingCommand(definition, bindingName); - addBinding.run(); - Binding binding = (Binding) addBinding.getWSDLElement(); - PortType portType = CreateWSDLElementHelper.createPortType(binding.getEnclosingDefinition()); - - binding.setPortType(portType); - - return binding; - } - - public static PortType createPortType(Definition definition) { - if (portTypeName == null || portTypeName.trim().equals("")) - portTypeName = NameUtil.buildUniquePortTypeName(definition, "PortType"); - - AddPortTypeCommand addPortTypeCommand = new AddPortTypeCommand(definition, portTypeName); - addPortTypeCommand.run(); - PortType portType = (PortType) addPortTypeCommand.getWSDLElement(); - - if (CREATE_DOWN_TO_PART) { - CreateWSDLElementHelper.createOperation(portType); - } - - return portType; - } - - -/* - * The following methods creates the 'specified' (by calling a certain method) WSDLElement - * and it's 'children' all the way to the Part level. - */ - public static Operation createOperation(PortType portType) { - if (operationName == null || operationName.trim().equals("")) - operationName = NameUtil.buildUniqueOperationName(portType); - - AddOperationCommand action = new AddOperationCommand(portType, operationName); - action.run(); - Operation operation = (Operation) action.getWSDLElement(); - CreateWSDLElementHelper.createOutput(portType, operation); - CreateWSDLElementHelper.createInput(portType, operation, null); - -// ((PortTypeImpl) portType).updateElement(false); - return operation; - } - - public static Input createInput(PortType portType, Operation operation, String inputName) { - if (inputName == null || inputName.trim().equals("")) - inputName = NameUtil.buildUniqueInputName(portType, operation.getName(), ""); - - AddInputCommand action = new AddInputCommand(operation, inputName); - action.run(); - Input input = (Input) action.getWSDLElement(); - Message mess = CreateWSDLElementHelper.createMessage(input); - input.setMessage(mess); - - return input; - } - - public static Output createOutput(PortType portType, Operation operation) { - if (outputName == null || outputName.trim().equals("")) - outputName = NameUtil.buildUniqueOutputName(portType, operation.getName(), ""); - - AddOutputCommand action = new AddOutputCommand(operation, outputName); - action.run(); - Output output = (Output) action.getWSDLElement(); - Message mess = CreateWSDLElementHelper.createMessage(output); - output.setMessage(mess); - - return output; - } - - public static Fault createFault(Operation operation) { - if (faultName == null || faultName.trim().equals("")) - faultName = NameUtil.buildUniqueFaultName(operation); - - AddFaultCommand action = new AddFaultCommand(operation, faultName); - action.run(); - Fault fault = (Fault) action.getWSDLElement(); - Message mess = CreateWSDLElementHelper.createMessage(fault); - fault.setMessage(mess); - - return fault; - } - - public static Message createMessage(MessageReference iof) { - if (messageName == null || messageName.trim().equals("")) - messageName = NameUtil.buildUniqueMessageName(iof.getEnclosingDefinition(), iof); -// messageName = NameUtil.buildMessageName(iof.getName()); - - Definition def = iof.getEnclosingDefinition(); - AddMessageCommand action = new AddMessageCommand(def, messageName); - action.run(); - Message message = (Message) action.getWSDLElement(); - CreateWSDLElementHelper.createPart(message); - Element parentNode = message.getElement(); - if (parentNode instanceof IDOMNode) - { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)parentNode); - } - - messageName = null; - return message; - } - - public static Part createPart(Message message) { - Definition def = message.getEnclosingDefinition(); - String name = NameUtil.buildUniquePartName(message, message.getQName().getLocalPart()); - AddPartCommand action = null; - - if (PART_TYPE_OR_DEFINITION == PART_INFO_TYPE_DEFINITION) { - action = new AddPartCommand(message, name, WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string", true); - } - else if (PART_TYPE_OR_DEFINITION == PART_INFO_ELEMENT_DECLARATION) { - //action = new AddPartCommand(message, name, WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string", true); - String elementName = getNewNameHelper(name, def, false); - AddXSDElementDeclarationCommand elementAction = new AddXSDElementDeclarationCommand(def, elementName); - elementAction.run(); - action = new AddPartCommand(message, name, def.getTargetNamespace(), elementName, false); - } - - action.run(); - - return (Part) action.getWSDLElement(); - } - - /* - * Used to determine a name for an Element - */ - private static String getNewNameHelper(String base, Definition def, boolean isType) - { - String name = base; - int count = 0; - - // Ugly.... Redo this... - // Get a list of Elements... - List elementList = null; - if (def.getETypes() != null) { - List xsdsList = def.getETypes().getEExtensibilityElements(); - if (xsdsList != null) { - Iterator xsdsIterator = xsdsList.iterator(); - XSDSchemaExtensibilityElement xsdElement = (XSDSchemaExtensibilityElement) xsdsIterator.next(); - XSDSchema schema = xsdElement.getSchema(); - if (schema != null) { - elementList = schema.getElementDeclarations(); - } - } - } - - if (elementList != null) { - int index = 0; - while (index < elementList.size()) { - XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) elementList.get(index); - - if (name.equals(elementDeclaration.getName())) { - count++; - name = name + count; - index = 0; - } - else { - index++; - } - } - } - - return name; - } - - /* - * Return the type of Part this WSDLElement should have (Element vs Type). To determine this, we filter up to the 'parent' PortType - * and go down to the first Part we encounter and check the type it has. If this fails, default to Type. - */ - public static String getPartInfo(WSDLElement element) { - String partInfo = null; - - if (element instanceof PortType) { - partInfo = getPartInfo((PortType) element); - } - else if (element instanceof Operation) { - partInfo = getPartInfo(((WSDLElementImpl) element).getContainer()); - } - else if (element instanceof MessageReferenceImpl) { - partInfo = getPartInfo(((WSDLElementImpl) element).getContainer()); - } - - if (partInfo == null) { - partInfo = CreateWSDLElementHelper.PART_INFO_TYPE_DEFINITION; - } - - return partInfo; - } - - private static String getPartInfo(PortType portType) { - String partInfo = null; - - if (portType.getOperations() != null) { - Iterator operationIt = portType.getOperations().iterator(); - while (operationIt.hasNext()) { - Operation op = (Operation) operationIt.next(); - - if (op.getEInput() != null) { - partInfo = getMessageRefPartInfo((MessageReferenceImpl) op.getEInput()); - } - - if (partInfo == null && op.getEOutput() != null) { - partInfo = getMessageRefPartInfo((MessageReferenceImpl) op.getEOutput()); - } - - if (op.getEFaults() != null) { - Iterator faultIt = op.getEFaults().iterator(); - while (partInfo == null && faultIt.hasNext()) { - Fault fault = (Fault) faultIt.next(); - partInfo = getMessageRefPartInfo((MessageReferenceImpl) fault); - } - } - - if (partInfo != null) - break; - } - } - - return partInfo; - } - - private static String getMessageRefPartInfo(MessageReferenceImpl iof) { - String partInfo = null; - - if (iof.getEMessage() != null && iof.getEMessage().getEParts() != null) { - Iterator partIt = iof.getEMessage().getEParts().iterator(); - - while (partInfo == null && partIt.hasNext()) { - Part part = (Part) partIt.next(); - - if (part.getTypeDefinition() != null) { - partInfo = CreateWSDLElementHelper.PART_INFO_TYPE_DEFINITION; - } - else if (part.getElementDeclaration() != null) { - partInfo = CreateWSDLElementHelper.PART_INFO_ELEMENT_DECLARATION; - } - } - } - - return partInfo; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java deleted file mode 100644 index 1778c8c9d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java +++ /dev/null @@ -1,427 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; - -public class NameUtil -{ - /** - * Return a name which is not used by any other fault in the operation. - * @return String - */ - public static String buildUniqueFaultName(Operation operation) - { - return buildUniqueFaultName(operation, "NewFault"); - } - - public static String buildUniqueFaultName(Operation operation, String baseName) { - if (baseName == null) - baseName = "NewFault"; - - List names = getUsedFaultNames(operation); - - // Now search the list until we find an unused name - return getUniqueNameHelper(baseName, names); - } - - /** - * Return a name which is not used by any other input in the portType. Returned name will be of the form: - * <operationName> + <ending> [+ unique Integer] - * @return String - */ - public static String buildUniqueInputName(PortType portType, String operationName, String ending) - { - String name = null; - String candidate = operationName + ending; - - int i = 0; - - // loop until we find a unique name (the name will consist of the operationName + ending + an integer) - while (name == null) - { - boolean unique = true; - - // determine if this combination is unique within the current porttype - for (Iterator it = portType.getEOperations().iterator(); it.hasNext() && unique;) - { - Operation current = (Operation) it.next(); - // TODO : port check - // old if(current.isSetEInput() && current.getEInput().isSetName()) { - if (current.getEInput() != null && current.getEInput().getName() != null) - { - if (current.getEInput().getName().equals(candidate)) - unique = false; - } - } - if (unique) - name = candidate; - else - candidate = operationName + ending + i; - i++; - } - return name; - } - - /** - * Return a name which is not used by any other message in the definition. - * @return String - */ - public static String buildUniqueMessageName(Definition definition, String baseName) - { - if (baseName == null) - { - baseName = "NewMessage"; - } - - List names = getUsedMessageNames(definition); - - // Now search the list until we find an unused name - return getUniqueNameHelper(baseName, names); - } - - /** - * Return a name which is not used by any other operation in the port type. - * @return String - */ - public static String buildUniqueOperationName(PortType portType) - { - return buildUniqueOperationName(portType, "NewOperation"); - } - - public static String buildUniqueOperationName(PortType portType, String baseName) - { - if (baseName == null) { - baseName = "NewOperation"; - } - - List names = getUsedOperationNames(portType); - - // Now search the list until we find an unused name - return getUniqueNameHelper(baseName, names); - } - - /** - * Return a name which is not used by any other output in the portType. Returned name will be of the form: - * <operationName> + <ending> [+ unique Integer] - * @return String - */ - public static String buildUniqueOutputName(PortType portType, String operationName, String ending) - { - String name = null; - String candidate = operationName + ending; - - int i = 0; - - // loop until we find a unique name (the name will consist of the operationName + ending + an integer) - while (name == null) - { - boolean unique = true; - - // determine if this combination is unique within the current porttype - for (Iterator it = portType.getEOperations().iterator(); it.hasNext() && unique;) - { - Operation current = (Operation) it.next(); - // TODO: port check - // old if(current.isSetEOutput() && current.getEOutput().isSetName()) { - if (current.getEOutput() != null && current.getEOutput().getName() != null) - { - if (current.getEOutput().getName().equals(candidate)) - unique = false; - } - } - if (unique) - name = candidate; - else - candidate = operationName + ending + i; - i++; - } - return name; - } - - /** - * Return a name which is not used by any other part in the message. - * @return String - */ - public static String buildUniquePartName(Message message) - { - List names = getUsedPartNames(message); - - // Now search the list until we find an unused name - return getUniqueNameHelper("NewPart", names); - } - - public static String buildUniquePartName(Message message, String baseName) - { - if (baseName == null) - { - baseName = "NewPart"; - } - - List names = getUsedPartNames(message); - - // Now search the list until we find an unused name - return getUniqueNameHelper(baseName, names); - } - - /** - * Return a name which is not used by any other port type in the definition. - * @return String - */ - public static String buildUniquePortTypeName(Definition definition, String baseName) - { - if (baseName == null) - { - baseName = "NewPortType"; - } - - List names = getUsedPortTypeNames(definition); - - // Now search the list until we find an unused name - return getUniqueNameHelper(baseName, names); - } - - public static String getUniqueNameHelper(String baseName, List names) - { - int i = 0; - - String name = baseName; - while (true) - { - if (!names.contains(name)) - { - break; - } - i++; - name = baseName + i; - } - - return name; - } - - /** - * Return a name which is not used by any other service in the definition. - * @return String - */ - public static String buildUniqueServiceName(Definition definition) - { - List names = getUsedServiceNames(definition); - - // Now search the list until we find an unused name - return getUniqueNameHelper("NewService", names); - } - - /** - * Return a name which is not used by any other binding in the definition. - * @return String - */ - public static String buildUniqueBindingName(Definition definition, String baseName) - { - if (baseName == null) - { - baseName = "NewBinding"; - } - - List names = getUsedBindingNames(definition); - - return getUniqueNameHelper(baseName, names); - } - - public static String buildUniquePrefix(Definition definition, String basePrefix) - { - String prefix = basePrefix; - for (int i = 1; definition.getNamespace(prefix) != null; i++) - { - prefix = basePrefix + i; - } - return prefix; - } - - public static String buildUniquePortName(Service service, String baseName) - { - if (baseName == null) - { - baseName = "NewPort"; - } - - List names = getUsedPortNames(service); - - return getUniqueNameHelper(baseName, names); - } - - public static String buildUniqueMessageName(Definition definition, MessageReference messRef) - { - String name = null; - if (messRef instanceof Input) - { - name = createOperationName(messRef, "Request"); - } - else if (messRef instanceof Output) - { - name = createOperationName(messRef, "Response"); - } - else if (messRef instanceof Fault) - { - String faultName = ((Fault) messRef).getName(); - if (faultName == null || faultName.length() == 0) - { - faultName = "Fault"; - } - name = createOperationName(messRef, faultName); - } - - return NameUtil.buildUniqueMessageName(definition, name); - } - - - public static List getUsedFaultNames(Operation operation) { - ArrayList names = new ArrayList(); - for (Iterator i = operation.getEFaults().iterator(); i.hasNext();) - { - Fault fault = (Fault) i.next(); - names.add(fault.getName()); - } - - return names; - } - - public static List getUsedOperationNames(PortType portType) { - ArrayList names = new ArrayList(); - for (Iterator i = portType.getEOperations().iterator(); i.hasNext();) - { - Operation op = (Operation) i.next(); - names.add(op.getName()); - } - - return names; - } - - public static List getUsedPartNames(Message message) { - ArrayList names = new ArrayList(); - for (Iterator i = message.getEParts().iterator(); i.hasNext();) - { - Part part = (Part) i.next(); - names.add(part.getName()); - } - return names; - } - - public static List getUsedPortTypeNames(Definition definition) { - ArrayList names = new ArrayList(); - for (Iterator i = definition.getEPortTypes().iterator(); i.hasNext();) - { - PortType portType = (PortType) i.next(); - // TODO: port check - // if (portType.isSetQName()) - if (portType.getQName() != null) - { - names.add(portType.getQName().getLocalPart()); - } - } - - return names; - - } - public static List getUsedServiceNames(Definition definition) { - // First build a list of names already used - ArrayList names = new ArrayList(); - for (Iterator i = definition.getEServices().iterator(); i.hasNext();) - { - Service service = (Service) i.next(); - // TODO: port check - // if(service.isSetQName()) - if (service.getQName() != null) - names.add(service.getQName().getLocalPart()); - } - - return names; - } - - public static List getUsedMessageNames(Definition definition) { - ArrayList names = new ArrayList(); - for (Iterator i = definition.getEMessages().iterator(); i.hasNext();) - { - Message msg = (Message) i.next(); - // TODO: port check - if (msg.getQName() != null) - // if(msg.isSetQName()) - names.add(msg.getQName().getLocalPart()); - } - - return names; - } - - public static List getUsedBindingNames(Definition definition) { - ArrayList names = new ArrayList(); - for (Iterator i = definition.getEBindings().iterator(); i.hasNext();) - { - Binding binding = (Binding) i.next(); - // TODO: port check - // if (binding.isSetQName()) - if (binding.getQName() != null) - { - names.add(binding.getQName().getLocalPart()); - } - } - - return names; - } - - public static List getUsedPortNames(Service service) { - // First build a list of names already used - ArrayList names = new ArrayList(); - for (Iterator i = service.getEPorts().iterator(); i.hasNext();) - { - Port port = (Port) i.next(); - - if (port.getName() != null) - { - names.add(port.getName()); - } - } - - return names; - } - - private static String createOperationName(Object object, String suffix) - { - String result = null; - if (object instanceof EObject) - { - EObject parent = ((EObject)object).eContainer(); - if (parent instanceof Operation) - { - result = ((Operation)parent).getName(); - } - } - if (result != null) - { - result += suffix; - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java deleted file mode 100644 index 144c9ad3d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.INodeAssociationProvider; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class NodeAssociationManager -{ - protected WSDLEditorExtension[] extensions; - protected INodeAssociationProvider[] providers; - - public NodeAssociationManager() - { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - extensions = registry.getRegisteredExtensions(WSDLEditorExtension.NODE_ASSOCIATION_PROVIDER); - providers = new INodeAssociationProvider[extensions.length]; - for (int i = 0; i < extensions.length; i++) - { - providers[i] = (INodeAssociationProvider)extensions[i].createExtensionObject(WSDLEditorExtension.NODE_ASSOCIATION_PROVIDER, null); - } - } - - protected INodeAssociationProvider getAppicableProvider(Object object) - { - INodeAssociationProvider provider = null; - for (int i = 0; i < extensions.length; i++) - { - if (extensions[i].isApplicable(object)) - { - provider = providers[i]; - if (provider != null) - { - break; - } - } - } - return provider; - } - - - public Object getModelObjectForNode(Object rootObject, Element targetNode) - { - int currentIndex = 0; - - Element[] elementChain = getParentElementChain((Element)targetNode); - - INodeAssociationProvider p = getAppicableProvider(rootObject); - if (p != null) - { - Node rootObjectNode = p.getNode(rootObject); - - while (currentIndex < elementChain.length) - { - Element e = elementChain[currentIndex]; - if (e == rootObjectNode) - { - currentIndex++; - break; - } - currentIndex++; - } - } - - Object currentObject = rootObject; - int end[] = new int[1]; - - while (currentIndex < elementChain.length) - { - p = getAppicableProvider(currentObject); - if (p != null) - { - end[0] = elementChain.length; - currentObject = p.getModelObject(currentObject, elementChain, currentIndex, end); - - if (currentObject == null) - { - // failure - break; - } - else - { - currentIndex = Math.max(end[0], currentIndex + 1); - } - } - else - { - break; - } - } - - return (currentIndex == elementChain.length) ? currentObject : null; - } - - - public Node getNode(Object modelObject) - { - Node result = null; - if (modelObject instanceof Node) - { - result = (Node)modelObject; - } - else - { - INodeAssociationProvider p = getAppicableProvider(modelObject); - if (p != null) - { - result = p.getNode(modelObject); - } - } - return result; - } - - protected Element[] getParentElementChain(Element element) - { - List list = new ArrayList(); - while (element != null) - { - list.add(0, element); - Node node = element.getParentNode(); - element = (node != null && node.getNodeType() == Node.ELEMENT_NODE) ? (Element)node : null; - } - - int listSize = list.size(); - Element[] result = new Element[listSize]; - for (int i = 0; i < listSize; i++) - { - result[i] = (Element)list.get(i); - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java deleted file mode 100644 index bfa7fd1f6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -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.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -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; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.ImportImpl; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -public class OpenOnSelectionHelper extends WSDLSwitch -{ - Definition definition; - Attr attr = null; - Element element = null; - - public OpenOnSelectionHelper(Definition definition) - { - this.definition = definition; - } - - public void openEditor(EObject eObject) - { - String[] array = computeSpecification(eObject); - if (array != null) - { - openEditor(array[0], array[1]); - } - } - - public void openEditor(Node node) - { - String[] array = computeSpecification(node); - if (array != null) - { - openEditor(array[0], array[1]); - } - } - - protected void openEditor(String resource, String spec) - { - String pattern = "platform:/resource"; - if (resource != null && resource.startsWith(pattern)) - { - try - { - Path path = new Path(resource.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 (resource.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) - { - } - } - - Class theClass = editorPart.getClass(); - Class[] methodArgs = { String.class }; - Method method = theClass.getMethod("openOnSelection", methodArgs); - Object args[] = { spec }; - method.invoke(editorPart, args); - workbenchPage.getNavigationHistory().markLocation(editorPart); - } - catch (Exception e) - { - } - } - } - - public String[] computeSpecification(EObject eObject) - { - String[] result = null; - Object referencedObject = doSwitch(eObject); - if (referencedObject instanceof EObject) - { - EObject referencedEObject = (EObject)referencedObject; - if (referencedEObject != eObject || - referencedEObject.eResource() != definition.eResource()) - { - - Resource resource = referencedEObject.eResource(); - if (resource != null) - { - result = new String[2]; - result[0] = resource.getURI().toString(); - result[1] = resource.getURIFragment(referencedEObject); - } - } - } - return result; - } - - public String[] computeSpecification(Node node) - { - String[] result = null; - switch (node.getNodeType()) - { - case Node.ELEMENT_NODE : - { - element = (Element)node; - break; - } - case Node.ATTRIBUTE_NODE : - { - attr = (Attr)node; - element = attr.getOwnerElement(); - break; - } - case Node.TEXT_NODE : - { - Node parent = node.getParentNode(); - element = (parent instanceof Element) ? (Element)parent : null; - break; - } - } - if (element != null) - { - Object object = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, element); - if (object instanceof EObject) - { - result = computeSpecification((EObject)object); - } - } - return result; - } - - public Object caseBinding(Binding binding) - { - Object result = binding; - if (isMatchingAttribute(WSDLConstants.TYPE_ATTRIBUTE)) - { - result = binding.getEPortType(); - } - return result; - } - - public Object caseDefinition(Definition definition) - { - return definition; - } - - public Object casePart(Part part) - { - Object result = part; - if (attr != null) - { - if (isMatchingAttribute(WSDLConstants.TYPE_ATTRIBUTE)) - { - result = part.getTypeDefinition(); - } - else if (isMatchingAttribute(WSDLConstants.ELEMENT_ATTRIBUTE)) - { - result = part.getElement(); - } - } - else if (part.getEnclosingDefinition() == definition) - { - result = part.getTypeDefinition() != null ? (Object)part.getTypeDefinition() : (Object)part.getElement(); - } - return result; - } - - public Object casePort(Port port) - { - Object result = port; - if (isMatchingAttribute(WSDLConstants.BINDING_ATTRIBUTE)) - { - result = port.getEBinding(); - - } - return result; - } - - public Object caseFault(Fault fault) - { - Object result = fault; - if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE)) - { - result = fault.getMessage(); - } - return result; - } - - public Object caseInput(Input input) - { - Object result = input; - if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE)) - { - result = input.getMessage(); - } - return result; - } - - public Object caseOutput(Output output) - { - Object result = output; - - if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE)) - { - result = output.getMessage(); - } - return result; - } - - public Object caseImport(Import theImport) - { - Object result = null; - - // For now, look at the file extension. When bugzilla 118293 is fixed, look at - // the Import's eDefinition and eSchema instead. - Path importPath = new Path(theImport.getLocationURI()); - String extension = importPath.getFileExtension(); - if (extension.equalsIgnoreCase("xsd")) { - if (theImport.getESchema() == null) { - ((ImportImpl)theImport).importDefinitionOrSchema(); - } - - result = theImport.getESchema(); - } - else if (extension.equalsIgnoreCase("wsdl")) { - if (theImport.getEDefinition() == null) { - ((ImportImpl)theImport).importDefinitionOrSchema(); - } - - result = theImport.getEDefinition(); - } - - -// if (theImport.getESchema() != null) { -// result = theImport.getESchema(); -// } -// else if (theImport.getEDefinition() != null) { -// result = theImport.getEDefinition(); -// } -// else { -// // Need to resolve imports because the model doesn't automatically -// // do it for us -// ((ImportImpl)theImport).importDefinitionOrSchema(); -// result = theImport.getESchema(); -// } - - return result; - } - - public Object caseWSDLElement(WSDLElement wsdlElement) - { - return wsdlElement; - } - - private boolean isMatchingAttribute(String value) - { - return attr != null && value.equals(attr.getName()); - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java deleted file mode 100644 index 8f4153964..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java +++ /dev/null @@ -1,363 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLPackage; -import org.eclipse.wst.wsdl.internal.util.WSDLSwitch; - - -public class ReferenceManager -{ - protected static InternalAdapterFactory internalAdapterFactory = new InternalAdapterFactory(); - - - public interface Listener - { - public void bindingsChanged( Operation operation); - } - - - public static void adaptDefinition(Definition definition) - { - internalAdapterFactory.adapt(definition); - for (Iterator i = definition.getEBindings().iterator(); i.hasNext(); ) - { - Binding binding = (Binding)i.next(); - internalAdapterFactory.adaptBinding(binding); - } - } - - - public static void addBindingListener(Operation operation, Listener listener) - { - OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation); - if (adapter != null) - { - adapter.addListener(listener); - } - } - - - public static void removeBindingListener(Operation operation, Listener listener) - { - OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation); - if (adapter != null) - { - adapter.removeListener(listener); - } - } - - protected static void fireNotificationForPortType(PortType portType) - { - // get the adapter for each operation and notify listeners - if (portType != null) - { - for (Iterator i = portType.getEOperations().iterator(); i.hasNext(); ) - { - fireNotificationForOperation((Operation)i.next()); - } - } - } - - - protected static void fireNotificationForOperation(Operation operation) - { - if (operation != null) - { - OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation); - adapter.fireBindingsChanged(); - } - } - - - public static class InternalAdapterFactory extends AdapterFactoryImpl - { - public Adapter createAdapter(Notifier target) - { - WSDLSwitch wsdlSwitch = new WSDLSwitch() - { - public Object caseBinding(Binding binding) - { - return createBindingAdapter(); - } - - public Object caseBindingFault(BindingFault bindingFault) - { - return createBindingFaultAdapter(); - } - - public Object caseBindingOperation(BindingOperation bindingOperation) - { - return createBindingOperationAdapter(); - } - - public Object caseDefinition(Definition definition) - { - return createDefinitionAdapter(); - } - - public Object caseOperation(Operation operation) - { - return createOperationAdapter(); - } - }; - - Object o = wsdlSwitch.doSwitch((EObject)target); - - Adapter result = null; - if (o instanceof Adapter) - { - result = (Adapter)o; - } - else - { - System.out.println("did not create adapter for target : " + target); - Thread.dumpStack(); - } - //System.out.println("createAdapter(" + target + ") " + result); - return result; - } - - - public Adapter createBindingAdapter() - { - return new BindingAdapter(); - } - - public Adapter createBindingFaultAdapter() - { - return new BindingFaultAdapter(); - } - - public Adapter createBindingOperationAdapter() - { - return new BindingOperationAdapter(); - } - - public Adapter createDefinitionAdapter() - { - return new DefinitionAdapter(); - } - - public Adapter createOperationAdapter() - { - return new OperationAdapter(); - } - - public Adapter adapt(Notifier target) - { - return target != null ? adapt(target, internalAdapterFactory) : null; - } - - protected void adaptBinding(Binding binding) - { - adapt(binding); - for (Iterator i = binding.getEBindingOperations().iterator(); i.hasNext(); ) - { - BindingOperation bindingOperation = (BindingOperation)i.next(); - adapt(bindingOperation); - for (Iterator j = bindingOperation.getEBindingFaults().iterator(); j.hasNext(); ) - { - BindingFault bindingFault = (BindingFault)j.next(); - adapt(bindingFault); - } - } - } - } - - - protected static abstract class BaseAdapter extends AdapterImpl - { - public boolean isAdapterForType(Object type) - { - return type == internalAdapterFactory; - } - - public WSDLPackage getPackage() - { - return WSDLPackage.eINSTANCE; - } - } - - - // DefinitionAdapter - // - protected static class DefinitionAdapter extends BaseAdapter - { - public void notifyChanged(Notification msg) - { - if ((EStructuralFeature)msg.getFeature() == getPackage().getDefinition_EBindings()) - { - Object newValue = msg.getNewValue(); - switch (msg.getEventType()) - { - case Notification.ADD: - { - handleAdd((Binding)newValue); - break; - } - case Notification.ADD_MANY: - { - for (Iterator newValues = ((Collection)newValue).iterator(); newValues.hasNext(); ) - { - handleAdd((Binding)newValues.next()); - } - break; - } - } - } - } - - protected void handleAdd(Binding binding) - { - internalAdapterFactory.adaptBinding(binding); - PortType portType = binding.getEPortType(); - if (portType != null) - { - fireNotificationForPortType(portType); - } - } - } - - - protected static class BindingAdapter extends BaseAdapter - { - public void notifyChanged(Notification msg) - { - if ((EStructuralFeature)msg.getFeature() == getPackage().getBinding_EPortType()) - { - // fireNotifcation for all of the operation of the old and new portType - fireNotificationForPortType((PortType)msg.getNewValue()); - fireNotificationForPortType((PortType)msg.getOldValue()); - } - else if ((EStructuralFeature)msg.getFeature() == getPackage().getBinding_EBindingOperations()) - { - // fireNotifcation for all operations that were added or removed - Object newValue = msg.getNewValue(); - Object oldValue = msg.getNewValue(); - switch (msg.getEventType()) - { - case Notification.ADD: - { - handleAdd((BindingOperation)newValue); - break; - } - case Notification.ADD_MANY: - { - for (Iterator newValues = ((Collection)newValue).iterator(); newValues.hasNext(); ) - { - handleAdd((BindingOperation)newValues.next()); - } - break; - } - case Notification.REMOVE: - { - handleRemove((BindingOperation)oldValue); - break; - } - case Notification.REMOVE_MANY: - { - for (Iterator oldValues = ((Collection)oldValue).iterator(); oldValues.hasNext(); ) - { - handleRemove((BindingOperation)oldValues.next()); - } - break; - } - } - } - } - - protected void handleAdd(BindingOperation bindingOperation) - { - internalAdapterFactory.adapt(bindingOperation); - Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation); - fireNotificationForOperation(operation); - } - - protected void handleRemove(BindingOperation bindingOperation) - { - if (bindingOperation != null) - { - Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation); - fireNotificationForOperation(operation); - } - } - } - - - - protected static class BindingOperationAdapter extends BaseAdapter - { - public void notifyChanged(Notification msg) - { - BindingOperation bindingOperation = (BindingOperation)getTarget(); - Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation); - fireNotificationForOperation(operation); - } - } - - - protected static class BindingFaultAdapter extends BaseAdapter - { - public void notifyChanged(Notification msg) - { - BindingFault bindingFault = (BindingFault)getTarget(); - BindingOperation bindingOperation = (BindingOperation)bindingFault.eContainer(); - Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation); - fireNotificationForOperation(operation); - } - } - - - protected static class OperationAdapter extends BaseAdapter - { - protected Definition definition; - protected List listeners = new ArrayList(); - - public void addListener(Listener listener) - { - listeners.add(listener); - } - - public void removeListener(Listener listener) - { - listeners.remove(listener); - } - - public void fireBindingsChanged() - { - Operation operation = (Operation)getTarget(); - for (Iterator i = listeners.iterator(); i.hasNext(); ) - { - Listener listener = (Listener)i.next(); - listener.bindingsChanged(operation); - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java deleted file mode 100644 index 9f1fda475..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -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; - -// This class is used to help syncronize selections between two models. -// -public abstract class SelectionAdapter implements ISelectionProvider -{ - protected List listenerList = new ArrayList(); - protected ISelection selection = new StructuredSelection(); - protected ISelectionProvider eventSource; - - public void setEventSource(ISelectionProvider eventSource) - { - this.eventSource = eventSource; - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.add(listener); - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.remove(listener); - } - - public ISelection getSelection() - { - return selection; - } - - /** - * This method should be specialized to return the correct object that corresponds to the 'other' model - */ - abstract protected Object getObjectForOtherModel(Object object); - - - public void setSelection(ISelection modelSelection) - { - List otherModelObjectList = new ArrayList(); - if (modelSelection instanceof IStructuredSelection) - { - for (Iterator i = ((IStructuredSelection)modelSelection).iterator(); i.hasNext(); ) - { - Object modelObject = i.next(); - Object otherModelObject = getObjectForOtherModel(modelObject); - if (otherModelObject != null) - { - otherModelObjectList.add(otherModelObject); - } - } - } - - StructuredSelection nodeSelection = new StructuredSelection(otherModelObjectList); - selection = nodeSelection; - SelectionChangedEvent event = new SelectionChangedEvent(eventSource != null ? eventSource : this, nodeSelection); - - for (Iterator i = listenerList.iterator(); i.hasNext(); ) - { - ISelectionChangedListener listener = (ISelectionChangedListener)i.next(); - listener.selectionChanged(event); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java deleted file mode 100644 index 677932219..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java +++ /dev/null @@ -1,405 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import org.eclipse.wst.common.ui.internal.UIPlugin; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class ValidateHelper -{ - // XML Lang can have many different valid formats - // 1) xx ie. en, fr, de - // 2) xx-xx ie. en-US, en-FR - // 3) I-xx ie. I-en - // 4) X-xx ie. X-en - public static String checkXMLLang(String lang) - { - if (lang.length() == 0) - return null; - - if (lang.length() == 1) - { - char ch0 = lang.charAt(0); - if ((ch0 >= 'a' && ch0 <= 'z') || (ch0 >= 'A' && ch0 <= 'Z')) - return UIPlugin.getResourceString("_WARN_LANG_TOO_SHORT"); - else - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - } - - int offset; - - char ch0 = lang.charAt(0); - if (lang.charAt(1) == '-') - { - if (ch0 == 'i' || ch0 == 'I' || ch0 == 'x' || ch0 == 'X') - offset = 1; - else - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - } - else - { - char ch1 = lang.charAt(1); - if ((ch0 >= 'a' && ch0 <= 'z') || (ch0 >= 'A' && ch0 <= 'Z')) - if ((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) - offset = 2; - else - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch1 + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - else - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - } - - if (lang.length() > offset) - { - char ch = lang.charAt(offset++); - if (ch != '-') - return UIPlugin.getResourceString("_WARN_HYPHEN_NEEDED") + Integer.toString(offset-1); - else - { - while (true) - { - if (ch == '-') - { - if (lang.length() == offset) - return UIPlugin.getResourceString("_WARN_HYPHEN_ENDING"); - - ch = lang.charAt(offset++); - if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')) - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - - if (lang.length() == offset) - return null; - } - else if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')) - return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch + - UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END"); - else if (lang.length() == offset) - return null; - ch = lang.charAt(offset++); - } - } - } - - return null; - } - - /** - * Check to see if the min value is correct. - * A minimum value must be non-negative and < maxValue - */ - public static String isValidMinValue(String minValue, String maxValue) - { - int min; - - if (minValue == null || minValue.equals("")) - { - // Nothing to check - return null; - } - - try - { - min = Integer.parseInt(minValue); - } - catch (NumberFormatException ex) - { - return UIPlugin.getResourceString("_ERROR_MIN_NOT_POSITIVE"); - } - - if (min < 0) - { - return UIPlugin.getResourceString("_ERROR_MIN_NOT_POSITIVE"); - } - - try - { - int max = Integer.parseInt(maxValue); - if (min > max) - { - return UIPlugin.getResourceString("_ERROR_MIN_VALUE"); - } - } - catch (NumberFormatException ex) - { - // Max is not accurate. Don't compare it. - } - return null; - } - - /** - * Check to see if the max value is correct. - * A maximum value must be non-negative and > minValue - * - * It can also be set the string "unbounded" - */ - public static String isValidMaxValue(String maxValue, String minValue) - { - int max; - - if (maxValue == null || maxValue.equals("")) - { - // Nothing to check - return null; - } - - if (maxValue.equals("unbounded")) - { - return null; - } - - try - { - max = Integer.parseInt(maxValue); - } - catch (NumberFormatException ex) - { - return UIPlugin.getResourceString("_ERROR_MAX_NOT_POSITIVE"); - } - - if (max < 0) - { - return UIPlugin.getResourceString("_ERROR_MAX_NOT_POSITIVE"); - } - - try - { - int min = Integer.parseInt(minValue); - if (max < min) - { - return UIPlugin.getResourceString("_ERROR_MAX_VALUE"); - } - } - catch (NumberFormatException ex) - { - // Min is not accurate. Don't compare it. - } - return null; - } - - /** - * Validate the name conforms to the XML spec - */ - public static String checkXMLName(String name, boolean allowEntityRef) - { - int length = name.length(); - char character; - - if (length == 0) - { - return WSDLEditorPlugin.getWSDLString("_WARN_NAME_MUST_CONTAIN_AT_LEAST_ONE_CHAR"); - } - - if (name.indexOf(" ") >= 0) - { - return(WSDLEditorPlugin.getWSDLString("_WARN_NAME_HAS_SPACE")); - } - - int index = 0; - if (length > 0 && - name.charAt(0) == '%') - { - if (allowEntityRef) - { - // skip over the first character - index++; - } // end of if () - else - { - return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_FIRST"); - } // end of else - } - - for(; index < length; index++) - { - character = name.charAt(index); - - if(index == 0) - { - if( !isXMLNameStart(character) ) - { - return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_FIRST"); - } - } - else - { - if(!isXMLNameChar(character)) - { - if ((index == length - 1) && //check if the last character is a ';' - allowEntityRef && - character == ';') - { - // we're still ok then - continue; - } // end of if () - else - { - return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_CHAR") + character + - WSDLEditorPlugin.getWSDLString("_UI_NAME_INVALID_CHAR_END"); - } // end of else - } - } - } - return null; - } - - /** - * Validate the name conforms to the XML spec - */ - public static String checkXMLName(String name) - { - return checkXMLName(name, false); - } - - /** - * isXMLNameStart - **/ - private static boolean isXMLNameStart(char ch) - { - return (ch == '_' || ch == ':' || Character.isLetter(ch) ); - } - - /** - * isXMLNameChar - **/ - private static boolean isXMLNameChar(char ch) - { - return (Character.isLetterOrDigit(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':'); - } - - /** - * isXMLPrefixStart - **/ -// private static boolean isXMLPrefixStart(char ch) -// { -// return (ch == '_' || Character.isLetter(ch) ); -// } - - /** - * isXMLPrefixChar - **/ - private static boolean isXMLPrefixChar(char ch) - { - return (Character.isLetterOrDigit(ch) || ch == '.' || ch == '-' || ch == '_'); - } - - /** - * parseElementText - */ - public static String parseElementText(String text) - { - if (text.indexOf('<') != -1 || text.indexOf('>') != -1) - { - return UIPlugin.getResourceString("_WARN_ELEMENT_INVALID_CHAR"); - } - return null; - } - - /** - * parseAttributeValue - */ - public static String parseAttributeValue(String value) - { - if (value.indexOf('"') != -1 || value.indexOf('<') != -1 || value.indexOf('>') != -1) - { - return UIPlugin.getResourceString("_WARN_ATTRIBUTE_INVALID_CHAR"); - - } - return null; - } - - /** - * parseADATASection - */ - public static String parseCDATASection(String section) - { - if (section.indexOf("]]>") != -1) - { - return UIPlugin.getResourceString("_WARN_CDATA_INVALID_STRING"); - - } - return null; - } - - /** - * parseProcessiingInstruction - */ - public static String parseProcessingInstructionData(String data) - { - if (data.indexOf("?>") != -1) - { - return UIPlugin.getResourceString("_WARN_PROCESSING_INVALID_STRING"); - - } - return null; - } - - /** - * parseProcessingInstructionTarget - */ - public static String parseProcessingInstructionTarget(String target) - { - if (target.length() == 3 && (target.indexOf("XML") != -1 || target.indexOf("XMl") != -1 || target.indexOf("XmL") != -1 || - target.indexOf("xML") != -1 || target.indexOf("Xml") != -1 || target.indexOf("xMl") != -1 || - target.indexOf("xmL") != -1 || target.indexOf("xml") != -1)) - { - return UIPlugin.getResourceString("_WARN_PROCESSING_TARGET_INVALID_STRING"); - - } - return checkXMLName(target); - } - - /** - * parsComment - */ - public static String parseComment(String comment) - { - if (comment.indexOf("--") != -1) - { - return UIPlugin.getResourceString("_WARN_COMMENT_INVALID_STRING"); - } - return null; - } - - /** - * Validate the prefix conforms to the XML spec - */ - public static String checkXMLPrefix(String prefix) - { - int length = prefix.length(); - if (length == 0) - { - return null; - } - char character; - - if (prefix.indexOf(" ") >= 0) - { - return(UIPlugin.getResourceString("_WARN_PREFIX_HAS_SPACE")); - } - - for(int index = 0; index < length; index++) - { - character = prefix.charAt(index); - - if(!isXMLPrefixChar(character)) - { - return UIPlugin.getString("_WARN_PREFIX_INVALID_CHAR", String.valueOf(character)); - } - } - return null; - } - -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java deleted file mode 100644 index 2fa47f748..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibleElement; -import org.eclipse.wst.wsdl.MessageReference; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider; -import org.eclipse.wst.wsdl.ui.internal.typesystem.ExtensibleTypeSystemProvider; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class WSDLEditorUtil extends WSDLConstants -{ - protected static WSDLEditorUtil instance; - protected NodeAssociationManager nodeAssociationManager = new NodeAssociationManager(); - - protected HashMap elementNameToTypeMap = new HashMap(); - - public static final int ELEMENT = 14; - public static final int TYPE = 15; - - public static WSDLEditorUtil getInstance() - { - if (instance == null) - { - instance = new WSDLEditorUtil(); - } - return instance; - } - - public WSDLEditorUtil() - { - elementNameToTypeMap.put(BINDING_ELEMENT_TAG, new Integer(BINDING)); - elementNameToTypeMap.put(DEFINITION_ELEMENT_TAG, new Integer(DEFINITION)); - elementNameToTypeMap.put(DOCUMENTATION_ELEMENT_TAG, new Integer(DOCUMENTATION)); - elementNameToTypeMap.put(FAULT_ELEMENT_TAG, new Integer(FAULT)); - elementNameToTypeMap.put(IMPORT_ELEMENT_TAG, new Integer(IMPORT)); - elementNameToTypeMap.put(INPUT_ELEMENT_TAG, new Integer(INPUT)); - elementNameToTypeMap.put(MESSAGE_ELEMENT_TAG, new Integer(MESSAGE)); - elementNameToTypeMap.put(OPERATION_ELEMENT_TAG, new Integer(OPERATION)); - elementNameToTypeMap.put(OUTPUT_ELEMENT_TAG, new Integer(OUTPUT)); - elementNameToTypeMap.put(PART_ELEMENT_TAG, new Integer(PART)); - elementNameToTypeMap.put(PORT_ELEMENT_TAG, new Integer(PORT)); - elementNameToTypeMap.put(PORT_TYPE_ELEMENT_TAG, new Integer(PORT_TYPE)); - elementNameToTypeMap.put(SERVICE_ELEMENT_TAG, new Integer(SERVICE)); - elementNameToTypeMap.put(TYPES_ELEMENT_TAG, new Integer(TYPES)); - } - - public int getWSDLType(Element element) - { - int result = -1; - - Integer integer = (Integer)elementNameToTypeMap.get(element.getLocalName()); - if (integer != null) - { - result = integer.intValue(); - } - return result; - } - - protected List getParentElementChain(Element element) - { - List list = new ArrayList(); - while (element != null) - { - list.add(0, element); - Node node = element.getParentNode(); - element = (node != null && node.getNodeType() == Node.ELEMENT_NODE) ? (Element)node : null; - } - return list; - } - - public Object findModelObjectForElement(Definition definition, Element targetElement) - { - Object o = nodeAssociationManager.getModelObjectForNode(definition, targetElement); - return o; - } - - public Element getElementForObject(Object o) - { - return ((org.eclipse.wst.wsdl.WSDLElement)o).getElement(); - } - - public Node getNodeForObject(Object o) - { - return nodeAssociationManager.getNode(o); - } - - // Provide a mapping between Definitions and ITypeSystemProviders - private Hashtable typeSystemProviders = new Hashtable(); - private ITypeSystemProvider typeSystemProvider; - - public ITypeSystemProvider getTypeSystemProvider(Definition definition) - { - if (typeSystemProvider == null) { - typeSystemProvider = new ExtensibleTypeSystemProvider(); - } - return typeSystemProvider; - } - - public void setTypeSystemProvider(Definition definition, ITypeSystemProvider typeSystemProvider) - { - // typeSystemProviders.put(definition,typeSystemProvider); - } - - public static QName createQName(Definition definition, String prefixedName) - { - QName qname = null; - if (prefixedName != null) - { - int index = prefixedName.indexOf(":"); - String prefix = (index == -1) ? null : prefixedName.substring(0, index); - if (prefix != null) - { - String namespace = definition.getNamespace(prefix); - if (namespace != null) - { - String localPart = prefixedName.substring(index + 1); - qname = new QName(namespace, localPart); - } - } - } - return qname; - } - - public List getExtensibilityElementNodes(ExtensibleElement extensibleElement) - { - // For Types, I need to get all the schemas - if (extensibleElement instanceof Types) - { - Types xsdEE = (Types)extensibleElement; - return xsdEE.getSchemas(); - } - /* - List childList = new ArrayList(); - - Element parentElement = getElementForObject(extensibleElement); - if (parentElement != null) - { - - NodeList nodeList = parentElement.getChildNodes(); - int nodeListLength = nodeList.getLength(); - for (int i = 0; i < nodeListLength; i++) - { - childList.add(nodeList.item(i)); - } - HashMap extensibleElementTable = new HashMap(); - for (Iterator i = extensibleElement.getEExtensibilityElements().iterator(); i.hasNext();) - { - ExtensibilityElement extensibilityElement = (ExtensibilityElement)i.next(); - if (extensibilityElement != null) - { - Element element = getElementForObject(extensibilityElement); - if (element != null) - { - extensibleElementTable.put(element, element); - } - } - } - - for (Iterator i = childList.iterator(); i.hasNext();) - { - Object o = i.next(); - if (extensibleElementTable.get(o) == null) - { - i.remove(); - } - } - } - return childList; - */ - return extensibleElement.getEExtensibilityElements(); - } - - /* - * Returns a list of 'children' of the given object model (WSDLElement). - */ - public static List getModelGraphViewChildren(Object object) { - List childList = new ArrayList(); - - if (object instanceof PortType) { - PortType portType = (PortType) object; - childList.addAll(portType.getOperations()); - } - else if (object instanceof Operation) { - Operation operation = (Operation) object; - - if (operation.getEInput() != null) { - childList.add(operation.getEInput()); - } - if (operation.getEOutput() != null) { - childList.add(operation.getEOutput()); - } - childList.addAll(operation.getFaults().values()); - } - else if (object instanceof MessageReference) { - MessageReference messageReference = (MessageReference) object; - childList.add(messageReference.getEMessage()); - } - - return childList; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java deleted file mode 100644 index 60724abad..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; -import org.eclipse.wst.wsdl.internal.util.WSDLModelLocator; - -public class WSDLModelLocatorAdapterFactory extends AdapterFactoryImpl -{ - protected CustomWSDLModelLocator customWSDLModelLocator = new CustomWSDLModelLocator(); - - class CustomWSDLModelLocator extends AdapterImpl implements WSDLModelLocator - { - public String resolveURI(String baseLocation, String namespace, String location) - { - return URIResolverPlugin.createResolver().resolve(baseLocation, namespace, location); - } - - public boolean isAdatperForType(Object type) - { - return type == WSDLModelLocator.class; - } - } - - public boolean isFactoryForType(Object type) - { - return type == WSDLModelLocator.class; - } - - public Adapter adaptNew(Notifier target, Object type) - { - return customWSDLModelLocator; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java deleted file mode 100644 index ddc335303..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.ui.internal.extension.INodeAssociationProvider; -import org.eclipse.xsd.impl.XSDComponentImpl; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class WSDLNodeAssociationProvider implements INodeAssociationProvider -{ - public Object getModelObject(Object parentModelObject, Element[] elementChain, int start, int[] end) - { - Object currentObject = parentModelObject; - for (int i = start; i < elementChain.length; i++) - { - Object o = getModelObjectHelper(currentObject, elementChain[i]); - if (o == null) - { - end[0] = i; - break; - } - else - { - currentObject = o; - } - } - return currentObject != parentModelObject ? currentObject : null; - } - - public Node getNode(Object modelObject) - { - if (modelObject instanceof WSDLElement) - return ((WSDLElementImpl)modelObject).getElement(); - else - return null; - } - - protected Object getModelObjectHelper(Object parentObject, Element elementNode) - { - Object result = null; - Collection childComponentList = ((WSDLElementImpl) parentObject).getWSDLContents(); - for (Iterator i = childComponentList.iterator(); i.hasNext();) - { - Object o = i.next(); - Element element = null; - - if (o != null) - { - if (o instanceof WSDLElementImpl) - { - element = ((WSDLElementImpl)o).getElement(); - } - else if (o instanceof XSDComponentImpl) - { - element = ((XSDComponentImpl)o).getElement(); - } - } - - if (element == elementNode) - { - result = o; - break; - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java deleted file mode 100644 index a51b5e8a9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class WSDLPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public WSDLPreferencePage() - { - super(FieldEditorPreferencePage.FLAT); - setPreferenceStore(WSDLEditorPlugin.getInstance().getPreferenceStore()); - } - - public void init(IWorkbench workbench) - { - } - - protected void createFieldEditors() - { - Composite parent = getFieldEditorParent(); - GridLayout parentLayout = new GridLayout(); - parentLayout.marginWidth = 0; - parent.setLayout(parentLayout); - -// WorkbenchHelp.setHelp(getControl(), some context id here); - - Group group = new Group(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.numColumns = 2; - group.setLayout(layout); - group.setText(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_CREATING_FILES")); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - group.setLayoutData(data); - - Composite composite = new Composite(group, SWT.NULL); - GridData data1 = new GridData(); - data1.verticalAlignment = GridData.FILL; - data1.horizontalAlignment = GridData.FILL; - data1.grabExcessHorizontalSpace = true; - composite.setLayoutData(data1); - - String namespaceLabel = WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE"); - StringFieldEditor targetNamespace = new StringFieldEditor(namespaceLabel, namespaceLabel, composite); // Externalize - GridLayout compositeLayout = (GridLayout)composite.getLayout(); - compositeLayout.marginWidth = 5; // Default value - compositeLayout.numColumns = 2; - addField(targetNamespace); - targetNamespace.setFocus(); - - String generateLabel = WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_AUTO_REGENERATE_BINDING"); - BooleanFieldEditor generateBindingOnSave = new BooleanFieldEditor(generateLabel, generateLabel, parent); - addField(generateBindingOnSave); - - String showGenerateDialogLabel = "Prompt Regenerate Binding on save"; // TODO: Externalize - BooleanFieldEditor showGenerateDialog = new BooleanFieldEditor(showGenerateDialogLabel, showGenerateDialogLabel, parent); - addField(showGenerateDialog); - - /* Do we need this preference below? If so, change WSDLEditorPlugin.java and use this preference in: - HttpContentGenerator.java - SoapContentGenerator.java - SoapPortOptionsPage.java - */ -// HttpPortOptionsPage.java StringFieldEditor location = new StringFieldEditor("Defualt Location:", "Default Location:", editorGroup1); // Externalize -// addField(location); - - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java deleted file mode 100644 index 8b1dd18db..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.util.Iterator; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl; -import org.eclipse.wst.wsdl.internal.util.WSDLModelLocator; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; -import org.w3c.dom.Element; - - -public class WSDLResourceUtil -{ - public static void reloadDirectives(Definition definition) - { - Resource rootResource = definition.eResource(); - ResourceSet resourceSet = rootResource.getResourceSet(); - - for (Iterator i = resourceSet.getResources().iterator(); i.hasNext();) - { - Resource resource = (Resource) i.next(); - if (resource != rootResource) - { - // TODO... consider unloading the resources - // resource.unload(); - i.remove(); - } - } - ReloadDirectiveVisitor visitor = new ReloadDirectiveVisitor(); - visitor.visitDefinition(definition); - } - - static class ReloadDirectiveVisitor - { - - public void visitImport(Import theImport) - { - // force the import to reload - Element element = WSDLEditorUtil.getInstance().getElementForObject(theImport); - if (element != null) - { - ((WSDLElementImpl)theImport).elementChanged(element); - } - } - - public void visitXSDSchemaDirective(XSDSchemaDirective directive) - { - // force the schema directive to reload - Element element = directive.getElement(); - if (element != null) - { - directive.elementAttributesChanged(element); - } - } - - public void visitDefinition(Definition definition) - { - if (definition != null) - { - for (Iterator i = definition.getEImports().iterator(); i.hasNext();) - { - visitImport((Import) i.next()); - } - Types types = definition.getETypes(); - if (types != null) - { - - for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement e = (XSDSchemaExtensibilityElement) o; - if (e.getSchema() != null) - { - visitSchema(e.getSchema()); - } - } - } - } - } - } - - public void visitSchema(XSDSchema schema) - { - for (Iterator i = schema.getContents().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaDirective) - { - visitXSDSchemaDirective((XSDSchemaDirective) o); - } - } - } - } - - - public static class InternalURIResolver implements WSDLModelLocator - { - //IdResolver idResolver = new IdResolverImpl(null, true); - org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver resolver = URIResolverPlugin.createResolver(); - - InternalURIResolver() - { - } - - public String resolveURI(String baseLocation, String namespace, String location) - { - String resolvedLocation = resolver.resolve(baseLocation, namespace, location); - - // here's an ugly hack... Platform.resolve() returns Windows files with the pattern "file:D:/hello.xsd" - // but EMF's URI class expects a pattern like this "file:///D:/hello.xsd" - // - if (resolvedLocation != null) - { - String fileProtocol = "file:"; - if (resolvedLocation.startsWith(fileProtocol) && !resolvedLocation.startsWith(fileProtocol + "/")) - { - resolvedLocation = resolvedLocation.substring(fileProtocol.length()); - } - resolvedLocation = URIHelper.addImpliedFileProtocol(resolvedLocation); - } - // end ugly hack - return resolvedLocation; - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java deleted file mode 100644 index 7f338b73e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import java.io.InputStream; -import java.net.URL; - -import javax.xml.transform.TransformerFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - -/** - * - */ -public class XMLQuickScan -{ - public static String getTargetNamespaceURIForSchema(String uri) - { - String result = null; - try - { - URL url = new URL(uri); - InputStream inputStream = url.openStream(); - result = XMLQuickScan.getTargetNamespaceURIForSchema(inputStream); - } - catch (Exception e) - { - } - return result; - } - - public static String getTargetNamespaceURIForSchema(InputStream input) - { - TargetNamespaceURIContentHandler handler = new TargetNamespaceURIContentHandler(); - ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader()); - // Line below is a hack to get XMLReader working - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - try - { - XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); - reader.setContentHandler(handler); - reader.parse(new InputSource(input)); - } - catch (Exception e) - { - } - finally - { - Thread.currentThread().setContextClassLoader(prevClassLoader); - } - return handler.targetNamespaceURI; - } - - protected static class TargetNamespaceURIContentHandler extends DefaultHandler - { - public String targetNamespaceURI; - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - { - if (localName.equals("schema") || localName.equals("definitions")) - { - int nAttributes = attributes.getLength(); - for (int i = 0; i < nAttributes; i++) - { - if (attributes.getLocalName(i).equals("targetNamespace")) - { - targetNamespaceURI = attributes.getValue(i); - break; - } - } - } - // todo there's a ice way to do this I'm sure - // here I intentially cause an exception... - String x = null; - x.length(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java deleted file mode 100644 index 64b9ae85c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.xsd.util.XSDSchemaLocationResolver; - -public class XSDSchemaLocationResolverAdapterFactory extends AdapterFactoryImpl -{ - protected XSDSchemaLocationResolverImpl schemaLocator = new XSDSchemaLocationResolverImpl(); - - public boolean isFactoryForType(Object type) - { - return type == XSDSchemaLocationResolver.class; - } - - public Adapter adaptNew(Notifier target, Object type) - { - return schemaLocator; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java deleted file mode 100644 index 306a2e80d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util; - -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDSchemaLocationResolver; -import org.eclipse.xsd.util.XSDSchemaLocator; - -public class XSDSchemaLocationResolverImpl extends AdapterImpl implements XSDSchemaLocationResolver -{ - public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) - { - String baseLocation = xsdSchema.getSchemaLocation(); - String result = URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI); - if (result == null) { - result = namespaceURI; - } - if (result == null) { - result = ""; - } - - return result; - } - - public boolean isAdatperForType(Object type) - { - return type == XSDSchemaLocator.class; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java deleted file mode 100644 index b4793549d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; - -public class FlatPageHeader extends Canvas implements IPropertyChangeListener -{ - private Image backgroundImage; - private String text; - private Image buttonImage; - private Color imageBackgroundColor; - private Color textForegroundColor; - private int textHMargin = 10; - private int textVMargin = 5; - private Font headerFont; - - private List listeners; - private int buttonImageX; - private int buttonImageY; - - // Usage: - // See org.eclipse.wst.common.ui.FlatViewUtility.createFlatPageHeader() - // methods. - // - // Ex) - // Composite parent = ... ; - // Image image = ... ; - // Layout layout = ... ; - // String title = ... ; - // WidgetFactory factory = ... ; - // - // header = new FlatPageHeader(parent,SWT.NONE); - // header.setLayout(layout); - // header.setBackgroundImage(image); - // header.setText(title); - // Composite formParent = factory.createComposite(header); - // - // GridLayout gl = new GridLayout(); - // gl.numColumns = 1; - // formParent.setLayout(gl); - // formParent.setLayoutData(new GridData(GridData.FILL_BOTH)); - // - public FlatPageHeader(Composite parent, int style) - { - super(parent, style); - - // The default image background color is white - // The default text forekground color is black - imageBackgroundColor = new Color(null, 255, 255, 255); - textForegroundColor = new Color(null, 0, 0, 0); - setBackground(imageBackgroundColor); - - // The default text font is Header font - headerFont = JFaceResources.getHeaderFont(); - - // Need to dispose the Color - addDisposeListener - (new DisposeListener() - { - public void widgetDisposed(DisposeEvent e) - { - FlatPageHeader.this.widgetDisposed(e); - } - } - ); - - // need to paint - addPaintListener - (new PaintListener() - { - public void paintControl(PaintEvent e) - { - FlatPageHeader.this.paintControl(e); - } - } - ); - - // create a list of listeners - listeners = new ArrayList(); - - // add a mouse listener - this.addMouseListener - (new MouseAdapter() - { - public void mouseDown(MouseEvent event) - { - handleMouseDown(event); - } - } - ); - - JFaceResources.getFontRegistry().addListener(this); - } - - // Compute size of the widget - public Point computeSize(int wHint, int hHint, boolean changed) - { - int width = getParent().getClientArea().width; - int height = 0; - if (backgroundImage != null) - { - Rectangle bounds = backgroundImage.getBounds(); - height = bounds.height; - } - if (text != null) - { - GC gc = new GC(this); - int textHeight = getTextHeight(gc); - gc.dispose(); - height = Math.max(height, textHeight); - } - if (buttonImage != null) - { - Rectangle bounds = buttonImage.getBounds(); - if (height < bounds.height) - height = bounds.height; - } - if (wHint != SWT.DEFAULT) width = wHint; - if (hHint != SWT.DEFAULT) height = hHint; - return new Point(width + 2, height + 2); - } - - protected void paintControl(PaintEvent e) - { - GC gc = e.gc; - if (backgroundImage != null) - { - Rectangle imageBounds = backgroundImage.getBounds(); - int y = 0; - int x = 0; - - if (imageBackgroundColor != null) - { - gc.setBackground(imageBackgroundColor); - gc.fillRectangle(0, 0, imageBounds.width, imageBounds.height); - } - - if (SWT.getPlatform().equals("motif")==false) - { - gc.drawImage(backgroundImage, x, y); - } - if (textForegroundColor != null) - gc.setForeground(textForegroundColor); - gc.setFont(headerFont); -// gc.setFont(getFont()); - gc.drawText(text, textHMargin, textVMargin, true); - if (buttonImage != null) - { - Rectangle parentBounds = getParent().getClientArea(); - Rectangle buttonBounds = buttonImage.getBounds(); - int p = parentBounds.x + parentBounds.width; - buttonImageX = p - buttonBounds.width - 4; - buttonImageY = 4; - gc.drawImage(buttonImage, buttonImageX, buttonImageY); - } - } - } - - public void addSelectionListener(SelectionListener listener) - { - listeners.add(listener); - } - - public void removeSelectionListener(SelectionListener listener) - { - listeners.remove(listener); - } - - protected void handleMouseDown(MouseEvent event) - { - if (buttonImage == null) - return; - // chekc if the Button image is clicked - int x = event.x; - int y = event.y; - if (x < buttonImageX || x > buttonImageX + buttonImage.getBounds().width) - { - return; - } - if (y < buttonImageY || y > buttonImageY + buttonImage.getBounds().height) - { - return; - } - - int size = listeners.size(); - for (int i = 0; i < size; i++) - { - SelectionListener listener = (SelectionListener)listeners.get(i); - listener.widgetSelected(null); - } - } - - protected void widgetDisposed(DisposeEvent e) - { - if (imageBackgroundColor != null) imageBackgroundColor.dispose(); - if (textForegroundColor != null) textForegroundColor.dispose(); - if (backgroundImage != null) backgroundImage.dispose(); - } - - // getters and setters - public Image getBackgroundImage() - { - return backgroundImage; - } - - public void setBackgroundImage(Image backgroundImage) - { - this.backgroundImage = backgroundImage; - redraw(); - } - - public Image getButtonImage() - { - return buttonImage; - } - - public void setButtonImage(Image buttonImage) - { - this.buttonImage = buttonImage; - redraw(); - } - - public String getText() - { - return text; - } - - public void setText(String text) - { - this.text = text; - redraw(); - } - - public int getTextHMargin() - { - return textHMargin; - } - - public void setTextHMargin(int textHMargin) - { - this.textHMargin = textHMargin; - } - - public int getTextVMargin() - { - return textVMargin; - } - - public void setTextVMargin(int textVMargin) - { - this.textVMargin = textVMargin; - } - - public Color getImageBackgroundColor() - { - return imageBackgroundColor; - } - - public void setImageBackgroundColor(Color imageBackgroundColor) - { - if (imageBackgroundColor == null) - return; - this.imageBackgroundColor = imageBackgroundColor; - redraw(); - } - - public Color getTextForegroundColor() - { - return textForegroundColor; - } - - public void setTextForegroundColor(Color textForegroundColor) - { - if (textForegroundColor == null) - return; - this.textForegroundColor = textForegroundColor; - redraw(); - } - - private int getTextHeight(GC gc) - { - int imageHeight = 0; - if (backgroundImage!= null && SWT.getPlatform().equals("motif")==false) - { - imageHeight = backgroundImage.getBounds().height; - } - gc.setFont(headerFont); -// gc.setFont(getFont()); - FontMetrics fm = gc.getFontMetrics(); - int fontHeight = fm.getHeight(); - int height = fontHeight + textVMargin + textVMargin; - return Math.max(height, imageHeight); - } - -// private int getTextWidth(GC gc) -// { -// int imageWidth = 0; -// if (backgroundImage!= null && SWT.getPlatform().equals("motif")==false) -// { -// imageWidth = backgroundImage.getBounds().width; -// } -// gc.setFont(headerFont); -//// gc.setFont(getFont()); -// FontMetrics fm = gc.getFontMetrics(); -// int fontWidth = fm.getAverageCharWidth() + 5; -// int width = fontWidth * text.length() + textHMargin + textHMargin; -// return Math.max(width, imageWidth); -// } - - public void handleEvent(Event e) - { -// Widget source = e.widget; - } - - public void propertyChange(PropertyChangeEvent event) - { - if(event.getProperty() == JFaceResources.HEADER_FONT && this.isDisposed() == false) - { - headerFont = JFaceResources.getFontRegistry().get(JFaceResources.HEADER_FONT); - this.layout(true); - this.redraw(); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java deleted file mode 100644 index 7ef2e6ced..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java +++ /dev/null @@ -1,408 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ViewForm; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; - -//public abstract class FormSection implements IPropertyChangeListener, IModelChangedListener { -public abstract class FlatPageSection extends ViewForm implements IPropertyChangeListener { - public static final int SELECTION = 1; -// private PDEFormPage formPage; - private String headerColorKey = WidgetFactory.DEFAULT_HEADER_COLOR; - private String headerText; - private Control client; - protected Label header; - protected Control separator; -// private SectionChangeManager sectionManager; - private java.lang.String description; - private boolean dirty; - protected Label descriptionLabel; - private ToggleControl toggle; - private boolean readOnly; - private boolean titleAsHyperlink; - private boolean addSeparator=true; - private boolean descriptionPainted=true; - private boolean headerPainted=true; - private boolean collapsable=false; - private Composite control; - - -/* - * This is a special layout for the section. Both the - * header and the description labels will wrap and - * they will use client's size to calculate needed - * height. This kind of behaviour is not possible - * with stock grid layout. - */ -class SectionLayout extends Layout { - int vspacing = 3; - int sepHeight = 2; - - - protected Point computeSize(Composite parent, int wHint, int hHint, boolean flush) { - int width = 0; - int height = 0; - int cwidth = 0; - int collapsedHeight = 0; - - if (wHint != SWT.DEFAULT) - width = wHint; - if (hHint != SWT.DEFAULT) - height = hHint; - - cwidth = width; - - if (client != null) { - Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush); - if (width == 0) { - width = csize.x; - cwidth = width; - } - if (height==0) height = csize.y; - } - - Point toggleSize = null; - - if (collapsable && toggle!=null) - toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush); - - if (hHint== SWT.DEFAULT && headerPainted && header!=null) { - int hwidth = cwidth; - if (toggleSize!=null) - hwidth = cwidth - toggleSize.x - 5; - Point hsize = header.computeSize(hwidth, SWT.DEFAULT, flush); - height += hsize.y; - collapsedHeight = hsize.y; - height += vspacing; - } - - if (hHint==SWT.DEFAULT && addSeparator) { - height += sepHeight; - height += vspacing; - collapsedHeight += vspacing + sepHeight; - } - if (hHint == SWT.DEFAULT && descriptionPainted && descriptionLabel!=null) { - Point dsize = descriptionLabel.computeSize(cwidth, SWT.DEFAULT, flush); - height += dsize.y; - height += vspacing; - } - if (toggle!=null && toggle.getSelection()) { - // collapsed state - height = collapsedHeight; - } - return new Point(width, height); - } - protected void layout(Composite parent, boolean flush) { - int width = parent.getClientArea().width; - int height = parent.getClientArea().height; - int y = 0; - Point toggleSize=null; - - if (collapsable) { - toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush); - } - - if (headerPainted && header!=null) { - Point hsize; - - if (titleAsHyperlink) { - hsize = header.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush); - header.setBounds(0, y, hsize.x, hsize.y); - } - else { - int availableWidth = width; - if (toggleSize!=null) - availableWidth = width - toggleSize.x - 5; - hsize = header.computeSize(availableWidth, SWT.DEFAULT, flush); - - int hx = 0; - if (toggle!=null) { - int ty = y + hsize.y - toggleSize.y; // + vspacing; - toggle.setBounds(0, ty, toggleSize.x, toggleSize.y); - hx = toggleSize.x; - } - header.setBounds(hx, y, availableWidth, hsize.y); - } - y += hsize.y + vspacing; - } - if (addSeparator && separator!=null) { - separator.setBounds(0, y, width, 2); - y += sepHeight + vspacing; - } - if (toggle!=null && toggle.getSelection()) { - return; - } - if (descriptionPainted && descriptionLabel!=null) { - Point dsize = descriptionLabel.computeSize(width, SWT.DEFAULT, flush); - descriptionLabel.setBounds(0, y, width, dsize.y); - y += dsize.y + vspacing; - } - if (client!=null) { - client.setBounds(0, y, width, height - y); - } - } -} - - -public FlatPageSection(Composite parent) { - // Description causes problems re word wrapping - // and causes bad layout in schema and - // component editors when in Motif - turning off - - super(parent, SWT.FLAT); - if (SWT.getPlatform().equals("motif")) { - descriptionPainted = false; - } - JFaceResources.getFontRegistry().addListener(this); -} -public void commitChanges(boolean onSave) { -} -public abstract Composite createClient(Composite parent, WidgetFactory factory); -public final Control createControl( - Composite parent, - WidgetFactory factory) { - Composite section = factory.createComposite(parent); - SectionLayout slayout = new SectionLayout(); - section.setLayout(slayout); - section.setData(this); - - if (headerPainted) { - Color headerColor = factory.getColor(getHeaderColorKey()); - header = factory.createHeadingLabel(section, getHeaderText(), headerColor, SWT.WRAP); - if (titleAsHyperlink) { - factory.turnIntoHyperlink(header, new HyperlinkAdapter() { - public void linkActivated(Control label) { - titleActivated(); - } - }); - } - if (collapsable) { - toggle = new ToggleControl(section, SWT.NULL); - toggle.setBackground(factory.getBackgroundColor()); - toggle.setActiveDecorationColor(factory.getHyperlinkColor()); - toggle.setDecorationColor(factory.getColor(WidgetFactory.COLOR_COMPOSITE_SEPARATOR)); - toggle.setActiveCursor(factory.getHyperlinkCursor()); - toggle.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - - boolean collapsed = toggle.getSelection(); - reflow(); - if (descriptionLabel!=null) - descriptionLabel.setVisible(!collapsed); - if (client!=null) - client.setVisible(!collapsed); - } - }); - } - } - - - if (addSeparator) { - //separator = factory.createSeparator(section, SWT.HORIZONTAL); - separator = factory.createCompositeSeparator(section); - } - - if (descriptionPainted && description != null) { - descriptionLabel = factory.createLabel(section, description, SWT.WRAP); - } - client = createClient(section, factory); - section.setData(this); - control = section; - return section; -} - -protected void reflow() { - control.layout(true); - control.getParent().layout(true); - - Widget grandParent = control.getParent().getParent(); - if (grandParent != null && grandParent instanceof Composite) - ((Composite)grandParent).layout(true); -/* - SectionForm form = formPage.getForm(); - if (form instanceof ScrollableSectionForm) { - ((ScrollableSectionForm)form).updateScrollBars(); - } -*/ -} - -protected Text createText(Composite parent, String label, WidgetFactory factory) { - return createText(parent, label, factory, 1); -} -protected Text createText(Composite parent, String label, WidgetFactory factory, int span) { - factory.createLabel(parent, label); - Text text = factory.createText(parent, ""); - GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - gd.grabExcessHorizontalSpace = true; - gd.horizontalSpan=span; - text.setLayoutData(gd); - return text; -} -protected Text createText(Composite parent, WidgetFactory factory, int span) { - Text text = factory.createText(parent, ""); - GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - gd.grabExcessHorizontalSpace = true; - gd.horizontalSpan=span; - text.setLayoutData(gd); - return text; -} -public void dispose() { - JFaceResources.getFontRegistry().removeListener(this); - super.dispose(); -} -public void doGlobalAction(String actionId) {} -public void expandTo(Object object) {} -/* -public final void fireChangeNotification(int changeType, Object changeObject) { - if (sectionManager == null) - return; - sectionManager.dispatchNotification(this, changeType, changeObject); -} -public final void fireSelectionNotification(Object changeObject) { - fireChangeNotification(SELECTION, changeObject); -} -*/ -public java.lang.String getDescription() { - return description; -} -/* -public PDEFormPage getFormPage() { - return formPage; -} -*/ - -public java.lang.String getHeaderColorKey() { - return headerColorKey; -} -public java.lang.String getHeaderText() { - return headerText; -} -public void initialize(Object input) {} - -public boolean isDirty() { - return dirty; -} - -public boolean isReadOnly() { - return readOnly; -} -public boolean isTitleAsHyperlink() { - return titleAsHyperlink; -} -/* -public void modelChanged(IModelChangedEvent e) { -} -*/ -public void sectionChanged(FlatPageSection source, int changeType, Object changeObject) {} -public void setAddSeparator(boolean newAddSeparator) { - addSeparator = newAddSeparator; -} - - -private String trimNewLines(String text) { - StringBuffer buff = new StringBuffer(); - for (int i=0; i<text.length(); i++) { - char c = text.charAt(i); - if (c=='\n') - buff.append(' '); - else - buff.append(c); - } - return buff.toString(); -} - -public void setDescription(java.lang.String newDescription) { - // we will trim the new lines so that we can - // use layout-based word wrapping instead - // of hard-coded one - description = trimNewLines(newDescription); - //description = newDescription; - if (descriptionLabel!=null) descriptionLabel.setText(newDescription); -} -public void setDescriptionPainted(boolean newDescriptionPainted) { - descriptionPainted = newDescriptionPainted; -} -public void setDirty(boolean newDirty) { - dirty = newDirty; -} -/* -public void setFocus() { -} -*/ -public void setHeaderColorKey(java.lang.String newHeaderColorKey) { - headerColorKey = newHeaderColorKey; -} -public void setHeaderPainted(boolean newHeaderPainted) { - headerPainted = newHeaderPainted; -} -public void setHeaderText(java.lang.String newHeaderText) { - headerText = newHeaderText; - if (header!=null) header.setText(headerText); -} -/* -void setManager(SectionChangeManager manager) { - this.sectionManager = manager; -} -*/ -public void setReadOnly(boolean newReadOnly) { - readOnly = newReadOnly; -} -public void setTitleAsHyperlink(boolean newTitleAsHyperlink) { - titleAsHyperlink = newTitleAsHyperlink; -} -public void titleActivated() { -} -/* -public void update() {} -*/ - -public void propertyChange(PropertyChangeEvent arg0) { - if (control!=null && header!=null) { - if (!header.isDisposed()) - header.setFont(JFaceResources.getBannerFont()); - if (!control.isDisposed()) - control.layout(true); - } -} - - - /** - * Gets the collapsable. - * @return Returns a boolean - */ - public boolean getCollapsable() { - return collapsable; - } - - /** - * Sets the collapsable. - * @param collapsable The collapsable to set - */ - public void setCollapsable(boolean collapsable) { - this.collapsable = collapsable; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java deleted file mode 100644 index 4e52bb988..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -public class HyperlinkAdapter implements IHyperlinkListener{ - -public HyperlinkAdapter() { - super(); -} -public void linkActivated(org.eclipse.swt.widgets.Control linkLabel) {} -public void linkEntered(org.eclipse.swt.widgets.Control linkLabel) {} -public void linkExited(org.eclipse.swt.widgets.Control linkLabel) {} -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java deleted file mode 100644 index bcd3c338d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import java.util.Enumeration; -import java.util.Hashtable; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; - -public class HyperlinkHandler implements MouseListener, MouseTrackListener, PaintListener { - - public static final int UNDERLINE_NEVER = 1; - public static final int UNDERLINE_ROLLOVER = 2; - public static final int UNDERLINE_ALWAYS = 3; - - private static Cursor hyperlinkCursor; - private static Cursor busyCursor; - private boolean hyperlinkCursorUsed=true; - private int hyperlinkUnderlineMode=UNDERLINE_ALWAYS; - private Color background; - private Color foreground; - private Color activeBackground; - private Color activeForeground; - private Hashtable hyperlinkListeners; - private Control lastLink; - -public HyperlinkHandler() { - hyperlinkListeners = new Hashtable(); - if (hyperlinkCursor == null) - { - hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); - busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT); - } -} -public void dispose() { - hyperlinkCursor.dispose(); - busyCursor.dispose(); -} -public org.eclipse.swt.graphics.Color getActiveBackground() { - return activeBackground; -} -public org.eclipse.swt.graphics.Color getActiveForeground() { - return activeForeground; -} -public org.eclipse.swt.graphics.Color getBackground() { - return background; -} -public org.eclipse.swt.graphics.Cursor getBusyCursor() { - return busyCursor; -} -public org.eclipse.swt.graphics.Color getForeground() { - return foreground; -} -public org.eclipse.swt.graphics.Cursor getHyperlinkCursor() { - return hyperlinkCursor; -} -public int getHyperlinkUnderlineMode() { - return hyperlinkUnderlineMode; -} -public org.eclipse.swt.widgets.Control getLastLink() { - return lastLink; -} -public boolean isHyperlinkCursorUsed() { - return hyperlinkCursorUsed; -} - public void mouseDoubleClick(MouseEvent e) { - } -public void mouseDown(MouseEvent e) { - if (e.button == 1) - return; - lastLink = (Control)e.widget; -} -public void mouseEnter(MouseEvent e) { - Control control = (Control) e.widget; - if (isHyperlinkCursorUsed()) - control.setCursor(hyperlinkCursor); - if (activeBackground != null) - control.setBackground(activeBackground); - if (activeForeground != null) - control.setForeground(activeForeground); - if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER) underline(control, true); - - IHyperlinkListener action = - (IHyperlinkListener) hyperlinkListeners.get(control); - if (action != null) - action.linkEntered(control); -} -public void mouseExit(MouseEvent e) { - Control control = (Control) e.widget; - if (isHyperlinkCursorUsed()) - control.setCursor(null); - if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER) - underline(control, false); - if (background != null) - control.setBackground(background); - if (foreground != null) - control.setForeground(foreground); - IHyperlinkListener action = - (IHyperlinkListener) hyperlinkListeners.get(control); - if (action != null) - action.linkExited(control); -} - public void mouseHover(MouseEvent e) { - } -public void mouseUp(MouseEvent e) { - if (e.button != 1) - return; - IHyperlinkListener action = - (IHyperlinkListener) hyperlinkListeners.get(e.widget); - if (action != null) { - Control c = (Control) e.widget; - c.setCursor(busyCursor); - action.linkActivated(c); - if (!c.isDisposed()) - c.setCursor(isHyperlinkCursorUsed()?hyperlinkCursor:null); - } -} -public void paintControl(PaintEvent e) { - Control label = (Control) e.widget; - if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS) - HyperlinkHandler.underline(label, true); -} -public void registerHyperlink(Control control, IHyperlinkListener listener) { - if (background != null) - control.setBackground(background); - if (foreground != null) - control.setForeground(foreground); - control.addMouseListener(this); - control.addMouseTrackListener(this); - if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS) - control.addPaintListener(this); - hyperlinkListeners.put(control, listener); - removeDisposedLinks(); -} -private void removeDisposedLinks() { - for (Enumeration keys = hyperlinkListeners.keys(); keys.hasMoreElements();) { - Control control = (Control)keys.nextElement(); - if (control.isDisposed()) { - hyperlinkListeners.remove(control); - } - } -} -public void reset() { - hyperlinkListeners.clear(); -} -public void setActiveBackground(org.eclipse.swt.graphics.Color newActiveBackground) { - activeBackground = newActiveBackground; -} -public void setActiveForeground(org.eclipse.swt.graphics.Color newActiveForeground) { - activeForeground = newActiveForeground; -} -public void setBackground(org.eclipse.swt.graphics.Color newBackground) { - background = newBackground; -} -public void setForeground(org.eclipse.swt.graphics.Color newForeground) { - foreground = newForeground; -} -public void setHyperlinkCursorUsed(boolean newHyperlinkCursorUsed) { - hyperlinkCursorUsed = newHyperlinkCursorUsed; -} -public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) { - hyperlinkUnderlineMode = newHyperlinkUnderlineMode; -} -public static void underline(Control control, boolean inside) { - if (!(control instanceof Label)) - return; - Composite parent = control.getParent(); - Rectangle bounds = control.getBounds(); - GC gc = new GC(parent); - Color color = inside? control.getForeground() : control.getBackground(); - gc.setForeground(color); - int y = bounds.y + bounds.height; - gc.drawLine(bounds.x, y, bounds.x+bounds.width, y); - gc.dispose(); -} -} - - - - - - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java deleted file mode 100644 index 03dfbadcf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import org.eclipse.swt.widgets.Control; - -public interface IHyperlinkListener { - - public void linkActivated(Control linkLabel); - public void linkEntered(Control linkLabel); - public void linkExited(Control linkLabel); -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java deleted file mode 100644 index 3149fef88..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.ACC; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleControlAdapter; -import org.eclipse.swt.accessibility.AccessibleControlEvent; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackAdapter; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.TypedListener; - -public class ToggleControl extends Canvas { - private boolean fCollapsed; - private Color fDecorationColor; - private Color fActiveColor; - private Cursor fActiveCursor; - private boolean fHasFocus; - private boolean fHover = false; - private static final int MARGIN_WIDTH = 2; - private static final int MARGIN_HEIGHT = 2; - - private static final int DEFAULT_HEIGHT = 8; - private static final int[] EXPANDED_POINTS = { 0, 2, 8, 2, 4, 6 }; - private static final int[] COLLAPSED_POINTS = { 2, 0, 2, 8, 6, 4 }; - private int fHeight = DEFAULT_HEIGHT; - - /* accessibility */ - private String fName; - private String fDescription; - - public ToggleControl(Composite parent, int style) { - super(parent, style); - initAccessible(); - - addPaintListener(new PaintListener() { - public void paintControl(PaintEvent e) { - paint(e); - } - }); - addMouseListener(new MouseAdapter() { - public void mouseDown(MouseEvent e) { - notifyListeners(SWT.Selection); - } - }); - addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.character == '\r' || e.character == ' ') { - // Activation - notifyListeners(SWT.Selection); - } - } - }); - addListener(SWT.Traverse, new Listener() { - public void handleEvent(Event e) { - if (e.detail != SWT.TRAVERSE_RETURN) - e.doit = true; - } - }); - addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - if (!fHasFocus) { - fHasFocus = true; - redraw(); - } - } - public void focusLost(FocusEvent e) { - if (fHasFocus) { - fHasFocus = false; - redraw(); - } - } - }); - - addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fCollapsed = !fCollapsed; - redraw(); - } - }); - - addMouseTrackListener(new MouseTrackAdapter() { - public void mouseEnter(MouseEvent e) { - fHover = true; - if (fActiveCursor != null) - setCursor(fActiveCursor); - redraw(); - } - public void mouseExit(MouseEvent e) { - fHover = false; - if (fActiveCursor != null) - setCursor(null); - redraw(); - } - }); - } - - public void addSelectionListener(SelectionListener listener) { - checkWidget(); - if (listener != null) - addListener(SWT.Selection, new TypedListener(listener)); - } - - public void setDecorationColor(Color decorationColor) { - this.fDecorationColor = decorationColor; - } - - public Color getDecorationColor() { - return fDecorationColor; - } - - public void setActiveDecorationColor(Color activeColor) { - this.fActiveColor = activeColor; - } - - public void removeSelectionListener(SelectionListener listener) { - checkWidget(); - if (listener != null) - removeListener(SWT.Selection, listener); - } - - public void setActiveCursor(Cursor activeCursor) { - this.fActiveCursor = activeCursor; - } - - public Color getActiveDecorationColor() { - return fActiveColor; - } - - public Point computeSize(int wHint, int hHint, boolean changed) { - - return new Point((wHint != SWT.DEFAULT ? wHint : fHeight + 2 * MARGIN_WIDTH), (hHint != SWT.DEFAULT ? hHint : fHeight + 2 * MARGIN_HEIGHT)); - } - - protected void paint(PaintEvent e) { - GC gc = e.gc; - Point size = getSize(); - gc.setFont(getFont()); - paint(gc); - if (fHasFocus) { - gc.setForeground(getForeground()); - gc.drawFocus(0, 0, size.x, size.y); - } - } - - /* - * @see SelectableControl#paint(GC) - */ - protected void paint(GC gc) { - if (fHover && fActiveColor != null) - gc.setBackground(fActiveColor); - else if (fDecorationColor != null) - gc.setBackground(fDecorationColor); - else - gc.setBackground(getForeground()); - Point size = getSize(); - gc.fillPolygon(translate((fCollapsed ? COLLAPSED_POINTS : EXPANDED_POINTS), ((size.x - fHeight) / 2), ((size.y - fHeight) / 2))); - gc.setBackground(getBackground()); - } - - private int[] translate(int[] data, int x, int y) { - int[] target = new int[data.length]; - for (int i = 0; i < data.length; i += 2) { - target[i] = data[i]*fHeight/DEFAULT_HEIGHT + x; - } - for (int i = 1; i < data.length; i += 2) { - target[i] = data[i]*fHeight/DEFAULT_HEIGHT + y; - } - return target; - } - - public void setHeight(int y) { - fHeight = y; - } - - private void notifyListeners(int eventType) { - Event event = new Event(); - event.type = eventType; - event.widget = this; - notifyListeners(eventType, event); - } - - public boolean getSelection() { - return fCollapsed; - } - - public void setSelection(boolean selection) { - this.fCollapsed = selection; - } - - public void setName(String name) { - fName = name; - } - - public void setDescription(String description) { - fDescription = description; - } - - private void initAccessible() { - getAccessible().addAccessibleListener(new AccessibleAdapter() { - - public void getName(AccessibleEvent e) { - e.result = fName; - } - - public void getDescription(AccessibleEvent e) { - e.result = fDescription; - } - }); - - getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() { - - public void getLocation(AccessibleControlEvent e) { - Rectangle location = getBounds(); - Point pt = toDisplay(new Point(location.x, location.y)); - e.x = pt.x; - e.y = pt.y; - e.width = location.width; - e.height = location.height; - } - - public void getChildCount(AccessibleControlEvent e) { - e.detail = 0; - } - - public void getRole(AccessibleControlEvent e) { - e.detail = ACC.ROLE_TREE; - } - - public void getState(AccessibleControlEvent e) { - e.detail = fCollapsed ? ACC.STATE_COLLAPSED : ACC.STATE_EXPANDED; - } - - }); - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java deleted file mode 100644 index c09998212..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.flatui; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.Hashtable; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.custom.TableTree; -import org.eclipse.swt.custom.ViewForm; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -public class WidgetFactory { - public static final String DEFAULT_HEADER_COLOR = "__default__header__"; - public static final String COLOR_BACKGROUND = "__bg"; - public static final String COLOR_BORDER = "__border"; - public static final String COLOR_COMPOSITE_SEPARATOR = "__compSep"; - public static final String COLOR_HYPERLINK="__hyperlink"; - - private Hashtable colorRegistry = new Hashtable(); - private Color backgroundColor; - private Color clientAreaColor; - private Color foregroundColor; - private Color fReadOnlyColor; - private Display fDisplay; - public static final int BORDER_STYLE = SWT.NONE; - private BorderPainter borderPainter; - private Color borderColor; - private HyperlinkHandler hyperlinkHandler; - private static Image fBanner; - - - class BorderPainter implements PaintListener { - public void paintControl(PaintEvent event) { - Composite composite = (Composite) event.widget; - Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) { - Control c = children[i]; - //if (c.isEnabled()==false) continue; - if (c instanceof Text - || c instanceof Canvas - || c instanceof CCombo) { - Rectangle b = c.getBounds(); - GC gc = event.gc; - gc.setForeground(c.getBackground()); - gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1); - gc.setForeground(foregroundColor); - gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - } - else if (c instanceof Table - || c instanceof Tree - || c instanceof TableTree) { - Rectangle b = c.getBounds(); - GC gc = event.gc; - gc.setForeground(borderColor); - //gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - gc.drawRectangle(b.x-1, b.y-1, b.width+2, b.height+2); - } - } - } - } - - -public WidgetFactory() { - fDisplay = Display.getDefault(); - initialize(); -} - -public Button createButton(Composite parent, String text, int style) { - int flatStyle = BORDER_STYLE == SWT.BORDER ? SWT.NULL : SWT.FLAT; - //int flatStyle = SWT.NULL; - Button button = new Button(parent, style | flatStyle); - button.setBackground(backgroundColor); - button.setForeground(foregroundColor); - if (text!=null) button.setText(text); - return button; -} -public Composite createComposite(Composite parent) { - return createComposite(parent, SWT.NULL); -} -public Composite createComposite(Composite parent, int style) { - Composite composite = new Composite(parent, style); - composite.setBackground(backgroundColor); - return composite; -} -public Composite createCompositeSeparator(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setBackground(getColor(COLOR_COMPOSITE_SEPARATOR)); - return composite; -} -public Group createGroup(Composite parent, String text) { - Group group = new Group(parent, SWT.SHADOW_NONE); - group.setText(text); - group.setBackground(backgroundColor); - group.setForeground(foregroundColor); - return group; -} -public Label createHeadingLabel(Composite parent, String text, Color bg) { - return createHeadingLabel(parent, text, bg, SWT.NONE); -} -public Label createHeadingLabel(Composite parent, String text, Color bg, int style) { - Label label = new Label(parent, style); - label.setText(text); - label.setBackground(backgroundColor); - label.setForeground(foregroundColor); - label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); - return label; -} -public Label createHyperlinkLabel(Composite parent, String text, IHyperlinkListener listener) { - return createHyperlinkLabel(parent, text, listener, SWT.NULL); -} -public Label createHyperlinkLabel(Composite parent, String text, IHyperlinkListener listener, int style) { - Label label = createLabel(parent, text, style); - turnIntoHyperlink(label, listener); - return label; -} -public Label createLabel(Composite parent, String text) { - return createLabel(parent, text, SWT.NONE); -} -public Label createLabel(Composite parent, String text, int style) { - Label label = new Label(parent, style); - if (text!=null) label.setText(text); - label.setBackground(backgroundColor); - label.setForeground(foregroundColor); - return label; -} -public Label createSeparator(Composite parent, int style) { - Label label = new Label(parent, SWT.SEPARATOR | style); - label.setBackground(backgroundColor); - label.setForeground(borderColor); - return label; -} -public ScrolledComposite createScrolledComposite (Composite parent) { - ScrolledComposite scrolledcomposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); - scrolledcomposite.setBackground(backgroundColor); - scrolledcomposite.setForeground(foregroundColor); - return scrolledcomposite; -} -public Table createTable(Composite parent, int style) { - Table table = new Table(parent, BORDER_STYLE | style); - table.setBackground(backgroundColor); - table.setForeground(foregroundColor); - //hookDeleteListener(table); - return table; -} -public Text createText(Composite parent, String value) { - return createText(parent, value, BORDER_STYLE | SWT.SINGLE); -} -public Text createText(Composite parent, String value, int style) { - Text text = new Text(parent, style); - text.setText(value); - text.setBackground(clientAreaColor); - text.setForeground(foregroundColor); - if ((style & SWT.READ_ONLY) != 0) - text.setForeground(fReadOnlyColor); - return text; -} -public Tree createTree(Composite parent, int style) { - Tree tree = new Tree(parent, BORDER_STYLE | style); - tree.setBackground(backgroundColor); - tree.setForeground(foregroundColor); - //hookDeleteListener(tree); - return tree; -} -/* -private void deleteKeyPressed(Widget widget) { - if (!(widget instanceof Control)) return; - Control control = (Control)widget; - for (Control parent = control.getParent(); - parent != null; - parent = parent.getParent()) { - if (parent.getData() instanceof FormSection) { - FormSection section = (FormSection) parent.getData(); - section.doGlobalAction(IWorkbenchActionConstants.DELETE); - break; - } - } -} -*/ -public ViewForm createViewForm(Composite parent) { - ViewForm viewForm = new ViewForm(parent, SWT.NULL); - viewForm.setBackground(clientAreaColor); - viewForm.setForeground(foregroundColor); - return viewForm; -} -public void dispose() { - Enumeration colors= colorRegistry.elements(); - while (colors.hasMoreElements()) { - Color c = (Color)colors.nextElement(); - c.dispose(); - } - hyperlinkHandler.dispose(); - colorRegistry=null; - if (fBanner != null) - { - fBanner.dispose(); - fBanner = null; - } -} -public Color getBackgroundColor() { - return backgroundColor; -} -public Image getBanner() { - if (fBanner == null) - { - try { - fBanner = (ImageDescriptor.createFromURL(new URL((WSDLEditorPlugin.getInstance().getDescriptor().getInstallURL()), "icons\form_banner.gif"))).createImage(); - System.out.println("Created Image!!!! "); - } catch (MalformedURLException e) { - System.out.println("Exception!!!! " + e); - } - } - return fBanner; -} -public Color getBorderColor() { - return borderColor; -} -public Cursor getBusyCursor() { - return hyperlinkHandler.getBusyCursor(); -} -public Color getClientAreaColor() { - return clientAreaColor; -} -public Color getColor(String key) { - return (Color)colorRegistry.get(key); -} -public Color getForegroundColor() { - return foregroundColor; -} -public Color getHyperlinkColor() { - return hyperlinkHandler.getForeground(); -} -public Cursor getHyperlinkCursor() { - return hyperlinkHandler.getHyperlinkCursor(); -} -public Color getHyperlinkHoverColor() { - return hyperlinkHandler.getActiveForeground(); -} -public int getHyperlinkUnderlineMode() { - return hyperlinkHandler.getHyperlinkUnderlineMode(); -} -/* -public void hookDeleteListener(Control control) { - if (deleteListener == null) { - deleteListener = new KeyAdapter() { - public void keyPressed(KeyEvent event) { - if (event.character == SWT.DEL && event.stateMask == 0) { - deleteKeyPressed(event.widget); - } - } - }; - } - control.addKeyListener(deleteListener); -} -*/ - private void initStaticColors() - { - if (colorRegistry == null) - { - colorRegistry = new Hashtable(); - registerColor(COLOR_BACKGROUND, 0xff, 0xfe, 0xf9); - registerColor(COLOR_BORDER, 195, 191, 179); - registerColor(COLOR_COMPOSITE_SEPARATOR, 152, 170, 203); - registerColor(DEFAULT_HEADER_COLOR, 0x48, 0x70, 0x98); - registerColor(COLOR_HYPERLINK, 0, 0, 153); - } - } - -private void initialize() { - clientAreaColor = fDisplay.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - fReadOnlyColor = fDisplay.getSystemColor(SWT.COLOR_DARK_GRAY); - initStaticColors(); - backgroundColor = clientAreaColor; - borderColor = getColor(COLOR_BORDER); - foregroundColor = fDisplay.getSystemColor(SWT.COLOR_LIST_FOREGROUND); - hyperlinkHandler = new HyperlinkHandler(); - hyperlinkHandler.setForeground(getColor(COLOR_HYPERLINK)); - hyperlinkHandler.setBackground(backgroundColor); -} -public void paintBordersFor(Composite parent) { - if (BORDER_STYLE == SWT.BORDER) return; - if (borderPainter==null) borderPainter = new BorderPainter(); - parent.addPaintListener(borderPainter); -} -public Color registerColor(String key, int r, int g, int b) { - Color c = new Color(fDisplay, r, g, b); - colorRegistry.put(key, c); - return c; -} - -public void setClientAreaColor(Color color) -{ - clientAreaColor = color; - backgroundColor = clientAreaColor; -} - -public void setHyperlinkColor(Color color) { - hyperlinkHandler.setForeground(color); -} -public void setHyperlinkHoverColor(org.eclipse.swt.graphics.Color hoverColor) { - hyperlinkHandler.setActiveForeground(hoverColor); -} -public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) { - hyperlinkHandler.setHyperlinkUnderlineMode(newHyperlinkUnderlineMode); -} -public void turnIntoHyperlink(Control control, IHyperlinkListener listener) { - hyperlinkHandler.registerHyperlink(control, listener); -} - -} - - - - - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java deleted file mode 100644 index 4d30cf1ca..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.ui; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.wst.common.ui.internal.UIPlugin; - -abstract public class BaseDesignWindow extends Viewer -{ - protected ScrolledComposite mainUIComponent; - protected Composite controlsContainer; - - protected boolean pageComplete = true; - protected Object input; - - private IStatusLineManager statusLine; - - public BaseDesignWindow(IStatusLineManager statusLine) - { - this.statusLine = statusLine; - } - - protected void setStatusLine(IStatusLineManager statusLine) - { - this.statusLine = statusLine; - } - - protected IStatusLineManager getStatusLine() - { - if (statusLine == null) - { - //statusLine = WorkbenchUtility.getStatusLineManager(); - - IWorkbench workbench = UIPlugin.getDefault().getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - - try - { - EditorActionBarContributor contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor(); - statusLine = contributor.getActionBars().getStatusLineManager(); - } - catch (Exception e) - { - } - } - return statusLine; - } - - public Object getInput() - { - return input; - } - - public void setInput(Object input) - { - if (this.input != input) - { - setErrorMessage(""); - } - - this.input = input; - } - - public ISelection getSelection() - { - return null; - } - - public void setSelection(ISelection selection, boolean reveal) - { - } - - public void refresh() - { - } - - /** - * A design view that has a main area for controls, and a message line at - * the bottom - */ - protected Control createDesignPane(Composite parent, int numColumns) - { - // Create the main UI container - mainUIComponent= new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) - { - public void setVisible(boolean visible) - { - super.setVisible(visible); - if (visible == false && !currentMessage.equals("")) - { - showMessageInStatusLine(visible == true); - } - } - }; - -// mainUIComponent.setLayoutData(new GridData(GridData.FILL_BOTH)); - - controlsContainer = new Composite(mainUIComponent, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - controlsContainer.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - controlsContainer.setLayoutData(data); - - // TODO: Remove above line and uncomment the following two when XSDEditor views - // are rewritten. Also refer do related TODO in DTDEditor's BaseWindow. - // FlatViewUtility flatViewUtility = new FlatViewUtility(); - // controlsContainer = flatViewUtility.createComposite(mainUIComponent, numColumns); - - mainUIComponent.setContent(controlsContainer); - - return mainUIComponent; - } - - public void setScrollComposite() - { - Point p = controlsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT); - mainUIComponent.setExpandHorizontal(true); - mainUIComponent.setExpandVertical(true); - mainUIComponent.setMinSize(p); - } - - public Composite getControlsContainer() - { - return controlsContainer; - } - - /** - * Sets the complete state of the page. - * If false, then client is not allowed to move to next page - */ - public void setPageComplete(boolean complete) - { - pageComplete= complete; - } - - /** - * Returns whether the page is complete or not. - */ - public boolean isPageComplete() - { - return pageComplete; - } - - private String currentMessage = ""; - protected void showMessageInStatusLine(boolean show) - { - if (getStatusLine() == null) - return; - - if (show) - { - getStatusLine().setErrorMessage(currentMessage); - } - else - { - getStatusLine().setErrorMessage(""); - } - - - getStatusLine().update(false); - } - - /** - * Sets the message line - */ - public void setMessage(String message) - { - currentMessage = message; - if (getStatusLine() != null) - { - getStatusLine().setErrorMessage(currentMessage); - getStatusLine().update(false); - } - } - - /** - * Clears a message. - */ - public void clearMessage() - { - currentMessage = ""; - if (getStatusLine() != null) - { - getStatusLine().setErrorMessage(currentMessage); - getStatusLine().update(false); - } - } - - public void setErrorMessage(String message) - { - setMessage(message); - setPageComplete(false); - } - - public void clearErrorMessage() - { - clearMessage(); - setPageComplete(true); - } - - public String getErrorMessage() - { - return currentMessage; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java deleted file mode 100644 index 47bdeb5f3..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.ui; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.TableTree; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; - -public class BorderPainter implements PaintListener -{ - Color backgroundColor, foregroundColor; - static Color borderColor; - - public BorderPainter() - { - Display display = Display.getCurrent(); - if (borderColor == null) - { - borderColor = new Color(Display.getCurrent(), 195, 191, 179); - } - backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); - } - - public void paintControl(PaintEvent event) - { - Composite composite = (Composite) event.widget; - Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) - { - Control c = children[i]; - if (c.isEnabled()==false) - { - if (c instanceof Text - || c instanceof Canvas - || c instanceof List - || c instanceof CCombo) - { - Rectangle b = c.getBounds(); - GC gc = event.gc; - gc.setForeground(backgroundColor); -// gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1); - gc.setForeground(borderColor); - gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - } - continue; - } - if (c instanceof Text -// || c instanceof Canvas - || c instanceof List - || c instanceof CCombo) - { - Rectangle b = c.getBounds(); - GC gc = event.gc; - gc.setForeground(backgroundColor); - gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1); - gc.setForeground(foregroundColor); - gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - } - else if (c instanceof Table - || c instanceof Tree - || c instanceof TableTree) { - Rectangle b = c.getBounds(); - GC gc = event.gc; - gc.setForeground(foregroundColor); - //gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - gc.drawRectangle(b.x-1, b.y-1, b.width+2, b.height+2); - } - } - } -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java deleted file mode 100644 index f0b9fb552..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java +++ /dev/null @@ -1,902 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.util.ui; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.part.PageBook; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.flatui.FlatPageHeader; -import org.eclipse.wst.wsdl.ui.internal.util.flatui.WidgetFactory; - -public class FlatViewUtility implements PaintListener -{ - Color backgroundColor, foregroundColor; - Color comboBackgroundColor, comboDisabledColor; - static Color borderColor; - - // Added for createFlatPageHeader() - private boolean headingVisible=true; - private Image headingImage = null; - private Composite headerControl = null; - private int TITLE_VMARGIN = 5; - - private KeyboardHandler keyboardHandler; - - public static final int H_SCROLL_INCREMENT = 5; - public static final int V_SCROLL_INCREMENT = 64; - - // this defaults to the flat style, but users can change it if they wish - private int flatStyle = SWT.FLAT; - private int border = 0; - - public FlatViewUtility() - { - Display display = Display.getCurrent(); - if (borderColor == null) - { - borderColor = new Color(Display.getCurrent(), 195, 191, 179); - } - backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); - comboBackgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - comboDisabledColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - keyboardHandler = new KeyboardHandler(); - } - - public FlatViewUtility(boolean isFlat) - { - this(); - - setFlat(isFlat); - } - - public void setFlat(boolean flat) - { - Display display = Display.getCurrent(); - if (flat) - { - flatStyle = SWT.FLAT; - backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); - } - else - { - flatStyle = 0; - border = SWT.BORDER; - backgroundColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - foregroundColor = display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); - } - } - - public void setColor(Control c) - { - if (flatStyle == SWT.FLAT) - { - c.setBackground(backgroundColor); - } - } - - public void paintControl(PaintEvent event) - { - Control c = (Control) event.widget; - if (c.isEnabled()==false) - { - if (c instanceof Text -// || c instanceof Canvas - || c instanceof List - || c instanceof CCombo) - { - GC gc = event.gc; - gc.setForeground(backgroundColor); -// gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1); - gc.setForeground(borderColor); -// gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3); - } - } - - // Defect 252891 : this causes some major problems on Linux GTK - // This looks rather dodgy in any case since an cyclic painting behaviour - // is likely occuring here - //if (c.getParent() != null) - //{ - // c.getParent().redraw(); - //} - } - - private static Font font; - - public static Font getFont() - { - if (font == null) - { - font = new Font(Display.getCurrent(), "ms sans serif", 8, SWT.NORMAL); - } - return font; - } - - public static void setFont(Font newFont) - { - font = newFont; - } - - public static void setComposite(Composite comp) - { - // deprecated. Remove later - } - - public Composite createSimpleComposite(Composite parent, int style) - { - Composite composite = new Composite(parent, style | flatStyle); - composite.setFont(getFont()); - setColor(composite); - - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - return composite; - } - - public Composite createComposite(Composite parent, int numColumns) - { - Composite composite = new Composite(parent, SWT.NONE | flatStyle); - composite.setFont(getFont()); - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - setColor(composite); - if (flatStyle == SWT.FLAT) - { - composite.addPaintListener(new BorderPainter()); - } - return composite; - } - - public Composite createComposite(Composite parent, int numColumns, boolean horizontalFill) - { - if (!horizontalFill) - { - createComposite(parent, numColumns); - } - - Composite composite = new Composite(parent, SWT.NONE | flatStyle); - composite.setFont(getFont()); - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - composite.setLayoutData(data); - setColor(composite); - if (flatStyle == SWT.FLAT) - { - composite.addPaintListener(new BorderPainter()); - } - return composite; - } - - public Composite createComposite(Composite parent, int numColumns, boolean horizontalFill, boolean verticalFill) - { - if (!horizontalFill && !verticalFill) - { - createComposite(parent, numColumns); - } - - Composite composite = new Composite(parent, SWT.NONE | flatStyle); - composite.setFont(getFont()); - - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - setColor(composite); - if (flatStyle == SWT.FLAT) - { - composite.addPaintListener(new BorderPainter()); - } - return composite; - } - - public SashForm createSashForm(Composite parent, int style) - { - SashForm sashForm = new SashForm(parent, style | flatStyle); - setColor(sashForm); - return sashForm; - } - - public PageBook createPageBook(Composite parent, int style) - { - PageBook pageBook = new PageBook(parent, style | flatStyle); - setColor(pageBook); - if (flatStyle == SWT.FLAT) - { - pageBook.addPaintListener(new BorderPainter()); - } - return pageBook; - } - - public Label createHeadingLabel(Composite parent, String text, Color bg) { - return createHeadingLabel(parent, text, bg, SWT.NONE); - } - public Label createHeadingLabel(Composite parent, String text, Color bg, int style) { - Label label = new Label(parent, style); - label.setText(text); - setColor(label); - if (flatStyle == SWT.FLAT) - { - label.setForeground(foregroundColor); - } - label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); - return label; - } - - public Label createHorizontalFiller(Composite parent, int horizontalSpan) - { - Label label = new Label(parent, SWT.LEFT | flatStyle); - setColor(label); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = horizontalSpan; - label.setLayoutData(data); - return label; - } - - /** - * Helper method for creating labels. - */ - public Label createLabel(Composite parent, int style, String text) - { - Label label = new Label(parent, style | flatStyle); - setColor(label); - label.setText(text); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - public Label createLabel(Composite parent, String text) - { - Label label = new Label(parent, SWT.LEFT | flatStyle); - setColor(label); - label.setText(text); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - public Label createLabel(Composite parent, String text, int alignment) - { - Label label = new Label(parent, SWT.LEFT | flatStyle); - label.setText(text); - setColor(label); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = alignment; - label.setLayoutData(data); - return label; - } - - /** - * Helper method for creating buttons. - */ - public Button createPushButton(Composite parent, String label) - { - Button button = new Button(parent, SWT.PUSH | flatStyle); - button.setText(label); - setColor(button); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - button.setLayoutData(data); - button.addKeyListener(keyboardHandler); - - return button; - } - - public Table createTable(Composite parent) - { - Table table = new Table(parent, SWT.SINGLE | SWT.BORDER | flatStyle); - setColor(table); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - table.setLayoutData(data); - return table; - } - - /** - * Create radio button - */ - public Button createRadioButton(Composite parent, String label) - { - Button button = new Button(parent, SWT.RADIO | flatStyle); - button.setText(label); - setColor(button); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - button.setLayoutData(data); - button.addKeyListener(keyboardHandler); - - return button; - } - - /** - * Helper method for creating check box - */ - public Button createCheckBox(Composite parent, String label) - { - Button button = new Button(parent, SWT.CHECK | flatStyle); - button.setText(label); - setColor(button); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - button.setLayoutData(data); - return button; - } - - public Combo createComboBox(Composite parent) - { - return createComboBox(parent, true); - } - - public Combo createComboBox(Composite parent, boolean isReadOnly) - { - int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN; - - Combo combo = new Combo(parent, style | flatStyle | border); - setColor(combo); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - combo.setLayoutData(data); - return combo; - } - - public CCombo createCComboBox(Composite parent) - { - return createCComboBox(parent, true); - } - - public CCombo createCComboBox(Composite parent, boolean isReadOnly) - { - int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN; - - CCombo combo = new CCombo(parent, style | flatStyle | border); - // setColor(combo); - // Always use List Background - combo.setBackground(comboBackgroundColor); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - combo.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - combo.addPaintListener(this); - } - else - { - /* - // Defect 252891 : I'm not sure if this code will also cause problems on Linux GTK - // But since its potentially cyclic ... I'm commenting it out for now - combo.addPaintListener(new PaintListener() - { - public void paintControl(PaintEvent event) - { - Control c = (Control) event.widget; - if (c.isEnabled()==true) - { - c.setBackground(comboBackgroundColor); - } - else - { - c.setBackground(comboDisabledColor); - } - final Control con = c; - Runnable delayedUpdate = new Runnable() - { - public void run() - { - if (con != null) - { - if (!con.isDisposed()) // it gets disposed - { - con.redraw(); - } - } - } - }; - Display.getCurrent().asyncExec(delayedUpdate); - } - });*/ - } - return combo; - } - - public List createListBox(Composite parent, int width, boolean isMultiSelect) - { - int style = isMultiSelect ? SWT.MULTI : SWT.SINGLE; - List list = new List(parent, style | flatStyle | border); - setColor(list); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = width; - list.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - list.addPaintListener(this); - } - return list; - } - - public List createListBox(Composite parent, int width, boolean isMultiSelect, boolean verticalFill) - { - int style = isMultiSelect ? SWT.MULTI : SWT.SINGLE; - List list = new List(parent, style | flatStyle | border); - setColor(list); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = verticalFill; - data.widthHint = width; - list.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - list.addPaintListener(this); - } - return list; - } - - public List createListBox(Composite parent, int style) - { - List list = new List(parent, style | flatStyle | border); - setColor(list); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - list.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - list.addPaintListener(this); - } - return list; - } - - public Text createTextField(Composite parent) - { - Text text = new Text(parent, SWT.SINGLE | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - text.addKeyListener(keyboardHandler); - return text; - } - - public Text createTextField(Composite parent, int width) - { - Text text = new Text(parent, SWT.SINGLE | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = width; - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - text.addKeyListener(keyboardHandler); - return text; - } - - public Text createTextField(Composite parent, int width, int style) - { - Text text = new Text(parent, style | SWT.SINGLE | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = width; - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - return text; - } - - /** - * <code>createWrappedMultiTextField</code> creates a wrapped multitext field - * - * @param parent a <code>Composite</code> value - * @param width an <code>int</code> value - * @param numLines an <code>int</code> value representing number of characters in height - * @param verticalFill a <code>boolean</code> value - * @return a <code>Text</code> value - */ - public Text createWrappedMultiTextField(Composite parent, int width, int numLines, boolean verticalFill) - { - Text text = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - if (verticalFill) - { - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - } - data.widthHint = width; - FontData[] fontData = getFont().getFontData(); - // hack for now where on Windows, only 1 fontdata exists - data.heightHint = numLines * fontData[0].getHeight(); - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - return text; - } - - public Text createMultiTextField(Composite parent, int width, int height, boolean verticalFill) - { - Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - if (verticalFill) - { - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - } - data.widthHint = width; - data.heightHint = height; - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - return text; - } - - public Text createMultiTextField(Composite parent, boolean verticalFill) - { - Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | flatStyle | border); - setColor(text); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - if (verticalFill) - { - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - } - text.setLayoutData(data); - if (flatStyle == SWT.FLAT) - { - text.addPaintListener(this); - } - return text; - } - - public Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill) - { - Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | flatStyle); - group.setText(text); - setColor(group); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - if (verticalFill) - { - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - } - group.setLayoutData(data); - - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - group.setLayout(layout); - if (flatStyle == SWT.FLAT) - { - group.addPaintListener(new BorderPainter()); - } - return group; - } - - public Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill, int alignment) - { - Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | flatStyle); - group.setText(text); - setColor(group); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.verticalAlignment = alignment; - if (verticalFill) - { - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - } - group.setLayoutData(data); - - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - group.setLayout(layout); - if (flatStyle == SWT.FLAT) - { - group.addPaintListener(new BorderPainter()); - } - return group; - } - - public Label createVerticalFiller(Composite parent, int verticalSpan) - { - Label label = new Label(parent, SWT.LEFT | flatStyle); - label.setFont(getFont()); - setColor(label); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.verticalSpan = verticalSpan; - label.setLayoutData(data); - - return label; - } - - // - // FlatPageHeader - // - - // This will use the default background image. - public Composite createFlatPageHeader - (Composite parent, - String title) - { - Image bgImage = createDefaultImage(); - return createFlatPageHeader(parent,bgImage,title); - } - - // Provide your own background image. - public Composite createFlatPageHeader - (Composite parent, - Image bgImage, - String title) - { - FlatPageHeader header = new FlatPageHeader(parent,SWT.NONE); - header.setLayout(new PageLayout()); - header.setBackgroundImage(bgImage); - header.setText(title); - WidgetFactory factory = new WidgetFactory(); - Composite formParent = factory.createComposite(header); - //Composite formParent = createComposite(header,1); - createPageContent(formParent); - headerControl = header; // this is used in getTitleHeight() - return formParent; - } - - public void updateFlatPageHeaderTitle(String title) - { - ((FlatPageHeader)headerControl).setText(title); - } - - private void createPageContent(Composite parent) - { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - } - - class PageLayout extends Layout - { - protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) - { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - - Control client = composite.getChildren()[0]; - Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache); - if (headingVisible) csize.y += getTitleHeight(); - - return csize; - } - - protected void layout(Composite composite, boolean flushCache) - { - Rectangle clientArea = composite.getClientArea(); - Control client = composite.getChildren()[0]; - int theight = headingVisible ? getTitleHeight() : 0; - client.setBounds(clientArea.x, clientArea.y + theight, clientArea.width, clientArea.height - theight); - } - } - - private int getTitleHeight() - { - int imageHeight = 0; - // Note - Find out why headingImage is always null. - if (headingImage != null && SWT.getPlatform().equals("motif") == false) - imageHeight = headingImage.getBounds().height; - - GC gc = new GC(headerControl); - gc.setFont(JFaceResources.getHeaderFont()); - FontMetrics fm = gc.getFontMetrics(); - int fontHeight = fm.getHeight(); - gc.dispose(); - - int height = fontHeight + TITLE_VMARGIN + TITLE_VMARGIN; - return Math.max(height,imageHeight); - } - - - private Image createDefaultImage() - { - return ImageDescriptor.createFromFile - (WSDLEditorPlugin.class, - "icons/page_banner.gif").createImage(); - } - /** - * Returns the backgroundColor. - * @return Color - */ - public Color getBackgroundColor() - { - return backgroundColor; - } - - public class KeyboardHandler extends KeyAdapter - { - public void keyPressed(KeyEvent e) - { - Widget w = e.widget; - if (w instanceof Control) - { - processKey(e.keyCode, (Control) w); - } - } - - private void scrollVertical(ScrolledComposite scomp, boolean up) - { - scroll(scomp, 0, up ? -V_SCROLL_INCREMENT : V_SCROLL_INCREMENT); - } - - private void scrollHorizontal(ScrolledComposite scomp, boolean left) - { - scroll(scomp, left ? -H_SCROLL_INCREMENT : H_SCROLL_INCREMENT, 0); - } - - private void scrollPage(ScrolledComposite scomp, boolean up) - { - Rectangle clientArea = scomp.getClientArea(); - int increment = up ? -clientArea.height : clientArea.height; - scroll(scomp, 0, increment); - } - - private void scroll(ScrolledComposite scomp, int xoffset, int yoffset) - { - Point origin = scomp.getOrigin(); - Point contentSize = scomp.getContent().getSize(); - int xorigin = origin.x + xoffset; - int yorigin = origin.y + yoffset; - xorigin = Math.max(xorigin, 0); - xorigin = Math.min(xorigin, contentSize.x - 1); - yorigin = Math.max(yorigin, 0); - yorigin = Math.min(yorigin, contentSize.y - 1); - scomp.setOrigin(xorigin, yorigin); - } - - protected ScrolledComposite getScrolledComposite(Control c) - { - Composite parent = c.getParent(); - - while (parent != null) - { - if (parent instanceof ScrolledComposite) - { - return (ScrolledComposite) parent; - } - parent = parent.getParent(); - } - return null; - } - - protected void processKey(int keyCode, Control c) - { - ScrolledComposite scomp = getScrolledComposite(c); - if (scomp != null) - { - switch (keyCode) - { - case SWT.ARROW_DOWN : - scrollVertical(scomp, false); - break; - case SWT.ARROW_UP : - scrollVertical(scomp, true); - break; - case SWT.ARROW_LEFT : - scrollHorizontal(scomp, true); - break; - case SWT.ARROW_RIGHT : - scrollHorizontal(scomp, false); - break; - case SWT.PAGE_UP : - scrollPage(scomp, true); - break; - case SWT.PAGE_DOWN : - scrollPage(scomp, false); - break; - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BaseViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BaseViewer.java deleted file mode 100644 index 83a118bbf..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BaseViewer.java +++ /dev/null @@ -1,367 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.util.ui.BaseDesignWindow; -import org.eclipse.wst.wsdl.ui.internal.util.ui.BorderPainter; -import org.eclipse.wst.wsdl.ui.internal.util.ui.FlatViewUtility; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public abstract class BaseViewer extends BaseDesignWindow implements Listener, SelectionListener -{ -// protected Object input; - - // for use in subclasses - protected FlatViewUtility flatViewUtility = new FlatViewUtility(true); - - public BaseViewer(IStatusLineManager statusLine) - { - super(statusLine); - } - - public Object getInput() - { - return input; - } - - // gets called only if we currently are not handling an event - abstract public void doSetInput(Object input); - - /** - * @see org.eclipse.jface.viewers.Viewer#setInput(Object) - */ - static Object oldInput = null; - ModelAdapterListener oldModelAdapterListener = null; - - public void setInput(Object input) - { - super.setInput(input); - - doSetInput(input); -/* - if (!isInDoHandle() && !getControl().isDisposed()) - { - final Object obj = input; - getControl().getDisplay().asyncExec(new Runnable() - { - public void run() - { - doSetInput(obj); - } - }); - } -*/ - } - - - boolean listenerEnabled = true; - /** - * Get the value of listenerEnabled. - * @return value of listenerEnabled. - */ - public boolean isListenerEnabled() - { - return listenerEnabled; - } - - /** - * Set the value of listenerEnabled. - * @param v Value to assign to listenerEnabled. - */ - public void setListenerEnabled(boolean v) - { - this.listenerEnabled = v; - } - - - public void handleEvent(Event event) - { - if (isListenerEnabled() && - getInput() != null && - !isInDoHandle) - { - isInDoHandle = true; - startDelayedEvent(event); - isInDoHandle = false; - } // end of if () - } - - abstract public void doHandleEvent(Event event); - abstract public void createControl(Composite parent); - - protected DelayedEvent delayedTask; - - protected void startDelayedEvent(Event e) - { - if (delayedTask == null || - delayedTask.getEvent() == null) - { - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500,delayedTask); - } - else - { - Event delayedEvent = delayedTask.getEvent(); - - if (e.widget == delayedEvent.widget && - e.type == delayedEvent.type) - { - // same event, just different data, delay new event - delayedTask.setEvent(null); - } - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500,delayedTask); - } - } - - class DelayedEvent implements Runnable - { - protected Event event; - - /* - * @see Runnable#run() - */ - public void run() - { - if (event != null) - { - isInDoHandle = true; - doHandleEvent(event); - isInDoHandle = false; - event = null; - } - } - - /** - * Gets the event. - * @return Returns a Event - */ - public Event getEvent() - { - return event; - } - - /** - * Sets the event. - * @param event The event to set - */ - public void setEvent(Event event) - { - this.event = event; - } - - } - - - boolean isInDoHandle; - /** - * Get the value of isInDoHandle. - * @return value of isInDoHandle. - */ - public boolean isInDoHandle() - { - return isInDoHandle; - } - - /* - * @see Viewer#getControl() - */ - public Control getControl() - { - return mainUIComponent; - } - - - /* - * @see BaseDesignWindow#createDesignPane(Composite, int) - */ - protected Control createDesignPane(Composite arg0, int arg1) - { - Control control = super.createDesignPane(arg0, arg1); - - Composite client = super.getControlsContainer(); - - client.addPaintListener(new BorderPainter()); - - client.setBackground(new Color(Display.getCurrent(),255,255,255)); - - return control; - } - - - public ISelection getSelection() - { - return null; - } - - public void refresh() - { - } - - public void setSelection(ISelection selection, boolean reveal) - { - } - - -// public abstract Control getControl(); - - - public Node getNode() - { - return (Node) getInput(); - } - - - public void doWidgetDefaultSelected(SelectionEvent e) - {} - - public void doWidgetSelected(SelectionEvent e) - {} - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) - { - if (isListenerEnabled() && - getInput() != null && - !isInDoHandle) - { - isInDoHandle = true; - doWidgetDefaultSelected(e); - isInDoHandle = false; - } - - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) - { - if (isListenerEnabled() && - getInput() != null && - !isInDoHandle) - { - isInDoHandle = true; - doWidgetSelected(e); - isInDoHandle = false; - } - - } - - public Node getChildNode(Element parent, String childName) - { - NodeList list = null; - if (parent != null) - { - list = parent.getChildNodes(); - } - - if (list != null) - { - // Performance issue perhaps? - for (int i = 0; i < list.getLength(); i++) - { - if (list.item(i) instanceof Element) - { - if (list.item(i).getLocalName().equals(childName)) - { - return list.item(i); - } - } - } - } - return null; - } - - - protected Element performAddElement(Node parentNode, String namespaceName, String localName) - { - if (parentNode != null) - { - Element newElement = createElement(parentNode, namespaceName, localName); - parentNode.appendChild(newElement); - format(parentNode); - return newElement; - } - return null; - } - - protected Element createElement(Node parentNode, String namespaceName, String localName) - { - Document document = parentNode.getOwnerDocument(); - Element element = document.createElement(localName); - return element; - } - - protected void addAttributes(Element newElement, String attr, String value) - { - newElement.setAttribute(attr, value); - } - - protected void format(Node parentNode) - { - if (parentNode instanceof IDOMNode) - { - // format selected node - FormatProcessorXML formatProcessorXML = new FormatProcessorXML(); - formatProcessorXML.formatNode((IDOMNode)parentNode); - } - } - - static protected IEditorPart getActiveEditor() - { - IWorkbench workbench = WSDLEditorPlugin.getInstance().getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - - return editorPart; - } - - static protected IStatusLineManager getStatusLineManager(IEditorPart editorPart) - { - IStatusLineManager result = null; - try - { - EditorActionBarContributor contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor(); - result = contributor.getActionBars().getStatusLineManager(); - } - catch (Exception e) - { - } - return result; - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingInputOutputFaultViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingInputOutputFaultViewer.java deleted file mode 100644 index 5c7d396a0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingInputOutputFaultViewer.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class BindingInputOutputFaultViewer extends NamedComponentViewer -{ - public BindingInputOutputFaultViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - String result = ""; - if (input instanceof BindingInput) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_INPUT"); - } - else if (input instanceof BindingOutput) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_OUTPUT"); - } - else if (input instanceof BindingFault) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_FAULT"); - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingOperationViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingOperationViewer.java deleted file mode 100644 index f10337bca..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingOperationViewer.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class BindingOperationViewer extends NamedComponentViewer -{ - public BindingOperationViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_OPERATION"); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingViewer.java deleted file mode 100644 index 79d8bce9f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/BindingViewer.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.ComponentNameComboHelper; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.InvokeDialogButton; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; - -public class BindingViewer extends NamedComponentViewer -{ - protected CCombo componentNameCombo; - protected ComponentNameComboHelper componentNameComboHelper; - InvokeDialogButton button; - - public BindingViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING"); //$NON-NLS-1$ - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORTTYPE")); //$NON-NLS-1$ - - componentNameCombo = flatViewUtility.createCComboBox(composite); - componentNameCombo.addListener(SWT.Modify, this); - - - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getPortTypeNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.TYPE_ATTRIBUTE; - } - }; - - button = new InvokeDialogButton(composite, getInput()); - button.setEditor(editorPart); - - return composite; - } - - protected void update() - { - super.update(); - componentNameComboHelper.update(input); - button.setInput(input); - } - - protected void handleEventHelper(Element element, Event event) - { - super.handleEventHelper(element, event); - componentNameComboHelper.handleEventHelper(element, event); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/DefinitionViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/DefinitionViewer.java deleted file mode 100644 index 5384c1d32..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/DefinitionViewer.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.EditNamespacesAction; - -public class DefinitionViewer extends NamedComponentViewer -{ - public DefinitionViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_DEFINITION"); //$NON-NLS-1$ - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_NAMESPACES")); //$NON-NLS-1$ - Button button = flatViewUtility.createPushButton(composite, WSDLEditorPlugin.getWSDLString("_UI_EDIT_NAMESPACES")); - SelectionListener listener = new SelectionListener() - { - public void widgetDefaultSelected(SelectionEvent event) - { - } - - public void widgetSelected(SelectionEvent event) - { - EditNamespacesAction action = new EditNamespacesAction((Definition)getInput()); - action.run(); - } - }; - button.addSelectionListener(listener); - return composite; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/EmptyViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/EmptyViewer.java deleted file mode 100644 index e4e254189..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/EmptyViewer.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; - -public class EmptyViewer extends BaseViewer -{ - protected Composite control; - - public EmptyViewer(Composite parent, int style) - { - super(getStatusLineManager(getActiveEditor())); - createControl(parent); - } - - public void createControl(Composite parent) - { - control = new Composite(parent, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - control.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - control.setLayoutData(data); - } - - public Control getControl() - { - return control; - } - - public void doSetInput(Object input) - { - - } - - /* - * @see BaseWindow#doHandleEvent(Event) - */ - public void doHandleEvent(Event event) - { - if (event.type == SWT.Modify) - { - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibilityElementViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibilityElementViewer.java deleted file mode 100644 index 0f3a17017..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibilityElementViewer.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.AttributesTable; -import org.w3c.dom.Node; - -public class ExtensibilityElementViewer extends BaseViewer implements ModelAdapterListener -{ - protected Composite control; - protected IEditorPart editorPart; - protected AttributesTable attributesTable; - boolean isForTabbedProperties = false; - - public ExtensibilityElementViewer(Composite parent, IEditorPart editorPart) - { - super(getStatusLineManager(editorPart)); - this.editorPart = editorPart; - - createControl(parent); - } - - public ExtensibilityElementViewer(Composite parent, IEditorPart editorPart, boolean isForTabbedProperties) - { - super(getStatusLineManager(editorPart)); - this.editorPart = editorPart; - this.isForTabbedProperties = isForTabbedProperties; - if (isForTabbedProperties) - { - createControlForTabbedPropertySheet(parent); - } - else - { - createControl(parent); - } - } - - protected String getHeadingText() - { - String result = ""; - if (input != null) - { - Node node = ((WSDLElement)input).getElement(); - result = node.getNodeName(); - if (result == null || result.length() == 0) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_UNKNOWN_EXTENSIBILITY_ELEMENT"); //$NON-NLS-1$ - } - } - return result; - } - - // TODO... move this method down to BaseViewer! - public void doHandleEvent(Event event) - { - } - - public void createControlForTabbedPropertySheet(Composite parent) - { - attributesTable = new AttributesTable(editorPart, parent); - } - - public void createControl(Composite parent) - { - control = flatViewUtility.createComposite(parent, 1, true); - control.setBackground (new Color(null,255,0,0)); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.verticalAlignment= GridData.FILL; - gd.grabExcessVerticalSpace= true; - - control.setLayoutData(gd); - - - GridLayout layout = (GridLayout)control.getLayout(); - layout.verticalSpacing = 0; - layout.marginHeight = 0; - layout.marginWidth = 0; - - flatViewUtility.createFlatPageHeader(control, ""); - - Composite c = flatViewUtility.createComposite(control, 1, true); - GridData cGD= new GridData(); - cGD.horizontalAlignment= GridData.FILL; - cGD.grabExcessHorizontalSpace= true; - cGD.verticalAlignment= GridData.FILL; - cGD.grabExcessVerticalSpace= true; - - c.setLayoutData(cGD); - attributesTable = new AttributesTable(editorPart, c); - - GridData attributesTableGD= new GridData(); - attributesTableGD.horizontalAlignment= GridData.FILL; - attributesTableGD.grabExcessHorizontalSpace= true; - attributesTableGD.verticalAlignment= GridData.FILL; - attributesTableGD.grabExcessVerticalSpace= true; - - attributesTable.getControl().setLayoutData(attributesTableGD); - } - - public Control getControl() - { - return control; - } - - - public void doSetInput(Object input) - { - if (!isForTabbedProperties) - { - flatViewUtility.updateFlatPageHeaderTitle(getHeadingText()); - } - setListenerEnabled(false); - - attributesTable.setInput(((WSDLElement)input).getElement()); - - setListenerEnabled(true); - - if (oldInput != null) - { - WSDLModelAdapterFactory.removeModelAdapterListener(oldInput, this); - } - WSDLModelAdapterFactory.addModelAdapterListener(input, this); - - oldInput = input; - } - - public void propertyChanged(Object object, String property) - { - if (isListenerEnabled()) - { - setListenerEnabled(false); - update(); - setListenerEnabled(true); - } - } - - protected void update() - { - Runnable runnable = new Runnable() - { - public void run() - { - if (!attributesTable.getControl().isDisposed()) - { - attributesTable.refresh(); - } - } - }; - Display.getCurrent().asyncExec(runnable); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibleDetailsViewerProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibleDetailsViewerProvider.java deleted file mode 100644 index 2c6057f44..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ExtensibleDetailsViewerProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.IDetailsViewerProvider; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry; - -public class ExtensibleDetailsViewerProvider implements IDetailsViewerProvider -{ - protected WSDLEditorExtension[] extensions; - protected IDetailsViewerProvider[] detailsViewerProviders; - - protected final static Object[] EMPTY_ARRAY = {}; - - public ExtensibleDetailsViewerProvider(WSDLEditor wsdlEditor) - { - WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry(); - - extensions = registry.getRegisteredExtensions(WSDLEditorExtension.DETAILS_VIEWER_PROVIDER); - detailsViewerProviders = new IDetailsViewerProvider[extensions.length]; - for (int i = 0; i < extensions.length; i++) - { - detailsViewerProviders[i] = (IDetailsViewerProvider)extensions[i].createExtensionObject(WSDLEditorExtension.DETAILS_VIEWER_PROVIDER, wsdlEditor); - } - } - - - protected IDetailsViewerProvider getApplicableDetailsProvider(Object object) - { - IDetailsViewerProvider provider = null; - for (int i = 0; i < extensions.length; i++) - { - if (extensions[i].isApplicable(object)) - { - provider = detailsViewerProviders[i]; - if (provider != null) - { - break; - } - } - } - return provider; - } - - - public Object getViewerKey(Object object) - { - IDetailsViewerProvider provider = getApplicableDetailsProvider(object); - return provider != null ? provider.getViewerKey(object) : null; - } - - - public Viewer createViewer(Object object, Composite parent, IEditorPart editorPart) - { - IDetailsViewerProvider provider = getApplicableDetailsProvider(object); - return provider != null ? provider.createViewer(object, parent, editorPart) : null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ImportViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ImportViewer.java deleted file mode 100644 index 1419425ed..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ImportViewer.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -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.XMLQuickScan; -import org.w3c.dom.Element; - - -public class ImportViewer extends BaseViewer implements ModelAdapterListener -{ - protected Composite control; - protected IEditorPart editorPart; - - protected Text namespaceText; - protected Text prefixText; - protected Text locationText; - Button selectButton; - - /** - * Constructor for ImportViewer. - * @param parent - * @param editorPart - */ - public ImportViewer(Composite parent, IEditorPart editorPart) - { - super(getStatusLineManager(editorPart)); - this.editorPart = editorPart; - createControl(parent); - } - /** - * @see org.eclipse.wst.wsdl.ui.internal.viewers.NamedComponentViewer#getHeadingText() - */ - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_IMPORT"); //$NON-NLS-1$ - } - - public void createControl(Composite parent) - { - control = flatViewUtility.createComposite(parent, 1, true); - GridLayout layout = (GridLayout)control.getLayout(); - layout.verticalSpacing = 0; - - flatViewUtility.createFlatPageHeader(control, getHeadingText()); - - Composite c = flatViewUtility.createComposite(control, 1, true); - - Label bogus = flatViewUtility.createLabel(c, 0, ""); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - - bogus.setLayoutData(gd); - - Composite composite = flatViewUtility.createComposite(c, 2, true); - GridLayout layout2 = new GridLayout(); - layout2.makeColumnsEqualWidth = false; - layout2.numColumns = 3; - layout2.marginHeight = 3; - composite.setLayout(layout2); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAMESPACE")); //$NON-NLS-1$ - namespaceText = flatViewUtility.createTextField(composite); - namespaceText.setEnabled(false); - - // place holder - Control con= flatViewUtility.createLabel(composite, 0, ""); - gd = new GridData(); - gd.grabExcessHorizontalSpace = false; - con.setLayoutData(gd); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_PREFIX")); //$NON-NLS-1$ - prefixText = flatViewUtility.createTextField(composite); - prefixText.addListener(SWT.Modify,this); - prefixText.setEnabled(false); - - // place holder - Control con2= flatViewUtility.createLabel(composite, 0, ""); - gd = new GridData(); - gd.grabExcessHorizontalSpace = false; - con2.setLayoutData(gd); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_LOCATION")); //$NON-NLS-1$ - locationText = flatViewUtility.createTextField(composite); - locationText.setEnabled(false); - - selectButton = flatViewUtility.createPushButton(composite, "..."); - gd = new GridData(); - gd.horizontalAlignment = GridData.BEGINNING; - gd.grabExcessHorizontalSpace = false; - selectButton.setLayoutData(gd); - selectButton.addSelectionListener(this); - } - - public void doSetInput(Object input) - { - setListenerEnabled(false); - try - { -// Node node = WSDLEditorUtil.getInstance().getNodeForObject(input); - update(); - } - finally - { - setListenerEnabled(true); - } - - if (oldInput != null) - { - WSDLModelAdapterFactory.removeModelAdapterListener(oldInput, this); - } - - WSDLModelAdapterFactory.addModelAdapterListener(input, this); - oldInput = input; - } - - protected void handleEventHelper(Element element, Event event) - { - if (event.type == SWT.Modify) - { - } - } - - protected void update() - { - Element element = ((WSDLElement)input).getElement(); - flatViewUtility.updateFlatPageHeaderTitle(getHeadingText()); - prefixText.setText(""); - locationText.setText(""); - namespaceText.setText(" "); - namespaceText.getParent().layout(); - namespaceText.setText(""); - String locationValue = element.getAttribute("location"); - locationText.setText(locationValue != null ? locationValue : ""); - - String namespaceValue = element.getAttribute("namespace"); - namespaceText.setText(namespaceValue != null ? namespaceValue : ""); - - String prefix = ((Import)input).getEnclosingDefinition().getPrefix(namespaceValue); - prefixText.setText(prefix != null ? prefix : ""); - } - - public Control getControl() - { - return control; - } - - /* - * @see BaseWindow#doHandleEvent(Event) - */ - public void doHandleEvent(Event event) - { -// if (event.widget == prefixText) -// { -// String newPrefix = prefixText.getText(); -// String errorMessage = ValidateHelper.checkXMLPrefix(newPrefix); -// -// if (errorMessage == null || errorMessage.length() == 0) -// { -// Import importObj = (Import)input; -// org.w3c.dom.Element importElement = WSDLUtil.getInstance().getElementForObject(importObj); -// -// Definition definition = importObj.getEnclosingDefinition(); -// org.w3c.dom.Element definitionElement = WSDLUtil.getInstance().getElementForObject(definition); -// -// String nsFromModel = importObj.getNamespaceURI(); -// String nsFromDOM = importElement.getAttribute("namespace"); -// System.out.println(nsFromModel); -// System.out.println(nsFromDOM); -// -// String oldPrefix = definition.getPrefix(nsFromModel); -// definitionElement.removeAttribute("xmlns:" + oldPrefix); -// definitionElement.setAttribute("xmlns:" + newPrefix, nsFromModel); -// } -// } - } - - public void propertyChanged(Object object, String property) - { - if (isListenerEnabled()) - { - setListenerEnabled(false); - update(); - setListenerEnabled(true); - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - - } - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == selectButton) - { -// TODO: port check - WSDLEditor editor = (WSDLEditor)editorPart; - IFile currentWSDLFile = ((IFileEditorInput)editor.getEditorInput()).getFile(); - - SelectSingleFileDialog dialog = new SelectSingleFileDialog(WSDLEditorPlugin.getShell(), null, true); - String [] filters = { "xsd", "wsdl" }; - IFile [] excludedFiles = { currentWSDLFile }; - - dialog.addFilterExtensions(filters, excludedFiles); - dialog.create(); - dialog.getShell().setText(WSDLEditorPlugin.getWSDLString("_UI_TITLE_SELECT")); //$NON-NLS-1$ - dialog.setTitle(WSDLEditorPlugin.getWSDLString("_UI_TITLE_SELECT_FILE")); //$NON-NLS-1$ - dialog.setMessage(WSDLEditorPlugin.getWSDLString("_UI_DESCRIPTION_SELECT_WSDL_OR_XSD")); //$NON-NLS-1$ - int rc = dialog.open(); - if (rc == IDialogConstants.OK_ID) - { - IFile selectedFile = dialog.getFile(); - - //if (selectedFile.getLocation().toOSString().equals(currentWSDLFile.getLocation().toOSString())) - //{ - // System.out.println("SAME FILE:" + currentWSDLFile.getLocation()); - //} - - String location = ComponentReferenceUtil.computeRelativeURI(selectedFile, currentWSDLFile, true); - - Import importObj = (Import)input; - org.w3c.dom.Element importElement = WSDLEditorUtil.getInstance().getElementForObject(importObj); - Definition definition = importObj.getEnclosingDefinition(); - org.w3c.dom.Element definitionElement = WSDLEditorUtil.getInstance().getElementForObject(definition); - - String importTargetNamespace = ""; - String prefix = prefixText.getText(); - String uniquePrefix = ""; - - URI uri = URI.createPlatformResourceURI(selectedFile.getFullPath().toString()); - - // note that the getTargetNamespaceURIForSchema works for both schema and wsdl files - // I should change the name of this convenience method - importTargetNamespace = XMLQuickScan.getTargetNamespaceURIForSchema(uri.toString()); - - if (prefix.trim().equals("")) - { - uniquePrefix = getUniquePrefix(definition, uri.fileExtension()); - } - else - { - uniquePrefix = prefix; - } - - - if (importTargetNamespace == null || - (importTargetNamespace != null && importTargetNamespace.trim().length() == 0)) - { - return; // what to do with no namespace docs? - } - - importElement.setAttribute("location", location); - importElement.setAttribute("namespace", importTargetNamespace); - - definitionElement.setAttribute("xmlns:" + uniquePrefix, importTargetNamespace); - - namespaceText.setText(importTargetNamespace); - locationText.setText(location); - prefixText.setText(uniquePrefix); - } - } - } - - private String getUniquePrefix(Definition definition, String initPrefix) - { - String uniquePrefix; - Map map = definition.getNamespaces(); - - if (definition.getNamespace(initPrefix) == null) - { - uniquePrefix = initPrefix; - } - else // if used, then try to create a unique one - { - String tempPrefix = initPrefix; - int i = 1; - while(map.containsKey(tempPrefix + i)) - { - i++; - } - uniquePrefix = tempPrefix + i; - } - return uniquePrefix; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/InputOutputFaultViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/InputOutputFaultViewer.java deleted file mode 100644 index bcd529b4a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/InputOutputFaultViewer.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.ComponentNameComboHelper; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.InvokeDialogButton; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; - -public class InputOutputFaultViewer extends NamedComponentViewer -{ - protected CCombo componentNameCombo; - protected ComponentNameComboHelper componentNameComboHelper; - InvokeDialogButton button; - - public InputOutputFaultViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - String result = ""; - - if (input instanceof Input) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_INPUT"); //$NON-NLS-1$ - } - else if (input instanceof Output) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_OUTPUT"); //$NON-NLS-1$ - } - else if (input instanceof Fault) - { - result = WSDLEditorPlugin.getWSDLString("_UI_LABEL_FAULT"); //$NON-NLS-1$ - } - - return result; - } - - public boolean isObjectExtensible() - { - return false; - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE")); //$NON-NLS-1$ - - componentNameCombo = flatViewUtility.createCComboBox(composite); - componentNameCombo.addListener(SWT.Modify, this); - - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getMessageNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.MESSAGE_ATTRIBUTE; - } - }; - - button = new InvokeDialogButton(composite, getInput()); - button.setEditor(editorPart); - - return composite; - } - - - protected void update() - { - super.update(); - componentNameComboHelper.update(input); - button.setInput(input); - } - - protected void handleEventHelper(Element element, Event event) - { - super.handleEventHelper(element, event); - componentNameComboHelper.handleEventHelper(element, event); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/MessageViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/MessageViewer.java deleted file mode 100644 index 3a8e0c858..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/MessageViewer.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -public class MessageViewer extends NamedComponentViewer -{ - public MessageViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_MESSAGE"); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/NamedComponentViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/NamedComponentViewer.java deleted file mode 100644 index 80a506561..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/NamedComponentViewer.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.SmartRenameAction; -import org.eclipse.wst.wsdl.ui.internal.model.ModelAdapterListener; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLModelAdapterFactory; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; - -public abstract class NamedComponentViewer extends BaseViewer implements ModelAdapterListener -{ - protected Composite control; - protected Text nameField; - protected IEditorPart editorPart; - - public NamedComponentViewer(Composite parent, IEditorPart editorPart) - { - super(getStatusLineManager(editorPart)); - this.editorPart = editorPart; - - createControl(parent); - } - - protected abstract String getHeadingText(); - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite group = flatViewUtility.createComposite(parent, 2, true); - - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Composite nameFieldComposite = flatViewUtility.createComposite(group, 2, true); - ((GridLayout)nameFieldComposite.getLayout()).marginWidth = 0; - ((GridLayout)nameFieldComposite.getLayout()).marginHeight = 0; - - GridLayout layout = new GridLayout(); - layout.makeColumnsEqualWidth = false; - layout.numColumns = 3; - layout.marginHeight = 4; - layout.marginWidth = 0; - - nameFieldComposite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - gd.verticalAlignment = GridData.BEGINNING; - nameFieldComposite.setLayoutData(gd); - - - flatViewUtility.createLabel(nameFieldComposite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAME")); //$NON-NLS-1$ - nameField = flatViewUtility.createTextField(nameFieldComposite); - nameField.addListener(SWT.Modify, this); - - // place holder - Control c = flatViewUtility.createLabel(nameFieldComposite, 0, ""); - c.setBackground(new Color(null, 0, 255, 100)); - gd = new GridData(); - gd.grabExcessHorizontalSpace = false; - gd.heightHint = 0; - gd.widthHint = 0; - c.setLayoutData(gd); - - return nameFieldComposite; - } - - public void createControl(Composite parent) - { - SashForm sashForm = new SashForm(parent, SWT.BORDER); - sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - control = sashForm; - sashForm.setOrientation(SWT.HORIZONTAL); - - Composite composite = flatViewUtility.createComposite(sashForm, 1, true); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = (GridLayout)composite.getLayout(); - layout.verticalSpacing = 0; - layout.marginHeight = 0; - layout.marginWidth = 0; - - flatViewUtility.createFlatPageHeader(composite, getHeadingText()); - - populatePrimaryDetailsSection(composite); - - TabbedViewer tabbedViewer = new TabbedViewer((WSDLEditor)editorPart); - - Control c = tabbedViewer.createControl(sashForm); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - } - - public void doSetInput(Object input) - { - setListenerEnabled(false); - try - { -// Node node = WSDLEditorUtil.getInstance().getNodeForObject(input); - update(); - } - finally - { - setListenerEnabled(true); - } - - if (oldInput != null) - { - WSDLModelAdapterFactory.removeModelAdapterListener(oldInput, this); - } - - WSDLModelAdapterFactory.addModelAdapterListener(input, this); - oldInput = input; - } - - protected void update() - { - Element element = ((WSDLElement)input).getElement(); - flatViewUtility.updateFlatPageHeaderTitle(getHeadingText()); - - nameField.setText(""); - String nameValue = element.getAttribute(WSDLConstants.NAME_ATTRIBUTE); - nameField.setText(nameValue != null ? nameValue : ""); - } - - public Control getControl() - { - return control; - } - - /* - * @see BaseWindow#doHandleEvent(Event) - */ - public void doHandleEvent(Event event) - { - setListenerEnabled(false); - Element element = WSDLEditorUtil.getInstance().getElementForObject(input); - handleEventHelper(element, event); - setListenerEnabled(true); - } - - protected void handleEventHelper(Element element, Event event) - { - if (event.type == SWT.Modify) - { - if (event.widget == nameField) - { - new SmartRenameAction(input, nameField.getText()).run(); - } - } - } - - public void propertyChanged(Object object, String property) - { - if (isListenerEnabled()) - { - setListenerEnabled(false); - if (!control.isDisposed()) - { - update(); - } - setListenerEnabled(true); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/OperationViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/OperationViewer.java deleted file mode 100644 index c0c326e11..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/OperationViewer.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class OperationViewer extends NamedComponentViewer -{ - public OperationViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_OPERATION"); //$NON-NLS-1$ - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_PARAMETER_ORDER")); //$NON-NLS-1$ - Text parameterOrderField = flatViewUtility.createTextField(composite); - parameterOrderField.addListener(SWT.Modify, this); - - //Button button = new Button(composite, SWT.FLAT); - //button.setText("..."); - - return composite; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PartViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PartViewer.java deleted file mode 100644 index f509a79c4..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PartViewer.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.InvokeDialogButton; -import org.w3c.dom.Element; - -public class PartViewer extends NamedComponentViewer -{ - protected CCombo componentNameCombo; - protected CCombo referenceKindCombo; - protected Label componentNameLabel; - InvokeDialogButton button; -// Button importButton; - - - public PartViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_PART"); //$NON-NLS-1$ - } - - public boolean isObjectExtensible() - { - return false; - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - - flatViewUtility.createLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_REFERENCE_KIND")); //$NON-NLS-1$ - referenceKindCombo = flatViewUtility.createCComboBox(composite); - referenceKindCombo.add("element"); - referenceKindCombo.add("type"); - referenceKindCombo.setText("type"); - referenceKindCombo.addListener(SWT.Modify, this); - - flatViewUtility.createLabel(composite, ""); - - componentNameLabel = flatViewUtility.createLabel(composite, WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT")); //$NON-NLS-1$ - - componentNameCombo = flatViewUtility.createCComboBox(composite); - componentNameCombo.addListener(SWT.Modify, this); - componentNameCombo.addSelectionListener(this); - - button = new InvokeDialogButton(composite, getInput()); - - return composite; - } - - protected void update() - { - try - { - Part part = (Part)input; - boolean isType = ComponentReferenceUtil.isType(part); - String value = ComponentReferenceUtil.getPartComponentReference(part); - - // update the combo-box content - // - componentNameCombo.removeAll(); - List compList = ComponentReferenceUtil.getComponentNameList(part, isType); - if (compList != null) - { - for (Iterator iterator = compList.iterator(); iterator.hasNext();) - { - componentNameCombo.add((String)iterator.next()); - } - } - - if (isType) - { - referenceKindCombo.setText("type"); - componentNameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TYPE")); //$NON-NLS-1$ - componentNameCombo.setText(value != null ? value : ""); - button.setReferenceKind("type"); - } - else - { - referenceKindCombo.setText("element"); - componentNameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_ELEMENT")); //$NON-NLS-1$ - componentNameCombo.setText(value != null ? value : ""); - button.setReferenceKind("element"); - } - button.setInput(input); - button.setEditor(editorPart); - super.update(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - - protected void handleEventHelper(Element element, Event event) - { - super.handleEventHelper(element, event); - if (event.type == SWT.Modify) - { - if (event.widget == referenceKindCombo) - { - // TODO... I have no idea why we need to use a delayed runnable to get - // updating working properly .... this is something we need to revisit - DelayedRenameRunnable runnable = new DelayedRenameRunnable((Part)input); - Display.getCurrent().asyncExec(runnable); - } - } - } - - protected class DelayedRenameRunnable implements Runnable - { - Part part; - - DelayedRenameRunnable(Part part) - { - this.part = part; - } - - public void run() - { - boolean isType = referenceKindCombo.getText().equals("type"); - ComponentReferenceUtil.setComponentReference(part, isType, null); - } - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == componentNameCombo) - { - Part part = (Part)input; - boolean isType = referenceKindCombo.getText().equals("type"); - ComponentReferenceUtil.setComponentReference(part, isType, componentNameCombo.getText()); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortTypeViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortTypeViewer.java deleted file mode 100644 index d85fdfc9d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortTypeViewer.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class PortTypeViewer extends NamedComponentViewer -{ - public PortTypeViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORTTYPE"); //$NON-NLS-1$ - } - - public boolean isObjectExtensible() - { - return false; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortViewer.java deleted file mode 100644 index 8e5f3d087..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/PortViewer.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.ComponentNameComboHelper; -import org.eclipse.wst.wsdl.ui.internal.viewers.widgets.InvokeDialogButton; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.w3c.dom.Element; - -public class PortViewer extends NamedComponentViewer -{ - protected CCombo componentNameCombo; - protected ComponentNameComboHelper componentNameComboHelper; - InvokeDialogButton button; - - public PortViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_PORT"); //$NON-NLS-1$ - } - - protected Composite populatePrimaryDetailsSection(Composite parent) - { - Composite composite = super.populatePrimaryDetailsSection(parent); - - flatViewUtility.createLabel(composite, 0, WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING")); //$NON-NLS-1$ - - componentNameCombo = flatViewUtility.createCComboBox(composite); - componentNameCombo.addListener(SWT.Modify, this); - - componentNameComboHelper = new ComponentNameComboHelper(componentNameCombo) - { - protected List getComponentNameList(ComponentReferenceUtil util) - { - return util.getBindingNames(); - } - - protected String getAttributeName() - { - return WSDLConstants.BINDING_ATTRIBUTE; - } - }; - - button = new InvokeDialogButton(composite, getInput()); - button.setEditor(editorPart); - - return composite; - } - - protected void update() - { - super.update(); - componentNameComboHelper.update(input); - button.setInput(input); - } - - protected void handleEventHelper(Element element, Event event) - { - super.handleEventHelper(element, event); - componentNameComboHelper.handleEventHelper(element, event); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ServiceViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ServiceViewer.java deleted file mode 100644 index 01b23cce0..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/ServiceViewer.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class ServiceViewer extends NamedComponentViewer -{ - public ServiceViewer(Composite parent, IEditorPart editorPart) - { - super(parent, editorPart); - } - - protected String getHeadingText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_SERVICE"); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/TabbedViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/TabbedViewer.java deleted file mode 100644 index c44135e7c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/TabbedViewer.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -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.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.AddElementAction; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.xsd.XSDComponent; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class TabbedViewer implements ISelectionChangedListener -{ - protected WSDLEditor editor; - protected CTabFolder tabFolder; - protected Text documentationField; - protected DocumentationListener documentationListener; - protected boolean listenerEnabled; - - public TabbedViewer(WSDLEditor editor) - { - this.editor = editor; - } - - public Control createControl(Composite parent) - { - tabFolder = new CTabFolder(parent, 0); - - CTabItem tab = new CTabItem(tabFolder, SWT.NONE); - tab.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_DOCUMENTION")); //$NON-NLS-1$ - documentationField = new Text(tabFolder, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP); - tab.setControl(documentationField); - tabFolder.setSelection(tab); - - documentationListener = new DocumentationListener(); - listenerEnabled = true; - documentationField.addModifyListener(documentationListener); - - editor.getSelectionManager().addSelectionChangedListener(this); - - return tabFolder; - } - - public void setInput(Object object) - { - listenerEnabled = false; - documentationListener.setInput(object); - documentationField.setEnabled(true); - documentationField.setText(""); - - if (object instanceof XSDComponent || !(object instanceof WSDLElement)) - { - documentationField.setEnabled(false); - listenerEnabled = true; - return; - } - - Element element = WSDLEditorUtil.getInstance().getElementForObject(object); - if (element != null) - { - if (element.getLocalName().equals("documentation")) - { - documentationField.setEnabled(false); - listenerEnabled = true; - return; - } - - Node docNode = getChildNode(element, element.getPrefix(), "documentation"); - if (docNode != null) - { - Node textNode = docNode.getFirstChild(); - if (textNode != null) - { - String textNodeValue = textNode.getNodeValue(); - documentationField.setText(textNodeValue != null ? textNodeValue : ""); - } - } - } - listenerEnabled = true; -// There appears to be a defect in the model...it doesn't return -// the documentationElement even though it exists -// if (object instanceof WSDLElement) -// { -// WSDLElement elem = (WSDLElement)object; -// System.out.println("elem = " + elem); -// -// if (elem != null) -// { -// Element doc = elem.getDocumentationElement(); -// System.out.println("docNode = " + doc); -// if (doc != null) -// { -// Node textNode = doc.getFirstChild(); -// if (textNode != null) -// { -// documentationField.setText(textNode.getNodeValue()); -// } -// } -// } -// } - } - - public void selectionChanged(SelectionChangedEvent event) - { - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection) - { - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o != null) - { - setInput(o); - } - } - } - - public Node getChildNode(Element parent, String prefix, String childName) - { - NodeList list = null; - if (parent != null) - { - list = parent.getChildNodes(); - } - String targetName; - if (prefix != null && prefix.length() > 0) - { - targetName = prefix + ":" + childName; - } - else - { - targetName = childName; - } - - if (list != null) - { - // Performance issue perhaps? - for (int i = 0; i < list.getLength(); i++) - { - if (list.item(i) instanceof Element) - { - if (list.item(i).getNodeName().equals(targetName)) - { - return list.item(i); - } - } - } - } - return null; - } - - - - class DocumentationListener implements ModifyListener - { - Object object; - - public void setInput(Object object) - { - this.object = object; - } - - /** - * @see org.eclipse.swt.events.ModifyListener#modifyText(ModifyEvent) - */ - public void modifyText(ModifyEvent e) - { - if (listenerEnabled) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(object); - if (element != null) - { - Node docNode = getChildNode(element, element.getPrefix(), "documentation"); - if (docNode != null) - { - Node textNode = docNode.getFirstChild(); - if (textNode != null) - { - textNode.setNodeValue(documentationField.getText()); - } - else - { - if (documentationField.getText() != null && documentationField.getText().length() > 0) - { - Document document = docNode.getOwnerDocument(); - org.w3c.dom.Text newTextNode = document.createTextNode(documentationField.getText()); - docNode.appendChild(newTextNode); - } - } - } - else - { - AddElementAction action = new AddElementAction(element, element.getPrefix(), "documentation", element.getFirstChild()); - action.run(); - Element newDocumentation = action.getNewElement(); - - Document document = newDocumentation.getOwnerDocument(); - org.w3c.dom.Text newTextNode = document.createTextNode(documentationField.getText()); - newDocumentation.appendChild(newTextNode); - } - } - } - } - } -} -
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewer.java deleted file mode 100644 index 35c8d23af..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewer.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import java.util.HashMap; - -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.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.xsd.XSDSchema; - - -public class WSDLDetailsViewer implements ISelectionChangedListener -{ - protected WSDLEditor editor; - protected Composite client; - protected PageBook pageBook; - protected ExtensibleDetailsViewerProvider detailsViewerProvider; - protected HashMap viewerMap = new HashMap(); - - protected final static String EMPTY_VIEWER_KEY = "EMPTY_VIEWER_KEY"; - protected Viewer emptyViewer; - - public WSDLDetailsViewer(WSDLEditor editor) - { - this.editor = editor; - detailsViewerProvider = new ExtensibleDetailsViewerProvider(editor); - editor.getSelectionManager().addSelectionChangedListener(this); - } - - public Control createControl(Composite parent) - { - client = pageBook = new PageBook(parent, 0); - pageBook.setLayoutData(new GridData(GridData.FILL_BOTH)); - emptyViewer = new EmptyViewer(pageBook, SWT.NONE); - viewerMap.put(EMPTY_VIEWER_KEY, emptyViewer); - pageBook.showPage(emptyViewer.getControl()); - return client; - } - - public void setInput(Object object) - { - try - { - Object key = detailsViewerProvider.getViewerKey(object); - - if (key == null) - { - key = EMPTY_VIEWER_KEY; - } - Viewer viewer = (Viewer)viewerMap.get(key); - if (viewer == null) - { - viewer = detailsViewerProvider.createViewer(object, pageBook, editor); - if (viewer != null) - { - viewerMap.put(key, viewer); - if (viewer instanceof OperationViewer) - { - - } - } - } - - if (viewer != null) - { - if (object instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement schema = (XSDSchemaExtensibilityElement)object; - XSDSchema xsdSchema = schema.getSchema(); - if (xsdSchema != null) - { - viewer.setInput(xsdSchema.getElement()); - } - } - else - { - viewer.setInput(object); - } - pageBook.showPage(viewer.getControl()); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void selectionChanged(SelectionChangedEvent event) - { - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection) - { - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o instanceof WSDLGroupObject) - { - o = ((WSDLGroupObject)o).getDefinition(); - } - setInput(o); - } - } -} -
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewerProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewerProvider.java deleted file mode 100644 index 216af1e37..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/WSDLDetailsViewerProvider.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingFault; -import org.eclipse.wst.wsdl.BindingInput; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.BindingOutput; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ExtensibilityElement; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.ui.internal.extension.IDetailsViewerProvider; - -public class WSDLDetailsViewerProvider implements IDetailsViewerProvider -{ - public Object getViewerKey(Object modelObject) - { - Object result = null; - - // todo.... use a switch - if (modelObject instanceof Message) - { - result = "message"; - } - else if (modelObject instanceof Binding) - { - result = "binding"; - } - else if (modelObject instanceof BindingOperation) - { - result = "bindingOperation"; - } - else if (modelObject instanceof Operation) - { - result = "operation"; - } - else if (modelObject instanceof Definition) - { - result = "definition"; - } - else if (modelObject instanceof Part) - { - result = "part"; - } - else if (modelObject instanceof Port) - { - result = "port"; - } - else if (modelObject instanceof Input || - modelObject instanceof Output || - modelObject instanceof Fault) - { - result = "inputOutputFault"; - } - else if (modelObject instanceof BindingInput || - modelObject instanceof BindingOutput || - modelObject instanceof BindingFault) - { - result = "bindingInputOutputFault"; - } - else if (modelObject instanceof PortType) - { - result = "portType"; - } - else if (modelObject instanceof Service) - { - result = "service"; - } - else if (modelObject instanceof ExtensibilityElement) - { - result = "extensibilityElement"; - } - else if (modelObject instanceof Import) - { - result = "import"; - } - else - { - result = "empty"; - } - return result; - } - - - public Viewer createViewer(Object modelObject, Composite parent, IEditorPart editorPart) - { - Viewer viewer = null; - Object key = getViewerKey(modelObject); - if (key != null) - { - if (key.equals("message")) - { - viewer = new MessageViewer(parent, editorPart); - } - else if (key.equals("binding")) - { - viewer = new BindingViewer(parent, editorPart); - } - else if (key.equals("definition")) - { - viewer = new DefinitionViewer(parent, editorPart); - } - else if (key.equals("bindingOperation")) - { - viewer = new BindingOperationViewer(parent, editorPart); - } - else if (key.equals("operation")) - { - viewer = new OperationViewer(parent, editorPart); - } - else if (key.equals("part")) - { - viewer = new PartViewer(parent, editorPart); - } - else if (key.equals("port")) - { - viewer = new PortViewer(parent, editorPart); - } - else if (key.equals("inputOutputFault")) - { - viewer = new InputOutputFaultViewer(parent, editorPart); - } - else if (key.equals("bindingInputOutputFault")) - { - viewer = new BindingInputOutputFaultViewer(parent, editorPart); - } - else if (key.equals("service")) - { - viewer = new ServiceViewer(parent, editorPart); - } - else if (key.equals("extensibilityElement")) - { - viewer = new ExtensibilityElementViewer(parent, editorPart); - } - else if (key.equals("portType")) - { - viewer = new PortTypeViewer(parent, editorPart); - } - else if (key.equals("import")) - { - viewer = new ImportViewer(parent, editorPart); - } - else - { - viewer = new EmptyViewer(parent, 0); - } - } - return viewer; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/AttributesTable.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/AttributesTable.java deleted file mode 100644 index 26b04cc6b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/AttributesTable.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - -import java.text.Collator; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.w3c.dom.Element; - -public class AttributesTable extends TableViewer implements ICellModifier -{ - protected static final String PROPERTY = WSDLEditorPlugin.getWSDLString("_UI_LABEL_PROPERTY"); //$NON-NLS-1$ - protected static final String VALUE = WSDLEditorPlugin.getWSDLString("_UI_LABEL_VALUE"); //$NON-NLS-1$ - - protected IEditorPart editorPart; - protected String[] columnProperties = {PROPERTY, VALUE}; - protected PropertyTableProvider tableProvider = new PropertyTableProvider(this); - protected CellEditor textCellEditor; - //protected StringComboBoxCellEditor comboCellEditor; - protected IPropertySource propertySource; - - - public AttributesTable(IEditorPart editorPart, Composite parent) - { - super(new Table(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.FLAT)); - this.editorPart = editorPart; - getTable().setLinesVisible(true); - getTable().setHeaderVisible(true); - - setContentProvider(tableProvider); - setLabelProvider(tableProvider); - setColumnProperties(columnProperties); - - for (int i = 0; i < columnProperties.length; i++) - { - TableColumn column = new TableColumn(getTable(), SWT.NONE, i); - column.setText(columnProperties[i]); - column.setAlignment(SWT.LEFT); - } - - TableLayout layout = new TableLayout(); - ColumnWeightData data = new ColumnWeightData(40, 40, true); - layout.addColumnData(data); - - ColumnWeightData data2 = new ColumnWeightData(80, 80, true); - layout.addColumnData(data2); - - getTable().setLayout(layout); - - textCellEditor = new TextCellEditor(getTable()); - resetCellEditors(); - - setCellModifier(this); - } - - protected void hookControl(Control control) { - // we need to hook up our own mouse listener first - // so that we can update the cellEditors before - // the 'internal' listener tries to get hold of them - Table tableControl = (Table)control; - tableControl.addMouseListener(new MouseAdapter() { - public void mouseDown(MouseEvent e) { - updateCellEditors(); - } - }); - super.hookControl(control); - } - - // ICellModifier - public boolean canModify(Object element, String property) - { - return property.equals(VALUE); - } - - public Object getValue(Object element, String property) - { - int column = 0; - if (property.equals(columnProperties[0])) - { - column = 0; - } - else if (property.equals(columnProperties[1])) - { - column = 1; - } - return tableProvider.getColumnText(element, column); - } - - public void modify(Object element, String property, Object value) - { - TableItem item = (TableItem)element; - IPropertyDescriptor propertyDescriptor = (IPropertyDescriptor)item.getData(); - - // if the new value is the same as the old value, the user has only clicked - // on the cell in the course of 'browsing' ... so don't edit the value - Object oldValue = getValue(propertyDescriptor, property); - if (value != null && !value.equals(oldValue)) - { - // we assume the value is empty that the attribute should be removed - // todo... we probably need to look at this in more detail - if (value instanceof String && ((String)value).length() == 0) - { - value = null; - } - propertySource.setPropertyValue(propertyDescriptor.getId(), value); - refresh(item.getData()); - } - } - - - protected void updateCellEditors() - { - CellEditor[] cellEditors = new CellEditor[2]; - cellEditors[0] = textCellEditor; - cellEditors[1] = textCellEditor; - - IPropertyDescriptor[] propertyDescriptors = propertySource.getPropertyDescriptors(); - int index = getTable().getSelectionIndex(); - if (index >= 0 && index < propertyDescriptors.length) - { - CellEditor[] oldCellEditors = getCellEditors(); - CellEditor oldCellEditor = (oldCellEditors.length > 1) ? oldCellEditors[1] : null; - if (oldCellEditor != null && oldCellEditor != textCellEditor) - { - oldCellEditor.deactivate(); - oldCellEditor.dispose(); - } - cellEditors[1] = propertyDescriptors[index].createPropertyEditor(getTable()); - } - setCellEditors(cellEditors); - } - - - public String[] getStringArray(List list) - { - String[] result = new String[list.size()]; - for (int i = 0; i < result.length; i++) - { - result[i] = (String)list.get(i); - } - return result; - } - - protected void resetCellEditors() - { - CellEditor[] cellEditors = new CellEditor[2]; - cellEditors[0] = textCellEditor; - cellEditors[1] = textCellEditor; - setCellEditors(cellEditors); - } - - - class PropertyTableProvider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider - { - protected TableViewer viewer; - - PropertyTableProvider(TableViewer viewer) - { - this.viewer = viewer; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - resetCellEditors(); - if (newInput instanceof IDOMElement) - { - propertySource = new ExtensiblePropertySource(editorPart, (IDOMElement)newInput); - } - else if (newInput instanceof Element) - { - propertySource = new ReadOnlyPropertySource(editorPart, (Element)newInput); - } - else - { - propertySource = null; - } - } - - public Image getColumnImage(Object element, int columnIndex) - { - return null; - } - - public String getColumnText(Object o, int columnIndex) - { - IPropertyDescriptor propertyDescriptor = (IPropertyDescriptor)o; - return (columnIndex == 0) ? propertyDescriptor.getId().toString() : propertySource.getPropertyValue(propertyDescriptor.getId()).toString(); - } - - public Object[] getElements(Object o) - { - Object[] result = propertySource.getPropertyDescriptors(); - // For some strange reson the ViewerSorter doesn't seem to be working for this table - // As a workaround we sort them in this method before returning them to the viewer - if (result.length > 0) - { - Arrays.sort(result, new InternalComparator()); - } - return result; - } - } - - class InternalComparator implements Comparator - { - public int compare(Object e1, Object e2) - { - IPropertyDescriptor p1 = (IPropertyDescriptor)e1; - IPropertyDescriptor p2 = (IPropertyDescriptor)e2; - return Collator.getInstance().compare(p1.getDisplayName(), p2.getDisplayName()); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentNameComboHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentNameComboHelper.java deleted file mode 100644 index 224ce561a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentNameComboHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Event; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.w3c.dom.Element; - - -// A convenience class -// -public abstract class ComponentNameComboHelper -{ - protected CCombo componentNameCombo; - - public ComponentNameComboHelper(CCombo componentNameCombo) - { - this.componentNameCombo = componentNameCombo; - } - - public void update(Object input) - { - Element element = ((WSDLElement)input).getElement(); - componentNameCombo.removeAll(); - String value = element.getAttribute(getAttributeName()); - componentNameCombo.setText(value != null ? value : ""); - - if (input instanceof WSDLElement) - { - Definition definition = ((WSDLElement)input).getEnclosingDefinition(); - ComponentReferenceUtil componentReferenceUtil = new ComponentReferenceUtil(definition); - java.util.List list = getComponentNameList(componentReferenceUtil); - for (Iterator iter = list.iterator(); iter.hasNext();) - { - componentNameCombo.add((String)iter.next()); - } - } - } - - public void handleEventHelper(Element element, Event event) - { - if (event.type == SWT.Modify) - { - if (event.widget == componentNameCombo) - { - element.setAttribute(getAttributeName(), componentNameCombo.getText()); - } - } - } - - protected abstract List getComponentNameList(ComponentReferenceUtil util); - - protected abstract String getAttributeName(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentsSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentsSection.java deleted file mode 100644 index 57225bee9..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ComponentsSection.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.flatui.FlatPageSection; -import org.eclipse.wst.wsdl.ui.internal.util.flatui.WidgetFactory; -import org.eclipse.wst.wsdl.ui.internal.util.ui.FlatViewUtility; - -public class ComponentsSection extends FlatPageSection -{ - protected CCombo namesCombo; - protected Button newButton; - protected Button importButton; - protected String title; - - public ComponentsSection(Composite parent, FlatViewUtility flatViewUtility, String title) - { - this(parent, title); - - WidgetFactory factory = new WidgetFactory(); - factory.setClientAreaColor(flatViewUtility.getBackgroundColor()); - - Control section = createControl(this, factory); - setContent(section); - - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - setLayoutData(gridData); - } - - - public ComponentsSection(Composite parent, String title) - { - super(parent); - setCollapsable(true); - setHeaderText(title); - setAddSeparator(true); - } - - public CCombo getNamesCombo() - { - return namesCombo; - } - - public Button getNewMessageButton() - { - return newButton; - } - - public Button getImportMessageButton() - { - return importButton; - } - - /* - * @see FlatPageSection#createClient(Composite, WidgetFactory) - */ - public Composite createClient(Composite parent, WidgetFactory factory) - { - FlatViewUtility flatViewUtility = new FlatViewUtility(true); - - Composite client = flatViewUtility.createComposite(parent, 1); - - namesCombo = flatViewUtility.createCComboBox(client); - - Composite buttonComposite = flatViewUtility.createComposite(client, 3, true); - GridLayout gridLayout = (GridLayout)buttonComposite.getLayout(); - gridLayout.marginWidth = 3; - gridLayout.marginHeight = 3; - gridLayout.makeColumnsEqualWidth = true; - - Label filler = flatViewUtility.createHorizontalFiller(buttonComposite, 1); - GridData gd = (GridData)filler.getLayoutData(); - gd.grabExcessHorizontalSpace = true; - newButton = flatViewUtility.createPushButton(buttonComposite, WSDLEditorPlugin.getWSDLString("_UI_BUTTON_NEW")); //$NON-NLS-1$ - importButton = flatViewUtility.createPushButton(buttonComposite, WSDLEditorPlugin.getWSDLString("_UI_BUTTON_IMPORT")); //$NON-NLS-1$ - - return client; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ExtensiblePropertySource.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ExtensiblePropertySource.java deleted file mode 100644 index b6e6f3017..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ExtensiblePropertySource.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.properties.section.IPropertyDescriptorProvider; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.ui.internal.properties.XMLPropertySource; -import org.w3c.dom.Element; - -public class ExtensiblePropertySource extends XMLPropertySource -{ - protected IEditorPart editorPart; - private INodeNotifier nodeNotifier; - - public ExtensiblePropertySource(IEditorPart editorPart, INodeNotifier target) - { - super(target); - this.editorPart = editorPart; - this.nodeNotifier = target; - } - - - - protected IPropertyDescriptor createPropertyDescriptor(CMAttributeDeclaration attrDecl) - { - IPropertyDescriptor result = null; - CMDocument cmDocument = (CMDocument)attrDecl.getProperty("CMDocument"); - if (cmDocument != null) - { - String namespaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); - if (namespaceURI != null) - { - IPropertyDescriptorProvider provider = (IPropertyDescriptorProvider)WSDLEditorPlugin.getInstance().getPropertyDescriptorProviderRegistry().getProperty(namespaceURI, ""); - if (provider != null) - { - result = provider.getPropertyDescriptor(editorPart, (Element) nodeNotifier, namespaceURI, attrDecl.getNodeName()); - } - } - } - if (result == null) - { - result = super.createPropertyDescriptor(attrDecl); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/InvokeDialogButton.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/InvokeDialogButton.java deleted file mode 100644 index 5b1906b1e..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/InvokeDialogButton.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.ui.internal.dialogs.InvokeSetDialog; - -// instead of using a Button directly (which causes sizing/layout problems) -// we use this class -public class InvokeDialogButton extends Composite implements SelectionListener -{ - protected Button button; - protected Object input; - protected Composite parent; - protected IEditorPart editorPart; - protected String kind; - - public InvokeDialogButton(Composite parent, Object input) - { - super(parent, SWT.NONE); - this.parent = parent; - this.input = input; - GridData gd = new GridData(); - gd.grabExcessHorizontalSpace = false; - gd.grabExcessVerticalSpace = false; - setLayoutData(gd); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - setLayout(layout); - - button = new Button(this, SWT.NONE); - gd = new GridData(); - gd.grabExcessHorizontalSpace = false; - gd.heightHint = 17; - gd.widthHint = 24; - button.setLayoutData(gd); - button.setText("..."); - button.addSelectionListener(this); - } - - public Button getButton() - { - return button; - } - - public void setInput(Object input) - { - this.input = input; - } - - public void setEditor(IEditorPart editorPart) - { - this.editorPart = editorPart; - } - - public void setReferenceKind(String kind) - { - this.kind = kind; - } - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == button) - { - InvokeSetDialog dialog = new InvokeSetDialog(); - if (input instanceof Part) - { - dialog.setReferenceKind(kind); - } - dialog.run(input, editorPart); - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ReadOnlyPropertySource.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ReadOnlyPropertySource.java deleted file mode 100644 index 7f48c9451..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/viewers/widgets/ReadOnlyPropertySource.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.viewers.widgets; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; - -public class ReadOnlyPropertySource implements IPropertySource -{ - protected Element element; - - public ReadOnlyPropertySource(IEditorPart editPart, Element element) - { - this.element = element; - } - - public Object getEditableValue() - { - return null; - } - - public IPropertyDescriptor[] getPropertyDescriptors() - { - List list = new ArrayList(); - NamedNodeMap map = element.getAttributes(); - int mapLength = map.getLength(); - for (int i = 0; i < mapLength; i++) - { - Attr attr = (Attr) map.item(i); - list.add(new PropertyDescriptor(attr.getName(), attr.getName())); - } - IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()]; - list.toArray(result); - return result; - } - - public Object getPropertyValue(Object id) - { - Object result = null; - if (id instanceof String) - { - result = element.getAttribute((String) id); - } - return result != null ? result : ""; - } - - public boolean isPropertySet(Object id) - { - return false; - } - - public void resetPropertyValue(Object id) - { - } - - public void setPropertyValue(Object id, Object value) - { - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BaseRenamer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BaseRenamer.java deleted file mode 100644 index f92d94286..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BaseRenamer.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.visitor; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.WSDLElement; - -public abstract class BaseRenamer extends WSDLVisitor -{ - protected String newName; - protected WSDLElement globalComponent; - - public BaseRenamer(WSDLElement globalComponent, String newName) - { - super(globalComponent.getEnclosingDefinition()); - this.globalComponent = globalComponent; - this.newName = newName; - } - - public String getNewQName() - { - String qName = null; - if (newName != null) - { - Definition definition = globalComponent.getEnclosingDefinition(); - qName = definition.getPrefix(definition.getTargetNamespace()); - qName += ":" + newName; - } - else - { - qName = newName; - } - - return qName; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BindingRenamer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BindingRenamer.java deleted file mode 100644 index b85cf04da..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/BindingRenamer.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.visitor; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - -public class BindingRenamer extends BaseRenamer -{ - /** - * Constructor for BindingRenamer. - * @param globalComponent - * @param newName - */ - public BindingRenamer(WSDLElement globalComponent, String newName) - { - super(globalComponent, newName); - } - - public void visitPort(Port port) - { - super.visitPort(port); - Binding binding = port.getEBinding(); - if (globalComponent.equals(binding)) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(port); - element.setAttribute("binding", getNewQName()); - } - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/MessageRenamer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/MessageRenamer.java deleted file mode 100644 index 75cf21e8a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/MessageRenamer.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.visitor; - -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - -public class MessageRenamer extends BaseRenamer -{ - /** - * Constructor for MessageRenamer. - * @param globalComponent - * @param newName - */ - public MessageRenamer(WSDLElement globalComponent, String newName) - { - super(globalComponent, newName); - } - - public void visitInput(Input input) - { - super.visitInput(input); - Message message = input.getEMessage(); - if (globalComponent.equals(message)) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(input); - element.setAttribute("message", getNewQName()); - } - } - - public void visitOutput(Output output) - { - super.visitOutput(output); - if (globalComponent.equals(output)) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(output); - element.setAttribute("message", getNewQName()); - } - } - - public void visitFault(Fault fault) - { - super.visitFault(fault); - if (globalComponent.equals(fault)) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(fault); - element.setAttribute("message", getNewQName()); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/PortTypeRenamer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/PortTypeRenamer.java deleted file mode 100644 index da4d02935..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/PortTypeRenamer.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.visitor; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.WSDLElement; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.w3c.dom.Element; - -public class PortTypeRenamer extends BaseRenamer -{ - /** - * Constructor for PortTypeRenamer. - * @param globalComponent - * @param newName - */ - public PortTypeRenamer(WSDLElement globalComponent, String newName) - { - super(globalComponent, newName); - } - - public void visitBinding(Binding binding) - { - super.visitBinding(binding); - PortType portType = binding.getEPortType(); - - if (globalComponent.equals(portType)) - { - Element element = WSDLEditorUtil.getInstance().getElementForObject(binding); - element.setAttribute("type", getNewQName()); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/WSDLVisitor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/WSDLVisitor.java deleted file mode 100644 index 8100d4e0a..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/visitor/WSDLVisitor.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.visitor; - -import java.util.Iterator; - -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.BindingOperation; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Fault; -import org.eclipse.wst.wsdl.Input; -import org.eclipse.wst.wsdl.Message; -import org.eclipse.wst.wsdl.Operation; -import org.eclipse.wst.wsdl.Output; -import org.eclipse.wst.wsdl.Part; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.PortType; -import org.eclipse.wst.wsdl.Service; - -public class WSDLVisitor -{ - protected Definition definition; - - - public WSDLVisitor(Definition definition) - { - this.definition = definition; - } - - - public void visitDefinition() - { - visitBindings(); - visitMessages(); - visitPortTypes(); - visitServices(); - } - - public void visitBindings() - { - for (Iterator iterator = definition.getEBindings().iterator(); iterator.hasNext(); ) - { - Binding binding = (Binding)iterator.next(); - visitBinding(binding); - } - } - - public void visitMessages() - { - for (Iterator iterator = definition.getEMessages().iterator(); iterator.hasNext(); ) - { - Message message = (Message)iterator.next(); - visitMessage(message); - } - } - - public void visitPortTypes() - { - for (Iterator iterator = definition.getEPortTypes().iterator(); iterator.hasNext(); ) - { - PortType portType = (PortType)iterator.next(); - visitPortType(portType); - } - } - - public void visitServices() - { - for (Iterator iterator = definition.getEServices().iterator(); iterator.hasNext(); ) - { - Service service = (Service)iterator.next(); - visitService(service); - } - } - - public void visitBinding(Binding binding) - { - PortType portType = binding.getEPortType(); - if (portType != null) - { - visitPortType(portType); - } - - for (Iterator iterator = binding.getEBindingOperations().iterator(); iterator.hasNext(); ) - { - BindingOperation bindingOperation = (BindingOperation)iterator.next(); - visitBindingOperation(bindingOperation); - } - } - - public void visitPortType(PortType portType) - { - for (Iterator iterator = portType.getEOperations().iterator(); iterator.hasNext(); ) - { - Operation operation = (Operation)iterator.next(); - visitOperation(operation); - } - } - - public void visitBindingOperation(BindingOperation bindingOperation) - { -// BindingInput bindingInput = bindingOperation.getEBindingInput(); -// BindingOutput bindingOutput = bindingOperation.getEBindingOutput(); - } - - public void visitOperation(Operation operation) - { - Input input = operation.getEInput(); - Output output = operation.getEOutput(); - - if (input != null) - { - visitInput(input); - } - if (output != null) - { - visitOutput(output); - } - - for (Iterator iterator = operation.getEFaults().iterator(); iterator.hasNext(); ) - { - Fault fault = (Fault)iterator.next(); - if (fault != null) - { - visitFault(fault); - } - } - - } - - public void visitPart(Part part) - { -// XSDTypeDefinition type = part.getTypeDefinition(); - } - - public void visitMessage(Message message) - { - for (Iterator iterator = message.getEParts().iterator(); iterator.hasNext(); ) - { - Part part = (Part)iterator.next(); - visitPart(part); - } - } - - public void visitInput(Input input) - { - Message message = input.getEMessage(); - if (message != null) - { - visitMessage(message); - } - } - - public void visitOutput(Output output) - { - Message message = output.getEMessage(); - if (message != null) - { - visitMessage(message); - } - } - - public void visitFault(Fault fault) - { - Message message = fault.getEMessage(); - if (message != null) - { - visitMessage(message); - } - } - - public void visitPort(Port port) - { - Binding binding = port.getEBinding(); - if (binding != null) - { - visitBinding(binding); - } - } - - public void visitService(Service service) - { - for (Iterator iterator = service.getEPorts().iterator(); iterator.hasNext(); ) - { - Port port = (Port)iterator.next(); - visitPort(port); - } - - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentDialog.java deleted file mode 100644 index cbb04c33d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentDialog.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.widgets; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class NewComponentDialog extends Dialog implements ModifyListener -{ - protected Text nameField; - protected Button okButton; - protected String name; - protected String title; - protected Label errorMessageLabel; - protected List usedNames; - - public NewComponentDialog(Shell parentShell, String title, String defaultName) - { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - name = defaultName; - this.title = title; - } - - public NewComponentDialog(Shell parentShell, String title, String defaultName, List usedNames) - { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - name = defaultName; - this.title = title; - this.usedNames = usedNames; - } - - public int createAndOpen() - { - create(); - getShell().setText(title); - setBlockOnOpen(true); - return open(); - } - - protected Control createContents(Composite parent) - { - Control control = super.createContents(parent); - nameField.forceFocus(); - nameField.selectAll(); - updateErrorMessage(); - return control; - } - - - protected void createButtonsForButtonBar(Composite parent) - { - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - protected void createHeaderContent(Composite parent) - { - } - - protected void createExtendedContent(Composite parent) - { - } - - protected Control createDialogArea(Composite parent) - { - Composite dialogArea = (Composite)super.createDialogArea(parent); - - createHeaderContent(dialogArea); - - Composite composite = new Composite(dialogArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - composite.setLayout(layout); - - GridData gdFill= new GridData(); - gdFill.horizontalAlignment= GridData.FILL; - gdFill.grabExcessHorizontalSpace= true; - gdFill.verticalAlignment= GridData.FILL; - gdFill.grabExcessVerticalSpace= true; - composite.setLayoutData(gdFill); - - Label nameLabel = new Label(composite, SWT.NONE); - nameLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAME")); //$NON-NLS-1$ - - nameField = new Text(composite, SWT.SINGLE | SWT.BORDER); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.widthHint = 200; - nameField.setLayoutData(gd); - nameField.setText(name); - nameField.addModifyListener(this); - - createExtendedContent(dialogArea); - - // error message - errorMessageLabel = new Label(dialogArea, SWT.NONE); - errorMessageLabel.setText("error message goes here"); - GridData gd2 = new GridData(); - gd2.horizontalAlignment= GridData.FILL; - gd2.grabExcessHorizontalSpace= true; - gd2.widthHint = 200; - errorMessageLabel.setLayoutData(gd2); -// Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0); -// errorMessageLabel.setForeground(color); - - return dialogArea; - } - - public void modifyText(ModifyEvent e) - { - updateErrorMessage(); - } - - protected String computeErrorMessage(String name) - { - if (usedNames == null) - return null; - - Iterator iterator = usedNames.iterator(); - while (iterator.hasNext()) { - if (name.equalsIgnoreCase((String) iterator.next())) { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_WARNING_DUPLICATE_NAME_EXISTS"); - } - } - - return null; - } - - protected void updateErrorMessage() - { - String errorMessage = null; - String name = nameField.getText().trim(); - if (name.length() > 0) - { - errorMessage = computeErrorMessage(name); - } - else - { - errorMessage = ""; - } - errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); -// okButton.setEnabled(errorMessage == null); - } - - protected void buttonPressed(int buttonId) - { - if (buttonId == IDialogConstants.OK_ID) - { - name = nameField.getText(); - } - super.buttonPressed(buttonId); - } - - public String getName() - { - return name; - } -} - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentWithChildDialog.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentWithChildDialog.java deleted file mode 100644 index 4c5091970..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/NewComponentWithChildDialog.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.widgets; - -import java.util.List; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - - -/* - * This class extends NewComponentDialog to allow additional widgets. More - * specifically, the 'create sub-components' checkbox - */ -public class NewComponentWithChildDialog extends NewComponentDialog { - protected Button createMessageCheckBox; - private boolean createMessageBoolean; - - public NewComponentWithChildDialog(Shell parentShell, String title, String defaultName) { - super(parentShell, title, defaultName); - } - - public NewComponentWithChildDialog(Shell parentShell, String title, String defaultName, List usedNames) { - super(parentShell, title, defaultName, usedNames); - } - - protected void createExtendedContent(Composite parent) { - Composite child = new Composite (parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - layout.marginHeight = 0; - child.setLayout(layout); - - createMessageCheckBox = new Button(child, SWT.CHECK); - createMessageCheckBox.setSelection(true); - createMessageCheckBox.setText(WSDLEditorPlugin.getWSDLString("_UI_CREATE_MESSAGE_CHECKBOX_LABEL")); - } - - public boolean createSubComponents() { - return createMessageBoolean; - } - - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - createMessageBoolean = createMessageCheckBox.getSelection(); - } - super.buttonPressed(buttonId); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/ProtocolComponentControl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/ProtocolComponentControl.java deleted file mode 100644 index 53c990550..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/widgets/ProtocolComponentControl.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.widgets; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.part.PageBook; -import org.eclipse.wst.wsdl.internal.generator.BaseGenerator; -import org.eclipse.wst.wsdl.internal.generator.ContentGenerator; -import org.eclipse.wst.wsdl.internal.generator.extension.ContentGeneratorExtensionFactoryRegistry; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.ContentGeneratorOptionsPage; - -public abstract class ProtocolComponentControl extends Composite implements SelectionListener, ModifyListener -{ - protected BaseGenerator generator; - - protected Text componentNameField; - protected Combo refNameCombo; - protected Button refBrowseButton; - protected Combo protocolCombo; - protected Button overwriteButton; - protected PageBook pageBook; - protected Composite emptySettingsPage; - protected Map pageMap = new HashMap(); - - // List of ContentGenerators for each Protocol found in protocolCombo - protected List contentGenerators; - - //protected boolean isBindingComponent = true; - //protected boolean isNewComponent = true; - protected String name; - protected String refName; - - protected String UNSPECIFIED = WSDLEditorPlugin.getWSDLString("_UI_UNSPECIFIED"); - //protected BindingGenerator bindingGenerator; - - public ProtocolComponentControl(Composite parent, BaseGenerator generator, boolean showOverwriteButton) - { - super(parent, SWT.NONE); - this.generator = generator; - contentGenerators = new ArrayList(); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - setLayout(layout); - setLayoutData(createGridData(true, 1)); - - Composite labelValueComposite = new Composite(this, SWT.NONE); - labelValueComposite.setLayout(new GridLayout(2, false)); - labelValueComposite.setLayoutData(createGridData(false, 1)); - - // row 1 - // - Label componentNameLabel = new Label(labelValueComposite, SWT.NONE); - componentNameLabel.setText(getComponentNameLabelText()); //$NON-NLS-1$ - - componentNameField = new Text(labelValueComposite, SWT.BORDER); - GridData gdName= new GridData(); - gdName.horizontalAlignment= GridData.FILL; - gdName.grabExcessHorizontalSpace= true; - componentNameField.setLayoutData(gdName); - componentNameField.addModifyListener(this); - //createPlaceHolder(labelValueComposite); - - // row 2 - // - Label refNameLabel = new Label(labelValueComposite, SWT.NONE); - refNameLabel.setText(getRefNameLabelText()); //$NON-NLS-1$ - refNameCombo = new Combo(labelValueComposite, SWT.READ_ONLY); - GridData gdRefName= new GridData(); - gdRefName.horizontalAlignment= GridData.FILL; - gdRefName.grabExcessHorizontalSpace= true; - refNameCombo.setLayoutData(gdRefName); - refNameCombo.addSelectionListener(this); - - //refBrowseButton = new Button(labelValueComposite, SWT.NONE); - //refBrowseButton.setText(" ... "); - //GridData gd = new GridData(); - //gd.grabExcessHorizontalSpace = false; - //gd.heightHint = 17; - //gd.widthHint = 24; - //refBrowseButton.setLayoutData(gd); - //refBrowseButton.addSelectionListener(this); - //createPlaceHolder(labelValueComposite); - - // row 3 - // - Label protocolLabel = new Label(labelValueComposite, SWT.NONE); - protocolLabel.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_PROTOCOL")); //$NON-NLS-1$ - protocolCombo = new Combo(labelValueComposite, SWT.READ_ONLY); - GridData gdProtocol= new GridData(); - gdProtocol.horizontalAlignment= GridData.FILL; - gdProtocol.grabExcessHorizontalSpace= true; - protocolCombo.setLayoutData(gdProtocol); - protocolCombo.addSelectionListener(this); - //createPlaceHolder(labelValueComposite); - - // optional overwrite button - // - if (showOverwriteButton) - { - overwriteButton = new Button(this, SWT.CHECK); - overwriteButton.setText(WSDLEditorPlugin.getWSDLString("_UI_CHECKBOX_OVERWRITE")); //$NON-NLS-1$ - overwriteButton.addSelectionListener(this); - } - - // protocol specific settings - // - pageBook = new PageBook(this, SWT.NONE); - GridData gdFill= new GridData(); - gdFill.horizontalAlignment= GridData.FILL; - gdFill.grabExcessHorizontalSpace= true; - gdFill.verticalAlignment= GridData.FILL; - gdFill.grabExcessVerticalSpace= true; - pageBook.setLayoutData(gdFill); - - emptySettingsPage = new Composite(pageBook, SWT.NONE); - for (int i = 0; i < 6; i++) - { - new Label(emptySettingsPage, SWT.NONE); - } - } - - public void initFields() - { - // prime the fields - // - componentNameField.setText(getDefaultName()); - updateRefNameCombo(); - updateProtocolCombo(); - updatePageBook(generator.getProtocol()); - } - - public Text getComponentNameField() - { - return componentNameField; - } - - public String getComponentNameLabelText() - { - return WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAME"); - } - - private GridData createGridData(boolean both, int span) - { - GridData gd = new GridData(both ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL); - gd.horizontalSpan = span; - return gd; - } - -// private Control createPlaceHolder(Composite parent) -// { -// Label label = new Label(parent, SWT.NONE); -// return label; -// } - public BaseGenerator getGenerator() - { - return generator; - } - - // implements SelectionListener - // - public void widgetDefaultSelected(SelectionEvent event) - { - } - - public void widgetSelected(SelectionEvent event) - { - if (event.widget == overwriteButton && overwriteButton != null) - { - getGenerator().setOverwrite(overwriteButton.getSelection()); - } - else if (event.widget == refNameCombo) - { - int index = refNameCombo.getSelectionIndex(); - String refName = refNameCombo.getItem(index); - if (refName.equals(UNSPECIFIED)) { - getGenerator().setRefName(""); - } - else { - getGenerator().setRefName(refName); - } - } - else if (event.widget == protocolCombo) - { - int index = protocolCombo.getSelectionIndex(); - String protocol = (index != -1) ? protocolCombo.getItem(index) : null; - getGenerator().setContentGenerator((ContentGenerator) contentGenerators.get(index)); - updatePageBook(protocol); - } - } - - private static final String IS_OVERWRITE_APPLICABLE = "IS_OVERWRITE_APPLICABLE"; - protected void updatePageBook(String protocol) - { - if (protocol != null) - { - ContentGeneratorOptionsPage page = (ContentGeneratorOptionsPage) pageMap.get(protocol); - if (page == null) - { - page = createContentGeneratorOptionsPage(protocol); - - if (page != null) - { - page.init(getGenerator()); - Control control = page.createControl(pageBook); - control.setData(IS_OVERWRITE_APPLICABLE, new Boolean(page.isOverwriteApplicable())); - pageMap.put(protocol, page); - } - -// if (page != null) -// { -// pageMap.put(protocol, page); -// } - } - - boolean enableOverwriteButton = true; - if (page != null) - { - if (overwriteButton != null) - { - Boolean data = (Boolean) page.getControl().getData(IS_OVERWRITE_APPLICABLE); - enableOverwriteButton = data == null || data.equals(Boolean.TRUE); - } - pageBook.showPage(page.getControl()); - pageBook.layout(); - pageBook.getParent().layout(); - - page.setOptionsOnGenerator(); - } - else - { - pageBook.showPage(emptySettingsPage); - } - - if (overwriteButton != null) - { - if (enableOverwriteButton) - { - overwriteButton.setEnabled(true); - overwriteButton.setSelection(generator.getOverwrite()); - } - else - { - overwriteButton.setEnabled(false); - overwriteButton.setSelection(true); - } - } - } - } - - protected void updateProtocolCombo() - { - protocolCombo.removeAll(); - - List list = new ArrayList(); - list.add(UNSPECIFIED); -// list.addAll(WSDLEditorPlugin.getInstance().getContentGeneratorExtensionRegistry().getBindingExtensionNames()); - list.addAll(ContentGeneratorExtensionFactoryRegistry.getInstance().getBindingExtensionNames()); - - String protocolText = generator.getProtocol(); - - for (Iterator i = list.iterator(); i.hasNext();) - { - String protocol = (String) i.next(); - protocolCombo.add(protocol); - - if (protocol.equals(UNSPECIFIED)) { - contentGenerators.add(null); - } - else { - ContentGenerator gen = ContentGeneratorExtensionFactoryRegistry.getInstance().getGeneratorClassFromName(protocol); - contentGenerators.add(gen); - } - } - - if (protocolText == null && protocolCombo.getItemCount() > 0) - { - protocolText = protocolCombo.getItem(0); -// generator.setProtocol(!UNSPECIFIED.equals(protocolText) ? protocolText : null); - } - protocolCombo.setText(protocolText); - - ContentGenerator gen = ContentGeneratorExtensionFactoryRegistry.getInstance().getGeneratorClassFromName(protocolText); - generator.setContentGenerator(gen); - } - - protected void updateRefNameCombo() - { - refNameCombo.removeAll(); - - refNameCombo.add(UNSPECIFIED); - for (Iterator i = getRefNames().iterator(); i.hasNext();) - { - refNameCombo.add((String) i.next()); - } - - if (refNameCombo.getItemCount() > 0) - { - String refText = generator.getRefName(); - refNameCombo.setText(refText != null ? refText : UNSPECIFIED); - } - } - - public void modifyText(ModifyEvent e) - { - generator.setName(componentNameField.getText()); - } - - public abstract List getRefNames(); - public abstract String getRefNameLabelText(); - public abstract String getDefaultName(); - public abstract ContentGeneratorOptionsPage createContentGeneratorOptionsPage(String protocol); -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/BindingWizard.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/BindingWizard.java deleted file mode 100644 index 087a051ed..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/BindingWizard.java +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.internal.generator.BindingGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.ContentGeneratorOptionsPage; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.HttpBindingOptionsPage; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.SoapBindingOptionsPage; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.ProtocolComponentControl; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class BindingWizard extends Wizard -{ - protected BindingGenerator bindingGenerator; - protected BindingWizardOptionsPage specifyBindingPage; - - protected Document document; - protected int kind; - - public static final int KIND_NEW_BINDING = 1; - public static final int KIND_REGENERATE_BINDING = 2; - - protected Definition definition; - - /* - * Constructor used when are creating a brand new Binding - */ - public BindingWizard(Definition definition) - { - this(definition, null, KIND_NEW_BINDING); - } - - /* - * Constructor used when are creating a brand new Binding - */ - public BindingWizard(Definition definition, Document document) - { - this(definition, null, KIND_NEW_BINDING); - this.document = document; - } - - /* - * Constructor used when there is an existing Binding we wish to modify/regenerate - */ - public BindingWizard(Definition definition, Binding binding, int kind) - { - super(); - this.definition = definition; - this.kind = kind; - bindingGenerator = new BindingGenerator(definition, binding); - - setWindowTitle(WSDLEditorPlugin.getWSDLString("_UI_BINDING_WIZARD")); //$NON-NLS-1$ - //setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(WSDLEditorPlugin.class, "icons/NewXML.gif")); - } - - public void setBindingName(String bindingName) - { -// QName qname = new QName(definition.getTargetNamespace(), bindingName); - bindingGenerator.setName(bindingName); -/* - // Binding binding = (Binding) definition.getBinding(qname); - if (binding != null) - { - List eeList = binding.getEExtensibilityElements(); - if (eeList.size() > 0) - { - ExtensibilityElement ee = (ExtensibilityElement) eeList.get(0); - Element element = WSDLEditorUtil.getInstance().getElementForObject(ee); - String namespace = element.getNamespaceURI(); - if (namespace != null) - { - ContentGeneratorExtension extension = WSDLEditorPlugin.getInstance().getContentGeneratorExtensionRegistry().getExtensionForNamespace(namespace); - - if (extension != null) - { - bindingGenerator.setProtocol(extension.getName()); - } - } - } - } - */ - } - - public void setPortTypeName(String portTypeName) - { - bindingGenerator.setRefName(portTypeName); - } - - public BindingGenerator getBindingGenerator() - { - return bindingGenerator; - } - - /** - * Return true if wizard setup is successful, false otherwise - */ - public boolean setup() - { - return true; - } - - public void addPages() - { - specifyBindingPage = new BindingWizardOptionsPage(); - addPage(specifyBindingPage); - } - - public boolean performFinish() - { - boolean recordingStarted = false; - if (definition.getElement() == null || (document != null && document.getChildNodes().getLength() == 0)) { - recordingStarted = true; - beginRecording(); - - // Create the Definitions element with proper namespace - Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences(); - String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - if (charSet == null || charSet.trim().equals("")) - { - charSet = "UTF-8"; - } - document.appendChild(document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + charSet + "\"")); - Element root = document.createElement("wsdl:definitions"); - document.appendChild(root); - - // Add various namespace attributes here. - root.setAttribute("xmlns:soap", "http://schemas.xmlsoap.org/wsdl/soap/"); - root.setAttribute("xmlns:tns", getDefaultNamespace(definition)); - root.setAttribute("xmlns:wsdl", "http://schemas.xmlsoap.org/wsdl/"); - root.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); - root.setAttribute("name", getFileName(definition)); - root.setAttribute("targetNamespace", getDefaultNamespace(definition)); - - definition.setElement(root); - } - - // Generate/re-generate the Binding - try - { - Binding binding = bindingGenerator.generateBinding(); - - if (binding != null) - { - IEditorPart editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - ISelectionProvider selectionProvider = (ISelectionProvider) editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) - { - selectionProvider.setSelection(new StructuredSelection(binding)); - } - } - } - catch (Exception e) - { - } - finally { - if (recordingStarted) - endRecording(); - } - - return true; - } - - private String getDefaultNamespace(Definition definition) - { - String namespace = WSDLEditorPlugin.getInstance().getPreferenceStore().getString(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE")); - if (!namespace.endsWith("/")) { - namespace = namespace.concat("/"); - } - - namespace += getFileName(definition) + "/"; - - return namespace; - } - - private String getFileName(Definition definition) { - String fileLocation = definition.getLocation(); - IPath filePath = new Path(fileLocation); - return filePath.removeFileExtension().lastSegment().toString(); - } - - private void beginRecording() { - Node node = document; - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().beginRecording(this, WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_BINDING")); - } - } - - private void endRecording() { - Node node = document; - if (node instanceof IDOMNode) - { - ((IDOMNode)node).getModel().endRecording(this); - } - } - - class BindingWizardOptionsPage extends WizardPage - { - protected ProtocolComponentControl protocolComponentControl; - - public BindingWizardOptionsPage() - { - super("SpecifyBindingPage"); - setTitle(WSDLEditorPlugin.getWSDLString("_UI_TITLE_SPECIFY_BINDING_DETAILS")); - setDescription(WSDLEditorPlugin.getWSDLString("_UI_SPECIFY_BINDING_DETAILS_LABEL")); - } - - protected BindingGenerator getBindingGenerator() - { - return ((BindingWizard) getWizard()).getBindingGenerator(); - } - - public void createControl(Composite parent) - { - ProtocolComponentControl protocolComponentControl = new BindingProtocolComponentControl(parent, bindingGenerator, true); - protocolComponentControl.initFields(); - setControl(protocolComponentControl); - } - } - - public static class BindingProtocolComponentControl extends ProtocolComponentControl - { - public BindingProtocolComponentControl(Composite parent, BindingGenerator generator) - { - this(parent, generator, true); - } - - public BindingProtocolComponentControl(Composite parent, BindingGenerator generator, boolean showOverwriteButton) - { - super(parent, generator, showOverwriteButton); - - if (generator.getName() != null) - { - componentNameField.setEditable(false); - } - } - - public String getRefNameLabelText() - { - return WSDLEditorPlugin.getWSDLString("_UI_PORT_TYPE"); - } - - public List getRefNames() - { - return new ComponentReferenceUtil(generator.getDefinition()).getPortTypeNames(); - } - - public String getDefaultName() - { - String bindingName = generator.getName(); - return bindingName != null ? bindingName : NameUtil.buildUniqueBindingName(generator.getDefinition(), null); - } - - public ContentGeneratorOptionsPage createContentGeneratorOptionsPage(String protocol) - { - ContentGeneratorOptionsPage optionsPage = null; - String protocolSelection = protocolCombo.getItem(protocolCombo.getSelectionIndex()); - if (protocolSelection.equals("SOAP")) { - optionsPage = new SoapBindingOptionsPage(); - } - else if (protocolSelection.equals("HTTP")) { - optionsPage = new HttpBindingOptionsPage(); - } -// ContentGeneratorExtension extension = WSDLEditorPlugin.getInstance().getContentGeneratorExtensionRegistry().getContentGeneratorExtension(protocol); -// if (extension != null) -// { -// optionsPage = extension.createBindingContentGeneratorOptionsPage(); -// } - return optionsPage; - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NamespaceTable.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NamespaceTable.java deleted file mode 100644 index 1ea47f6ed..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NamespaceTable.java +++ /dev/null @@ -1,701 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.wst.common.ui.internal.viewers.NavigableTableViewer; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -import org.eclipse.wst.xml.ui.internal.dialogs.EditNamespaceInfoDialog; -import org.eclipse.wst.xml.ui.internal.dialogs.UpdateListener; -import org.eclipse.wst.xml.ui.internal.util.XMLCommonResources; - -public class NamespaceTable extends Composite -{ - protected static final String NAMESPACE_URI = XMLCommonResources.getInstance().getString("_UI_LABEL_NAMESPACE_NAME"); //$NON-NLS-1$ - protected static final String PREFIX = XMLCommonResources.getInstance().getString("_UI_LABEL_PREFIX"); //$NON-NLS-1$ - protected static final String INCLUDE = WSDLEditorPlugin.getWSDLString("_UI_TITLE_SELECT"); //$NON-NLS-1$ - - protected List namespaceInfoList = new Vector(); - protected List checkedList = new Vector(); - protected NamespaceNavigableTableViewer tableViewer; - protected Button addButton; - - protected NamespaceInfoTableLabelProvider provider; - protected UpdateListener updateListener; - protected IPath resourceLocation; - protected int visibleRows = -1; - protected boolean dummyRowsRemoved = false; - Table table; - - public NamespaceTable(Composite parent) - { - this(parent, -1, -1, -1); - } - - public NamespaceTable(Composite parent, int visibleRows) - { - this(parent, -1, -1, visibleRows); - } - - public NamespaceTable(Composite parent, int widthHint, int heightHint) - { - this(parent, widthHint, heightHint, -1); - } - - public NamespaceTable(Composite parent, int widthHint, int heightHint, int visibleRows) - { - super(parent, SWT.NONE); - setLayout(createGridLayout()); - GridData fillGD= new GridData(); - fillGD.horizontalAlignment= GridData.FILL; - fillGD.grabExcessHorizontalSpace= true; - fillGD.verticalAlignment= GridData.FILL; - fillGD.grabExcessVerticalSpace= true; - - setLayoutData(fillGD); - - Group namespaceInfoGroup = new Group(this, SWT.NONE); - namespaceInfoGroup.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_NAMESPACE_URIS_TO_BE_INCLUDED")); //$NON-NLS-1$ - namespaceInfoGroup.setLayout(new GridLayout()); - GridData gd = fillGD; - if (widthHint != -1) - { - gd.widthHint = widthHint; - } - if (heightHint != -1) - { - gd.heightHint = heightHint; - } - namespaceInfoGroup.setLayoutData(gd); - //WorkbenchHelp.setHelp(namespaceInfoGroup, new ControlContextComputer(namespaceInfoGroup, XMLBuilderContextIds.XMLC_NAMESPACE_GROUP)); - - String[] titleArray = {INCLUDE, PREFIX, NAMESPACE_URI}; - - table = new Table(namespaceInfoGroup, SWT.FULL_SELECTION); - table.setHeaderVisible(true); - - table.setLayoutData(fillGD); - table.setLinesVisible(true); - table.addMouseListener(new MouseAdapter() - { - public void mouseDown(MouseEvent e) - { - TableItem item = table.getItem(new Point(e.x, e.y)); - if (item != null) - { - Object obj = item.getData(); - if (obj != null) - { - TableElement holder = (TableElement)obj; - TableColumn col = table.getColumn(0); - if (e.x < col.getWidth()) // if the point falls within the Select column then perform check/uncheck - { - String currentState = holder.getChecked(); - if (currentState.equals("true")) //$NON-NLS-1$ - { - holder.setChecked("false"); //$NON-NLS-1$ - checkedList.set(holder.getIndex(), "false"); //$NON-NLS-1$ - } - else if (currentState.equals("false")) //$NON-NLS-1$ - { - holder.setChecked("true"); //$NON-NLS-1$ - checkedList.set(holder.getIndex(), "true"); //$NON-NLS-1$ - } - tableViewer.refresh(); - if (updateListener != null) - { - updateListener.updateOccured(this, namespaceInfoList); - } - } - } - } - } - }); - - tableViewer = new NamespaceNavigableTableViewer(table); - provider = new NamespaceInfoTableLabelProvider(); - tableViewer.setContentProvider(provider); - tableViewer.setLabelProvider(provider); - tableViewer.setColumnProperties(titleArray); - tableViewer.setCellModifier(new NamespaceInfoCellModifier()); - - - int[] widthArray = {10, 20, 50}; - TableLayout layout = new TableLayout(); - - for (int i = 0; i < titleArray.length; i++) - { - TableColumn column = new TableColumn(table, i); - column.setText(titleArray[i]); - column.setAlignment(SWT.LEFT); - layout.addColumnData(new ColumnWeightData(widthArray[i], true)); - } - this.visibleRows = visibleRows; - for (int i = 0; i < visibleRows; i++) - { - TableItem item = new TableItem(table, SWT.NONE); - item.setText("#######"); //$NON-NLS-1$ - } - table.setLayout(layout); - - CellEditor[] cellEditors = new CellEditor[titleArray.length]; - cellEditors[0] = new NamespaceInfoCheckboxCellEditor(table); - cellEditors[1] = new TextCellEditor(table); - tableViewer.setCellEditors(cellEditors); - -// createButtons(namespaceInfoGroup); - - initialize(); - } - - public void setUpdateListener(UpdateListener updateListener) - { - this.updateListener = updateListener; - } - - public void setNamespaceInfoList(List namespaceInfoList) - { - this.namespaceInfoList = namespaceInfoList; - update(); - } - - public List getNamespaceInfoList() - { - return namespaceInfoList; - } - - public List getNamespaceCheckedList() - { - return checkedList; - } - - public String getWSDLPrefix() - { - return ((NamespaceInfo)(namespaceInfoList.get(0))).prefix; - } - - public void setResourceLocation(IPath resourceLocation) - { - this.resourceLocation = resourceLocation; - } - - public GridLayout createGridLayout() - { - GridLayout gridLayout = new GridLayout(); - gridLayout.marginWidth = 0; - gridLayout.horizontalSpacing = 0; - return gridLayout; - } - - protected void initialize() - { - // better way to do this.... - NamespaceInfo info1 = new NamespaceInfo(); - info1.prefix = "wsdl"; //$NON-NLS-1$ - info1.uri = "http://schemas.xmlsoap.org/wsdl/"; //$NON-NLS-1$ - namespaceInfoList.add(info1); - checkedList.add("true"); //$NON-NLS-1$ - NamespaceInfo info2 = new NamespaceInfo(); - info2.prefix = "soap"; //$NON-NLS-1$ - info2.uri = "http://schemas.xmlsoap.org/wsdl/soap/"; //$NON-NLS-1$ - namespaceInfoList.add(info2); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info3 = new NamespaceInfo(); - info3.prefix = "http"; //$NON-NLS-1$ - info3.uri = "http://schemas.xmlsoap.org/wsdl/http/"; //$NON-NLS-1$ - namespaceInfoList.add(info3); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info4 = new NamespaceInfo(); - info4.prefix = "mime"; //$NON-NLS-1$ - info4.uri = "http://schemas.xmlsoap.org/wsdl/mime/"; //$NON-NLS-1$ - namespaceInfoList.add(info4); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info5 = new NamespaceInfo(); - info5.prefix = "soapenc"; //$NON-NLS-1$ - info5.uri = "http://schemas.xmlsoap.org/soap/encoding/"; //$NON-NLS-1$ - namespaceInfoList.add(info5); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info6 = new NamespaceInfo(); - info6.prefix = "soapenv"; //$NON-NLS-1$ - info6.uri = "http://schemas.xmlsoap.org/soap/envelope/"; //$NON-NLS-1$ - namespaceInfoList.add(info6); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info7 = new NamespaceInfo(); - info7.prefix = "xsi"; //$NON-NLS-1$ - info7.uri = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$ - namespaceInfoList.add(info7); - checkedList.add("false"); //$NON-NLS-1$ - NamespaceInfo info8 = new NamespaceInfo(); - info8.prefix = "xsd"; //$NON-NLS-1$ - info8.uri = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$ - namespaceInfoList.add(info8); - checkedList.add("true"); //$NON-NLS-1$ - update(); - } - - protected void createButtons(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - GridData hFillGD = new GridData(); - hFillGD.horizontalAlignment= GridData.FILL; - hFillGD.grabExcessHorizontalSpace= true; - - composite.setLayoutData(hFillGD); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.marginHeight = 0; - gridLayout.marginWidth = 0; - composite.setLayout(gridLayout); - - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace= true; - - Button hiddenButton = new Button(composite, SWT.NONE); - hiddenButton.setLayoutData(gd); - hiddenButton.setVisible(false); - hiddenButton.setEnabled(false); - - SelectionListener selectionListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (e.widget == addButton) - { - performNew(); - } - } - }; - - // create a composite to hold the three buttons - Composite buttonComposite = new Composite(composite, SWT.NONE); - - buttonComposite.setLayoutData(hFillGD); - GridLayout buttonGridLayout = new GridLayout(); - buttonGridLayout.numColumns = 1; - buttonGridLayout.makeColumnsEqualWidth = true; - buttonComposite.setLayout(buttonGridLayout); - - // add the New button - // - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - - addButton = new Button(buttonComposite, SWT.NONE); - addButton.setText(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD")); //$NON-NLS-1$ - addButton.setLayoutData(gd);//ViewUtility.createHorizontalFill()); - addButton.addSelectionListener(selectionListener); - } - - public void performNew() - { - NamespaceInfo info = new NamespaceInfo(); - EditNamespaceInfoDialog dialog = invokeDialog(XMLCommonResources.getInstance().getString("_UI_LABEL_NEW_NAMESPACE_INFORMATION"), info); //$NON-NLS-1$ - if (dialog.getReturnCode() == Dialog.OK) - { - namespaceInfoList.add(info); - checkedList.add("true"); //$NON-NLS-1$ - performDelayedUpdate(); - } - } - - protected EditNamespaceInfoDialog invokeDialog(String title, NamespaceInfo info) - { - Shell shell = XMLCommonResources.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - EditNamespaceInfoDialog dialog = new EditNamespaceInfoDialog(shell, info); - dialog.create(); - dialog.getShell().setText(title); - dialog.setBlockOnOpen(true); - dialog.setResourceLocation(resourceLocation); - dialog.open(); - return dialog; - } - - protected void performDelayedUpdate() - { - Runnable delayedUpdate = new Runnable() - { - public void run() - { - update(); - } - }; - Display.getCurrent().asyncExec(delayedUpdate); - - if (updateListener != null) - { - updateListener.updateOccured(this, namespaceInfoList); - } - } - - protected NamespaceInfo getTargetNamespaceInfo() - { - return (namespaceInfoList != null && namespaceInfoList.size() > 0) ? - (NamespaceInfo)namespaceInfoList.get(0) : - null; - } - - - public void update() - { - updateHelper(namespaceInfoList); - } - - public void updateHelper(List namespaceInfoList) - { - if (visibleRows != -1 && !dummyRowsRemoved) - { -// dummyRowsRemoved = true; -// tableViewer.getTable().removeAll(); - } - ISelection selection = tableViewer.getSelection(); - tableViewer.setInput(namespaceInfoList); - if (selection.isEmpty()) - { - if (namespaceInfoList.size() > 0) - { - tableViewer.setSelection(new StructuredSelection(namespaceInfoList.get(0))); - } - } - else - { - tableViewer.setSelection(selection); - } - } - - protected class NamespaceInfoCheckboxCellEditor extends CheckboxCellEditor implements MouseListener - { - public NamespaceInfoCheckboxCellEditor(Composite parent) - { - super(parent); - } - - protected void doSetValue(Object value) - { - } - - public void activate() - { - super.activate(); - deactivate(); - Display.getCurrent().getFocusControl().redraw(); - } - - public void mouseDown(MouseEvent e) - { - if (tableViewer.getTable().getItem(new Point(e.x, e.y)) != null) - { - } - } - public void mouseDoubleClick(MouseEvent e) {} - public void mouseUp(MouseEvent e) {} - - - } - - - protected class NamespaceInfoCellModifier implements ICellModifier - { - public NamespaceInfoCellModifier() - { - - } - - public boolean canModify(Object element, String property) - { - if (property.equals(INCLUDE)) - { - return true; - } - else if (property.equals(PREFIX)) - { - return true; - } - return false; - } - - public Object getValue(Object element, String property) - { - int column = 0; - if (property.equals(INCLUDE)) - { - column = 0; - } - else if (property.equals(PREFIX)) - { - column = 1; - } - else if (property.equals(NAMESPACE_URI)) - { - column = 2; - } - - if (element instanceof TableElement) - { - return provider.getColumnText(element, column); - } - else - { - return null; - } - } - - public void modify(Object element, String property, Object value) - { - TableItem item = (TableItem)element; - if (item != null) - { - Object obj = item.getData(); - if (obj != null) - { - TableElement holder = (TableElement)obj; - NamespaceInfo info = holder.getNamespaceInfo(); - if (property.equals(INCLUDE)) - { - if (value instanceof Boolean) - { - if (((Boolean)value).booleanValue()) - { - holder.setChecked("true"); - checkedList.set(holder.getIndex(), "true"); - } - else - { - holder.setChecked("false"); - checkedList.set(holder.getIndex(), "false"); - } - } - } - else if (property.equals(PREFIX)) - { - info.prefix = ((String)value).trim(); - } - - Runnable delayedUpdate = new Runnable() - { - public void run() - { - tableViewer.refresh(); - } - }; - Display.getCurrent().asyncExec(delayedUpdate); - if (updateListener != null) - { - updateListener.updateOccured(this, namespaceInfoList); - } - -// performDelayedUpdate(); - } - } - } - } - - protected class TableElement - { - NamespaceInfo info; - int index; - String checked = "true"; - - TableElement(NamespaceInfo info, int index) - { - this.info = info; - this.index = index; - } - - public NamespaceInfo getNamespaceInfo() - { - return info; - } - - public int getIndex() - { - return index; - } - - public String getChecked() - { - return checked; - } - - public void setChecked(String checked) - { - this.checked = checked; - } - } - - /** - * NamespaceInfoTableLabelProvider - */ - protected class NamespaceInfoTableLabelProvider implements ITableLabelProvider, IStructuredContentProvider - { - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - public boolean isLabelProperty(Object element, String property) - { - return false; - } - - public boolean isDeleted(Object element) - { - return false; - } - - public Object[] getElements(Object inputElement) - { - Vector v = new Vector(); - for (int i = 0; i < namespaceInfoList.size(); i++) - { - NamespaceInfo info = (NamespaceInfo)namespaceInfoList.get(i); - TableElement holder = new TableElement(info, i); - holder.setChecked((String)checkedList.get(i)); - v.add(holder); - } - return v.toArray(); - } - - public String getColumnText(Object object, int column) - { - TableElement holder = (TableElement)object; - NamespaceInfo info = holder.getNamespaceInfo(); - String result = null; - switch (column) - { - case 1: { result = info.prefix; break; } - case 2: { result = info.uri; break; } - } - result = result != null ? result.trim() : ""; - if (result.equals("")) - { - switch (column) - { - case 2: - { - result = XMLCommonResources.getInstance().getString("_UI_NO_NAMESPACE_NAME"); //$NON-NLS-1$ - break; - } - } - } - return result; - } - -// private String getDefaultPrefix() -// { -// String defaultPrefix = "p"; -// if (namespaceInfoList == null) -// return defaultPrefix; -// -// Vector v = new Vector(); -// for (int i=0; i<namespaceInfoList.size(); i++) -// { -// NamespaceInfo nsinfo = (NamespaceInfo)namespaceInfoList.get(i); -// if (nsinfo.prefix != null) -// v.addElement(nsinfo.prefix); -// } -// -// if (v.contains(defaultPrefix)) -// { -// String s = defaultPrefix; -// for (int j=0; v.contains(s); j++) -// { -// s = defaultPrefix + Integer.toString(j); -// } -// return s; -// } -// else -// return defaultPrefix; -// } - - public Image getColumnImage(Object object, int columnIndex) - { - if (columnIndex == 0) // Output Column - { - if (object instanceof TableElement) - { - TableElement holder = (TableElement) object; - String result = holder.getChecked(); - if (result.equals("true")) //$NON-NLS-1$ - { - return WSDLEditorPlugin.getInstance().getImage("icons/output_yes.gif"); //$NON-NLS-1$ - } - else - { - return WSDLEditorPlugin.getInstance().getImage("icons/output_no.gif"); //$NON-NLS-1$ - } - } - } - return null; - } - - public boolean isLabelProperty(Object object, Object property) - { - return false; - } - - public void addListener(ILabelProviderListener listener) - { - } - - public void removeListener(ILabelProviderListener listener) - { - } - - public void dispose() - { - } - } - - class NamespaceNavigableTableViewer extends NavigableTableViewer - { - public NamespaceNavigableTableViewer(Table parent) - { - super(parent); - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NewWSDLWizard.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NewWSDLWizard.java deleted file mode 100644 index 8c73cbe5c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/NewWSDLWizard.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import javax.xml.namespace.QName; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.wst.common.ui.internal.UIPlugin; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; -import org.eclipse.wst.wsdl.Binding; -import org.eclipse.wst.wsdl.Port; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.binding.http.internal.generator.HTTPContentGenerator; -import org.eclipse.wst.wsdl.binding.http.internal.util.HTTPConstants; -import org.eclipse.wst.wsdl.binding.soap.internal.generator.SOAPContentGenerator; -import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants; -import org.eclipse.wst.wsdl.internal.generator.BindingGenerator; -import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl; -import org.eclipse.wst.wsdl.internal.impl.WSDLFactoryImpl; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.CreateWSDLElementHelper; -import org.eclipse.wst.wsdl.util.WSDLResourceImpl; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList; -import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.DOMValidator; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -import org.w3c.dom.Element; - -public class NewWSDLWizard extends Wizard implements INewWizard { - private WSDLNewFilePage newFilePage; - private WSDLNewFileOptionsPage optionsPage; - private IStructuredSelection selection; - - /** - * Constructor for NewWSDLWizard. - */ - public NewWSDLWizard() { - super(); - } - - /** - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - IFile file = newFilePage.createNewFile(); - - Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences(); - String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - if (charSet == null || charSet.trim().equals("")) { - charSet = "UTF-8"; - } - - String wsdlPrefix = "wsdl"; - Vector namespaces = optionsPage.getNamespaceInfo(); - - String prefix = optionsPage.getPrefix(); - String definitionName = optionsPage.getDefinitionName(); - - URI uri2 = URI.createPlatformResourceURI(file.getFullPath().toOSString()); - ResourceSet resourceSet = new ResourceSetImpl(); - WSDLResourceImpl resource = (WSDLResourceImpl) resourceSet.createResource(URI.createURI("*.wsdl")); - resource.setURI(uri2); - - WSDLFactoryImpl factory = new WSDLFactoryImpl(); - DefinitionImpl definition = (DefinitionImpl) factory.createDefinition(); - resource.getContents().add(definition); - - definition.setTargetNamespace(optionsPage.getTargetNamespace()); - definition.setLocation(file.getLocation().toString()); - definition.setEncoding(charSet); - definition.setQName(new QName(wsdlPrefix, definitionName)); - definition.addNamespace(prefix, optionsPage.getTargetNamespace()); - - for (int i = 0; i < namespaces.size(); i++) { - NamespaceInfo info = (NamespaceInfo) namespaces.get(i); - - if (info.prefix.length() > 0) { - definition.addNamespace(info.prefix, info.uri); - } - else { - definition.addNamespace(null, info.uri); - } - } - // TODO : cs... why do we need this? these calls are evil! - definition.updateElement(true); - try { - if (optionsPage.getCreateSkeletonBoolean()) { - if (optionsPage.isSoapDocLiteralProtocol()) { - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.PART_INFO_ELEMENT_DECLARATION; - } - else { - CreateWSDLElementHelper.PART_TYPE_OR_DEFINITION = CreateWSDLElementHelper.PART_INFO_TYPE_DEFINITION; - } - - CreateWSDLElementHelper.serviceName = definitionName; - CreateWSDLElementHelper.portName = definitionName + optionsPage.getProtocol(); - Service service = CreateWSDLElementHelper.createService(definition); - - - // Generate Binding - Iterator bindingIt = definition.getEBindings().iterator(); - Binding binding = null; - if (bindingIt.hasNext()) { - binding = (Binding) bindingIt.next(); - } - BindingGenerator bindingGenerator = new BindingGenerator(definition, binding, SOAPConstants.SOAP_NAMESPACE_URI); - Port port = (Port) service.getEPorts().iterator().next(); - bindingGenerator.setName(ComponentReferenceUtil.getName(port.getEBinding())); - bindingGenerator.setRefName(ComponentReferenceUtil.getPortTypeReference(port.getEBinding())); - bindingGenerator.setOverwrite(true); - - if (optionsPage.getProtocol().equals("SOAP")) { - String namespace = SOAPConstants.SOAP_NAMESPACE_URI; - bindingGenerator.setContentGenerator(BindingGenerator.getContentGenerator(namespace)); - - SOAPContentGenerator soapGen = (SOAPContentGenerator) bindingGenerator.getContentGenerator(); - Boolean booleanValue = (Boolean) optionsPage.getProtocolOptions()[0]; - Boolean booleanValue2 = (Boolean) optionsPage.getProtocolOptions()[2]; - if (booleanValue.booleanValue()) { - // Document Literal - soapGen.setStyle(SOAPContentGenerator.STYLE_DOCUMENT); - soapGen.setUse(SOAPContentGenerator.USE_LITERAL); - } - else if (booleanValue2.booleanValue()){ - // RPC Literal - soapGen.setStyle(SOAPContentGenerator.STYLE_RPC); - soapGen.setUse(SOAPContentGenerator.USE_LITERAL); - } - else { - // RPC Encoded - soapGen.setStyle(SOAPContentGenerator.STYLE_RPC); - soapGen.setUse(SOAPContentGenerator.USE_ENCODED); - } - } - else if (optionsPage.getProtocol().equals("HTTP")) { - String namespace = HTTPConstants.HTTP_NAMESPACE_URI; - bindingGenerator.setContentGenerator(BindingGenerator.getContentGenerator(namespace)); - - Boolean booleanValue = (Boolean) optionsPage.getProtocolOptions()[0]; - if (booleanValue.booleanValue()) { - // Post - ((HTTPContentGenerator) bindingGenerator.getContentGenerator()).setVerb(HTTPContentGenerator.VERB_POST); - } - else { - // Get - ((HTTPContentGenerator) bindingGenerator.getContentGenerator()).setVerb(HTTPContentGenerator.VERB_GET); - } - } - - bindingGenerator.generateBinding(); - bindingGenerator.generatePortContent(); - } - resource.save(null); - } - catch (Exception e) { - System.out.println("\nCould not write new WSDL file in WSDL Wizard: " + e); - } - - /* - * if (file != null) { final ISelection selection = new - * StructuredSelection(file); if (selection != null) { IWorkbench - * workbench = UIPlugin.getDefault().getWorkbench(); final - * IWorkbenchWindow workbenchWindow = - * workbench.getActiveWorkbenchWindow(); final IWorkbenchPart - * focusPart = workbenchWindow.getActivePage().getActivePart(); if - * (focusPart instanceof ISetSelectionTarget) { - * Display.getCurrent().asyncExec (new Runnable() { public void run() { - * ((ISetSelectionTarget)focusPart).selectReveal(selection); } }); } } } - */ - openEditor(file); - - return true; - } - - /** - * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, - * IStructuredSelection) - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.selection = selection; - - // Need new icon - this.setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(WSDLEditor.class, "icons/new_wsdl_wiz.gif")); - this.setWindowTitle(WSDLEditorPlugin.getWSDLString("_UI_TITLE_NEW_WSDL_FILE")); //$NON-NLS-1$ - } - - public void addPages() { - newFilePage = new WSDLNewFilePage(selection); - optionsPage = new WSDLNewFileOptionsPage(WSDLEditorPlugin.getWSDLString("_UI_TITLE_OPTIONS"), WSDLEditorPlugin.getWSDLString("_UI_TITLE_OPTIONS"), null); //$NON-NLS-1$ //$NON-NLS-2$ - addPage(newFilePage); - addPage(optionsPage); - } - - public IPath getNewFilePath() { - String fileName = newFilePage.getFileName(); - return fileName != null ? new Path(fileName) : null; - } - - public boolean canFinish() { - if (newFilePage.isPageComplete() && optionsPage.isPageComplete()) { - return true; - } - return false; - } - - static public void openEditor(final IFile iFile) { - if (iFile != null) { - IWorkbench workbench = UIPlugin.getDefault().getWorkbench(); - final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), "org.eclipse.wst.wsdl.ui.internal.WSDLEditor"); - } - catch (PartInitException ex) { - // B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception - // encountered when attempting to open file: " + iFile - // + "\n\n" + ex); - } - } - }); - } - } - - public class AvailableContentCMVisitor extends CMVisitor { - public static final int INCLUDE_ATTRIBUTES = ModelQuery.INCLUDE_ATTRIBUTES; - public static final int INCLUDE_CHILD_NODES = ModelQuery.INCLUDE_CHILD_NODES; - public static final int INCLUDE_SEQUENCE_GROUPS = ModelQuery.INCLUDE_SEQUENCE_GROUPS; - - public Hashtable childNodeTable = new Hashtable(); - public Hashtable attributeTable = new Hashtable(); - public Element rootElement; - public CMElementDeclaration rootElementDeclaration; - public boolean isRootVisited; - protected boolean includeSequenceGroups; - public DOMValidator validator; - - public AvailableContentCMVisitor(Element rootElement, CMElementDeclaration rootElementDeclaration) { - this.rootElement = rootElement; - this.rootElementDeclaration = rootElementDeclaration; - validator = new DOMValidator(); - } - - protected String getKey(CMNode cmNode) { - String key = cmNode.getNodeName(); - CMDocument cmDocument = (CMDocument) cmNode.getProperty("CMDocument"); - if (cmDocument != null) { - String namespaceURI = (String) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); - if (namespaceURI != null) { - key = "[" + namespaceURI + "]" + key; - } - } - return key; - } - - public List computeAvailableContent(int includeOptions) { - Vector v = new Vector(); - - int contentType = rootElementDeclaration.getContentType(); - includeSequenceGroups = ((includeOptions & INCLUDE_SEQUENCE_GROUPS) != 0); - visitCMNode(rootElementDeclaration); - - if ((includeOptions & INCLUDE_ATTRIBUTES) != 0) { - v.addAll(attributeTable.values()); - CMAttributeDeclaration nillableAttribute = (CMAttributeDeclaration) rootElementDeclaration.getProperty("http://org.eclipse.wst/cm/properties/nillable"); - if (nillableAttribute != null) { - v.add(nillableAttribute); - } - } - - if ((includeOptions & INCLUDE_CHILD_NODES) != 0) { - if (contentType == CMElementDeclaration.MIXED || contentType == CMElementDeclaration.ELEMENT) { - v.addAll(childNodeTable.values()); - } - else if (contentType == CMElementDeclaration.ANY) { - CMDocument cmDocument = (CMDocument) rootElementDeclaration.getProperty("CMDocument"); - if (cmDocument != null) { - CMNamedNodeMap elements = cmDocument.getElements(); - for (Iterator i = elements.iterator(); i.hasNext();) { - v.add((CMElementDeclaration) i.next()); - } - } - } - - if (contentType == CMElementDeclaration.MIXED || contentType == CMElementDeclaration.PCDATA || contentType == CMElementDeclaration.ANY) { - CMDataType dataType = rootElementDeclaration.getDataType(); - if (dataType != null) { - v.add(dataType); - } - } - } - return v; - } - - /* - * public void visitCMAnyElement(CMAnyElement anyElement) { String uri = - * anyElement.getNamespaceURI(); List list = - * getCMDocumentList(rootElement, rootElementDeclaration, uri); for - * (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - * CMDocument cmdocument = (CMDocument)iterator.next(); if (cmdocument != - * null) { CMNamedNodeMap map = cmdocument.getElements(); int size = - * map.getLength(); for (int i = 0; i < size; i++) { CMNode ed = - * map.item(i); - * - * childNodeTable.put(getKey(ed), ed); } } } } - */ - public void visitCMAttributeDeclaration(CMAttributeDeclaration ad) { - super.visitCMAttributeDeclaration(ad); - attributeTable.put(ad.getNodeName(), ad); - } - - public void visitCMElementDeclaration(CMElementDeclaration ed) { - if (ed == rootElementDeclaration && !isRootVisited) { - isRootVisited = true; - super.visitCMElementDeclaration(ed); - } - else { - if (!Boolean.TRUE.equals(ed.getProperty("Abstract"))) { - childNodeTable.put(getKey(ed), ed); - } - - CMNodeList substitutionGroup = (CMNodeList) ed.getProperty("SubstitutionGroup"); - if (substitutionGroup != null) { - handleSubstitutionGroup(substitutionGroup); - } - } - } - - protected void handleSubstitutionGroup(CMNodeList substitutionGroup) { - int substitutionGroupLength = substitutionGroup.getLength(); - if (substitutionGroupLength > 1) { - for (int i = 0; i < substitutionGroupLength; i++) { - CMNode ed = substitutionGroup.item(i); - if (!Boolean.TRUE.equals(ed.getProperty("Abstract"))) { - childNodeTable.put(getKey(ed), ed); - } - } - } - } - - public void visitCMGroup(CMGroup group) { - if (includeSequenceGroups) { - if (group.getOperator() == CMGroup.SEQUENCE && group.getChildNodes().getLength() > 1 && includesRequiredContent(group)) { - childNodeTable.put(group, group); - } - } - super.visitCMGroup(group); - } - - public boolean includesRequiredContent(CMGroup group) { - List list = getValidator().createContentSpecificationList(group); - return list.size() > 1; - } - - public DOMValidator getValidator() { - return validator; - } - } // ///////////////////////// here -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/PortWizard.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/PortWizard.java deleted file mode 100644 index 4ccf3c664..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/PortWizard.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import java.util.List; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.wsdl.Service; -import org.eclipse.wst.wsdl.internal.generator.PortGenerator; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.ContentGeneratorOptionsPage; -import org.eclipse.wst.wsdl.ui.internal.contentgenerator.ui.SoapBindingOptionsPage; -import org.eclipse.wst.wsdl.ui.internal.util.ComponentReferenceUtil; -import org.eclipse.wst.wsdl.ui.internal.util.NameUtil; -import org.eclipse.wst.wsdl.ui.internal.widgets.ProtocolComponentControl; - -public class PortWizard extends Wizard -{ - protected final static int STYLE_NEW_BINDING = 1; - protected final static int STYLE_EXISTING_BINDING = 1 << 1; - protected final static int STYLE_DEFAULT = STYLE_NEW_BINDING | STYLE_EXISTING_BINDING; - - protected PortGenerator portGenerator; - protected PortWizardOptionsPage specifyBindingPage; - protected int style; - - /** - * Constructor for PortWizard. - */ - public PortWizard(Service service) - { - this(service, 0); - } - - public PortWizard(Service service, int style) - { - super(); - portGenerator = new PortGenerator(service); - setWindowTitle(WSDLEditorPlugin.getWSDLString("_UI_PORT_WIZARD")); //$NON-NLS-1$ - //setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(WSDLEditorPlugin.class, "icons/NewXML.gif")); - } - - /** - * Return true if wizard setup is successful, false otherwise - */ - public boolean setup() - { - return true; - } - - public void addPages() - { - specifyBindingPage = new PortWizardOptionsPage(style); - addPage(specifyBindingPage); - } - - public boolean performFinish() - { - Object object = portGenerator.generatePort(); - - try - { - if (object != null) - { - IEditorPart editorPart = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - ISelectionProvider selectionProvider = (ISelectionProvider) editorPart.getAdapter(ISelectionProvider.class); - if (selectionProvider != null) - { - selectionProvider.setSelection(new StructuredSelection(object)); - } - } - } - catch (Exception e) - { - } - return true; - } - - class PortWizardOptionsPage extends WizardPage - { - - protected ProtocolComponentControl protocolComponentControl; - - public PortWizardOptionsPage(int style) - { - super("SpecifyPortPage"); - setTitle(WSDLEditorPlugin.getWSDLString("_UI_SPECIFY_PORT_DETAILS")); - setDescription(WSDLEditorPlugin.getWSDLString("_UI_SPECIFY_PORT_DETAILS_TO_BE_CREATED")); - } - - public PortGenerator getGenerator() - { - return portGenerator; - } - - public void createControl(Composite parent) - { - ProtocolComponentControl protocolComponentControl = new PortProtocolComponentControl(parent, portGenerator); - protocolComponentControl.initFields(); - setControl(protocolComponentControl); - } - } - - class PortProtocolComponentControl extends ProtocolComponentControl - { - - public PortProtocolComponentControl(Composite parent, PortGenerator generator) - { - super(parent, generator, false); - } - - public String getRefNameLabelText() - { - return WSDLEditorPlugin.getWSDLString("_UI_BINDING"); - } - - public List getRefNames() - { - return new ComponentReferenceUtil(portGenerator.getDefinition()).getBindingNames(); - } - - public String getDefaultName() - { - Service service = portGenerator.getService(); - return NameUtil.buildUniquePortName(service, null); - } - - public ContentGeneratorOptionsPage createContentGeneratorOptionsPage(String protocol) - { - ContentGeneratorOptionsPage optionsPage = null; - String protocolSelection = protocolCombo.getItem(protocolCombo.getSelectionIndex()); - if (protocolSelection.equals("SOAP")) { - optionsPage = new SoapBindingOptionsPage(); - } - else if (protocolSelection.equals("HTTP")) { - optionsPage = new SoapBindingOptionsPage(); - } -// ContentGeneratorExtension extension = WSDLEditorPlugin.getInstance().getContentGeneratorExtensionRegistry().getContentGeneratorExtension(protocol); -// if (extension != null) -// { -// optionsPage = extension.createPortContentGeneratorOptionsPage(); -// } - return optionsPage; - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFileOptionsPage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFileOptionsPage.java deleted file mode 100644 index ba906c039..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFileOptionsPage.java +++ /dev/null @@ -1,610 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Vector; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.PageBook; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.util.ValidateHelper; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -import org.eclipse.wst.xml.ui.internal.dialogs.UpdateListener; - -public class WSDLNewFileOptionsPage extends WizardPage implements ModifyListener, UpdateListener, SelectionListener -{ - protected Text targetNamespaceText; - protected Text prefixText; - protected boolean updatePortOpFieldBoolean = true; - - protected PageBook protocolPageBook; - protected Combo protocolCombo; - protected Composite soapPage; - protected Composite httpPage; - protected Button docLitRadio; - protected Button rpcLitRadio; - protected Button rpcEncRadio; - protected Button httpGetRadio; - protected Button httpPostRadio; - -// private BindingGenerator generator; - - /** - * Constructor for WSDLNewFileOptionsPage. - * @param pageName - */ - public WSDLNewFileOptionsPage(String pageName) - { - super(pageName); - } - /** - * Constructor for WSDLNewFileOptionsPage. - * @param pageName - * @param title - * @param titleImage - */ - public WSDLNewFileOptionsPage(String pageName, String title, ImageDescriptor titleImage) - { - super(pageName, title, titleImage); - setDescription(WSDLEditorPlugin.getWSDLString("_UI_DESCRIPTION_NEW_WSDL_FILE")); //$NON-NLS-1$ - } - /** - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) - { - Composite base = new Composite(parent, SWT.NONE); - WorkbenchHelp.setHelp(base, WSDLEditorPlugin.getWSDLString("_UI_HELP")); //$NON-NLS-1$ - base.setLayout(new GridLayout()); - - // Group wsdlGroup = ViewUtility.createGroup(base, 2, "WSDL", false); - Composite wsdlGroup = new Composite(base, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - wsdlGroup.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - wsdlGroup.setLayoutData(data); - - GridData gd = (GridData)wsdlGroup.getLayoutData(); - gd.grabExcessHorizontalSpace = true; - - Label targetNamespace = new Label(wsdlGroup, SWT.LEFT); - targetNamespace.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_TARGET_NAMESPACE")); //$NON-NLS-1$ - GridData nsData = new GridData(); - nsData.horizontalAlignment = GridData.FILL; - targetNamespace.setLayoutData(nsData); - - targetNamespaceText = new Text(wsdlGroup, SWT.SINGLE | SWT.BORDER); - GridData textData = new GridData(); - textData.horizontalAlignment = GridData.FILL; - textData.grabExcessHorizontalSpace = true; - textData.widthHint = 10; - targetNamespaceText.setLayoutData(textData); - - targetNamespaceText.addModifyListener(this); - - Label prefix = new Label(wsdlGroup, SWT.LEFT); - prefix.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_PREFIX_WITH_COLON")); //$NON-NLS-1$\ - - GridData prefixData = new GridData(); - prefixData.horizontalAlignment = GridData.FILL; - prefix.setLayoutData(prefixData); - - prefixText = new Text(wsdlGroup, SWT.SINGLE | SWT.BORDER); - GridData prefixTextData = new GridData(); - prefixTextData.horizontalAlignment = GridData.FILL; - prefixTextData.grabExcessHorizontalSpace = true; - prefixTextData.widthHint = 10; - prefixText.setLayoutData(prefixTextData); - - prefixText.addModifyListener(this); - - // XMLCatalog xmlCatalog = XMLCatalogRegistry.getInstance().lookupOrCreateXMLCatalog("default"); - // SelectXMLCatalogIdPanel catalog = new SelectXMLCatalogIdPanel(base, xmlCatalog); - -// Determine if the user wishes to create a skeleton WSDL. If yes, present the user with input fields. - createSkeletonCheckBox = new Button(base, SWT.CHECK); - createSkeletonCheckBox.setText(WSDLEditorPlugin.getWSDLString("_UI_LABEL_CREATE_WSDL_SKELETON")); - createSkeletonCheckBox.setSelection(true); - - wsdlSkeletonGroup = new Composite(base, SWT.NONE); - GridLayout layout2 = new GridLayout(); - layout2.numColumns = 2; - wsdlSkeletonGroup.setLayout(layout2); - - GridData data2 = new GridData(); - data2.verticalAlignment = GridData.FILL; - data2.horizontalAlignment = GridData.FILL; - wsdlSkeletonGroup.setLayoutData(data2); - - createLabel(wsdlSkeletonGroup, WSDLEditorPlugin.getWSDLString("_UI_LABEL_BINDING_PROTOCOL")); - protocolCombo = new Combo(wsdlSkeletonGroup, SWT.READ_ONLY); - GridData dataC = new GridData(); - dataC.horizontalAlignment = GridData.FILL; - dataC.grabExcessHorizontalSpace = true; - protocolCombo.setLayoutData(dataC); - protocolCombo.add(SOAP_PROTOCOL); - protocolCombo.add(HTTP_PROTOCOL); - protocolCombo.select(0); - protocolCombo.addModifyListener(this); - - sepLabel = new Label(base, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData sepData = new GridData(); - sepData.horizontalAlignment = GridData.FILL; - sepData.grabExcessHorizontalSpace = true; - sepLabel.setLayoutData(sepData); - - - // Create PageBook and pages/controls for the PageBook - protocolPageBook = new PageBook(base, SWT.NONE); - - ///////////////////////// Soap Page - soapPage = new Composite(protocolPageBook, SWT.NONE); - GridLayout pbLayout = new GridLayout(); - soapPage.setLayout(pbLayout); - - GridData pbData = new GridData(); - pbData.verticalAlignment = GridData.FILL; - pbData.horizontalAlignment = GridData.FILL; - soapPage.setLayoutData(pbData); - - createLabel(soapPage, WSDLEditorPlugin.getWSDLString("_UI_LABEL_SOAP_BINDING_OPTIONS")); - docLitRadio = new Button(soapPage, SWT.RADIO); - rpcLitRadio = new Button(soapPage, SWT.RADIO); - rpcEncRadio = new Button(soapPage, SWT.RADIO); - docLitRadio.setText(SOAP_DOCUMENT_LITERAL); - rpcLitRadio.setText(SOAP_RPC_LITERAL); - rpcEncRadio.setText(SOAP_RPC_ENCODED); - docLitRadio.setSelection(true); - - ///////////////////////// Http Page - httpPage = new Composite(protocolPageBook, SWT.NONE); - pbLayout = new GridLayout(); - httpPage.setLayout(pbLayout); - - pbData = new GridData(); - pbData.verticalAlignment = GridData.FILL; - pbData.horizontalAlignment = GridData.FILL; - httpPage.setLayoutData(pbData); - - createLabel(httpPage, WSDLEditorPlugin.getWSDLString("_UI_LABEL_HTTP_BINDING_OPTIONS")); // Already Externalized - httpGetRadio = new Button(httpPage, SWT.RADIO); - httpPostRadio = new Button(httpPage, SWT.RADIO); - httpGetRadio.setText(HTTP_GET); - httpPostRadio.setText(HTTP_POST); - httpGetRadio.setSelection(true); - - wsdlSkeletonGroup.setVisible(true); - sepLabel.setVisible(true); - protocolPageBook.showPage(soapPage); - protocolPageBook.setVisible(true); - - ////////////////////////// Add Selection Listeners - createSkeletonCheckBox.addSelectionListener(this); - -// BindingProtocolComponentControl component = new BindingProtocolComponentControl(base, generator, false); -// component.initFields(); - - setControl(base); - } - - private NewWSDLWizard getNewWSDLWizard() - { - return (NewWSDLWizard)getWizard(); - } - - private String computeDefaultDefinitionName() - { - String name = "DefaultName"; - IPath path = getNewWSDLWizard().getNewFilePath(); - if (path != null) - { - name = path.removeFileExtension().lastSegment().toString(); - } - return name; - } - - private String computeDefaultNamespaceName() - { - String namespace = WSDLEditorPlugin.getInstance().getPreferenceStore().getString(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE")); - if (!namespace.endsWith("/")) { - namespace = namespace.concat("/"); - } - - IPath path = getNewWSDLWizard().getNewFilePath(); - if (path != null) - { - namespace += path.removeFileExtension().toString() + "/"; - } - return namespace; - } - - public void setVisible(boolean visible) - { - super.setVisible(visible); - - if (visible) - { - // prime the fields - targetNamespaceText.setText(computeDefaultNamespaceName()); - prefixText.setText("tns"); - } - } - - public String getTargetNamespace() - { - return targetNamespaceText.getText(); - } - - public String getPrefix() - { - return prefixText.getText().trim(); - } - - public String getDefinitionName() - { - return computeDefaultDefinitionName(); - } - - public void modifyText(ModifyEvent e) - { - if (e.widget == targetNamespaceText) - { - startDelayedEvent(e); - } - else if (e.widget == prefixText) - { - setPageComplete(isPageComplete()); - } - else if (e.widget == protocolCombo) { - // Update what page/control we show in the PageBook - if (protocolCombo.getText().equals("SOAP")) { - protocolPageBook.showPage(soapPage); - } - else if (protocolCombo.getText().equals("HTTP")) { - protocolPageBook.showPage(httpPage); - } - } - } - - public void updateOccured(Object arg1, Object arg2) - { - setPageComplete(isPageComplete()); - } - - public boolean isPageComplete() - { - boolean ready = true; - - setErrorMessage(null); - - // so that the page doesn't immediately show up with an error - if (targetNamespaceText.getText().trim().equals("")) - { - if (ready) - { - setErrorMessage(null); - } - return false; - } - - if (!validateTargetNamespace(targetNamespaceText.getText())) - { - ready = false; - } - - return ready; - } - - protected boolean validatePrefix(String prefix) - { - String errorMessage = ValidateHelper.checkXMLPrefix(prefix); - - if (errorMessage == null || errorMessage.length() == 0) - { - return true; - } - return false; - } - - protected boolean validateXMLName(String xmlName) - { - String errorMessage = ValidateHelper.checkXMLName(xmlName); - - if (errorMessage == null || errorMessage.length() == 0) - { - return true; - } - setErrorMessage(errorMessage); - return false; - } - - protected boolean validateTargetNamespace(String ns) - { - boolean test = true; - try - { - new URI(ns); -// URI testURI = new URI(ns); - // if (!testURI.isGenericURI()) - // { - // setErrorMessage(WSDLEditorPlugin.getInstance().getWSDLString("_UI_ERROR_NAMESPACE_INVALID")); //$NON-NLS-1$ - // test = false; - // } - } - catch (URISyntaxException e) - { - // String errorMessage = ValidateHelper.checkXMLName(ns); - // if (errorMessage == null || errorMessage.length() == 0) - // { - // test = true; - // } - // else - // { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_NAMESPACE_INVALID")); //$NON-NLS-1$ - test = false; - // } - } - - return test; - } - - /* - private boolean arePrefixesUniqueAndValid() - { - java.util.List infoList = namespaceInfo.getNamespaceInfoList(); - java.util.List checkedList = namespaceInfo.getNamespaceCheckedList(); - - Vector prefixList = new Vector(); - boolean test = true; - boolean isOneBlank = false; - - String currentPrefix = prefixText.getText().trim(); - if (currentPrefix.length() == 0) - { - isOneBlank = true; - } - else - { - if (validatePrefix(currentPrefix)) - { - prefixList.add(currentPrefix); - } - else - { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_PREFIX_IS_INVALID", currentPrefix)); //$NON-NLS-1$ - return false; - } - } - - for (int i = 0; i < infoList.size(); i++) - { - NamespaceInfo info = (NamespaceInfo)infoList.get(i); - if (((String)checkedList.get(i)).equals("true")) //$NON-NLS-1$ - { - String aPrefix = info.prefix.trim(); - if (aPrefix.length() > 0) - { - if (!prefixList.contains(aPrefix)) - { - if (validatePrefix(aPrefix)) - { - prefixList.add(aPrefix); - } - else - { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_PREFIX_IS_INVALID", info.prefix)); //$NON-NLS-1$ - test = false; - break; - } - } - else - { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_PREFIX_IS_A_DUPLICATE", info.prefix)); //$NON-NLS-1$ - test = false; - break; - } - } - else - { - if (!isOneBlank) - { - isOneBlank = true; - } - else - { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_MORE_THAN_ONE_PREFIX_IS_BLANK")); //$NON-NLS-1$ - test = false; - break; - } - } - } - } - return test; - } - */ - - protected DelayedEvent delayedTask; - protected void startDelayedEvent(ModifyEvent e) - { - if (delayedTask == null || delayedTask.getEvent() == null) - { - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500, delayedTask); - } - else - { - ModifyEvent delayedEvent = delayedTask.getEvent(); - - if (e.widget == delayedEvent.widget) - { - // same event, just different data, delay new event - delayedTask.setEvent(null); - } - delayedTask = new DelayedEvent(); - delayedTask.setEvent(e); - Display.getDefault().timerExec(500, delayedTask); - } - } - - class DelayedEvent implements Runnable - { - protected ModifyEvent event; - - /* - * @see Runnable#run() - */ - public void run() - { - if (event != null) - { - setPageComplete(isPageComplete()); - event = null; - } - } - - public ModifyEvent getEvent() - { - return event; - } - - public void setEvent(ModifyEvent event) - { - this.event = event; - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - if (e.widget == createSkeletonCheckBox) { - if (createSkeletonCheckBox.getSelection()) { - wsdlSkeletonGroup.setVisible(true); - sepLabel.setVisible(true); - protocolPageBook.setVisible(true); - } - else { - wsdlSkeletonGroup.setVisible(false); - sepLabel.setVisible(false); - protocolPageBook.setVisible(false); - } - } - } - - private static final String SOAP_PROTOCOL = "SOAP"; - private static final String HTTP_PROTOCOL = "HTTP"; - private static final String SOAP_RPC_ENCODED = WSDLEditorPlugin.getWSDLString("_UI_RADIO_RPC_ENCODED"); - private static final String SOAP_RPC_LITERAL = WSDLEditorPlugin.getWSDLString("_UI_RADIO_RPC_LITERAL"); - private static final String SOAP_DOCUMENT_LITERAL = WSDLEditorPlugin.getWSDLString("_UI_RADIO_DOCUMENT_LITERAL"); - private static final String HTTP_POST = "HTTP POST"; - private static final String HTTP_GET = "HTTP GET"; - - Composite wsdlSkeletonGroup; - Button createSkeletonCheckBox; - - Label sepLabel; - - private Label createLabel(Composite comp, String labelString) { - Label label = new Label(comp, SWT.LEFT); - label.setText(labelString); - GridData nsData = new GridData(); - nsData.horizontalAlignment = GridData.FILL; - label.setLayoutData(nsData); - - return label; - } - - public Vector getNamespaceInfo() { - Vector namespaces = new Vector(); - - // Add Default Namespaces - NamespaceInfo info1 = new NamespaceInfo(); - info1.prefix = "wsdl"; - info1.uri = "http://schemas.xmlsoap.org/wsdl/"; - namespaces.addElement(info1); - - NamespaceInfo info8 = new NamespaceInfo(); - info8.prefix = "xsd"; - info8.uri = "http://www.w3.org/2001/XMLSchema"; - namespaces.addElement(info8); - - return namespaces; - } - - public boolean getCreateSkeletonBoolean() { - return createSkeletonCheckBox.getSelection(); - } - - public String getProtocol() { - return protocolCombo.getText(); - } - - public Object[] getProtocolOptions() { - Object bool[] = new Boolean[3]; - if (protocolCombo.getText().equals(SOAP_PROTOCOL)) { - if (docLitRadio.getSelection()) { - bool[0] = new Boolean(true); - } - else { - bool[0] = new Boolean(false); - } - - if (rpcLitRadio.getSelection()) { - bool[2] = new Boolean(true); - } - else { - bool[2] = new Boolean(false); - } - } - else if (protocolCombo.getText().equals(HTTP_PROTOCOL)){ - if (httpGetRadio.getSelection()) { - bool[0] = new Boolean(false); - } - else { - bool[0] = new Boolean(true); - } - } - - return bool; - } - - public boolean isSoapDocLiteralProtocol() { - if (getProtocol().equals(SOAP_PROTOCOL) && docLitRadio.getSelection()) { - return true; - } - else { - return false; - } - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFilePage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFilePage.java deleted file mode 100644 index c50644770..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/wizards/WSDLNewFilePage.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.wizards; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; - -public class WSDLNewFilePage extends WizardNewFileCreationPage -{ - public WSDLNewFilePage(IStructuredSelection selection) - { - super(WSDLEditorPlugin.getWSDLString("_UI_TITLE_NEW_WSDL_FILE"), selection); //$NON-NLS-1$ - setTitle(WSDLEditorPlugin.getWSDLString("_UI_TITLE_NEW_WSDL_FILE")); //$NON-NLS-1$ - setDescription(WSDLEditorPlugin.getWSDLString("_UI_LABEL_CREATE_NEW_WSDL_FILE")); //$NON-NLS-1$ - } - - public void createControl(Composite parent) - { - // inherit default container and name specification widgets - super.createControl(parent); - this.setFileName(computeDefaultFileName()); - - setPageComplete(validatePage()); - } - - protected boolean validatePage() - { - Path newName = new Path(getFileName()); - String fullFileName = getFileName(); - String extension = newName.getFileExtension(); - if (extension == null || !extension.equalsIgnoreCase("wsdl")) //$NON-NLS-1$ - { - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_FILE_MUST_END_WITH_WSDL")); //$NON-NLS-1$ - return false; - } - else - { - setErrorMessage(null); - } - - // check for file should be case insensitive - String sameName = existsFileAnyCase(fullFileName); - if (sameName != null) - { -// String qualifiedFileName = getContainerFullPath().toString() + '/' + fullFileName; - setErrorMessage(WSDLEditorPlugin.getWSDLString("_UI_ERROR_FILE_ALREADY_EXISTS", sameName)); //$NON-NLS-1$ - return false; - } - - - return super.validatePage(); - } - - public String defaultName = "NewWSDLFile"; //$NON-NLS-1$ - public String defaultFileExtension = ".wsdl"; //$NON-NLS-1$ - public String[] filterExtensions = { "*.wsdl"}; //$NON-NLS-1$ - - - protected String computeDefaultFileName() - { - int count = 0; - String fileName = defaultName + defaultFileExtension; - IPath containerFullPath = getContainerFullPath(); - if (containerFullPath != null) - { - while (true) - { - IPath path = containerFullPath.append(fileName); - // if (WorkbenchUtility.getWorkspace().getRoot().exists(path)) - if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) - { - count++; - fileName = defaultName + count + defaultFileExtension; - } - else - { - break; - } - } - } - return fileName; - } - - // returns true if file of specified name exists in any case for selected container - protected String existsFileAnyCase(String fileName) - { - if ( (getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) - && (fileName.compareTo("") != 0)) - { - //look through all resources at the specified container - compare in upper case - IResource parent = ResourcesPlugin.getWorkspace().getRoot().findMember(getContainerFullPath()); - if (parent instanceof IContainer) - { - IContainer container = (IContainer) parent; - try - { - IResource[] members = container.members(); - String enteredFileUpper = fileName.toUpperCase(); - for (int i=0; i<members.length; i++) - { - String resourceUpperName = members[i].getName().toUpperCase(); - if (resourceUpperName.equals(enteredFileUpper)) - { - return members[i].getName(); - } - } - } - catch (CoreException e) - { - } - } - } - return null; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDDetailsViewerProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDDetailsViewerProvider.java deleted file mode 100644 index 073604d63..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDDetailsViewerProvider.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - - - -public class XSDDetailsViewerProvider // implements IDetailsViewerProvider -{ -// public Object getViewerKey(Object modelObject) -// { -// Object result = null; -// -// if (modelObject instanceof XSDConcreteComponent) -// { -// Element input = ((XSDConcreteComponent)modelObject).getElement(); -// -// if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, false)) -// { -// result = "element"; -// } -// else if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, true)) -// { -// result = "elementRef"; -// } -// else if (inputEquals(input, XSDConstants.SEQUENCE_ELEMENT_TAG, false) || -// inputEquals(input, XSDConstants.CHOICE_ELEMENT_TAG, false) || -// inputEquals(input, XSDConstants.ALL_ELEMENT_TAG, false)) -// { -// result = "sequenceChoiceAll"; -// } -// else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false)) -// { -// result = "attribute"; -// } -// else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true)) -// { -// result = "attributeRef"; -// } -// else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false)) -// { -// result = "attributeGroup"; -// } -// else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true)) -// { -// result = "attributeGroupRef"; -// } -// else if (inputEquals(input, XSDConstants.NOTATION_ELEMENT_TAG, false)) -// { -// result = "notation"; -// } -// else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, false)) -// { -// result = "group"; -// } -// else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, true)) -// { -// result = "groupRef"; -// } -// else if (inputEquals(input, XSDConstants.SCHEMA_ELEMENT_TAG, false)) -// { -// result = "schema"; -// } -// else if (inputEquals(input, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false)) -// { -// result = "complexType"; -// } -// else if (inputEquals(input, XSDConstants.DOCUMENTATION_ELEMENT_TAG, false)) -// { -// result = "documentation"; -// } -// else if (inputEquals(input, XSDConstants.APPINFO_ELEMENT_TAG, false)) -// { -// result = "appInfo"; -// } -// else if (inputEquals(input, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) -// { -// if (input != null && input instanceof Element) -// { -// Element parentElement = (Element)input; -// XSDDOMHelper xsdDOMHelper = new XSDDOMHelper(); -// Element derivedByNode = xsdDOMHelper.getDerivedByElement(parentElement); -// if (derivedByNode != null) -// { -// if (inputEquals(derivedByNode, XSDConstants.RESTRICTION_ELEMENT_TAG, false)) -// { -// result = "simpleContent"; -// } -// else if (inputEquals(derivedByNode, XSDConstants.EXTENSION_ELEMENT_TAG, false)) -// { -// result = "simpleContent"; -// } -// } -// else -// { -// result = "xsd"; -// } -// } -// } -// else if (inputEquals(input, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)) -// { -// if (input != null && input instanceof Element) -// { -// Element parentElement = (Element)input; -// XSDDOMHelper xsdDOMHelper = new XSDDOMHelper(); -// Element derivedByNode = xsdDOMHelper.getDerivedByElement(parentElement); -// if (derivedByNode != null) -// { -// result = "simpleContent"; -// } -// else -// { -// result = "xsd"; -// } -// } -// } -// else if (inputEquals(input, XSDConstants.INCLUDE_ELEMENT_TAG, false)) -// { -// result = "includeXSD"; -// } -// else if (inputEquals(input, XSDConstants.IMPORT_ELEMENT_TAG, false)) -// { -// result = "importXSD"; -// } -// else if (inputEquals(input, XSDConstants.REDEFINE_ELEMENT_TAG, false)) -// { -// result = "redefine"; -// } -// else if (inputEquals(input, XSDConstants.LIST_ELEMENT_TAG, false)) -// { -// result = "simpleBase"; -// } -// else if (inputEquals(input, XSDConstants.UNION_ELEMENT_TAG, false)) -// { -// result = "simpleBase"; -// } -// else if (inputEquals(input, XSDConstants.RESTRICTION_ELEMENT_TAG, false)) -// { -// result = getKeyForRestrictWindow(input); -// } -// else if (XSDDOMHelper.isFacet(input)) -// { -// if (input != null && input instanceof Element) -// { -// Node parentElement = ((Element)input).getParentNode(); -// if (inputEquals(parentElement, XSDConstants.RESTRICTION_ELEMENT_TAG, false)) -// { -// result = getKeyForRestrictWindow(input); -// } -// } -// } -// else if (inputEquals(input, XSDConstants.EXTENSION_ELEMENT_TAG, false)) -// { -// if (input != null && input instanceof Element) -// { -// Node parentElement = ((Element)input).getParentNode(); -// if (inputEquals(parentElement, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)) -// { -// result = "simpleContent"; -// } -// else if (inputEquals(parentElement, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) -// { -// result = "simpleContent"; -// } -// else -// { -// result = "xsd"; -// } -// } -// } -// else if (inputEquals(input, XSDConstants.PATTERN_ELEMENT_TAG, false)) -// { -// result = "pattern"; -// } -// else if (inputEquals(input, XSDConstants.ENUMERATION_ELEMENT_TAG, false)) -// { -// result = "enum"; -// } -// else if (inputEquals(input, XSDConstants.ANY_ELEMENT_TAG, false)) -// { -// result = "anyElement"; -// } -// else if (inputEquals(input, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false)) -// { -// result = "anyAttribute"; -// } -// else if (inputEquals(input, XSDConstants.UNIQUE_ELEMENT_TAG, false)) -// { -// result = "unique"; -// } -// else if (inputEquals(input, XSDConstants.KEYREF_ELEMENT_TAG, false)) -// { -// result = "keyRef"; -// } -// else if (inputEquals(input, XSDConstants.SELECTOR_ELEMENT_TAG, false)) -// { -// result = "selector"; -// } -// else if (inputEquals(input, XSDConstants.FIELD_ELEMENT_TAG, false)) -// { -// result = "field"; -// } -// else if (inputEquals(input, XSDConstants.KEY_ELEMENT_TAG, false)) -// { -// result = "key"; -// } -// else -// { -// result = "xsd"; -// } -// } -// else if (modelObject instanceof org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement) -// { -// result = "schema"; -// } -// -// return result; -// } -// -// -// public Viewer createViewer(Object modelObject, Composite parent, IEditorPart editorPart) -// { -// Viewer viewer = null; -// -// -// DesignViewer designViewer = new DesignViewer(editorPart); -// designViewer.setControl(parent); -// if (modelObject instanceof XSDConcreteComponent) -// { -// Element elem = ((XSDConcreteComponent)modelObject).getElement(); -// viewer = designViewer.createViewer(elem); -////TODO port -//// ((BaseWindow)viewer).setModelObject(modelObject); -//// viewer.setInput(elem); -// } -// else if (modelObject instanceof org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement) -// { -// XSDSchemaExtensibilityElement schema = (XSDSchemaExtensibilityElement)modelObject; -// XSDSchema xsdSchema = schema.getSchema(); -// Element elem = xsdSchema.getElement(); -// viewer = designViewer.createViewer(elem); -////TODO port -//// ((BaseWindow)viewer).setModelObject(modelObject); -//// viewer.setInput(elem); -// } -// return viewer; -// } -// -// protected boolean inputEquals(Object input, String tagname, boolean isRef) -// { -// return XSDDOMHelper.inputEquals(input, tagname, isRef); -// } -// -// protected String getKeyForRestrictWindow(Object input) -// { -// // special case where SimpleType restriction is different than SimpleContent restriction -// -// if (input != null && input instanceof Element) -// { -// Node parentElement = ((Element)input).getParentNode(); -// if (inputEquals(parentElement, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false)) -// { -// return "simpleRestrict"; -// } -// else if (inputEquals(parentElement, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) -// { -// return "simpleRestrict"; -// } -// else if (inputEquals(parentElement, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)) -// { -// return "simpleContent"; -// } -// } -// return "xsd"; -// } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtension.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtension.java deleted file mode 100644 index fa840f539..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtension.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - - -// import org.eclipse.emf.edit.provider.ItemProvider; -// import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -// import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension; -import org.eclipse.wst.wsdl.ui.internal.xsd.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.graph.model.Category; -import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.provider.XSDAdapterFactoryLabelProvider; -import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl; -import org.eclipse.xsd.XSDConcreteComponent; - - -// -// -public class XSDExtension implements WSDLEditorExtension -{ - XSDModelAdapterFactoryImpl xsdModelAdapterFactory; - XSDAdapterFactoryLabelProvider adapterFactoryLabelProvider; - - public XSDExtension() - { - xsdModelAdapterFactory = new XSDModelAdapterFactoryImpl(); - adapterFactoryLabelProvider = new XSDAdapterFactoryLabelProvider(xsdModelAdapterFactory); - } - - public boolean isExtensionTypeSupported(int type) - { - return - //CS comment these out until the port is complete - type == OUTLINE_TREE_CONTENT_PROVIDER || - type == OUTLINE_LABEL_PROVIDER || - type == PROPERTY_SOURCE_PROVIDER || - type == PROPERTY_SECTION_DESCRIPTOR_PROVIDER || - type == MENU_ACTION_CONTRIBUTOR || - type == DETAILS_VIEWER_PROVIDER || - type == EDIT_PART_FACTORY || - type == TYPE_SYSTEM_PROVIDER || - type == NODE_RECONCILER || - type == NODE_ASSOCIATION_PROVIDER || - type == MODEL_QUERY_CONTRIBUTOR; - } - - public boolean isApplicable(Object object) - { - return (object instanceof XSDSchemaExtensibilityElement || - object instanceof XSDConcreteComponent || - object instanceof CategoryAdapter || - object instanceof Category); - // || object instanceof ItemProvider); - } - - public Object createExtensionObject(int type, WSDLEditor wsdlEditor) - { - Object result = null; - switch (type) - { - case OUTLINE_TREE_CONTENT_PROVIDER : - { - result = new XSDModelAdapterContentProvider(xsdModelAdapterFactory); -// result = new XSDModelAdapterContentProvider(); - // result = new AdapterFactoryContentProvider(XSDExtensionPlugin.getXSDSemanticItemProviderAdapterFactory()); - break; - } - case OUTLINE_LABEL_PROVIDER : - { - result = new XSDLabelProvider(adapterFactoryLabelProvider); - // result = new AdapterFactoryLabelProvider(XSDExtensionPlugin.getXSDSemanticItemProviderAdapterFactory()); - break; - } - case DETAILS_VIEWER_PROVIDER : - { - // result = new XSDDetailsViewerProvider(); - result = null; - break; - } - case MENU_ACTION_CONTRIBUTOR : - { - result = new XSDMenuActionContributor(wsdlEditor); - break; - } - case TYPE_SYSTEM_PROVIDER : - { - result = new XSDTypeSystemProvider(); - break; - } - case EDIT_PART_FACTORY : - { - result = new XSDExtensionEditPartFactory(); - break; - } - case NODE_RECONCILER : - { - result = new XSDNodeReconciler(); - break; - } - case NODE_ASSOCIATION_PROVIDER : - { - result = new XSDNodeAssociationProvider(); - break; - } - case MODEL_QUERY_CONTRIBUTOR : - { - //result = new XSDModelQueryContributor(wsdlEditor); - break; - } - case PROPERTY_SOURCE_PROVIDER: - { - result = new XSDPropertySourceProvider(); - break; - } - case PROPERTY_SECTION_DESCRIPTOR_PROVIDER: - { - result = new XSDSectionDescriptorProvider(); - break; - } - case XSD_DELETE_ACTION: - { - result = new DeleteAction(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE")); - break; - } - } - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtensionEditPartFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtensionEditPartFactory.java deleted file mode 100644 index 43c50c1ce..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDExtensionEditPartFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.gef.EditPart; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.xsd.graph.editparts.XSDSchemaDrillDownEditPart; -import org.eclipse.wst.xsd.ui.internal.graph.editparts.XSDEditPartFactory; -import org.eclipse.xsd.XSDSchema; - -public class XSDExtensionEditPartFactory extends XSDEditPartFactory -{ - public EditPart createEditPart(EditPart parent, Object model) - { - EditPart editPart = null; - - if (model instanceof XSDSchema && parent.getModel() instanceof WSDLGroupObject) - { - editPart = new XSDSchemaDrillDownEditPart(); - editPart.setModel(model); - editPart.setParent(parent); - } - else - { - editPart = super.createEditPart(parent, model); - } - - return editPart; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDLabelProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDLabelProvider.java deleted file mode 100644 index 66474aa53..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDLabelProvider.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.xsd.ui.internal.provider.XSDAdapterFactoryLabelProvider; -import org.eclipse.xsd.XSDSchema; - - - -/** - * This version of the XSDLabelProvider is a modified version of the one in XSDEditor. - * This provider only needs to handle nodes in the XML Schema namespace. - * Other XML nodes (including comments, PIs etc) get handled by the 'main' provider. - */ -public class XSDLabelProvider extends LabelProvider -{ - XSDAdapterFactoryLabelProvider adapterFactoryLabelProvider; - - /** - * Constructor for XSDLabelProvider. - */ - public XSDLabelProvider(XSDAdapterFactoryLabelProvider adapterFactoryLabelProvider) - { - super(); - this.adapterFactoryLabelProvider = adapterFactoryLabelProvider; - } - - /* - * @see ILabelProvider#getImage(Object) - */ - public Image getImage(Object element) - { - if (element instanceof XSDSchemaExtensibilityElement) - { - element = ((XSDSchemaExtensibilityElement)element).getSchema().getElement(); - } - return adapterFactoryLabelProvider.getImage(element); - } - - /* - * @see ILabelProvider#getText(Object) - */ - public String getText(Object element) - { - // override text for xsd schema - if (element instanceof XSDSchema) - { - return ((XSDSchema)element).getTargetNamespace(); - } - else - { - // We don't call "adapterFactoryLabelProvider.getText(element)" because it will return a object.toString() if - // there is no labelProvider.... but we don't want to display this 'garbage' info to the user. - AdapterFactory adapterFactory = adapterFactoryLabelProvider.getAdapterFactory(); - ILabelProvider labelProvider = (ILabelProvider)adapterFactory.adapt(element, ILabelProvider.class); - String text = ""; - if (labelProvider != null) { - text = labelProvider.getText(element); - } - - return text; - } - } - -} - - diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDMenuActionContributor.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDMenuActionContributor.java deleted file mode 100644 index 444acb575..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDMenuActionContributor.java +++ /dev/null @@ -1,381 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.gef.EditPart; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditor; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.extension.IMenuActionContributor; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLComponentViewer; -import org.eclipse.wst.wsdl.ui.internal.model.WSDLGroupObject; -import org.eclipse.wst.wsdl.ui.internal.xsd.actions.AddSchemaAction; -import org.eclipse.wst.wsdl.ui.internal.xsd.actions.BackAction; -import org.eclipse.wst.xml.core.internal.document.DocumentImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.XSDMenuListener; -import org.eclipse.wst.xsd.ui.internal.actions.CreateElementAction; -import org.eclipse.wst.xsd.ui.internal.actions.CreateGroupAction; -import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute; -import org.eclipse.wst.xsd.ui.internal.gef.util.editparts.AbstractComponentViewerRootEditPart; -import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart; -import org.eclipse.wst.xsd.ui.internal.graph.model.Category; -import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class XSDMenuActionContributor implements IMenuActionContributor -{ - Element currElement; - Document currDocument; -// XSDSchema xsdSchema; -// protected ISelectionProvider iSelectionProvider; - WSDLEditor wsdlEditor; - - public XSDMenuActionContributor(WSDLEditor wsdlEditor) - { - this.wsdlEditor = wsdlEditor; - } - - public void contributeMenuActions(IMenuManager manager, Node node, Object object) - { - XSDMenuExtensionListener xsdMenuListener = new XSDMenuExtensionListener(wsdlEditor.getSelectionManager()); - xsdMenuListener.contributeMenuActions(manager, node, object); - } - - class XSDMenuExtensionListener extends XSDMenuListener - { - public XSDMenuExtensionListener(ISelectionProvider selectionProvider) - { - super(selectionProvider); - } - - protected boolean isSchemaReadOnly() - { - Iterator eeIt = wsdlEditor.getDefinition().getETypes().getEExtensibilityElements().iterator(); - while (eeIt.hasNext()) { - XSDSchemaExtensibilityElement ee = (XSDSchemaExtensibilityElement) eeIt.next(); - XSDSchema schema = ee.getSchema(); - if (schema == xsdSchema) { - return false; - } - } - - - return true; - } - - /* - * TODO: For now, just return the first inline schema we have. - */ - protected XSDSchema getCurrentSchemaInEditor() - { - Iterator eeIt = wsdlEditor.getDefinition().getETypes().getEExtensibilityElements().iterator(); - while (eeIt.hasNext()) { - XSDSchemaExtensibilityElement ee = (XSDSchemaExtensibilityElement) eeIt.next(); - return ee.getSchema(); - } - - return null; - } - - public void contributeMenuActions(IMenuManager manager, Node node, Object object) - { - updateXSDSchema(); - AbstractComponentViewerRootEditPart editPart = (AbstractComponentViewerRootEditPart)wsdlEditor.getGraphViewer().getComponentViewer().getRootEditPart().getContents(); -// iSelectionProvider = ((WSDLContentOutlinePage)(wsdlEditor.getWSDLTextEditor().getContentOutlinePage())).getTreeViewer(); - EditPart focusEditPart = wsdlEditor.getGraphViewer().getComponentViewer().getFocusEditPart(); - - if (object instanceof WSDLGroupObject) - { - WSDLGroupObject group = (WSDLGroupObject)object; - if (group.getType() == WSDLGroupObject.TYPES_GROUP) - { - boolean typesExist = group.getParent().getTypes() != null; - - Element typesElement = null; - if (typesExist) - { - Types types = group.getParent().getETypes(); - typesElement = types.getElement(); - } - if (manager != null) - { - Document document = null; - if (editPart.getViewer() instanceof WSDLComponentViewer) { - WSDLComponentViewer wsdlComponentViewer = (WSDLComponentViewer) editPart.getViewer(); - document = wsdlComponentViewer.getWSDLEditor().getXMLDocument(); - } - - manager.add(new AddSchemaAction(group.getDefinition(), (Element)node, typesElement, document)); - } - } - } - else if (object instanceof Types) - { - // IMenuManager menu = manager.findMenuUsingPath("addchild"); - - if (manager != null) - { - Types types = (Types)object; - manager.add(new AddSchemaAction(types.getEnclosingDefinition(), (Element)node)); - } - } - - if (xsdSchema == null) - { - return; - } - - ArrayList attributes = null; - Node relativeNode = null; - - BackAction backAction; - - if (object instanceof XSDSchema || focusEditPart instanceof TopLevelComponentEditPart || object instanceof Category) - { - backAction = new BackAction(WSDLEditorPlugin.getWSDLString("_UI_BACK_TO_DEFINITION")); - backAction.setDefinition(wsdlEditor.getDefinition()); - backAction.setSelectionProvider(selectionProvider); - backAction.setRootEditPart(editPart); - backAction.setGraphViewer(wsdlEditor.getGraphViewer()); - manager.add(backAction); - manager.add(new Separator()); - } - else if (object instanceof XSDConcreteComponent) - { - backAction = new BackAction(XSDEditorPlugin.getXSDString("_UI_ACTION_BACK_TO_SCHEMA_VIEW")); - // backAction.setXSDSchema(((XSDConcreteComponent)object).getSchema()); - backAction.setXSDSchema(xsdSchema); - backAction.setSelectionProvider(selectionProvider); - backAction.setRootEditPart(editPart); - backAction.setGraphViewer(wsdlEditor.getGraphViewer()); - manager.add(backAction); - manager.add(new Separator()); - } - - // CS: I'm removing the 'object instanceof Element' case from this test - // for now the menu actions are driven from 'model' objects - if (object instanceof XSDConcreteComponent || (object instanceof org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement)) - { - Element parent; - if (object instanceof XSDConcreteComponent) - { - parent = ((XSDConcreteComponent)object).getElement(); - xsdSchema = ((XSDConcreteComponent)object).getSchema(); - } - else if (object instanceof Element) - { - manager.add(new Separator()); - parent = (Element)object; - } - else if (object instanceof org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement schema = (XSDSchemaExtensibilityElement)object; - xsdSchema = schema.getSchema(); - manager.add(new Separator()); - parent = xsdSchema.getElement(); - } - else - { - return; - } - - currElement = parent; - currDocument = parent.getOwnerDocument(); - -// if (!(currDocument instanceof DocumentImpl)) -// { -// return; -// } - - addContextItems(manager, currElement, null); - - if (!(object instanceof XSDSchema) || - (object instanceof XSDSchema && !(wsdlEditor.getGraphViewer().getComponentViewer().getInput() instanceof XSDSchema))) { - IStructuredSelection selections = (IStructuredSelection) wsdlEditor.getSelectionManager().getSelection(); - manager.add(new Separator()); - org.eclipse.wst.wsdl.ui.internal.actions.DeleteWSDLAndXSDAction deleteWSDLAndXSDAction = new org.eclipse.wst.wsdl.ui.internal.actions.DeleteWSDLAndXSDAction(selections.toList(), currElement, wsdlEditor); - deleteWSDLAndXSDAction.setEnabled(!isReadOnly); - manager.add(deleteWSDLAndXSDAction); - } - } - else if (object instanceof Category - || object instanceof CategoryAdapter) - { - int groupType = -1; - - if (object instanceof Category) - { - Category cg = (Category)object; - xsdSchema = cg.getXSDSchema(); - groupType = cg.getGroupType(); - } - else // CategoryAdapter - { - CategoryAdapter category = (CategoryAdapter)object; - groupType = category.getGroupType(); - xsdSchema = category.getXSDSchema(); - } - Element parent = xsdSchema.getElement(); - currElement = parent; - currDocument = parent.getOwnerDocument(); - switch (groupType) - { - case Category.TYPES: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType"))); - Action action = addCreateElementAction(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_COMPLEX_TYPE"), attributes, parent, relativeNode); - ((CreateElementAction)action).setIsGlobal(true); - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType"))); - Action action2 = addCreateSimpleTypeAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SIMPLE_TYPE"), attributes, parent, relativeNode); - ((CreateElementAction)action2).setIsGlobal(true); - break; - } - case Category.ELEMENTS: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, - getNewGlobalName(XSDConstants.ELEMENT_ELEMENT_TAG, "GlobalElement"))); - attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName())); - Action action = addCreateElementAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT"), attributes, parent, relativeNode); - ((CreateElementAction)action).setIsGlobal(true); - break; - } - case Category.GROUPS: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, - getNewGlobalName(XSDConstants.GROUP_ELEMENT_TAG, "Group"))); - CreateGroupAction groupAction = addCreateGroupAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GROUP"), attributes, parent, relativeNode); - groupAction.setIsGlobal(true); - break; - } - case Category.ATTRIBUTES: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, - getNewGlobalName(XSDConstants.ATTRIBUTE_ELEMENT_TAG, "GlobalAttribute"))); - attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName())); - Action action = addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GLOBAL_ATTRIBUTE"), attributes, parent, relativeNode); - ((CreateElementAction)action).setIsGlobal(true); - break; - } - case Category.ATTRIBUTE_GROUPS: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, - getNewGlobalName(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, "AttributeGroup"))); - Action action = addCreateElementAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP"), attributes, parent, relativeNode); - ((CreateElementAction)action).setIsGlobal(true); - break; - } - case Category.NOTATIONS: - { - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, - getNewGlobalName(XSDConstants.NOTATION_ELEMENT_TAG, "Notation"))); - attributes.add(new DOMAttribute(XSDConstants.PUBLIC_ATTRIBUTE, "")); - Action action = addCreateElementAction(manager, XSDConstants.NOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_NOTATION"), attributes, parent, relativeNode); - ((CreateElementAction)action).setIsGlobal(true); - break; - } - case Category.DIRECTIVES: - { - boolean b = true; - NodeList children = parent.getChildNodes(); - Node effectiveRelativeNode = parent.getFirstChild(); - for (int i=0; i < children.getLength() && b; i++) - { - Node child = children.item(i); - if (child != null && child instanceof Element) - { - if (XSDDOMHelper.inputEquals((Element)child, XSDConstants.INCLUDE_ELEMENT_TAG, false) || - XSDDOMHelper.inputEquals((Element)child, XSDConstants.IMPORT_ELEMENT_TAG, false) || - XSDDOMHelper.inputEquals((Element)child, XSDConstants.REDEFINE_ELEMENT_TAG, false) || - XSDDOMHelper.inputEquals((Element)child, XSDConstants.ANNOTATION_ELEMENT_TAG, false)) - { - effectiveRelativeNode = child; - } - else - { - b = false; - } - } - } - relativeNode = effectiveRelativeNode != null ? effectiveRelativeNode.getNextSibling() : null; - attributes = new ArrayList(); - attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, "")); - - addCreateElementAction(manager, XSDConstants.INCLUDE_ELEMENT_TAG,XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_INCLUDE"), attributes, parent, relativeNode); - addCreateElementAction(manager, XSDConstants.IMPORT_ELEMENT_TAG,XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_IMPORT"), null, parent, relativeNode); - addCreateElementAction(manager, XSDConstants.REDEFINE_ELEMENT_TAG,XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_REDEFINE"), attributes, parent, relativeNode); - - - break; - } - } - } - } - - protected IFile getFileResource() - { - ///// WSDL TODO - // if (getEditor() != null) - // return getEditor().getFileResource(); - return null; - } - -// protected Object getSelectedElement() -// { -// return currElement; -// } - - protected XSDSchema getXSDSchema() - { - return xsdSchema; - } - - protected IDOMModel getXMLModel() - { - if (currElement != null) - { - Object obj = currElement.getOwnerDocument(); - if (obj instanceof DocumentImpl) - { - DocumentImpl xmlDoc = (DocumentImpl) currElement.getOwnerDocument(); - return xmlDoc.getModel(); - } - } - return null; - } - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDModelAdapterContentProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDModelAdapterContentProvider.java deleted file mode 100644 index 4271d7802..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDModelAdapterContentProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.xsd.ui.internal.provider.XSDContentProvider; -import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl; -import org.eclipse.xsd.XSDConcreteComponent; - - -public class XSDModelAdapterContentProvider extends XSDContentProvider -{ - public XSDModelAdapterContentProvider(XSDModelAdapterFactoryImpl xsdModelAdapterFactory) - { - super(xsdModelAdapterFactory); - } - - public Object[] getChildren(Object parentObject) - { - XSDConcreteComponent xsdComp = null; - if (parentObject instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement xsdSchemaExtensibilityElement = (XSDSchemaExtensibilityElement)parentObject; - xsdComp = xsdSchemaExtensibilityElement.getSchema(); - return super.getChildren(xsdComp); - } - return super.getChildren(parentObject); - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeAssociationProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeAssociationProvider.java deleted file mode 100644 index 81367fd4d..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeAssociationProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.extension.INodeAssociationProvider; -import org.eclipse.wst.xsd.ui.internal.graph.model.Category; -import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -class XSDNodeAssociationProvider implements INodeAssociationProvider -{ - public Object getModelObject(Object parentModelObject, Element[] elementChain, int start, int[] end) - { - Object result = null; - if (parentModelObject instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement extensibilityElement = (XSDSchemaExtensibilityElement)parentModelObject; - XSDSchema schema = extensibilityElement.getSchema(); - if (schema != null) - { - Element targetElement = elementChain[elementChain.length - 1]; - result = schema.getCorrespondingComponent(targetElement); - } - } - else if (parentModelObject instanceof CategoryAdapter) - { - result = ((CategoryAdapter)parentModelObject).getXSDSchema(); - } - else if (parentModelObject instanceof Category) - { - result = ((Category)parentModelObject).getXSDSchema(); - } - - return result; - } - - public Node getNode(Object modelObject) - { - Node node = null; - if (modelObject instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement extensibilityElement = (XSDSchemaExtensibilityElement)modelObject; - XSDSchema schema = extensibilityElement.getSchema(); - if (schema != null) - { - node = schema.getElement(); - } - } - else if (modelObject instanceof XSDConcreteComponent) - { - node = ((XSDConcreteComponent)modelObject).getElement(); - } - else if (modelObject instanceof CategoryAdapter) - { - node = ((CategoryAdapter)modelObject).getXSDSchema().getElement(); - } - else if (modelObject instanceof Category) - { - node = ((Category)modelObject).getXSDSchema().getElement(); - } - - return node; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeReconciler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeReconciler.java deleted file mode 100644 index d4a77c6f6..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDNodeReconciler.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.extension.INodeReconciler; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; - - -public class XSDNodeReconciler implements INodeReconciler -{ - public void notifyChanged(Object modelObject, Element element, int eventType, Object feature, Object oldValue, Object newValue, int index) - { - XSDConcreteComponent component = null; - if (modelObject instanceof XSDConcreteComponent) - { - component = (XSDConcreteComponent)modelObject; - } - else if (modelObject instanceof XSDSchemaExtensibilityElement) - { - XSDSchemaExtensibilityElement extensibilityElement = (XSDSchemaExtensibilityElement)modelObject; - component = extensibilityElement.getSchema(); - } - - if (component != null) - { - switch (eventType) - { - case INodeNotifier.CHANGE: - { - component.elementAttributesChanged(element); - break; - } - case INodeNotifier.STRUCTURE_CHANGED: - { - component.elementContentsChanged(element); - break; - } - case INodeNotifier.CONTENT_CHANGED: - { - component.elementChanged(element); - break; - } - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDPropertySourceProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDPropertySourceProvider.java deleted file mode 100644 index 95ff36ebc..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDPropertySourceProvider.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.edit.provider.IItemPropertySource; -import org.eclipse.emf.edit.ui.provider.PropertySource; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.IPropertySourceProvider; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.xsd.ui.internal.properties.AnyAttributePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.AnyElementPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.AppInfoPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.AttributeGroupRefPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.AttributePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.BasePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.ComplexTypePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.DocumentationPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.ElementPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.EnumerationPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.GroupRefPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.ImportPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.IncludePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.KeyrefPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.ModelGroupPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.NamePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.NotationPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.PatternPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SchemaPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SimpleContentPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SimpleRestrictPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SimpleTypeListPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SimpleTypePropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.SimpleTypeUnionPropertySource; -import org.eclipse.wst.xsd.ui.internal.properties.XPathPropertySource; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class XSDPropertySourceProvider implements IPropertySourceProvider -{ - /* (non-Javadoc) - * @see org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource(java.lang.Object) - */ - public IPropertySource getPropertySource(Object object) - { -// Using XSD's item providers -// XSDItemProviderAdapterFactory adapterFactory = XSDExtensionPlugin.getXSDItemProviderAdapterFactory(); -// -// IItemPropertySource itemPropertySource = -// (IItemPropertySource) -// (object instanceof EObject && ((EObject)object).eClass() == null ? -// null : -// adapterFactory.adapt(object, IItemPropertySource.class)); -// return -// itemPropertySource != null ? createPropertySource(object, itemPropertySource) : null; - - if (object == null) return null; - - if (object instanceof XSDSchemaExtensibilityElement) - { - object = ((XSDSchemaExtensibilityElement)object).getSchema(); - } - if (object instanceof XSDConcreteComponent) - { - BasePropertySource bps = (BasePropertySource)getXSDPropertySource(object); - Element input = ((XSDConcreteComponent)object).getElement(); - bps.setInput(input); - return bps; - } - return null; - } - - protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) - { - return new PropertySource(object, itemPropertySource); - } - - protected boolean inputEquals(Object input, String tagname, boolean isRef) - { - return XSDDOMHelper.inputEquals(input, tagname, isRef); - } - - boolean showParent = false; - - // TODO: We should use adapters to do this. Do as we complete 'model'-based port - public IPropertySource getXSDPropertySource(Object object) - { - XSDSchema xsdSchema = ((XSDConcreteComponent)object).getSchema(); - Element input = ((XSDConcreteComponent)object).getElement(); - - if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, false)) - { - return new ElementPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, true)) - { - return new GroupRefPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.SEQUENCE_ELEMENT_TAG, false) || - inputEquals(input, XSDConstants.CHOICE_ELEMENT_TAG, false) || - inputEquals(input, XSDConstants.ALL_ELEMENT_TAG, false)) - { - return new ModelGroupPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false)) - { - return new AttributePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true)) - { - return new AttributeGroupRefPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false)) - { - return new NamePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true)) - { - return new AttributeGroupRefPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.NOTATION_ELEMENT_TAG, false)) - { - return new NotationPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false)) - { - return new SimpleTypePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, false)) - { - return new NamePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, true)) - { - return new GroupRefPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.SCHEMA_ELEMENT_TAG, false)) - { - return new SchemaPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false)) - { - return new ComplexTypePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.DOCUMENTATION_ELEMENT_TAG, false)) - { - return new DocumentationPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.APPINFO_ELEMENT_TAG, false)) - { - return new AppInfoPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) - { - if (input != null && input instanceof Element) - { - Element parent = (Element)input; - XSDDOMHelper xsdDOMHelper = new XSDDOMHelper(); - Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent); - if (derivedByNode != null) - { - if (inputEquals(derivedByNode, XSDConstants.RESTRICTION_ELEMENT_TAG, false) || - inputEquals(derivedByNode, XSDConstants.EXTENSION_ELEMENT_TAG, false)) - { - return new SimpleContentPropertySource(xsdSchema); - } - } - else - { - return null; - } - } - } - else if (inputEquals(input, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)) - { - if (input != null && input instanceof Element) - { - Element parent = (Element)input; - XSDDOMHelper xsdDOMHelper = new XSDDOMHelper(); - Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent); - if (derivedByNode != null) - { - return new SimpleContentPropertySource(xsdSchema); - } - else - { - return null; - } - } - } - else if (inputEquals(input, XSDConstants.INCLUDE_ELEMENT_TAG, false)) - { -// if (editor instanceof XSDEditor) -// { -// IFile inputFile = ((IFileEditorInput)editor.getEditorInput()).getFile(); - IFile inputFile = null; - return new IncludePropertySource(xsdSchema, inputFile); -// } -// return null; - } - else if (inputEquals(input, XSDConstants.IMPORT_ELEMENT_TAG, false)) - { -// if (editor instanceof XSDEditor) -// { -// IFile inputFile = ((IFileEditorInput)editor.getEditorInput()).getFile(); - IFile inputFile = null; - return new ImportPropertySource(xsdSchema, inputFile); -// } -// return null; - } - else if (inputEquals(input, XSDConstants.REDEFINE_ELEMENT_TAG, false)) - { -// if (editor instanceof XSDEditor) -// { -// IFile inputFile = ((IFileEditorInput)editor.getEditorInput()).getFile(); - IFile inputFile = null; - return new IncludePropertySource(xsdSchema, inputFile); -// } -// return null; - } - else if (inputEquals(input, XSDConstants.LIST_ELEMENT_TAG, false)) - { - return new SimpleTypeListPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.UNION_ELEMENT_TAG, false)) - { - return new SimpleTypeUnionPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.RESTRICTION_ELEMENT_TAG, false)) - { - return createRestrictWindow(input, xsdSchema); - } - else if (XSDDOMHelper.isFacet(input)) - { - if (input != null && input instanceof Element) - { - Node parent = ((Element)input).getParentNode(); - if (inputEquals(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false)) - { - return createRestrictWindow(input, xsdSchema); - } - } - } - else if (inputEquals(input, XSDConstants.EXTENSION_ELEMENT_TAG, false)) - { - if (input != null && input instanceof Element) - { - Node parent = ((Element)input).getParentNode(); - if (inputEquals(parent, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false) - || inputEquals(parent, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) - { - showParent = true; - return new SimpleContentPropertySource(xsdSchema); - } - } - } - else if (inputEquals(input, XSDConstants.PATTERN_ELEMENT_TAG, false)) - { - return new PatternPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ENUMERATION_ELEMENT_TAG, false)) - { - return new EnumerationPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ANY_ELEMENT_TAG, false)) - { - return new AnyElementPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false)) - { - return new AnyAttributePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.UNIQUE_ELEMENT_TAG, false)) - { - return new NamePropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.KEYREF_ELEMENT_TAG, false)) - { - return new KeyrefPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.SELECTOR_ELEMENT_TAG, false)) - { - return new XPathPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.FIELD_ELEMENT_TAG, false)) - { - return new XPathPropertySource(xsdSchema); - } - else if (inputEquals(input, XSDConstants.KEY_ELEMENT_TAG, false)) - { - return new NamePropertySource(xsdSchema); - } - else - { - return null; - } - return null; - } - - protected IPropertySource createRestrictWindow(Object input, XSDSchema xsdSchema) - { - // special case where SimpleType restriction is different than SimpleContent restriction - - if (input != null && input instanceof Element) - { - Node parent = ((Element)input).getParentNode(); - if (inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false)) - { - return new SimpleRestrictPropertySource(xsdSchema); - } - else if (inputEquals(parent, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)) - { - return new SimpleRestrictPropertySource(xsdSchema); - } - else if (inputEquals(parent, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)) - { - showParent = true; - return new SimpleContentPropertySource(xsdSchema); - } - } - return null; - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDSectionDescriptorProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDSectionDescriptorProvider.java deleted file mode 100644 index 9b5f5a1d5..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDSectionDescriptorProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider; - -public class XSDSectionDescriptorProvider implements ISectionDescriptorProvider -{ - org.eclipse.wst.xsd.ui.internal.properties.section.XSDSectionDescriptorProvider descriptor; - /** - * - */ - public XSDSectionDescriptorProvider() - { - super(); - descriptor = new org.eclipse.wst.xsd.ui.internal.properties.section.XSDSectionDescriptorProvider(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider#getSectionDescriptors() - */ - public ISectionDescriptor[] getSectionDescriptors() - { - return descriptor.getSectionDescriptors(); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTempDetailsViewer.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTempDetailsViewer.java deleted file mode 100644 index 1b01ef690..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTempDetailsViewer.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.wst.wsdl.ui.internal.viewers.BaseViewer; - - -public class XSDTempDetailsViewer extends BaseViewer -{ - protected Composite control; - - public XSDTempDetailsViewer(Composite parent) - { - super(null); - createControl(parent); - } - - public void doSetInput(Object input) - { - } - - public void createControl(Composite parent) - { - control = flatViewUtility.createComposite(parent, 1, true); - - flatViewUtility.createFlatPageHeader(control, "XSDViewer"); - } - - protected void update() - { - } - - public Control getControl() - { - return control; - } - - public void doHandleEvent(Event event) - { - - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTypeSystemProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTypeSystemProvider.java deleted file mode 100644 index 2d8fadfad..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/XSDTypeSystemProvider.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.Import; -import org.eclipse.wst.wsdl.Types; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider; -import org.eclipse.wst.wsdl.util.WSDLConstants; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaContent; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.impl.XSDImportImpl; - -// -// -public class XSDTypeSystemProvider implements ITypeSystemProvider -{ - public List getPrefixes(Definition definition, String namespace) - { - List list = new ArrayList(); - Map map = definition.getNamespaces(); - for (Iterator i = map.keySet().iterator(); i.hasNext();) - { - String prefix = (String) i.next(); - String theNamespace = (String) map.get(prefix); - if (theNamespace != null && theNamespace.equals(namespace)) - { - list.add(prefix); - } - } - return list; - } - - public List getPrefixedNames(Definition definition, String namespace, String localName) - { - List list = new ArrayList(); - for (Iterator i = getPrefixes(definition, namespace).iterator(); i.hasNext();) - { - String prefix = (String) i.next(); - String name = (prefix != null && prefix.length() > 0) ? prefix + ":" + localName : localName; - list.add(name); - } - return list; - } - - protected void addNamedComponents(Definition definition, List list, List namedComponents) - { - for (Iterator i = namedComponents.iterator(); i.hasNext();) - { - XSDNamedComponent component = (XSDNamedComponent) i.next(); - list.addAll(getPrefixedNames(definition, component.getTargetNamespace(), component.getName())); - } - } - - public void initWSIStyleImports(XSDSchema xsdSchema) - { - if (xsdSchema.getTargetNamespace() == null) - { - for (Iterator i = xsdSchema.getContents().iterator(); i.hasNext();) - { - XSDSchemaContent content = (XSDSchemaContent) i.next(); - if (content instanceof XSDImportImpl) - { - XSDImportImpl xsdImport = (XSDImportImpl) content; - XSDSchema schema = (XSDSchema)xsdImport.getResolvedSchema(); - if (schema == null) - { - schema = xsdImport.importSchema(); - } - } - } - } - } - - public List getAvailableTypeNames(Definition definition, int typeNameCategory) - { - List list = new ArrayList(); - - if (typeNameCategory == ITypeSystemProvider.BUILT_IN_TYPE) { - list = getBuiltInTypeNamesList(definition); - } - else { - Types types = definition.getETypes(); - if (types != null) - { - for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaExtensibilityElement) - { - XSDSchema schema = ((XSDSchemaExtensibilityElement) o).getSchema(); - if (schema != null) - { - initWSIStyleImports(schema); - addNamedComponents(definition, list, schema.getTypeDefinitions()); - } - } - } - } - - for (Iterator i = definition.getEImports().iterator(); i.hasNext();) - { - Import theImport = (Import) i.next(); - XSDSchema schema = theImport.getESchema(); - if (schema != null) - { - addNamedComponents(definition, list, schema.getTypeDefinitions()); - } - } - list.addAll(getBuiltInTypeNamesList(definition)); - } - - return list; - } - - public List getAvailableTypes(Definition definition, XSDSchema schema, int typeNameCategory) - { - List keepTypes = new ArrayList(); - Iterator typeIterator = schema.getTypeDefinitions().iterator(); - // Filter out unwanted Types - if (typeNameCategory == ITypeSystemProvider.USER_DEFINED_COMPLEX_TYPE) { - while (typeIterator.hasNext()) { - Object type = typeIterator.next(); - if (type instanceof XSDComplexTypeDefinition) { - keepTypes.add(type); - } - } - } - else if (typeNameCategory == ITypeSystemProvider.USER_DEFINED_SIMPLE_TYPE) { - while (typeIterator.hasNext()) { - Object type = typeIterator.next(); - if (type instanceof XSDSimpleTypeDefinition) { - keepTypes.add(type); - } - } - } - - //addNamedComponents(definition, list, keepTypes); - //return list; - return keepTypes; - } - - public java.util.List getBuiltInTypeNamesList(Definition definition) - { - List items = new ArrayList(); - if (definition != null) - { - List prefixes = getPrefixes(definition, WSDLConstants.XSD_NAMESPACE_URI); - for (Iterator i = prefixes.iterator(); i.hasNext();) - { - String prefix = (String) i.next(); - for (int j = 0; j < XSDDOMHelper.dataType.length; j++) - { - String localName = XSDDOMHelper.dataType[j][0]; - String name = (prefix != null && prefix.length() > 0) ? prefix + ":" + localName : localName; - items.add(name); - } - } - } - return items; - } - public List getAvailableElementNames(Definition definition) - { - List list = new ArrayList(); - Types types = definition.getETypes(); - if (types != null) - { - for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaExtensibilityElement) - { - XSDSchema schema = ((XSDSchemaExtensibilityElement) o).getSchema(); - if (schema != null) - { - initWSIStyleImports(schema); - addNamedComponents(definition, list, schema.getElementDeclarations()); - } - } - } - } - - for (Iterator i = definition.getEImports().iterator(); i.hasNext();) - { - Import theImport = (Import) i.next(); - XSDSchema schema = theImport.getESchema(); - if (schema != null) - { - addNamedComponents(definition, list, schema.getElementDeclarations()); - } - } - return list; - } - public int getCategoryForTypeName(Definition definition, String typeName) - { - return 0; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/AddSchemaAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/AddSchemaAction.java deleted file mode 100644 index 9037b3c7f..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/AddSchemaAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd.actions; - -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin; -import org.eclipse.wst.wsdl.ui.internal.actions.AddElementAction; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class AddSchemaAction extends AddElementAction -{ - protected String targetNamespace; - protected boolean createTypesElement = false; - - public AddSchemaAction(Definition definition, Element definitionElement) - { - this(definition, definitionElement, false); - } - - public AddSchemaAction(Definition definition, Element definitionElement, boolean createTypesElement) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_SCHEMA"), "icons/xsd_obj.gif", definitionElement, "xsd:schema"); - this.createTypesElement = createTypesElement; - targetNamespace = definition.getTargetNamespace(); - } - - public AddSchemaAction(Definition definition, Element definitionElement, Element typesElement) - { - super(WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD_SCHEMA"), "icons/xsd_obj.gif", definitionElement, "xsd:schema"); - if (typesElement != null) - { - parentNode = typesElement; - this.createTypesElement = false; - } - else - { - this.createTypesElement = true; - } - targetNamespace = definition.getTargetNamespace(); - } - - public AddSchemaAction(Definition definition, Element definitionElement, Element typesElement, Document document) - { - this(definition, definitionElement, typesElement); - this.definition = definition; - this.document = document; - } - - protected boolean showDialog() - { - return true; - } - - protected void addAttributes(Element newElement) - { - newElement.setAttribute("xmlns:xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); - newElement.setAttribute("elementFormDefault", "qualified"); - newElement.setAttribute("targetNamespace", targetNamespace); - } - - public void run() - { - beginRecording(); - if (parentNode == null || (document != null && document.getChildNodes().getLength() == 0)) { - createDefinitionStub(); - prefix = null; - targetNamespace = definition.getTargetNamespace(); - } - - if (createTypesElement) - { - AddElementAction addTypesAction = new AddElementAction("", "icons/xsd_obj.gif", parentNode, parentNode.getPrefix(), "types"); - addTypesAction.setComputeTopLevelRefChild(true); - addTypesAction.run(); - parentNode = addTypesAction.getNewElement(); - } - super.run(); - endRecording(); - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/BackAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/BackAction.java deleted file mode 100644 index 975790466..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/BackAction.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.graph.WSDLGraphViewer; -import org.eclipse.wst.xsd.ui.internal.gef.util.editparts.AbstractComponentViewerRootEditPart; -import org.eclipse.xsd.XSDSchema; - -public class BackAction extends Action -{ - ISelectionProvider selectionProvider; - XSDSchema xsdSchema; - Definition definition; - WSDLGraphViewer graphViewer; - - /** - * - */ - public BackAction() - { - super(); - } - - /** - * @param text - */ - public BackAction(String text) - { - super(text); - } - - /** - * @param text - * @param image - */ - public BackAction(String text, ImageDescriptor image) - { - super(text, image); - } - - /** - * @param text - * @param style - */ - public BackAction(String text, int style) - { - super(text, style); - } - - public void setSelectionProvider(ISelectionProvider selectionProvider) - { - this.selectionProvider = selectionProvider; - } - - AbstractComponentViewerRootEditPart editPart; - public void setRootEditPart(AbstractComponentViewerRootEditPart editPart) - { - this.editPart = editPart; - } - - public void setDefinition(Definition definition) - { - this.definition = definition; - } - - public void setXSDSchema(XSDSchema xsdSchema) - { - this.xsdSchema = xsdSchema; - } - - public void setGraphViewer(WSDLGraphViewer graphViewer) - { - this.graphViewer = graphViewer; - } - - /* - * @see IAction#run() - */ - public void run() - { - if (xsdSchema != null) - { - StructuredSelection selection = new StructuredSelection(xsdSchema); - selectionProvider.setSelection(selection); - // editPart.setInput(xsdSchema); - graphViewer.setInput(xsdSchema); - } - else if (definition != null) - { - StructuredSelection selection = new StructuredSelection(definition); - selectionProvider.setSelection(selection); - // editPart.setInput(definition); - graphViewer.setInput(definition); - } - } - -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/DeleteAction.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/DeleteAction.java deleted file mode 100644 index b4e8fcf0b..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/actions/DeleteAction.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd.actions; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.ui.internal.actions.DeleteInterfaceAction; -import org.eclipse.wst.wsdl.ui.internal.util.WSDLEditorUtil; -import org.eclipse.wst.xml.core.internal.document.DocumentImpl; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -// Should try to use xsdeditor's delete action.... - -public class DeleteAction extends Action implements DeleteInterfaceAction -{ - XSDSchema xsdSchema; - Definition definition; - List deleteList; - - /** - * Constructor for DeleteAction. - * @param text - */ - public DeleteAction(String text) - { - super(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE")); - } - - public XSDSchema getSchema() - { - return xsdSchema; - } - - public void setSchema(XSDSchema xsdSchema) - { - this.xsdSchema = xsdSchema; - } - - public void setDeleteList(List list) { - deleteList = list; - } - - public List getDeleteList() { - return deleteList; - } - - /* - * @see IAction#run() - */ - public void run() - { - List selections = getDeleteList(); - - if (selections.isEmpty()) - { - return; - } - - Iterator iter = selections.iterator(); - DocumentImpl doc = null; - while (iter.hasNext()) - { - Object obj = iter.next(); - Element node; - if (obj instanceof Element) - { - node = (Element)obj; - Object elem = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, node); - if (elem instanceof XSDComponent) - { - xsdSchema = ((XSDComponent)elem).getSchema(); - } - } - else if (obj instanceof XSDComponent) - { - node = ((XSDComponent)obj).getElement(); - xsdSchema = ((XSDComponent)obj).getSchema(); - } - else if (obj instanceof XSDConcreteComponent) { - node = ((XSDConcreteComponent)obj).getElement(); - xsdSchema = ((XSDConcreteComponent)obj).getSchema(); - } - else - { - return; - } - - if (!XSDDOMHelper.inputEquals(node, XSDConstants.SCHEMA_ELEMENT_TAG, false)) - { - - if (doc == null) - { - doc = (DocumentImpl) node.getOwnerDocument(); - doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_NODES")); - } - - boolean refresh = cleanupReferences(node); - XSDDOMHelper.removeNodeAndWhitespace(node); - - // Workaround to reset included elements in XSD model - if (refresh) - { -// TODO -// getEditor().reparseSchema(); -// getEditor().getGraphViewer().setSchema(getEditor().getXSDSchema()); - } - } - } - if (doc != null) - { - doc.getModel().endRecording(this); - } - } - - protected boolean cleanupReferences(Node deletedNode) - { - boolean refresh = false; - XSDConcreteComponent comp = getSchema().getCorrespondingComponent(deletedNode); - - if (comp instanceof XSDInclude || - comp instanceof XSDImport || - comp instanceof XSDRedefine) - { -// XSDSchema resolvedSchema = ((XSDSchemaDirective)comp).getResolvedSchema(); - XSDSchema referencedSchema = null; - if (comp instanceof XSDInclude) - { - referencedSchema = ((XSDInclude)comp).getIncorporatedSchema(); - refresh = true; - } - else if (comp instanceof XSDRedefine) - { - referencedSchema = ((XSDRedefine)comp).getIncorporatedSchema(); - refresh = true; - } - else if (comp instanceof XSDImport) - { - referencedSchema = ((XSDImport)comp).getResolvedSchema(); - } - - if (referencedSchema != null) - { -// XSDExternalFileCleanup cleanHelper = new XSDExternalFileCleanup(referencedSchema); -// cleanHelper.visitSchema(getSchema()); -// // populate messages -//// TODO -//// getEditor().createTasksInTaskList(cleanHelper.getMessages()); - } - if (comp instanceof XSDImport) - { - TypesHelper typesHelper = new TypesHelper(getSchema()); - typesHelper.updateMapAfterDelete((XSDImport)comp); - } - } - else if (getSchema().equals(comp.getContainer())) - { -// BaseGlobalCleanup cleanHelper = null; - // Only need to clean up references if the component being deleted is global scoped -// if (comp instanceof XSDElementDeclaration) -// { -// cleanHelper = new GlobalElementCleanup(comp); -// } -// else if (comp instanceof XSDModelGroupDefinition) -// { -// cleanHelper = new GlobalGroupCleanup(comp); -// } -// else if (comp instanceof XSDTypeDefinition) -// { -// cleanHelper = new GlobalSimpleOrComplexTypeCleanup(comp); -// } -// else if (comp instanceof XSDAttributeDeclaration) -// { -// cleanHelper = new GlobalAttributeCleanup(comp); -// } -// else if (comp instanceof XSDAttributeGroupDefinition) -// { -// cleanHelper = new GlobalAttributeGroupCleanup(comp); -// } -// -// -// if (cleanHelper != null) -// { -// cleanHelper.visitSchema(getSchema()); -// // populate messages -//// TODO -//// getEditor().createTasksInTaskList(cleanHelper.getMessages()); -// } - } - return refresh; - } -} diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaDrillDownEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaDrillDownEditPart.java deleted file mode 100644 index 9a6acfca2..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaDrillDownEditPart.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd.graph.editparts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.wst.wsdl.ui.internal.graph.editparts.DrillDownEditPart; -import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin; -import org.eclipse.xsd.XSDSchema; - - -public class XSDSchemaDrillDownEditPart extends DrillDownEditPart -{ - protected IFigure createFigure() - { - IFigure figure = super.createFigure(); - label.setIcon(XSDEditorPlugin.getXSDImage("icons/XSDFile.gif")); - return figure; - } - - protected void refreshVisuals() - { - XSDSchema schema = (XSDSchema)getModel(); - String ns = schema.getTargetNamespace() != null ? schema.getTargetNamespace() : ""; - label.setText(ns); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaExtensibilityElementEditPart.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaExtensibilityElementEditPart.java deleted file mode 100644 index c10245b7c..000000000 --- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/xsd/graph/editparts/XSDSchemaExtensibilityElementEditPart.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsdl.ui.internal.xsd.graph.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement; -import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerFigure; - - -public class XSDSchemaExtensibilityElementEditPart extends AbstractGraphicalEditPart -{ - protected EditPartFactory factory; - - public XSDSchemaExtensibilityElementEditPart(EditPartFactory factory) - { - this.factory = factory; - } - - protected IFigure createFigure() - { - ContainerFigure figure = new ContainerFigure(); - return figure; - } - - protected EditPart createChild(Object model) - { - return factory.createEditPart(this, model); - } - - protected List getModelChildren() - { - XSDSchemaExtensibilityElement e = (XSDSchemaExtensibilityElement)getModel(); - List result = new ArrayList(); - result.add(e.getSchema()); - return result; - } - - protected void createEditPolicies() - { - } -}
\ No newline at end of file |