Author: vyemialyanchyk
Date: 2009-10-13 10:31:24 -0400 (Tue, 13 Oct 2009)
New Revision: 18068
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/AutoLayoutCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/CollapseAllCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ExpandAllCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleAssociationCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleClassMappingCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionsCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleForeignKeyConstraintCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/TogglePropertyMappingCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeExpandStateCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleAssociationAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleClassMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleForeignKeyConstraintAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/TogglePropertyMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4694 - fixed
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.AutoLayoutCommand;
/**
* @author some modifications from Vitali
@@ -32,6 +35,12 @@
}
public void run() {
- getDiagramViewer().getOrmDiagram().autolayout();
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new AutoLayoutCommand(getDiagramViewer().getOrmDiagram()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/CollapseAllAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,8 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.CollapseAllCommand;
/**
* @author Vitali Yemialyanchyk
@@ -29,6 +32,12 @@
}
public void run() {
- getDiagramViewer().getOrmDiagram().collapseAll();
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new CollapseAllCommand(getDiagramViewer().getOrmDiagram()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CommandStack;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
@@ -57,4 +59,27 @@
}
return res;
}
+
+ /**
+ * Executes the given {@link Command} using the command stack. The stack is obtained
by
+ * calling {@link #getCommandStack()}, which uses <code>IAdapatable</code>
to retrieve the
+ * stack from the workbench part.
+ * @param command the command to execute
+ */
+ protected void execute(Command command) {
+ if (command == null || !command.canExecute()) {
+ return;
+ }
+ getCommandStack().execute(command);
+ }
+
+ /**
+ * Returns the editor's command stack. This is done by asking the workbench part for
its
+ * CommandStack via
+ * {@link org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)}.
+ * @return the command stack
+ */
+ protected CommandStack getCommandStack() {
+ return (CommandStack)getDiagramViewer().getAdapter(CommandStack.class);
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExpandAllAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,8 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.ExpandAllCommand;
/**
* @author Vitali Yemialyanchyk
@@ -29,6 +32,12 @@
}
public void run() {
- getDiagramViewer().getOrmDiagram().expandAll();
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new ExpandAllCommand(getDiagramViewer().getOrmDiagram()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleAssociationAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleAssociationAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleAssociationAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleAssociationCommand;
/**
* Show|Hide connections which type is "Associations" (class associations).
@@ -36,7 +39,12 @@
}
public void run() {
- boolean state = getDiagramViewer().getConnectionsVisibilityAssociation();
- getDiagramViewer().setConnectionsVisibilityAssociation(!state);
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new ToggleAssociationCommand(getDiagramViewer()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleClassMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleClassMappingAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleClassMappingAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleClassMappingCommand;
/**
* Show|Hide connections which type is "Class Mappings" (class->table).
@@ -36,7 +39,12 @@
}
public void run() {
- boolean state = getDiagramViewer().getConnectionsVisibilityClassMapping();
- getDiagramViewer().setConnectionsVisibilityClassMapping(!state);
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new ToggleClassMappingCommand(getDiagramViewer()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleConnectionsCommand;
/**
* Show|Hide all connections.
@@ -34,13 +37,12 @@
}
public void run() {
- boolean state = getDiagramViewer().getConnectionsVisibilityAssociation();
- getDiagramViewer().setConnectionsVisibilityAssociation(!state);
- state = getDiagramViewer().getConnectionsVisibilityClassMapping();
- getDiagramViewer().setConnectionsVisibilityClassMapping(!state);
- state = getDiagramViewer().getConnectionsVisibilityForeignKeyConstraint();
- getDiagramViewer().setConnectionsVisibilityForeignKeyConstraint(!state);
- state = getDiagramViewer().getConnectionsVisibilityPropertyMapping();
- getDiagramViewer().setConnectionsVisibilityPropertyMapping(!state);
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new ToggleConnectionsCommand(getDiagramViewer()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleForeignKeyConstraintAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleForeignKeyConstraintAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleForeignKeyConstraintAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleForeignKeyConstraintCommand;
/**
* Show|Hide connections which type is "Foreign key constraints"
@@ -37,10 +40,15 @@
}
public void run() {
- boolean state = getDiagramViewer().getConnectionsVisibilityForeignKeyConstraint();
- getDiagramViewer().setConnectionsVisibilityForeignKeyConstraint(!state);
+ execute(getCommand());
}
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new ToggleForeignKeyConstraintCommand(getDiagramViewer()));
+ return cc;
+ }
+
@Override
public boolean isEnabled() {
// TODO: JBIDE-4956 -> still not implemented
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/TogglePropertyMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/TogglePropertyMappingAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/TogglePropertyMappingAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -10,9 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.TogglePropertyMappingCommand;
/**
* Show|Hide connections which type is "Property Mappings"
(property->column).
@@ -36,7 +39,12 @@
}
public void run() {
- boolean state = getDiagramViewer().getConnectionsVisibilityPropertyMapping();
- getDiagramViewer().setConnectionsVisibilityPropertyMapping(!state);
+ execute(getCommand());
}
+
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ cc.add(new TogglePropertyMappingCommand(getDiagramViewer()));
+ return cc;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -14,12 +14,15 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeExpandStateCommand;
import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
@@ -42,10 +45,15 @@
setImageDescriptor(img);
}
+ public void run() {
+ execute(getCommand());
+ }
+
@SuppressWarnings("unchecked")
- public void run() {
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
if (getSelectedObjects().isEmpty()) {
- return;
+ return cc;
}
List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
Iterator it = getSelectedObjects().iterator();
@@ -61,9 +69,10 @@
selectedShape.add((ExpandableShape)obj);
}
}
- for (ExpandableShape shape : selectedShape) {
- shape.setExpanded(!shape.isExpanded());
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape));
}
+ return cc;
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -14,6 +14,8 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -22,6 +24,7 @@
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
@@ -44,10 +47,15 @@
setImageDescriptor(img);
}
+ public void run() {
+ execute(getCommand());
+ }
+
@SuppressWarnings("unchecked")
- public void run() {
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
if (getSelectedObjects().isEmpty()) {
- return;
+ return cc;
}
List<OrmShape> selectedShape = new ArrayList<OrmShape>();
Iterator it = getSelectedObjects().iterator();
@@ -63,12 +71,10 @@
selectedShape.add((OrmShape)obj);
}
}
- for (OrmShape shape : selectedShape) {
- Object ormElement = shape.getOrmElement();
- if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
- shape.setVisible(!shape.isVisible());
- }
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
}
+ return cc;
}
@Override
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/AutoLayoutCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/AutoLayoutCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/AutoLayoutCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import java.util.HashMap;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class AutoLayoutCommand extends Command {
+
+ protected HashMap<String, Point> elLocations;
+ protected OrmDiagram ormDiagram;
+
+ public AutoLayoutCommand(OrmDiagram ormDiagram) {
+ this.ormDiagram = ormDiagram;
+ elLocations = null;
+ }
+
+ public void execute() {
+ elLocations = ormDiagram.getElementsLocations();
+ ormDiagram.autolayout();
+ }
+
+ public void undo() {
+ if (elLocations != null) {
+ ormDiagram.setElementsLocations(elLocations);
+ }
+ }
+
+ public boolean canUndo() {
+ return (elLocations != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/CollapseAllCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/CollapseAllCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/CollapseAllCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import java.util.HashMap;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class CollapseAllCommand extends Command {
+
+ protected HashMap<String, Boolean> elExpState;
+ protected OrmDiagram ormDiagram;
+
+ public CollapseAllCommand(OrmDiagram ormDiagram) {
+ this.ormDiagram = ormDiagram;
+ }
+
+ public void execute() {
+ elExpState = ormDiagram.getElementsExpState();
+ ormDiagram.collapseAll();
+ }
+
+ public void undo() {
+ ormDiagram.setElementsExpState(elExpState);
+ }
+
+ public boolean canUndo() {
+ return (elExpState != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ExpandAllCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ExpandAllCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ExpandAllCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import java.util.HashMap;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ExpandAllCommand extends Command {
+
+ protected HashMap<String, Boolean> elExpState;
+ protected OrmDiagram ormDiagram;
+
+ public ExpandAllCommand(OrmDiagram ormDiagram) {
+ this.ormDiagram = ormDiagram;
+ }
+
+ public void execute() {
+ elExpState = ormDiagram.getElementsExpState();
+ ormDiagram.expandAll();
+ }
+
+ public void undo() {
+ ormDiagram.setElementsExpState(elExpState);
+ }
+
+ public boolean canUndo() {
+ return (elExpState != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleAssociationCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleAssociationCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleAssociationCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleAssociationCommand extends Command {
+
+ protected boolean stateConnectionsVisibilityAssociation;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleAssociationCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionsVisibilityAssociation =
+ diagramViewer.getConnectionsVisibilityAssociation();
+ }
+
+ public void execute() {
+ stateConnectionsVisibilityAssociation =
+ diagramViewer.getConnectionsVisibilityAssociation();
+ diagramViewer.setConnectionsVisibilityAssociation(
+ !stateConnectionsVisibilityAssociation);
+ }
+
+ public void undo() {
+ diagramViewer.setConnectionsVisibilityAssociation(
+ stateConnectionsVisibilityAssociation);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleClassMappingCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleClassMappingCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleClassMappingCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleClassMappingCommand extends Command {
+
+ protected boolean stateConnectionsVisibilityClassMapping;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleClassMappingCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionsVisibilityClassMapping =
+ diagramViewer.getConnectionsVisibilityClassMapping();
+ }
+
+ public void execute() {
+ stateConnectionsVisibilityClassMapping =
+ diagramViewer.getConnectionsVisibilityClassMapping();
+ diagramViewer.setConnectionsVisibilityClassMapping(
+ !stateConnectionsVisibilityClassMapping);
+ }
+
+ public void undo() {
+ diagramViewer.setConnectionsVisibilityClassMapping(
+ stateConnectionsVisibilityClassMapping);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionsCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionsCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionsCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleConnectionsCommand extends Command {
+
+ protected boolean stateConnectionsVisibilityAssociation;
+ protected boolean stateConnectionsVisibilityClassMapping;
+ protected boolean stateConnectionsVisibilityForeignKeyConstraint;
+ protected boolean stateConnectionsVisibilityPropertyMapping;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleConnectionsCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionsVisibilityAssociation =
+ diagramViewer.getConnectionsVisibilityAssociation();
+ stateConnectionsVisibilityClassMapping =
+ diagramViewer.getConnectionsVisibilityClassMapping();
+ stateConnectionsVisibilityForeignKeyConstraint =
+ diagramViewer.getConnectionsVisibilityForeignKeyConstraint();
+ stateConnectionsVisibilityPropertyMapping =
+ diagramViewer.getConnectionsVisibilityPropertyMapping();
+ }
+
+ public void execute() {
+ stateConnectionsVisibilityAssociation =
+ diagramViewer.getConnectionsVisibilityAssociation();
+ diagramViewer.setConnectionsVisibilityAssociation(
+ !stateConnectionsVisibilityAssociation);
+ stateConnectionsVisibilityClassMapping =
+ diagramViewer.getConnectionsVisibilityClassMapping();
+ diagramViewer.setConnectionsVisibilityClassMapping(
+ !stateConnectionsVisibilityClassMapping);
+ stateConnectionsVisibilityForeignKeyConstraint =
+ diagramViewer.getConnectionsVisibilityForeignKeyConstraint();
+ diagramViewer.setConnectionsVisibilityForeignKeyConstraint(
+ !stateConnectionsVisibilityForeignKeyConstraint);
+ stateConnectionsVisibilityPropertyMapping =
+ diagramViewer.getConnectionsVisibilityPropertyMapping();
+ diagramViewer.setConnectionsVisibilityPropertyMapping(
+ !stateConnectionsVisibilityPropertyMapping);
+ }
+
+ public void undo() {
+ diagramViewer.setConnectionsVisibilityAssociation(
+ stateConnectionsVisibilityAssociation);
+ diagramViewer.setConnectionsVisibilityClassMapping(
+ stateConnectionsVisibilityClassMapping);
+ diagramViewer.setConnectionsVisibilityForeignKeyConstraint(
+ stateConnectionsVisibilityForeignKeyConstraint);
+ diagramViewer.setConnectionsVisibilityPropertyMapping(
+ stateConnectionsVisibilityPropertyMapping);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleForeignKeyConstraintCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleForeignKeyConstraintCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleForeignKeyConstraintCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleForeignKeyConstraintCommand extends Command {
+
+ protected boolean stateConnectionsVisibilityForeignKeyConstraint;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleForeignKeyConstraintCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionsVisibilityForeignKeyConstraint =
+ diagramViewer.getConnectionsVisibilityForeignKeyConstraint();
+ }
+
+ public void execute() {
+ stateConnectionsVisibilityForeignKeyConstraint =
+ diagramViewer.getConnectionsVisibilityForeignKeyConstraint();
+ diagramViewer.setConnectionsVisibilityForeignKeyConstraint(
+ !stateConnectionsVisibilityForeignKeyConstraint);
+ }
+
+ public void undo() {
+ diagramViewer.setConnectionsVisibilityForeignKeyConstraint(
+ stateConnectionsVisibilityForeignKeyConstraint);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/TogglePropertyMappingCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/TogglePropertyMappingCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/TogglePropertyMappingCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class TogglePropertyMappingCommand extends Command {
+
+ protected boolean stateConnectionsVisibilityPropertyMapping;
+ protected DiagramViewer diagramViewer;
+
+ public TogglePropertyMappingCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionsVisibilityPropertyMapping =
+ diagramViewer.getConnectionsVisibilityPropertyMapping();
+ }
+
+ public void execute() {
+ stateConnectionsVisibilityPropertyMapping =
+ diagramViewer.getConnectionsVisibilityPropertyMapping();
+ diagramViewer.setConnectionsVisibilityPropertyMapping(
+ !stateConnectionsVisibilityPropertyMapping);
+ }
+
+ public void undo() {
+ diagramViewer.setConnectionsVisibilityPropertyMapping(
+ stateConnectionsVisibilityPropertyMapping);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeExpandStateCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeExpandStateCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeExpandStateCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleShapeExpandStateCommand extends Command {
+
+ protected List<ExpandableShape> selectedShape;
+
+ public ToggleShapeExpandStateCommand(List<ExpandableShape> selectedShape) {
+ this.selectedShape = selectedShape;
+ }
+
+ public void execute() {
+ for (ExpandableShape shape : selectedShape) {
+ shape.setExpanded(!shape.isExpanded());
+ }
+ }
+
+ public void undo() {
+ for (ExpandableShape shape : selectedShape) {
+ shape.setExpanded(!shape.isExpanded());
+ }
+ }
+
+ public boolean canUndo() {
+ return (selectedShape != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.command;
+
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Table;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleShapeVisibleStateCommand extends Command {
+
+ protected List<OrmShape> selectedShape;
+
+ public ToggleShapeVisibleStateCommand(List<OrmShape> selectedShape) {
+ this.selectedShape = selectedShape;
+ }
+
+ public void execute() {
+ for (OrmShape shape : selectedShape) {
+ Object ormElement = shape.getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ shape.setVisible(!shape.isVisible());
+ }
+ }
+ }
+
+ public void undo() {
+ for (OrmShape shape : selectedShape) {
+ Object ormElement = shape.getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ shape.setVisible(!shape.isVisible());
+ }
+ }
+ }
+
+ public boolean canUndo() {
+ return (selectedShape != null);
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-13
13:51:59 UTC (rev 18067)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-13
14:31:24 UTC (rev 18068)
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
+import java.util.Map.Entry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -33,6 +34,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;
@@ -821,4 +823,40 @@
public void setMemento(IMemento memento) {
this.memento = memento;
}
+
+ public HashMap<String, Point> getElementsLocations() {
+ HashMap<String, Point> elLocations = new HashMap<String, Point>();
+ Iterator< Entry<String, OrmShape> > it = elements.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, OrmShape> entry = it.next();
+ elLocations.put(entry.getKey(), entry.getValue().getLocation());
+ }
+ return elLocations;
+ }
+
+ public void setElementsLocations(HashMap<String, Point> elLocations) {
+ Iterator< Entry<String, Point> > it = elLocations.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, Point> entry = it.next();
+ elements.get(entry.getKey()).setLocation(entry.getValue());
+ }
+ }
+
+ public HashMap<String, Boolean> getElementsExpState() {
+ HashMap<String, Boolean> elExpState = new HashMap<String, Boolean>();
+ Iterator< Entry<String, OrmShape> > it = elements.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, OrmShape> entry = it.next();
+ elExpState.put(entry.getKey(), entry.getValue().isExpanded());
+ }
+ return elExpState;
+ }
+
+ public void setElementsExpState(HashMap<String, Boolean> elExpState) {
+ Iterator< Entry<String, Boolean> > it = elExpState.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, Boolean> entry = it.next();
+ elements.get(entry.getKey()).setExpanded(entry.getValue());
+ }
+ }
}