Author: vyemialyanchyk
Date: 2009-11-20 14:50:31 -0500 (Fri, 20 Nov 2009)
New Revision: 18767
Added:
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/command/ToggleConnectionRouterFanCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterManhattanCommand.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapecollapse.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeexpand.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapehide.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeshow.png
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
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/DiagramContentOutlinePage.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/ConnectionRouterFanAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterManhattanAction.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/parts/DiagramEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
Log:
https://jira.jboss.org/jira/browse/jbide-5131 - fixed & was a bugfix for popup menu
for change router actions
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -39,6 +39,14 @@
public static String OpenSourceAction_canot_find_source_file;
public static String OpenSourceAction_canot_open_source_file;
public static String OpenSourceAction_open_source_file;
+ public static String ShapeCollapseAction_shape_collapse;
+ public static String ShapeCollapseAction_shape_collapse_tooltip;
+ public static String ShapeExpandAction_shape_expand;
+ public static String ShapeExpandAction_shape_expand_tooltip;
+ public static String ShapeHideAction_shape_hide;
+ public static String ShapeHideAction_shape_hide_tooltip;
+ public static String ShapeShowAction_shape_show;
+ public static String ShapeShowAction_shape_show_tooltip;
public static String ToggleShapeExpandStateAction_toggle_expand_state;
public static String ToggleShapeExpandStateAction_toggle_expand_state_tooltip;
public static String ToggleShapeVisibleStateAction_toggle_visible_state;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-11-20
19:50:31 UTC (rev 18767)
@@ -15,10 +15,18 @@
OpenSourceAction_canot_find_source_file=Can't find source file.
OpenSourceAction_canot_open_source_file=Can't open source file.
OpenSourceAction_open_source_file=Open Source File
-ToggleShapeExpandStateAction_toggle_expand_state=Expand|Collapse
+ShapeCollapseAction_shape_collapse=Collapse shape(s)
+ShapeCollapseAction_shape_collapse_tooltip=Collapse shape(s)
+ShapeExpandAction_shape_expand=Expand shape(s)
+ShapeExpandAction_shape_expand_tooltip=Expand shape(s)
+ShapeHideAction_shape_hide=Hide shape(s)
+ShapeHideAction_shape_hide_tooltip=Hide shape(s)
+ShapeShowAction_shape_show=Show shape(s)
+ShapeShowAction_shape_show_tooltip=Show shape(s)
+ToggleShapeExpandStateAction_toggle_expand_state=Expand|Collapse shape(s)
ToggleShapeExpandStateAction_toggle_expand_state_tooltip=Expand|Collapse (Enter)
-ToggleShapeVisibleStateAction_toggle_visible_state=Toggle visible state
-ToggleShapeVisibleStateAction_toggle_visible_state_tooltip=Toggle visible state (+)
+ToggleShapeVisibleStateAction_toggle_visible_state=Show|Hide shape(s)
+ToggleShapeVisibleStateAction_toggle_visible_state_tooltip=Show|Hide shape(s) (+)
ToggleConnectionsAction_toggle_connections=Show|Hide connections
ShapeSetConstraintCommand_move=move
PartFactory_canot_create_part_for_model_element=Can't create part for model element:
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-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -35,6 +35,10 @@
import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ConnectionRouterFanAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ConnectionRouterManhattanAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeCollapseAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeExpandAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeHideAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeShowAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleAssociationAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleClassMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
@@ -67,28 +71,56 @@
AutoLayoutAction.img);
addRetargetAction(diagramAction);
//
- DiagramBaseRetargetAction diagramAction1 = new DiagramBaseRetargetAction(
+ DiagramBaseRetargetAction diagramToggleConnectionsAction = new
DiagramBaseRetargetAction(
ToggleConnectionsAction.ACTION_ID,
DiagramViewerMessages.ToggleConnectionsAction_toggle_connections,
DiagramViewerMessages.ToggleConnectionsAction_toggle_connections,
ToggleConnectionsAction.img);
- addRetargetAction(diagramAction1);
+ addRetargetAction(diagramToggleConnectionsAction);
//
- DiagramBaseRetargetAction diagramAction2 = new DiagramBaseRetargetAction(
+ DiagramBaseRetargetAction diagramToggleExpandStateAction = new
DiagramBaseRetargetAction(
ToggleShapeExpandStateAction.ACTION_ID,
DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state,
DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state_tooltip,
ToggleShapeExpandStateAction.img);
- addRetargetAction(diagramAction2);
+ addRetargetAction(diagramToggleExpandStateAction);
//
diagramAction = new DiagramBaseRetargetAction(
+ ShapeExpandAction.ACTION_ID,
+ DiagramViewerMessages.ShapeExpandAction_shape_expand,
+ DiagramViewerMessages.ShapeExpandAction_shape_expand_tooltip,
+ ShapeExpandAction.img);
+ addRetargetAction(diagramAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
+ ShapeCollapseAction.ACTION_ID,
+ DiagramViewerMessages.ShapeCollapseAction_shape_collapse,
+ DiagramViewerMessages.ShapeCollapseAction_shape_collapse_tooltip,
+ ShapeCollapseAction.img);
+ addRetargetAction(diagramAction);
+ //
+ DiagramBaseRetargetAction diagramToggleVisibleStateAction = new
DiagramBaseRetargetAction(
ToggleShapeVisibleStateAction.ACTION_ID,
DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state,
DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state_tooltip,
ToggleShapeVisibleStateAction.img);
+ addRetargetAction(diagramToggleVisibleStateAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
+ ShapeHideAction.ACTION_ID,
+ DiagramViewerMessages.ShapeHideAction_shape_hide,
+ DiagramViewerMessages.ShapeHideAction_shape_hide_tooltip,
+ ShapeHideAction.img);
addRetargetAction(diagramAction);
//
diagramAction = new DiagramBaseRetargetAction(
+ ShapeShowAction.ACTION_ID,
+ DiagramViewerMessages.ShapeShowAction_shape_show,
+ DiagramViewerMessages.ShapeShowAction_shape_show_tooltip,
+ ShapeShowAction.img);
+ addRetargetAction(diagramAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
ToggleClassMappingAction.ACTION_ID,
DiagramViewerMessages.ToggleClassMappingAction_class_mappings,
DiagramViewerMessages.ToggleClassMappingAction_class_mappings,
@@ -138,8 +170,18 @@
act[4] = null;
act[5] = (Action)getAction(ConnectionRouterManhattanAction.ACTION_ID);
act[6] = (Action)getAction(ConnectionRouterFanAction.ACTION_ID);
- diagramAction1.setMenuCreator(new ActionMenu(act));
+ 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(ShapeShowAction.ACTION_ID);
+ act[1] = (Action)getAction(ShapeHideAction.ACTION_ID);
+ diagramToggleVisibleStateAction.setMenuCreator(new ActionMenu(act));
+ //
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addRetargetAction(new ZoomInRetargetAction());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramContentOutlinePage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramContentOutlinePage.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramContentOutlinePage.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -19,7 +19,6 @@
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.parts.ScrollableThumbnail;
import org.eclipse.draw2d.parts.Thumbnail;
-import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.LayerConstants;
@@ -32,6 +31,7 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.swt.SWT;
@@ -50,7 +50,6 @@
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.TreePartFactory;
-import org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider;
/**
*
@@ -179,7 +178,9 @@
protected void configureOutlineViewer() {
getViewer().setEditDomain(editor.getDefaultEditDomain());
getViewer().setEditPartFactory(new TreePartFactory());
- ContextMenuProvider provider = new PopupMenuProvider(getViewer(),
getActionRegistry());
+ MenuManager provider = editor.getContextMenu();
+ //MenuManager provider = new PopupMenuProvider(getViewer(), getActionRegistry());
+ //getViewer().setContextMenu(provider);
getViewer().setContextMenu(provider);
getSite().registerContextMenu(
"org.jboss.tools.hibernate.ui.diagram.editors.popup.outline.contextmenu",
//$NON-NLS-1$
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-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -52,6 +52,7 @@
import org.eclipse.gef.ui.rulers.RulerComposite;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.util.TransferDropTargetListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -62,19 +63,20 @@
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ActionMenu;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
-import org.jboss.tools.hibernate.ui.diagram.editors.actions.CollapseAllAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ConnectionRouterFanAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ConnectionRouterManhattanAction;
-import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExpandAllAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.LexicalSortingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenSourceAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.PrintDiagramViewerAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.RefreshAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeCollapseAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeExpandAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeHideAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ShapeShowAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleAssociationAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleClassMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
@@ -176,6 +178,8 @@
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY,
new Boolean(getOrmDiagram().getRulerVisibility()));
loadProperties();
+
+ updateConnectionRouterActions();
}
public GraphicalViewer getEditPartViewer() {
@@ -251,24 +255,42 @@
action = new ConnectionRouterFanAction(this);
registry.registerAction(action);
+ getPropertyActions().add(action.getId());
action = new ConnectionRouterManhattanAction(this);
registry.registerAction(action);
+ getPropertyActions().add(action.getId());
- action = new ToggleShapeExpandStateAction(this);
+ ToggleShapeExpandStateAction actionToggleShapeExpandState = new
ToggleShapeExpandStateAction(this);
+ registry.registerAction(actionToggleShapeExpandState);
+ getSelectionActions().add(actionToggleShapeExpandState.getId());
+
+ action = new ShapeExpandAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
-
- action = new ToggleShapeVisibleStateAction(this);
+
+ action = new ShapeCollapseAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new CollapseAllAction(this);
+ ToggleShapeVisibleStateAction actionToggleShapeVisibleState = new
ToggleShapeVisibleStateAction(this);
+ registry.registerAction(actionToggleShapeVisibleState);
+ getSelectionActions().add(actionToggleShapeVisibleState.getId());
+
+ action = new ShapeHideAction(this);
registry.registerAction(action);
-
- action = new ExpandAllAction(this);
+ getSelectionActions().add(action.getId());
+
+ action = new ShapeShowAction(this);
registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+ //action = new CollapseAllAction(this);
+ //registry.registerAction(action);
+
+ //action = new ExpandAllAction(this);
+ //registry.registerAction(action);
+
action = new ZoomInAction(gefRootEditPart.getZoomManager());
registry.registerAction(action);
@@ -277,7 +299,7 @@
action = new LexicalSortingAction(this, null);
registry.registerAction(action);
-
+
Action[] act = new Action[7];
act[0] = (Action)registry.getAction(TogglePropertyMappingAction.ACTION_ID);
act[1] = (Action)registry.getAction(ToggleClassMappingAction.ACTION_ID);
@@ -288,6 +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(ShapeShowAction.ACTION_ID);
+ act[1] = (Action)registry.getAction(ShapeHideAction.ACTION_ID);
+ actionToggleShapeVisibleState.setMenuCreator(new ActionMenu(act));
}
private TransferDropTargetListener createTransferDropTargetListener() {
@@ -635,4 +666,67 @@
}
return null;
}
+
+ public void updateSelectionActions() {
+ updateActions(getSelectionActions());
+ }
+
+ public void updateConnectionRouterActions() {
+ boolean res = isManhattanConnectionRouter();
+ ActionRegistry registry = getActionRegistry();
+ IAction action = registry.getAction(ConnectionRouterManhattanAction.ACTION_ID);
+ action.setChecked(res);
+ action = registry.getAction(ConnectionRouterFanAction.ACTION_ID);
+ action.setChecked(!res);
+ }
+
+ public MenuManager getContextMenu() {
+ final GraphicalViewer viewer = getGraphicalViewer();
+ if (viewer != null) {
+ return viewer.getContextMenu();
+ }
+ return null;
+ }
+
+ public boolean isFanConnectionRouter() {
+ boolean res = false;
+ DiagramEditPart diagramEditPart = getDiagramEditPart();
+ if (diagramEditPart != null) {
+ res = diagramEditPart.isFanConnectionRouter();
+ }
+ return res;
+ }
+
+ public void setFanConnectionRouter(boolean res) {
+ DiagramEditPart diagramEditPart = getDiagramEditPart();
+ if (diagramEditPart != null) {
+ if (res) {
+ diagramEditPart.setupFanConnectionRouter();
+ } else {
+ diagramEditPart.setupManhattanConnectionRouter();
+ }
+ }
+ updateConnectionRouterActions();
+ }
+
+ public boolean isManhattanConnectionRouter() {
+ boolean res = false;
+ DiagramEditPart diagramEditPart = getDiagramEditPart();
+ if (diagramEditPart != null) {
+ res = diagramEditPart.isManhattanConnectionRouter();
+ }
+ return res;
+ }
+
+ public void setManhattanConnectionRouter(boolean res) {
+ DiagramEditPart diagramEditPart = getDiagramEditPart();
+ if (diagramEditPart != null) {
+ if (res) {
+ diagramEditPart.setupManhattanConnectionRouter();
+ } else {
+ diagramEditPart.setupFanConnectionRouter();
+ }
+ }
+ updateConnectionRouterActions();
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterFanAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterFanAction.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterFanAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -10,17 +10,20 @@
******************************************************************************/
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.parts.DiagramEditPart;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleConnectionRouterFanCommand;
/**
* Connect figures with direct line connections
*
* @author Vitali Yemialyanchyk
*/
-public class ConnectionRouterFanAction extends DiagramBaseAction {
+public class ConnectionRouterFanAction extends DiagramBaseAction
+{
public static final String ACTION_ID = "connectionRouterFanId"; //$NON-NLS-1$
public static final ImageDescriptor img =
@@ -35,17 +38,15 @@
}
public void run() {
- DiagramEditPart diagramEditPart = getDiagramViewer().getDiagramEditPart();
- if (diagramEditPart != null) {
- diagramEditPart.setupFanConnectionRouter();
- }
+ execute(getCommand());
}
- public boolean isChecked() {
- DiagramEditPart diagramEditPart = getDiagramViewer().getDiagramEditPart();
- if (diagramEditPart != null) {
- return diagramEditPart.isFanConnectionRouter();
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ boolean checked = editor.isFanConnectionRouter();
+ if (!checked) {
+ cc.add(new ToggleConnectionRouterFanCommand(getDiagramViewer()));
}
- return super.isChecked();
+ return cc;
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterManhattanAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterManhattanAction.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ConnectionRouterManhattanAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -10,17 +10,20 @@
******************************************************************************/
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.parts.DiagramEditPart;
+import
org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleConnectionRouterManhattanCommand;
/**
* Connect figures with bend line connections
*
* @author Vitali Yemialyanchyk
*/
-public class ConnectionRouterManhattanAction extends DiagramBaseAction {
+public class ConnectionRouterManhattanAction extends DiagramBaseAction
+{
public static final String ACTION_ID = "connectionRouterManhattanId";
//$NON-NLS-1$
public static final ImageDescriptor img =
@@ -35,17 +38,15 @@
}
public void run() {
- DiagramEditPart diagramEditPart = getDiagramViewer().getDiagramEditPart();
- if (diagramEditPart != null) {
- diagramEditPart.setupManhattanConnectionRouter();
- }
+ execute(getCommand());
}
- public boolean isChecked() {
- DiagramEditPart diagramEditPart = getDiagramViewer().getDiagramEditPart();
- if (diagramEditPart != null) {
- return diagramEditPart.isManhattanConnectionRouter();
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ boolean checked = editor.isManhattanConnectionRouter();
+ if (!checked) {
+ cc.add(new ToggleConnectionRouterManhattanCommand(getDiagramViewer()));
}
- return super.isChecked();
- }
+ return cc;
+ }
}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeCollapseAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.actions;
+
+import java.util.ArrayList;
+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;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ShapeCollapseAction extends SelectionAction {
+
+ public static final String ACTION_ID = "shapeCollapseId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/shapecollapse.png"); //$NON-NLS-1$
+
+ public ShapeCollapseAction(IWorkbenchPart editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ShapeCollapseAction_shape_collapse);
+ setToolTipText(DiagramViewerMessages.ShapeCollapseAction_shape_collapse_tooltip);
+ setImageDescriptor(img);
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
+
+ public void run() {
+ execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ if (getSelectedObjects().isEmpty()) {
+ return cc;
+ }
+ List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ 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) {
+ ExpandableShape es = (ExpandableShape)obj;
+ if (es.isExpanded()) {
+ selectedShape.add(es);
+ }
+ }
+ }
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape));
+ }
+ return cc;
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return canPerformAction();
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean canPerformAction() {
+ boolean res = false;
+ if (getSelectedObjects().isEmpty()) {
+ return res;
+ }
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext() && !res) {
+ Object firstElement = it.next();
+ 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) {
+ ExpandableShape es = (ExpandableShape)obj;
+ if (es.isExpanded()) {
+ res = true;
+ }
+ }
+ }
+ return res;
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeExpandAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.actions;
+
+import java.util.ArrayList;
+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;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ShapeExpandAction extends SelectionAction {
+
+ public static final String ACTION_ID = "shapeExpandId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class, "icons/shapeexpand.png");
//$NON-NLS-1$
+
+ public ShapeExpandAction(IWorkbenchPart editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ShapeExpandAction_shape_expand);
+ setToolTipText(DiagramViewerMessages.ShapeExpandAction_shape_expand_tooltip);
+ setImageDescriptor(img);
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
+
+ public void run() {
+ execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ if (getSelectedObjects().isEmpty()) {
+ return cc;
+ }
+ List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ 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) {
+ ExpandableShape es = (ExpandableShape)obj;
+ if (!es.isExpanded()) {
+ selectedShape.add(es);
+ }
+ }
+ }
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeExpandStateCommand(selectedShape));
+ }
+ return cc;
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return canPerformAction();
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean canPerformAction() {
+ boolean res = false;
+ if (getSelectedObjects().isEmpty()) {
+ return res;
+ }
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext() && !res) {
+ Object firstElement = it.next();
+ 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) {
+ ExpandableShape es = (ExpandableShape)obj;
+ if (!es.isExpanded()) {
+ res = true;
+ }
+ }
+ }
+ return res;
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeHideAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.actions;
+
+import java.util.ArrayList;
+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.hibernate.mapping.PersistentClass;
+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;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ShapeHideAction extends SelectionAction {
+
+ public static final String ACTION_ID = "shapeHideId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class, "icons/shapehide.png");
//$NON-NLS-1$
+
+ public ShapeHideAction(IWorkbenchPart editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ShapeHideAction_shape_hide);
+ setToolTipText(DiagramViewerMessages.ShapeHideAction_shape_hide_tooltip);
+ setImageDescriptor(img);
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
+
+ public void run() {
+ execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ if (getSelectedObjects().isEmpty()) {
+ return cc;
+ }
+ List<OrmShape> selectedShape = new ArrayList<OrmShape>();
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ 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) {
+ OrmShape ormShape = (OrmShape)obj;
+ if (ormShape.isVisible()) {
+ selectedShape.add(ormShape);
+ }
+ }
+ }
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
+ }
+ return cc;
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return canPerformAction();
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean canPerformAction() {
+ boolean res = false;
+ if (getSelectedObjects().isEmpty()) {
+ return res;
+ }
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext() && !res) {
+ Object firstElement = it.next();
+ 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) {
+ OrmShape ormShape = (OrmShape)obj;
+ Object ormElement = ormShape.getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ if (ormShape.isVisible()) {
+ res = true;
+ }
+ }
+ }
+ }
+ return res;
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ShapeShowAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.actions;
+
+import java.util.ArrayList;
+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.hibernate.mapping.PersistentClass;
+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;
+
+/**
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ShapeShowAction extends SelectionAction {
+
+ public static final String ACTION_ID = "shapeShowId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class, "icons/shapeshow.png");
//$NON-NLS-1$
+
+ public ShapeShowAction(IWorkbenchPart editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ShapeShowAction_shape_show);
+ setToolTipText(DiagramViewerMessages.ShapeShowAction_shape_show_tooltip);
+ setImageDescriptor(img);
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
+
+ public void run() {
+ execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Command getCommand() {
+ CompoundCommand cc = new CompoundCommand();
+ if (getSelectedObjects().isEmpty()) {
+ return cc;
+ }
+ List<OrmShape> selectedShape = new ArrayList<OrmShape>();
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext()) {
+ Object firstElement = it.next();
+ 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) {
+ OrmShape ormShape = (OrmShape)obj;
+ if (!ormShape.isVisible()) {
+ selectedShape.add(ormShape);
+ }
+ }
+ }
+ if (selectedShape.size() > 0) {
+ cc.add(new ToggleShapeVisibleStateCommand(selectedShape));
+ }
+ return cc;
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return canPerformAction();
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean canPerformAction() {
+ boolean res = false;
+ if (getSelectedObjects().isEmpty()) {
+ return res;
+ }
+ Iterator it = getSelectedObjects().iterator();
+ while (it.hasNext() && !res) {
+ Object firstElement = it.next();
+ 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) {
+ OrmShape ormShape = (OrmShape)obj;
+ Object ormElement = ormShape.getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ if (!ormShape.isVisible()) {
+ res = true;
+ }
+ }
+ }
+ }
+ return res;
+ }
+}
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-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -44,9 +44,16 @@
setToolTipText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state_tooltip);
setImageDescriptor(img);
}
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
public void run() {
execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
}
@SuppressWarnings("unchecked")
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-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -46,9 +46,16 @@
setToolTipText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state_tooltip);
setImageDescriptor(img);
}
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
public void run() {
execute(getCommand());
+ if (getDiagramViewer() != null) {
+ getDiagramViewer().updateSelectionActions();
+ }
}
@SuppressWarnings("unchecked")
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterFanCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterFanCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterFanCommand.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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 ToggleConnectionRouterFanCommand extends Command {
+
+ protected boolean stateConnectionRouterFan;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleConnectionRouterFanCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionRouterFan = diagramViewer.isFanConnectionRouter();
+ }
+
+ public void execute() {
+ stateConnectionRouterFan = diagramViewer.isFanConnectionRouter();
+ diagramViewer.setFanConnectionRouter(true);
+ }
+
+ public void undo() {
+ diagramViewer.setFanConnectionRouter(stateConnectionRouterFan);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterManhattanCommand.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterManhattanCommand.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/command/ToggleConnectionRouterManhattanCommand.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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 ToggleConnectionRouterManhattanCommand extends Command {
+
+ protected boolean stateConnectionRouterManhattan;
+ protected DiagramViewer diagramViewer;
+
+ public ToggleConnectionRouterManhattanCommand(DiagramViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ stateConnectionRouterManhattan = diagramViewer.isManhattanConnectionRouter();
+ }
+
+ public void execute() {
+ stateConnectionRouterManhattan = diagramViewer.isManhattanConnectionRouter();
+ diagramViewer.setManhattanConnectionRouter(true);
+ }
+
+ public void undo() {
+ diagramViewer.setManhattanConnectionRouter(stateConnectionRouterManhattan);
+ }
+
+ public boolean canUndo() {
+ return (diagramViewer != null);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapecollapse.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapecollapse.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeexpand.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeexpand.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapehide.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapehide.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeshow.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/shapeshow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -67,19 +67,15 @@
}
public void setupManhattanConnectionRouter() {
- if (!isManhattanConnectionRouter()) {
- ConnectionLayer connLayer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
- connLayer.setConnectionRouter(new ManhattanConnectionRouter());
- getOrmDiagram().setupManhattanConnectionRouter();
- }
+ ConnectionLayer connLayer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
+ connLayer.setConnectionRouter(new ManhattanConnectionRouter());
+ getOrmDiagram().setupManhattanConnectionRouter();
}
public void setupFanConnectionRouter() {
- if (!isFanConnectionRouter()) {
- ConnectionLayer connLayer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
- connLayer.setConnectionRouter(new FanRouter());
- getOrmDiagram().setupFanConnectionRouter();
- }
+ ConnectionLayer connLayer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
+ connLayer.setConnectionRouter(new FanRouter());
+ getOrmDiagram().setupFanConnectionRouter();
}
public boolean isManhattanConnectionRouter() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-11-20
18:14:15 UTC (rev 18766)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-11-20
19:50:31 UTC (rev 18767)
@@ -33,8 +33,6 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
-import org.jboss.tools.hibernate.ui.diagram.editors.actions.CollapseAllAction;
-import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExpandAllAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.OpenSourceAction;
@@ -59,9 +57,10 @@
super(viewer);
this.actionRegistry = actionRegistry;
}
-
+
@SuppressWarnings("unchecked")
public void buildContextMenu(IMenuManager menu) {
+
// Add standard action groups to the menu
GEFActionConstants.addStandardActionGroups(menu);
@@ -139,13 +138,13 @@
appendToGroup(GEFActionConstants.GROUP_VIEW, action);
createMenuItem(getMenu(), action);
- action = getActionRegistry().getAction(CollapseAllAction.ACTION_ID);
- appendToGroup(GEFActionConstants.GROUP_VIEW, action);
- createMenuItem(getMenu(), action);
+ //action = getActionRegistry().getAction(CollapseAllAction.ACTION_ID);
+ //appendToGroup(GEFActionConstants.GROUP_VIEW, action);
+ //createMenuItem(getMenu(), action);
- action = getActionRegistry().getAction(ExpandAllAction.ACTION_ID);
- appendToGroup(GEFActionConstants.GROUP_VIEW, action);
- createMenuItem(getMenu(), action);
+ //action = getActionRegistry().getAction(ExpandAllAction.ACTION_ID);
+ //appendToGroup(GEFActionConstants.GROUP_VIEW, action);
+ //createMenuItem(getMenu(), action);
action = getActionRegistry().getAction(ExportImageAction.ACTION_ID);
appendToGroup(GEFActionConstants.MB_ADDITIONS, action);
@@ -176,7 +175,7 @@
if (hidden) {
return;
}
- MenuItem item = new MenuItem(menu, SWT.CASCADE);
+ MenuItem item = new MenuItem(menu, SWT.CASCADE | SWT.RADIO | SWT.CHECK);
String displayName = action.getText();
item.addSelectionListener(new AL(action));
item.setText(displayName);