Author: vyemialyanchyk
Date: 2009-10-27 11:17:23 -0400 (Tue, 27 Oct 2009)
New Revision: 18306
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/LexicalSortingAction.java
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/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/ToggleShapeExpandStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5009 - fixed
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-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -40,7 +40,9 @@
public static String OpenSourceAction_canot_open_source_file;
public static String OpenSourceAction_open_source_file;
public static String ToggleShapeExpandStateAction_toggle_expand_state;
+ public static String ToggleShapeExpandStateAction_toggle_expand_state_tooltip;
public static String ToggleShapeVisibleStateAction_toggle_visible_state;
+ public static String ToggleShapeVisibleStateAction_toggle_visible_state_tooltip;
public static String ToggleConnectionsAction_toggle_connections;
public static String ShapeSetConstraintCommand_move;
public static String PartFactory_canot_create_part_for_model_element;
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-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-10-27
15:17:23 UTC (rev 18306)
@@ -16,7 +16,9 @@
OpenSourceAction_canot_open_source_file=Can't open source file.
OpenSourceAction_open_source_file=Open Source File
ToggleShapeExpandStateAction_toggle_expand_state=Expand|Collapse
+ToggleShapeExpandStateAction_toggle_expand_state_tooltip=Expand|Collapse (Enter)
ToggleShapeVisibleStateAction_toggle_visible_state=Toggle visible state
+ToggleShapeVisibleStateAction_toggle_visible_state_tooltip=Toggle visible state (+)
ToggleConnectionsAction_toggle_connections=Show|Hide connections
ShapeSetConstraintCommand_move=move
PartFactory_canot_create_part_for_model_element=Can't create part for model element:
@@ -27,7 +29,7 @@
DiagramContentOutlinePage_Outline=Outline
DiagramContentOutlinePage_Overview=Overview
DiagramViewer_OutlinePage_Sort_label=Sort
-DiagramViewer_OutlinePage_Sort_tooltip=Sort
+DiagramViewer_OutlinePage_Sort_tooltip=Sort (Space)
DiagramViewer_OutlinePage_Sort_description=Enable Sorting
ToggleClassMappingAction_class_mappings=Class Mappings
TogglePropertyMappingAction_property_mappings=Property Mappings
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-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramContentOutlinePage.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -35,7 +35,6 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -45,6 +44,7 @@
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.LexicalSortingAction;
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;
@@ -167,6 +167,8 @@
bars.setGlobalActionHandler(id, registry.getAction(id));
id = ToggleShapeVisibleStateAction.ACTION_ID;
bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = LexicalSortingAction.ACTION_ID;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
bars.updateActionBars();
}
@@ -184,7 +186,7 @@
provider, getSite().getSelectionProvider());
IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
- tbm.add(new LexicalSortingAction());
+ tbm.add(editor.getLexicalSortingAction());
showOutlineAction = new Action() {
public void run() {
@@ -354,7 +356,11 @@
public void setOrmDiagram(OrmDiagram ormDiagram) {
this.ormDiagram = ormDiagram;
}
-
+
+ public Control getOutline() {
+ return outline;
+ }
+
public DiagramViewer getEditor() {
return editor;
}
@@ -366,37 +372,4 @@
protected ActionRegistry getActionRegistry() {
return actionRegistry;
}
-
- class LexicalSortingAction extends Action {
-
- @SuppressWarnings("restriction")
- public LexicalSortingAction() {
- super();
- setText(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_label);
- org.eclipse.jdt.internal.ui.JavaPluginImages.setLocalImageDescriptors(this,
"alphab_sort_co.gif"); //$NON-NLS-1$
- setToolTipText(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_tooltip);
- setDescription(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_description);
-
- boolean checked = getOrmDiagram().isDeepIntoSort();
- if (checked) {
- valueChanged(checked);
- }
- }
-
- public void run() {
- valueChanged(isChecked());
- }
-
- private void valueChanged(final boolean on) {
- setChecked(on);
- BusyIndicator.showWhile(outline.getDisplay(), new Runnable() {
- public void run() {
- final OrmDiagram od = getOrmDiagram();
- od.setDeepIntoSort(on);
- od.refresh();
- setContents(od);
- }
- });
- }
- }
}
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-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -23,6 +23,8 @@
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
import org.eclipse.gef.MouseWheelHandler;
import org.eclipse.gef.MouseWheelZoomHandler;
import org.eclipse.gef.SnapToGeometry;
@@ -44,6 +46,7 @@
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.GraphicalViewerKeyHandler;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.gef.ui.parts.TreeViewer;
import org.eclipse.gef.ui.rulers.RulerComposite;
@@ -65,6 +68,7 @@
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.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;
@@ -94,6 +98,7 @@
public class DiagramViewer extends GraphicalEditor {
private GEFRootEditPart gefRootEditPart = new GEFRootEditPart();
+ private KeyHandler sharedKeyHandler;
private RulerComposite rulerComp;
public DiagramViewer() {
@@ -129,6 +134,9 @@
final GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new OrmEditPartFactory());
//
+ viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
+ .setParent(getCommonKeyHandler()));
+ //
List<String> zoomLevels = new ArrayList<String>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
@@ -258,6 +266,9 @@
action = new ZoomOutAction(gefRootEditPart.getZoomManager());
registry.registerAction(action);
+ action = new LexicalSortingAction(this, null);
+ registry.registerAction(action);
+
Action[] act = new Action[4];
act[0] = (Action)registry.getAction(TogglePropertyMappingAction.ACTION_ID);
act[1] = (Action)registry.getAction(ToggleClassMappingAction.ACTION_ID);
@@ -344,6 +355,9 @@
RefreshAction refreshAction = (RefreshAction)getActionRegistry().getAction(
ActionFactory.REFRESH.getId());
refreshAction.setOutlinePage(outline);
+ LexicalSortingAction lexicalSortAction =
(LexicalSortingAction)getActionRegistry().getAction(
+ LexicalSortingAction.ACTION_ID);
+ lexicalSortAction.setOutlinePage(outline);
return outline;
}
if (type == ZoomManager.class) {
@@ -565,4 +579,31 @@
IAction action = registry.getAction(TogglePropertyMappingAction.ACTION_ID);
action.setChecked(connectionsVisibilityPropertyMapping);
}
+
+ /**
+ * Returns the KeyHandler with common bindings for both the Outline and Graphical
Views.
+ * For example, delete is a common action.
+ */
+ protected KeyHandler getCommonKeyHandler(){
+ if (sharedKeyHandler == null){
+ sharedKeyHandler = new KeyHandler();
+ sharedKeyHandler.put(
+ KeyStroke.getPressed('\r', Action.findKeyCode("RETURN"), 0),
//$NON-NLS-1$
+ getActionRegistry().getAction(ToggleShapeExpandStateAction.ACTION_ID));
+ sharedKeyHandler.put(
+ KeyStroke.getPressed('\r', SWT.KEYPAD_CR, 0),
+ getActionRegistry().getAction(ToggleShapeExpandStateAction.ACTION_ID));
+ sharedKeyHandler.put(
+ KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0),
+ getActionRegistry().getAction(ToggleShapeVisibleStateAction.ACTION_ID));
+ sharedKeyHandler.put(
+ KeyStroke.getReleased(' ', Action.findKeyCode("SPACE"), 0),
//$NON-NLS-1$
+ getActionRegistry().getAction(LexicalSortingAction.ACTION_ID));
+ }
+ return sharedKeyHandler;
+ }
+
+ public IAction getLexicalSortingAction() {
+ return getActionRegistry().getAction(LexicalSortingAction.ACTION_ID);
+ }
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/LexicalSortingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/LexicalSortingAction.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/LexicalSortingAction.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramContentOutlinePage;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+
+/**
+ * Lexical sort items.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class LexicalSortingAction extends Action {
+
+ public static final String ACTION_ID = "toggleLexicalSortingId";
//$NON-NLS-1$
+
+ private DiagramViewer diagramViewer;
+ private DiagramContentOutlinePage outlinePage;
+
+ @SuppressWarnings("restriction")
+ public LexicalSortingAction(DiagramViewer diagramViewer, DiagramContentOutlinePage
outlinePage) {
+ super(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_label, AS_CHECK_BOX);
+ setId(ACTION_ID);
+ this.diagramViewer = diagramViewer;
+ this.outlinePage = outlinePage;
+ setText(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_label);
+ org.eclipse.jdt.internal.ui.JavaPluginImages.setLocalImageDescriptors(this,
"alphab_sort_co.gif"); //$NON-NLS-1$
+ setToolTipText(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_tooltip);
+ setDescription(DiagramViewerMessages.DiagramViewer_OutlinePage_Sort_description);
+
+ boolean checked = getOrmDiagram().isDeepIntoSort();
+ setChecked(checked);
+ if (checked) {
+ valueChanged(checked);
+ }
+ }
+
+ public boolean isChecked() {
+ return getOrmDiagram().isDeepIntoSort();
+ }
+
+ public void run() {
+ valueChanged(!getOrmDiagram().isDeepIntoSort());
+ setChecked(getOrmDiagram().isDeepIntoSort());
+ }
+
+ private void valueChanged(final boolean on) {
+ BusyIndicator.showWhile(getDisplay(), new Runnable() {
+ public void run() {
+ final OrmDiagram od = getOrmDiagram();
+ od.setDeepIntoSort(on);
+ od.refresh();
+ if (outlinePage != null) {
+ outlinePage.setContents(od);
+ }
+ }
+ });
+ }
+
+ protected Display getDisplay () {
+ if (diagramViewer != null && diagramViewer.getEditPartViewer() != null
&&
+ diagramViewer.getEditPartViewer().getControl() != null) {
+ return diagramViewer.getEditPartViewer().getControl().getDisplay();
+ }
+ if (outlinePage != null && outlinePage.getOutline() != null) {
+ return outlinePage.getOutline().getDisplay();
+ }
+ return null;
+ }
+
+ public void setOutlinePage(DiagramContentOutlinePage outlinePage) {
+ this.outlinePage = outlinePage;
+ }
+
+ protected OrmDiagram getOrmDiagram() {
+ if (diagramViewer != null) {
+ return diagramViewer.getOrmDiagram();
+ }
+ if (outlinePage != null) {
+ return outlinePage.getOrmDiagram();
+ }
+ return null;
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeExpandStateAction.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -41,7 +41,7 @@
super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state);
- setToolTipText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state);
+ setToolTipText(DiagramViewerMessages.ToggleShapeExpandStateAction_toggle_expand_state_tooltip);
setImageDescriptor(img);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ToggleShapeVisibleStateAction.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -43,7 +43,7 @@
super(editor);
setId(ACTION_ID);
setText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state);
- setToolTipText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state);
+ setToolTipText(DiagramViewerMessages.ToggleShapeVisibleStateAction_toggle_visible_state_tooltip);
setImageDescriptor(img);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-27
15:11:41 UTC (rev 18305)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-27
15:17:23 UTC (rev 18306)
@@ -69,6 +69,7 @@
public static final String HIBERNATE_MAPPING_LAYOUT_FOLDER_NAME =
"hibernateMapping"; //$NON-NLS-1$
public static final String DIRTY = "dirty"; //$NON-NLS-1$
public static final String AUTOLAYOUT = "autolayout"; //$NON-NLS-1$
+ public static final String DEEPINTOSORT = "deepIntoSort"; //$NON-NLS-1$
// hibernate console configuration is the source of diagram elements
protected String consoleConfigName;
@@ -857,7 +858,10 @@
}
public void setDeepIntoSort(boolean deepIntoSort) {
- this.deepIntoSort = deepIntoSort;
+ if (this.deepIntoSort != deepIntoSort) {
+ this.deepIntoSort = deepIntoSort;
+ firePropertyChange(DEEPINTOSORT, null, null);
+ }
}
public boolean equals(Object obj) {