Author: bbrodt
Date: 2010-11-03 18:13:24 -0400 (Wed, 03 Nov 2010)
New Revision: 26238
Modified:
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/AssignImplSection.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariableInitializationSection.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/EmfModelQuery.java
Log:
CODING IN PROGRESS - issue JBIDE-7351: General issues with Variable Initialization,
Assign, and Copy
https://jira.jboss.org/browse/JBIDE-7351
Modified:
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -3134,8 +3134,14 @@
case Node.TEXT_NODE:
case Node.CDATA_SECTION_NODE:
- elementData.append(getText(n));
- break;
+ //
https://jira.jboss.org/browse/JBIDE-7351
+ // don't display "null" for literal editor widgets
+ {
+ String data = getText(n);
+ if (data != null)
+ elementData.append(data);
+ break;
+ }
}
}
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/AssignImplSection.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/AssignImplSection.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/AssignImplSection.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -592,6 +592,11 @@
fCurrentCopy.setFrom(BPELFactory.eINSTANCE.createFrom());
}
section.fCurrent.setInput(fCurrentCopy.getFrom());
+
+ //
https://jira.jboss.org/browse/JBIDE-7351
+ // construct an initializer if From is empty
+ if (section.fCurrent instanceof LiteralAssignCategory)
+ VariableInitializationSection.createDefaultInitializer(getBPELEditor(),
fCurrentCopy.getFrom(), fCurrentCopy.getTo());
}
section.showCurrent();
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -10,31 +10,20 @@
*******************************************************************************/
package org.eclipse.bpel.ui.properties;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
import org.eclipse.bpel.common.ui.flatui.FlatFormData;
import org.eclipse.bpel.model.From;
-import org.eclipse.bpel.model.impl.VariableImpl;
import org.eclipse.bpel.model.resource.BPELResource;
import org.eclipse.bpel.model.util.BPELUtils;
-import org.eclipse.bpel.model.util.XSD2XMLGenerator;
import org.eclipse.bpel.ui.IBPELUIConstants;
import org.eclipse.bpel.ui.Messages;
import org.eclipse.bpel.ui.adapters.IVirtualCopyRuleSide;
import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.bpel.validator.EmfModelQuery;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDTypeDefinition;
/**
@@ -99,73 +88,16 @@
From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);
fChangeHelper.startNonUserChange();
- try {
- String fromString = EMPTY_STRING;
- if (from != null) {
- fromString = from.getLiteral();
- }
- if (fromString == null) {
- fromString = EMPTY_STRING;
- //
https://jira.jboss.org/browse/JBIDE-7351
- // if "From" is empty, construct a suitable literal for the variable
- try {
- VariableImpl var = (VariableImpl)fOwnerSection.getModel();
- String rootElement = null;
- String uriWSDL = null;
-
- // Variable is defined using "messageType"
- Message msg = (Message)var.getMessageType();
- if (msg != null) {
- if (msg.eIsProxy()) {
- EObject obj = EmfModelQuery.lookupMessage(getBPELEditor().getProcess(),
msg.getQName());
- if (obj instanceof Message)
- msg = (Message)obj;
- }
- Part part = null;
- Map parts = msg.getParts();
- if (parts!=null && !parts.isEmpty()) {
- Map.Entry entry = (Map.Entry)parts.entrySet().iterator().next();
- part = (Part)entry.getValue();
- }
- if (aModel.getPart() != null)
- part = aModel.getPart();
- if (part!=null) {
- XSDElementDeclaration declaration = part.getElementDeclaration();
- if (declaration != null) {
- uriWSDL = declaration.getSchema().getSchemaLocation();
- rootElement = declaration.getName();
- }
- }
- }
-
- // Variable is defined using "type"
- XSDTypeDefinition type = var.getType();
- if (type != null) {
- QName qname = new QName(type.getTargetNamespace(), type.getName());
- rootElement = qname.getLocalPart();
- uriWSDL = type.eResource().getURI().toString();
- }
-
- // Variable is defined using "element"
- XSDElementDeclaration element = var.getXSDElement();
- if (element != null) {
- QName qname = new QName(element.getTargetNamespace(), element
- .getName());
- rootElement = qname.getLocalPart();
- uriWSDL = element.eResource().getURI().toString();
- }
-
- XSD2XMLGenerator generator = new XSD2XMLGenerator(uriWSDL, rootElement);
- fromString = generator.createXML();
- }
- catch (Exception e) {
- }
- }
-
- fLiteralText.setText(fromString);
- } finally {
- fChangeHelper.finishNonUserChange();
+ String fromString = EMPTY_STRING;
+ if (from != null) {
+ fromString = from.getLiteral();
}
+ if (fromString == null) {
+ fromString = EMPTY_STRING;
+ }
+
+ fLiteralText.setText(fromString);
+ fChangeHelper.finishNonUserChange();
}
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariableInitializationSection.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariableInitializationSection.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariableInitializationSection.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -11,16 +11,25 @@
package org.eclipse.bpel.ui.properties;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
import org.eclipse.bpel.common.ui.details.IDetailsAreaConstants;
import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
import org.eclipse.bpel.common.ui.flatui.FlatFormData;
import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.bpel.model.BPELPackage;
+import org.eclipse.bpel.model.From;
+import org.eclipse.bpel.model.To;
import org.eclipse.bpel.model.Variable;
+import org.eclipse.bpel.model.util.XSD2XMLGenerator;
+import org.eclipse.bpel.ui.BPELEditor;
import org.eclipse.bpel.ui.Messages;
import org.eclipse.bpel.ui.commands.SetCommand;
import org.eclipse.bpel.ui.util.BPELUtil;
import org.eclipse.bpel.ui.util.MultiObjectAdapter;
+import org.eclipse.bpel.validator.EmfModelQuery;
import org.eclipse.core.resources.IMarker;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
@@ -30,6 +39,10 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.wsdl.Message;
+import org.eclipse.wst.wsdl.Part;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDTypeDefinition;
/**
@@ -274,6 +287,19 @@
section.updateCombo();
}
+ //
https://jira.jboss.org/browse/JBIDE-7351
+ // generate an appropriate XML initializer literal if currently empty
+ if (section.fCurrent instanceof LiteralAssignCategory) {
+ From from = fVariable.getFrom();
+ if (from!=null) {
+ String literal = from.getLiteral();
+ if (literal==null || literal.isEmpty()) {
+ literal = createDefaultInitializer(getBPELEditor(), fVariable, null);
+ from.setLiteral(literal);
+ }
+ }
+ }
+
// Set the input of the category after we insert the to or from into the model.
section.fCurrent.setInput( fVariable.getFrom() );
section.showCurrent();
@@ -311,4 +337,87 @@
public void gotoMarker(IMarker marker) {
refresh();
}
+
+ /**
+ * Construct an appropriate XML literal initializer for the given "from" and
"to" parts
+ *
+ * @param bpelEditor
+ * @param from
+ * @param to
+ * @return
+ */
+ public static String createDefaultInitializer(BPELEditor bpelEditor, From from, To to)
{
+ String literal = EMPTY_STRING;
+ if ( from!=null && to!=null) {
+ literal = from.getLiteral();
+ if (literal==null || literal.isEmpty()) {
+ literal = createDefaultInitializer(bpelEditor, to.getVariable(), to.getPart());
+ from.setLiteral(literal);
+ }
+ }
+ return literal;
+ }
+
+ /**
+ * Construct an appropriate XML literal initializer for the given variable and message
part.
+ *
+ * @param bpelEditor
+ * @param var - the variable to be initialized
+ * @param part - if the variable is defined as a message, this is the message part
+ * otherwise null
+ * @return - XML string representing an intializer for the given variable
+ * @see
https://jira.jboss.org/browse/JBIDE-7351
+ */
+ public static String createDefaultInitializer(BPELEditor bpelEditor, Variable var, Part
part) {
+ String fromString = EMPTY_STRING;
+ try {
+ String rootElement = null;
+ String uriWSDL = null;
+
+ // Variable is defined using "messageType"
+ Message msg = (Message)var.getMessageType();
+ if (msg != null) {
+ if (msg.eIsProxy()) {
+ msg = (Message)EmfModelQuery.resolveProxy(bpelEditor.getProcess(), msg);
+ }
+ if (part==null) {
+ Map parts = msg.getParts();
+ if (parts!=null && !parts.isEmpty()) {
+ Map.Entry entry = (Map.Entry)parts.entrySet().iterator().next();
+ part = (Part)entry.getValue();
+ }
+ }
+ if (part!=null) {
+ XSDElementDeclaration declaration = part.getElementDeclaration();
+ if (declaration != null) {
+ uriWSDL = declaration.getSchema().getSchemaLocation();
+ rootElement = declaration.getName();
+ }
+ }
+ }
+
+ // Variable is defined using "type"
+ XSDTypeDefinition type = var.getType();
+ if (type != null) {
+ QName qname = new QName(type.getTargetNamespace(), type.getName());
+ rootElement = qname.getLocalPart();
+ uriWSDL = type.eResource().getURI().toString();
+ }
+
+ // Variable is defined using "element"
+ XSDElementDeclaration element = var.getXSDElement();
+ if (element != null) {
+ QName qname = new QName(element.getTargetNamespace(), element
+ .getName());
+ rootElement = qname.getLocalPart();
+ uriWSDL = element.eResource().getURI().toString();
+ }
+
+ XSD2XMLGenerator generator = new XSD2XMLGenerator(uriWSDL, rootElement);
+ fromString = generator.createXML();
+ }
+ catch (Exception e) {
+ }
+ return fromString;
+ }
}
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -39,20 +39,17 @@
import org.eclipse.bpel.ui.util.XSDUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.wsdl.Message;
import org.eclipse.wst.wsdl.Part;
import org.eclipse.xsd.XSDAttributeDeclaration;
@@ -480,6 +477,10 @@
side.setQuery(null);
}
+ /*
+ //
https://jira.jboss.org/browse/JBIDE-7351
+ // remove all of this: don't ask to initialize variables whenever focus
+ // changes - this makes for a bad user experience!
// From?
if (side.isSource())
return;
@@ -502,6 +503,7 @@
(new Object[] { var.getName() })))) {
initTargetVariable(var, side);
}
+ */
}
private boolean isInitializerExist(Variable var, IVirtualCopyRuleSide side) {
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/util/BPELUtil.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -83,6 +83,7 @@
import org.eclipse.bpel.ui.extensions.BPELUIRegistry;
import org.eclipse.bpel.ui.uiextensionmodel.ActivityExtension;
import org.eclipse.bpel.ui.uiextensionmodel.UiextensionmodelPackage;
+import org.eclipse.bpel.validator.EmfModelQuery;
import org.eclipse.bpel.wsil.model.inspection.InspectionPackage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -1720,6 +1721,11 @@
public static void openEditor(EObject modelObject, BPELEditor editor) {
try {
+ //
https://jira.jboss.org/browse/JBIDE-7351
+ // try to resolve proxies here, otherwise we don't know editor input
+ if (modelObject.eIsProxy()) {
+ modelObject = EmfModelQuery.resolveProxy(editor.getProcess(), modelObject);
+ }
Assert.isNotNull(modelObject);
Assert.isNotNull(modelObject.eResource());
IFile file = BPELUtil.getFileFromURI(modelObject.eResource().getURI());
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/EmfModelQuery.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/EmfModelQuery.java 2010-11-03
22:07:20 UTC (rev 26237)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/EmfModelQuery.java 2010-11-03
22:13:24 UTC (rev 26238)
@@ -12,7 +12,6 @@
import java.util.List;
-import javax.wsdl.OperationType;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -22,10 +21,19 @@
import org.eclipse.bpel.model.Variable;
import org.eclipse.bpel.model.partnerlinktype.PartnerLinkType;
import org.eclipse.bpel.model.partnerlinktype.Role;
+import org.eclipse.bpel.model.proxy.MessageProxy;
+import org.eclipse.bpel.model.proxy.OperationProxy;
+import org.eclipse.bpel.model.proxy.PartProxy;
+import org.eclipse.bpel.model.proxy.PartnerLinkTypeProxy;
+import org.eclipse.bpel.model.proxy.PortTypeProxy;
+import org.eclipse.bpel.model.proxy.PropertyProxy;
+import org.eclipse.bpel.model.proxy.RoleProxy;
+import org.eclipse.bpel.model.proxy.XSDElementDeclarationProxy;
+import org.eclipse.bpel.model.proxy.XSDTypeDefinitionProxy;
import org.eclipse.bpel.model.util.ImportResolver;
import org.eclipse.bpel.model.util.ImportResolverRegistry;
+import org.eclipse.bpel.model.util.WSDLUtil;
import org.eclipse.bpel.model.util.XSDComparer;
-import org.eclipse.bpel.model.util.WSDLUtil;
import org.eclipse.bpel.model.util.XSDUtil;
import org.eclipse.bpel.validator.factory.AdapterFactory;
import org.eclipse.emf.common.util.EList;
@@ -495,6 +503,40 @@
return null;
}
+ public static EObject resolveProxy( Process process, EObject obj) {
+ if (obj instanceof MessageProxy) {
+ return scanImports ( process, ((MessageProxy)obj).getQName(), WSDLUtil.WSDL_MESSAGE
);
+ }
+ else if (obj instanceof PortTypeProxy) {
+ return scanImports ( process, ((PortTypeProxy)obj).getQName(), WSDLUtil.WSDL_PORT_TYPE
);
+ }
+ else if (obj instanceof PartnerLinkTypeProxy) {
+ return scanImports ( process, ((PartnerLinkTypeProxy)obj).getQName(),
WSDLUtil.BPEL_PARTNER_LINK_TYPE );
+ }
+ else if (obj instanceof RoleProxy) {
+ return scanImports ( process, ((RoleProxy)obj).getQName(), WSDLUtil.BPEL_ROLE );
+ }
+ else if (obj instanceof PropertyProxy) {
+ return scanImports ( process, ((PropertyProxy)obj).getQName(), WSDLUtil.BPEL_PROPERTY
);
+ }
+ else if (obj instanceof OperationProxy) {
+ QName qname = new QName(((OperationProxy)obj).getName());
+ return scanImports ( process, qname, WSDLUtil.WSDL_OPERATION );
+ }
+ else if (obj instanceof PartProxy) {
+ QName qname = new QName(((PartProxy)obj).getName());
+ return scanImports ( process, qname, WSDLUtil.WSDL_PART );
+ }
+ else if (obj instanceof XSDTypeDefinitionProxy) {
+ QName qname = new QName(((XSDTypeDefinitionProxy)obj).getName());
+ return scanImports ( process, qname, WSDLUtil.XSD_TYPE_DEFINITION );
+ }
+ else if (obj instanceof XSDElementDeclarationProxy) {
+ QName qname = new QName(((XSDElementDeclarationProxy)obj).getName());
+ return scanImports ( process, qname, WSDLUtil.XSD_ELEMENT_DECLARATION );
+ }
+ return obj;
+ }
static void assertTrue ( boolean mustBeTrue , String msg ) {
if (!mustBeTrue) {