Author: koen.aers(a)jboss.com
Date: 2008-07-29 05:44:40 -0400 (Tue, 29 Jul 2008)
New Revision: 9374
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/
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/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
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/GenericContextMenuProvider.java
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/OverviewOutlinePage.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/PaletteFactory.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/figure/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy/
Removed:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath
Log:
changed source and output folders
Modified: trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath 2008-07-29 09:41:25
UTC (rev 9373)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath 2008-07-29 09:44:40
UTC (rev 9374)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/JBossToolsProcessPlugin.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -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 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);
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/JBossToolsProcessPlugin.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,147 @@
+package org.jboss.tools.flow.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class DropDownMenuWithDefaultAction extends Action implements IMenuCreator {
+
+ private Menu dropDownMenu;
+ private IAction delegate;
+ private List<Object> list;
+ private IPropertyChangeListener enabledListener;
+ private SelectionListener selectionListener;
+
+ public DropDownMenuWithDefaultAction(final IAction action) {
+ this.selectionListener = new ItemSelectionListener(this);
+ setMenuCreator(this);
+ this.dropDownMenu = null;
+ setAction(action);
+ this.list = new ArrayList<Object>();
+ }
+
+ public void dispose() {
+ if (this.dropDownMenu != null) {
+ this.dropDownMenu.dispose();
+ this.dropDownMenu = null;
+ }
+ }
+
+ public void add(final IContributionItem item) {
+ this.list.add(item);
+ }
+
+ public void add(final IAction action) {
+ this.list.add(action);
+ }
+
+ public Menu getMenu(final Control parent) {
+ if (this.dropDownMenu == null) {
+ this.dropDownMenu = new Menu(parent);
+ populateMenu();
+ }
+ return this.dropDownMenu;
+ }
+
+ public Menu getMenu(final Menu parent) {
+ if (this.dropDownMenu == null) {
+ this.dropDownMenu = new Menu(parent);
+ populateMenu();
+ }
+ return this.dropDownMenu;
+ }
+
+ private void populateMenu() {
+ for (Object object: list) {
+ if (object instanceof IContributionItem) {
+ final IContributionItem item = (IContributionItem) object;
+ item.fill(this.dropDownMenu, -1);
+ } else {
+ final IAction action = (IAction) object;
+ final ActionContributionItem item = new ActionContributionItem(action);
+ item.fill(this.dropDownMenu, -1);
+ }
+ }
+ final MenuItem[] items = this.dropDownMenu.getItems();
+ for (int i = 0; i < items.length; i++) {
+ items[i].addSelectionListener(this.selectionListener);
+ }
+ }
+
+ public void setAction(final IAction action) {
+ if (this.enabledListener == null) {
+ this.enabledListener = new EnabledPropertyChangeListener(this);
+ }
+ setText(action.getText());
+ setToolTipText(action.getToolTipText());
+ setImageDescriptor(action.getImageDescriptor());
+ setDisabledImageDescriptor(action.getDisabledImageDescriptor());
+ setEnabled(action.isEnabled());
+ setDescription(action.getDescription());
+ setHelpListener(action.getHelpListener());
+ setHoverImageDescriptor(action.getHoverImageDescriptor());
+ if (this.delegate != null) {
+ this.delegate.removePropertyChangeListener(this.enabledListener);
+ }
+ this.delegate = action;
+ this.delegate.addPropertyChangeListener(this.enabledListener);
+ }
+
+ public void run() {
+ this.delegate.run();
+ }
+
+ public static class EnabledPropertyChangeListener implements IPropertyChangeListener
{
+ private IAction action;
+
+ public EnabledPropertyChangeListener(final IAction action) {
+ this.action = action;
+ }
+
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ this.action.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ public static class ItemSelectionListener implements SelectionListener {
+ private DropDownMenuWithDefaultAction dropDownMenu;
+
+ public ItemSelectionListener(
+ final DropDownMenuWithDefaultAction dropDownMenu) {
+ this.dropDownMenu = dropDownMenu;
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ final MenuItem menuItem = (MenuItem) e.getSource();
+ if (menuItem.getData() instanceof ActionContributionItem) {
+ final ActionContributionItem item = (ActionContributionItem) menuItem
+ .getData();
+ this.dropDownMenu.setAction(item.getAction());
+ }
+ }
+
+ public void widgetSelected(final SelectionEvent e) {
+ final MenuItem menuItem = (MenuItem) e.getSource();
+ if (menuItem.getData() instanceof ActionContributionItem) {
+ final ActionContributionItem item = (ActionContributionItem) menuItem
+ .getData();
+ this.dropDownMenu.setAction(item.getAction());
+ }
+ }
+ }
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericActionBarContributor.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,83 @@
+package org.jboss.tools.flow.editor;
+
+/*
+ * 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.draw2d.PositionConstants;
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.AlignmentRetargetAction;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.RetargetAction;
+
+/**
+ * Common implementation of a ActionBarContributor.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class GenericActionBarContributor extends ActionBarContributor {
+
+ protected void buildActions() {
+ addRetargetAction( new UndoRetargetAction() );
+ addRetargetAction( new RedoRetargetAction() );
+ addRetargetAction( new DeleteRetargetAction() );
+
+ addRetargetAction( new ZoomInRetargetAction() );
+ addRetargetAction( new ZoomOutRetargetAction() );
+
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.LEFT ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.CENTER ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.RIGHT ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.TOP ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.MIDDLE ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.BOTTOM ) );
+
+ addRetargetAction( new RetargetAction(
+ GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid" ));
+ }
+
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add( getAction( ActionFactory.UNDO.getId() ) );
+ toolBarManager.add( getAction( ActionFactory.REDO.getId() ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( new ZoomComboContributionItem( getPage() ) );
+ toolBarManager.add( new Separator() );
+
+ DropDownMenuWithDefaultAction alignMenu = new DropDownMenuWithDefaultAction(
getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_CENTER )
);
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_RIGHT )
);
+ alignMenu.add( new Separator() );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_TOP ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_MIDDLE )
);
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_BOTTOM )
);
+ toolBarManager.add( alignMenu );
+
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY) );
+ }
+
+ protected void declareGlobalActionKeys() {
+ }
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericActionBarContributor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericContextMenuProvider.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericContextMenuProvider.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericContextMenuProvider.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericContextMenuProvider.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,61 @@
+package org.jboss.tools.flow.editor;
+
+/*
+ * 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.ContextMenuProvider;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * Common implementation of a ContextMenuProvider.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class GenericContextMenuProvider extends ContextMenuProvider {
+
+ private ActionRegistry actionRegistry;
+
+ public GenericContextMenuProvider(GraphicalViewer viewer, ActionRegistry registry) {
+ super(viewer);
+ setActionRegistry(registry);
+ }
+
+ public void buildContextMenu(IMenuManager menu) {
+ GEFActionConstants.addStandardActionGroups(menu);
+ IAction action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
+ menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+ action = getActionRegistry().getAction(ActionFactory.REDO.getId());
+ menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+ action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
+ if (action.isEnabled()) {
+ menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ }
+ }
+
+ private ActionRegistry getActionRegistry() {
+ return actionRegistry;
+ }
+
+ public void setActionRegistry(ActionRegistry registry) {
+ actionRegistry = registry;
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericContextMenuProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericModelEditor.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,366 @@
+package org.jboss.tools.flow.editor;
+
+/*
+ * 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.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.EventObject;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.LayerManager;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.AlignmentAction;
+import org.eclipse.gef.ui.actions.DirectEditAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.ToggleGridAction;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+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;
+
+/**
+ * Abstract implementation of a graphical editor.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class GenericModelEditor extends GraphicalEditorWithPalette {
+
+ private Object model;
+ private boolean savePreviouslyNeeded = false;
+ private KeyHandler sharedKeyHandler;
+ private PaletteRoot root;
+ private OverviewOutlinePage overviewOutlinePage;
+
+ public GenericModelEditor() {
+ setEditDomain(new DefaultEditDomain(this));
+ }
+
+ protected void setModel(Object model) {
+ this.model = model;
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createActions() {
+ super.createActions();
+ ActionRegistry registry = getActionRegistry();
+
+ IAction action = new DirectEditAction((IWorkbenchPart) this);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.LEFT);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.CENTER);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.RIGHT);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.TOP);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.MIDDLE);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.BOTTOM);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+ }
+
+ public void commandStackChanged(EventObject event) {
+ if (isDirty()) {
+ if (!savePreviouslyNeeded()) {
+ setSavePreviouslyNeeded(true);
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ } else {
+ setSavePreviouslyNeeded(false);
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ super.commandStackChanged(event);
+ }
+
+ protected abstract void writeModel(OutputStream os) throws IOException;
+
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ getGraphicalViewer().setRootEditPart(new ScalableRootEditPart());
+ getGraphicalViewer().setEditPartFactory(createEditPartFactory());
+ getGraphicalViewer().setKeyHandler(
+ new GraphicalViewerKeyHandler(getGraphicalViewer())
+ .setParent(getCommonKeyHandler()));
+
+ IAction showGrid = new ToggleGridAction(getGraphicalViewer());
+ getActionRegistry().registerAction(showGrid);
+
+ ContextMenuProvider provider = new GenericContextMenuProvider(
+ getGraphicalViewer(), getActionRegistry());
+ getGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu("org.drools.eclipse.flow.editor.contextmenu",
+ provider, getGraphicalViewer());
+ }
+
+ protected abstract EditPartFactory createEditPartFactory();
+
+ protected void initializeGraphicalViewer() {
+ getGraphicalViewer().setContents(model);
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writeModel(out);
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ file.setContents(new ByteArrayInputStream(out.toByteArray()), true,
+ false, monitor);
+ out.close();
+ getCommandStack().markSaveLocation();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void doSaveAs() {
+ SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow()
+ .getShell());
+ dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
+ dialog.open();
+ IPath path = dialog.getResult();
+
+ if (path == null) {
+ return;
+ }
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IFile file = workspace.getRoot().getFile(path);
+
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ public void execute(final IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writeModel(out);
+ file.create(new ByteArrayInputStream(out.toByteArray()),
+ true, monitor);
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ try {
+ new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
+ .run(false, true, op);
+ setInput(new FileEditorInput(file));
+ getCommandStack().markSaveLocation();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected KeyHandler getCommonKeyHandler() {
+ if (sharedKeyHandler == null) {
+ sharedKeyHandler = new KeyHandler();
+ sharedKeyHandler
+ .put(KeyStroke.getPressed(SWT.DEL, 127, 0),
+ getActionRegistry().getAction(
+ ActionFactory.DELETE.getId()));
+ sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
+ getActionRegistry().getAction(
+ GEFActionConstants.DIRECT_EDIT));
+ }
+ return sharedKeyHandler;
+ }
+
+ public boolean isDirty() {
+ return isSaveOnCloseNeeded();
+ }
+
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ public boolean isSaveOnCloseNeeded() {
+ return getCommandStack().isDirty();
+ }
+
+ private boolean savePreviouslyNeeded() {
+ return savePreviouslyNeeded;
+ }
+
+ private void setSavePreviouslyNeeded(boolean value) {
+ savePreviouslyNeeded = value;
+ }
+
+ protected PaletteRoot getPaletteRoot() {
+ if (root == null) {
+ root = createPalette();
+ }
+ return root;
+ }
+
+ protected abstract PaletteRoot createPalette();
+
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
+
+ IFile file = getFile();
+ setPartName(file.getName());
+ try {
+ InputStream is = file.getContents(false);
+ createModel(is);
+ } catch (Throwable t) {
+ JBossToolsProcessPlugin.log(t);
+ }
+ if (getGraphicalViewer() != null) {
+ initializeGraphicalViewer();
+ }
+ }
+
+ public IFile getFile() {
+ return ((IFileEditorInput) getEditorInput()).getFile();
+ }
+
+ public IProject getProject() {
+ IFile file = getFile();
+ if (file != null) {
+ return file.getProject();
+ }
+ return null;
+ }
+
+ protected abstract void createModel(InputStream is);
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class type) {
+ if (type == IContentOutlinePage.class) {
+ return getOverviewOutlinePage();
+ }
+ if (type == ZoomManager.class) {
+ return ((ScalableRootEditPart) getGraphicalViewer()
+ .getRootEditPart()).getZoomManager();
+ }
+ return super.getAdapter(type);
+ }
+
+ protected OverviewOutlinePage getOverviewOutlinePage() {
+ if (null == overviewOutlinePage && null != getGraphicalViewer()) {
+ ScalableRootEditPart rootEditPart = (ScalableRootEditPart) getGraphicalViewer()
+ .getRootEditPart();
+ overviewOutlinePage = new OverviewOutlinePage(rootEditPart);
+ }
+ return overviewOutlinePage;
+ }
+
+ public String getContributorId() {
+ return getSite().getId();
+ }
+
+ /**
+ * Writes the content of this editor to the given stream.
+ * Possible formats are for example SWT.IMAGE_BMP, IMAGE_GIF,
+ * IMAGE_JPEG, IMAGE_PNG.
+ * @param stream
+ * @param format
+ */
+ public void createImage(OutputStream stream, int format) {
+ SWTGraphics g = null;
+ GC gc = null;
+ Image image = null;
+ LayerManager layerManager = (LayerManager)
+ getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
+ IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
+ Rectangle r = figure.getBounds();
+ try {
+ image = new Image(Display.getDefault(), r.width, r.height);
+ gc = new GC(image);
+ g = new SWTGraphics(gc);
+ g.translate(r.x * -1, r.y * -1);
+ figure.paint(g);
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[] { image.getImageData() };
+ imageLoader.save(stream, format);
+ } catch (Throwable t) {
+ JBossToolsProcessPlugin.log(t);
+ } finally {
+ if (g != null) {
+ g.dispose();
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+ if (image != null) {
+ image.dispose();
+ }
+ }
+ }
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/GenericModelEditor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/OverviewOutlinePage.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/OverviewOutlinePage.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/OverviewOutlinePage.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/OverviewOutlinePage.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,91 @@
+package org.jboss.tools.flow.editor;
+
+/*
+ * 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.draw2d.LightweightSystem;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.parts.ScrollableThumbnail;
+import org.eclipse.draw2d.parts.Thumbnail;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Common implementation of an outline page.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class OverviewOutlinePage extends Page implements IContentOutlinePage {
+
+ private Canvas overview;
+ private ScalableRootEditPart rootEditPart;
+ private Thumbnail thumbnail;
+
+ public OverviewOutlinePage(ScalableRootEditPart rootEditPart) {
+ this.rootEditPart = rootEditPart;
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+
+ public void createControl(Composite parent) {
+ overview = new Canvas(parent, SWT.NONE);
+ LightweightSystem lws = new LightweightSystem(overview);
+ thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
+ thumbnail.setBorder(new MarginBorder(3));
+ thumbnail.setSource(rootEditPart
+ .getLayer(LayerConstants.PRINTABLE_LAYERS));
+ lws.setContents(thumbnail);
+ }
+
+ public void dispose() {
+ if (null != thumbnail) {
+ thumbnail.deactivate();
+ }
+ super.dispose();
+ }
+
+ public Control getControl() {
+ return overview;
+ }
+
+ public ISelection getSelection() {
+ return StructuredSelection.EMPTY;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setFocus() {
+ if (getControl() != null) {
+ getControl().setFocus();
+ }
+ }
+
+ public void setSelection(ISelection selection) {
+ }
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/OverviewOutlinePage.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/PaletteFactory.java
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/PaletteFactory.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/PaletteFactory.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/PaletteFactory.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,104 @@
+package org.jboss.tools.flow.editor;
+
+/*
+ * 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.palette.ConnectionCreationToolEntry;
+import org.eclipse.gef.palette.MarqueeToolEntry;
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.flow.JBossToolsProcessPlugin;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionFactory;
+
+/**
+ * Factory for creating a RuleFlow palette.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class PaletteFactory {
+
+ private ConnectionFactory connectionFactory;
+
+ public PaletteFactory(ConnectionFactory connectionFactory) {
+ this.connectionFactory = connectionFactory;
+ }
+
+ public PaletteRoot createPalette() {
+ PaletteRoot palette = new PaletteRoot();
+ palette.addAll(createCategories(palette));
+ return palette;
+ }
+
+ protected List<PaletteContainer> createCategories(PaletteRoot root) {
+ List<PaletteContainer> categories = new
ArrayList<PaletteContainer>();
+ categories.add(createControlGroup(root));
+ categories.add(createComponentsDrawer());
+ return categories;
+ }
+
+ protected PaletteContainer createControlGroup(PaletteRoot root) {
+ PaletteGroup controlGroup = new PaletteGroup("Control Group");
+
+ List<PaletteEntry> entries = new ArrayList<PaletteEntry>();
+
+ ToolEntry tool = new SelectionToolEntry();
+ entries.add(tool);
+ root.setDefaultEntry(tool);
+
+ tool = new MarqueeToolEntry();
+ entries.add(tool);
+
+ tool = new ConnectionCreationToolEntry(
+ "Connection Creation",
+ "Creating connections",
+ new CreationFactory() {
+ public Object getNewObject() {
+ return connectionFactory.createElementConnection();
+ }
+ public Object getObjectType() {
+ return AbstractConnectionWrapper.class;
+ }
+ },
+
ImageDescriptor.createFromURL(JBossToolsProcessPlugin.getDefault().getBundle().getEntry("icons/connection.gif")),
+
ImageDescriptor.createFromURL(JBossToolsProcessPlugin.getDefault().getBundle().getEntry("icons/connection.gif"))
+ );
+ entries.add(tool);
+
+ controlGroup.addAll(entries);
+ return controlGroup;
+ }
+
+ protected PaletteContainer createComponentsDrawer() {
+ PaletteDrawer drawer = new PaletteDrawer("Components", null);
+ List<PaletteEntry> entries = createComponentEntries();
+ drawer.addAll(entries);
+ return drawer;
+ }
+
+ protected abstract List<PaletteEntry> createComponentEntries();
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/PaletteFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java 2008-07-23
14:05:02 UTC (rev 9240)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -1,59 +0,0 @@
-package org.jboss.tools.flow.editor.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.editor.core.ContainerWrapper;
-import org.jboss.tools.flow.editor.core.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);
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java
(from rev 9263,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/AddElementCommand.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,63 @@
+package org.jboss.tools.flow.editor.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.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.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);
+ }
+
+}
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java 2008-07-23
14:05:02 UTC (rev 9240)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -1,88 +0,0 @@
-package org.jboss.tools.flow.editor.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.editor.core.AbstractConnectionWrapper;
-import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
-import org.jboss.tools.flow.editor.core.NodeWrapper;
-
-/**
- * A command for splitting a connection.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class SplitConnectionCommand extends Command {
-
- private AbstractRootWrapper parent;
- private NodeWrapper oldSource;
- private NodeWrapper oldTarget;
- private AbstractConnectionWrapper oldConnection;
- private AbstractConnectionWrapper secondConnection;
- private NodeWrapper newElement;
-
- public void setNewSecondConnection(AbstractConnectionWrapper connection) {
- if (connection == null) {
- throw new IllegalArgumentException("new second connection cannot be
null");
- }
- this.secondConnection = connection;
- }
-
- public void execute() {
- if (secondConnection == null) {
- throw new IllegalStateException("new second connection is still null");
- }
- oldConnection.disconnect();
- parent.addElement(newElement);
- newElement.setParent(parent);
- oldConnection.connect(oldSource, newElement);
- secondConnection.connect(newElement, oldTarget);
- }
-
- public void setParent(AbstractRootWrapper process) {
- if (process == null) {
- throw new IllegalArgumentException("process is null");
- }
- parent = process;
- }
-
- public void setElementConnection(AbstractConnectionWrapper connection) {
- if (connection == null) {
- throw new IllegalArgumentException("Element connection is null");
- }
- this.oldConnection = connection;
- oldSource = connection.getSource();
- oldTarget = connection.getTarget();
- }
-
- public void setNewElement(NodeWrapper newElement) {
- if (newElement == null) {
- throw new IllegalArgumentException("NewElement is null");
- }
- this.newElement = newElement;
-
- }
-
- public void undo() {
- oldConnection.disconnect();
- secondConnection.disconnect();
- parent.removeElement(newElement);
- newElement.setParent(null);
- oldConnection.connect(oldSource, oldTarget);
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
(from rev 9264,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,94 @@
+package org.jboss.tools.flow.editor.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.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for splitting a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class SplitConnectionCommand extends Command {
+
+ private AbstractRootWrapper parent;
+ private NodeWrapper oldSource;
+ private NodeWrapper oldTarget;
+ private AbstractConnectionWrapper oldConnection;
+ private AbstractConnectionWrapper secondConnection;
+ private NodeWrapper newElement;
+
+ public void setNewSecondConnection(AbstractConnectionWrapper connection) {
+ if (connection == null) {
+ throw new IllegalArgumentException("new second connection cannot be
null");
+ }
+ this.secondConnection = connection;
+ }
+
+ public void execute() {
+ if (secondConnection == null) {
+ throw new IllegalStateException("new second connection is still null");
+ }
+ oldConnection.disconnect();
+ parent.addElement(newElement);
+ newElement.setParent(parent);
+ oldConnection.connect(oldSource, newElement);
+ secondConnection.connect(newElement, oldTarget);
+ }
+
+ public void setParent(AbstractRootWrapper process) {
+ if (process == null) {
+ throw new IllegalArgumentException("process is null");
+ }
+ parent = process;
+ }
+
+ public void setElementConnection(AbstractConnectionWrapper connection) {
+ if (connection == null) {
+ throw new IllegalArgumentException("Element connection is null");
+ }
+ this.oldConnection = connection;
+ oldSource = connection.getSource();
+ oldTarget = connection.getTarget();
+ }
+
+ public void setNewElement(NodeWrapper newElement) {
+ if (newElement == null) {
+ throw new IllegalArgumentException("NewElement is null");
+ }
+ this.newElement = newElement;
+
+ }
+
+ public void undo() {
+ oldConnection.disconnect();
+ secondConnection.disconnect();
+ parent.removeElement(newElement);
+ newElement.setParent(null);
+ oldConnection.connect(oldSource, oldTarget);
+ }
+
+ public boolean canExecute() {
+ return parent.acceptsElement(newElement) &&
+ newElement.acceptsIncomingConnection(oldConnection, oldSource) &&
+ newElement.acceptsOutgoingConnection(secondConnection, oldTarget);
+ }
+
+}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java 2008-07-23
14:05:02 UTC (rev 9240)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -1,100 +0,0 @@
-package org.jboss.tools.flow.editor.core;
-
-/*
- * 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.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A wrapper for a process element.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public abstract class AbstractRootWrapper extends AbstractWrapper implements
ContainerWrapper {
-
- public static final int CHANGE_ELEMENTS = 1;
- public static final int CHANGE_VISUAL = 2;
-
- public static final Integer ROUTER_LAYOUT_MANUAL = new Integer(0);
- public static final Integer ROUTER_LAYOUT_MANHATTAN = new Integer(1);
- public static final Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
-
- private Map<String, NodeWrapper> elements = new HashMap<String,
NodeWrapper>();
- private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
-
- public abstract Integer getRouterLayout();
-
- public void setRouterLayout(Integer routerLayout) {
- internalSetRouterLayout(routerLayout);
- notifyListeners(CHANGE_VISUAL);
- }
-
- protected void internalSetRouterLayout(Integer routerLayout) {
- }
-
- public List<NodeWrapper> getElements() {
- return Collections.unmodifiableList(
- new ArrayList<NodeWrapper>(elements.values()));
- }
-
- public NodeWrapper getElement(String id) {
- return (NodeWrapper) elements.get(id);
- }
-
- public void addElement(NodeWrapper element) {
- internalAddElement(element);
- localAddElement(element);
- notifyListeners(CHANGE_ELEMENTS);
- }
-
- public void localAddElement(NodeWrapper element) {
- elements.put(element.getId(), element);
- }
-
- protected abstract void internalAddElement(NodeWrapper element);
-
- public void removeElement(NodeWrapper element) {
- elements.remove(element.getId());
- notifyListeners(CHANGE_ELEMENTS);
- internalRemoveElement(element);
- }
-
- protected abstract void internalRemoveElement(NodeWrapper element);
-
- public AbstractRootWrapper getProcessWrapper() {
- return this;
- }
-
- public void addListener(ModelListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(ModelListener listener) {
- listeners.remove(listener);
- }
-
- public void notifyListeners(int change) {
- ModelEvent event = new ModelEvent(change);
- for (ModelListener listener: listeners) {
- listener.modelChanged(event);
- }
- }
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
(from rev 9263,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,105 @@
+package org.jboss.tools.flow.editor.core;
+
+/*
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A wrapper for a process element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractRootWrapper extends AbstractWrapper implements
ContainerWrapper {
+
+ public static final int CHANGE_ELEMENTS = 1;
+ public static final int CHANGE_VISUAL = 2;
+
+ public static final Integer ROUTER_LAYOUT_MANUAL = new Integer(0);
+ public static final Integer ROUTER_LAYOUT_MANHATTAN = new Integer(1);
+ public static final Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
+
+ private Map<String, NodeWrapper> elements = new HashMap<String,
NodeWrapper>();
+ private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
+
+ public abstract Integer getRouterLayout();
+
+ public void setRouterLayout(Integer routerLayout) {
+ internalSetRouterLayout(routerLayout);
+ notifyListeners(CHANGE_VISUAL);
+ }
+
+ protected void internalSetRouterLayout(Integer routerLayout) {
+ }
+
+ public List<NodeWrapper> getElements() {
+ return Collections.unmodifiableList(
+ new ArrayList<NodeWrapper>(elements.values()));
+ }
+
+ public NodeWrapper getElement(String id) {
+ return (NodeWrapper) elements.get(id);
+ }
+
+ public void addElement(NodeWrapper element) {
+ if (!acceptsElement(element)) return;
+ internalAddElement(element);
+ localAddElement(element);
+ notifyListeners(CHANGE_ELEMENTS);
+ }
+
+ public void localAddElement(NodeWrapper element) {
+ elements.put(element.getId(), element);
+ }
+
+ public boolean acceptsElement(NodeWrapper element) {
+ return true;
+ }
+
+ protected abstract void internalAddElement(NodeWrapper element);
+
+ public void removeElement(NodeWrapper element) {
+ elements.remove(element.getId());
+ notifyListeners(CHANGE_ELEMENTS);
+ internalRemoveElement(element);
+ }
+
+ protected abstract void internalRemoveElement(NodeWrapper element);
+
+ public AbstractRootWrapper getProcessWrapper() {
+ return this;
+ }
+
+ public void addListener(ModelListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(ModelListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void notifyListeners(int change) {
+ ModelEvent event = new ModelEvent(change);
+ for (ModelListener listener: listeners) {
+ listener.modelChanged(event);
+ }
+ }
+
+}
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-23
14:05:02 UTC (rev 9240)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -1,33 +0,0 @@
-package org.jboss.tools.flow.editor.core;
-
-/*
- * 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.List;
-
-public interface ContainerWrapper extends Wrapper {
-
- void addElement(NodeWrapper element);
-
- void localAddElement(NodeWrapper element);
-
- void removeElement(NodeWrapper element);
-
- List<NodeWrapper> getElements();
-
- AbstractRootWrapper getProcessWrapper();
-
-}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
(from rev 9263,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-29
09:44:40 UTC (rev 9374)
@@ -0,0 +1,35 @@
+package org.jboss.tools.flow.editor.core;
+
+/*
+ * 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.List;
+
+public interface ContainerWrapper extends Wrapper {
+
+ void addElement(NodeWrapper element);
+
+ void localAddElement(NodeWrapper element);
+
+ void removeElement(NodeWrapper element);
+
+ List<NodeWrapper> getElements();
+
+ AbstractRootWrapper getProcessWrapper();
+
+ boolean acceptsElement(NodeWrapper element);
+
+}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/figure
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/figure
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy
(from rev 9240,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy)
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy
___________________________________________________________________
Name: svn:mergeinfo
+