Changeset 1456

Show
Ignore:
Timestamp:
02/02/07 11:51:47 (2 years ago)
Author:
dsugar
Message:

Fix ticket:108 problem with domains being created at random.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeCreateCommand.java

    r1437 r1456  
    2020 
    2121import org.eclipse.gef.commands.CommandStack; 
     22import org.eclipse.jface.window.Window; 
    2223import org.eclipse.jface.wizard.WizardDialog; 
    2324import org.eclipse.swt.graphics.Image; 
     
    5354        /** The bounds of the new Shape. */ 
    5455        private Rectangle m_bounds; 
     56         
     57        private boolean m_bWasInserted = false; 
    5558 
    5659        /** 
     
    9598                if (size.width > 0 && size.height > 0) 
    9699                        m_newShape.setSize(size); 
    97                  
    98                 setLabel (Messages.creation + " " + m_newShape.getName()); 
    99                  
    100                 if ( m_newShape.getComponent() != null ) 
     100 
     101 
     102                if (m_newShape.getComponent() != null) 
    101103                { 
    102104                        redo(); 
    103                 } 
    104                 //Dialog block to get the initial information for the shape 
    105                 if ( m_newShape.getWizard() != null ) 
    106                 { 
    107                         WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), m_newShape.getWizard()); 
    108                         dlg.setBlockOnOpen (true); 
    109                         dlg.open(); 
     105 
     106                        //Dialog block to get the initial information for the shape 
     107                        if (m_newShape.getWizard() != null) 
     108                        { 
     109                                WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), m_newShape.getWizard()); 
     110                                dlg.setBlockOnOpen (true); 
     111                                m_bWasInserted = dlg.open() == Window.OK; 
     112                        } 
     113 
     114                        if (m_bWasInserted) 
     115                        { 
     116                                setLabel (Messages.creation + " " + m_newShape.getName()); 
     117                        } 
    110118                } 
    111119                 
    112120                //If shape properties are not complete then remove from policy 
    113                 if (!m_newShape.isShapeComplete()
     121                if (!m_bWasInserted
    114122                { 
    115123                        undo(); 
    116124                } 
    117125         
     126        } 
     127         
     128        public boolean canUndo () 
     129        { 
     130                return m_bWasInserted; 
    118131        } 
    119132         
  • branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/BaseDomainShape.java

    r1437 r1456  
    6969        public Wizard getWizard() 
    7070        { 
    71                 if ( getComponent()  != null
     71                if (getComponent()  != null
    7272                        return new BaseDomainPropertyWizard(this); 
    7373                 
    74                 else 
    75                 { 
    76                         setShapeComplete(false); 
    77                         return null; 
    78                 } 
    79                          
     74                return null; 
    8075        } 
    8176         
  • branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/BaseResourceShape.java

    r1437 r1456  
    6868        public Wizard getWizard() 
    6969        { 
    70                 if (getComponent() != null
     70                if (getComponent() != null
    7171                        return new BaseResourcePropertyWizard(this); 
    72                  
    73                 else 
    74                 { 
    75                         setShapeComplete(false); 
    76                         return null; 
    77                 } 
     72                return null; 
    7873        } 
    7974         
  • branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/DomainShape.java

    r1453 r1456  
    7878        } 
    7979         
     80        public Policy getPolicy () 
     81        { 
     82                if (getParent () == null) 
     83                        return null; 
     84                 
     85                return getParent ().getPolicy(); 
     86        } 
     87         
    8088        /* 
    8189         * Returns a wizard dialog for initial shape information 
  • branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/Shape.java

    r1437 r1456  
    123123        protected PolicyDiagram parent = null; 
    124124        final protected SELinuxSystem m_system; 
    125         private boolean shapeInfoComplete = false; 
    126125         
    127126        public Shape (SELinuxSystem i_system, Component i_component) 
     
    238237                return i_pd.getPolicy(); 
    239238        } 
     239         
    240240        public Policy getPolicy () 
    241241        { 
     
    466466                String oldName = getComponent().getName(); 
    467467 
    468                 if (pol.Rename(getComponent(), i_sName)) 
     468                if (pol != null && pol.Rename(getComponent(), i_sName)) 
    469469                        firePropertyChange(NAME_PROP, oldName, getComponent().getName()); 
    470470        } 
     
    665665                } 
    666666        } 
    667          
    668         public void setShapeComplete(boolean i_complete) 
    669         { 
    670                 shapeInfoComplete = i_complete; 
    671         } 
    672          
    673         public boolean isShapeComplete() 
    674         { 
    675                 return shapeInfoComplete; 
    676         } 
    677667} 
  • branches/gefeditor/src/com/tresys/framework/plugin/wizards/BaseDomainPropertyWizard.java

    r1437 r1456  
    2929                m_shape = i_shape; 
    3030                setDefaultPageImageDescriptor (SEFramework_Plugin.getDefault ().getImageRegistry ().getDescriptor (FRAMEWORKImageRegistry.FRAMEWORK_ICON)); 
    31                 m_shape.setShapeComplete(false); 
    3231        } 
    3332 
     
    5049                m_shape.setComponent(m_selectedBaseDomain); 
    5150         
    52                 m_shape.setShapeComplete(true); 
    53                  
    5451                return true; 
    5552        } 
  • branches/gefeditor/src/com/tresys/framework/plugin/wizards/BaseResourcePropertyWizard.java

    r1437 r1456  
    2929                m_shape = i_shape; 
    3030                setDefaultPageImageDescriptor (SEFramework_Plugin.getDefault ().getImageRegistry ().getDescriptor (FRAMEWORKImageRegistry.FRAMEWORK_ICON)); 
    31                 m_shape.setShapeComplete(false); 
    3231        } 
    3332 
     
    4948                 
    5049                m_shape.setComponent(m_selectedBaseResource); 
    51          
    52                 m_shape.setShapeComplete(true); 
    5350                 
    5451                return true; 
  • branches/gefeditor/src/com/tresys/framework/plugin/wizards/ResourceShapePropertyWizard.java

    r1437 r1456  
    3333        { 
    3434                super (i_shape); 
    35                 getShape().setShapeComplete(false); 
    3635        } 
    3736         
     
    5958                m_path = m_resourcePageInfo.getResourcePath(); 
    6059                m_rdef = m_resourcePageInfo.getRDefSelected(); 
     60 
    6161                //m_pd.addChild (getShape()); 
    62                 if ( getShape() instanceof ResourceShape
     62                if (getShape() instanceof ResourceShape
    6363                { 
    6464                        //set the shape name 
     
    7575                        component.SetRdef(m_rdef, new Token (m_rdef.GetName (),  ((ResourceShape) getShape()).getErrorHandler())); 
    7676                 
    77                          ((ResourceShape) getShape()).updatePath(); 
    78                           
    79                          getShape().setShapeComplete(true); 
     77                        ((ResourceShape) getShape()).updatePath(); 
     78                        return true; 
    8079                } 
    81                 return true; 
     80                 
     81                return false; 
    8282        } 
    8383 
  • branches/gefeditor/src/com/tresys/framework/plugin/wizards/ShapePropertyWizard.java

    r1437 r1456  
    3939                setDefaultPageImageDescriptor (SEFramework_Plugin.getDefault ().getImageRegistry ().getDescriptor (FRAMEWORKImageRegistry.FRAMEWORK_ICON)); 
    4040                m_shape = i_shape; 
    41                 m_shape.setShapeComplete(false); 
    4241        } 
    4342         
     
    6665                } 
    6766                 
    68                 m_shape.setShapeComplete(true); 
    69          
    7067                return true; 
    7168        }