From jbosstools-commits at lists.jboss.org Wed Jul 30 10:12:13 2008 Content-Type: multipart/mixed; boundary="===============6106268432616400464==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r9433 - trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action. Date: Wed, 30 Jul 2008 10:12:13 -0400 Message-ID: --===============6106268432616400464== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: koen.aers(a)jboss.com Date: 2008-07-30 10:12:13 -0400 (Wed, 30 Jul 2008) New Revision: 9433 Removed: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools= /flow/editor/action/HorizontalAutoLayoutActionDelegate.java trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools= /flow/editor/action/VerticalAutoLayoutActionDelegate.java Log: generalized the auto layout actions Deleted: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss= /tools/flow/editor/action/HorizontalAutoLayoutActionDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tool= s/flow/editor/action/HorizontalAutoLayoutActionDelegate.java 2008-07-30 14:= 11:21 UTC (rev 9432) +++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tool= s/flow/editor/action/HorizontalAutoLayoutActionDelegate.java 2008-07-30 14:= 12:13 UTC (rev 9433) @@ -1,38 +0,0 @@ -package org.jboss.tools.flow.editor.action; - -/* - * 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.Map; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.graph.DirectedGraph; -import org.eclipse.draw2d.graph.Node; - -/** - * Action for auto layouting a process. - * = - * @author Kris Verlaenen<= /a> - */ -public class HorizontalAutoLayoutActionDelegate extends VerticalAutoLayout= ActionDelegate { - - protected DirectedGraph createDirectedGraph(Map mapping)= { - DirectedGraph graph =3D super.createDirectedGraph(mapping); - graph.setDirection(PositionConstants.HORIZONTAL); - return graph; - } - -} Deleted: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss= /tools/flow/editor/action/VerticalAutoLayoutActionDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tool= s/flow/editor/action/VerticalAutoLayoutActionDelegate.java 2008-07-30 14:11= :21 UTC (rev 9432) +++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tool= s/flow/editor/action/VerticalAutoLayoutActionDelegate.java 2008-07-30 14:12= :13 UTC (rev 9433) @@ -1,98 +0,0 @@ -package org.jboss.tools.flow.editor.action; - -/* - * 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.HashMap; -import java.util.Map; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.graph.DirectedGraph; -import org.eclipse.draw2d.graph.DirectedGraphLayout; -import org.eclipse.draw2d.graph.Edge; -import org.eclipse.draw2d.graph.Node; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionDelegate; -import org.jboss.tools.flow.editor.GenericModelEditor; -import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper; -import org.jboss.tools.flow.editor.core.AbstractFlowWrapper; -import org.jboss.tools.flow.editor.core.NodeWrapper; - -/** - * Action for auto layouting a process. - * = - * @author Kris Verlaenen<= /a> - */ -public class VerticalAutoLayoutActionDelegate extends ActionDelegate imple= ments IEditorActionDelegate { - - private IEditorPart editor; - = - public void run(IAction action) { - execute(); - } - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - editor =3D targetEditor; - } - - private void execute() { - editor.doSave(null); - Map mapping =3D new HashMap(); - DirectedGraph graph =3D createDirectedGraph(mapping); - DirectedGraphLayout layout =3D new DirectedGraphLayout(); - layout.visit(graph); - for (Map.Entry entry: mapping.entrySet()) { - Node node =3D entry.getValue(); - NodeWrapper nodeWrapper =3D - ((AbstractFlowWrapper) ((GenericModelEditor) editor).getMo= del()).getElement(entry.getKey()); - nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.w= idth, node.height)); - } - // TODO: implement changes as a command, so we can support undo - editor.doSave(null); - } - = - @SuppressWarnings("unchecked") - protected DirectedGraph createDirectedGraph(Map mapping)= { - DirectedGraph graph =3D new DirectedGraph(); - AbstractFlowWrapper processWrapper =3D (AbstractFlowWrapper) ((Gen= ericModelEditor) editor).getModel(); - for (NodeWrapper elementWrapper: processWrapper.getElements()) { - Node node =3D new Node(); - Integer width =3D (Integer) elementWrapper.getConstraint().wid= th; - Integer height =3D (Integer) elementWrapper.getConstraint().he= ight; - if (width =3D=3D null || width <=3D 0) { - width =3D 80; - } - if (height =3D=3D null || height <=3D 0) { - height =3D 40; - } - node.setSize(new Dimension(width, height)); - graph.nodes.add(node); - mapping.put(elementWrapper.getId(), node); - } - for (NodeWrapper elementWrapper: processWrapper.getElements()) { - for (AbstractConnectionWrapper connection: elementWrapper.getI= ncomingConnections()) { - Node source =3D mapping.get(connection.getSource().getId()= ); - Node target =3D mapping.get(connection.getTarget().getId()= ); - graph.edges.add(new Edge(source, target)); - } - } - return graph; - } - -} --===============6106268432616400464==--