Author: vyemialyanchyk
Date: 2009-09-17 13:18:22 -0400 (Thu, 17 Sep 2009)
New Revision: 17640
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ActionMenu.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/RefreshAction.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/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/icons/toggleassociation.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleclassmapping.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleforeignkeyconstraint.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/togglepropertymapping.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate2.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/DiagramBaseAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseRetargetAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.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/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/icons/autolayout.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleconnections.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapevisiblestate.png
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java
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/Shape.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-4873,
https://jira.jboss.org/jira/browse/JBIDE-4620 - gui update (icons, toolbar, menu, new
action, small bugfix)
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -53,4 +53,8 @@
public static String DiagramViewer_OutlinePage_Sort_label;
public static String DiagramViewer_OutlinePage_Sort_tooltip;
public static String DiagramViewer_OutlinePage_Sort_description;
+ public static String ToggleClassMappingAction_class_mappings;
+ public static String TogglePropertyMappingAction_property_mappings;
+ public static String ToggleAssociationAction_associations;
+ public static String ToggleForeignKeyConstraintAction_foreign_key_constraints;
}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-09-17
17:18:22 UTC (rev 17640)
@@ -15,9 +15,9 @@
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=Toggle expand state
+ToggleShapeExpandStateAction_toggle_expand_state=Expand|Collapse
ToggleShapeVisibleStateAction_toggle_visible_state=Toggle visible state
-ToggleConnectionsAction_toggle_connections=Toggle connections
+ToggleConnectionsAction_toggle_connections=Show|Hide connections
ShapeSetConstraintCommand_move=move
PartFactory_canot_create_part_for_model_element=Can't create part for model element:
PartFactory_null=null
@@ -29,3 +29,7 @@
DiagramViewer_OutlinePage_Sort_label=Sort
DiagramViewer_OutlinePage_Sort_tooltip=Sort
DiagramViewer_OutlinePage_Sort_description=Enable Sorting
+ToggleClassMappingAction_class_mappings=Class Mappings
+TogglePropertyMappingAction_property_mappings=Property Mappings
+ToggleAssociationAction_associations=Associations
+ToggleForeignKeyConstraintAction_foreign_key_constraints=Foreign key constraints
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramActionBarContributor.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -19,6 +19,7 @@
import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
@@ -30,9 +31,14 @@
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
+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.ToggleAssociationAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleClassMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.DiagramBaseRetargetAction;
+import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleForeignKeyConstraintAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.TogglePropertyMappingAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.view.ImageBundle;
@@ -49,28 +55,72 @@
workbenchAction.setToolTipText(DiagramViewerMessages.EditorActionContributor_refresh_visual_mapping);
addAction(workbenchAction);
//
- addRetargetAction(new DiagramBaseRetargetAction(
+ DiagramBaseRetargetAction diagramAction;
+ Action[] act;
+ //
+ diagramAction = new DiagramBaseRetargetAction(
AutoLayoutAction.ACTION_ID,
DiagramViewerMessages.AutoLayoutAction_auto_layout,
DiagramViewerMessages.AutoLayoutAction_auto_layout,
- AutoLayoutAction.img));
+ AutoLayoutAction.img);
+ addRetargetAction(diagramAction);
//
- addRetargetAction(new DiagramBaseRetargetAction(
+ DiagramBaseRetargetAction diagramAction1 = new DiagramBaseRetargetAction(
ToggleConnectionsAction.ACTION_ID,
DiagramViewerMessages.ToggleConnectionsAction_toggle_connections,
DiagramViewerMessages.ToggleConnectionsAction_toggle_connections,
- ToggleConnectionsAction.img));
- addRetargetAction(new DiagramBaseRetargetAction(
+ ToggleConnectionsAction.img);
+ addRetargetAction(diagramAction1);
+ //
+ DiagramBaseRetargetAction diagramAction2 = new DiagramBaseRetargetAction(
ToggleShapeExpandStateAction.ACTION_ID,
DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state,
DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state,
- ToggleShapeExpandStateAction.img));
- addRetargetAction(new DiagramBaseRetargetAction(
+ ToggleShapeExpandStateAction.img);
+ addRetargetAction(diagramAction2);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
ToggleShapeVisibleStateAction.ACTION_ID,
DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state,
DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state,
- ToggleShapeVisibleStateAction.img));
+ ToggleShapeVisibleStateAction.img);
+ addRetargetAction(diagramAction);
//
+ diagramAction = new DiagramBaseRetargetAction(
+ ToggleClassMappingAction.ACTION_ID,
+ DiagramViewerMessages.ToggleClassMappingAction_class_mappings,
+ DiagramViewerMessages.ToggleClassMappingAction_class_mappings,
+ ToggleClassMappingAction.img, IAction.AS_CHECK_BOX);
+ addRetargetAction(diagramAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
+ TogglePropertyMappingAction.ACTION_ID,
+ DiagramViewerMessages.TogglePropertyMappingAction_property_mappings,
+ DiagramViewerMessages.TogglePropertyMappingAction_property_mappings,
+ TogglePropertyMappingAction.img, IAction.AS_CHECK_BOX);
+ addRetargetAction(diagramAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
+ ToggleAssociationAction.ACTION_ID,
+ DiagramViewerMessages.ToggleAssociationAction_associations,
+ DiagramViewerMessages.ToggleAssociationAction_associations,
+ ToggleAssociationAction.img, IAction.AS_CHECK_BOX);
+ addRetargetAction(diagramAction);
+ //
+ diagramAction = new DiagramBaseRetargetAction(
+ ToggleForeignKeyConstraintAction.ACTION_ID,
+ DiagramViewerMessages.ToggleForeignKeyConstraintAction_foreign_key_constraints,
+ DiagramViewerMessages.ToggleForeignKeyConstraintAction_foreign_key_constraints,
+ ToggleForeignKeyConstraintAction.img, IAction.AS_CHECK_BOX);
+ addRetargetAction(diagramAction);
+ //
+ act = new Action[4];
+ act[0] = (Action)getAction(TogglePropertyMappingAction.ACTION_ID);
+ act[1] = (Action)getAction(ToggleClassMappingAction.ACTION_ID);
+ act[2] = (Action)getAction(ToggleAssociationAction.ACTION_ID);
+ act[3] = (Action)getAction(ToggleForeignKeyConstraintAction.ACTION_ID);
+ diagramAction1.setMenuCreator(new ActionMenu(act));
+ //
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addRetargetAction(new ZoomInRetargetAction());
@@ -93,10 +143,10 @@
*/
public void contributeToToolBar(IToolBarManager tbm) {
tbm.add(getAction(ActionFactory.REFRESH.getId()));
- tbm.add(new Separator());
- tbm.add(getAction(ActionFactory.UNDO.getId()));
- tbm.add(getAction(ActionFactory.REDO.getId()));
- tbm.add(new Separator());
+ tbm.add(new Separator());
+ //tbm.add(getAction(ActionFactory.UNDO.getId()));
+ //tbm.add(getAction(ActionFactory.REDO.getId()));
+ //tbm.add(new Separator());
//tbm.add(getAction(GEFActionConstants.ZOOM_IN));
//tbm.add(getAction(GEFActionConstants.ZOOM_OUT));
String[] zoomStrings = new String[] {
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramContentOutlinePage.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -44,6 +44,10 @@
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.PageBook;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
+import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
+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;
@@ -151,6 +155,18 @@
bars.setGlobalActionHandler(id, registry.getAction(id));
id = ActionFactory.REDO.getId();
bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ActionFactory.REFRESH.getId();
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ActionFactory.PRINT.getId();
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = AutoLayoutAction.ACTION_ID;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ToggleConnectionsAction.ACTION_ID;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ToggleShapeExpandStateAction.ACTION_ID;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ToggleShapeVisibleStateAction.ACTION_ID;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
bars.updateActionBars();
}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -41,13 +41,13 @@
import org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction;
import org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction;
import org.eclipse.gef.ui.actions.UndoAction;
-import org.eclipse.gef.ui.actions.WorkbenchPartAction;
import org.eclipse.gef.ui.actions.ZoomInAction;
import org.eclipse.gef.ui.actions.ZoomOutAction;
import org.eclipse.gef.ui.parts.GraphicalEditor;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.gef.ui.parts.TreeViewer;
import org.eclipse.gef.ui.rulers.RulerComposite;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.util.TransferDropTargetListener;
import org.eclipse.swt.SWT;
@@ -60,6 +60,7 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.RootClass;
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.ExpandAllAction;
@@ -67,7 +68,12 @@
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.ToggleAssociationAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleClassMappingAction;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
+import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleForeignKeyConstraintAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.TogglePropertyMappingAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
@@ -81,7 +87,9 @@
import org.jboss.tools.hibernate.ui.view.ObjectEditorInput;
/**
- * @author some modifications from Vitali
+ *
+ * @author ?
+ * @author Vitali Yemialyanchyk
*/
public class DiagramViewer extends GraphicalEditor {
@@ -151,21 +159,15 @@
@SuppressWarnings("unchecked")
protected void createActions() {
- getEditorSite().getActionBars().setGlobalActionHandler(
- ActionFactory.REFRESH.getId(), new WorkbenchPartAction(this) {
-
- protected boolean calculateEnabled() {
- return true;
- }
- public void run() {
- ormDiagram.refresh();
- }
- });
-
//super.createActions();
// BEGIN: redefine super.createActions
ActionRegistry registry = getActionRegistry();
IAction action;
+
+ action = new RefreshAction(this);
+ registry.registerAction(action);
+ getEditorSite().getActionBars().setGlobalActionHandler(
+ ActionFactory.REFRESH.getId(), action);
action = new UndoAction(this);
registry.registerAction(action);
@@ -206,14 +208,28 @@
action = new AutoLayoutAction(this);
registry.registerAction(action);
- action = new ToggleConnectionsAction(this);
+ ToggleConnectionsAction actionToggleConnections = new ToggleConnectionsAction(this);
+ registry.registerAction(actionToggleConnections);
+
+ action = new ToggleAssociationAction(this);
registry.registerAction(action);
+ action = new ToggleClassMappingAction(this);
+ registry.registerAction(action);
+
+ action = new ToggleForeignKeyConstraintAction(this);
+ registry.registerAction(action);
+
+ action = new TogglePropertyMappingAction(this);
+ registry.registerAction(action);
+
action = new ToggleShapeExpandStateAction(this);
registry.registerAction(action);
+ getSelectionActions().add(action.getId());
action = new ToggleShapeVisibleStateAction(this);
registry.registerAction(action);
+ getSelectionActions().add(action.getId());
action = new CollapseAllAction(this);
registry.registerAction(action);
@@ -227,6 +243,13 @@
action = new ZoomOutAction(gefRootEditPart.getZoomManager());
registry.registerAction(action);
+ Action[] act = new Action[4];
+ act[0] = (Action)registry.getAction(TogglePropertyMappingAction.ACTION_ID);
+ act[1] = (Action)registry.getAction(ToggleClassMappingAction.ACTION_ID);
+ act[2] = (Action)registry.getAction(ToggleAssociationAction.ACTION_ID);
+ act[3] = (Action)registry.getAction(ToggleForeignKeyConstraintAction.ACTION_ID);
+ actionToggleConnections.setMenuCreator(new ActionMenu(act));
+
}
private TransferDropTargetListener createTransferDropTargetListener() {
@@ -304,6 +327,9 @@
outline.setSelectionSynchronizer(getSelectionSynchronizer());
outline.setOrmDiagram(ormDiagram);
outline.setEditor(this);
+ RefreshAction refreshAction = (RefreshAction)getActionRegistry().getAction(
+ ActionFactory.REFRESH.getId());
+ refreshAction.setOutlinePage(outline);
return outline;
}
if (type == ZoomManager.class) {
@@ -480,4 +506,49 @@
}
return res;
}
+
+
+ public boolean getConnectionsVisibilityAssociation() {
+ return getViewerContents().getConnectionsVisibilityAssociation();
+ }
+
+ public void setConnectionsVisibilityAssociation(boolean
connectionsVisibilityAssociation) {
+ getViewerContents().setConnectionsVisibilityAssociation(connectionsVisibilityAssociation);
+ ActionRegistry registry = getActionRegistry();
+ IAction action = registry.getAction(ToggleAssociationAction.ACTION_ID);
+ action.setChecked(connectionsVisibilityAssociation);
+ }
+
+ public boolean getConnectionsVisibilityClassMapping() {
+ return getViewerContents().getConnectionsVisibilityClassMapping();
+ }
+
+ public void setConnectionsVisibilityClassMapping(boolean
connectionsVisibilityClassMapping) {
+ getViewerContents().setConnectionsVisibilityClassMapping(connectionsVisibilityClassMapping);
+ ActionRegistry registry = getActionRegistry();
+ IAction action = registry.getAction(ToggleClassMappingAction.ACTION_ID);
+ action.setChecked(connectionsVisibilityClassMapping);
+ }
+
+ public boolean getConnectionsVisibilityForeignKeyConstraint() {
+ return getViewerContents().getConnectionsVisibilityForeignKeyConstraint();
+ }
+
+ public void setConnectionsVisibilityForeignKeyConstraint(boolean
connectionsVisibilityForeignKeyConstraint) {
+ getViewerContents().setConnectionsVisibilityForeignKeyConstraint(connectionsVisibilityForeignKeyConstraint);
+ ActionRegistry registry = getActionRegistry();
+ IAction action = registry.getAction(ToggleForeignKeyConstraintAction.ACTION_ID);
+ action.setChecked(connectionsVisibilityForeignKeyConstraint);
+ }
+
+ public boolean getConnectionsVisibilityPropertyMapping() {
+ return getViewerContents().getConnectionsVisibilityPropertyMapping();
+ }
+
+ public void setConnectionsVisibilityPropertyMapping(boolean
connectionsVisibilityPropertyMapping) {
+ getViewerContents().setConnectionsVisibilityPropertyMapping(connectionsVisibilityPropertyMapping);
+ ActionRegistry registry = getActionRegistry();
+ IAction action = registry.getAction(TogglePropertyMappingAction.ACTION_ID);
+ action.setChecked(connectionsVisibilityPropertyMapping);
+ }
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ActionMenu.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ActionMenu.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ActionMenu.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+
+/**
+ * Menu with list of actions.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ActionMenu extends Action implements IMenuCreator {
+
+ private Action[] actions;
+ private Menu menu;
+
+ public ActionMenu(Action[] actions) {
+ this.actions = actions;
+ if (this.actions.length > 0) {
+ setToolTipText(actions[0].getToolTipText());
+ setImageDescriptor(actions[0].getImageDescriptor());
+ if (actions.length > 1) {
+ setMenuCreator(this);
+ }
+ }
+ }
+
+ public void run() {
+ if (actions.length > 0) {
+ actions[0].run();
+ }
+ }
+
+ public void dispose() {
+ if (menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+
+ public Menu getMenu(Control parent) {
+ if (menu != null) {
+ menu.dispose();
+ }
+ menu = new Menu(parent);
+ for (int i = 0; i < actions.length; i++) {
+ addActionToMenu(menu, actions[i]);
+ }
+ return menu;
+ }
+
+ public Menu getMenu(Menu parent) {
+ if (menu != null) {
+ menu.dispose();
+ }
+ menu = new Menu(parent);
+ for (int i = 0; i < actions.length; i++) {
+ addActionToMenu(menu, actions[i]);
+ }
+ return menu;
+ }
+
+ protected void addActionToMenu(Menu parent, Action action) {
+ ActionContributionItem item = new ActionContributionItem(action);
+ item.fill(parent, -1);
+ }
+}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -27,6 +27,11 @@
public DiagramBaseAction(DiagramViewer editor) {
this.editor = editor;
}
+
+ public DiagramBaseAction(DiagramViewer editor, int style) {
+ super(null, style);
+ this.editor = editor;
+ }
protected DiagramViewer getDiagramViewer() {
DiagramViewer res = editor;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseRetargetAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseRetargetAction.java 2009-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseRetargetAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -24,5 +24,13 @@
setToolTipText(toolTipText);
setImageDescriptor(imgDescriptor);
}
+
+ public DiagramBaseRetargetAction(final String actionId, final String text,
+ final String toolTipText, final ImageDescriptor imgDescriptor,
+ int style) {
+ super(actionId, text, style);
+ setToolTipText(toolTipText);
+ setImageDescriptor(imgDescriptor);
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java 2009-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * 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,
@@ -16,11 +16,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.Column;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java 2009-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -16,11 +16,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.Column;
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/RefreshAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/RefreshAction.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/RefreshAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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 org.eclipse.gef.ui.actions.WorkbenchPartAction;
+import org.eclipse.ui.actions.ActionFactory;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramContentOutlinePage;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * Refresh diagram action
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class RefreshAction extends WorkbenchPartAction {
+
+ public static final String ACTION_ID = ActionFactory.REFRESH.getId();
+
+ protected DiagramContentOutlinePage outline = null;
+
+ public RefreshAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ }
+
+ protected DiagramViewer getDiagramViewer() {
+ return (DiagramViewer)getWorkbenchPart();
+ }
+
+ public void run() {
+ getDiagramViewer().getViewerContents().refresh();
+ if (outline != null) {
+ // synchronize contents of outline page
+ outline.setContents(outline.getOrmDiagram());
+ }
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return true;
+ }
+
+ public void setOutlinePage(DiagramContentOutlinePage outline) {
+ this.outline = outline;
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleAssociationAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -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.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * Show|Hide connections which type is "Associations" (class associations).
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleAssociationAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleAssociationId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleassociation.png"); //$NON-NLS-1$
+
+ public ToggleAssociationAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleAssociationAction_associations);
+ setToolTipText(DiagramViewerMessages.ToggleAssociationAction_associations);
+ setImageDescriptor(img);
+ boolean state = getDiagramViewer().getConnectionsVisibilityAssociation();
+ setChecked(state);
+ }
+
+ public void run() {
+ boolean state = getDiagramViewer().getConnectionsVisibilityAssociation();
+ getDiagramViewer().setConnectionsVisibilityAssociation(!state);
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleClassMappingAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -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.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * Show|Hide connections which type is "Class Mappings" (class->table).
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleClassMappingAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleClassMappingId"; //$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleclassmapping.png"); //$NON-NLS-1$
+
+ public ToggleClassMappingAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleClassMappingAction_class_mappings);
+ setToolTipText(DiagramViewerMessages.ToggleClassMappingAction_class_mappings);
+ setImageDescriptor(img);
+ boolean state = getDiagramViewer().getConnectionsVisibilityClassMapping();
+ setChecked(state);
+ }
+
+ public void run() {
+ boolean state = getDiagramViewer().getConnectionsVisibilityClassMapping();
+ getDiagramViewer().setConnectionsVisibilityClassMapping(!state);
+ }
+}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleConnectionsAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -15,6 +15,8 @@
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
/**
+ * Show|Hide all connections.
+ *
* @author Vitali Yemialyanchyk
*/
public class ToggleConnectionsAction extends DiagramBaseAction {
@@ -24,7 +26,7 @@
ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleconnections.png"); //$NON-NLS-1$
public ToggleConnectionsAction(DiagramViewer editor) {
- super(editor);
+ super(editor, AS_DROP_DOWN_MENU);
setId(ACTION_ID);
setText(DiagramViewerMessages.ToggleConnectionsAction_toggle_connections);
setToolTipText(DiagramViewerMessages.ToggleConnectionsAction_toggle_connections);
@@ -32,6 +34,13 @@
}
public void run() {
- getDiagramViewer().getViewerContents().toggleConnections();
+ 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);
}
}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleForeignKeyConstraintAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -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.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * Show|Hide connections which type is "Foreign key constraints"
+ * (foreign keys which associations are based on).
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ToggleForeignKeyConstraintAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "toggleForeignKeyConstraintId";
//$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleforeignkeyconstraint.png"); //$NON-NLS-1$
+
+ public ToggleForeignKeyConstraintAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.ToggleForeignKeyConstraintAction_foreign_key_constraints);
+ setToolTipText(DiagramViewerMessages.ToggleForeignKeyConstraintAction_foreign_key_constraints);
+ setImageDescriptor(img);
+ boolean state = getDiagramViewer().getConnectionsVisibilityForeignKeyConstraint();
+ setChecked(state);
+ }
+
+ public void run() {
+ boolean state = getDiagramViewer().getConnectionsVisibilityForeignKeyConstraint();
+ getDiagramViewer().setConnectionsVisibilityForeignKeyConstraint(!state);
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/TogglePropertyMappingAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -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.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+
+/**
+ * Show|Hide connections which type is "Property Mappings"
(property->column).
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class TogglePropertyMappingAction extends DiagramBaseAction {
+
+ public static final String ACTION_ID = "togglePropertyMappingId";
//$NON-NLS-1$
+ public static final ImageDescriptor img =
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/togglepropertymapping.png"); //$NON-NLS-1$
+
+ public TogglePropertyMappingAction(DiagramViewer editor) {
+ super(editor);
+ setId(ACTION_ID);
+ setText(DiagramViewerMessages.TogglePropertyMappingAction_property_mappings);
+ setToolTipText(DiagramViewerMessages.TogglePropertyMappingAction_property_mappings);
+ setImageDescriptor(img);
+ boolean state = getDiagramViewer().getConnectionsVisibilityPropertyMapping();
+ setChecked(state);
+ }
+
+ public void run() {
+ boolean state = getDiagramViewer().getConnectionsVisibilityPropertyMapping();
+ getDiagramViewer().setConnectionsVisibilityPropertyMapping(!state);
+ }
+}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -15,10 +15,9 @@
import java.util.List;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
+import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
+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.model.ExpandableShape;
@@ -29,13 +28,13 @@
*
* @author Vitali Yemialyanchyk
*/
-public class ToggleShapeExpandStateAction extends DiagramBaseAction {
+public class ToggleShapeExpandStateAction extends SelectionAction {
public static final String ACTION_ID = "toggleShapeExpandStateId";
//$NON-NLS-1$
public static final ImageDescriptor img =
- ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleshapeexpandstate.png"); //$NON-NLS-1$
+ ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleshapeexpandstate2.png"); //$NON-NLS-1$
- public ToggleShapeExpandStateAction(DiagramViewer editor) {
+ public ToggleShapeExpandStateAction(IWorkbenchPart editor) {
super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state);
@@ -45,29 +44,52 @@
@SuppressWarnings("unchecked")
public void run() {
- ISelection selection = getDiagramViewer().getEditPartViewer().getSelection();
- if (!(selection instanceof StructuredSelection)) {
+ if (getSelectedObjects().isEmpty()) {
return;
}
List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
- IStructuredSelection structedSelection = (IStructuredSelection)selection;
- if (structedSelection != null) {
- Iterator it = structedSelection.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) {
- selectedShape.add((ExpandableShape)obj);
- }
+ 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) {
+ selectedShape.add((ExpandableShape)obj);
+ }
}
for (ExpandableShape shape : selectedShape) {
shape.setExpanded(!shape.isExpanded());
}
}
+
+ @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) {
+ res = true;
+ }
+ }
+ return res;
+ }
}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -15,10 +15,9 @@
import java.util.List;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
+import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
@@ -31,13 +30,13 @@
*
* @author Vitali Yemialyanchyk
*/
-public class ToggleShapeVisibleStateAction extends DiagramBaseAction {
+public class ToggleShapeVisibleStateAction extends SelectionAction {
public static final String ACTION_ID = "toggleShapeVisibleStateId";
//$NON-NLS-1$
public static final ImageDescriptor img =
ImageDescriptor.createFromFile(DiagramViewer.class,
"icons/toggleshapevisiblestate.png"); //$NON-NLS-1$
- public ToggleShapeVisibleStateAction(DiagramViewer editor) {
+ public ToggleShapeVisibleStateAction(IWorkbenchPart editor) {
super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state);
@@ -47,26 +46,22 @@
@SuppressWarnings("unchecked")
public void run() {
- ISelection selection = getDiagramViewer().getEditPartViewer().getSelection();
- if (!(selection instanceof StructuredSelection)) {
+ if (getSelectedObjects().isEmpty()) {
return;
}
List<OrmShape> selectedShape = new ArrayList<OrmShape>();
- IStructuredSelection structedSelection = (IStructuredSelection)selection;
- if (structedSelection != null) {
- Iterator it = structedSelection.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) {
- selectedShape.add((OrmShape)obj);
- }
+ 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) {
+ selectedShape.add((OrmShape)obj);
+ }
}
for (OrmShape shape : selectedShape) {
Object ormElement = shape.getOrmElement();
@@ -75,4 +70,34 @@
}
}
}
+
+ @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) {
+ Object ormElement = ((OrmShape)obj).getOrmElement();
+ if (ormElement instanceof PersistentClass || ormElement instanceof Table) {
+ res = true;
+ }
+ }
+ }
+ return res;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/autolayout.png
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleassociation.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleassociation.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/toggleclassmapping.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleclassmapping.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/icons/toggleconnections.png
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleforeignkeyconstraint.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleforeignkeyconstraint.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/togglepropertymapping.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/togglepropertymapping.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/icons/toggleshapeexpandstate.png
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate2.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/icons/toggleshapeexpandstate2.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/icons/toggleshapevisiblestate.png
===================================================================
(Binary files differ)
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java 2009-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Connection.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -13,12 +13,20 @@
/**
* Directed connection between 2 shapes, from source to target.
*
- * @author some modifications from Vitali
+ * @author ?
+ * @author Vitali Yemialyanchyk
*/
public class Connection extends BaseElement {
protected Shape source;
protected Shape target;
+
+ public enum ConnectionType {
+ ClassMapping,
+ PropertyMapping,
+ Association,
+ ForeignKeyConstraint,
+ };
/**
* flag to prevent cycle call of updateVisibleValue()
@@ -42,6 +50,20 @@
public Shape getTarget() {
return target;
}
+
+ public ConnectionType getConnectionType() {
+ if ((source instanceof OrmShape) && (target instanceof OrmShape)) {
+ return ConnectionType.ClassMapping;
+ }
+ if ((source instanceof OrmShape) || (target instanceof OrmShape)) {
+ return ConnectionType.Association;
+ }
+ // TODO: what is ForeignKeyConstraint?
+ //if ( ??? ) {
+ // return ConnectionType.ForeignKeyConstraint;
+ //}
+ return ConnectionType.PropertyMapping;
+ }
/**
* It has no children, so not possible to add.
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -39,6 +39,7 @@
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.mapping.RootClass;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection.ConnectionType;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
@@ -62,7 +63,10 @@
private HashMap<String, OrmShape> elements = new HashMap<String,
OrmShape>();
private RootClass[] ormElements;
private String[] entityNames;
- private boolean connectionsVisibility = true;
+ private boolean connectionsVisibilityClassMapping = true;
+ private boolean connectionsVisibilityPropertyMapping = true;
+ private boolean connectionsVisibilityAssociation = true;
+ private boolean connectionsVisibilityForeignKeyConstraint = true;
private ArrayList<Connection> connections = new ArrayList<Connection>();
// editor elements settings
@@ -315,27 +319,74 @@
firePropertyChange(AUTOLAYOUT, null, null);
}
- public boolean getConnectionsVisibility() {
- return connectionsVisibility;
+ public boolean getConnectionsVisibilityAssociation() {
+ return connectionsVisibilityAssociation;
}
- public void setConnectionsVisibility(boolean connectionsVisibility) {
- if (this.connectionsVisibility == connectionsVisibility) {
+ public void setConnectionsVisibilityAssociation(boolean
connectionsVisibilityAssociation) {
+ if (this.connectionsVisibilityAssociation == connectionsVisibilityAssociation) {
return;
}
- this.connectionsVisibility = connectionsVisibility;
+ this.connectionsVisibilityAssociation = connectionsVisibilityAssociation;
for (Connection connection : connections) {
- if (!(connection.getSource() instanceof OrmShape) ||
- !(connection.getTarget() instanceof OrmShape)) {
- connection.setVisible(connectionsVisibility);
+ ConnectionType ct = connection.getConnectionType();
+ if (ct == ConnectionType.Association) {
+ connection.setVisible(connectionsVisibilityAssociation);
}
}
}
- public void toggleConnections() {
- setConnectionsVisibility(!getConnectionsVisibility());
+ public boolean getConnectionsVisibilityClassMapping() {
+ return connectionsVisibilityClassMapping;
}
+ public void setConnectionsVisibilityClassMapping(boolean
connectionsVisibilityClassMapping) {
+ if (this.connectionsVisibilityClassMapping == connectionsVisibilityClassMapping) {
+ return;
+ }
+ this.connectionsVisibilityClassMapping = connectionsVisibilityClassMapping;
+ for (Connection connection : connections) {
+ ConnectionType ct = connection.getConnectionType();
+ if (ct == ConnectionType.ClassMapping) {
+ connection.setVisible(connectionsVisibilityClassMapping);
+ }
+ }
+ }
+
+ public boolean getConnectionsVisibilityForeignKeyConstraint() {
+ return connectionsVisibilityForeignKeyConstraint;
+ }
+
+ public void setConnectionsVisibilityForeignKeyConstraint(boolean
connectionsVisibilityForeignKeyConstraint) {
+ if (this.connectionsVisibilityForeignKeyConstraint ==
connectionsVisibilityForeignKeyConstraint) {
+ return;
+ }
+ this.connectionsVisibilityForeignKeyConstraint =
connectionsVisibilityForeignKeyConstraint;
+ for (Connection connection : connections) {
+ ConnectionType ct = connection.getConnectionType();
+ if (ct == ConnectionType.ForeignKeyConstraint) {
+ connection.setVisible(connectionsVisibilityForeignKeyConstraint);
+ }
+ }
+ }
+
+ public boolean getConnectionsVisibilityPropertyMapping() {
+ return connectionsVisibilityPropertyMapping;
+ }
+
+ public void setConnectionsVisibilityPropertyMapping(boolean
connectionsVisibilityPropertyMapping) {
+ if (this.connectionsVisibilityPropertyMapping == connectionsVisibilityPropertyMapping)
{
+ return;
+ }
+ this.connectionsVisibilityPropertyMapping = connectionsVisibilityPropertyMapping;
+ for (Connection connection : connections) {
+ ConnectionType ct = connection.getConnectionType();
+ if (ct == ConnectionType.PropertyMapping) {
+ connection.setVisible(connectionsVisibilityPropertyMapping);
+ }
+ }
+ }
+
@Override
protected void loadFromProperties(Properties properties) {
super.loadFromProperties(properties);
@@ -349,6 +400,14 @@
zoom = Double.valueOf(str).doubleValue();
str = properties.getProperty("deepIntoSort", "false");
//$NON-NLS-1$ //$NON-NLS-2$
deepIntoSort = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("connectionsVisibilityAssociation",
"true"); //$NON-NLS-1$ //$NON-NLS-2$
+ connectionsVisibilityAssociation = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("connectionsVisibilityClassMapping",
"true"); //$NON-NLS-1$ //$NON-NLS-2$
+ connectionsVisibilityClassMapping = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("connectionsVisibilityForeignKeyConstraint",
"true"); //$NON-NLS-1$ //$NON-NLS-2$
+ connectionsVisibilityForeignKeyConstraint = Boolean.valueOf(str).booleanValue();
+ str = properties.getProperty("connectionsVisibilityPropertyMapping",
"true"); //$NON-NLS-1$ //$NON-NLS-2$
+ connectionsVisibilityPropertyMapping = Boolean.valueOf(str).booleanValue();
}
@Override
@@ -358,6 +417,10 @@
properties.put("gridEnabled", "" + gridEnabled); //$NON-NLS-1$
//$NON-NLS-2$
properties.put("zoom", "" + zoom); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("deepIntoSort", "" + deepIntoSort); //$NON-NLS-1$
//$NON-NLS-2$
+ properties.put("connectionsVisibilityAssociation", "" +
connectionsVisibilityAssociation); //$NON-NLS-1$ //$NON-NLS-2$
+ properties.put("connectionsVisibilityClassMapping", "" +
connectionsVisibilityClassMapping); //$NON-NLS-1$ //$NON-NLS-2$
+ properties.put("connectionsVisibilityForeignKeyConstraint", "" +
connectionsVisibilityForeignKeyConstraint); //$NON-NLS-1$ //$NON-NLS-2$
+ properties.put("connectionsVisibilityPropertyMapping", "" +
connectionsVisibilityPropertyMapping); //$NON-NLS-1$ //$NON-NLS-2$
super.saveInProperties(properties);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2009-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -20,6 +20,7 @@
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection.ConnectionType;
import org.jboss.tools.hibernate.ui.view.HibernateUtils;
/**
@@ -171,10 +172,42 @@
super.updateVisibleValue(initState);
// update connections visibility state
for (Connection connection : sourceConnections) {
- connection.updateVisibleValue(getOrmDiagram().getConnectionsVisibility());
+ boolean state = true;
+ ConnectionType ct = connection.getConnectionType();
+ switch (ct) {
+ case ClassMapping:
+ state = getOrmDiagram().getConnectionsVisibilityClassMapping();
+ break;
+ case PropertyMapping:
+ state = getOrmDiagram().getConnectionsVisibilityPropertyMapping();
+ break;
+ case Association:
+ state = getOrmDiagram().getConnectionsVisibilityAssociation();
+ break;
+ case ForeignKeyConstraint:
+ state = getOrmDiagram().getConnectionsVisibilityForeignKeyConstraint();
+ break;
+ }
+ connection.updateVisibleValue(state);
}
for (Connection connection : targetConnections) {
- connection.updateVisibleValue(getOrmDiagram().getConnectionsVisibility());
+ boolean state = true;
+ ConnectionType ct = connection.getConnectionType();
+ switch (ct) {
+ case ClassMapping:
+ state = getOrmDiagram().getConnectionsVisibilityClassMapping();
+ break;
+ case PropertyMapping:
+ state = getOrmDiagram().getConnectionsVisibilityPropertyMapping();
+ break;
+ case Association:
+ state = getOrmDiagram().getConnectionsVisibilityAssociation();
+ break;
+ case ForeignKeyConstraint:
+ state = getOrmDiagram().getConnectionsVisibilityForeignKeyConstraint();
+ break;
+ }
+ connection.updateVisibleValue(state);
}
}
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-09-17
16:41:17 UTC (rev 17639)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-09-17
17:18:22 UTC (rev 17640)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * 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
*
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.popup;
@@ -41,13 +41,16 @@
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction;
import
org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
/**
* Context menu provider for Diagram Viewer and Diagram Outline.
*
- * @author some modifications from Vitali
+ * @author ?
+ * @author Vitali Yemialyanchyk
*/
public class PopupMenuProvider extends ContextMenuProvider {
private ActionRegistry actionRegistry;
@@ -94,9 +97,10 @@
createMenuItem(getMenu(), action);
}
}
- boolean addToggleMenu = false;
+ boolean addToggleVisibleStateMenu = false;
+ boolean addToggleExpandStateMenu = false;
Iterator it = selection.iterator();
- while (it.hasNext() && !addToggleMenu) {
+ while (it.hasNext() && (!addToggleVisibleStateMenu ||
!addToggleExpandStateMenu)) {
Object element = it.next();
Object obj = null;
if (element instanceof OrmEditPart) {
@@ -104,19 +108,23 @@
} else if (element instanceof AbstractTreeEditPart) {
obj = ((AbstractTreeEditPart)element).getModel();
}
- if (null != obj && obj instanceof Shape) {
+ if (null != obj && obj instanceof OrmShape) {
selectedShape = (Shape)obj;
Object first = selectedShape.getOrmElement();
if (first instanceof PersistentClass || first instanceof Table) {
- addToggleMenu = true;
+ addToggleVisibleStateMenu = true;
}
+ }
+ if (null != obj && obj instanceof ExpandableShape) {
+ addToggleExpandStateMenu = true;
}
}
- if (addToggleMenu) {
+ if (addToggleVisibleStateMenu) {
action = getActionRegistry().getAction(ToggleShapeVisibleStateAction.ACTION_ID);
appendToGroup(GEFActionConstants.GROUP_EDIT, action);
createMenuItem(getMenu(), action);
-
+ }
+ if (addToggleExpandStateMenu) {
action = getActionRegistry().getAction(ToggleShapeExpandStateAction.ACTION_ID);
appendToGroup(GEFActionConstants.GROUP_EDIT, action);
createMenuItem(getMenu(), action);