Changeset 1975
- 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
| r1953 |
r1975 |
|
| 50 | 50 | |
|---|
| 51 | 51 | // The Color used to represent this level in the diagram |
|---|
| 52 | | protected String _color = "0x000000"; |
|---|
| | 52 | protected String _color = "0xffffff"; |
|---|
| 53 | 53 | |
|---|
| 54 | 54 | // The Range used to specify the level in the generated Policy |
|---|
| … | … | |
| 93 | 93 | * @param name - The name assigned by the user during the creation process |
|---|
| 94 | 94 | */ |
|---|
| 95 | | public MLSLevel(String name) |
|---|
| | 95 | public MLSLevel(String name, String i_sRange) |
|---|
| 96 | 96 | { |
|---|
| 97 | 97 | _name = name; |
|---|
| | 98 | _range = i_sRange; |
|---|
| 98 | 99 | } |
|---|
| 99 | 100 | |
|---|
| … | … | |
| 219 | 220 | } |
|---|
| 220 | 221 | |
|---|
| | 222 | /* (non-Javadoc) |
|---|
| | 223 | * @see java.lang.Object#toString() |
|---|
| | 224 | */ |
|---|
| | 225 | public String toString () |
|---|
| | 226 | { |
|---|
| | 227 | return getName () + "(" + getRange () + ")"; |
|---|
| | 228 | } |
|---|
| | 229 | |
|---|
| 221 | 230 | } |
|---|
| r1973 |
r1975 |
|
| 78 | 78 | private static final String LEVEL_ELEMENT_NAME = "level"; |
|---|
| 79 | 79 | |
|---|
| 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"; |
|---|
| 83 | 83 | |
|---|
| 84 | 84 | private static final String DEFAULT_MLS_HIGH_COLOR_VALUE = "0xff0000"; |
|---|
| … | … | |
| 89 | 89 | |
|---|
| 90 | 90 | 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 | |
|---|
| 99 | 92 | // The file |
|---|
| 100 | 93 | private File _file = null; |
|---|
| … | … | |
| 119 | 112 | { |
|---|
| 120 | 113 | initialize (f); |
|---|
| 121 | | if (null == MLSSupport._LEVELS) |
|---|
| 122 | | { |
|---|
| 123 | | MLSSupport._LEVELS = this; |
|---|
| 124 | | } |
|---|
| 125 | 114 | } |
|---|
| 126 | 115 | catch (ParserConfigurationException pce) |
|---|
| … | … | |
| 149 | 138 | _file = new File(fileName); |
|---|
| 150 | 139 | |
|---|
| 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); |
|---|
| 152 | 141 | mls.setColor (DEFAULT_MLS_LOW_COLOR_VALUE); |
|---|
| 153 | | mls.setRange (DEFAULT_MLS_SYSTEM_LOW_RANGE); |
|---|
| 154 | 142 | mls.setOrder (this.size ()); |
|---|
| 155 | 143 | this.add (mls); |
|---|
| 156 | 144 | |
|---|
| 157 | | mls = new MLSLevel(DEFAULT_MLS_HIGH_LEVEL_NAME); |
|---|
| | 145 | mls = new MLSLevel(DEFAULT_MLS_HIGH_LEVEL_NAME, DEFAULT_MLS_SYSTEM_HIGH_RANGE); |
|---|
| 158 | 146 | mls.setColor (DEFAULT_MLS_HIGH_COLOR_VALUE); |
|---|
| 159 | | mls.setRange (DEFAULT_MLS_SYSTEM_HIGH_RANGE); |
|---|
| 160 | 147 | mls.setOrder (this.size ()); |
|---|
| 161 | 148 | this.add (mls); |
|---|
| 162 | | |
|---|
| 163 | | if (null == MLSSupport._LEVELS) |
|---|
| 164 | | { |
|---|
| 165 | | MLSSupport._LEVELS = this; |
|---|
| 166 | | } |
|---|
| 167 | 149 | } |
|---|
| 168 | 150 | |
|---|
| r1974 |
r1975 |
|
| 607 | 607 | if (null == _mlsConfiguration) |
|---|
| 608 | 608 | { |
|---|
| 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) |
|---|
| 615 | 619 | { |
|---|
| 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 ()); |
|---|
| 628 | 623 | } |
|---|
| 629 | 624 | } |
|---|
| r1974 |
r1975 |
|
| 203 | 203 | |
|---|
| 204 | 204 | MLSSupport mlsSupport = getCastedModel ().getMLSSupport (); |
|---|
| 205 | | if (mls == null || mlsSupport.getLevel (mls.getName ()) == null) |
|---|
| | 205 | if (mls == null || !mlsSupport.contains (mls)) |
|---|
| 206 | 206 | { |
|---|
| 207 | 207 | mls = mlsSupport.getDefaultMLSLevel (); |
|---|
| … | … | |
| 209 | 209 | { |
|---|
| 210 | 210 | getCastedModel ().setMLS (mls); |
|---|
| 211 | | refreshVisuals (); |
|---|
| 212 | 211 | } |
|---|
| 213 | 212 | } |
|---|
| | 213 | refreshVisuals (); |
|---|
| 214 | 214 | } |
|---|
| 215 | 215 | } |
|---|
| r1974 |
r1975 |
|
| 33 | 33 | import org.eclipse.jface.viewers.ArrayContentProvider; |
|---|
| 34 | 34 | import org.eclipse.jface.viewers.CellEditor; |
|---|
| 35 | | import org.eclipse.jface.viewers.ColorCellEditor; |
|---|
| 36 | 35 | import org.eclipse.jface.viewers.ComboViewer; |
|---|
| 37 | 36 | import org.eclipse.jface.viewers.ICellEditorValidator; |
|---|
| … | … | |
| 72 | 71 | import com.tresys.framework.plugin.SEFramework_Plugin; |
|---|
| 73 | 72 | import com.tresys.framework.plugin.builder.FrameworkNature; |
|---|
| | 73 | import com.tresys.framework.plugin.editor.properties.ColorSelectorCellEditor; |
|---|
| 74 | 74 | import com.tresys.framework.plugin.preferences.Messages; |
|---|
| 75 | 75 | import com.tresys.slide.utility.MLSPatternFilter; |
|---|
| … | … | |
| 90 | 90 | public static final String DEFAULT_MLS = "mls-low"; |
|---|
| 91 | 91 | |
|---|
| 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 | |
|---|
| 99 | 96 | protected Table _table = null; |
|---|
| 100 | 97 | protected TableViewer _ctv = null; |
|---|
| … | … | |
| 106 | 103 | protected ComboViewer _levelsDefault = null; |
|---|
| 107 | 104 | protected IEclipsePreferences projPrefs = null; |
|---|
| 108 | | |
|---|
| | 105 | |
|---|
| 109 | 106 | /** |
|---|
| 110 | 107 | * ctor |
|---|
| … | … | |
| 176 | 173 | setTitle (Messages.mls_settings); |
|---|
| 177 | 174 | 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; |
|---|
| 180 | 177 | composite.setLayout (layout); |
|---|
| 181 | 178 | |
|---|
| … | … | |
| 202 | 199 | }); |
|---|
| 203 | 200 | |
|---|
| | 201 | |
|---|
| 204 | 202 | // Define the columns which will display |
|---|
| 205 | 203 | // information within the table control |
|---|
| 206 | 204 | 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); |
|---|
| 209 | 207 | |
|---|
| 210 | 208 | 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); |
|---|
| 213 | 211 | |
|---|
| 214 | 212 | 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); |
|---|
| 217 | 215 | |
|---|
| 218 | 216 | FrameworkNature nat = FrameworkNature.getNature (getProject ()); |
|---|
| … | … | |
| 233 | 231 | // Define the Cell editors |
|---|
| 234 | 232 | CellEditor[] ces = new CellEditor[] { |
|---|
| 235 | | new ColorCellEditor(_table), |
|---|
| | 233 | new ColorSelectorCellEditor(_table), |
|---|
| 236 | 234 | new TextCellEditor(_table), |
|---|
| 237 | 235 | new TextCellEditor(_table) }; |
|---|
| … | … | |
| 273 | 271 | // associated with managing the MLS configuration |
|---|
| 274 | 272 | 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; |
|---|
| 277 | 275 | LevelControls.setLayout (gl2); |
|---|
| 278 | 276 | LevelControls.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); |
|---|
| … | … | |
| 310 | 308 | { |
|---|
| 311 | 309 | // 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$ |
|---|
| 313 | 311 | mls.setOrder (_levels.size ()); |
|---|
| 314 | 312 | |
|---|
| … | … | |
| 523 | 521 | // Define the User selected Default level |
|---|
| 524 | 522 | this.projPrefs.put (SEFPreferencePage.DEFAULT_MLS_LEVEL, mls.getName ()); |
|---|
| 525 | | MLSSupport.getInstance ().setDefaultMLSLevel (mls); |
|---|
| | 523 | _levels.setDefaultMLSLevel (mls); |
|---|
| 526 | 524 | } |
|---|
| 527 | 525 | |
|---|
| … | … | |
| 585 | 583 | MLSSettingsProjProperties.DEFAULT_MLS); |
|---|
| 586 | 584 | 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); |
|---|
| 589 | 587 | } |
|---|
| 590 | 588 | catch (MLSInitializationException mie) |
|---|
| … | … | |
| 742 | 740 | */ |
|---|
| 743 | 741 | protected class MLSCellModifier |
|---|
| 744 | | implements ICellModifier |
|---|
| | 742 | implements ICellModifier |
|---|
| 745 | 743 | { |
|---|
| 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 | | |
|---|
| 750 | 744 | /** |
|---|
| 751 | 745 | * ctor |
|---|
| … | … | |
| 793 | 787 | |
|---|
| 794 | 788 | // Determine which property is being requested |
|---|
| 795 | | if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| | 789 | if (COLOR_PROPERTY_NAME.equals (property)) |
|---|
| 796 | 790 | { |
|---|
| 797 | 791 | retValue = MLSEclipseLevel.getColorRGB (mls); |
|---|
| 798 | 792 | } |
|---|
| 799 | | else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| | 793 | else if (NAME_PROPERTY_NAME.equals (property)) |
|---|
| 800 | 794 | { |
|---|
| 801 | 795 | retValue = mls.getName (); |
|---|
| 802 | 796 | } |
|---|
| 803 | | else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| | 797 | else if (RANGE_PROPERTY_NAME.equals (property)) |
|---|
| 804 | 798 | { |
|---|
| 805 | 799 | retValue = mls.getRange (); |
|---|
| … | … | |
| 834 | 828 | |
|---|
| 835 | 829 | // Determine which property has changed |
|---|
| 836 | | if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| | 830 | if (COLOR_PROPERTY_NAME.equals (property)) |
|---|
| 837 | 831 | { |
|---|
| 838 | 832 | // Update the Color Definition |
|---|
| 839 | 833 | MLSEclipseLevel.setColorInstance (mls, (RGB)value); |
|---|
| 840 | 834 | } |
|---|
| 841 | | else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| | 835 | else if (NAME_PROPERTY_NAME.equals (property)) |
|---|
| 842 | 836 | { |
|---|
| 843 | 837 | // The Name was change so the key to it needs to be changed too |
|---|
| … | … | |
| 848 | 842 | _levels.add (mls); |
|---|
| 849 | 843 | } |
|---|
| 850 | | else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| | 844 | else if (RANGE_PROPERTY_NAME.equals (property)) |
|---|
| 851 | 845 | { |
|---|
| 852 | 846 | mls.setRange (value.toString ()); |
|---|
| r1953 |
r1975 |
|
| 24 | 24 | public static String select_directory; |
|---|
| 25 | 25 | public static String select_file; |
|---|
| | 26 | |
|---|
| | 27 | // MLS preferences |
|---|
| 26 | 28 | public static String mls_settings; |
|---|
| 27 | 29 | public static String add_level; |
|---|
| … | … | |
| 35 | 37 | public static String range_error_title; |
|---|
| 36 | 38 | public static String range_error_message; |
|---|
| 37 | | |
|---|
| | 39 | public static String new_mls_level_name; |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | |
|---|
| r1953 |
r1975 |
|
| 29 | 29 | range_error_title=MLS Range Editor Error |
|---|
| 30 | 30 | range_error_message=Invalid Range value entered |
|---|
| | 31 | new_mls_level_name=new-mls-level |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | ## text editor preferences |
|---|
Download in other formats:
* Generating other formats may take time.