Changeset 1488
- Timestamp:
- 02/20/07 10:14:03
(2 years ago)
- Author:
- dsugar
- Message:
Final fix (hopefully) for dealing with routing and arrows in sub-domains ticket:109
Major change is now there is an invisible figure which is used at the target of the arrow rather than the main figure.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1474 |
r1488 |
|
| 21 | 21 | import org.eclipse.core.resources.IWorkspaceRunnable; |
|---|
| 22 | 22 | import org.eclipse.core.runtime.CoreException; |
|---|
| 23 | | import org.eclipse.core.runtime.IAdaptable; |
|---|
| 24 | 23 | import org.eclipse.core.runtime.IPath; |
|---|
| 25 | 24 | import org.eclipse.core.runtime.IProgressMonitor; |
|---|
| … | … | |
| 33 | 32 | import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; |
|---|
| 34 | 33 | import org.eclipse.gef.editparts.ZoomManager; |
|---|
| 35 | | //import org.eclipse.gef.editparts.ZoomManager; |
|---|
| 36 | 34 | import org.eclipse.gef.palette.PaletteRoot; |
|---|
| 37 | 35 | import org.eclipse.gef.requests.CreationFactory; |
|---|
| … | … | |
| 148 | 146 | m_rootEditPart = new ScalableFreeformRootEditPart (); |
|---|
| 149 | 147 | ZoomManager mgr = m_rootEditPart.getZoomManager(); |
|---|
| 150 | | // mgr.setZoom(1); |
|---|
| 151 | | |
|---|
| | 148 | |
|---|
| 152 | 149 | List zoomLevels = new ArrayList(1); |
|---|
| 153 | 150 | zoomLevels.add(ZoomManager.FIT_ALL); |
|---|
| 154 | 151 | mgr.setZoomLevelContributions(zoomLevels); |
|---|
| 155 | | |
|---|
| | 152 | |
|---|
| 156 | 153 | IAction zoomIn = new ZoomInAction (mgr); |
|---|
| 157 | 154 | IAction zoomOut = new ZoomOutAction (mgr); |
|---|
| … | … | |
| 160 | 157 | getSite().getKeyBindingService().registerAction(zoomIn); |
|---|
| 161 | 158 | getSite().getKeyBindingService().registerAction(zoomOut); |
|---|
| 162 | | |
|---|
| | 159 | |
|---|
| 163 | 160 | GraphicalViewer viewer = getGraphicalViewer(); |
|---|
| 164 | 161 | viewer.setEditPartFactory(new GraphicPolicyFactory ()); |
|---|
| … | … | |
| 374 | 371 | } |
|---|
| 375 | 372 | }, null); |
|---|
| 376 | | } catch (CoreException e) { |
|---|
| 377 | | } |
|---|
| 378 | | |
|---|
| | 373 | } |
|---|
| | 374 | catch (CoreException e) |
|---|
| | 375 | {} |
|---|
| 379 | 376 | |
|---|
| 380 | 377 | // mark as 'saved' |
|---|
| … | … | |
| 384 | 381 | public void doSaveAs () |
|---|
| 385 | 382 | { |
|---|
| 386 | | |
|---|
| 387 | 383 | } |
|---|
| 388 | 384 | |
|---|
| … | … | |
| 394 | 390 | protected void setDocumentProvider (IEditorInput input) |
|---|
| 395 | 391 | { |
|---|
| 396 | | |
|---|
| 397 | 392 | } |
|---|
| 398 | 393 | |
|---|
| … | … | |
| 535 | 530 | * @see IElementStateListener#elementDirtyStateChanged(Object, boolean) |
|---|
| 536 | 531 | */ |
|---|
| 537 | | public void elementDirtyStateChanged(Object element, boolean isDirty) { |
|---|
| | 532 | public void elementDirtyStateChanged(Object element, boolean isDirty) |
|---|
| | 533 | { |
|---|
| 538 | 534 | } |
|---|
| 539 | 535 | |
|---|
| r1468 |
r1488 |
|
| | 1 | /*\ |
|---|
| | 2 | |*| Copyright (C) 2006 Tresys Technology, LLC |
|---|
| | 3 | |*| License: refer to COPYING file for license information. |
|---|
| | 4 | |*| Author: David Sugar <dsugar@tresys.com> |
|---|
| | 5 | |*| |
|---|
| | 6 | |*| Version: @version@ |
|---|
| | 7 | \*/ |
|---|
| | 8 | |
|---|
| 1 | 9 | package com.tresys.framework.plugin.editor.policy.graphic.figure; |
|---|
| 2 | 10 | |
|---|
| r1479 |
r1488 |
|
| 23 | 23 | { |
|---|
| 24 | 24 | DomainTargetConnectionAnchor m_peer = null; |
|---|
| 25 | | // Rectangle m_figBounds = null; |
|---|
| 26 | | Point m_prevRefPoint = null; |
|---|
| 27 | 25 | |
|---|
| 28 | 26 | private DomainSourceConnectionAnchor () |
|---|
| … | … | |
| 46 | 44 | Point loc = m_peer.getLocation().getCopy(); |
|---|
| 47 | 45 | |
|---|
| 48 | | Rectangle bounds = getOwner().getBounds(); |
|---|
| | 46 | Rectangle bounds = getOwner().getBounds().getCopy(); |
|---|
| 49 | 47 | getOwner ().translateToAbsolute(bounds); |
|---|
| 50 | 48 | |
|---|
| … | … | |
| 52 | 50 | { |
|---|
| 53 | 51 | if (loc.x <= bounds.x) |
|---|
| 54 | | loc.x = bounds.x + 5; |
|---|
| | 52 | loc.x = bounds.x + 2; |
|---|
| 55 | 53 | if (loc.x >= bounds.x + bounds.width) |
|---|
| 56 | | loc.x = bounds.x + bounds.width - 5; |
|---|
| | 54 | loc.x = bounds.x + bounds.width - 2; |
|---|
| 57 | 55 | |
|---|
| 58 | 56 | if (loc.y <= bounds.y) |
|---|
| 59 | | loc.y = bounds.y + 5; |
|---|
| | 57 | loc.y = bounds.y + 2; |
|---|
| 60 | 58 | if (loc.y >= bounds.y + bounds.height) |
|---|
| 61 | | loc.y = bounds.y + bounds.height - 5; |
|---|
| | 59 | loc.y = bounds.y + bounds.height - 2; |
|---|
| 62 | 60 | } |
|---|
| 63 | 61 | |
|---|
| … | … | |
| 67 | 65 | public void ancestorMoved (IFigure figure) |
|---|
| 68 | 66 | { |
|---|
| 69 | | // if (figure.getBounds().equals(m_figBounds)) |
|---|
| 70 | | // return; |
|---|
| 71 | | |
|---|
| 72 | 67 | System.out.println("Source Ancestor Moved - owner " + getOwner() + " figure: " + figure ); |
|---|
| 73 | | // m_figBounds = figure.getBounds().getCopy(); |
|---|
| 74 | 68 | |
|---|
| 75 | 69 | super.ancestorMoved (figure); |
|---|
| … | … | |
| 79 | 73 | public void anchorMoved (ConnectionAnchor anchor) |
|---|
| 80 | 74 | { |
|---|
| 81 | | // getOwner().repaint(); |
|---|
| 82 | | /* |
|---|
| 83 | | if (m_prevRefPoint == null) |
|---|
| 84 | | m_prevRefPoint = anchor.getReferencePoint().getCopy(); |
|---|
| 85 | | else |
|---|
| 86 | | { |
|---|
| 87 | | if (m_prevRefPoint.equals(anchor.getReferencePoint())) |
|---|
| 88 | | return; |
|---|
| 89 | | m_prevRefPoint = anchor.getReferencePoint().getCopy(); |
|---|
| 90 | | } |
|---|
| 91 | | */ |
|---|
| 92 | 75 | System.out.println("Source Anchor Moved - owner " + getOwner()); |
|---|
| 93 | 76 | |
|---|
| r1479 |
r1488 |
|
| 23 | 23 | |
|---|
| 24 | 24 | Point fixedLoc = null; |
|---|
| 25 | | Point m_prevRefPoint = null; |
|---|
| 26 | | // Rectangle m_figBounds = null; |
|---|
| 27 | 25 | |
|---|
| 28 | 26 | private DomainTargetConnectionAnchor () |
|---|
| … | … | |
| 39 | 37 | |
|---|
| 40 | 38 | } |
|---|
| 41 | | /* |
|---|
| 42 | | public void setLocation (Point i_Location) |
|---|
| 43 | | { |
|---|
| 44 | | fixedLoc = i_Location; |
|---|
| 45 | | } |
|---|
| 46 | | */ |
|---|
| | 39 | |
|---|
| 47 | 40 | public DomainTargetConnectionAnchor (IFigure owner) |
|---|
| 48 | 41 | { |
|---|
| … | … | |
| 53 | 46 | public void ancestorMoved (IFigure figure) |
|---|
| 54 | 47 | { |
|---|
| 55 | | // if (figure.getBounds().equals(m_figBounds)) |
|---|
| 56 | | // return; |
|---|
| 57 | | |
|---|
| 58 | 48 | System.out.println("Target Ancestor Moved - owner " + getOwner() + " figure: " + figure); |
|---|
| 59 | | // m_figBounds = figure.getBounds().getCopy(); |
|---|
| 60 | | |
|---|
| 61 | 49 | super.ancestorMoved (figure); |
|---|
| 62 | 50 | } |
|---|
| … | … | |
| 64 | 52 | public Point getLocation (Point reference) |
|---|
| 65 | 53 | { |
|---|
| 66 | | //if (fixedLoc != null) |
|---|
| 67 | | // return fixedLoc; |
|---|
| 68 | | |
|---|
| 69 | 54 | Point oldLoc = null; |
|---|
| 70 | 55 | if (fixedLoc != null) |
|---|
| … | … | |
| 75 | 60 | if (!fixedLoc.equals(oldLoc)) |
|---|
| 76 | 61 | { |
|---|
| 77 | | // if (oldLoc == null) |
|---|
| 78 | | // oldLoc = new Point (-1, -1); |
|---|
| 79 | | |
|---|
| 80 | 62 | System.out.println("Target Anchor - owner " + getOwner () + " Moved was: " + oldLoc + " now: " + fixedLoc); |
|---|
| 81 | | |
|---|
| 82 | | if (oldLoc != null) |
|---|
| 83 | | { |
|---|
| 84 | | int nDistance = fixedLoc.getDistanceOrthogonal(oldLoc); |
|---|
| 85 | | System.out.println(" Orthogonal Distance: " + nDistance); |
|---|
| 86 | | if (nDistance < 5) |
|---|
| 87 | | return fixedLoc; |
|---|
| 88 | | } |
|---|
| 89 | | |
|---|
| 90 | 63 | anchorMoved(this); |
|---|
| 91 | 64 | } |
|---|
| … | … | |
| 97 | 70 | public void anchorMoved (ConnectionAnchor anchor) |
|---|
| 98 | 71 | { |
|---|
| 99 | | // fixedLoc = anchor.getReferencePoint(); |
|---|
| 100 | | /* |
|---|
| 101 | | if (m_prevRefPoint == null) |
|---|
| 102 | | m_prevRefPoint = anchor.getReferencePoint().getCopy(); |
|---|
| 103 | | else |
|---|
| 104 | | { |
|---|
| 105 | | if (m_prevRefPoint.equals(anchor.getReferencePoint())) |
|---|
| 106 | | return; |
|---|
| 107 | | m_prevRefPoint = anchor.getReferencePoint().getCopy(); |
|---|
| 108 | | } |
|---|
| 109 | | */ |
|---|
| 110 | 72 | System.out.println("Target Anchor Moved - owner " + getOwner()); |
|---|
| 111 | 73 | |
|---|
| … | … | |
| 123 | 85 | return "Domain Target Connection Anchor: " + getOwner().toString(); //$NON-NLS-1$ |
|---|
| 124 | 86 | } |
|---|
| 125 | | |
|---|
| 126 | 87 | } |
|---|
| r1456 |
r1488 |
|
| 1 | 1 | /*\ |
|---|
| 2 | | * |*| Copyright (C) 2006 Tresys Technology, LLC |
|---|
| | 2 | |*| Copyright (C) 2006 Tresys Technology, LLC |
|---|
| 3 | 3 | |*| License: refer to COPYING file for license information. |
|---|
| 4 | 4 | |*| Author: David Sugar <dsugar@tresys.com> |
|---|
| … | … | |
| 326 | 326 | cr.setLocation (loc); |
|---|
| 327 | 327 | } |
|---|
| 328 | | } |
|---|
| | 328 | |
|---|
| | 329 | |
|---|
| | 330 | } |
|---|
| 329 | 331 | |
|---|
| 330 | 332 | void add (ControlResourceShape i_controlResource) |
|---|
| r1480 |
r1488 |
|
| 31 | 31 | import com.tresys.framework.compiler.policy.Component; |
|---|
| 32 | 32 | import com.tresys.framework.compiler.policy.Enter; |
|---|
| | 33 | import com.tresys.framework.plugin.editor.policy.graphic.figure.ConnectionAnchorFigure; |
|---|
| 33 | 34 | import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainFigure; |
|---|
| 34 | 35 | import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainSourceConnectionAnchor; |
|---|
| … | … | |
| 49 | 50 | private ScalableFreeformLayeredPane m_layers = null; |
|---|
| 50 | 51 | private FreeformLayeredPane m_printableLayers = null; |
|---|
| | 52 | private ConnectionAnchorFigure m_connectionAnchor = null; |
|---|
| 51 | 53 | |
|---|
| 52 | 54 | public DomainEditPart () |
|---|
| … | … | |
| 64 | 66 | ConnectionLayer connectionLayer = new ConnectionLayer (); |
|---|
| 65 | 67 | connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter (mainLayer)); |
|---|
| 66 | | |
|---|
| | 68 | |
|---|
| 67 | 69 | m_printableLayers = new FreeformLayeredPane (); |
|---|
| 68 | 70 | m_printableLayers.setLayoutManager(new StackLayout ()); |
|---|
| 69 | 71 | m_printableLayers.add (connectionLayer, LayerConstants.CONNECTION_LAYER); |
|---|
| 70 | 72 | m_printableLayers.add (mainLayer, LayerConstants.PRIMARY_LAYER); |
|---|
| | 73 | |
|---|
| | 74 | mainLayer.add(m_connectionAnchor); |
|---|
| 71 | 75 | } |
|---|
| 72 | 76 | |
|---|
| … | … | |
| 74 | 78 | } |
|---|
| 75 | 79 | |
|---|
| | 80 | |
|---|
| | 81 | |
|---|
| 76 | 82 | protected LayeredPane getLayers () |
|---|
| 77 | 83 | { |
|---|
| … | … | |
| 132 | 138 | else if (getModel() instanceof IDomainShape) |
|---|
| 133 | 139 | { |
|---|
| 134 | | fig = new DomainFigure(); |
|---|
| | 140 | DomainFigure domFig = new DomainFigure(); |
|---|
| | 141 | m_connectionAnchor = new ConnectionAnchorFigure (domFig); |
|---|
| | 142 | fig = domFig; |
|---|
| 135 | 143 | } |
|---|
| 136 | 144 | |
|---|
| … | … | |
| 251 | 259 | if (connection instanceof AccessEditPart) |
|---|
| 252 | 260 | { |
|---|
| 253 | | IFigure domFig = getFigure (); |
|---|
| | 261 | // IFigure domFig = getFigure (); |
|---|
| 254 | 262 | |
|---|
| 255 | 263 | //Get the accessConnection returned from the AccessEditPart's getModel method |
|---|
| … | … | |
| 268 | 276 | //source anchors using the resource as the key |
|---|
| 269 | 277 | DomainTargetConnectionAnchor target = (DomainTargetConnectionAnchor) getTargetConnectionAnchor(connection); |
|---|
| 270 | | anchor = new DomainSourceConnectionAnchor (domFig, target); |
|---|
| | 278 | anchor = new DomainSourceConnectionAnchor (m_connectionAnchor, target); |
|---|
| 271 | 279 | sourceAnchors.put (resource, anchor); |
|---|
| 272 | 280 | // target.addAnchorListener(anchor); |
|---|
| … | … | |
| 280 | 288 | else if (connection instanceof EntryEditPart) |
|---|
| 281 | 289 | { |
|---|
| 282 | | IFigure domFig = getFigure (); |
|---|
| 283 | | |
|---|
| 284 | 290 | EntryConnection entryConnection = (EntryConnection) ((EntryEditPart) connection).getModel(); |
|---|
| 285 | 291 | Enter enter = entryConnection.getEnter(); |
|---|
| … | … | |
| 290 | 296 | { |
|---|
| 291 | 297 | DomainTargetConnectionAnchor target = (DomainTargetConnectionAnchor) getTargetConnectionAnchor(connection); |
|---|
| 292 | | anchor = new DomainSourceConnectionAnchor (domFig, target); |
|---|
| 293 | | sourceAnchors.put(start_domain , anchor); |
|---|
| | 298 | anchor = new DomainSourceConnectionAnchor (m_connectionAnchor, target); |
|---|
| | 299 | sourceAnchors.put (start_domain, anchor); |
|---|
| 294 | 300 | } |
|---|
| 295 | 301 | |
|---|
| 296 | 302 | return anchor; |
|---|
| 297 | | |
|---|
| 298 | 303 | } |
|---|
| 299 | 304 | |
|---|
| r1479 |
r1488 |
|
| 23 | 23 | |
|---|
| 24 | 24 | /** |
|---|
| 25 | | * constrain the rectnage to be contained in the parent domain |
|---|
| | 25 | * constrain the rectangle to be contained in the parent domain |
|---|
| 26 | 26 | */ |
|---|
| 27 | 27 | |
|---|
Download in other formats:
* Generating other formats may take time.