Removal of unused methods and classes.
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCopyAction.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCopyAction.java
index 4c820b0..d377522 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCopyAction.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCopyAction.java
@@ -17,11 +17,11 @@
import org.eclipse.bpel.ui.commands.BPELCopyCommand;
import org.eclipse.bpel.ui.commands.CompoundCommand;
import org.eclipse.bpel.ui.commands.RestoreSelectionCommand;
-import org.eclipse.bpel.ui.util.SharedImages;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
/**
@@ -31,29 +31,27 @@
*
*/
public class BPELCopyAction extends EditAction {
-
+
public final static String ID = "BPELCopyAction"; //$NON-NLS-1$
-
+
/**
* Brand new shiny copy action.
- *
+ *
* @param editorPart
*/
public BPELCopyAction(IWorkbenchPart editorPart) {
super(editorPart);
}
-
+
@Override
protected void init() {
super.init();
- setText(Messages.BPELCopyAction_Copy_1);
- setToolTipText(Messages.BPELCopyAction_Copy_2);
+ setText(Messages.BPELCopyAction_Copy_1);
+ setToolTipText(Messages.BPELCopyAction_Copy_2);
setId(ID);
- setImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_COPY));
- setDisabledImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_COPY_DISABLED));
+ setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_COPY ));
+ setDisabledImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_COPY_DISABLED ));
setEnabled(false);
}
@@ -63,22 +61,22 @@
*/
@Override
protected Command getCommand() {
-
- CompoundCommand cmd = new CompoundCommand(Messages.BPELCopyAction_Copy_3);
-
+
+ CompoundCommand cmd = new CompoundCommand(Messages.BPELCopyAction_Copy_3);
+
final BPELEditor bpelEditor = (BPELEditor) getWorkbenchPart();
-
+
// 1. Restore selection
cmd.add(new RestoreSelectionCommand(bpelEditor.getAdaptingSelectionProvider(), true, true));
// 2. Copy the selected objects
BPELCopyCommand copyCmd = new BPELCopyCommand(bpelEditor);
- copyCmd.setObjectList( new ArrayList<EObject>(fSelection) );
+ copyCmd.setObjectList( new ArrayList<EObject>(this.fSelection) );
cmd.add(copyCmd);
-
-
+
+
return cmd;
}
-
+
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCutAction.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCutAction.java
index 715173e..3e35bd0 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCutAction.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELCutAction.java
@@ -20,11 +20,11 @@
import org.eclipse.bpel.ui.commands.DeleteChildCommand;
import org.eclipse.bpel.ui.commands.DeleteLinkCommand;
import org.eclipse.bpel.ui.commands.RestoreSelectionCommand;
-import org.eclipse.bpel.ui.util.SharedImages;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
/**
@@ -33,9 +33,9 @@
*
*/
public class BPELCutAction extends BPELDeleteAction {
-
+
public final static String ID = "BPELCutAction"; //$NON-NLS-1$
-
+
/**
* @param editorPart
*/
@@ -47,36 +47,34 @@
protected void init() {
super.init();
- setText(Messages.BPELCutAction_Cut_1);
- setToolTipText(Messages.BPELCutAction_Cut_2);
+ setText(Messages.BPELCutAction_Cut_1);
+ setToolTipText(Messages.BPELCutAction_Cut_2);
setId(ID);
- setImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_CUT));
- setDisabledImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_CUT_DISABLED));
+ setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_CUT ));
+ setDisabledImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_CUT_DISABLED ));
setEnabled(false);
}
-
+
@Override
protected Command getCommand () {
-
- if (fSelection.isEmpty()) {
+
+ if (this.fSelection.isEmpty()) {
return null ;
}
-
+
final BPELEditor bpelEditor = (BPELEditor) getWorkbenchPart();
-
+
CompoundCommand cmd = new CompoundCommand(Messages.BPELCutAction_Cut_3);
-
- // 1. Restore selection on undo/redo
+
+ // 1. Restore selection on undo/redo
cmd.add(new RestoreSelectionCommand(bpelEditor.getAdaptingSelectionProvider(), true, true));
- // 2. Actually copy the elements.
+ // 2. Actually copy the elements.
BPELCopyCommand copyCmd = new BPELCopyCommand( (BPELEditor)getWorkbenchPart() );
- copyCmd.setObjectList( new ArrayList<EObject> ( fSelection ) ) ;
+ copyCmd.setObjectList( new ArrayList<EObject> ( this.fSelection ) ) ;
cmd.add(copyCmd);
-
-
+
+
// // workaround: deselect all the objects first,
// // avoiding the untimely notification which leads to an NPE.
// // TODO: is this still needed? might not be, with batched adapters
@@ -85,18 +83,18 @@
// public Resource[] getResources() { return EMPTY_RESOURCE_ARRAY; }
// public Resource[] getModifiedResources() { return EMPTY_RESOURCE_ARRAY; }
// });
-//
-//
- // 3. The delete commands
- for(EObject next : fSelection) {
+//
+//
+ // 3. The delete commands
+ for(EObject next : this.fSelection) {
if (next instanceof Link) {
cmd.add(new DeleteLinkCommand((Link)next));
} else {
cmd.add(new DeleteChildCommand(next));
- }
+ }
}
-
+
return cmd;
}
-
+
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELDeleteAction.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELDeleteAction.java
index 081dbab..973a51b 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELDeleteAction.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELDeleteAction.java
@@ -12,13 +12,13 @@
/*******************************************************************************
* A newer version of DeleteAction
- *
+ *
* This version customizes the selection behavior after the delete has happened
* For example, we want to select a sibling after a particular object has been
* deleted as a usability enhancement.
- *
+ *
* This version customizes the label behavior of the DeleteAction.
- *
+ *
*******************************************************************************/
import org.eclipse.bpel.model.Link;
@@ -30,7 +30,6 @@
import org.eclipse.bpel.ui.commands.DeleteLinkCommand;
import org.eclipse.bpel.ui.commands.RestoreSelectionCommand;
import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.bpel.ui.util.SharedImages;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
@@ -38,30 +37,31 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
/**
* An action to delete selected objects.
*/
public class BPELDeleteAction extends EditAction {
-
+
public final static String ID = "BPELDeleteAction"; //$NON-NLS-1$
-
+
/**
* Brand new Delete Action.
* @param editor
*/
-
+
public BPELDeleteAction(IWorkbenchPart editor) {
super(editor);
}
-
+
/**
* Brand new DeleteAction.
- *
+ *
* @param editor
* @param label
*/
-
+
public BPELDeleteAction(IWorkbenchPart editor, String label) {
super(editor);
setText(label);
@@ -70,29 +70,27 @@
@Override
protected void init() {
super.init();
- setText(Messages.DeleteSelectedAction_Delete_1);
- setToolTipText(Messages.DeleteSelectedAction_Delete_2);
+ setText(Messages.DeleteSelectedAction_Delete_1);
+ setToolTipText(Messages.DeleteSelectedAction_Delete_2);
setId(ID);
- setImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_DELETE));
- setDisabledImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_DELETE ));
+ setDisabledImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_DELETE_DISABLED ));
setEnabled(false);
}
-
+
@SuppressWarnings("boxing")
@Override
protected Command getCommand () {
-
- if (fSelection.isEmpty()) {
+
+ if (this.fSelection.isEmpty()) {
return null ;
}
-
+
final BPELEditor bpelEditor = (BPELEditor) getWorkbenchPart();
-
+
CompoundCommand cmd = new CompoundCommand(Messages.DeleteSelectedAction_Delete_3);
-
+
// 1. Restore selection on undo/redo
cmd.add(new RestoreSelectionCommand(bpelEditor.getAdaptingSelectionProvider(), true, true));
@@ -104,26 +102,26 @@
// public Resource[] getResources() { return EMPTY_RESOURCE_ARRAY; }
// public Resource[] getModifiedResources() { return EMPTY_RESOURCE_ARRAY; }
// });
-//
-//
-
+//
+//
+
// 2. The delete commands.
- for(EObject next : fSelection) {
-
+ for(EObject next : this.fSelection) {
+
if (next instanceof Link) {
cmd.add(new DeleteLinkCommand((Link)next));
} else {
cmd.add(new DeleteChildCommand(next));
- }
- }
-
- int count = fSelection.size();
-
+ }
+ }
+
+ int count = this.fSelection.size();
+
// override default label
if (count == 1) {
cmd.setLabel(cmd.getLabel());
} else if (count > 1) {
- cmd.setLabel(NLS.bind(Messages.DeleteSelectedAction_Delete_Items_3, count));
+ cmd.setLabel(NLS.bind(Messages.DeleteSelectedAction_Delete_Items_3, count));
} else {
// commandCount is 0
return UnexecutableCommand.INSTANCE;
@@ -131,33 +129,33 @@
return cmd;
}
-
+
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
-
- fSelection = trimSelection (fSelection);
-
+
+ this.fSelection = trimSelection (this.fSelection);
+
Command cmd = getCommand();
if (cmd == null) {
return ;
}
-
- EObject modelObject = fSelection.get(0);
-
+
+ EObject modelObject = this.fSelection.get(0);
+
EObject parent = modelObject.eContainer();
Object sibling = null;
IContainer<EObject> container = BPELUtil.adapt(parent, IContainer.class);
if (container != null) {
sibling = container.getNextSiblingChild(parent, modelObject);
}
-
+
execute( cmd );
BPELEditor bpelEditor = (BPELEditor) getWorkbenchPart();
-
+
// TODO: make sure setFocus() hack makes it into RestoreSelectionCommand
bpelEditor.setFocus();
if (sibling == null) {
@@ -166,5 +164,5 @@
bpelEditor.getAdaptingSelectionProvider().setSelection(new StructuredSelection(sibling));
}
}
-
+
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELPasteAction.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELPasteAction.java
index 8ee24fe..42e8794 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELPasteAction.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/actions/BPELPasteAction.java
@@ -16,23 +16,23 @@
import org.eclipse.bpel.ui.commands.CompoundCommand;
import org.eclipse.bpel.ui.commands.RestoreSelectionCommand;
import org.eclipse.bpel.ui.commands.SetSelectionCommand;
-import org.eclipse.bpel.ui.util.SharedImages;
import org.eclipse.bpel.ui.util.TransferBuffer;
import org.eclipse.gef.commands.Command;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
/**
* @author IBM, Original Contribution.
- *
+ *
* @author Michal Chmielewski (michal.chmielewski@oracle.com)
* @date Jun 4, 2007
*
*/
public class BPELPasteAction extends EditAction {
-
+
public final static String ID = "BPELPasteAction"; //$NON-NLS-1$
-
+
/**
* Brand new BPELPaste action.
* @param editorPart
@@ -44,13 +44,11 @@
@Override
protected void init() {
super.init();
- setText(Messages.BPELPasteAction_Paste_1);
- setToolTipText(Messages.BPELPasteAction_Paste_2);
+ setText(Messages.BPELPasteAction_Paste_1);
+ setToolTipText(Messages.BPELPasteAction_Paste_2);
setId(ID);
- setImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_PASTE));
- setDisabledImageDescriptor(SharedImages.getWorkbenchImageDescriptor(
- ISharedImages.IMG_TOOL_PASTE_DISABLED));
+ setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_PASTE ));
+ setDisabledImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_PASTE_DISABLED ));
setEnabled(false);
}
@@ -58,49 +56,49 @@
/**
* @see org.eclipse.bpel.ui.actions.EditAction#getCommand()
*/
-
+
@Override
protected Command getCommand() {
-
- CompoundCommand cmd = new CompoundCommand(Messages.BPELPasteAction_Paste_3);
-
+
+ CompoundCommand cmd = new CompoundCommand(Messages.BPELPasteAction_Paste_3);
+
final BPELEditor bpelEditor = (BPELEditor) getWorkbenchPart();
-
+
// 1. Restore selection
cmd.add(new RestoreSelectionCommand(bpelEditor.getAdaptingSelectionProvider(), true, true));
// 2. Paste Command
BPELPasteCommand cmdPaste = new BPELPasteCommand(bpelEditor);
- cmdPaste.setTargetObject( fSelection.get(0) , false );
+ cmdPaste.setTargetObject( this.fSelection.get(0) , false );
cmd.add(cmdPaste);
-
- // 3. Add the command to select the pasted elements
- cmd.add( new SetSelectionCommand(cmdPaste,false) );
+
+ // 3. Add the command to select the pasted elements
+ cmd.add( new SetSelectionCommand(cmdPaste,false) );
return cmd;
}
-
+
@Override
protected boolean calculateEnabled() {
-
- boolean bEnabled = super.calculateEnabled() && fSelection.size() == 1;
-
+
+ boolean bEnabled = super.calculateEnabled() && this.fSelection.size() == 1;
+
if (!bEnabled) {
return bEnabled;
- }
-
+ }
+
BPELEditor bpelEditor = (BPELEditor)getWorkbenchPart();
TransferBuffer tb = bpelEditor.getTransferBuffer();
-
+
if (tb == null) {
return false;
}
-
- return tb.canCopyTransferBufferTo( fSelection.get(0) , false );
+
+ return tb.canCopyTransferBufferTo( this.fSelection.get(0) , false );
}
-
-
-
+
+
+
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELEditorUtil.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELEditorUtil.java
index fafce56..f4e03f3 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELEditorUtil.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELEditorUtil.java
@@ -1,45 +1,28 @@
package org.eclipse.bpel.ui.util;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import org.eclipse.bpel.model.Process;
import org.eclipse.bpel.model.util.BPELConstants;
-
-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.WSDLElement;
-import org.eclipse.wst.wsdl.ui.internal.extensions.ExtensibleTypeSystemProvider;
-import org.eclipse.wst.wsdl.ui.internal.extensions.ITypeSystemProvider;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
public class BPELEditorUtil extends BPELConstants
{
- protected static BPELEditorUtil instance;
+ protected static BPELEditorUtil instance = new BPELEditorUtil();
protected BPELNodeAssociationManager nodeAssociationManager = new BPELNodeAssociationManager();
protected HashMap elementNameToTypeMap = new HashMap();
-
+
public static final int ELEMENT = 14;
public static final int TYPE = 15;
- public static BPELEditorUtil getInstance()
- {
- if (instance == null)
- {
- instance = new BPELEditorUtil();
- }
+ public static BPELEditorUtil getInstance() {
return instance;
}
- public BPELEditorUtil()
+ private BPELEditorUtil()
{
//FIXME add bpel tags here
/*elementNameToTypeMap.put(BINDING_ELEMENT_TAG, new Integer(BINDING));
@@ -58,27 +41,13 @@
elementNameToTypeMap.put(TYPES_ELEMENT_TAG, new Integer(TYPES));*/
}
- public String getBPELType(Element element)
- {
- String result = "";
+ public String getBPELType(Element element) {
return element.getLocalName();
}
- 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(Process process, Element targetElement)
{
- Object o = nodeAssociationManager.getModelObjectForNode(process, targetElement);
+ Object o = this.nodeAssociationManager.getModelObjectForNode(process, targetElement);
return o;
}
@@ -86,151 +55,4 @@
{
return ((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(":"); //$NON-NLS-1$
-// String prefix = (index == -1) ? null : prefixedName.substring(0, index);
- String prefix = (index == -1) ? "" : 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();
- }
-
- 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;
- }
-
- /*public static String getTargetNamespaceURIForSchema(String uri)
- {
- String result = null;
- try
- {
- URL url = new URL(uri);
- InputStream inputStream = url.openStream();
- result = WSDLEditorUtil.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(WSDLEditorUtil.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")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- int nAttributes = attributes.getLength();
- for (int i = 0; i < nAttributes; i++)
- {
- if (attributes.getLocalName(i).equals("targetNamespace")) //$NON-NLS-1$
- {
- 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();
- }
- }*/
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELReader.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELReader.java
index f7ccbd1..3f9e158 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELReader.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELReader.java
@@ -30,7 +30,6 @@
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
/**
@@ -44,18 +43,6 @@
protected ExtensionMap extensionMap;
/**
- * Reads the given BPEL file.
- */
- public void read(IFile modelFile, ResourceSet resourceSet) {
- // TODO: These two lines are a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=72565
- EcorePackage instance = EcorePackage.eINSTANCE;
- instance.eAdapters();
- URI uri = URI.createPlatformResourceURI(modelFile.getFullPath().toString());
- processResource = resourceSet.getResource(uri, true);
- read(processResource, modelFile, resourceSet);
- }
-
- /**
* Another public method for those who want to get the process resource
* by their own means (such as the editor).
*/
@@ -63,9 +50,9 @@
// TODO: These two lines are a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=72565
EcorePackage instance = EcorePackage.eINSTANCE;
instance.eAdapters();
-
+
this.processResource = processResource;
-
+
IPath extensionsPath = modelFile.getFullPath().removeFileExtension().addFileExtension(IBPELUIConstants.EXTENSION_MODEL_EXTENSIONS);
URI extensionsUri = URI.createPlatformResourceURI(extensionsPath.toString());
IFile extensionsFile = ResourcesPlugin.getWorkspace().getRoot().getFile(extensionsPath);
@@ -74,59 +61,59 @@
processResource.load(Collections.EMPTY_MAP);
EList<EObject> contents = processResource.getContents();
if (!contents.isEmpty())
- process = (Process) contents.get(0);
+ this.process = (Process) contents.get(0);
} catch (Exception e) {
// TODO: If a file is empty Resource.load(Map) throws a java.lang.NegativeArraySizeException
// We should investigate EMF to see if we are supposed to handle this case or if this
- // is a bug in EMF.
+ // is a bug in EMF.
BPELUIPlugin.log(e);
}
try {
- extensionsResource = resourceSet.getResource(extensionsUri, extensionsFile.exists());
- if (extensionsResource != null) {
- extensionMap = ExtensionmodelFactory.eINSTANCE.findExtensionMap(
- IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE, extensionsResource.getContents());
+ this.extensionsResource = resourceSet.getResource(extensionsUri, extensionsFile.exists());
+ if (this.extensionsResource != null) {
+ this.extensionMap = ExtensionmodelFactory.eINSTANCE.findExtensionMap(
+ IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE, this.extensionsResource.getContents());
}
// Bugzilla 330513
- if (extensionMap != null)
- extensionMap.initializeAdapter();
+ if (this.extensionMap != null)
+ this.extensionMap.initializeAdapter();
} catch (Exception e) {
BPELUIPlugin.log(e);
}
- if (process == null) {
- process = BPELFactory.eINSTANCE.createProcess();
- processResource.getContents().add(process);
+ if (this.process == null) {
+ this.process = BPELFactory.eINSTANCE.createProcess();
+ processResource.getContents().add(this.process);
}
- if (extensionMap == null) {
- extensionMap = ExtensionmodelFactory.eINSTANCE.createExtensionMap(IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE);
- if (extensionsResource == null) {
- extensionsResource = resourceSet.createResource(extensionsUri);
+ if (this.extensionMap == null) {
+ this.extensionMap = ExtensionmodelFactory.eINSTANCE.createExtensionMap(IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE);
+ if (this.extensionsResource == null) {
+ this.extensionsResource = resourceSet.createResource(extensionsUri);
}
- extensionsResource.getContents().clear();
- extensionsResource.getContents().add(extensionMap);
+ this.extensionsResource.getContents().clear();
+ this.extensionsResource.getContents().add(this.extensionMap);
}
// Make sure the Process has Variables, PartnerLinks, CorrelationSets and MessageExchanges objects.
// They aren't strictly necessary according to the spec but make we need those in
// order for the editor tray to work.
- if (process.getVariables() == null) {
- process.setVariables(BPELFactory.eINSTANCE.createVariables());
+ if (this.process.getVariables() == null) {
+ this.process.setVariables(BPELFactory.eINSTANCE.createVariables());
}
- if (process.getPartnerLinks() == null) {
- process.setPartnerLinks(BPELFactory.eINSTANCE.createPartnerLinks());
+ if (this.process.getPartnerLinks() == null) {
+ this.process.setPartnerLinks(BPELFactory.eINSTANCE.createPartnerLinks());
}
- if (process.getCorrelationSets() == null) {
- process.setCorrelationSets(BPELFactory.eINSTANCE.createCorrelationSets());
+ if (this.process.getCorrelationSets() == null) {
+ this.process.setCorrelationSets(BPELFactory.eINSTANCE.createCorrelationSets());
}
- if (process.getMessageExchanges() == null) {
- process.setMessageExchanges(BPELFactory.eINSTANCE.createMessageExchanges());
+ if (this.process.getMessageExchanges() == null) {
+ this.process.setMessageExchanges(BPELFactory.eINSTANCE.createMessageExchanges());
}
-
+
// Make sure scopes have Variables.
// They aren't strictly necessary according to the spec but make we need those in
// order for the editor tray to work.
- for (Iterator<EObject> iter = process.eAllContents(); iter.hasNext();) {
+ for (Iterator<EObject> iter = this.process.eAllContents(); iter.hasNext();) {
EObject object = iter.next();
if (object instanceof Scope) {
Scope scope = (Scope)object;
@@ -144,131 +131,27 @@
}
}
}
-
+
// Make sure each model object has the necessary extensions!
- TreeIterator<EObject> it = process.eAllContents();
+ TreeIterator<EObject> it = this.process.eAllContents();
while (it.hasNext()) {
- ModelHelper.createExtensionIfNecessary(extensionMap, it.next());
- }
-
- if (extensionMap.get(process) == null) {
- ModelHelper.createExtensionIfNecessary(extensionMap, process);
- }
- }
-
- /**
- * Another public method for those who want to get the process resource
- * by their own means (such as the editor).
- */
- public void read(Resource processResource, IDOMModel domModel, ResourceSet resourceSet) {
- // TODO: These two lines are a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=72565
- EcorePackage instance = EcorePackage.eINSTANCE;
- instance.eAdapters();
-
- this.processResource = processResource;
-
- //IPath extensionsPath = modelFile.getFullPath().removeFileExtension().addFileExtension(IBPELUIConstants.EXTENSION_MODEL_EXTENSIONS);
- org.eclipse.core.runtime.IPath extensionsPath
- = (new org.eclipse.core.runtime.Path(domModel.getBaseLocation())).removeFileExtension().addFileExtension(IBPELUIConstants.EXTENSION_MODEL_EXTENSIONS);
- URI extensionsUri = URI.createPlatformResourceURI(extensionsPath.toString());
- IFile extensionsFile = ResourcesPlugin.getWorkspace().getRoot().getFile(extensionsPath);
-
- try {
- processResource.load(Collections.EMPTY_MAP);
- EList<EObject> contents = processResource.getContents();
- if (!contents.isEmpty())
- process = (Process) contents.get(0);
- } catch (Exception e) {
- // TODO: If a file is empty Resource.load(Map) throws a java.lang.NegativeArraySizeException
- // We should investigate EMF to see if we are supposed to handle this case or if this
- // is a bug in EMF.
- BPELUIPlugin.log(e);
- }
- try {
- extensionsResource = resourceSet.getResource(extensionsUri, extensionsFile.exists());
- if (extensionsResource != null) {
- extensionMap = ExtensionmodelFactory.eINSTANCE.findExtensionMap(
- IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE, extensionsResource.getContents());
- }
- } catch (Exception e) {
- BPELUIPlugin.log(e);
- }
- if (extensionMap != null) extensionMap.initializeAdapter();
-
- if (process == null) {
- process = BPELFactory.eINSTANCE.createProcess();
- processResource.getContents().add(process);
- }
- if (extensionMap == null) {
- extensionMap = ExtensionmodelFactory.eINSTANCE.createExtensionMap(IBPELUIConstants.MODEL_EXTENSIONS_NAMESPACE);
- if (extensionsResource == null) {
- extensionsResource = resourceSet.createResource(extensionsUri);
- }
- extensionsResource.getContents().clear();
- extensionsResource.getContents().add(extensionMap);
+ ModelHelper.createExtensionIfNecessary(this.extensionMap, it.next());
}
- // Make sure the Process has Variables, PartnerLinks and CorrelationSets objects.
- // They aren't strictly necessary according to the spec but make we need those in
- // order for the editor tray to work.
- if (process.getVariables() == null) {
- process.setVariables(BPELFactory.eINSTANCE.createVariables());
- }
- if (process.getPartnerLinks() == null) {
- process.setPartnerLinks(BPELFactory.eINSTANCE.createPartnerLinks());
- }
- if (process.getCorrelationSets() == null) {
- process.setCorrelationSets(BPELFactory.eINSTANCE.createCorrelationSets());
- }
- if (process.getMessageExchanges() == null) {
- process.setMessageExchanges(BPELFactory.eINSTANCE.createMessageExchanges());
- }
- // Make sure scopes have Variables.
- // They aren't strictly necessary according to the spec but make we need those in
- // order for the editor tray to work.
- for (Iterator<EObject> iter = process.eAllContents(); iter.hasNext();) {
- EObject object = iter.next();
- if (object instanceof Scope) {
- Scope scope = (Scope)object;
- if (scope.getVariables() == null) {
- scope.setVariables(BPELFactory.eINSTANCE.createVariables());
- }
- if (scope.getPartnerLinks() == null) {
- scope.setPartnerLinks(BPELFactory.eINSTANCE.createPartnerLinks());
- }
- if (scope.getCorrelationSets() == null) {
- scope.setCorrelationSets(BPELFactory.eINSTANCE.createCorrelationSets());
- }
- if (scope.getMessageExchanges() == null) {
- scope.setMessageExchanges(BPELFactory.eINSTANCE.createMessageExchanges());
- }
- }
- }
-
- // Make sure each model object has the necessary extensions!
- TreeIterator<EObject> it = process.eAllContents();
- while (it.hasNext()) {
- ModelHelper.createExtensionIfNecessary(extensionMap, it.next());
- }
-
- if (extensionMap.get(process) == null) {
- ModelHelper.createExtensionIfNecessary(extensionMap, process);
+ if (this.extensionMap.get(this.process) == null) {
+ ModelHelper.createExtensionIfNecessary(this.extensionMap, this.process);
}
}
public ExtensionMap getExtensionMap() {
- return extensionMap;
+ return this.extensionMap;
}
-
+
public Resource getExtensionsResource() {
- return extensionsResource;
+ return this.extensionsResource;
}
-
+
public Process getProcess() {
- return process;
- }
-
- public Resource getProcessResource() {
- return processResource;
+ return this.process;
}
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java
index 8ed0165..9632b3f 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java
@@ -175,7 +175,7 @@
/**
* BPELUtil is a place to put *static* helper methods for the BPEL editor.
- *
+ *
* Note that helpers which have specifically to do with accessing model objects are
* usually found in the ModelHelper class.
*/
@@ -194,120 +194,117 @@
* Global variable storing the path of the last BPEL file selected
*/
public static IPath lastBPELFilePath = null;
-
+
/**
* Global variable storing the path of the last XSD file selected
*/
public static IPath lastXSDFilePath;
-
-
+
+
static {
AdapterRegistry.INSTANCE.registerAdapterFactory(
BPELPackage.eINSTANCE, BPELUIAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
WSDLPackage.eINSTANCE, BPELUIWSDLAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
PartnerlinktypePackage.eINSTANCE, BPELUIPartnerLinkTypeAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
XSDPackage.eINSTANCE, BPELUIXSDAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
MessagepropertiesPackage.eINSTANCE, BPELUIMessagePropertiesAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
UiextensionmodelPackage.eINSTANCE, BPELUIExtensionAdapterFactory.getInstance());
-
+
AdapterRegistry.INSTANCE.registerAdapterFactory(
InspectionPackage.eINSTANCE, BPELUIWSILAdapterFactory.getInstance() );
-
+
}
-
+
/**
* Register adapter factory for the given EClass.
- *
+ *
* @param key
* @param factory
*/
-
+
public static void registerAdapterFactory(EClass key, AdapterFactory factory) {
AdapterRegistry.INSTANCE.registerAdapterFactory(key,factory);
}
-
+
public static void registerAdapterFactory(EPackage key, AdapterFactory factory) {
AdapterRegistry.INSTANCE.registerAdapterFactory(key, factory);
}
-
+
static Class<?> adapterInterface ( Object type ) {
-
+
if (type instanceof Class) {
return (Class) type;
}
-
+
if (type instanceof String) {
try {
return Class.forName((String)type);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
- }
+ }
}
-
+
throw new RuntimeException("Adapter type " + type + " is not understood."); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* @param <T>
* @param target
* @param clazz
* @return the adapted interface or object
*/
-
- @SuppressWarnings("unchecked")
-
- public static <T extends Object> T adapt ( Object target, Class<T> clazz) {
+ public static <T extends Object> T adapt ( Object target, Class<T> clazz) {
return AdapterRegistry.INSTANCE.adapt(target, clazz);
}
-
-
-
+
+
+
/**
* This method tries the registered adapter factories one by one, returning
* the first non-null result it gets. If none of the factories can adapt
* the result, it returns null.
- * @param target target object
+ * @param target target object
* @param type type of the adapter to find
* @return the adapter for the target.
*/
-
+
public static Object adapt (Object target, Object type) {
return AdapterRegistry.INSTANCE.adapt(target, type);
}
-
-
+
+
/**
- * Create an adapter for the given target of the given type.
- * In addition, pass a context object to the adapter(s) of the target.
- *
- * The idea is that some adapters can be stateful and depend not only
+ * Create an adapter for the given target of the given type.
+ * In addition, pass a context object to the adapter(s) of the target.
+ *
+ * The idea is that some adapters can be stateful and depend not only
* on the objects that they wrap, but also on some other context that is needed
* to completely and correctly implement the interface for which the adaptor is
* needed.
- *
+ *
* Adapters that are stateless, should ignore any notifications sent to them.
- *
+ *
* @param target the target object
* @param type the type it wants to adapt to
* @param context the context object
- *
+ *
* @return the adapter
*/
- public static Object adapt (Object target, Object type, Object context) {
+ public static Object adapt (Object target, Object type, Object context) {
return AdapterRegistry.INSTANCE.adapt(target, type,context);
}
-
+
/**
* Returns the effective EClass for a custom activity (action).
@@ -315,8 +312,8 @@
public static EClass getEClassFor(Object target) {
if (target instanceof Invoke) {
ActionDescriptor[] descriptors = BPELUIRegistry.getInstance().getActionDescriptors();
- for (int i = 0; i < descriptors.length; i++) {
- AbstractBPELAction action = descriptors[i].getAction();
+ for( ActionDescriptor descriptor : descriptors ) {
+ AbstractBPELAction action = descriptor.getAction();
if (action.isInstanceOf(target)) {
return action.getModelType();
}
@@ -327,12 +324,12 @@
}
return ((EObject)target).eClass();
}
-
+
public static boolean isCustomActivity(Object target) {
if (target instanceof Invoke) {
ActionDescriptor[] descriptors = BPELUIRegistry.getInstance().getActionDescriptors();
- for (int i = 0; i < descriptors.length; i++) {
- AbstractBPELAction action = descriptors[i].getAction();
+ for( ActionDescriptor descriptor : descriptors ) {
+ AbstractBPELAction action = descriptor.getAction();
if (action.getModelType() == BPELPackage.eINSTANCE.getInvoke()) continue;
if (action.isInstanceOf(target)) {
return true;
@@ -341,11 +338,11 @@
}
return false;
}
-
+
public static boolean isBPELAction(EClass target) {
ActionDescriptor[] descriptors = BPELUIRegistry.getInstance().getActionDescriptors();
- for (int i = 0; i < descriptors.length; i++) {
- AbstractBPELAction action = descriptors[i].getAction();
+ for( ActionDescriptor descriptor : descriptors ) {
+ AbstractBPELAction action = descriptor.getAction();
if (action.getModelType() == target) {
return true;
}
@@ -354,76 +351,76 @@
}
/**
- * Creates a new instance of clazz using the EFactory of the EPackage clazz belongs to.
+ * Creates a new instance of clazz using the EFactory of the EPackage clazz belongs to.
*/
public static EObject createEObject(EClass clazz) {
return clazz.getEPackage().getEFactoryInstance().create(clazz);
}
-
+
// This is a hack to bundle the result of a cloneSubtree with enough state to undo/redo
- // the extension map changes it caused.
+ // the extension map changes it caused.
public static class CloneResult {
-
+
/** The result of the clone */
public EObject targetRoot;
Map<EObject,EObject> targetMap;
Map<EObject,EObject> targetMapAdditions = new HashMap<EObject,EObject>();
-
+
/**
* Undo ... ?
*/
public void undo() {
- for (EObject next : targetMapAdditions.keySet()) {
- targetMap.remove(next);
+ for (EObject next : this.targetMapAdditions.keySet()) {
+ this.targetMap.remove(next);
}
}
-
+
/**
- * Redo ... ?
+ * Redo ... ?
*/
public void redo() {
- for (EObject key : targetMapAdditions.keySet()) {
- targetMap.put(key, targetMapAdditions.get(key));
+ for (EObject key : this.targetMapAdditions.keySet()) {
+ this.targetMap.put(key, this.targetMapAdditions.get(key));
}
}
}
-
+
// This helper is used by the cloneSubtree() method.
protected static void cloneSubtreeHelper (EObject source, Map<EObject,EObject> sourceMap, Map<EObject,EObject> targetMap,
Map<EObject,EObject> copyMap, CloneResult result)
{
EObject targetObject = createEObject(source.eClass());
copyMap.put(source, targetObject);
-
+
if (sourceMap != null && sourceMap.containsKey(source)) {
-
+
EObject sourceExtension = sourceMap.get(source);
EObject targetExtension = createEObject(sourceExtension.eClass());
-
+
copyMap.put(sourceExtension, targetExtension);
-
+
for (TreeIterator<?> it2 = sourceExtension.eAllContents(); it2.hasNext(); ) {
EObject source2 = (EObject)it2.next();
EObject target2 = createEObject(source2.eClass());
copyMap.put(source2, target2);
}
-
+
targetMap.put(targetObject, targetExtension);
result.targetMapAdditions.put(targetObject, targetExtension);
}
}
-
+
/**
* Clones an EObject and all EObjects contained directly or indirectly within it. All
* cloned objects possessing an extension in the sourceMap will also have their extensions
* cloned into the targetMap. Containment references and other references to any of the
* cloned object(s) will be fixed up to point into the target objects. Any references to
* non-cloned objects will be copied as-is in the cloned objects.
- *
+ *
* NOTE: This method relies on BPELUtil.createEObject() knowing how to create new instances
* of the EClasses of all copied objects (i.e. objectFactories must contain the necessary
* EFactory instances for everything copied by this method).
- *
+ *
* @param source The root of the source subtree to clone.
* @param sourceMap The extension map containing source extensions of cloned objects.
* @param targetMap The extension map in which cloned extensions should be recorded.
@@ -432,12 +429,12 @@
*/
@SuppressWarnings("nls")
public static CloneResult cloneSubtree (EObject source, Map<EObject,EObject> sourceMap, Map<EObject,EObject> targetMap) {
-
+
HashMap<EObject,EObject> copyMap = new HashMap<EObject,EObject>();
-
+
CloneResult result = new CloneResult();
result.targetMap = targetMap;
-
+
// (1) Create target objects for each EObject in the containment subtree of source.
// If the source object has an extension in sourceMap, create copies of the extension
// and its containment tree as well.
@@ -445,46 +442,46 @@
// work with fixing up references. We have to iterate its eAllContents also here.
cloneSubtreeHelper(source, sourceMap, targetMap, copyMap, result);
-
+
for (TreeIterator<?> it = source.eAllContents(); it.hasNext(); ) {
EObject sourceObject = (EObject)it.next();
cloneSubtreeHelper(sourceObject, sourceMap, targetMap, copyMap, result);
}
-
+
// (2) Copy the features from each cloned source object to the corresponding target
// object. As we copy, we replace any references to cloned source objects with
// references to the corresponding target objects--but references to non-cloned
// objects are copied as-is.
-
+
for (Map.Entry<EObject,EObject> entry : copyMap.entrySet() ) {
-
+
EObject sourceObject = entry.getKey();
- EObject targetObject = entry.getValue();
-
+ EObject targetObject = entry.getValue();
+
if (sourceObject.eClass() != targetObject.eClass()) {
throw new IllegalStateException("Source and target objects are not of the same class after cloning.");
}
-
+
if (Policy.DEBUG) {
System.out.println("copying a "+sourceObject.eClass().getName()); //$NON-NLS-1$
}
-
+
for ( EStructuralFeature feature : sourceObject.eClass().getEAllStructuralFeatures()) {
-
+
// special cases first.
if (!feature.isChangeable()) {
if (Policy.DEBUG) System.out.println(" *** skipping unchangeable feature "+feature); //$NON-NLS-1$
continue;
- }
-
+ }
+
if (feature.isUnsettable() && !targetObject.eIsSet(feature)) {
if (Policy.DEBUG) System.out.println(" unsetting feature "+feature.getName()); //$NON-NLS-1$
- targetObject.eUnset(feature);
+ targetObject.eUnset(feature);
continue;
}
-
+
Object value = sourceObject.eGet(feature);
-
+
boolean treatAsReference = (feature instanceof EReference);
if (treatAsReference) {
@@ -492,16 +489,16 @@
// list of references.
EList<Object> newValues = new BasicEList<Object>();
if (Policy.DEBUG) System.out.println(" copying multi-reference feature "+feature.getName()+":"); //$NON-NLS-1$ //$NON-NLS-2$
-
+
for (Iterator<?> it3 = ((Collection)value).iterator(); it3.hasNext(); ) {
Object oldValue = it3.next();
Object newValue = (oldValue==null ? null : copyMap.get(oldValue));
-
+
if (newValue == null) {
newValue = oldValue;
}
if (Policy.DEBUG) System.out.println("+ (oldValue="+oldValue+" newValue="+newValue+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- newValues.add(newValue);
+ newValues.add(newValue);
}
targetObject.eSet(feature, newValues);
} else {
@@ -512,28 +509,28 @@
}
if (Policy.DEBUG) System.out.println(" copying reference feature "+feature.getName() //$NON-NLS-1$
+" (value="+value+" newValue="+newValue+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- targetObject.eSet(feature, newValue);
+ targetObject.eSet(feature, newValue);
}
} else {
-
+
/** In case of a DOM Node and the "element" feature, we simply clone the result */
if (value instanceof org.w3c.dom.Node && "element".equals(feature.getName())) {
org.w3c.dom.Node e = (org.w3c.dom.Node)value;
value = e.cloneNode(true);
}
-
+
// non-reference attribute. just copy the value
if (Policy.DEBUG) System.out.println(" copying attr feature "+feature.getName()+" (value="+value+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
targetObject.eSet(feature, value);
}
}
}
-
+
result.targetRoot = copyMap.get(source);
return result;
}
-
+
/**
* Convenience formatting methods.
*/
@@ -543,24 +540,24 @@
public static String formatString(String format, String arg1, String arg2) {
return MessageFormat.format(format, new Object[] { arg1, arg2 });
}
-
+
/**
* strips out invalid characters to conform to QName specs.
* If the resulting name is null, returns "bpel" as a valid QName
* to guarantee that something valid is returned.
- *
+ *
* TODO: This has to be a valid NCName ...
- *
+ *
* @param str
- *
- * @return
+ *
+ * @return
*/
-
+
public static String generateValidName(String str) {
-
+
StringBuilder result = new StringBuilder(""); //$NON-NLS-1$
if (str != null) {
- for(char ch : str.trim().toCharArray()) {
+ for(char ch : str.trim().toCharArray()) {
int destLength = result.length();
if (((destLength == 0) && (Character.isLetter(ch) || ch == '_'))
|| ((destLength > 0) && Character.isJavaIdentifierPart(ch))) {
@@ -568,17 +565,17 @@
}
}
}
-
+
if (result.length() == 0)
result.append(IBPELUIConstants.EXTENSION_BPEL);
-
+
return result.toString();
}
/**
* Helper that traverses the IContainer hierarchy of the given modelObject in depth
* first fashion and applies the given visitor to each node.
- *
+ *
* DO NOT USE THIS for anything that must see "all" model objects (including implicit
* sequences, for example). Use TreeIterator modelObject.eAllContents() for that.
*/
@@ -600,38 +597,39 @@
}
}
}
-
+
private static class NameUnusedVisitor implements IModelVisitor {
private boolean unused = true;
- private String candidateName;
- private Collection<EObject> ignoreObjects;
-
+ private final String candidateName;
+ private final Collection<EObject> ignoreObjects;
+
NameUnusedVisitor(String candidateName, Collection<EObject> ignoreObjects) {
this.candidateName = candidateName;
if (ignoreObjects == null) ignoreObjects = Collections.emptySet();
this.ignoreObjects = ignoreObjects;
}
-
+
+ @Override
public boolean visit(Object child) {
- if (!ignoreObjects.contains(child)) {
+ if (!this.ignoreObjects.contains(child)) {
INamedElement namedElement = BPELUtil.adapt(child, INamedElement.class);
if (namedElement != null) {
String name = namedElement.getName(child);
- if ((name != null) && (name.compareToIgnoreCase(candidateName) == 0))
- unused = false;
+ if ((name != null) && (name.compareToIgnoreCase(this.candidateName) == 0))
+ this.unused = false;
}
}
return true;//unused;
}
-
- public boolean isUnused() {
- return unused;
+
+ public boolean isUnused() {
+ return this.unused;
}
}
-
- /**
+
+ /**
* checks if a name is available for use within the given process (i.e. if this name
- * were added within the modelRoot, would it be unique).
+ * were added within the modelRoot, would it be unique).
*/
public static boolean isNameUnused(EObject modelRoot, String candidateName, Collection ignoreObjects) {
NameUnusedVisitor visitor = new NameUnusedVisitor(candidateName, ignoreObjects);
@@ -644,30 +642,30 @@
/**
* return a mangled name (based on the given hint) which is unique in the given process.
- */
+ */
public static String getUniqueModelName(EObject context, String hint, Collection ignoreObjects) {
return getUniqueModelName2(context, hint, ignoreObjects);
}
/**
* return a mangled name (based on the given hint) which is unique in the given WSDL definition.
- */
+ */
public static String getUniqueModelName (Definition definition, String hint, Collection ignoreObjects) {
return getUniqueModelName2(definition, hint, ignoreObjects);
}
-
+
protected static String getUniqueModelName2 (EObject modelRoot, String hint, Collection ignoreObjects) {
-
+
// first try it exactly as hinted.
String result = BPELUtil.generateValidName((hint==null)?"":hint.trim()); //$NON-NLS-1$
if (isNameUnused(modelRoot, result, ignoreObjects)) return result;
-
+
// go back to the first non-digit
int digitPos = result.length()-1;
while (digitPos >= 0 && Character.isDigit(result.charAt(digitPos))) digitPos--;
digitPos++; // move back to the digit
String nameWithoutNum = result.substring(0, digitPos);
-
+
// try increasing numbers until one is accepted.
for (int num = 1; ; num++) {
result = nameWithoutNum+String.valueOf(num);
@@ -676,16 +674,16 @@
}
public static String generateUniqueModelName (EObject context, String hint, EObject model) {
-
+
if (hint == null || "".equals(hint)) { //$NON-NLS-1$
ILabeledElement element = BPELUtil.adapt(model, ILabeledElement.class);
hint = (element != null) ? element.getTypeLabel(model) : ""; //$NON-NLS-1$
}
return BPELUtil.getUniqueModelName(context, hint, Collections.singletonList(model));
}
-
+
public static String getFilenameFromUri(String uri) {
- if (uri == null) return Messages.BPELUtil__unknown_URI__54;
+ if (uri == null) return Messages.BPELUtil__unknown_URI__54;
// Hack. Why aren't we just using URI objects?
int idx = Math.max(uri.lastIndexOf("/"), uri.lastIndexOf("\\")); //$NON-NLS-1$ //$NON-NLS-2$
return (idx >= 0)? uri.substring(idx+1) : uri;
@@ -693,7 +691,7 @@
/**
* Converts the first letter of the target String to upper case.
- * @param target
+ * @param target
* @return the name with the first letter uppercased.
*/
public static String upperCaseFirstLetter (String target) {
@@ -755,9 +753,9 @@
ModelHelper.createExtensionIfNecessary(extensionMap, impSeq);
Collection ignoreObjects = Collections.singletonList(impSeq);
if (ModelHelper.isSpecCompliant(process)) {
- impSeq.setName(getUniqueModelName(process, Messages.BPELUtil_Sequence_1, ignoreObjects));
+ impSeq.setName(getUniqueModelName(process, Messages.BPELUtil_Sequence_1, ignoreObjects));
} else {
- impSeq.setName(getUniqueModelName(process, Messages.BPELUtil_HiddenSequence_2, ignoreObjects));
+ impSeq.setName(getUniqueModelName(process, Messages.BPELUtil_HiddenSequence_2, ignoreObjects));
((ActivityExtension)ModelHelper.getExtension(impSeq)).setImplicit(true);
}
// TODO: also give sequence a unique ID marked as implicit!
@@ -768,38 +766,43 @@
final TreeIterator<EObject> allContents = node.eAllContents();
return new TreeIterator() {
boolean didNode = false;
+ @Override
public void prune() {
// TODO: This won't work when calling on the first item.
- if (!didNode) throw new IllegalStateException();
+ if (!this.didNode) throw new IllegalStateException();
allContents.prune();
}
+ @Override
public boolean hasNext() {
- if (didNode) return allContents.hasNext();
+ if (this.didNode) return allContents.hasNext();
return node != null;
}
+ @Override
public Object next() {
- if (didNode) return allContents.next();
- didNode = true; return node;
+ if (this.didNode) return allContents.next();
+ this.didNode = true; return node;
}
+ @Override
public void remove() {
// This won't work when calling on the first item.
- if (!didNode) throw new IllegalStateException();
+ if (!this.didNode) throw new IllegalStateException();
allContents.remove();
}
};
}
-
+
private static class RefreshActionVisitor implements IModelVisitor {
- private GraphicalViewer viewer;
+ private final GraphicalViewer viewer;
public RefreshActionVisitor(GraphicalViewer viewer) {
- this.viewer = viewer;
+ this.viewer = viewer;
}
+ @Override
public boolean visit(Object child) {
- EditPart ep = (EditPart) viewer.getEditPartRegistry().get(child);
+ EditPart ep = (EditPart) this.viewer.getEditPartRegistry().get(child);
if (ep != null && ep instanceof BPELEditPart) {
IFigure fig = ((BPELEditPart)ep).getContentPane();
if (fig != null) {
@@ -813,8 +816,8 @@
return true;//unused;
}
}
-
- /**
+
+ /**
* refreshes all the editparts of the process. Useful for changing layouts etc
*/
public static void regenerateVisuals(Process process, GraphicalViewer viewer) {
@@ -822,8 +825,8 @@
visitModelDepthFirst(process, visitor);
return;
}
-
-
+
+
/**
* The policy for whether a BPELEditPart's edges should be hilighted or not. This one defers
* to the active tool if it is an IHilightControllingTool and says no otherwise.
@@ -835,8 +838,8 @@
}
return false;
}
-
-
+
+
/**
* Used to determine the type of pattern to paint a container in the Process.
* Because the nesting of containers is confusing, we want to draw nice gradients
@@ -845,7 +848,7 @@
* 0 and 2 mean gradient fills.
*/
public static int getRepaintFillType(IFigure fig) {
- int depth = 0;
+ int depth = 0;
IFigure parent = fig.getParent();
while (parent != null) {
if (parent != null && parent.getBorder() != null && parent.getBorder() instanceof GradientBorder) {
@@ -862,11 +865,11 @@
for (int i = 0; i<resultSize; i++) {
for (int j = i+1; j<resultSize; j++) {
- Flow flow1 = (Flow)(result.get(i)).getModel();
+ Flow flow1 = (Flow)(result.get(i)).getModel();
Flow flow2 = (Flow)(result.get(j)).getModel();
Flow[] parents = FlowLinkUtil.getParentFlows(flow2);
- for (int k = 0; k<parents.length; k++) {
- if (parents[k] == flow1) {
+ for( Flow parent : parents ) {
+ if (parent == flow1) {
// flow2 must be layed out before flow1 so its size will be known!
FlowEditPart temp = result.get(i);
result.set(i, result.get(j));
@@ -885,7 +888,7 @@
String s = ((ILabelProvider)viewer.getLabelProvider()).getText(selectedObject);
viewer.getCombo().setText(s);
}
-
+
/**
* Helper method to calculate the width of a button.
* This is necessary for internationalization and accessibility.
@@ -895,19 +898,19 @@
public static int calculateButtonWidth(Widget widget, int defaultSize){
GC gc;
int width = 0;
-
+
if (widget instanceof Button) {
Button w = (Button)widget;
gc = new GC(w);
- gc.setFont(w.getFont());
- width = gc.textExtent(w.getText()).x + 17;
+ gc.setFont(w.getFont());
+ width = gc.textExtent(w.getText()).x + 17;
gc.dispose();
- return Math.max(width, defaultSize);
- }
+ return Math.max(width, defaultSize);
+ }
return defaultSize;
}
-
-
+
+
public static String getMaxLengthString(String strings[]) {
int max = -1;
int index = -1;
@@ -917,48 +920,48 @@
index = i;
}
}
-
+
if (index >= 0) return strings[index];
return ""; //$NON-NLS-1$
}
-
+
/**
* Helper method to calculate the width of a CLabel.
* This is necessary for internationalization and accessibility.
- *
+ *
* Returned value is the calculated width or defaultSize, whichever
* is larger.
*/
public static int calculateLabelWidth(Widget widget, int defaultSize){
GC gc;
int width = 0;
-
+
if (widget instanceof CLabel) {
CLabel w = (CLabel)widget;
gc = new GC(w);
- gc.setFont(w.getFont());
- width = gc.textExtent(w.getText()).x + 17;
+ gc.setFont(w.getFont());
+ width = gc.textExtent(w.getText()).x + 17;
gc.dispose();
-
- return Math.max(width, defaultSize);
+
+ return Math.max(width, defaultSize);
}
if (widget instanceof DecoratedLabel) {
DecoratedLabel w = (DecoratedLabel)widget;
gc = new GC(w);
- gc.setFont(w.getFont());
- width = gc.textExtent(w.getText()).x + 17;
- gc.dispose();
- return Math.max(width, defaultSize);
- }
+ gc.setFont(w.getFont());
+ width = gc.textExtent(w.getText()).x + 17;
+ gc.dispose();
+ return Math.max(width, defaultSize);
+ }
-
+
if (widget instanceof Label) {
Label w = (Label)widget;
gc = new GC(w);
- gc.setFont(w.getFont());
- width = gc.textExtent(w.getText()).x + 5;
+ gc.setFont(w.getFont());
+ width = gc.textExtent(w.getText()).x + 5;
gc.dispose();
- return Math.max(width, defaultSize);
+ return Math.max(width, defaultSize);
}
return defaultSize;
}
@@ -969,7 +972,7 @@
}
return getFileFromPlatformURI(uri);
}
-
+
public static IFile getFileFromDeviceURI(URI uri) {
String device = uri.device();
Iterator pathIt = uri.segmentsList().iterator();
@@ -979,7 +982,7 @@
}
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(device, path.toString()));
}
-
+
public static IFile getFileFromPlatformURI(URI uri) {
String [] segs = uri.segments();
IPath path = null;
@@ -994,7 +997,7 @@
return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
- /**
+ /**
* Function to return a platform URI from a standard hierarchital URI.
* Normally we can use URI.createPlatformURI, but that function always assumes
* that it is non-platform
@@ -1006,7 +1009,7 @@
}
/* external fault handler helpers */
-
+
public static boolean getShowFaultHandler(EditPart part) {
if (part instanceof ScopeEditPart)
return ((ScopeEditPart)part).getShowFaultHandler();
@@ -1016,7 +1019,7 @@
return ((StartNodeEditPart)part).getShowFaultHandler();
return false;
}
-
+
public static void setShowFaultHandler(EditPart part, boolean show) {
if (part instanceof ScopeEditPart)
((ScopeEditPart)part).setShowFaultHandler(show);
@@ -1025,9 +1028,9 @@
else if (part instanceof StartNodeEditPart)
((StartNodeEditPart)part).setShowFaultHandler(show);
}
-
+
/* external compensation handler helpers */
-
+
public static boolean getShowCompensationHandler(EditPart part) {
if (part instanceof ScopeEditPart)
return ((ScopeEditPart)part).getShowCompensationHandler();
@@ -1055,7 +1058,7 @@
}
/* external event handler helpers */
-
+
public static boolean getShowEventHandler(EditPart part) {
if (part instanceof ScopeEditPart)
return ((ScopeEditPart)part).getShowEventHandler();
@@ -1078,7 +1081,7 @@
IPath path = bpelFile.getFullPath().removeFileExtension().addFileExtension(IBPELUIConstants.EXTENSION_MODEL_EXTENSIONS);
return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
-
+
/**
* Returns the artifacts WSDL of the given BPEL file.
*/
@@ -1089,7 +1092,7 @@
wsdlPath = wsdlPath.addFileExtension(IBPELUIConstants.EXTENSION_WSDL);
return ResourcesPlugin.getWorkspace().getRoot().getFile(wsdlPath);
}
-
+
public static Image getImage(IMarker marker) {
Image img = ModelMarkerUtil.getImage(marker);
ImageData background = null;
@@ -1132,7 +1135,7 @@
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
return desc.getImageData();
}
-
+
/**
* Returns the EditPart which is responsible for the given IFigure.
*/
@@ -1161,7 +1164,7 @@
public static AccessibleEditPart getAccessibleEditPart(GraphicalEditPart part) {
final GraphicalEditPart thisPart = part;
-
+
return new AccessibleEditPart() {
@Override
public void getName(AccessibleEvent e) {
@@ -1221,7 +1224,7 @@
}
e.children = childList.toArray();
}
-
+
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle bounds = thisPart.getFigure().getBounds().getCopy();
@@ -1233,7 +1236,7 @@
e.width = bounds.width;
e.height = bounds.height;
}
-
+
/**
* @see AccessibleEditPart#getState(AccessibleControlEvent)
*/
@@ -1247,10 +1250,10 @@
}
};
}
-
-
+
+
/** creates a table cursor that can be used to navigate tables for keyboard accessibility **/
-
+
public static TableCursor createTableCursor(final Table table, final TableViewer tableViewer) {
// create a TableCursor to navigate around the table
final TableCursor cursor = new TableCursor(table, SWT.NONE);
@@ -1279,15 +1282,17 @@
cursor.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
- if ((e.keyCode == SWT.CTRL) || (e.keyCode == SWT.SHIFT) ||
+ if ((e.keyCode == SWT.CTRL) || (e.keyCode == SWT.SHIFT) ||
(e.stateMask & SWT.CONTROL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
cursor.setVisible(false);
}
}
});
-
+
cursor.addMouseListener(new MouseListener() {
+ @Override
public void mouseDoubleClick(MouseEvent e) { }
+ @Override
public void mouseDown(MouseEvent e) {
TableItem row = cursor.getRow();
if (row != null) {
@@ -1297,10 +1302,11 @@
tableViewer.editElement(obj, column);
}
}
+ @Override
public void mouseUp(MouseEvent e) {
}
});
-
+
// Show the TableCursor when the user releases the "SHIFT" or "CTRL" key.
// This signals the end of the multiple selection task.
table.addKeyListener(new KeyAdapter() {
@@ -1321,25 +1327,26 @@
TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
table.showItem(row);
cursor.setSelection(row, 0);
- cursor.setVisible(true);
+ cursor.setVisible(true);
cursor.setFocus();
}
});
return cursor;
}
-
+
public static ResourceSet createResourceSetImpl() {
// TODO: Extensibility
return new ResourceSetImpl();
}
-
+
static final NCNameWordDetector NCNAME_DETECTOR = new NCNameWordDetector ();
-
+
/**
* Returns a validator that checks that the new value is a valid NCName.
*/
public static IInputValidator getNCNameValidator() {
return new IInputValidator() {
+ @Override
public String isValid (String newText) {
if ( NCNAME_DETECTOR.isValid( newText ) == false ) {
return Messages.BPELUtil_NCName;
@@ -1349,7 +1356,7 @@
}
};
}
-
+
public static void deleteNonContainmentRefs(EObject modelObject, Collection referents) {
if (modelObject == null) return;
for (EReference feature : modelObject.eClass().getEAllReferences()) {
@@ -1380,7 +1387,7 @@
//@return: returns arraylist with all activities the compensate
// can validly point to
public static ArrayList getCompensableActivities(Object context){
- final ArrayList returnObjects = new ArrayList();
+ final ArrayList returnObjects = new ArrayList();
if (context instanceof CompensateScope) {
CompensateScope compensateScope = (CompensateScope) context;
EObject enclosingContainer = compensateScope;
@@ -1392,10 +1399,11 @@
enclosingContainer = enclosingContainer.eContainer();
}
}
-
+
// Put all scopes and invokes within parent scope in arraylist
visitModelDepthFirst(enclosingContainer,
new IModelVisitor() {
+ @Override
public boolean visit(Object modelObject) {
if (modelObject instanceof Scope) {
returnObjects.add(modelObject);
@@ -1407,12 +1415,12 @@
});
// https://issues.jboss.org/browse/JBIDE-8044
if (!returnObjects.isEmpty())
- returnObjects.remove(0); //remove the scope containing the compensate
+ returnObjects.remove(0); //remove the scope containing the compensate
return returnObjects;
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
}
-
+
public static Object resolveXSDObject(Object xsdObject) {
if (xsdObject instanceof XSDElementDeclaration) {
XSDElementDeclaration resolvedElement = ((XSDElementDeclaration)xsdObject).getResolvedElementDeclaration();
@@ -1423,7 +1431,7 @@
}
return xsdObject;
}
-
+
public static String debugObject(Object object) {
if (object == null) return "null"; //$NON-NLS-1$
if (object instanceof String) { return "\""+(String)object+"\""; } //$NON-NLS-1$ //$NON-NLS-2$
@@ -1464,7 +1472,7 @@
}
return b.toString();
}
-
+
public static String debug(Notification n) {
StringBuffer b = new StringBuffer(shortClassName(n.getClass()));
b.append("("); //$NON-NLS-1$
@@ -1490,7 +1498,7 @@
b.append(String.valueOf(n.getPosition()));
b.append("]"); //$NON-NLS-1$
} else {
- if (feature != null && feature.isMany()) b.append("{***}"); //$NON-NLS-1$
+ if (feature != null && feature.isMany()) b.append("{***}"); //$NON-NLS-1$
}
b.append(": "); //$NON-NLS-1$
b.append(debugObject(n.getOldValue()));
@@ -1498,7 +1506,7 @@
b.append(debugObject(n.getNewValue()));
b.append(")"); //$NON-NLS-1$
return b.toString();
-
+
}
protected static String shortClassName(Class clazz) {
StringBuffer b = new StringBuffer(clazz.getName());
@@ -1518,6 +1526,7 @@
layout.marginWidth = margin;
result.setLayout(layout);
result.addPaintListener(new PaintListener() {
+ @Override
public void paintControl(PaintEvent e) {
org.eclipse.swt.graphics.Rectangle bounds = result.getBounds();
bounds.x = margin-1;
@@ -1544,8 +1553,8 @@
}
}
}
-
-
+
+
static void addVisibleVariables (Map<String,Variable> targetMap, EObject target, Variable refVariable ) {
if (target == null) {
return;
@@ -1553,14 +1562,14 @@
if (target instanceof Resource) {
return;
}
-
+
if (target instanceof Process) {
addVariablesToMap(targetMap, ((Process)target).getVariables(), refVariable );
return ;
- }
+ }
// recursively add less local variables first
addVisibleVariables(targetMap, target.eContainer(), refVariable );
-
+
if (target instanceof Scope) {
addVariablesToMap(targetMap, ((Scope)target).getVariables(), refVariable );
}
@@ -1576,7 +1585,7 @@
targetMap.put(v.getName(), v);
}
}
-
+
if (target instanceof ForEach) {
Variable v = ((ForEach)target).getCounterName();
if (v != null && v.getName() != null) {
@@ -1604,11 +1613,10 @@
}
}
}
-
+
private static void addCorrelationSetsToMap(Map<String, CorrelationSet> targetMap, CorrelationSets csets) {
if (csets == null) return;
- for (Iterator<CorrelationSet> it = csets.getChildren().iterator(); it.hasNext(); ) {
- CorrelationSet c = it.next();
+ for( CorrelationSet c : csets.getChildren() ) {
if (c.getName() != null) targetMap.put(c.getName(), c);
}
}
@@ -1625,41 +1633,42 @@
}
}
}
-
+
/**
* Look up the variables visible to a certain context activity (or the whole process).
* Variables in BPEL follow lexical scoping rules (resolved OASIS issue 101).
- *
+ *
* The returned variables are in no particular order.
*/
public static Variable[] getVisibleVariables (EObject target) {
-
+
Map<String,Variable> name2Variable = new HashMap<String,Variable>();
-
+
addVisibleVariables(name2Variable, target, target instanceof Variable ? (Variable) target: null );
-
+
if (name2Variable.isEmpty()) {
return EMPTY_VARIABLE_ARRAY;
}
-
- Collection<Variable> variables = name2Variable.values();
- if (variables.size() == 1) {
+
+ Collection<Variable> variables = name2Variable.values();
+ if (variables.size() == 1) {
return variables.toArray(EMPTY_VARIABLE_ARRAY);
- }
+ }
ArrayList<Variable> list = new ArrayList<Variable>( variables );
Collections.sort(list, new Comparator<Variable>() {
+ @Override
public int compare(Variable o1, Variable o2) {
return o1.getName().compareTo(o2.getName());
- }
- });
- return list.toArray(EMPTY_VARIABLE_ARRAY);
+ }
+ });
+ return list.toArray(EMPTY_VARIABLE_ARRAY);
}
-
+
/**
* Look up the PartnerLinks visible to a certain context activity (or the whole process).
* When local PartnerLinks are added to the spec, they will follow lexical scoping rules
* just like variables.
- *
+ *
* The returned PartnerLinks are in no particular order.
*/
public static PartnerLink[] getVisiblePartnerLinks(EObject target) {
@@ -1670,12 +1679,12 @@
name2PartnerLink.values().toArray(result);
return result;
}
-
+
/**
* Look up the PartnerLinks visible to a certain context activity (or the whole process).
* When local PartnerLinks are added to the spec, they will follow lexical scoping rules
* just like variables.
- *
+ *
* The returned PartnerLinks are in no particular order.
*/
public static CorrelationSet[] getVisibleCorrelationSets(EObject target) {
@@ -1686,11 +1695,11 @@
name2CorrelationSet.values().toArray(result);
return result;
}
-
+
/**
* If the given message is used by an operation in the same definition,
- * returns the Operation that uses the given message.
- * Otherwise, returns null.
+ * returns the Operation that uses the given message.
+ * Otherwise, returns null.
*/
public static Operation getOperationFromMessage(Message message) {
if (message == null) return null;
@@ -1730,7 +1739,7 @@
}
return null;
}
-
+
public static void openEditor(EObject modelObject, BPELEditor editor) {
try {
// https://issues.jboss.org/browse/JBIDE-8044
@@ -1741,7 +1750,7 @@
Messages.BPELUtil_NoEditorForNullObject);
return;
}
-
+
EObject resolvedObject = null;
if (modelObject.eResource()==null) {
// https://jira.jboss.org/browse/JBIDE-7351
@@ -1752,7 +1761,7 @@
}
else
resolvedObject = modelObject;
-
+
if (resolvedObject==null) {
// https://issues.jboss.org/browse/JBIDE-8601
MessageDialog.openError(editor.getEditorSite().getShell(),
@@ -1762,7 +1771,7 @@
return;
}
IFile file = BPELUtil.getFileFromURI(resolvedObject.eResource().getURI());
- IDE.openEditor(editor.getSite().getWorkbenchWindow().getActivePage(), file);
+ IDE.openEditor(editor.getSite().getWorkbenchWindow().getActivePage(), file);
} catch (PartInitException ex) {
BPELUIPlugin.log(ex, IStatus.WARNING);
}
@@ -1775,33 +1784,33 @@
return getFileFromURI(process.eResource().getURI());
}
-
-
+
+
public static String lookupOrCreateNamespacePrefix ( EObject context, String namespace, String prefix, Shell shell ) {
-
+
String nsPrefix = BPELUtils.getNamespacePrefix(context, namespace);
if (nsPrefix != null && nsPrefix.length() > 0) {
return nsPrefix;
}
-
+
NamespaceMappingDialog dialog = new NamespaceMappingDialog (shell, context);
- dialog.setNamespace(namespace);
+ dialog.setNamespace(namespace);
if (prefix != null) {
dialog.setPrefix(prefix);
}
-
+
if (dialog.open() == Window.CANCEL) {
return nsPrefix;
}
-
+
nsPrefix = dialog.getPrefix();
BPELUtils.setNamespacePrefix(context, namespace, nsPrefix);
- return nsPrefix;
+ return nsPrefix;
}
-
-
+
+
/**
- * Traverses the root object and returns all objects under it that are of the same
+ * Traverses the root object and returns all objects under it that are of the same
* class or subclasses of "target".
*/
public static List<EObject> getAllEObjectsOfType(EObject root, EClass eClass) {
@@ -1815,8 +1824,8 @@
}
return allElems;
}
-
-
+
+
public static boolean isBPELProject(IProject project){
if (project == null) {
return false;
@@ -1828,22 +1837,22 @@
} catch (CoreException e) {
return false;
}
- if (fproj.hasProjectFacet(getBPELFacetVersion())) {
+ if (fproj.hasProjectFacet(getBPELFacetVersion())) {
return true;
}
}
return false;
-
+
}
-
+
public static IProjectFacetVersion getBPELFacetVersion() {
IProjectFacet bpelFacet = ProjectFacetsManager.getProjectFacet(IBPELModuleFacetConstants.BPEL20_PROJECT_FACET);
IProjectFacetVersion bpelFacetVersion = bpelFacet.getVersion(IBPELModuleFacetConstants.BPEL20_MODULE_VERSION);
return bpelFacetVersion;
}
-
-
- public static org.eclipse.core.resources.IContainer getBPELContentFolder(IProject project) {
+
+
+ public static org.eclipse.core.resources.IContainer getBPELContentFolder(IProject project) {
org.eclipse.core.resources.IContainer bpelContent = null;
if (BPELUtil.isBPELProject(project)) {
IPath rootPath = getWebContentRootPath(project);
@@ -1852,7 +1861,7 @@
}
}
return bpelContent;
- }
+ }
public static IPath getWebContentRootPath(IProject project) {
IPath path = null;
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/Gate.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/Gate.java
deleted file mode 100644
index ce26d37..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/Gate.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util;
-
-import java.lang.reflect.Method;
-
-
-
-/**
- * This is a good example of a dynamic proxy in Java.
- *
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- * @date Nov 3, 2006
- *
- */
-public class Gate implements IGate, java.lang.reflect.InvocationHandler {
-
- private Object fObj;
-
- /**
- * Should access be synchronized around the proxy object.
- */
- boolean bSync = false;
-
- /**
- * Is the Gate armed ? If so, no traffic is allowed.
- */
- boolean fArmed = false;
-
- /**
- * Create a new instance of an IGate that also responds to the
- * protocol of the object passed.
- *
- * @param obj whose method access will be gated.
- * @return a new instance of the dynamic proxy
- */
-
- public static final Object newInstance ( Object obj ) {
- return newInstance ( obj, false );
- }
-
- /**
- * Create a new instance of an IGate that also responds to the
- * protocol of the object passed.
- *
- * @param obj whose method access will be gated.
- * @param sync if set to true, method invocations will be synchronized.
- * @return a new instance of the dynamic proxy
- */
-
- public static final Object newInstance ( Object obj , boolean sync) {
-
- Class[] i1 = obj.getClass().getInterfaces();
- Class[] i2 = new Class[] { IGate.class };
- Class[] iA = new Class[ i1.length + i2.length ];
- System.arraycopy(i1, 0, iA, 0, i1.length);
- System.arraycopy(i2, 0, iA, i1.length, i2.length);
-
- return java.lang.reflect.Proxy.newProxyInstance(
- obj.getClass().getClassLoader(),
- iA,
- new Gate(obj, sync) );
- }
-
- /**
- * Private constructor, so the only way to get instances is via
- * newInstance().
- *
- * @param obj
- * @param sync
- */
-
- Gate (Object obj, boolean sync) {
- fObj = obj;
- bSync = sync;
- }
-
-
- /**
- * The invocation handler of the dynamic proxy.
- *
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- */
-
- public Object invoke (Object proxy, Method m, Object[] args) throws Throwable
- {
- try {
- // if the method invocation succeeds on us, then the method was
- // on one of the interfaces that we implement. Otherwise, it is
- return m.invoke(this, args);
- } catch (Throwable t) {
- // not for us; fall through, continue proxy execution.
- }
-
- if (fArmed) {
- return null;
- }
-
- if (bSync) {
- synchronized (fObj) {
- return m.invoke(fObj,args);
- }
- }
-
- return m.invoke(fObj, args);
- }
-
-
- /** (non-Javadoc)
- * @see org.eclipse.bpel.ui.util.IGate#off()
- */
-
- public void off() {
- fArmed = false;
- }
-
- /** (non-Javadoc)
- * @see org.eclipse.bpel.ui.util.IGate#on()
- */
-
- public void on() {
- fArmed = true;
- }
-
-}
-
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/IGate.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/IGate.java
deleted file mode 100644
index 26fbee7..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/IGate.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util;
-
-/**
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- * @date Nov 6, 2006
- *
- */
-
-public interface IGate {
-
- /**
- * Turns the gate on.
- *
- */
- public void on () ;
-
- /**
- * Turns the gate off.
- *
- */
- public void off ();
-
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/ListMap.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/ListMap.java
index 04a7ddf..92fdda1 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/ListMap.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/ListMap.java
@@ -16,55 +16,42 @@
/**
* A little bit of LISP.
- *
+ *
* @author Michal Chmielewski (michal.chmielewski@oracle.com)
* @date Jul 19, 2006
*
*/
public class ListMap {
-
+
/**
*
- */
+ */
static final public Object IGNORE = new Object();
-
+
/**
* Interface visitor. The object returned from visit need not be the same
* object as passed to visit. If IGNORE is returned (above), then
- * the resulting value will not be added to the resulting list.
+ * the resulting value will not be added to the resulting list.
*/
-
+
static public interface Visitor {
/**
- * @param obj the object to visit.
+ * @param obj the object to visit.
* @return some other object, the object itself, or IGNORE
*/
- public Object visit ( Object obj );
- }
-
-
- /**
- * Map the visitor "visitor" on the list "list" and return the result as a list.
- *
- * @param list the list of objects
- * @param visitor the visitor
- * @return the resulting (new) list
- */
-
- static public Object Map (List<?> list, Visitor visitor) {
- return Map(list,visitor,null);
+ public Object visit ( Object obj );
}
-
+
/**
* Map the visitor "visitor" on the list "list" and return the result as a list. If the list argument
* is passed (ret) the result is returned as an array of the results, otherwise it is a list.
- *
+ *
* @param list the list of objects
* @param visitor the visitor
* @param ret the array class to convert the results into.
- * @return the resulting (new) list
+ * @return the resulting (new) list
*/
static public Object Map ( List<?> list, Visitor visitor , Object[] ret ) {
List<Object> output = new ArrayList<Object>(list.size());
@@ -73,38 +60,25 @@
if (result != IGNORE) {
output.add( result );
}
- }
+ }
if (ret == null) {
return output;
}
-
- return output.toArray(ret);
+
+ return output.toArray(ret);
}
-
-
- /**
- * Map the visitor "visitor" on the list "list" and return the result as a list.
- *
- * @param list the list of objects
- * @param visitor the visitor
- * @return the resulting (new) list
- *
- */
- static public Object Map ( Object[] list, Visitor visitor ) {
- return Map(list,visitor,null);
- }
-
-
+
+
/**
* Map the visitor "visitor" on the list "list" and return the result as a list. If the list argument
* is passed (ret) the result is returned as an array of the results, otherwise it is a list.
- *
+ *
* @param list the list of objects
* @param visitor the visitor
* @param ret the array class to convert the results into.
- * @return the resulting (new) list
+ * @return the resulting (new) list
*/
-
+
static public Object Map (Object[] list, Visitor visitor, Object[] ret) {
List<Object> l2 = new ArrayList<Object>(list.length);
for( Object n : list) {
@@ -120,36 +94,36 @@
* @return the object found or null
*/
static public final Object Find (List<?> list, Visitor visitor) {
- for(Object n : list) {
+ for(Object n : list) {
Object result = visitor.visit ( n );
if (result != IGNORE) {
return result;
}
}
- return null;
+ return null;
}
-
-
-
-
-
+
+
+
+
+
/**
* Find the element using the comparator in the list.
- *
+ *
* @param list
* @param key
* @param comparator
* @return the element found or null
*/
-
+
public static Object findElement (List<?> list, Object key, Comparator<Object> comparator) {
for (Object n : list) {
if (comparator.compare(n, key) == 0) {
return n;
- }
+ }
}
- return null;
+ return null;
}
-
-
+
+
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/NamespaceUtils.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/NamespaceUtils.java
index 4bd0e05..0f4f216 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/NamespaceUtils.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/NamespaceUtils.java
@@ -16,15 +16,15 @@
import java.util.Iterator;
/**
- * Utility class for calculating default namespaces based on namespace templates from the preference store.
+ * Utility class for calculating default namespaces based on namespace templates from the preference store.
*/
public class NamespaceUtils
{
- protected static char NS_SEPARATOR = '/';
- protected static char PACKAGE_SEPARATOR = '.';
+ protected static char NS_SEPARATOR = '/';
+ protected static char PACKAGE_SEPARATOR = '.';
protected static String HEX_PREFIX = "%"; //$NON-NLS-1$
protected static String CHARSET_UTF8 = "UTF-8"; //$NON-NLS-1$
-
+
// unsafe characters
public static final String SPACE = " "; //$NON-NLS-1$
public static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
@@ -41,7 +41,7 @@
public static final String LEFT_SQUARE = "["; //$NON-NLS-1$
public static final String RIGHT_SQUARE = "]"; //$NON-NLS-1$
public static final String GRAVE = "`"; //$NON-NLS-1$
-
+
// escaped characters
public static final String ESCAPED_SPACE = "%20"; //$NON-NLS-1$
public static final String ESCAPED_DOUBLE_QUOTE = "%22"; //$NON-NLS-1$
@@ -58,7 +58,7 @@
public static final String ESCAPED_LEFT_SQUARE = "%5B"; //$NON-NLS-1$
public static final String ESCAPED_RIGHT_SQUARE = "%5D"; //$NON-NLS-1$
public static final String ESCAPED_GRAVE = "%60"; //$NON-NLS-1$
-
+
protected static HashMap fCharToEscaped = new HashMap(15);
static
{
@@ -78,11 +78,11 @@
fCharToEscaped.put(RIGHT_SQUARE, ESCAPED_RIGHT_SQUARE);
fCharToEscaped.put(GRAVE, ESCAPED_GRAVE);
}
-
+
/**
* Converts a UTF-8 escaped string back into a unicode string. This method undoes the
* operation performed in convertNamespaceToUri.
- *
+ *
* @param uri
* @return - a unicode representation of the given UTF-8 escaped string.
* @see convertNamespaceToUri
@@ -91,15 +91,15 @@
{
if (uri==null || uri.length()<1)
return null;
-
+
String namespace = uri;
-
+
int prevIndex = 0; // index of the previously found %, plus 1
int contiguousIndex = 0; // index of next contiguous hex number
Byte hexByte = null;
ArrayList contiguousBytes = null;
String hexChunk = null;
-
+
for (int i=uri.indexOf(HEX_PREFIX); i>=0; i=uri.indexOf(HEX_PREFIX, prevIndex))
{
// get hex byte
@@ -107,42 +107,42 @@
contiguousBytes = new ArrayList();
contiguousIndex = i;
hexChunk = "";
-
+
prevIndex = contiguousIndex+1; // +1 for %
-
+
// get contiguous bytes
while (hexByte!=null)
{
contiguousBytes.add(hexByte);
-
+
hexChunk += uri.substring(contiguousIndex, contiguousIndex+3);
prevIndex = contiguousIndex+1; // +1 for %
-
+
hexByte = getHexByte(uri, contiguousIndex+3); // 2 for current hex num, 1 for %
-
+
contiguousIndex += 3;
}
prevIndex = prevIndex>=uri.length()?uri.length()-1:prevIndex;
-
+
if (contiguousBytes.size()<=0)
continue;
-
+
// convert hex string to bytes
byte[] cbytes = new byte[contiguousBytes.size()];
for (int j=0; j<cbytes.length; j++)
cbytes[j] = ((Byte)contiguousBytes.get(j)).byteValue();
-
+
try
{
// convert bytes to unicode
String unicode = new String(cbytes, CHARSET_UTF8);
-
+
// now find the hex string in the namespace and replace it with the proper unicode
int beginIndex = namespace.indexOf(hexChunk);
int endIndex = beginIndex+hexChunk.length();
int lastIndex = namespace.length();
endIndex = endIndex>lastIndex?lastIndex:endIndex;
-
+
namespace = namespace.substring(0, beginIndex) + unicode + namespace.substring(endIndex);
}
catch(UnsupportedEncodingException e)
@@ -151,14 +151,14 @@
// JM: Commented out:
//ModelUtilPlugin.logWarning(e, e.getMessage());
}
- }
-
+ }
+
return namespace;
}
-
+
/**
* Returns the Byte value of the hex string at position index in string uri.
- *
+ *
* @param uri
* @param index
* @return null if characters at position index aren't of the form %HH
@@ -167,25 +167,25 @@
{
if (uri==null || uri.length()<1)
return null;
-
+
if (index>=uri.length())
return null;
-
+
// first character must be %
if (!HEX_PREFIX.equals(String.valueOf(uri.charAt(index))))
return null;
-
+
// hex string is two digits
int lastIndex = uri.length();
int endIndex = index+3;
-
+
// ensure endIndex doesn't extend the length of the string
if (endIndex>lastIndex)
endIndex = lastIndex;
-
+
String hexString = uri.substring(index+1, endIndex);
byte hexByte = 0;
-
+
try
{
hexByte = Integer.valueOf(hexString, 16).byteValue();
@@ -195,7 +195,7 @@
// not a hex number, return
return null;
}
-
+
return Byte.valueOf( hexByte );
}
@@ -204,11 +204,11 @@
* XSD spec, any string typed with xsd:anyURI cannot contain any characters outside the US-ASCII character set.
* These characters must be escaped in the UTF-8 hex notation, %HH. This method also escapes "unwise" characters
* by calling escapeUnsafeCharacters first.
- *
+ *
* Note that models saving to an XMLResource don't need this method since the XMLResource saves/loads using a
* Xerces parser which automatically does this. Models using the SSE parser for saving/loading need this as the
* SSE parser doesn't do this automatically.
- *
+ *
* @param namespace
* @return - UTF-8 character escaped string of any characters outside the US-ASCII character set.
* @see convertUriToNamespace
@@ -218,7 +218,7 @@
{
return convertNamespaceToUri(namespace, true);
}
-
+
/**
* Convert a string intended to be a target namespace, i.e. any string typed with xsd:anyURI. According to the
* XSD spec, any string typed with xsd:anyURI cannot contain any characters outside the US-ASCII character set.
@@ -226,11 +226,11 @@
* (except for '%' if escapePercent is set to false) by calling escapeUnsafeCharacters first. Setting escapePercent
* to false means you can call this method on previously converted strings without the '%' from '%HH' being converted
* again.
- *
+ *
* Note that models saving to an XMLResource don't need this method since the XMLResource saves/loads using a
* Xerces parser which automatically does this. Models using the SSE parser for saving/loading need this as the
* SSE parser doesn't do this automatically.
- *
+ *
* @param namespace
* @param escapePercent - escapes '%' to it's hex value if true, ignores it otherwise.
* @return - UTF-8 character escaped string of any characters outside the US-ASCII character set.
@@ -241,36 +241,34 @@
{
if (namespace==null || namespace.length()<1)
return null;
-
+
StringBuffer buffer = new StringBuffer();
-
- // first escape "unsafe" characters
+
+ // first escape "unsafe" characters
namespace = escapeUnsafeCharacters(namespace, escapePercent);
-
+
char[] nsChars = namespace.toCharArray();
byte[] utf8 = null;
-
+
try
{
- for (int i=0; i<nsChars.length; i++)
- {
+ for( char nsChar : nsChars ) {
// Convert all characters outside the US-ASCII range (>127) to
// UTF-8 bytes as dictated by the anyURI definition in the
// XSD spec.
- if (nsChars[i]>127)
+ if (nsChar>127)
{
- utf8 = String.valueOf(nsChars[i]).getBytes(CHARSET_UTF8);
- for (int j=0; j<utf8.length; j++)
- {
+ utf8 = String.valueOf(nsChar).getBytes(CHARSET_UTF8);
+ for( byte element : utf8 ) {
buffer.append(HEX_PREFIX);
-
+
// 2-digit hex value
- buffer.append(Integer.toString(( utf8[j] & 0xff ), 16).toUpperCase());
+ buffer.append(Integer.toString(( element & 0xff ), 16).toUpperCase());
}
}
else
{
- buffer.append(nsChars[i]);
+ buffer.append(nsChar);
}
}
}
@@ -280,33 +278,17 @@
// JM commented out:
//ModelUtilPlugin.logWarning(e, e.getMessage());
}
-
+
return buffer.toString();
}
-
- /**
- * Escapes the "delim" and "unwise" characters as specified by rfc2396. Also escapes the tilde (~) as this
- * also seems to cause problems with the XSD validator. The characters are escaped using the UTF-8 hex
- * notation, %HH.
- *
- * To do undo this operation, call convertUriToNamespace
- *
- * @param anyURI
- * @return
- * @see this is equivalent to escapeUnsafeCharacters(anyURI, true)
- */
- public static String escapeUnsafeCharacters(String anyURI)
- {
- return escapeUnsafeCharacters(anyURI, true);
- }
/**
* Escapes the "delim" and "unwise" characters as specified by rfc2396. Also escapes the tilde (~) as this
- * also seems to cause problems with the XSD validator. The characters are escaped using the UTF-8 hex
+ * also seems to cause problems with the XSD validator. The characters are escaped using the UTF-8 hex
* notation, %HH.
- *
+ *
* To do undo this operation, call convertUriToNamespace
- *
+ *
* @param anyURI
* @param escapePercent - escapes '%' to it's hex value if true, ignores it otherwise.
* @return
@@ -319,50 +301,19 @@
// must escape % first since our escapes have % in them.
if (escapePercent)
anyURI = anyURI.replaceAll("\\"+PERCENT, (String)fCharToEscaped.get(PERCENT)); //$NON-NLS-1$
-
+
String key = null;
-
+
// escape all other characters except %
for (Iterator i = fCharToEscaped.keySet().iterator(); i.hasNext();)
{
key = (String)i.next();
if (key.equals(PERCENT))
continue;
-
+
anyURI = anyURI.replaceAll("\\"+key, (String)fCharToEscaped.get(key)); //$NON-NLS-1$
}
return anyURI;
}
-
- /**
- * Returns the "delim" and "unwise" characters as specified by rfc2396 if found. Also returns the tilde (~) as this
- * also seems to cause problems with the XSD validator. Returns null if no unsafe characters found.
- *
- * @param anyURI
- * @param spaceUnsafe - if true, treats a space as an "unwise" character.
- * @return null if no unsafe characters found,
- * the unsafe character string otherwise
- */
- public static String containsUnsafeCharacter(String anyURI, boolean spaceUnsafe)
- {
- if (anyURI==null)
- return null;
-
- String key = null;
-
- for (Iterator i = fCharToEscaped.keySet().iterator(); i.hasNext();)
- {
- key = (String)i.next();
-
- if (!spaceUnsafe && SPACE.equals(key))
- continue;
-
- if (anyURI.indexOf(key)>=0)
- return key;
- }
-
- // no unsafe characters
- return null;
- }
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/SharedImages.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/SharedImages.java
deleted file mode 100644
index 657a53f..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/SharedImages.java
+++ /dev/null
@@ -1,22 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.internal.WorkbenchImages;
-
-public class SharedImages {
-
- // TODO: should we not be using the workbench images directly?
- public static ImageDescriptor getWorkbenchImageDescriptor(String symbolicName) {
- return WorkbenchImages.getImageDescriptor(symbolicName);
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/UIDebug.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/UIDebug.java
deleted file mode 100644
index ca8a03f..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/UIDebug.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- * @date Nov 7, 2006
- *
- */
-
-@SuppressWarnings("nls")
-
-public class UIDebug {
-
- /**
- * Dump the widget structure for the control.
- *
- * @param control
- */
- static public final void dump (Control control) {
- dump(control,0);
- }
-
- /**
- * Dump the widget structure of the control.
- * Level is just how much indentation on the output there should
- * be.
- *
- * @param control
- * @param level
- */
-
- static public final void dump (Control control, int level) {
-
- p(level,"+-");
- p(level,"+- ctrl: {0}",control);
-
- p(level,"+- data={0}",control.getLayoutData() );
- p(level,"+- location={0},size={1}", control.getLocation(), control.getSize());
- if (control instanceof Composite) {
- Composite composite = (Composite) control;
- Control [] children = composite.getChildren();
- p(level,"+- layout={0}",composite.getLayout());
- if (children.length > 0) {
- p(level,"+- childCount={0}",children.length);
- for(int i=0; i < children.length; i++) {
- dump ( children[i], level + 3);
- }
- }
- }
- }
-
- static final void p (int level, String format, Object ... args) {
- for(int i=0; i<level;i++) {
- System.out.print(' ');
- }
- System.out.println(java.text.MessageFormat.format(format, args));
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/XSDUtils.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/XSDUtils.java
index 3c3460e..ca73576 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/XSDUtils.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/XSDUtils.java
@@ -11,61 +11,39 @@
package org.eclipse.bpel.ui.util;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.xsd.XSDAnnotation;
import org.eclipse.xsd.XSDAttributeDeclaration;
import org.eclipse.xsd.XSDAttributeGroupDefinition;
import org.eclipse.xsd.XSDAttributeUse;
import org.eclipse.xsd.XSDAttributeUseCategory;
import org.eclipse.xsd.XSDComplexTypeContent;
import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDConstraint;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFacet;
-import org.eclipse.xsd.XSDFactory;
import org.eclipse.xsd.XSDFeature;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDModelGroup;
import org.eclipse.xsd.XSDModelGroupDefinition;
import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDNotationDeclaration;
import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaCompositor;
-import org.eclipse.xsd.XSDSchemaContent;
import org.eclipse.xsd.XSDSimpleTypeDefinition;
import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.XSDXPathDefinition;
import org.eclipse.xsd.util.XSDConstants;
import org.eclipse.xsd.util.XSDUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* Collection of utility methods for dealing with navigation of the XSD model
*/
public class XSDUtils {
-
+
// singleton lists of XSD simple type definitions for supported primitives (see getPrimitives()) and
// all xsd primitives (see getAdvancedPrimitives()) respectively
private static List<XSDSimpleTypeDefinition> primitives;
private static List<XSDTypeDefinition> advancedPrimitives;
-
+
// XSD short list -- these are the types presented to the user by default, rather than inundating them with
// all the available types
private static List<String> xsdShortList = new ArrayList<String>();
@@ -81,9 +59,9 @@
xsdShortList.add("hexBinary"); //$NON-NLS-1$
xsdShortList.add("float"); //$NON-NLS-1$
}
-
-
- // A list of all supported XSD types. Usually the user will not be presented with the full list, but
+
+
+ // A list of all supported XSD types. Usually the user will not be presented with the full list, but
// rather with the xsd short list
private static List<String> supportedPrimitives = new ArrayList<String>();
static {
@@ -117,7 +95,7 @@
supportedPrimitives.add("NCName"); //$NON-NLS-1$
supportedPrimitives.add("negativeInteger"); //$NON-NLS-1$
supportedPrimitives.add("NMTOKEN"); //$NON-NLS-1$
- supportedPrimitives.add("NMTOKENS"); //$NON-NLS-1$, "NMTOKENS");
+ supportedPrimitives.add("NMTOKENS"); //$NON-NLS-1$, "NMTOKENS");
supportedPrimitives.add("nonNegativeInteger"); //$NON-NLS-1$
supportedPrimitives.add("nonPositiveInteger"); //$NON-NLS-1$
supportedPrimitives.add("normalizedString"); //$NON-NLS-1$
@@ -133,246 +111,9 @@
supportedPrimitives.add("unsignedLong"); //$NON-NLS-1$
supportedPrimitives.add("unsignedShort"); //$NON-NLS-1$
}
-
- /**
- * Add a local annotation with userInfo to the given item.
- *
- * <p>
- * Note: We take an XSDConcreteComponent, however we must then cast it to
- * one of the types that has a setAnnotation call defined, since it doesn't
- * have a clear 'parent' interface for annotations.
- * </p>
- *
- * <p>
- * Also note that UserInformation and ApplicationInformation objects can
- * only be added <b>after </b> the parent of the annotation has been added
- * to an XSDSchema object. This is because these objects are modeled in the
- * concrete DOM layer only, and otherwise will throw a DOMException.
- * <p>
- *
- * @param component
- * to add annotation to; may be any kind of XSDConcreteComponent
- * object including an XSDSchema
- * @param text
- * text to add as the userInformation (xsd:documentation) node to
- * the annotation
- * @return the XSDAnnotation object created, after having been added to the
- * component; null if any error occoured
- */
- public static XSDAnnotation addDocumentation(XSDConcreteComponent component, String text) {
- if (null == component) {
- throw new IllegalArgumentException("addDocumentation called with null component"); //$NON-NLS-1$
- }
- try {
-
- // First get the factory from the component: this is
- // roundabout, but saves the user from having to
- // pass it in
- XSDFactory xsdFactory = XSDFactory.eINSTANCE;
-
- // Create an XSDAnnotation object to hold everything
- XSDAnnotation xsdAnnotation = xsdFactory.createXSDAnnotation();
-
- // Depending on the XSDConcreteComponent type, cast to
- // the appropriate type and add the annotation or, if component
- // already has an annotation, use that one instead.
- if (component instanceof XSDAttributeDeclaration) {
- if(((XSDAttributeDeclaration) component).getAnnotation() == null)
- ((XSDAttributeDeclaration) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDAttributeDeclaration) component).getAnnotation();
- } else if (component instanceof XSDAttributeGroupDefinition) {
- if(((XSDAttributeGroupDefinition) component).getAnnotation() == null)
- ((XSDAttributeGroupDefinition) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDAttributeGroupDefinition) component).getAnnotation();
- } else if (component instanceof XSDElementDeclaration) {
- if(((XSDElementDeclaration) component).getAnnotation() == null)
- ((XSDElementDeclaration) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDElementDeclaration) component).getAnnotation();
- } else if (component instanceof XSDFacet) {
- if(((XSDFacet) component).getAnnotation() == null)
- ((XSDFacet) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDFacet) component).getAnnotation();
- } else if (component instanceof XSDIdentityConstraintDefinition) {
- if(((XSDIdentityConstraintDefinition) component).getAnnotation() == null)
- ((XSDIdentityConstraintDefinition) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDIdentityConstraintDefinition) component).getAnnotation();
- } else if (component instanceof XSDImport) {
- if(((XSDImport) component).getAnnotation() == null)
- ((XSDImport) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDImport) component).getAnnotation();
- } else if (component instanceof XSDInclude) {
- if(((XSDInclude) component).getAnnotation() == null)
- ((XSDInclude) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDInclude) component).getAnnotation();
- } else if (component instanceof XSDModelGroup) {
- if(((XSDModelGroup) component).getAnnotation() == null)
- ((XSDModelGroup) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDModelGroup) component).getAnnotation();
- } else if (component instanceof XSDModelGroupDefinition) {
- if(((XSDModelGroupDefinition) component).getAnnotation() == null)
- ((XSDModelGroupDefinition) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDModelGroupDefinition) component).getAnnotation();
- } else if (component instanceof XSDNotationDeclaration) {
- if(((XSDNotationDeclaration) component).getAnnotation() == null)
- ((XSDNotationDeclaration) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDNotationDeclaration) component).getAnnotation();
- } else if (component instanceof XSDTypeDefinition) {
- if(((XSDTypeDefinition) component).getAnnotation() == null)
- ((XSDTypeDefinition) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDTypeDefinition) component).getAnnotation();
- } else if (component instanceof XSDWildcard) {
- if(((XSDWildcard) component).getAnnotation() == null)
- ((XSDWildcard) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDWildcard) component).getAnnotation();
- } else if (component instanceof XSDXPathDefinition) {
- if(((XSDXPathDefinition) component).getAnnotation() == null)
- ((XSDXPathDefinition) component).setAnnotation(xsdAnnotation);
- else
- xsdAnnotation = ((XSDXPathDefinition) component).getAnnotation();
- } else if (component instanceof XSDSchema) {
- // Note that this adds a global annotation to the
- // schema itself, not to any subcomponent
- ((XSDSchema) component).getContents().add(xsdAnnotation);
- } else {
- // Whoops, asked us to annotate an unannotateable item
- throw new IllegalArgumentException("Unable to addDocumentation onto type: " + component); //$NON-NLS-1$
- }
-
- // Remove any old documentation elements
- for(int i = 0; i < xsdAnnotation.getElement().getChildNodes().getLength(); i++) {
- Node node = xsdAnnotation.getElement().getChildNodes().item(i);
- if(node.getNodeName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG))
- xsdAnnotation.getElement().removeChild(node);
- }
- xsdAnnotation.getUserInformation().clear();
-
- if (text!=null)
- {
- // Now that the xsdAnnotation is added to a parent
- // XSDConcreteComponent, go ahead and create the
- // UserInformation node (xsd:documentation) and
- // add a DOM textNode to it containing the information
- Element userInfo = xsdAnnotation.createUserInformation(null);
- userInfo.appendChild(userInfo.getOwnerDocument().createTextNode(text));
-
- // Add the finished userInfo object to the concrete
- // element of the xsdAnnotation
- xsdAnnotation.getElement().appendChild(userInfo);
-
- // Add the finished userInfo object to the user information
- // list
- xsdAnnotation.getUserInformation().add(userInfo);
- }
-
- return xsdAnnotation;
- } catch (Exception e) {
- return null;
- }
- }
/**
- * Adds the text to the component as a Documentation element (just like addDocumentation) and then adds the
- * Documentation attributes to the Documentation element if they exist.
- * If text is null then no documentation is set.
- * If attributes is null then no attributes are added to the documentation element.
- * @param component
- * @param text
- * @param attributes
- * @return
- */
- public static XSDAnnotation addDocumentationAndAttributes(XSDConcreteComponent component, String text, Map attributes)
- {
- if (null == component)
- {
- throw new IllegalArgumentException("addDocumentationAndAttributes called with null component"); //$NON-NLS-1$
- }
-
- // nothing to add
- if (text==null && attributes==null)
- return null;
-
- // add documentation
- XSDAnnotation annotation = addDocumentation(component, text);
-
- if (annotation==null)
- return null;
-
- // no attributes so return
- if (attributes==null || attributes.isEmpty())
- return annotation;
-
- // get annotation dom element, create if necessary
- Element userInfo = null;
- if (annotation.getUserInformation().isEmpty())
- {
- userInfo = annotation.createUserInformation(null);
- annotation.getElement().appendChild(userInfo);
- }
- else
- {
- for (Iterator<Element> i = annotation.getUserInformation().iterator(); i.hasNext();)
- {
- userInfo = i.next();
- if (userInfo.getTagName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG))
- {
- break;
- }
- }
- }
-
- if (userInfo==null)
- return null;
-
- // add attributes
- String key = null;
- for (Iterator<String> iter = attributes.keySet().iterator(); iter.hasNext();)
- {
- key = iter.next();
- userInfo.setAttribute(key, (String)attributes.get(key));
- }
-
- return annotation;
- }
-
-
- /**
- * Returns a string which is not used by any element in 'elements'. The name
- * is generated by appending numerical suffixes on to 'prefix' until a
- * unique one is found. PRECONDITION: 'elements' is a list of
- * XSDNamedComponent instances
- *
- * @param prefix
- * @param elements
- * @return
- */
- public static String createUniqueElementName(String prefix, List elements) {
- ArrayList<String> usedNames = new ArrayList<String>();
- for(Iterator i = elements.iterator(); i.hasNext(); ) {
- usedNames.add( getDisplayName((XSDNamedComponent) i.next()));
- }
-
- int i = 1;
- String testName = prefix + i++;
- while(usedNames.contains(testName)) {
- testName = prefix + i++;
- }
- return testName;
- }
-
- /**
- * Like getPrimitives(), this returns a list of XSDTypeDefinitions. However where getPrimitives()
+ * Like getPrimitives(), this returns a list of XSDTypeDefinitions. However where getPrimitives()
* returns the basic set supported by the editor, getAdvancedPrimitives returns every known XSD
* primitive type.
* @return
@@ -381,10 +122,10 @@
advancedPrimitives = null;
if(advancedPrimitives == null) {
advancedPrimitives = new ArrayList<XSDTypeDefinition>();
-
+
// Get the schema for schemas instance to use when resolving primitives
XSDSchema schemaForSchemas = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
-
+
// Start adding the simple types using the supportedPrimitives list
for (String typeName : supportedPrimitives) {
XSDTypeDefinition type = schemaForSchemas.resolveSimpleTypeDefinition(typeName);
@@ -394,6 +135,7 @@
// Return primitives in alpha order
Collections.sort(advancedPrimitives, new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
if(o1 == null || o2 == null || ((XSDTypeDefinition) o1).getName() == null)
return 0;
@@ -401,49 +143,11 @@
}
});
}
- return advancedPrimitives;
+ return advancedPrimitives;
}
-
+
/**
- * Retrieves all the root Data types defined in the schema including complex types, user-defined simple types and anonymous
- * complex types. If there's an anonymous complex type definition (from a root element declaration) then we return
- * the element declaration's anonymous type.
- * @param schema
- * @return
- */
- public static List<XSDTypeDefinition> getAllDataTypes(XSDSchema schema)
- {
- if (schema==null)
- return Collections.emptyList();
-
- List<XSDTypeDefinition> bos = new ArrayList<XSDTypeDefinition>();
-
- EList<XSDSchemaContent> contents = schema.getContents();
- // First try the easy approach -- if this XSD contains a type definition, that's our BO,
- // return it. This is the recommended path, and the way our tooling does things.
- for (XSDSchemaContent item : contents) {
- if (item instanceof XSDTypeDefinition)
- bos.add((XSDTypeDefinition)item);
- }
-
- // If we failed, we try a second pass, this time looking for an element
- // with an anonymous complex
- // type defined in line
- for (XSDSchemaContent item : contents) {
- if (item instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration element = (XSDElementDeclaration) item;
- if (element.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition)
- {
- bos.add(element.getAnonymousTypeDefinition());
- }
- }
- }
- return bos;
- }
-
- /**
- * Given a BO (XSD Complex Type), return a list of the attributes
+ * Given a BO (XSD Complex Type), return a list of the attributes
* within the complexType.
* @param bo
* @return List of XSDAttributeDeclaration
@@ -455,63 +159,47 @@
for (int i=0; i< attrContents.size(); i++)
{
Object next = attrContents.get(i);
-
+
// Attribute contents may include actual attribute delcarations (wrapped in XSDAttributeUses) or
// attribute group definitions, containing bundles of attributes
if(next instanceof XSDAttributeUse) {
attrs.add( ((XSDAttributeUse) next).getContent().getResolvedAttributeDeclaration() );
-
+
} else if (next instanceof XSDAttributeGroupDefinition) {
-
+
// Add these attributes to the end of attrContents to be processed in turn
XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) next;
if(attrGroup.getResolvedAttributeGroupDefinition() != null)
attrContents.addAll(attrGroup.getResolvedAttributeGroupDefinition().getAttributeUses());
-
+
}
}
return attrs;
}
-
+
/**
- * Given a BO (XSD Complex Type), return a list of the XSDFeatures
+ * Given a BO (XSD Complex Type), return a list of the XSDFeatures
* within the complexType's modelgroup (sequence, choice, etc.)
* @param bo
* @return
*/
- public static List<XSDFeature> getChildElements(XSDComplexTypeDefinition bo)
- {
+ public static List<XSDFeature> getChildElements(XSDComplexTypeDefinition bo) {
return XSDUtils.getChildElements( getModelGroup(bo) );
}
/**
- * Given an XSDFeature, return a list of the XSDFeatures
- * within the complexType's modelgroup (sequence, choice, etc.)
- * @param bo
- * @return
- */
- public static List<XSDFeature> getChildElements(XSDFeature elem)
- {
- XSDComplexTypeDefinition cType = getResolvedComplexType(elem);
- return (cType != null) ? XSDUtils.getChildElements(cType) : Collections.EMPTY_LIST;
- }
-
-
- /**
- * Given a Model group, return a list of the XSDFeatures
+ * Given a Model group, return a list of the XSDFeatures
* declared within.
* @param group
- * @return
+ * @return
*/
- public static List<XSDFeature> getChildElements(XSDModelGroup group)
+ public static List<XSDFeature> getChildElements(XSDModelGroup group)
{
if(group == null)
return new ArrayList<XSDFeature>();
-
+
List<XSDFeature> children = new ArrayList<XSDFeature>();
- for(Iterator<XSDParticle> i = group.getContents().iterator(); i.hasNext();)
- {
- XSDParticle next = i.next();
+ for( XSDParticle next : group.getContents() ) {
if(next.getContent() instanceof XSDFeature)
children.add((XSDFeature) next.getContent());
else if (next.getTerm() instanceof XSDModelGroup)
@@ -519,161 +207,36 @@
}
return children;
}
-
- /**
- * Return the contents of the documentation element in type's annotation, if it has one.
- * Otherwise return null
- * @param type
- * @return
- */
- public static String getDocumentation(XSDFeature element) {
- XSDAnnotation annotation = null;
-
- if (element instanceof XSDAttributeDeclaration)
- annotation = ((XSDAttributeDeclaration)element).getAnnotation();
- else if (element instanceof XSDElementDeclaration)
- annotation = ((XSDElementDeclaration)element).getAnnotation();
-
- if(annotation != null) {
- for(Iterator i = annotation.getUserInformation().iterator(); i.hasNext(); ) {
- Element domElement = (Element) i.next();
- if(domElement.getTagName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG) &&
- domElement.getFirstChild() instanceof Text) {
- return ((Text) domElement.getFirstChild()).getData();
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the attributes on the documentation element if they exist. I.e. returns source and xml:lang
- * Returns an empty map if none.
- * @param type
- * @return
- */
- public static Map<String, String> getDocumentationAttributes(XSDTypeDefinition type)
- {
- Map<String, String> attributes = new HashMap<String, String>();
-
- if (type.getAnnotation() != null)
- {
- XSDAnnotation annotation = type.getAnnotation();
- for (Iterator i = annotation.getUserInformation().iterator(); i
- .hasNext();)
- {
- Element element = (Element) i.next();
- if (element.getTagName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG))
- {
- String source = element.getAttribute("source"); //$NON-NLS-1$
- String lang = element.getAttribute("xml:lang"); //$NON-NLS-1$
- if (lang==null || lang.length()<1)
- lang = element.getAttribute("lang"); //$NON-NLS-1$
-
- if (source!=null && source.length()>0)
- attributes.put("source", source); //$NON-NLS-1$
-
- if (lang!=null && lang.length()>0)
- attributes.put("xml:lang", lang); //$NON-NLS-1$
-
- return attributes;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the attributes on the documentation element if they exist. I.e. returns source and xml:lang
- * Returns an empty map if none.
- * @param element
- * @return
- */
- public static Map<String, String> getDocumentationAttributes(XSDFeature element)
- {
- XSDAnnotation annotation = null;
- Map<String, String> attributes = new HashMap<String, String>();
-
- if (element instanceof XSDAttributeDeclaration)
- annotation = ((XSDAttributeDeclaration)element).getAnnotation();
- else if (element instanceof XSDElementDeclaration)
- annotation = ((XSDElementDeclaration)element).getAnnotation();
-
- if (annotation != null)
- {
- for (Iterator i = annotation.getUserInformation().iterator(); i
- .hasNext();)
- {
- Element domElement = (Element) i.next();
- if (domElement.getTagName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG))
- {
- String source = domElement.getAttribute("source"); //$NON-NLS-1$
- String lang = domElement.getAttribute("xml:lang"); //$NON-NLS-1$
- if (lang==null || lang.length()<1)
- lang = domElement.getAttribute("lang"); //$NON-NLS-1$
-
- if (source!=null && source.length()>0)
- attributes.put("source", source); //$NON-NLS-1$
-
- if (lang!=null && lang.length()>0)
- attributes.put("xml:lang", lang); //$NON-NLS-1$
-
- return attributes;
- }
- }
- }
- return null;
- }
-
- /**
- * Return the contents of the documentation element in type's annotation, if it has one.
- * Otherwise return null
- * @param type
- * @return
- */
- public static String getDocumentation(XSDTypeDefinition type) {
- if(type.getAnnotation() != null) {
- XSDAnnotation annotation = type.getAnnotation();
- for(Iterator i = annotation.getUserInformation().iterator(); i.hasNext(); ) {
- Element element = (Element) i.next();
- if(element.getTagName().endsWith(XSDConstants.DOCUMENTATION_ELEMENT_TAG) &&
- element.getFirstChild() instanceof Text) {
- return ((Text) element.getFirstChild()).getData();
- }
- }
- }
- return null;
- }
/**
* Given an XSD Complex Type Definition, return the model group containing
- * its child elements.
+ * its child elements.
* @param element
* @return
*/
- public static XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType)
+ public static XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType)
{
XSDParticle particle = cType.getComplexType();
-
+
// In cases where cType doesn't have a model group AND cType has a parent with a modelgroup, the
- // call above will rather unexpectedly give us cType's PARENT's model group, rather than the null we
+ // call above will rather unexpectedly give us cType's PARENT's model group, rather than the null we
// might expect. We don't want that here, if the model group returned is null or belongs to someone
// other than us, return null
if (particle==null || particle.eContainer() != cType) {
return null;
}
-
+
// get the model group
Object particleContent = particle.getContent();
XSDModelGroup group = null;
-
+
if (particleContent instanceof XSDModelGroupDefinition) {
group = ((XSDModelGroupDefinition)particleContent).getResolvedModelGroupDefinition().getModelGroup();
} else if (particleContent instanceof XSDModelGroup) {
group = (XSDModelGroup)particleContent;
}
-
- if (group == null) {
+
+ if (group == null) {
return null;
}
@@ -689,56 +252,27 @@
if (cType.getBaseType()!=null)
{
XSDComplexTypeContent content = cType.getContent();
-
+
if (content instanceof XSDParticle) {
particleContent = ((XSDParticle)content).getContent();
if (particleContent instanceof XSDModelGroupDefinition) {
group = ((XSDModelGroupDefinition)particleContent).getResolvedModelGroupDefinition().getModelGroup();
} else if (particleContent instanceof XSDModelGroup) {
group = (XSDModelGroup)particleContent;
- }
+ }
}
-
+
}
- }
+ }
return group;
}
/**
- * General utility method for finding a name for an xsd component. This method will handle
- * mapping of xsd primitive names to their human readable counterparts, as well as resolving
- * element references for attributes and walking up object hierarchies for anonymous types.
- * Basically this method should be used whenever a name is needed to minimize the risk of
- * having a name of 'null' -- though this method WILL return null if no name can be found.
- * @param component
- * @return
- */
- public static String getDisplayName(XSDNamedComponent component) {
-
- if(component == null)
- return null;
-
- if(component instanceof XSDTypeDefinition)
- return getDisplayNameFromXSDType((XSDTypeDefinition) component);
-
- if (component instanceof XSDFeature) {
- XSDFeature feature = (XSDFeature) component;
- if(feature.getName() != null)
- return feature.getName();
- else if (feature.getResolvedFeature() != null && feature.getResolvedFeature().getName() != null)
- return feature.getResolvedFeature().getName();
- }
-
- return component.getName();
-
- }
-
- /**
* Try a variety of methods to get a human readable name for type. In order, this method will
* - check whether type is null, and if so return null
* - check whether type is a restriction of a primitive type, if so return its parent's name
- * - check whether type is a complex anonymous (un-named) inner type of a named element, and if so, return the element's name
+ * - check whether type is a complex anonymous (un-named) inner type of a named element, and if so, return the element's name
* - check whether type is a primitive type, and if so return a human-readable version of that type
* - check whether type is a named, non-primitive type, and if so, return its name
* @param xsdType
@@ -747,37 +281,35 @@
public static String getDisplayNameFromXSDType(XSDTypeDefinition type) {
return getDisplayNameFromXSDType(type, true);
}
-
+
/**
* Try a variety of methods to get a human readable name for type. In order, this method will
* - check whether type is null, and if so return null
- * - check whether type is a complex anonymous (un-named) inner type of a named element, and if so, return the element's name
+ * - check whether type is a complex anonymous (un-named) inner type of a named element, and if so, return the element's name
* - check whether type is a primitive type, and if so return a human-readable version of that type
* - check whether type is a named, non-primitive type, and if so, return its name
- * - if returnPrimitiveParents is true, check whether type is a restriction of a primitive type,
+ * - if returnPrimitiveParents is true, check whether type is a restriction of a primitive type,
* if so return its parent's name
* @param xsdType
- * @param returnPrimitiveParents if true, and if type is an anonymous restriction of an xsd primitive
- * type, this method will return the name of the parent primitive type. If false, restrictions of
+ * @param returnPrimitiveParents if true, and if type is an anonymous restriction of an xsd primitive
+ * type, this method will return the name of the parent primitive type. If false, restrictions of
* primitive types will not be treated differently from other types, and their container hierarchy will
- * be walked, instead of their inheritance hierarchy.
+ * be walked, instead of their inheritance hierarchy.
* @return
*/
- public static String getDisplayNameFromXSDType(XSDTypeDefinition type, boolean returnPrimitiveParents) {
+ public static String getDisplayNameFromXSDType(XSDTypeDefinition type, boolean returnPrimitiveParents) {
if(type == null)
return null;
-
-
-
+
// Does type have a name? If not, walk up the container tree to try and find one
if(type.getName() == null || type.getName().length() == 0) {
-
+
// In the special case where type is a restriction on a primitive type, just return the parent's
// name (which will either be a primitive itself, or a named simple type)
if(returnPrimitiveParents && isRestrictedPrimitiveType(type)) {
return getDisplayNameFromXSDType(type.getBaseType());
}
-
+
EObject container = type.eContainer();
while(container != null) {
@@ -791,41 +323,39 @@
} else
return type.getName();
}
-
+
/**
- * Return the type definition for the primitive with name xsdName (note, this is not the human-readable
- * name, but the actual XSD type name.) Return null if a type with this name is not in the list of
+ * Return the type definition for the primitive with name xsdName (note, this is not the human-readable
+ * name, but the actual XSD type name.) Return null if a type with this name is not in the list of
* all primitives
* @param xsdName
* @return
*/
public static XSDSimpleTypeDefinition getPrimitive(String xsdName) {
- for(Iterator<XSDTypeDefinition> i = getAdvancedPrimitives().iterator(); i.hasNext();) {
- XSDSimpleTypeDefinition next = (XSDSimpleTypeDefinition) i.next();
+ for( XSDTypeDefinition xsdTypeDefinition : getAdvancedPrimitives() ) {
+ XSDSimpleTypeDefinition next = (XSDSimpleTypeDefinition) xsdTypeDefinition;
if(next.getName().equals(xsdName)) {
- return next;
+ return next;
}
}
return null;
}
-
+
/**
- *
+ *
* @return Returns a list of XSDSimpleTypeDefinitions representing each of the supported primitives.
- * These will have their XSD spec names (e.g. xsd:dateTime) so they will likely need to be fed to
- * getDisplayName() if they are going to be presented to humans
+ * These will have their XSD spec names (e.g. xsd:dateTime) so they will likely need to be fed to
+ * getDisplayName() if they are going to be presented to humans
*/
public static List<XSDSimpleTypeDefinition> getPrimitives() {
if(primitives == null) {
primitives = new ArrayList<XSDSimpleTypeDefinition>();
-
+
// Get the schema for schemas instance to use when resolving primitives
XSDSchema schemaForSchemas = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
-
+
// Start adding the simple types from the XSD short list
- for(Iterator<String> i = xsdShortList.iterator(); i.hasNext(); ) {
- String typeName = i.next();
-
+ for( String typeName : xsdShortList ) {
XSDSimpleTypeDefinition type = schemaForSchemas.resolveSimpleTypeDefinition(typeName);
primitives.add(type);
}
@@ -833,6 +363,7 @@
// Return primitives in alpha order
Collections.sort(primitives, new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
if(o1 == null || o2 == null || getDisplayNameFromXSDType((XSDTypeDefinition) o1) == null)
return 0;
@@ -842,194 +373,32 @@
}
return primitives;
}
-
- /**
- * Return a collection of all types referenced by the attributes (XSDFeatures) of source. This
- * method is non-recursive (i.e. the list only contains direct references, not references-of-references)
- * Will not return null, but may return an empty set. This will not return a BO reference if the file
- * has been deleted (or just doesn't exist).
- * @param source The complex type to examine for references
- * @return a Collection of XSDComplexTypeDefinition instances -- no duplicates
- */
- public static Collection<XSDComplexTypeDefinition> getReferencedTypes(XSDComplexTypeDefinition source) {
- if(source == null)
- return Collections.emptySet();
-
- List<XSDComplexTypeDefinition> results = new ArrayList<XSDComplexTypeDefinition>();
- for(Iterator<XSDFeature> i = getChildElements(source).iterator(); i.hasNext(); ) {
- XSDFeature element = i.next();
- XSDComplexTypeDefinition elementType = getResolvedComplexType(element);
- if(elementType != null && !results.contains(elementType) && !XSDConstants.isSchemaForSchemaNamespace(elementType.getTargetNamespace()))
- results.add(elementType);
- }
- return results;
- }
/**
- * Return a collection of all types referenced by the attributes (XSDFeatures) of source. This
- * method is non-recursive (i.e. the list only contains direct references, not references-of-references)
- * Will not return null, but may return an empty set. This will return a BO reference if the file
- * has been deleted (or just doesn't exist).
- * @param source The complex type to examine for references
- * @return a Collection of XSDTypeDefinition (could be complex or simple type) instances -- no duplicates
- */
- public static Collection<XSDTypeDefinition> getAllReferencedTypes(XSDComplexTypeDefinition source)
- {
- return getAllReferencedTypes(source, false);
- }
-
- /**
- * Return a collection of all types referenced by the attributes (XSDFeatures) of source. This
- * method is non-recursive (i.e. the list only contains direct references, not references-of-references)
- * Will not return null, but may return an empty set. This will return a BO reference if the file
- * has been deleted (or just doesn't exist).
- * @param source The complex type to examine for references
- * @param includeAnonymous if true, the returned list will include anonymous inlined types as well. These
- * are not technically "referenced", however it allows this method to be used as a way to get all non-primitive
- * types used in any way by source
- * @return a Collection of XSDTypeDefinition (could be complex or simple type) instances -- no duplicates
- */
- public static Collection<XSDTypeDefinition> getAllReferencedTypes(XSDComplexTypeDefinition source, boolean includeAnonymous)
- {
- if (source == null)
- return Collections.emptySet();
-
- List<XSDTypeDefinition> results = new ArrayList<XSDTypeDefinition>();
- XSDTypeDefinition elementType = null;
- for (Iterator<XSDFeature> i = getChildElements(source).iterator(); i.hasNext();)
- {
- XSDFeature next = i.next();
- elementType = getResolvedType(next);
-
- // Only add non-null, non-duplicate, non-primitive types. If includeAnonymous is false,
- // anonymous types should be filtered out as well
- if( elementType != null &&
- !results.contains(elementType) &&
- !XSDConstants.isSchemaForSchemaNamespace(elementType.getTargetNamespace()) &&
- (includeAnonymous || elementType.eContainer() != next) )
- results.add(elementType);
- }
- return results;
- }
-
- /**
- * Given an element, return its complex type, or null if it does not have a complex type. This is
- * slightly more complicated than just calling getType() since an element may not have a type at all, it
- * may reference another element.
- * @param element
- * @return
- */
- public static XSDComplexTypeDefinition getResolvedComplexType(XSDFeature feature) {
- // The contents of this method have been adapted to the more general getResolvedType,
- // but this method is maintained for compatibility and convenience
- XSDTypeDefinition resolvedType = getResolvedType(feature);
- if(resolvedType instanceof XSDComplexTypeDefinition)
- return (XSDComplexTypeDefinition) resolvedType;
- return null;
- }
-
- /**
- * Given an element, return its type, or null if it does not have a type. This is
- * slightly more complicated than just calling getType() since an element may not have
- * a type at all, it may reference another element.
- * @param element
- * @return
- */
- public static XSDTypeDefinition getResolvedType(XSDFeature feature) {
-
- // Special case of elements referencing stale XSD complex types
- if (feature instanceof XSDElementDeclaration && ((XSDElementDeclaration) feature).getTypeDefinition() instanceof XSDComplexTypeDefinition) {
-
- XSDElementDeclaration element = (XSDElementDeclaration) feature;
-
- // We have a type, but types can be proxies, and proxies can become
- // stale if the referenced
- // type changes, so before we return it, re-resolve the proxy and
- // then return it
- XSDComplexTypeDefinition oldType = (XSDComplexTypeDefinition) element.getTypeDefinition();
- EObject newType = EcoreUtil.resolve(element.getTypeDefinition(), element);
- if (oldType != newType) {
- // We only return the resolved type if the name and the namespace has not changed. Changing the name
- // and namespace is essentially an unresolved BO.
- String oldName = oldType.getName();
- String newName = ((XSDTypeDefinition)newType).getName();
- String oldTNS = oldType.getTargetNamespace();
- String newTNS = ((XSDTypeDefinition)newType).getTargetNamespace();
-
- if ( ((oldName==newName) || (oldName!=null && oldName.equals(newName))) &&
- ((oldTNS==newTNS) || (oldTNS!=null && oldTNS.equals(newTNS))) )
- element.setTypeDefinition((XSDTypeDefinition) newType);
- }
- return element.getTypeDefinition();
-
- } else if (feature.getType() != null) {
- return feature.getType();
- } else if (feature.getResolvedFeature() != null && feature.getResolvedFeature().getType() != null) {
- // We reference another element
- return feature.getResolvedFeature().getType();
- } else {
- return null;
- }
- }
-
- /**
* Return the base type from which this type inherits - that is, all xsd types are
* either xsd:anyType or xsd:anySimpleType at the topmost level of inheritance, so return the second
- * topmost level of type's inheritance. The first specific type from which type inherits.
+ * topmost level of type's inheritance. The first specific type from which type inherits.
* @param type
* @return
*/
public static XSDTypeDefinition getRootType(XSDTypeDefinition type) {
if(type == null)
return null;
-
+
XSDTypeDefinition baseType = type.getBaseType();
while(baseType != null && !XSDConstants.isAnySimpleType(baseType) && !XSDConstants.isAnyType(baseType)) {
// walk one more step up the hierarchy
type = baseType;
baseType = type.getBaseType();
}
-
+
// Since baseType, type's immediate parent, broke the while condition, we know that type is now
// as high up the tree as we want to be
return type;
-
-
-
}
-
+
/**
- * Given a schema, return the list of XSDSimpleTypeDefinitions found within it. Will not return null,
- * but may return an empty list
- * @param schema
- * @return
- */
- public static List<XSDSimpleTypeDefinition> getUserDefinedSimpleTypes(XSDSchema schema) {
- if(schema == null)
- return Collections.emptyList();
-
- List<XSDSimpleTypeDefinition> result = new ArrayList<XSDSimpleTypeDefinition>();
- for (XSDSchemaContent next : schema.getContents()) {
- if(next instanceof XSDSimpleTypeDefinition)
- result.add((XSDSimpleTypeDefinition)next);
- }
- return result;
- }
-
- /**
- * Given a display name for a BO attribute type, return the XSD type name.
- * If the given input is not a display name, the input is returned.
- * @param displayName
- * @return
- */
- public static String getXSDTypeFromDisplayName(String displayName)
- {
- // Now a no-op since we no longer translate XSD type names to "human readable" ones
- return displayName;
- }
-
- /**
- * Return true iff type is a descendant of a primitive xsd type. Will not return true for primitives
+ * Return true if type is a descendant of a primitive xsd type. Will not return true for primitives
* themselves.
* @param type
* @return
@@ -1037,11 +406,11 @@
public static boolean isRestrictedPrimitiveType(XSDTypeDefinition type) {
if(type instanceof XSDComplexTypeDefinition)
return false;
-
+
XSDTypeDefinition baseType = getRootType(type);
return getAdvancedPrimitives().contains(baseType);
}
-
+
/**
* Gets the "minOccurs" attribute value for the given XSDFeature, if
* there is none then it returns the default 1.
@@ -1054,15 +423,15 @@
{
return (((XSDAttributeUse)xsdElem.eContainer()).getUse()==XSDAttributeUseCategory.REQUIRED_LITERAL?1:0);
}
-
+
XSDParticle particle = (XSDParticle)xsdElem.eContainer();
int min = 1;
if (particle.isSetMinOccurs())
min = particle.getMinOccurs();
-
+
return min;
}
-
+
/**
* Gets the "maxOccurs" attribute value for the given XSDFeature, if
* there is none then it returns the default 1.
@@ -1072,101 +441,19 @@
public static int getMaxOccurs(XSDFeature xsdElem)
{
int max = 1;
-
+
// not a particle means an attribute use. attributes are maxed at 1.
if ( !(xsdElem.eContainer() instanceof XSDParticle) )
return max;
-
+
XSDParticle particle = (XSDParticle)xsdElem.eContainer();
if (particle.isSetMaxOccurs())
max = particle.getMaxOccurs();
-
+
return max;
}
-
- /**
- * Return the Data Type from the given schema with the given name.
- * @param schema - The schema containing the type.
- * @param boName - The local name of the type to retrieve -- if null method returns first type found.
- * @return The XSDTypeDefinition if one exists, null otherwise
- */
- public static XSDTypeDefinition getDataType(XSDSchema schema, String typeName) {
- if(schema == null)
- return null;
-
- boolean pickFirstFound = (typeName==null || typeName.length()<1);
-
- EList<XSDSchemaContent> contents = schema.getContents();
-
- // First try the easy approach -- if this XSD contains a type definition with the right name, that's
- // our type, return it. This is the recommended path, and the way our tooling does things.
- for(Iterator<XSDSchemaContent> i = contents.iterator(); i.hasNext(); ) {
- Object item = i.next();
- if(item instanceof XSDTypeDefinition)
- if (pickFirstFound)
- return (XSDTypeDefinition) item;
- else if ( typeName.equals(getDisplayName((XSDTypeDefinition)item)))
- return (XSDTypeDefinition) item;
- }
-
- // If we failed, we try a second pass, this time looking for an element with an anonymous
- // type defined in line
- for(Iterator<XSDSchemaContent> i = contents.iterator(); i.hasNext(); ) {
- Object item = i.next();
- if(item instanceof XSDFeature) {
- XSDFeature element = (XSDFeature) item;
- XSDTypeDefinition resolvedType = getResolvedType(element);
- if(resolvedType != null && resolvedType.getSchema() == schema) {
- if (pickFirstFound)
- return resolvedType;
- else if (typeName.equals(getDisplayName(element)))
- return resolvedType;
- }
- }
- }
- return null;
-
- }
/**
- * Gets the "default" attribute value for the given XSDFeature, if there
- * is none then it returns an empty string.
- * @param xsdElem
- * @return
- */
- public static String getDefaultValue(XSDFeature xsdElem)
- {
- XSDConstraint constraint = null;
- if (xsdElem instanceof XSDAttributeDeclaration)
- {
- // attribute declarations store their default values in
- // their containers (attribute uses)
- XSDAttributeUse use = (XSDAttributeUse)xsdElem.getContainer();
- if (use.isSetConstraint())
- constraint = use.getConstraint();
-
- if (constraint!=null && constraint.equals(XSDConstraint.DEFAULT_LITERAL))
- if (use.getLexicalValue()!=null)
- return use.getLexicalValue();
- else
- return ""; //$NON-NLS-1$
- }
- else if (xsdElem instanceof XSDElementDeclaration)
- {
- if (xsdElem.isSetConstraint())
- constraint = xsdElem.getConstraint();
-
- if (constraint!=null && constraint.equals(XSDConstraint.DEFAULT_LITERAL))
- if (xsdElem.getLexicalValue()!=null)
- return xsdElem.getLexicalValue();
- else
- return ""; //$NON-NLS-1$
-
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
* Return the enclosing Complex Type definition.
* @param component
* @return
@@ -1175,68 +462,21 @@
{
if (component == null)
return null;
-
+
if (component instanceof XSDComplexTypeDefinition)
return (XSDComplexTypeDefinition)component;
return getEnclosingTypeDefinition(component.eContainer());
}
-
- /**
- * Given an XSD schema with a new target namespace set, this method will cycle through the XSD schema directives
- * (i.e. imports/includes/redefines) and remove as appropriate.
- *
- * I.e. this method will remove all includes/redefines if the new TNS is different than the old TNS and it will remove
- * all imports that have the same namespace as the new TNS (since these should now be includes).
- *
- * @param schema - has the new target namespace set
- * @param oldTNS
- */
- public static void removeImportsAndIncludes(XSDSchema schema, String oldTNS)
- {
- if (schema==null)
- return;
-
- String newTNS = schema.getTargetNamespace();
-
- // namespace hasn't changed
- if (newTNS==null && oldTNS==null)
- return;
-
- // namespace hasn't changed
- if (newTNS!=null && newTNS.equals(oldTNS))
- return;
-
- // namespace has changed so remove all includes and remove any imports to the new namespace
- ArrayList schemaContents = new ArrayList(schema.getContents());
- for (Iterator i = schemaContents.iterator(); i.hasNext();)
- {
- Object next = i.next();
- if (next instanceof XSDImport)
- {
- XSDImport nextImport = (XSDImport) next;
- if (nextImport.getNamespace()==null && newTNS==null)
- schema.getContents().remove(nextImport);
- else if (nextImport.getNamespace()!=null && nextImport.getNamespace().equals(newTNS))
- schema.getContents().remove(nextImport);
- }
- else if (next instanceof XSDSchemaCompositor)
- {
- schema.getContents().remove(next);
- }
- }
-
- }
-
+
/**
* Given an XSD complex type, return a list of the XSDFeatures (element
* and attribute declarations) within the complex type.
*/
- public static List<XSDFeature> getXSDElementsAndAttributes(XSDComplexTypeDefinition complexType)
- {
+ public static List<XSDFeature> getXSDElementsAndAttributes(XSDComplexTypeDefinition complexType) {
List<XSDFeature> result = getChildElements(complexType);
result.addAll( getChildAttributes(complexType));
-
+
return result;
- }
+ }
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/FileAndComboSelectionDialog.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/FileAndComboSelectionDialog.java
deleted file mode 100644
index 736c79b..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/FileAndComboSelectionDialog.java
+++ /dev/null
@@ -1,296 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util.filedialog;
-
-import org.eclipse.bpel.common.ui.details.viewers.ComboViewer;
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.Messages;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-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.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ISelectionValidator;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-
-/**
- * A version of WorkbenchFileSelectionDialog which allows the user to select one element
- * from within the file, using a combo box.
- *
- * The dialog has an optional area that can be used to display details about the selected
- * item.
- */
-public abstract class FileAndComboSelectionDialog extends SelectionDialog {
-
- private IResource initialSelection;
-
- private String title;
- private String message;
- private String filterPatterns;
-
- private IPath resultPath;
-
- private Combo combo;
- protected ComboViewer comboViewer;
-
- private Object comboResult;
- protected Text detailsMessage;
- private boolean useDetails;
-
- // validation
- private Label statusMessage;
- private org.eclipse.ui.dialogs.ISelectionValidator validator;
-
- // widgets
- private Button okButton;
- private boolean comboValid = false;
- private boolean fileValid = false;
-
- // the widget group;
- private FileSelectionGroup resourceGroup;
-
- /**
- * A FileAndComboSelectionDialog takes the following arguments:
- * <ul>
- * <li> parentShell, the parent shell of the caller.(required)</li>
- * <li> initialSelection, (required)</li>
- * = null, takes the initial selection of the file from store, where it was memorizaed
- * != null, starts the selection right from the specified path.
- * <li> message, shows the message on titel bar for this dialog.(required)</li>
- * <li> filterPatterns, a string of extentions separated with "," as deliminator (eg; "wsdl, xsd, java")(optional)
- * <li> useDetails, true if the subclass needs the detailsMessage text widget.
- */
- public FileAndComboSelectionDialog(Shell parentShell, IPath initialSelection,
- String message, String filterPatterns, boolean useDetails)
- {
- super(parentShell);
- this.useDetails = useDetails;
-
- IPath initial = initialSelection;
- if (initial == null) {
- // TODO: find a suitable default somehow?
- }
- try {
- if (initial != null) {
- this.initialSelection =
- ResourcesPlugin.getWorkspace().getRoot().getFile(initial);
- }
- } catch (Exception e) {
- BPELUIPlugin.log(e);
- }
-
- this.title = Messages.FileAndComboSelectionDialog_Browse_1;
- this.message = message;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.filterPatterns = filterPatterns;
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- }
-
- protected boolean canFinish() {
- return fileValid && comboValid;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- okButton =
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(
- parent,
- IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL,
- false);
- okButton.setEnabled(canFinish());
- }
-
- /**
- * This function should open the selected file and read necessary model object(s) from
- * it. It should return some sort of "root" model object which is understood by the
- * content provider of the comboViewer.
- */
- protected abstract Object readModelFromSelectedFile();
-
- protected void reloadComboContents() {
- Object modelRoot = readModelFromSelectedFile();
- comboViewer.setInput(modelRoot);
- combo.select(0);
- if (useDetails) updateDetailsMessage();
- }
-
- /**
- * Subclasses which use detailsMessage should override this to set its contents.
- */
- protected void updateDetailsMessage() { }
-
- protected void clearComboContents() {
- comboViewer.setInput(null);
- updateDetailsMessage();
- }
-
- protected abstract void configureComboViewer(ComboViewer comboViewer);
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // create composite
- Composite dialogArea = (Composite) super.createDialogArea(parent);
-
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- fileValid = true;
- if (statusMessage != null && validator != null) {
- String errorMsg =
- validator.isValid(resourceGroup.getResourceFullPath());
- if (errorMsg == null || errorMsg.equals("")) { //$NON-NLS-1$
- statusMessage.setText(""); //$NON-NLS-1$
- fileValid = true;
- } else {
- statusMessage.setForeground(
- statusMessage.getDisplay().getSystemColor(SWT.COLOR_RED));
- statusMessage.setText(errorMsg);
- fileValid = false;
- }
- }
- if (fileValid) {
- resultPath = resourceGroup.getResourceFullPath();
- }
- if (fileValid && event.type == SWT.Selection) {
- reloadComboContents();
- comboValid = (combo.getItemCount() > 0);
- }
- if (getOkButton() != null) {
- getOkButton().setEnabled(canFinish());
- }
- if (!canFinish()) resultPath = null;
- }
- };
-
- // file selection group
- resourceGroup = new FileSelectionGroup(dialogArea, listener, message, filterPatterns);
-
- Composite comboComposite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 8;
- gridLayout.marginHeight = 0;
- comboComposite.setLayout(gridLayout);
- comboComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- combo = new Combo(comboComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite textComposite = new Composite(parent, SWT.NONE);
-
- gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 8;
- gridLayout.marginHeight = 8;
- textComposite.setLayout(gridLayout);
- textComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- if (useDetails) {
- detailsMessage = new Text(textComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
-
- GridData data = new GridData(GridData.FILL_BOTH);
- data.verticalSpan = 2;
-
- GC gc = new GC(detailsMessage);
- gc.setFont(detailsMessage.getFont());
- FontMetrics fontMetrics = gc.getFontMetrics();
- gc.dispose();
- data.heightHint = fontMetrics.getHeight() * 2;
- detailsMessage.setLayoutData(data);
- }
-
- comboViewer = new ComboViewer(combo);
- if (useDetails) {
- comboViewer.getCombo().addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateDetailsMessage();
- }
- public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); }
- });
- }
- configureComboViewer(comboViewer);
-
- statusMessage = new Label(textComposite, SWT.NONE);
- statusMessage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- if (initialSelection != null) {
- resourceGroup.setSelectedResource(initialSelection);
- }
-
- return dialogArea;
- }
-
- /**
- * Subclasses can override to create extra widgets below the combo.
- */
- public void createExtraWidgets(Composite composite) { }
-
- /**
- * Returns the full path of the selected file.
- */
- public IPath getFullPath() {
- return resultPath;
- }
-
- protected Object getComboSelection() {
- return ((IStructuredSelection)comboViewer.getSelection()).getFirstElement();
- }
-
- protected void setComboResult(Object comboResult) {
- this.comboResult = comboResult;
- }
-
- /**
- * Returns the result of selecting in the combo (note: might be different from getComboSelection()!)
- */
- public Object getComboResult() {
- return comboResult;
- }
-
- /**
- * Closes this dialog.
- */
- @Override
- protected void okPressed() {
- resultPath = resourceGroup.getResourceFullPath();
-
- super.okPressed();
- }
-
- /**
- * Sets the validator to use.
- */
- public void setValidator(ISelectionValidator validator) {
- this.validator = validator;
- }
-
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/ResourceSelectionDialog.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/ResourceSelectionDialog.java
deleted file mode 100644
index a5879fe..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/ResourceSelectionDialog.java
+++ /dev/null
@@ -1,89 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util.filedialog;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.swt.widgets.Shell;
-
-
-public abstract class ResourceSelectionDialog extends FileAndComboSelectionDialog {
-
- ResourceSet callerResourceSet;
- ResourceSet resourceSet;
-
- public ResourceSelectionDialog(Shell shell, ResourceSet resourceSet, String message,
- String filterPatterns, boolean useDetails)
- {
- this(shell, null, resourceSet, message, filterPatterns, useDetails);
- }
-
- public ResourceSelectionDialog(Shell shell, IPath initialSelection, ResourceSet resourceSet,
- String message, String filterPatterns, boolean useDetails)
- {
- super(shell, ((initialSelection != null) ? initialSelection : BPELUtil.lastWSDLFilePath),
- message, filterPatterns, useDetails);
- this.callerResourceSet = resourceSet;
- this.resourceSet = BPELUtil.createResourceSetImpl();
- }
-
- /**
- * This method should map the selectedModelObject to some identifier which can uniquely
- * identify it within its resource (e.g. the object's name). The result must be non-null.
- *
- * The mapping should be as robust as possible, since the model may already be loaded in
- * memory and modified.
- */
- protected abstract Object getIdFromModelObject(Object selectedModelObject);
-
- /**
- * This method should map the given objectId back to a model object reachable from the
- * given modelRoot. The objectId must be non-null and the result should be non-null.
- */
- protected abstract Object getModelObjectFromId(Object modelRoot, Object objectId);
-
-
- @Override
- protected void okPressed() {
- Object comboSelection = getComboSelection();
- super.okPressed();
- BPELUtil.lastWSDLFilePath = getFullPath();
-
- // hack: now load the model object into the real resourceSet
- this.resourceSet = callerResourceSet;
- Object objectId = getIdFromModelObject(comboSelection);
- setComboResult(null);
- if (objectId != null) {
- Object modelRoot = readModelFromSelectedFile();
- setComboResult(getModelObjectFromId(modelRoot, objectId));
- }
-
- }
-
- @Override
- protected Object readModelFromSelectedFile() {
- IPath path = getFullPath();
- if (path != null) {
- try {
- Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(path.toString()), true);
- return resource.getContents().isEmpty()? null : resource.getContents().get(0);
-
- } catch (Exception e) {
- BPELUIPlugin.log(e);
- }
- }
- return null;
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WorkbenchFileSelectionDialog.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WorkbenchFileSelectionDialog.java
deleted file mode 100644
index d3608a0..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WorkbenchFileSelectionDialog.java
+++ /dev/null
@@ -1,192 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util.filedialog;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.Messages;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-
-public class WorkbenchFileSelectionDialog
- extends org.eclipse.ui.dialogs.SelectionDialog {
-
- // the initial selection
- private IResource initialSelection;
-
- // message and title
- private String title;
- private String message;
-
- // Filters
- private String filterPatterns;
- // the result
- private IPath resultPath;
-
- // the validation message
- private Label statusMessage;
-
- //for validating the selection
- private org.eclipse.ui.dialogs.ISelectionValidator validator;
-
- // the widget group;
- private FileSelectionGroup resourceGroup;
- /**
- * A WorkbenchFileSelectionDialog takes the following arguments:
- * <ul>
- * <li> parentShell, the parent shell of the caller.(required)</li>
- * <li> initialSelection, (resuired)</li>
- * = null, takes the initial selection of the file from store, where it was memorizaed
- * != null, starts the selection right from the specified path.
- * <li> message, shows the message on titel bar for this dialog.(required)</li>
- * <li> filterPatterns, a string of extentions separated with "," as deliminator (eg; "wsdl, xsd, java")(optional)
- */
- public WorkbenchFileSelectionDialog(
- Shell parentShell,
- IPath initialSelection,
- String message) {
- this(parentShell, initialSelection, message, null);
- }
- /**
- * A WorkbenchFileSelectionDialog takes the following arguments:
- * <ul>
- * <li> parentShell, the parent shell of the caller.(required)</li>
- * <li> initialSelection, (resuired)</li>
- * = null, takes the initial selection of the file from store, where it was memorizaed
- * != null, starts the selection right from the specified path.
- * <li> message, shows the message on titel bar for this dialog.(required)</li>
- * <li> filterPatterns, a string of extentions separated with "," as deliminator (eg; "wsdl, xsd, java")(optional)
- */
- public WorkbenchFileSelectionDialog(
- Shell parentShell,
- IPath initialSelection,
- String message,
- String filterPatterns) {
- super(parentShell);
-
- IPath initial = initialSelection;
- if (initial == null) {
- // Before launch the dialog, get the path in WorkbenchSlectionDialogStore, which is the path recently selected
- //String pathString = (String)WorkbenchSlectionDialogStore.getInstance().getPreferences(workbenchFileSlectionStoreID);
- //if (pathString.length()>0) {
- // initial=(IPath)new Path(pathString);
- //}
- }
- try {
- if (initial != null) {
- this.initialSelection =
- ResourcesPlugin.getWorkspace().getRoot().getFile(initial);
- }
- } catch (Exception e) {
- BPELUIPlugin.log(e);
- }
-
- this.title = Messages.WorkbenchFileSelectionDialog_Browse_2;
- this.message = message;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.filterPatterns = filterPatterns;
- }
-
- /* (non-Javadoc)
- * Method declared in Window.
- */
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- }
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(
- parent,
- IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL,
- false);
- }
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // create composite
- Composite dialogArea = (Composite) super.createDialogArea(parent);
-
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- if (statusMessage != null && validator != null) {
- String errorMsg =
- validator.isValid(resourceGroup.getResourceFullPath());
- if (errorMsg == null || errorMsg.equals("")) { //$NON-NLS-1$
- statusMessage.setText(""); //$NON-NLS-1$
- getOkButton().setEnabled(true);
- } else {
- statusMessage.setForeground(
- statusMessage.getDisplay().getSystemColor(SWT.COLOR_RED));
- statusMessage.setText(errorMsg);
- getOkButton().setEnabled(false);
- }
- }
- }
- };
-
- // file selection group
- resourceGroup =
- new FileSelectionGroup(dialogArea, listener, message, filterPatterns);
-
- if (initialSelection != null) {
- resourceGroup.setSelectedResource(initialSelection);
- }
-
- statusMessage = new Label(parent, SWT.NONE);
- statusMessage.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- return dialogArea;
- }
-
- /**
- * Returns the "full path" (i.e. first segment is project name) of the selected file.
- */
- public IPath getFullPath() {
- return resultPath;
- }
- /**
- * Closes this dialog.
- */
- @Override
- protected void okPressed() {
- resultPath = resourceGroup.getResourceFullPath();
- // after file selected, save the path to WorkbenchSlectionDialogStore
- //WorkbenchSlectionDialogStore.getInstance().setPreferences(workbenchFileSlectionStoreID,result.toString());
-
- super.okPressed();
- }
- /**
- * Sets the validator to use.
- */
- public void setValidator(org.eclipse.ui.dialogs.ISelectionValidator validator) {
- this.validator = validator;
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlFileSelectionDialog.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlFileSelectionDialog.java
deleted file mode 100644
index 782f41d..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlFileSelectionDialog.java
+++ /dev/null
@@ -1,50 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util.filedialog;
-
-import org.eclipse.bpel.ui.IBPELUIConstants;
-import org.eclipse.bpel.ui.Messages;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.wst.wsdl.Definition;
-
-public class WsdlFileSelectionDialog extends WorkbenchFileSelectionDialog {
-
- public WsdlFileSelectionDialog(Shell shell) {
- super(shell,BPELUtil.lastWSDLFilePath, Messages.WsdlFileSelectionDialog_Select_a_WSDL_File_1, IBPELUIConstants.EXTENSION_DOT_WSDL);
- }
-
- public Definition readModelFromSelectedFile(){
- IPath path = getFullPath();
- if (path != null) {
- ResourceSet resourceSet = BPELUtil.createResourceSetImpl();
- URI uri = URI.createPlatformResourceURI(path.toString());
- Resource wsdlResource = resourceSet.getResource(uri, true);
- Definition definition = (Definition) wsdlResource.getContents().get(0);
- return definition;
- }
- return null;
- }
-
- public String getPath(){
- IPath path = getFullPath();
- if (path!=null){
- BPELUtil.lastWSDLFilePath = path;
- return path.toString();
- }
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlSelectionDialog.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlSelectionDialog.java
deleted file mode 100644
index 30303d4..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/filedialog/WsdlSelectionDialog.java
+++ /dev/null
@@ -1,105 +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 Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.util.filedialog;
-
-import java.util.Iterator;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.core.runtime.IPath;
-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.URIConverter;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.wst.wsdl.Definition;
-
-public abstract class WsdlSelectionDialog extends FileAndComboSelectionDialog {
-
- ResourceSet callerResourceSet;
- ResourceSet resourceSet;
-
- public WsdlSelectionDialog(Shell shell, ResourceSet resourceSet, String message,
- String filterPatterns, boolean useDetails)
- {
- super(shell, BPELUtil.lastWSDLFilePath, message, filterPatterns, useDetails);
- this.callerResourceSet = resourceSet;
- this.resourceSet = BPELUtil.createResourceSetImpl();
- }
-
- /**
- * This method should map the selectedModelObject to some identifier which can uniquely
- * identify it within its resource (e.g. the object's name). The result must be non-null.
- *
- * The mapping should be as robust as possible, since the model may already be loaded in
- * memory and modified.
- */
- protected abstract Object getIdFromModelObject(Object selectedModelObject);
-
- /**
- * This method should map the given objectId back to a model object reachable from the
- * given definition. The objectId must be non-null and the result should be non-null.
- */
- protected abstract Object getModelObjectFromId(Definition definition, Object objectId);
-
-
- @Override
- protected void okPressed() {
- Object comboSelection = getComboSelection();
- super.okPressed();
- BPELUtil.lastWSDLFilePath = getFullPath();
-
- // hack: now load the model object into the real resourceSet
- this.resourceSet = callerResourceSet;
- Object objectId = getIdFromModelObject(comboSelection);
- setComboResult(null);
- if (objectId != null) {
- Definition definition = (Definition)readModelFromSelectedFile();
- setComboResult(getModelObjectFromId(definition, objectId));
- }
-
- }
-
- @Override
- protected Object readModelFromSelectedFile() {
- IPath path = getFullPath();
- if (path != null) {
- try {
- // Check for it first in the caller set.
- URIConverter converter = callerResourceSet.getURIConverter();
- URI uri = URI.createPlatformResourceURI(path.toString());
- URI normalizedURI = converter.normalize(uri);
- Resource wsdlResource = null;
-
- Iterator it = callerResourceSet.getResources().iterator();
- while (it.hasNext()) {
- Resource resource = (Resource)it.next();
- if (converter.normalize(resource.getURI()).equals(normalizedURI)) {
- wsdlResource = resource;
- break;
- }
- }
-
- // It wasn't in the caller set; create it now in the temp set
- if (wsdlResource == null) {
- wsdlResource = resourceSet.getResource(uri, true);
- }
- Definition definition = (Definition) wsdlResource.getContents().get(0);
-
- return definition;
- } catch (Exception e) {
- BPELUIPlugin.log(e);
- }
- }
- return null;
- }
-}