Changeset 1474
- Timestamp:
- 02/12/07 16:01:41 (2 years ago)
- Files:
-
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditor.java (modified) (12 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditorActionBarContributor.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseDomainFigure.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseResourceFigure.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainFigure.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainSourceConnectionAnchor.java (modified) (4 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainTargetConnectionAnchor.java (modified) (5 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/EntryPointFigure.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/PolicyComponentFigure.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/ResourceFigure.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditor.java
r1444 r1474 14 14 import java.util.EventObject; 15 15 import java.util.Iterator; 16 import java.util.List; 16 17 17 18 import org.eclipse.core.resources.IContainer; … … 20 21 import org.eclipse.core.resources.IWorkspaceRunnable; 21 22 import org.eclipse.core.runtime.CoreException; 23 import org.eclipse.core.runtime.IAdaptable; 22 24 import org.eclipse.core.runtime.IPath; 23 25 import org.eclipse.core.runtime.IProgressMonitor; 24 26 import org.eclipse.core.runtime.Path; 27 import org.eclipse.draw2d.PositionConstants; 25 28 import org.eclipse.gef.ContextMenuProvider; 26 29 import org.eclipse.gef.DefaultEditDomain; … … 29 32 import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; 30 33 import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; 34 import org.eclipse.gef.editparts.ZoomManager; 31 35 //import org.eclipse.gef.editparts.ZoomManager; 32 36 import org.eclipse.gef.palette.PaletteRoot; 33 37 import org.eclipse.gef.requests.CreationFactory; 34 38 import org.eclipse.gef.requests.SimpleFactory; 39 import org.eclipse.gef.ui.actions.ActionRegistry; 40 import org.eclipse.gef.ui.actions.AlignmentAction; 41 import org.eclipse.gef.ui.actions.CopyTemplateAction; 42 import org.eclipse.gef.ui.actions.MatchHeightAction; 43 import org.eclipse.gef.ui.actions.MatchWidthAction; 44 import org.eclipse.gef.ui.actions.ZoomInAction; 45 import org.eclipse.gef.ui.actions.ZoomOutAction; 35 46 import org.eclipse.gef.ui.palette.PaletteViewerProvider; 36 47 import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; … … 38 49 import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; 39 50 import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; 51 import org.eclipse.jface.action.IAction; 40 52 import org.eclipse.jface.dialogs.MessageDialog; 41 53 import org.eclipse.jface.util.TransferDropTargetListener; … … 45 57 import org.eclipse.jface.viewers.SelectionChangedEvent; 46 58 import org.eclipse.jface.viewers.StructuredSelection; 59 import org.eclipse.swt.SWT; 47 60 import org.eclipse.swt.widgets.Display; 61 import org.eclipse.swt.widgets.Event; 62 import org.eclipse.swt.widgets.Listener; 48 63 import org.eclipse.swt.widgets.Shell; 49 64 import org.eclipse.ui.IEditorInput; … … 54 69 import org.eclipse.ui.IWorkbenchPage; 55 70 import org.eclipse.ui.IWorkbenchPart; 71 import org.eclipse.ui.actions.ActionFactory; 56 72 import org.eclipse.ui.texteditor.IDocumentProvider; 57 73 import org.eclipse.ui.texteditor.IDocumentProviderExtension2; … … 131 147 132 148 m_rootEditPart = new ScalableFreeformRootEditPart (); 133 // ZoomManager mgr = m_rootEditPart.getZoomManager(); 134 // mgr.setZoom(2); 149 ZoomManager mgr = m_rootEditPart.getZoomManager(); 150 // mgr.setZoom(1); 151 152 List zoomLevels = new ArrayList(1); 153 zoomLevels.add(ZoomManager.FIT_ALL); 154 mgr.setZoomLevelContributions(zoomLevels); 155 156 IAction zoomIn = new ZoomInAction (mgr); 157 IAction zoomOut = new ZoomOutAction (mgr); 158 getActionRegistry().registerAction(zoomIn); 159 getActionRegistry().registerAction(zoomOut); 160 getSite().getKeyBindingService().registerAction(zoomIn); 161 getSite().getKeyBindingService().registerAction(zoomOut); 135 162 136 163 GraphicalViewer viewer = getGraphicalViewer(); … … 155 182 } 156 183 184 Listener listener = new Listener () 185 { 186 public void handleEvent (Event event) 187 { 188 handleActivationChanged (event); 189 } 190 }; 191 192 getGraphicalControl().addListener(SWT.Activate, listener); 193 } 194 195 196 protected void handleActivationChanged (Event event) 197 { 198 IAction copy = null; 199 if (event.type == SWT.Deactivate) 200 copy = getActionRegistry().getAction(ActionFactory.COPY.getId()); 201 if (getEditorSite().getActionBars().getGlobalActionHandler(ActionFactory.COPY.getId()) != copy) 202 { 203 getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), copy); 204 getEditorSite().getActionBars().updateActionBars(); 205 } 157 206 } 158 207 … … 206 255 // return m_outline; 207 256 } 257 258 if (adapter == ZoomManager.class) 259 return m_rootEditPart.getZoomManager(); 208 260 209 261 //TODO: this needs to return a custom PropertySheetPage … … 422 474 extension.elementStateValidationChanged(input, false); 423 475 } 424 425 476 } 426 477 … … 454 505 } 455 506 507 456 508 /** 457 509 * Create a transfer drop target listener. When using a CombinedTemplateCreationEntry … … 638 690 RefreshViewer(); 639 691 } 692 693 protected void createActions () 694 { 695 super.createActions (); 696 697 ActionRegistry registry = getActionRegistry(); 698 IAction action; 699 700 action = new CopyTemplateAction(this); 701 registry.registerAction(action); 702 703 action = new MatchWidthAction(this); 704 registry.registerAction(action); 705 getSelectionActions().add(action.getId()); 706 707 action = new MatchHeightAction (this); 708 registry.registerAction(action); 709 getSelectionActions().add(action.getId()); 710 711 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.LEFT); 712 registry.registerAction(action); 713 getSelectionActions().add(action.getId()); 714 715 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.RIGHT); 716 registry.registerAction(action); 717 getSelectionActions().add(action.getId()); 718 719 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.TOP); 720 registry.registerAction(action); 721 getSelectionActions().add(action.getId()); 722 723 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.BOTTOM); 724 registry.registerAction(action); 725 getSelectionActions().add(action.getId()); 726 727 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.CENTER); 728 registry.registerAction(action); 729 getSelectionActions().add(action.getId()); 730 731 action = new AlignmentAction((IWorkbenchPart)this, PositionConstants.MIDDLE); 732 registry.registerAction(action); 733 getSelectionActions().add(action.getId()); 734 } 640 735 641 736 /** trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditorActionBarContributor.java
r1041 r1474 11 11 package com.tresys.framework.plugin.editor.policy.graphic; 12 12 13 import org.eclipse.jface.action.IMenuManager; 13 14 import org.eclipse.jface.action.IToolBarManager; 15 import org.eclipse.jface.action.MenuManager; 16 import org.eclipse.jface.action.Separator; 17 import org.eclipse.ui.IWorkbenchActionConstants; 14 18 import org.eclipse.ui.actions.ActionFactory; 15 19 20 import org.eclipse.draw2d.PositionConstants; 21 import org.eclipse.gef.editparts.ZoomManager; 16 22 import org.eclipse.gef.ui.actions.ActionBarContributor; 23 import org.eclipse.gef.ui.actions.AlignmentRetargetAction; 17 24 import org.eclipse.gef.ui.actions.DeleteRetargetAction; 25 import org.eclipse.gef.ui.actions.GEFActionConstants; 26 import org.eclipse.gef.ui.actions.MatchHeightRetargetAction; 27 import org.eclipse.gef.ui.actions.MatchWidthRetargetAction; 18 28 import org.eclipse.gef.ui.actions.RedoRetargetAction; 19 29 import org.eclipse.gef.ui.actions.UndoRetargetAction; 30 import org.eclipse.gef.ui.actions.ZoomComboContributionItem; 31 import org.eclipse.gef.ui.actions.ZoomInRetargetAction; 32 import org.eclipse.gef.ui.actions.ZoomOutRetargetAction; 20 33 21 34 /** … … 24 37 * @author Elias Volanakis 25 38 */ 26 public class GraphicPolicyEditorActionBarContributor extends ActionBarContributor { 39 public class GraphicPolicyEditorActionBarContributor 40 extends ActionBarContributor 41 { 27 42 28 /** 29 * Create actions managed by this contributor. 30 * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() 31 */ 32 protected void buildActions() { 33 addRetargetAction(new DeleteRetargetAction()); 34 addRetargetAction(new UndoRetargetAction()); 35 addRetargetAction(new RedoRetargetAction()); 36 } 37 38 /** 39 * Add actions to the given toolbar. 40 * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager) 41 */ 42 public void contributeToToolBar(IToolBarManager toolBarManager) { 43 toolBarManager.add(getAction(ActionFactory.UNDO.getId())); 44 toolBarManager.add(getAction(ActionFactory.REDO.getId())); 45 } 43 /** 44 * Create actions managed by this contributor. 45 * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() 46 */ 47 protected void buildActions() 48 { 49 addRetargetAction(new DeleteRetargetAction()); 50 addRetargetAction(new UndoRetargetAction()); 51 addRetargetAction(new RedoRetargetAction()); 52 53 addRetargetAction(new AlignmentRetargetAction(PositionConstants.LEFT)); 54 addRetargetAction(new AlignmentRetargetAction(PositionConstants.CENTER)); 55 addRetargetAction(new AlignmentRetargetAction(PositionConstants.RIGHT)); 56 addRetargetAction(new AlignmentRetargetAction(PositionConstants.TOP)); 57 addRetargetAction(new AlignmentRetargetAction(PositionConstants.MIDDLE)); 58 addRetargetAction(new AlignmentRetargetAction(PositionConstants.BOTTOM)); 59 60 addRetargetAction(new ZoomInRetargetAction()); 61 addRetargetAction(new ZoomOutRetargetAction()); 62 63 addRetargetAction(new MatchWidthRetargetAction()); 64 addRetargetAction(new MatchHeightRetargetAction()); 65 } 66 67 /** 68 * Add actions to the given toolbar. 69 * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager) 70 */ 71 public void contributeToToolBar(IToolBarManager tbm) 72 { 73 tbm.add(getAction(ActionFactory.UNDO.getId())); 74 tbm.add(getAction(ActionFactory.REDO.getId())); 75 76 tbm.add(new Separator()); 77 tbm.add(getAction(GEFActionConstants.ALIGN_LEFT)); 78 tbm.add(getAction(GEFActionConstants.ALIGN_CENTER)); 79 tbm.add(getAction(GEFActionConstants.ALIGN_RIGHT)); 80 tbm.add(new Separator()); 81 tbm.add(getAction(GEFActionConstants.ALIGN_TOP)); 82 tbm.add(getAction(GEFActionConstants.ALIGN_MIDDLE)); 83 tbm.add(getAction(GEFActionConstants.ALIGN_BOTTOM)); 84 85 tbm.add(new Separator()); 86 tbm.add(getAction(GEFActionConstants.MATCH_WIDTH)); 87 tbm.add(getAction(GEFActionConstants.MATCH_HEIGHT)); 88 89 tbm.add(new Separator()); 90 String[] zoomStrings = new String[] { ZoomManager.FIT_ALL }; 91 tbm.add(new ZoomComboContributionItem (getPage(), zoomStrings)); 92 } 93 94 public void contributeToMenu (IMenuManager menuManager) 95 { 96 super.contributeToMenu (menuManager); 97 98 MenuManager viewMenu = new MenuManager("Policy Diagram"); 99 viewMenu.add(getAction(GEFActionConstants.ZOOM_IN)); 100 viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT)); 101 // viewMenu.add(new Separator()); 102 // viewMenu.add(getAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY)); 103 // viewMenu.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); 104 // viewMenu.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY)); 105 viewMenu.add(new Separator()); 106 viewMenu.add(getAction(GEFActionConstants.MATCH_WIDTH)); 107 viewMenu.add(getAction(GEFActionConstants.MATCH_HEIGHT)); 108 menuManager.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu); 109 } 46 110 47 111 /* trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseDomainFigure.java
r1450 r1474 51 51 graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 52 52 53 super.fillShape (graphics); 53 54 } 54 55 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseResourceFigure.java
r1450 r1474 51 51 graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 52 52 53 super.fillShape (graphics); 53 54 } 54 55 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainFigure.java
r1451 r1474 54 54 if (imgWarning != null) 55 55 graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 56 57 super.fillShape (graphics); 56 58 } 57 59 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainSourceConnectionAnchor.java
r1453 r1474 23 23 { 24 24 DomainTargetConnectionAnchor m_peer = null; 25 Point m_prevRefPoint = null; 25 26 26 27 private DomainSourceConnectionAnchor () … … 63 64 public void ancestorMoved (IFigure figure) 64 65 { 65 //System.out.println("Source Ancestor Moved - owner " + getOwner());66 System.out.println("Source Ancestor Moved - owner " + getOwner()); 66 67 67 68 super.ancestorMoved (figure); … … 71 72 public void anchorMoved (ConnectionAnchor anchor) 72 73 { 73 // System.out.println("Source Anchor Moved - owner " + getOwner());74 74 getOwner().repaint(); 75 /* 76 if (m_prevRefPoint == null) 77 m_prevRefPoint = anchor.getReferencePoint().getCopy(); 78 else 79 { 80 if (m_prevRefPoint.equals(anchor.getReferencePoint())) 81 return; 82 m_prevRefPoint = anchor.getReferencePoint().getCopy(); 83 } 84 */ 85 System.out.println("Source Anchor Moved - owner " + getOwner()); 75 86 for (Iterator itr = listeners.iterator(); itr.hasNext (); ) 76 87 { … … 80 91 listener.anchorMoved(this); 81 92 } 93 82 94 } 83 95 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainTargetConnectionAnchor.java
r1453 r1474 23 23 24 24 Point fixedLoc = null; 25 Point m_prevRefPoint = null; 25 26 26 27 private DomainTargetConnectionAnchor () … … 50 51 public void ancestorMoved (IFigure figure) 51 52 { 52 //System.out.println("Target Ancestor Moved - owner " + getOwner());53 super.ancestorMoved (figure);53 System.out.println("Target Ancestor Moved - owner " + getOwner()); 54 // super.ancestorMoved (figure); 54 55 } 55 56 … … 66 67 67 68 if (!fixedLoc.equals(oldLoc)) 69 { 70 if (oldLoc == null) 71 oldLoc = new Point (-1, -1); 72 System.out.println("Target Anchor - owner " + getOwner () + " Moved was: " + oldLoc.toString() + " now: " + fixedLoc.toString()); 68 73 anchorMoved(this); 74 } 69 75 70 76 return fixedLoc; … … 74 80 public void anchorMoved (ConnectionAnchor anchor) 75 81 { 76 // System.out.println("Target Anchor Moved - owner " + getOwner());77 82 // fixedLoc = anchor.getReferencePoint(); 83 /* 84 if (m_prevRefPoint == null) 85 m_prevRefPoint = anchor.getReferencePoint().getCopy(); 86 else 87 { 88 if (m_prevRefPoint.equals(anchor.getReferencePoint())) 89 return; 90 m_prevRefPoint = anchor.getReferencePoint().getCopy(); 91 } 92 */ 93 System.out.println("Target Anchor Moved - owner " + getOwner()); 78 94 79 95 for (Iterator itr = listeners.iterator(); itr.hasNext(); ) … … 84 100 listener.anchorMoved(this); 85 101 } 86 102 103 87 104 } 88 105 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/EntryPointFigure.java
r1450 r1474 65 65 if (imgWarning != null) 66 66 graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 67 68 super.fillShape (graphics); 67 69 } 68 70 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/PolicyComponentFigure.java
r1468 r1474 17 17 18 18 import org.eclipse.draw2d.ColorConstants; 19 import org.eclipse.draw2d.Graphics; 19 20 import org.eclipse.draw2d.Shape; 20 21 import org.eclipse.jface.resource.JFaceResources; … … 126 127 } 127 128 129 130 protected void fillShape (Graphics graphics) 131 { 132 // Rectangle bounds = new Rectangle (getBounds()); 133 // String location = bounds.x + "," + bounds.y + "," + bounds.width + "," + bounds.height; 134 135 // graphics.drawText (getName (), bounds.x + 5, bounds.y + bounds.height/2 - metrics.getHeight()); 136 // graphics.drawText (location, bounds.x + 5, bounds.y + bounds.height/2); 137 } 128 138 } trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/ResourceFigure.java
r1450 r1474 48 48 if (imgWarning != null) 49 49 graphics.drawImage(imgWarning, bounds.x + bounds.width/2 - 8, bounds.y); 50 51 super.fillShape (graphics); 50 52 } 51 53 … … 57 59 * @return <code>true</code>if the given point is contained 58 60 */ 59 public boolean containsPoint(int x, int y) { 61 public boolean containsPoint(int x, int y) 62 { 60 63 if (!super.containsPoint(x, y)) 61 64 return false; … … 72 75 * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics) 73 76 */ 74 protected void outlineShape(Graphics graphics) { 77 protected void outlineShape(Graphics graphics) 78 { 75 79 Rectangle r = Rectangle.SINGLETON; 76 80 r.setBounds(getBounds()); trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java
r1453 r1474 117 117 if (!(fig instanceof DomainFigure)) 118 118 return null; 119 120 ScrollPane scrollPane = new ScrollPane (); 119 121 120 122 if (pane == null) 121 123 { 122 124 pane = new ScalableFreeformLayeredPane (); 123 pane.setScale(0.75);124 125 pane.setLayoutManager (new FreeformLayout ()); 125 126 ScrollPane scrollPane = new ScrollPane (); 126 // pane.setScale(0.75); 127 127 128 fig.setLayoutManager(new StackLayout ()); // XYLayout ()); 128 129 fig.add (scrollPane); … … 131 132 132 133 ConnectionLayer connLayer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER); 133 connLayer.setConnectionRouter(new ShortestPathConnectionRouter (pane));134 connLayer.setConnectionRouter(new ShortestPathConnectionRouter (pane)); 134 135 135 136 pane.add(connLayer, LayerConstants.CONNECTION_LAYER); 137 136 138 } 137 139 … … 141 143 /* 142 144 * Searches registry for the connection using the model as the key. If not found, then create, and if 143 * found then return completed connection. Checks for the outer connection of the connection also145 * found then return completed connection. Checks for the outer connection of the connection also 144 146 * (non-Javadoc) 145 147 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createOrFindConnection(java.lang.Object)
