Author: koen.aers(a)jboss.com
Date: 2009-04-27 13:32:53 -0400 (Mon, 27 Apr 2009)
New Revision: 14940
Added:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
Removed:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddElementCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
Log:
- rename AddElementCommand and DeleteElementCommand to AddNodeCommand and
DeleteNodeCommand
- add AddChildCommand and DeleteChildCommand
Added:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -0,0 +1,32 @@
+package org.jboss.tools.flow.common.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class AddChildCommand extends Command {
+
+ private Wrapper child;
+ private Wrapper parent;
+ private Object type;
+
+ public void execute() {
+ parent.addChild(type, child);
+ }
+
+ public void setChild(Wrapper newChild) {
+ child = newChild;
+ }
+
+ public void setType(Object newType) {
+ type = newType;
+ }
+
+ public void setParent(Wrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.removeChild(type, child);
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddElementCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddElementCommand.java 2009-04-27
16:43:54 UTC (rev 14939)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddElementCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -1,63 +0,0 @@
-package org.jboss.tools.flow.common.command;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.eclipse.gef.commands.Command;
-import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
-import org.jboss.tools.flow.common.wrapper.NodeWrapper;
-
-/**
- * A command for adding an element.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class AddElementCommand extends Command {
-
- private NodeWrapper child;
- private ContainerWrapper parent;
-
- public void execute() {
- parent.addElement(child);
- child.setParent(parent);
- }
-
- protected ContainerWrapper getParent() {
- return parent;
- }
-
- protected NodeWrapper getChild() {
- return child;
- }
-
- public void setChild(NodeWrapper newChild) {
- child = newChild;
- }
-
- public void setParent(ContainerWrapper newParent) {
- parent = newParent;
- }
-
- public void undo() {
- parent.removeElement(child);
- child.setParent(null);
- }
-
- public boolean canExecute() {
- return parent.acceptsElement(child);
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
(from rev 14456,
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddElementCommand.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -0,0 +1,63 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for adding an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class AddNodeCommand extends Command {
+
+ private NodeWrapper child;
+ private ContainerWrapper parent;
+
+ public void execute() {
+ parent.addElement(child);
+ child.setParent(parent);
+ }
+
+ protected ContainerWrapper getParent() {
+ return parent;
+ }
+
+ protected NodeWrapper getChild() {
+ return child;
+ }
+
+ public void setChild(NodeWrapper newChild) {
+ child = newChild;
+ }
+
+ public void setParent(ContainerWrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.removeElement(child);
+ child.setParent(null);
+ }
+
+ public boolean canExecute() {
+ return parent.acceptsElement(child);
+ }
+
+}
Added:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -0,0 +1,36 @@
+package org.jboss.tools.flow.common.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class DeleteChildCommand extends Command {
+
+ private Wrapper child;
+ private Wrapper parent;
+ private Object type;
+
+ public void execute() {
+ parent.removeChild(type, child);
+ }
+
+ public void setChild(Wrapper newChild) {
+ child = newChild;
+ }
+
+ public void setType(Object newType) {
+ type = newType;
+ }
+
+ public void setParent(Wrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.addChild(type, child);
+ }
+
+ public boolean canExecute() {
+ return child != null && parent != null && type != null;
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java 2009-04-27
16:43:54 UTC (rev 14939)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -1,130 +0,0 @@
-package org.jboss.tools.flow.common.command;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.gef.commands.Command;
-import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
-import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
-import org.jboss.tools.flow.common.wrapper.NodeWrapper;
-
-/**
- * A command for deleting an element.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class DeleteElementCommand extends Command {
-
- private NodeWrapper child;
- private ContainerWrapper parent;
-
- private List<DeleteElementCommand> embeddedCommands;
-
- private List<NodeWrapper> incomingElementWrappers = new
ArrayList<NodeWrapper>();
- private List<NodeWrapper> outgoingElementWrappers = new
ArrayList<NodeWrapper>();
- private List<ConnectionWrapper> incomingConnections = new
ArrayList<ConnectionWrapper>();
- private List<ConnectionWrapper> outgoingConnections = new
ArrayList<ConnectionWrapper>();
-
-
- private void deleteConnections(NodeWrapper element) {
- for (ConnectionWrapper connection: element.getIncomingConnections()) {
- incomingElementWrappers.add(connection.getSource());
- incomingConnections.add(connection);
- }
- for (ConnectionWrapper connection: element.getOutgoingConnections()) {
- outgoingElementWrappers.add(connection.getTarget());
- outgoingConnections.add(connection);
- }
- for (ConnectionWrapper connection: incomingConnections) {
- connection.disconnect();
- }
- for (ConnectionWrapper connection: outgoingConnections) {
- connection.disconnect();
- }
- }
-
- private void initializeEmbeddedCommands() {
- embeddedCommands = new ArrayList<DeleteElementCommand>();
- ContainerWrapper container = (ContainerWrapper)child;
- List<NodeWrapper> children = container.getNodeWrappers();
- for (NodeWrapper w : children) {
- DeleteElementCommand c = new DeleteElementCommand();
- c.setParent(container);
- c.setChild(w);
- embeddedCommands.add(c);
- }
- }
-
- private void executeEmbeddedCommands() {
- if (embeddedCommands == null) {
- initializeEmbeddedCommands();
- }
- for (DeleteElementCommand c : embeddedCommands) {
- c.execute();
- }
- }
-
- public void execute() {
- if (child instanceof ContainerWrapper) {
- executeEmbeddedCommands();
- }
- deleteConnections(child);
- parent.removeElement(child);
- }
-
- private void restoreConnections() {
- int i = 0;
- for (ConnectionWrapper connection: incomingConnections) {
- connection.connect((NodeWrapper) incomingElementWrappers.get(i), child);
- i++;
- }
- i = 0;
- for (ConnectionWrapper connection: outgoingConnections) {
- connection.connect(child, (NodeWrapper) outgoingElementWrappers.get(i));
- i++;
- }
- incomingConnections.clear();
- incomingElementWrappers.clear();
- outgoingConnections.clear();
- outgoingElementWrappers.clear();
- }
-
- public void setChild(NodeWrapper child) {
- this.child = child;
- }
-
- public void setParent(ContainerWrapper parent) {
- this.parent = parent;
- }
-
- private void undoEmbeddedCommands() {
- for (DeleteElementCommand c : embeddedCommands) {
- c.undo();
- }
- }
-
- public void undo() {
- parent.addElement(child);
- restoreConnections();
- if (child instanceof ContainerWrapper) {
- undoEmbeddedCommands();
- }
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
(from rev 14839,
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -0,0 +1,130 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for deleting an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class DeleteNodeCommand extends Command {
+
+ private NodeWrapper child;
+ private ContainerWrapper parent;
+
+ private List<DeleteNodeCommand> embeddedCommands;
+
+ private List<NodeWrapper> incomingElementWrappers = new
ArrayList<NodeWrapper>();
+ private List<NodeWrapper> outgoingElementWrappers = new
ArrayList<NodeWrapper>();
+ private List<ConnectionWrapper> incomingConnections = new
ArrayList<ConnectionWrapper>();
+ private List<ConnectionWrapper> outgoingConnections = new
ArrayList<ConnectionWrapper>();
+
+
+ private void deleteConnections(NodeWrapper element) {
+ for (ConnectionWrapper connection: element.getIncomingConnections()) {
+ incomingElementWrappers.add(connection.getSource());
+ incomingConnections.add(connection);
+ }
+ for (ConnectionWrapper connection: element.getOutgoingConnections()) {
+ outgoingElementWrappers.add(connection.getTarget());
+ outgoingConnections.add(connection);
+ }
+ for (ConnectionWrapper connection: incomingConnections) {
+ connection.disconnect();
+ }
+ for (ConnectionWrapper connection: outgoingConnections) {
+ connection.disconnect();
+ }
+ }
+
+ private void initializeEmbeddedCommands() {
+ embeddedCommands = new ArrayList<DeleteNodeCommand>();
+ ContainerWrapper container = (ContainerWrapper)child;
+ List<NodeWrapper> children = container.getNodeWrappers();
+ for (NodeWrapper w : children) {
+ DeleteNodeCommand c = new DeleteNodeCommand();
+ c.setParent(container);
+ c.setChild(w);
+ embeddedCommands.add(c);
+ }
+ }
+
+ private void executeEmbeddedCommands() {
+ if (embeddedCommands == null) {
+ initializeEmbeddedCommands();
+ }
+ for (DeleteNodeCommand c : embeddedCommands) {
+ c.execute();
+ }
+ }
+
+ public void execute() {
+ if (child instanceof ContainerWrapper) {
+ executeEmbeddedCommands();
+ }
+ deleteConnections(child);
+ parent.removeElement(child);
+ }
+
+ private void restoreConnections() {
+ int i = 0;
+ for (ConnectionWrapper connection: incomingConnections) {
+ connection.connect((NodeWrapper) incomingElementWrappers.get(i), child);
+ i++;
+ }
+ i = 0;
+ for (ConnectionWrapper connection: outgoingConnections) {
+ connection.connect(child, (NodeWrapper) outgoingElementWrappers.get(i));
+ i++;
+ }
+ incomingConnections.clear();
+ incomingElementWrappers.clear();
+ outgoingConnections.clear();
+ outgoingElementWrappers.clear();
+ }
+
+ public void setChild(NodeWrapper child) {
+ this.child = child;
+ }
+
+ public void setParent(ContainerWrapper parent) {
+ this.parent = parent;
+ }
+
+ private void undoEmbeddedCommands() {
+ for (DeleteNodeCommand c : embeddedCommands) {
+ c.undo();
+ }
+ }
+
+ public void undo() {
+ parent.addElement(child);
+ restoreConnections();
+ if (child instanceof ContainerWrapper) {
+ undoEmbeddedCommands();
+ }
+ }
+
+}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java 2009-04-27
16:43:54 UTC (rev 14939)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -22,7 +22,7 @@
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
-import org.jboss.tools.flow.common.command.AddElementCommand;
+import org.jboss.tools.flow.common.command.AddNodeCommand;
import org.jboss.tools.flow.common.command.ChangeConstraintCommand;
import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
import org.jboss.tools.flow.common.wrapper.NodeWrapper;
@@ -35,7 +35,7 @@
public class ElementContainerLayoutEditPolicy extends XYLayoutEditPolicy {
protected Command getCreateCommand(CreateRequest request) {
- AddElementCommand command = new AddElementCommand();
+ AddNodeCommand command = new AddNodeCommand();
command.setParent((ContainerWrapper) getHost().getModel());
NodeWrapper element = (NodeWrapper) request.getNewObject();
element.setConstraint((Rectangle) getConstraintFor(request));
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java 2009-04-27
16:43:54 UTC (rev 14939)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java 2009-04-27
17:32:53 UTC (rev 14940)
@@ -19,7 +19,7 @@
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
-import org.jboss.tools.flow.common.command.DeleteElementCommand;
+import org.jboss.tools.flow.common.command.DeleteNodeCommand;
import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
import org.jboss.tools.flow.common.wrapper.NodeWrapper;
@@ -32,7 +32,7 @@
protected Command createDeleteCommand(GroupRequest deleteRequest) {
ContainerWrapper parent = (ContainerWrapper) getHost().getParent().getModel();
- DeleteElementCommand deleteCmd = new DeleteElementCommand();
+ DeleteNodeCommand deleteCmd = new DeleteNodeCommand();
deleteCmd.setParent(parent);
deleteCmd.setChild((NodeWrapper) (getHost().getModel()));
return deleteCmd;