Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmah2006-08-30 16:18:00 +0000
committerrmah2006-08-30 16:18:00 +0000
commit2150ceb74ccc416b67b0a068e606cb24520a31c4 (patch)
treed4167288d57cad841fbdc91a49af1fd933c44acf /bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse
parent21ab5f93de6865b80b3cf933c686c6b86b078d80 (diff)
downloadwebtools.webservices-2150ceb74ccc416b67b0a068e606cb24520a31c4.tar.gz
webtools.webservices-2150ceb74ccc416b67b0a068e606cb24520a31c4.tar.xz
webtools.webservices-2150ceb74ccc416b67b0a068e606cb24520a31c4.zip
[155705] [wsdl editor] Deleting and reording parts may not always work
Diffstat (limited to 'bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse')
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11DeleteParameterCommand.java24
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11ReorderParametersCommand.java85
2 files changed, 103 insertions, 6 deletions
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11DeleteParameterCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11DeleteParameterCommand.java
index 1be840d9a..90125c529 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11DeleteParameterCommand.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11DeleteParameterCommand.java
@@ -24,23 +24,35 @@ import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDModelGroup;
import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDSchema;
+import org.w3c.dom.Element;
public class W11DeleteParameterCommand extends W11TopLevelElementCommand {
private IParameter parameter;
public W11DeleteParameterCommand(IParameter param) {
- super(Messages._UI_ACTION_DELETE, ((WSDLElement) ((WSDLBaseAdapter) param).getTarget()).getEnclosingDefinition());
+ super(Messages._UI_ACTION_DELETE, null);
this.parameter = param;
}
public void execute() {
- try {
- beginRecording(definition.getElement());
- delete();
+ Object object = ((WSDLBaseAdapter) parameter).getTarget();
+ Element element = null;
+ if (object instanceof XSDElementDeclaration) {
+ element = ((XSDElementDeclaration) object).getElement();
+ }
+ else if (object instanceof WSDLElement) {
+ element = ((Part) object).getElement();
}
- finally {
- endRecording(definition.getElement());
+
+ if (element != null) {
+ try {
+ beginRecording(element);
+ delete();
+ }
+ finally {
+ endRecording(element);
+ }
}
}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11ReorderParametersCommand.java b/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11ReorderParametersCommand.java
index b356c9d43..3075e8249 100644
--- a/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11ReorderParametersCommand.java
+++ b/bundles/org.eclipse.wst.wsdl.ui/src-asd-wsdl11/org/eclipse/wst/wsdl/ui/internal/adapters/commands/W11ReorderParametersCommand.java
@@ -15,8 +15,13 @@ import java.util.List;
import org.eclipse.wst.wsdl.Message;
import org.eclipse.wst.wsdl.Part;
import org.eclipse.wst.wsdl.ui.internal.Messages;
+import org.eclipse.wst.wsdl.ui.internal.adapters.basic.W11ParameterForAttribute;
+import org.eclipse.wst.wsdl.ui.internal.adapters.basic.W11ParameterForElement;
import org.eclipse.wst.wsdl.ui.internal.adapters.basic.W11ParameterForPart;
import org.eclipse.wst.wsdl.ui.internal.asd.facade.IParameter;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDModelGroup;
+import org.eclipse.xsd.XSDParticle;
public class W11ReorderParametersCommand extends W11TopLevelElementCommand {
protected IParameter leftSibling;
@@ -31,6 +36,86 @@ public class W11ReorderParametersCommand extends W11TopLevelElementCommand {
}
public void execute() {
+ if (leftSibling instanceof W11ParameterForPart ||
+ rightSibling instanceof W11ParameterForPart ||
+ movingParameter instanceof W11ParameterForPart) {
+ executeForPart();
+ }
+ else if (leftSibling instanceof W11ParameterForElement ||
+ rightSibling instanceof W11ParameterForElement ||
+ movingParameter instanceof W11ParameterForElement) {
+ executeForElement();
+ }
+ else if (leftSibling instanceof W11ParameterForAttribute ||
+ rightSibling instanceof W11ParameterForAttribute ||
+ movingParameter instanceof W11ParameterForAttribute) {
+// executeForElement();
+ }
+ }
+
+ private void executeForElement() {
+ XSDElementDeclaration leftSibElement = null;
+ XSDElementDeclaration rightSibElement = null;
+ XSDElementDeclaration movingChild = null;
+
+ XSDParticle movingParticle = null;
+ XSDParticle leftParticle = null;
+ XSDParticle rightParticle = null;
+
+ if (leftSibling instanceof W11ParameterForElement) {
+ leftSibElement = (XSDElementDeclaration) ((W11ParameterForElement) leftSibling).getTarget();
+ leftParticle = (XSDParticle) leftSibElement.eContainer();
+ }
+ if (rightSibling instanceof W11ParameterForElement) {
+ rightSibElement = (XSDElementDeclaration) ((W11ParameterForElement) rightSibling).getTarget();
+ rightParticle = (XSDParticle) rightSibElement.eContainer();
+ }
+ if (movingParameter instanceof W11ParameterForElement) {
+ movingChild = (XSDElementDeclaration) ((W11ParameterForElement) movingParameter).getTarget();
+ movingParticle = (XSDParticle) movingChild.eContainer();
+ }
+
+ if (movingChild.equals(leftSibElement) || movingChild.equals(rightSibElement)) {
+ return;
+ }
+
+ if (movingChild != null) {
+ try {
+ beginRecording(movingParticle.getElement());
+
+ XSDModelGroup container = (XSDModelGroup) movingParticle.getContainer();
+ List particles = container.getContents();
+
+ particles.remove(movingParticle);
+
+ int leftIndex = -1, rightIndex = -1;
+ if (leftParticle != null) {
+ leftIndex = particles.indexOf(leftParticle);
+ }
+ if (rightParticle!= null) {
+ rightIndex = particles.indexOf(rightParticle);
+ }
+
+ if (leftIndex == -1) {
+ // Add moving child to the front
+ particles.add(0, movingParticle);
+ }
+ else if (rightIndex == -1) {
+ // Add moving child to the end
+ particles.add(movingParticle);
+ }
+ else {
+ // Add moving child after the occurence of the left sibling
+ particles.add(leftIndex + 1, movingParticle);
+ }
+ }
+ finally {
+ endRecording(movingParticle.getElement());
+ }
+ }
+ }
+
+ private void executeForPart() {
Part leftSibElement = null;
Part rightSibElement = null;
Part movingChild = null;

Back to the top