Changeset 1975

Show
Ignore:
Timestamp:
03/04/08 14:53:06 (9 months ago)
Author:
dsugar
Message:

more cleanup - some constants moved around
singleton MLSSupport was bad - removed
fix up color cell editor to only show button only and not RGB value.

Files:

Legend:

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

    r1953 r1975  
    5050         
    5151        // The Color used to represent this level in the diagram 
    52         protected String _color = "0x000000"; 
     52        protected String _color = "0xffffff"; 
    5353         
    5454        // The Range used to specify the level in the generated Policy 
     
    9393         * @param name  - The name assigned by the user during the creation process 
    9494         */ 
    95         public MLSLevel(String name
     95        public MLSLevel(String name, String i_sRange
    9696        { 
    9797                _name = name; 
     98                _range = i_sRange; 
    9899        } 
    99100         
     
    219220        } 
    220221         
     222        /* (non-Javadoc) 
     223         * @see java.lang.Object#toString() 
     224         */ 
     225        public String toString () 
     226        { 
     227                return getName () + "(" + getRange () + ")"; 
     228        } 
     229         
    221230} 
  • branches/mls/framework-plugin/src/com/tresys/framework/compiler/mls/MLSSupport.java

    r1973 r1975  
    7878        private static final String LEVEL_ELEMENT_NAME = "level"; 
    7979         
    80         private static final String DEFAULT_MLS_SYSTEM_HIGH_RANGE = "mls-systemhigh"; 
    81          
    82         private static final String DEFAULT_MLS_SYSTEM_LOW_RANGE = "mls-systemlow"; 
     80        private static final String DEFAULT_MLS_SYSTEM_HIGH_RANGE = "mls_systemhigh"; 
     81         
     82        private static final String DEFAULT_MLS_SYSTEM_LOW_RANGE = "mls_systemlow"; 
    8383         
    8484        private static final String DEFAULT_MLS_HIGH_COLOR_VALUE = "0xff0000"; 
     
    8989         
    9090        private static final String DEFAULT_MLS_LOW_LEVEL_NAME = "mls-low"; 
    91          
    92         private static MLSSupport _LEVELS = null; 
    93          
    94         public static MLSSupport getInstance() 
    95         { 
    96                 return _LEVELS; 
    97         } 
    98          
     91 
    9992        // The file  
    10093        private File _file = null; 
     
    119112                { 
    120113                        initialize (f); 
    121                         if (null == MLSSupport._LEVELS) 
    122                         { 
    123                                 MLSSupport._LEVELS = this; 
    124                         } 
    125114                } 
    126115                catch (ParserConfigurationException pce) 
     
    149138                _file = new File(fileName); 
    150139                 
    151                 MLSLevel mls = new MLSLevel(DEFAULT_MLS_LOW_LEVEL_NAME); 
     140                MLSLevel mls = new MLSLevel(DEFAULT_MLS_LOW_LEVEL_NAME, DEFAULT_MLS_SYSTEM_LOW_RANGE); 
    152141                mls.setColor (DEFAULT_MLS_LOW_COLOR_VALUE); 
    153                 mls.setRange (DEFAULT_MLS_SYSTEM_LOW_RANGE); 
    154142                mls.setOrder (this.size ());             
    155143                this.add (mls); 
    156144                 
    157                 mls = new MLSLevel(DEFAULT_MLS_HIGH_LEVEL_NAME); 
     145                mls = new MLSLevel(DEFAULT_MLS_HIGH_LEVEL_NAME, DEFAULT_MLS_SYSTEM_HIGH_RANGE); 
    158146                mls.setColor (DEFAULT_MLS_HIGH_COLOR_VALUE); 
    159                 mls.setRange (DEFAULT_MLS_SYSTEM_HIGH_RANGE); 
    160147                mls.setOrder (this.size ());             
    161148                this.add (mls); 
    162                  
    163                 if (null == MLSSupport._LEVELS) 
    164                 { 
    165                         MLSSupport._LEVELS = this; 
    166                 }                
    167149        } 
    168150         
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java

    r1974 r1975  
    607607                if (null == _mlsConfiguration) 
    608608                { 
    609                         _mlsConfiguration = MLSSupport.getInstance (); 
    610                          
    611                         if (null == _mlsConfiguration) 
    612                         { 
    613                                 IFile mlsConfigurationFile = this.getSupportFolder ().getFile (MLS_CONFIGURATION_FILE); 
    614                                 try 
     609                        IFile mlsConfigurationFile = this.getSupportFolder ().getFile (MLS_CONFIGURATION_FILE); 
     610                        try 
     611                        { 
     612                                _mlsConfiguration = new MLSSupport(mlsConfigurationFile.getLocation ().toFile ()); 
     613                        } 
     614                        catch (MLSInitializationException mie) 
     615                        { 
     616                                // Establish a minimal MLS configuration  
     617                                // if it can't be loaded from the file system. 
     618                                if (bInitIfNotFound) 
    615619                                { 
    616                                         _mlsConfiguration = new MLSSupport(mlsConfigurationFile.getLocation ().toFile ()); 
    617                                 } 
    618                                 catch (MLSInitializationException mie) 
    619                                 { 
    620                                         // Establish a minimal MLS configuration  
    621                                         // if it can't be loaded from the file system. 
    622                                         if (bInitIfNotFound) 
    623                                         { 
    624                                                 IPath ipFull = mlsConfigurationFile.getLocation (); 
    625                                                 File file = ipFull.toFile ();   
    626                                                 _mlsConfiguration = new MLSSupport(file.getAbsolutePath ()); 
    627                                         } 
     620                                        IPath ipFull = mlsConfigurationFile.getLocation (); 
     621                                        File file = ipFull.toFile ();   
     622                                        _mlsConfiguration = new MLSSupport(file.getAbsolutePath ()); 
    628623                                } 
    629624                        } 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyEditPart.java

    r1974 r1975  
    203203         
    204204                                MLSSupport mlsSupport = getCastedModel ().getMLSSupport (); 
    205                                 if (mls == null || mlsSupport.getLevel (mls.getName ()) == null
     205                                if (mls == null || !mlsSupport.contains (mls)
    206206                                { 
    207207                                        mls = mlsSupport.getDefaultMLSLevel (); 
     
    209209                                        { 
    210210                                                getCastedModel ().setMLS (mls); 
    211                                                 refreshVisuals (); 
    212211                                        } 
    213212                                } 
     213                                refreshVisuals (); 
    214214                        } 
    215215                } 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/MLSSettingsProjProperties.java

    r1974 r1975  
    3333import org.eclipse.jface.viewers.ArrayContentProvider; 
    3434import org.eclipse.jface.viewers.CellEditor; 
    35 import org.eclipse.jface.viewers.ColorCellEditor; 
    3635import org.eclipse.jface.viewers.ComboViewer; 
    3736import org.eclipse.jface.viewers.ICellEditorValidator; 
     
    7271import com.tresys.framework.plugin.SEFramework_Plugin; 
    7372import com.tresys.framework.plugin.builder.FrameworkNature; 
     73import com.tresys.framework.plugin.editor.properties.ColorSelectorCellEditor; 
    7474import com.tresys.framework.plugin.preferences.Messages; 
    7575import com.tresys.slide.utility.MLSPatternFilter; 
     
    9090        public static final String DEFAULT_MLS = "mls-low"; 
    9191 
    92         private static final int LEVEL_DEFINITION_CONTROL_VERTICAL_SPACING = 2; 
    93         private static final int LEVEL_DEFINITION_CONTROL_COLUMN_LAYOUT = 4; 
    94         private static final int PAGE_VERTICAL_SPACING = 3; 
    95         private static final int PAGE_LAYOUT_COLUMNS = 1; 
    96         private static final int RANGE_COLUMN_WIDTH = 200; 
    97         private static final int NAME_COLUMN_WIDTH = 200; 
    98         private static final int COLOR_COLUMN_WIDTH = 200; 
     92        protected static final String RANGE_PROPERTY_NAME = Messages.range_column_header; 
     93        protected static final String NAME_PROPERTY_NAME = Messages.name_column_header; 
     94        protected static final String COLOR_PROPERTY_NAME = Messages.color_column_header; 
     95 
    9996        protected Table _table = null; 
    10097        protected TableViewer _ctv = null; 
     
    106103        protected ComboViewer _levelsDefault = null;  
    107104        protected IEclipsePreferences projPrefs = null; 
    108          
     105 
    109106        /** 
    110107         * ctor 
     
    176173                setTitle (Messages.mls_settings); 
    177174                Composite composite = new Composite (parent, SWT.NONE); 
    178                 GridLayout layout = new GridLayout (MLSSettingsProjProperties.PAGE_LAYOUT_COLUMNS, false); 
    179                 layout.verticalSpacing = MLSSettingsProjProperties.PAGE_VERTICAL_SPACING
     175                GridLayout layout = new GridLayout (1, false); 
     176                layout.verticalSpacing = 3
    180177                composite.setLayout (layout); 
    181178                 
     
    202199                        }); 
    203200 
     201                 
    204202                // Define the columns which will display  
    205203                // information within the table control 
    206204                TableColumn c2 = new TableColumn (_table, SWT.CENTER); 
    207                 c2.setText (Messages.color_column_header); 
    208                 c2.setWidth (MLSSettingsProjProperties.COLOR_COLUMN_WIDTH); 
     205                c2.setText (COLOR_PROPERTY_NAME); 
     206                c2.setWidth (60); 
    209207 
    210208                TableColumn c3 = new TableColumn (_table, SWT.LEFT); 
    211                 c3.setText (Messages.name_column_header); 
    212                 c3.setWidth (MLSSettingsProjProperties.NAME_COLUMN_WIDTH); 
     209                c3.setText (NAME_PROPERTY_NAME); 
     210                c3.setWidth (200); 
    213211                 
    214212                TableColumn c4 = new TableColumn (_table, SWT.LEFT); 
    215                 c4.setText (Messages.range_column_header); 
    216                 c4.setWidth (MLSSettingsProjProperties.RANGE_COLUMN_WIDTH); 
     213                c4.setText (RANGE_PROPERTY_NAME); 
     214                c4.setWidth (200); 
    217215                 
    218216                FrameworkNature nat = FrameworkNature.getNature (getProject ()); 
     
    233231                // Define the Cell editors 
    234232                CellEditor[] ces = new CellEditor[] {  
    235                                                         new ColorCellEditor(_table), 
     233                                                        new ColorSelectorCellEditor(_table), 
    236234                                                        new TextCellEditor(_table), 
    237235                                                        new TextCellEditor(_table) }; 
     
    273271                // associated with managing the MLS configuration 
    274272                Composite LevelControls = new Composite(composite, SWT.BORDER); 
    275                 GridLayout gl2 = new GridLayout(MLSSettingsProjProperties.LEVEL_DEFINITION_CONTROL_COLUMN_LAYOUT, false); 
    276                 gl2.verticalSpacing = MLSSettingsProjProperties.LEVEL_DEFINITION_CONTROL_VERTICAL_SPACING
     273                GridLayout gl2 = new GridLayout (4, false); 
     274                gl2.verticalSpacing = 2
    277275                LevelControls.setLayout (gl2); 
    278276                LevelControls.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); 
     
    310308                                { 
    311309                                        // Construct New Level 
    312                                         MLSLevel mls = new MLSLevel("new-mls-level"); 
     310                                        MLSLevel mls = new MLSLevel(Messages.new_mls_level_name, "s0");                //$NON-NLS-1$ 
    313311                                        mls.setOrder (_levels.size ()); 
    314312                                         
     
    523521                                // Define the User selected Default level 
    524522                                this.projPrefs.put (SEFPreferencePage.DEFAULT_MLS_LEVEL, mls.getName ()); 
    525                                 MLSSupport.getInstance ().setDefaultMLSLevel (mls); 
     523                                _levels.setDefaultMLSLevel (mls); 
    526524                        } 
    527525                                 
     
    585583                                                                                                MLSSettingsProjProperties.DEFAULT_MLS); 
    586584                MLSLevel mls = _levels.getLevel (defaultMLSLevel); 
    587                 _levelsDefault.setSelection (new StructuredSelection(mls));                     
    588                 MLSSupport.getInstance ().setDefaultMLSLevel (mls); 
     585                _levelsDefault.setSelection (new StructuredSelection(mls)); 
     586                _levels.setDefaultMLSLevel (mls); 
    589587        } 
    590588        catch (MLSInitializationException mie) 
     
    742740         */ 
    743741        protected class MLSCellModifier 
    744         implements ICellModifier 
     742               implements ICellModifier 
    745743        { 
    746                 private static final String RANGE_PROPERTY_NAME = "Range"; 
    747                 private static final String NAME_PROPERTY_NAME = "Name"; 
    748                 private static final String COLOR_PROPERTY_NAME = "Color"; 
    749                  
    750744                /** 
    751745                 * ctor 
     
    793787                         
    794788                        // Determine which property is being requested 
    795                         if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) 
     789                        if (COLOR_PROPERTY_NAME.equals (property)) 
    796790                        { 
    797791                                retValue = MLSEclipseLevel.getColorRGB (mls); 
    798792                        } 
    799                         else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) 
     793                        else if (NAME_PROPERTY_NAME.equals (property)) 
    800794                        { 
    801795                                retValue = mls.getName (); 
    802796                        }  
    803                         else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) 
     797                        else if (RANGE_PROPERTY_NAME.equals (property)) 
    804798                        { 
    805799                                retValue = mls.getRange (); 
     
    834828                         
    835829                        // Determine which property has changed 
    836                         if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) 
     830                        if (COLOR_PROPERTY_NAME.equals (property)) 
    837831                        { 
    838832                                // Update the Color Definition 
    839833                                MLSEclipseLevel.setColorInstance (mls, (RGB)value); 
    840834                        } 
    841                         else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) 
     835                        else if (NAME_PROPERTY_NAME.equals (property)) 
    842836                        { 
    843837                                // The Name was change so the key to it needs to be changed too 
     
    848842                                _levels.add (mls); 
    849843                        } 
    850                         else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) 
     844                        else if (RANGE_PROPERTY_NAME.equals (property)) 
    851845                        { 
    852846                                mls.setRange (value.toString ()); 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/Messages.java

    r1953 r1975  
    2424        public static String select_directory; 
    2525        public static String select_file; 
     26 
     27        // MLS preferences 
    2628        public static String mls_settings; 
    2729        public static String add_level; 
     
    3537        public static String range_error_title; 
    3638        public static String range_error_message; 
    37  
     39        public static String new_mls_level_name; 
    3840         
    3941 
  • branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/messages.properties

    r1953 r1975  
    2929range_error_title=MLS Range Editor Error 
    3030range_error_message=Invalid Range value entered 
     31new_mls_level_name=new-mls-level 
    3132 
    3233## text editor preferences