Author: koen.aers(a)jboss.com
Date: 2008-07-30 10:10:54 -0400 (Wed, 30 Jul 2008)
New Revision: 9431
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processH.gif
trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processV.gif
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/Activator.java
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
Removed:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/connection.gif
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java
Log:
generalized the auto layout actions
Modified: trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF 2008-07-30
12:59:36 UTC (rev 9430)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF 2008-07-30
14:10:54 UTC (rev 9431)
@@ -3,7 +3,7 @@
Bundle-Name: JBoss Tools Process Plug-in
Bundle-SymbolicName: org.jboss.tools.flow.common.graph;singleton:=true
Bundle-Version: 1.0.0
-Bundle-Activator: org.jboss.tools.flow.JBossToolsProcessPlugin
+Bundle-Activator: org.jboss.tools.flow.Activator
Bundle-Vendor: JBoss
Require-Bundle:
org.jboss.tools.flow.common.core;bundle-version="1.0.0",
Deleted: trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/connection.gif
===================================================================
(Binary files differ)
Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processH.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processH.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processV.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/processV.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/Activator.java
(from rev 9374,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/Activator.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/Activator.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -0,0 +1,64 @@
+package org.jboss.tools.flow;
+
+/*
+ * 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.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen
</a>
+ */
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.process";
+
+ private static Activator plugin;
+
+ public Activator() {
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ private static String getUniqueIdentifier() {
+ if (getDefault() == null ) {
+ return PLUGIN_ID;
+ }
+ return getDefault().getBundle().getSymbolicName();
+ }
+
+ public static void log(Throwable t) {
+ log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
+ "Internal error in JBoss Tools Process Plugin: ", t));
+ }
+
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+}
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java 2008-07-30
12:59:36 UTC (rev 9430)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -1,64 +0,0 @@
-package org.jboss.tools.flow;
-
-/*
- * 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.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen
</a>
- */
-public class JBossToolsProcessPlugin extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID = "org.jboss.tools.process";
-
- private static JBossToolsProcessPlugin plugin;
-
- public JBossToolsProcessPlugin() {
- plugin = this;
- }
-
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- }
-
- public static JBossToolsProcessPlugin getDefault() {
- return plugin;
- }
-
- private static String getUniqueIdentifier() {
- if (getDefault() == null ) {
- return PLUGIN_ID;
- }
- return getDefault().getBundle().getSymbolicName();
- }
-
- public static void log(Throwable t) {
- log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
- "Internal error in JBoss Tools Process Plugin: ", t));
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
-}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java 2008-07-30
12:59:36 UTC (rev 9430)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -30,6 +30,8 @@
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
+import org.jboss.tools.flow.editor.action.HorizontalAutoLayoutAction;
+import org.jboss.tools.flow.editor.action.VerticalAutoLayoutAction;
/**
* Common implementation of a ActionBarContributor.
@@ -55,6 +57,9 @@
addRetargetAction( new RetargetAction(
GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid" ));
+
+ addRetargetAction( new RetargetAction(VerticalAutoLayoutAction.ID, null));
+ addRetargetAction( new RetargetAction(HorizontalAutoLayoutAction.ID, null));
}
public void contributeToToolBar(IToolBarManager toolBarManager) {
@@ -76,6 +81,10 @@
toolBarManager.add( new Separator() );
toolBarManager.add( getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY) );
+
+ toolBarManager.add( new Separator());
+ toolBarManager.add( getAction(VerticalAutoLayoutAction.ID));
+ toolBarManager.add( getAction(HorizontalAutoLayoutAction.ID));
}
protected void declareGlobalActionKeys() {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java 2008-07-30
12:59:36 UTC (rev 9430)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -68,7 +68,9 @@
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.jboss.tools.flow.JBossToolsProcessPlugin;
+import org.jboss.tools.flow.Activator;
+import org.jboss.tools.flow.editor.action.HorizontalAutoLayoutAction;
+import org.jboss.tools.flow.editor.action.VerticalAutoLayoutAction;
/**
* Abstract implementation of a graphical editor.
@@ -160,11 +162,17 @@
IAction showGrid = new ToggleGridAction(getGraphicalViewer());
getActionRegistry().registerAction(showGrid);
+
+ IAction layoutVertically = new VerticalAutoLayoutAction(getGraphicalViewer());
+ getActionRegistry().registerAction(layoutVertically);
+ IAction layoutHorizontally = new HorizontalAutoLayoutAction(getGraphicalViewer());
+ getActionRegistry().registerAction(layoutHorizontally);
+
ContextMenuProvider provider = new GenericContextMenuProvider(
getGraphicalViewer(), getActionRegistry());
getGraphicalViewer().setContextMenu(provider);
- getSite().registerContextMenu("org.drools.eclipse.flow.editor.contextmenu",
+ getSite().registerContextMenu("org.jboss.tools.flow.editor.contextmenu",
provider, getGraphicalViewer());
}
@@ -279,7 +287,7 @@
InputStream is = file.getContents(false);
createModel(is);
} catch (Throwable t) {
- JBossToolsProcessPlugin.log(t);
+ Activator.log(t);
}
if (getGraphicalViewer() != null) {
initializeGraphicalViewer();
@@ -350,7 +358,7 @@
imageLoader.data = new ImageData[] { image.getImageData() };
imageLoader.save(stream, format);
} catch (Throwable t) {
- JBossToolsProcessPlugin.log(t);
+ Activator.log(t);
} finally {
if (g != null) {
g.dispose();
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java 2008-07-30
12:59:36 UTC (rev 9430)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -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 <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class HorizontalAutoLayoutAction extends VerticalAutoLayoutAction {
-
- protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
- DirectedGraph graph = super.createDirectedGraph(mapping);
- graph.setDirection(PositionConstants.HORIZONTAL);
- return graph;
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutActionDelegate.java
(from rev 9375,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutActionDelegate.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutActionDelegate.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -0,0 +1,38 @@
+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 <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class HorizontalAutoLayoutActionDelegate extends VerticalAutoLayoutActionDelegate
{
+
+ protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+ DirectedGraph graph = super.createDirectedGraph(mapping);
+ graph.setDirection(PositionConstants.HORIZONTAL);
+ return graph;
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutActionDelegate.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java 2008-07-30
12:59:36 UTC (rev 9430)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -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 <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class VerticalAutoLayoutAction extends ActionDelegate implements
IEditorActionDelegate {
-
- private IEditorPart editor;
-
- public void run(IAction action) {
- execute();
- }
-
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- editor = targetEditor;
- }
-
- private void execute() {
- editor.doSave(null);
- Map<String, Node> mapping = new HashMap<String, Node>();
- DirectedGraph graph = createDirectedGraph(mapping);
- DirectedGraphLayout layout = new DirectedGraphLayout();
- layout.visit(graph);
- for (Map.Entry<String, Node> entry: mapping.entrySet()) {
- Node node = entry.getValue();
- NodeWrapper nodeWrapper =
- ((AbstractFlowWrapper) ((GenericModelEditor)
editor).getModel()).getElement(entry.getKey());
- nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.width,
node.height));
- }
- // TODO: implement changes as a command, so we can support undo
- editor.doSave(null);
- }
-
- @SuppressWarnings("unchecked")
- protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
- DirectedGraph graph = new DirectedGraph();
- AbstractFlowWrapper processWrapper = (AbstractFlowWrapper) ((GenericModelEditor)
editor).getModel();
- for (NodeWrapper elementWrapper: processWrapper.getElements()) {
- Node node = new Node();
- Integer width = (Integer) elementWrapper.getConstraint().width;
- Integer height = (Integer) elementWrapper.getConstraint().height;
- if (width == null || width <= 0) {
- width = 80;
- }
- if (height == null || height <= 0) {
- height = 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.getIncomingConnections()) {
- Node source = mapping.get(connection.getSource().getId());
- Node target = mapping.get(connection.getTarget().getId());
- graph.edges.add(new Edge(source, target));
- }
- }
- return graph;
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutActionDelegate.java
(from rev 9396,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutActionDelegate.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutActionDelegate.java 2008-07-30
14:10:54 UTC (rev 9431)
@@ -0,0 +1,98 @@
+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 <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class VerticalAutoLayoutActionDelegate extends ActionDelegate implements
IEditorActionDelegate {
+
+ private IEditorPart editor;
+
+ public void run(IAction action) {
+ execute();
+ }
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ editor = targetEditor;
+ }
+
+ private void execute() {
+ editor.doSave(null);
+ Map<String, Node> mapping = new HashMap<String, Node>();
+ DirectedGraph graph = createDirectedGraph(mapping);
+ DirectedGraphLayout layout = new DirectedGraphLayout();
+ layout.visit(graph);
+ for (Map.Entry<String, Node> entry: mapping.entrySet()) {
+ Node node = entry.getValue();
+ NodeWrapper nodeWrapper =
+ ((AbstractFlowWrapper) ((GenericModelEditor)
editor).getModel()).getElement(entry.getKey());
+ nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.width,
node.height));
+ }
+ // TODO: implement changes as a command, so we can support undo
+ editor.doSave(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+ DirectedGraph graph = new DirectedGraph();
+ AbstractFlowWrapper processWrapper = (AbstractFlowWrapper) ((GenericModelEditor)
editor).getModel();
+ for (NodeWrapper elementWrapper: processWrapper.getElements()) {
+ Node node = new Node();
+ Integer width = (Integer) elementWrapper.getConstraint().width;
+ Integer height = (Integer) elementWrapper.getConstraint().height;
+ if (width == null || width <= 0) {
+ width = 80;
+ }
+ if (height == null || height <= 0) {
+ height = 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.getIncomingConnections()) {
+ Node source = mapping.get(connection.getSource().getId());
+ Node target = mapping.get(connection.getTarget().getId());
+ graph.edges.add(new Edge(source, target));
+ }
+ }
+ return graph;
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutActionDelegate.java
___________________________________________________________________
Name: svn:mergeinfo
+