Changeset 1955

Show
Ignore:
Timestamp:
02/25/08 16:29:51 (9 months ago)
Author:
jjarrett
Message:

Added logic that would only allow resetting of MLS Level to the Default MLS level when the currently assigned MLS Level was the same as the one being removed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java

    r1954 r1955  
    5151import com.tresys.framework.compiler.linkage.flnkage.FLNKParser; 
    5252import com.tresys.framework.compiler.mls.MLSInitializationException; 
     53import com.tresys.framework.compiler.mls.MLSLevel; 
    5354import com.tresys.framework.compiler.mls.MLSSupport; 
    5455import com.tresys.framework.plugin.SEFramework_Plugin; 
    5556import com.tresys.framework.plugin.builder.FrameworkBuilder; 
     57import com.tresys.framework.plugin.preferences.MLSSettingsProjProperties; 
    5658import com.tresys.framework.plugin.preferences.PreferenceInitializer; 
    5759import com.tresys.framework.plugin.preferences.SEFPreferencePage; 
     
    152154                } 
    153155                 
     156                if (event.getKey ().equals (SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED)) 
     157                { 
     158                        Iterator _iter = getSystems ().iterator (); 
     159                         
     160                        while (_iter.hasNext ()) 
     161                        { 
     162                                SELinuxSystem sels = (SELinuxSystem)_iter.next (); 
     163                                 
     164                                sels.mlsDefaultChanged (event); 
     165                        } 
     166                } 
     167                 
    154168                return; 
    155169        } 
     
    206220                 
    207221                desc.setBuildSpec(newCommands); 
    208  
    209                  
    210222                 
    211223                m_project.setDescription(desc, null); 
     
    270282                resetSupportFiles (); 
    271283                 
     284                // Load MLS Support when Project is set  
    272285                try 
    273286                { 
    274287                        this.getMLSSupport (); 
     288                         
     289                        // Redefine the Default MLS Level to match the definition for  
     290                        // the new Project being assigned. 
     291                        MLSLevel mls = this._mlsConfiguration.getLevel (m_projPrefs.get (SEFPreferencePage.DEFAULT_MLS_LEVEL, MLSSettingsProjProperties.DEFAULT_MLS)); 
     292                        this._mlsConfiguration.setDefaultMLSLevel (mls); 
    275293                } 
    276294                catch (MLSInitializationException mie) 
    277295                { 
    278                          
     296                        // Ignore the exception... 
    279297                } 
    280298                 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyEditPart.java

    r1953 r1955  
    4848{ 
    4949        private ConnectionAnchor anchor; 
    50         private static List EMPTY_LIST = new ArrayList ();  
     50        private static List EMPTY_LIST = new ArrayList (); 
     51        private String _oldDefaultLevel = null; 
     52        private String _newDefaultLevel = null; 
    5153 
    5254        final static protected boolean DEBUG = SEFramework_Plugin.getDefault ().isDebugging ("/debug/part"); 
     
    213215                        if (null != ov) 
    214216                        { 
    215                                 String oldValue = ov.toString (); 
     217                                this._oldDefaultLevel = ov.toString (); 
     218                                this._newDefaultLevel = evt.getNewValue ().toString (); 
     219                        } 
     220                } 
     221                else if (SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED.equals (prop)) 
     222                { 
     223                        Object ov = evt.getOldValue (); 
     224                        if (null != ov) 
     225                        { 
     226                                if (Boolean.TRUE.toString ().equals (evt.getNewValue ().toString ())) 
     227                                { 
    216228                                 
    217                                 Shape s = this.getCastedModel (); 
    218                                  
    219                                 IMLSSetting ims = (IMLSSetting) s.getComponent (); 
    220                                  
    221                                 if (oldValue.equals (ims.getMLSLabel ())) 
    222                                 { 
     229                                        Shape s = this.getCastedModel (); 
    223230                                         
    224                                         String levelName = evt.getNewValue ().toString (); 
     231                                        IMLSSetting ims = (IMLSSetting) s.getComponent (); 
    225232                                         
    226                                         ims.setMLSLabel (levelName); 
    227                                          
    228                                         MLSSupport mlsSupport = MLSSupport.getInstance (); 
    229                                          
    230                                         if (null != mlsSupport) 
    231                                         {                                
    232                                                 MLSLevel mls = mlsSupport.getLevel (levelName); 
     233                                        if (_oldDefaultLevel.equals (ims.getMLSLabel ())) 
     234                                        { 
    233235                                                 
    234                                                 if (null != mls) 
    235                                                 { 
    236                                                         this.figure.setBackgroundColor (MLSEclipseLevel.getColorInstance (mls)); 
    237                                                         refreshVisuals (); 
    238                                                 } 
    239                                         }                                
     236                                                String levelName = _newDefaultLevel; 
     237                                                 
     238                                                ims.setMLSLabel (levelName); 
     239                                                 
     240                                                MLSSupport mlsSupport = MLSSupport.getInstance (); 
     241                                                 
     242                                                if (null != mlsSupport) 
     243                                                {                                
     244                                                        MLSLevel mls = mlsSupport.getLevel (levelName); 
     245                                                         
     246                                                        if (null != mls) 
     247                                                        { 
     248                                                                this.figure.setBackgroundColor (MLSEclipseLevel.getColorInstance (mls)); 
     249                                                                refreshVisuals (); 
     250                                                        } 
     251                                                }                                
     252                                        } 
    240253                                } 
    241254                        } 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/MLSSettingsProjProperties.java

    r1954 r1955  
    9191        implements IWorkbenchPropertyPage 
    9292{ 
     93        public static final String DEFAULT_MLS = "mls-low"; 
    9394 
    9495        private static final int LEVEL_DEFINITION_CONTROL_VERTICAL_SPACING = 2; 
     
    99100        private static final int NAME_COLUMN_WIDTH = 200; 
    100101        private static final int COLOR_COLUMN_WIDTH = 200; 
    101         private static final String DEFAULT_MLS = "mls-low"; 
    102102        protected Table _table = null; 
    103103        protected TableViewer _ctv = null; 
     
    109109        protected ComboViewer _levelsDefault = null;  
    110110        protected IEclipsePreferences projPrefs = null; 
    111  
     111        protected boolean _defaultWasRemoved = false; 
    112112         
    113113        /** 
     
    176176                // Prepare the environment 
    177177                this.initProjPrefs (); 
     178 
     179                this._defaultWasRemoved = false; 
    178180                 
    179181                // Define the basics of the page 
     
    428430                                        { 
    429431                                                MLSLevel dl = _levels.getLevelOrderedAt (0); 
    430                                                 _levelsDefault.setSelection (new StructuredSelection(dl));       
     432                                                _levelsDefault.setSelection (new StructuredSelection(dl)); 
     433                                                _defaultWasRemoved = true; 
    431434                                        } 
    432435                                         
     
    552555                         
    553556                        this.projPrefs.put (SEFPreferencePage.MLS_UPDATE, Long.toHexString (System.currentTimeMillis ())); 
     557                         
     558                        if (_defaultWasRemoved) 
     559                        { 
     560                                this.projPrefs.put(SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED, Boolean.FALSE.toString ()); 
     561                                this.projPrefs.put(SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED, Boolean.TRUE.toString ()); 
     562                        } 
    554563                         
    555564                        projPrefs.flush ();                                                              
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/SEFPreferencePage.java

    r1953 r1955  
    5353         */ 
    5454        public static final String DEFAULT_MLS_LEVEL = "defaultMLSLevel"; 
     55        public static final String DEFAULT_MLS_LEVEL_REMOVED = "defaultMLSLevelRemoved"; 
    5556        public static final String MLS_UPDATE = "mlsUpdated"; 
    5657