Changeset 1474

Show
Ignore:
Timestamp:
02/12/07 16:01:41 (2 years ago)
Author:
dsugar
Message:

looking at problems with connection routing in subdomains and with the cause of the problems causing never ending looping when updating routing in general.
No progress made, but some minor changes made for debugging.

Files:

Legend:

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

    r1444 r1474  
    1414import java.util.EventObject; 
    1515import java.util.Iterator; 
     16import java.util.List; 
    1617 
    1718import org.eclipse.core.resources.IContainer; 
     
    2021import org.eclipse.core.resources.IWorkspaceRunnable; 
    2122import org.eclipse.core.runtime.CoreException; 
     23import org.eclipse.core.runtime.IAdaptable; 
    2224import org.eclipse.core.runtime.IPath; 
    2325import org.eclipse.core.runtime.IProgressMonitor; 
    2426import org.eclipse.core.runtime.Path; 
     27import org.eclipse.draw2d.PositionConstants; 
    2528import org.eclipse.gef.ContextMenuProvider; 
    2629import org.eclipse.gef.DefaultEditDomain; 
     
    2932import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; 
    3033import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; 
     34import org.eclipse.gef.editparts.ZoomManager; 
    3135//import org.eclipse.gef.editparts.ZoomManager; 
    3236import org.eclipse.gef.palette.PaletteRoot; 
    3337import org.eclipse.gef.requests.CreationFactory; 
    3438import org.eclipse.gef.requests.SimpleFactory; 
     39import org.eclipse.gef.ui.actions.ActionRegistry; 
     40import org.eclipse.gef.ui.actions.AlignmentAction; 
     41import org.eclipse.gef.ui.actions.CopyTemplateAction; 
     42import org.eclipse.gef.ui.actions.MatchHeightAction; 
     43import org.eclipse.gef.ui.actions.MatchWidthAction; 
     44import org.eclipse.gef.ui.actions.ZoomInAction; 
     45import org.eclipse.gef.ui.actions.ZoomOutAction; 
    3546import org.eclipse.gef.ui.palette.PaletteViewerProvider; 
    3647import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; 
     
    3849import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; 
    3950import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; 
     51import org.eclipse.jface.action.IAction; 
    4052import org.eclipse.jface.dialogs.MessageDialog; 
    4153import org.eclipse.jface.util.TransferDropTargetListener; 
     
    4557import org.eclipse.jface.viewers.SelectionChangedEvent; 
    4658import org.eclipse.jface.viewers.StructuredSelection; 
     59import org.eclipse.swt.SWT; 
    4760import org.eclipse.swt.widgets.Display; 
     61import org.eclipse.swt.widgets.Event; 
     62import org.eclipse.swt.widgets.Listener; 
    4863import org.eclipse.swt.widgets.Shell; 
    4964import org.eclipse.ui.IEditorInput; 
     
    5469import org.eclipse.ui.IWorkbenchPage; 
    5570import org.eclipse.ui.IWorkbenchPart; 
     71import org.eclipse.ui.actions.ActionFactory; 
    5672import org.eclipse.ui.texteditor.IDocumentProvider; 
    5773import org.eclipse.ui.texteditor.IDocumentProviderExtension2; 
     
    131147                         
    132148                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); 
    135162                 
    136163                GraphicalViewer viewer = getGraphicalViewer(); 
     
    155182                } 
    156183                 
     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                } 
    157206        } 
    158207         
     
    206255//                      return m_outline; 
    207256                } 
     257                 
     258                if (adapter == ZoomManager.class) 
     259                        return m_rootEditPart.getZoomManager(); 
    208260                 
    209261                //TODO: this needs to return a custom PropertySheetPage 
     
    422474                        extension.elementStateValidationChanged(input, false); 
    423475                } 
    424  
    425476        } 
    426477 
     
    454505        } 
    455506 
     507         
    456508        /** 
    457509         * Create a transfer drop target listener. When using a CombinedTemplateCreationEntry 
     
    638690                RefreshViewer(); 
    639691        } 
     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} 
    640735         
    641736        /** 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditorActionBarContributor.java

    r1041 r1474  
    1111package com.tresys.framework.plugin.editor.policy.graphic; 
    1212 
     13import org.eclipse.jface.action.IMenuManager; 
    1314import org.eclipse.jface.action.IToolBarManager; 
     15import org.eclipse.jface.action.MenuManager; 
     16import org.eclipse.jface.action.Separator; 
     17import org.eclipse.ui.IWorkbenchActionConstants; 
    1418import org.eclipse.ui.actions.ActionFactory; 
    1519 
     20import org.eclipse.draw2d.PositionConstants; 
     21import org.eclipse.gef.editparts.ZoomManager; 
    1622import org.eclipse.gef.ui.actions.ActionBarContributor; 
     23import org.eclipse.gef.ui.actions.AlignmentRetargetAction; 
    1724import org.eclipse.gef.ui.actions.DeleteRetargetAction; 
     25import org.eclipse.gef.ui.actions.GEFActionConstants; 
     26import org.eclipse.gef.ui.actions.MatchHeightRetargetAction; 
     27import org.eclipse.gef.ui.actions.MatchWidthRetargetAction; 
    1828import org.eclipse.gef.ui.actions.RedoRetargetAction; 
    1929import org.eclipse.gef.ui.actions.UndoRetargetAction; 
     30import org.eclipse.gef.ui.actions.ZoomComboContributionItem; 
     31import org.eclipse.gef.ui.actions.ZoomInRetargetAction; 
     32import org.eclipse.gef.ui.actions.ZoomOutRetargetAction; 
    2033 
    2134/** 
     
    2437 * @author Elias Volanakis 
    2538 */ 
    26 public class GraphicPolicyEditorActionBarContributor extends ActionBarContributor { 
     39public class GraphicPolicyEditorActionBarContributor  
     40        extends ActionBarContributor  
     41
    2742 
    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        } 
    46110 
    47111/* 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseDomainFigure.java

    r1450 r1474  
    5151                        graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 
    5252 
     53                super.fillShape (graphics); 
    5354        } 
    5455 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/BaseResourceFigure.java

    r1450 r1474  
    5151                        graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 
    5252 
     53                super.fillShape (graphics); 
    5354        } 
    5455 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainFigure.java

    r1451 r1474  
    5454                if (imgWarning != null) 
    5555                        graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 
     56 
     57                super.fillShape (graphics); 
    5658        } 
    5759 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainSourceConnectionAnchor.java

    r1453 r1474  
    2323{ 
    2424        DomainTargetConnectionAnchor m_peer = null; 
     25        Point           m_prevRefPoint = null; 
    2526         
    2627        private DomainSourceConnectionAnchor () 
     
    6364        public void ancestorMoved (IFigure figure) 
    6465        { 
    65 //            System.out.println("Source Ancestor Moved - owner " + getOwner()); 
     66              System.out.println("Source Ancestor Moved - owner " + getOwner()); 
    6667 
    6768                super.ancestorMoved (figure); 
     
    7172        public void anchorMoved (ConnectionAnchor anchor) 
    7273        { 
    73 //              System.out.println("Source Anchor Moved - owner " + getOwner()); 
    7474                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()); 
    7586                for (Iterator itr = listeners.iterator(); itr.hasNext (); ) 
    7687                { 
     
    8091                        listener.anchorMoved(this); 
    8192                } 
     93 
    8294        } 
    8395         
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/DomainTargetConnectionAnchor.java

    r1453 r1474  
    2323         
    2424        Point   fixedLoc = null; 
     25        Point   m_prevRefPoint = null; 
    2526         
    2627        private DomainTargetConnectionAnchor () 
     
    5051        public void ancestorMoved (IFigure figure) 
    5152        { 
    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); 
    5455        } 
    5556 
     
    6667                 
    6768                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()); 
    6873                        anchorMoved(this); 
     74                } 
    6975                 
    7076                return fixedLoc; 
     
    7480        public void anchorMoved (ConnectionAnchor anchor) 
    7581        { 
    76 //              System.out.println("Target Anchor Moved - owner " + getOwner()); 
    7782//              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()); 
    7894                 
    7995                for (Iterator itr = listeners.iterator(); itr.hasNext(); ) 
     
    84100                        listener.anchorMoved(this); 
    85101                } 
    86                  
     102 
     103 
    87104        } 
    88105 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/EntryPointFigure.java

    r1450 r1474  
    6565                if (imgWarning != null) 
    6666                        graphics.drawImage(imgWarning, bounds.x + 10, bounds.y + 10); 
     67 
     68                super.fillShape (graphics); 
    6769        } 
    6870 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/PolicyComponentFigure.java

    r1468 r1474  
    1717 
    1818import org.eclipse.draw2d.ColorConstants; 
     19import org.eclipse.draw2d.Graphics; 
    1920import org.eclipse.draw2d.Shape; 
    2021import org.eclipse.jface.resource.JFaceResources; 
     
    126127        } 
    127128 
     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        } 
    128138} 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/figure/ResourceFigure.java

    r1450 r1474  
    4848                if (imgWarning != null) 
    4949                        graphics.drawImage(imgWarning, bounds.x + bounds.width/2 - 8, bounds.y); 
     50                 
     51                super.fillShape (graphics); 
    5052        } 
    5153 
     
    5759         * @return <code>true</code>if the given point is contained 
    5860         */ 
    59         public boolean containsPoint(int x, int y) { 
     61        public boolean containsPoint(int x, int y)  
     62        { 
    6063                if (!super.containsPoint(x, y)) 
    6164                        return false; 
     
    7275         * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics) 
    7376         */ 
    74         protected void outlineShape(Graphics graphics) { 
     77        protected void outlineShape(Graphics graphics)  
     78        { 
    7579                Rectangle r = Rectangle.SINGLETON; 
    7680                r.setBounds(getBounds()); 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java

    r1453 r1474  
    117117                if (!(fig instanceof DomainFigure)) 
    118118                        return null; 
     119 
     120                ScrollPane scrollPane = new ScrollPane (); 
    119121                 
    120122                if (pane == null) 
    121123                { 
    122124                        pane = new ScalableFreeformLayeredPane (); 
    123                         pane.setScale(0.75); 
    124125                        pane.setLayoutManager (new FreeformLayout ()); 
    125  
    126                         ScrollPane scrollPane = new ScrollPane (); 
     126//                      pane.setScale(0.75); 
     127 
    127128                        fig.setLayoutManager(new StackLayout ()); // XYLayout ()); 
    128129                        fig.add (scrollPane); 
     
    131132 
    132133                        ConnectionLayer connLayer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER); 
    133                         connLayer.setConnectionRouter(new ShortestPathConnectionRouter(pane)); 
     134                        connLayer.setConnectionRouter(new ShortestPathConnectionRouter (pane)); 
    134135 
    135136                        pane.add(connLayer, LayerConstants.CONNECTION_LAYER); 
     137 
    136138                } 
    137139                 
     
    141143        /* 
    142144         * 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 outerconnection of the connection also 
     145         * found then return completed connection.  Checks for the outer connection of the connection also 
    144146         *  (non-Javadoc) 
    145147         * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createOrFindConnection(java.lang.Object)