Changeset 1479

Show
Ignore:
Timestamp:
02/15/07 16:43:38 (2 years ago)
Author:
dsugar
Message:

More work for routing of connections in sub-domains. Getting better. Now I think the layers are setup correctly.
Still a problem when zomming in/out with the whole diagram, but the connection layer in domains seems to route ok.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainSourceConnectionAnchor.java

    r1476 r1479  
    2020public class DomainSourceConnectionAnchor 
    2121        extends ChopboxAnchor //extends AbstractConnectionAnchor 
    22 //    implements AnchorListener 
     22      implements AnchorListener 
    2323{ 
    2424        DomainTargetConnectionAnchor m_peer = null; 
     
    3737 
    3838                m_peer = i_peer; 
    39 //            i_peer.addAnchorListener(this); 
    40 //            addAnchorListener(i_peer); 
     39              i_peer.addAnchorListener(this); 
     40              addAnchorListener(i_peer); 
    4141        } 
    4242 
     
    7474                 
    7575                super.ancestorMoved (figure); 
    76 //            getOwner().repaint(); 
     76              getOwner().repaint(); 
    7777        } 
    7878 
     
    9191*/ 
    9292                System.out.println("Source Anchor Moved - owner " + getOwner()); 
    93 /* 
     93 
    9494                for (Iterator itr = listeners.iterator(); itr.hasNext (); ) 
    9595                { 
     
    9999                        listener.anchorMoved(this); 
    100100                } 
    101 */ 
     101 
    102102        } 
    103103         
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainTargetConnectionAnchor.java

    r1476 r1479  
    1616import org.eclipse.draw2d.IFigure; 
    1717import org.eclipse.draw2d.geometry.Point; 
    18 import org.eclipse.draw2d.geometry.Rectangle; 
    1918 
    2019public class DomainTargetConnectionAnchor 
    2120        extends ChopboxAnchor 
    22 //    implements AnchorListener 
     21      implements AnchorListener 
    2322{ 
    2423         
     
    8988                        } 
    9089                         
    91 //                    anchorMoved(this); 
     90                      anchorMoved(this); 
    9291                } 
    9392                 
     
    118117                        listener.anchorMoved(this); 
    119118                } 
    120  
    121  
    122119        } 
    123120 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/AbstractConnectionEditPart.java

    r1475 r1479  
    4848                new XYAnchor(new Point(100, 100)); 
    4949 
    50       private IFigure m_connectionLayer = null; 
     50//    private IFigure m_connectionLayer = null; 
    5151        /** 
    5252         * Provides accessibility support for when connections are also themselves nodes. If a 
     
    287287                if (!wasNull && (!bSameParent || becomingNull)) 
    288288                        removeNotify(); 
    289               m_connectionLayer = null; 
     289//            m_connectionLayer = null; 
    290290                super.setParent(parent); 
    291291                if (!becomingNull && (!bSameParent || wasNull)) 
     
    339339                        EditPart ep = getSource().getParent(); 
    340340                        EditPart epParent = editPart.getParent(); 
    341                       EditPart thisPart = this; 
    342                       EditPart thisSourceParent = getSource().getParent(); 
    343                         Assert.isTrue(getSource().getParent() == editPart.getParent() 
    344                                 || getSource().getParent() == editPart 
    345                                 || getSource() == editPart.getParent(), "Connection end points must have same parent"); 
     341//                    EditPart thisPart = this; 
     342//                    EditPart thisSourceParent = getSource().getParent(); 
     343                        Assert.isTrue(ep == epParent 
     344                                || ep == editPart 
     345                                || getSource() == epParent, "Connection end points must have same parent"); 
    346346                } 
    347347                 
     
    367367                 
    368368                IFigure layer_figure = super.getLayer(layer); 
    369                 if (LayerConstants.CONNECTION_LAYER.equals(layer)) 
    370                 { 
    371                         if (m_connectionLayer == null) 
    372                         { 
    373                                 m_connectionLayer = layer_figure; 
    374                                 if (parent != null && parent instanceof DomainEditPart) 
    375                                         m_connectionLayer = ((DomainEditPart) parent).getConnectionLayer(); 
    376                         }  
    377                         layer_figure = m_connectionLayer; 
     369 
     370                if (parent instanceof DomainEditPart) 
     371                { 
     372                        layer_figure = ((DomainEditPart) parent).getLayer (layer); 
     373                 
    378374                } 
    379375 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java

    r1476 r1479  
    1515import org.eclipse.draw2d.ConnectionLayer; 
    1616import org.eclipse.draw2d.FreeformLayer; 
     17import org.eclipse.draw2d.FreeformLayeredPane; 
    1718import org.eclipse.draw2d.FreeformLayout; 
    18 import org.eclipse.draw2d.FreeformViewport; 
    1919import org.eclipse.draw2d.IFigure; 
    2020import org.eclipse.draw2d.LayeredPane; 
    2121import org.eclipse.draw2d.ScalableFreeformLayeredPane; 
    22 import org.eclipse.draw2d.ScalableLayeredPane; 
    23 import org.eclipse.draw2d.ScrollPane; 
    2422import org.eclipse.draw2d.ShortestPathConnectionRouter; 
    2523import org.eclipse.draw2d.StackLayout; 
    26 import org.eclipse.draw2d.Viewport; 
    2724import org.eclipse.draw2d.XYLayout; 
    2825import org.eclipse.gef.ConnectionEditPart; 
     
    3532import com.tresys.framework.compiler.policy.Enter; 
    3633import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainFigure; 
    37 import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainPane; 
    3834import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainSourceConnectionAnchor; 
    3935import com.tresys.framework.plugin.editor.policy.graphic.figure.DomainTargetConnectionAnchor; 
    40 import com.tresys.framework.plugin.editor.policy.graphic.figure.PolicyConnectionLayer; 
    4136import com.tresys.framework.plugin.editor.policy.graphic.figure.UserDomainFigure; 
    4237import com.tresys.framework.plugin.editor.policy.graphic.model.AccessConnection; 
     
    5247        private Map targetAnchors = new HashMap (); 
    5348 
    54         private ConnectionLayer m_connectionLayer = null; 
    55         private IFigure pane = null; 
    56  
     49        private LayeredPane m_layers = null; 
     50        private FreeformLayeredPane m_printableLayers = null; 
     51         
    5752        public DomainEditPart () 
    5853        { 
    5954                super (); 
    6055        } 
     56 
     57        protected LayeredPane getPrintableLayers () 
     58        { 
     59                if (m_printableLayers == null) 
     60                { 
     61                        FreeformLayer mainLayer = new FreeformLayer (); 
     62                        mainLayer.setLayoutManager(new FreeformLayout ()); 
     63                         
     64                        ConnectionLayer connectionLayer = new ConnectionLayer (); 
     65                        connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter (mainLayer)); 
     66                         
     67                        m_printableLayers = new FreeformLayeredPane (); 
     68                        m_printableLayers.setLayoutManager(new StackLayout ()); 
     69                        m_printableLayers.add (connectionLayer, LayerConstants.CONNECTION_LAYER); 
     70                        m_printableLayers.add (mainLayer, LayerConstants.PRIMARY_LAYER); 
     71                         
     72                } 
     73 
     74                return m_printableLayers; 
     75        } 
     76 
     77        protected LayeredPane createLayers () 
     78        { 
     79                IFigure fig = getFigure (); 
     80                fig.setLayoutManager(new StackLayout ()); 
     81                 
     82                 
     83                ScalableFreeformLayeredPane layers = new ScalableFreeformLayeredPane (); 
     84                layers.setLayoutManager(new StackLayout ()); 
     85                layers.setScale(.75); 
     86                 
     87                IFigure figureConetnts = layers; 
     88                 
     89//              layers.add (new GridLayer (), LayerConstants.GRID_LAYER); 
     90                layers.add (getPrintableLayers (), LayerConstants.PRINTABLE_LAYERS); 
     91//              layers.add (new FreeformLayer (), LayerConstants.HANDLE_LAYER); 
     92                //layers.add (new FeedbackLayer (), LayerConstants.FEEDBACK_LAYER); 
     93//              layers.add (new GuideLayer (), LayerConstants.GUIDE_LAYER); 
     94 
     95/* 
     96                // for scrolling in domains 
     97                // may cause problems with connection routing 
     98                ScrollPane scrollPane = new ScrollPane (); 
     99//              scrollPane.setHorizontalScrollBarVisibility(ScrollPane.NEVER); 
     100//              scrollPane.setVerticalScrollBarVisibility(ScrollPane.NEVER); 
     101                scrollPane.setViewport (new FreeformViewport ()); 
     102                scrollPane.setContents(layers); 
     103                figureConetnts = scrollPane; 
     104// */ 
     105 
     106                fig.add (figureConetnts); 
     107                 
     108                return layers; 
     109        } 
    61110         
    62111        protected IFigure getLayer (Object layer) 
    63112        { 
    64                 if (LayerConstants.CONNECTION_LAYER.equals(layer)) 
    65                 { 
    66                         if (m_connectionLayer == null) 
    67                         { 
    68                                 m_connectionLayer = new PolicyConnectionLayer (); 
    69                         } 
    70                          
    71                         return m_connectionLayer; 
    72                 } 
    73                 return super.getLayer (layer); 
     113                if (m_layers == null) 
     114                        m_layers = createLayers (); 
     115                 
     116                IFigure fig = m_layers.getLayer(layer); 
     117                if (fig == null) 
     118                        fig = m_printableLayers.getLayer(layer); 
     119                 
     120                if (fig == null) 
     121                        fig = super.getLayer(layer); 
     122                 
     123                return fig; 
    74124        } 
    75125         
     
    85135                        fig = new DomainFigure(); 
    86136                } 
    87                 //FIXME: should there be another else here to ensure no null pointer issues? 
    88                  
    89137                 
    90138                return fig; 
     
    119167        } 
    120168 
    121         public ConnectionLayer getConnectionLayer () 
    122         { 
    123                 return (ConnectionLayer) getLayer (LayerConstants.CONNECTION_LAYER); 
    124         } 
    125          
    126169        public IFigure getContentPane () 
    127170        { 
     171/*               
    128172                IFigure fig = getFigure(); 
    129173                if (!(fig instanceof DomainFigure)) 
    130174                        return null; 
    131  
    132                 if (pane == null) 
    133                 { 
    134                         pane = new ScalableFreeformLayeredPane (); 
    135                         pane.setLayoutManager (new FreeformLayout ()); 
    136 //                      pane.setScale(0.75); 
    137 /* 
    138                         ScrollPane scrollPane = new ScrollPane (); 
    139                         scrollPane.setHorizontalScrollBarVisibility(ScrollPane.NEVER); 
    140                         scrollPane.setVerticalScrollBarVisibility(ScrollPane.NEVER); 
    141                         scrollPane. 
    142                         fig.setLayoutManager(new StackLayout ()); // XYLayout ()); 
    143                         fig.add (scrollPane); 
    144                         scrollPane.setViewport(new FreeformViewport ()); 
    145                         scrollPane.setContents(pane); 
    146 //                      fig. 
    147 //                      fig.add(pane); 
    148175*/ 
    149                         DomainPane domainPane = new DomainPane (pane); 
    150                         fig.setLayoutManager(new StackLayout ()); // XYLayout ()); 
    151                         fig.add (domainPane); 
    152  
    153                         ConnectionLayer connLayer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER); 
    154                         connLayer.setConnectionRouter (new ShortestPathConnectionRouter (pane)); 
    155  
    156                         pane.add(connLayer, LayerConstants.CONNECTION_LAYER); 
    157                 } 
    158 /* 
    159                  
    160                 if (pane == null) 
    161                 { 
    162 //                      ScrollPane scrollPane = new ScrollPane (); 
    163                         pane = new FreeformLayer (); 
    164                         pane.setLayoutManager(new FreeformLayout ()); 
    165                         fig.setLayoutManager(new FreeformLayout ()); 
    166                 } 
    167 */               
    168                 return pane; 
     176 
     177                return getLayer (LayerConstants.PRIMARY_LAYER); 
     178 
    169179        } 
    170180         
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainXYLayoutEditPolicy.java

    r1476 r1479  
    1313import org.eclipse.draw2d.geometry.Rectangle; 
    1414 
    15 import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 
    16  
    1715public class DomainXYLayoutEditPolicy 
    1816        extends PolicyXYLayoutEditPolicy 
     
    2220        { 
    2321                super (i_layout); 
    24                 // TODO Auto-generated constructor stub 
    2522        } 
     23         
     24        /** 
     25         * constrain the rectnage to be contained in the parent domain 
     26         */ 
    2627 
    2728        public Object getConstraintFor (Rectangle r) 
    2829        { 
     30                Dimension shapeSize = getLayoutContainer().getSize(); 
     31 
    2932                if (r.x < 5) 
    3033                        r.x = 5; 
    3134                if (r.y < 5) 
    3235                        r.y = 5; 
    33                  
    34                 Dimension shapeSize = ((Shape) getHost().getModel()).getSize(); 
    35                  
    36                 if (r.y + r.height > shapeSize.height - 10) 
    37                         r.y = shapeSize.height - 10 - r.height; 
    38                 if (r.x + r.width > shapeSize.width -10) 
    39                         r.x = shapeSize.width - 10 - r.width; 
    40                  
     36 
     37                if (r.height > shapeSize.height) 
     38                        r.height = shapeSize.height - 10; 
     39                if (r.width > shapeSize.width) 
     40                        r.width = shapeSize.width - 10; 
     41 
     42                if (r.y + r.height > shapeSize.height - 5) 
     43                        r.y = shapeSize.height - 5 - r.height; 
     44                if (r.x + r.width > shapeSize.width - 5) 
     45                        r.x = shapeSize.width - 5 - r.width; 
     46 
    4147                return super.getConstraintFor (r); 
    4248        } 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyContainerEditPart.java

    r1476 r1479  
    1515import java.util.List; 
    1616 
    17 import org.eclipse.draw2d.XYLayout; 
    1817import org.eclipse.gef.EditPart; 
    1918import org.eclipse.gef.EditPolicy; 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyContainerHighlightEditPolicy.java

    r1336 r1479  
    4646        private IFigure getContainerFigure () 
    4747        { 
    48                 return ((GraphicalEditPart) getHost ()).getFigure (); 
     48//              ((DomainEditPart) getHost ()).getL 
     49                return ((GraphicalEditPart) getHost ()).getContentPane(); // getFigure (); 
    4950        } 
    5051