Author: vyemialyanchyk
Date: 2009-11-30 07:55:07 -0500 (Mon, 30 Nov 2009)
New Revision: 18920
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeCollapseAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeExpandAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeHideAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeShowAction.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/command/ToggleShapeExpandStateCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5131 - fixed - simplify Show|Hide &
Expand|Collapse functionality so the first selected item is a pattern to toggle selected
items state
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -172,15 +172,15 @@
act[6] = (Action)getAction(ConnectionRouterFanAction.ACTION_ID);
diagramToggleConnectionsAction.setMenuCreator(new ActionMenu(act));
//
- act = new Action[2];
- act[0] = (Action)getAction(ShapeExpandAction.ACTION_ID);
- act[1] = (Action)getAction(ShapeCollapseAction.ACTION_ID);
- diagramToggleExpandStateAction.setMenuCreator(new ActionMenu(act));
+ //act = new Action[2];
+ //act[0] = (Action)getAction(ShapeExpandAction.ACTION_ID);
+ //act[1] = (Action)getAction(ShapeCollapseAction.ACTION_ID);
+ //diagramToggleExpandStateAction.setMenuCreator(new ActionMenu(act));
//
- act = new Action[2];
- act[0] = (Action)getAction(ShapeShowAction.ACTION_ID);
- act[1] = (Action)getAction(ShapeHideAction.ACTION_ID);
- diagramToggleVisibleStateAction.setMenuCreator(new ActionMenu(act));
+ //act = new Action[2];
+ //act[0] = (Action)getAction(ShapeShowAction.ACTION_ID);
+ //act[1] = (Action)getAction(ShapeHideAction.ACTION_ID);
+ //diagramToggleVisibleStateAction.setMenuCreator(new ActionMenu(act));
//
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -310,15 +310,15 @@
act[6] = (Action)registry.getAction(ConnectionRouterFanAction.ACTION_ID);
actionToggleConnections.setMenuCreator(new ActionMenu(act));
- act = new Action[2];
- act[0] = (Action)registry.getAction(ShapeExpandAction.ACTION_ID);
- act[1] = (Action)registry.getAction(ShapeCollapseAction.ACTION_ID);
- actionToggleShapeExpandState.setMenuCreator(new ActionMenu(act));
+ //act = new Action[2];
+ //act[0] = (Action)registry.getAction(ShapeExpandAction.ACTION_ID);
+ //act[1] = (Action)registry.getAction(ShapeCollapseAction.ACTION_ID);
+ //actionToggleShapeExpandState.setMenuCreator(new ActionMenu(act));
- act = new Action[2];
- act[0] = (Action)registry.getAction(ShapeShowAction.ACTION_ID);
- act[1] = (Action)registry.getAction(ShapeHideAction.ACTION_ID);
- actionToggleShapeVisibleState.setMenuCreator(new ActionMenu(act));
+ //act = new Action[2];
+ //act[0] = (Action)registry.getAction(ShapeShowAction.ACTION_ID);
+ //act[1] = (Action)registry.getAction(ShapeHideAction.ACTION_ID);
+ //actionToggleShapeVisibleState.setMenuCreator(new ActionMenu(act));
}
private TransferDropTargetListener createTransferDropTargetListener() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeCollapseAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeCollapseAction.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeCollapseAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -79,7 +79,7 @@
}
}
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeExpandStateCommand(selectedShape));
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape, null));
}
return cc;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeExpandAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeExpandAction.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeExpandAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -79,7 +79,7 @@
}
}
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeExpandStateCommand(selectedShape));
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape, null));
}
return cc;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeHideAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeHideAction.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeHideAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -81,7 +81,7 @@
}
}
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape, null));
}
return cc;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeShowAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeShowAction.java 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeShowAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -81,7 +81,7 @@
}
}
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape, null));
}
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-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -19,6 +19,7 @@
import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
@@ -76,8 +77,21 @@
selectedShape.add((ExpandableShape)obj);
}
}
+ ExpandableShape primalElement = null;
+ if (getSelection() instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection)getSelection()).getFirstElement();
+ Object obj = null;
+ if (firstElement instanceof OrmEditPart) {
+ obj = ((OrmEditPart)firstElement).getModel();
+ } else if (firstElement instanceof AbstractTreeEditPart) {
+ obj = ((AbstractTreeEditPart)firstElement).getModel();
+ }
+ if (null != obj && obj instanceof ExpandableShape) {
+ primalElement = (ExpandableShape)obj;
+ }
+ }
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeExpandStateCommand(selectedShape));
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape, primalElement));
}
return cc;
}
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-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -19,6 +19,7 @@
import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
@@ -78,8 +79,21 @@
selectedShape.add((OrmShape)obj);
}
}
+ OrmShape primalElement = null;
+ if (getSelection() instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection)getSelection()).getFirstElement();
+ Object obj = null;
+ if (firstElement instanceof OrmEditPart) {
+ obj = ((OrmEditPart)firstElement).getModel();
+ } else if (firstElement instanceof AbstractTreeEditPart) {
+ obj = ((AbstractTreeEditPart)firstElement).getModel();
+ }
+ if (null != obj && obj instanceof OrmShape) {
+ primalElement = (OrmShape)obj;
+ }
+ }
if (selectedShape.size() > 0) {
- cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape, primalElement));
}
return cc;
}
Modified:
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 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeExpandStateCommand.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.command;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.commands.Command;
@@ -21,21 +22,35 @@
*/
public class ToggleShapeExpandStateCommand extends Command {
+ protected ExpandableShape primalElement;
protected List<ExpandableShape> selectedShape;
+ protected List<Boolean> selectedShapeStates;
- public ToggleShapeExpandStateCommand(List<ExpandableShape> selectedShape) {
+ public ToggleShapeExpandStateCommand(List<ExpandableShape> selectedShape,
ExpandableShape primalElement) {
+ this.primalElement = primalElement;
this.selectedShape = selectedShape;
+ selectedShapeStates = new ArrayList<Boolean>();
+ for (ExpandableShape shape : selectedShape) {
+ selectedShapeStates.add(shape.isExpanded());
+ }
}
public void execute() {
+ boolean expState = false;
+ if (primalElement != null) {
+ expState = primalElement.isExpanded();
+ } else if (selectedShape.size() > 0) {
+ expState = selectedShape.get(0).isExpanded();
+ }
for (ExpandableShape shape : selectedShape) {
- shape.setExpanded(!shape.isExpanded());
+ shape.setExpanded(!expState);
}
}
public void undo() {
- for (ExpandableShape shape : selectedShape) {
- shape.setExpanded(!shape.isExpanded());
+ for (int i = 0; i < selectedShape.size(); i++) {
+ ExpandableShape shape = selectedShape.get(i);
+ shape.setExpanded(selectedShapeStates.get(i));
}
}
Modified:
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 2009-11-30
11:38:06 UTC (rev 18919)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleShapeVisibleStateCommand.java 2009-11-30
12:55:07 UTC (rev 18920)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.command;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.commands.Command;
@@ -23,26 +24,40 @@
*/
public class ToggleShapeVisibleStateCommand extends Command {
+ protected OrmShape primalElement;
protected List<OrmShape> selectedShape;
+ protected List<Boolean> selectedShapeStates;
- public ToggleShapeVisibleStateCommand(List<OrmShape> selectedShape) {
+ public ToggleShapeVisibleStateCommand(List<OrmShape> selectedShape, OrmShape
primalElement) {
+ this.primalElement = primalElement;
this.selectedShape = selectedShape;
+ selectedShapeStates = new ArrayList<Boolean>();
+ for (OrmShape shape : selectedShape) {
+ selectedShapeStates.add(shape.isVisible());
+ }
}
public void execute() {
+ boolean visState = false;
+ if (primalElement != null) {
+ visState = primalElement.isVisible();
+ } else if (selectedShape.size() > 0) {
+ visState = selectedShape.get(0).isVisible();
+ }
for (OrmShape shape : selectedShape) {
Object ormElement = shape.getOrmElement();
if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
- shape.setVisible(!shape.isVisible());
+ shape.setVisible(!visState);
}
}
}
public void undo() {
- for (OrmShape shape : selectedShape) {
+ for (int i = 0; i < selectedShape.size(); i++) {
+ OrmShape shape = selectedShape.get(i);
Object ormElement = shape.getOrmElement();
if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
- shape.setVisible(!shape.isVisible());
+ shape.setVisible(selectedShapeStates.get(i));
}
}
}