Changeset 1936
- Timestamp:
- 02/15/08 14:04:45
(9 months ago)
- Author:
- jjarrett
- Message:
Refined rough implementation on MLS Setting property page.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1910 |
r1936 |
|
| 34 | 34 | public class MLSLevel |
|---|
| 35 | 35 | { |
|---|
| | 36 | private static final String COLOR_ATTRIBUTE_NAME = "color"; |
|---|
| | 37 | |
|---|
| | 38 | private static final String EMPTY_STRING = ""; |
|---|
| | 39 | |
|---|
| | 40 | private static final String LEVEL_ELEMENT_NAME = "level"; |
|---|
| | 41 | |
|---|
| | 42 | private static final String NAME_ATTRIBUTE_NAME = "name"; |
|---|
| | 43 | |
|---|
| | 44 | private static final String ORDER_ATTRIBUTE_NAME = "order"; |
|---|
| | 45 | |
|---|
| | 46 | private static final String RANGE_ATTRIBUTE_NAME = "range"; |
|---|
| | 47 | |
|---|
| 36 | 48 | // The Name of the Level |
|---|
| 37 | | protected String _name = ""; |
|---|
| | 49 | protected String _name = MLSLevel.EMPTY_STRING; |
|---|
| 38 | 50 | |
|---|
| 39 | 51 | // The Color used to represent this level in the diagram |
|---|
| … | … | |
| 41 | 53 | |
|---|
| 42 | 54 | // The Range used to specify the level in the generated Policy |
|---|
| 43 | | protected String _range = ""; |
|---|
| | 55 | protected String _range = MLSLevel.EMPTY_STRING; |
|---|
| 44 | 56 | |
|---|
| 45 | 57 | // The Order with the Configuration Panel |
|---|
| … | … | |
| 55 | 67 | MLSLevel(Element e) |
|---|
| 56 | 68 | { |
|---|
| 57 | | _name = e.getAttribute ("name"); |
|---|
| 58 | | _color = e.getAttribute ("color"); |
|---|
| 59 | | _range = e.getAttribute ("range"); |
|---|
| 60 | | |
|---|
| 61 | | String sOrder = e.getAttribute ("order"); |
|---|
| | 69 | _name = e.getAttribute (MLSLevel.NAME_ATTRIBUTE_NAME); |
|---|
| | 70 | _color = e.getAttribute (MLSLevel.COLOR_ATTRIBUTE_NAME); |
|---|
| | 71 | _range = e.getAttribute (MLSLevel.RANGE_ATTRIBUTE_NAME); |
|---|
| | 72 | |
|---|
| | 73 | String sOrder = e.getAttribute (MLSLevel.ORDER_ATTRIBUTE_NAME); |
|---|
| 62 | 74 | |
|---|
| 63 | 75 | try |
|---|
| … | … | |
| 197 | 209 | Element toXML(Document doc) |
|---|
| 198 | 210 | { |
|---|
| 199 | | Element retValue = doc.createElement ("level"); |
|---|
| 200 | | |
|---|
| 201 | | retValue.setAttribute ("name", _name); |
|---|
| 202 | | retValue.setAttribute ("color", _color); |
|---|
| 203 | | retValue.setAttribute ("range", _range); |
|---|
| 204 | | retValue.setAttribute ("order", "" + _order); |
|---|
| | 211 | Element retValue = doc.createElement (MLSLevel.LEVEL_ELEMENT_NAME); |
|---|
| | 212 | |
|---|
| | 213 | retValue.setAttribute (MLSLevel.NAME_ATTRIBUTE_NAME, _name); |
|---|
| | 214 | retValue.setAttribute (MLSLevel.COLOR_ATTRIBUTE_NAME, _color); |
|---|
| | 215 | retValue.setAttribute (MLSLevel.RANGE_ATTRIBUTE_NAME, _range); |
|---|
| | 216 | retValue.setAttribute (MLSLevel.ORDER_ATTRIBUTE_NAME, MLSLevel.EMPTY_STRING + _order); |
|---|
| 205 | 217 | |
|---|
| 206 | 218 | return retValue; |
|---|
| r1910 |
r1936 |
|
| 21 | 21 | package com.tresys.framework.compiler.mls; |
|---|
| 22 | 22 | |
|---|
| | 23 | import java.io.BufferedOutputStream; |
|---|
| 23 | 24 | import java.io.File; |
|---|
| 24 | 25 | import java.io.FileInputStream; |
|---|
| … | … | |
| 26 | 27 | import java.io.IOException; |
|---|
| 27 | 28 | import java.io.InputStream; |
|---|
| 28 | | import java.util.ArrayList; |
|---|
| | 29 | import java.io.OutputStream; |
|---|
| 29 | 30 | import java.util.Collection; |
|---|
| 30 | 31 | import java.util.Enumeration; |
|---|
| 31 | 32 | import java.util.Hashtable; |
|---|
| 32 | 33 | import java.util.Iterator; |
|---|
| 33 | | import java.util.List; |
|---|
| 34 | | |
|---|
| 35 | 34 | import javax.xml.parsers.DocumentBuilder; |
|---|
| 36 | 35 | import javax.xml.parsers.DocumentBuilderFactory; |
|---|
| 37 | 36 | import javax.xml.parsers.ParserConfigurationException; |
|---|
| 38 | | import javax.xml.stream.XMLOutputFactory; |
|---|
| 39 | | import javax.xml.stream.XMLStreamWriter; |
|---|
| 40 | 37 | import javax.xml.transform.OutputKeys; |
|---|
| 41 | 38 | import javax.xml.transform.Transformer; |
|---|
| … | … | |
| 51 | 48 | import org.xml.sax.InputSource; |
|---|
| 52 | 49 | import org.xml.sax.SAXException; |
|---|
| 53 | | |
|---|
| 54 | | //import com.sun.org.apache.xml.internal.serialize.OutputFormat; |
|---|
| 55 | | //import com.sun.org.apache.xml.internal.serialize.XMLSerializer; |
|---|
| 56 | 50 | |
|---|
| 57 | 51 | /** |
|---|
| … | … | |
| 75 | 69 | public class MLSSupport implements Collection |
|---|
| 76 | 70 | { |
|---|
| | 71 | |
|---|
| | 72 | private static final String XML_OUTPUT_TRANSFORMATION = "xml"; |
|---|
| | 73 | |
|---|
| | 74 | private static final String INDENT_VALUE = "yes"; |
|---|
| | 75 | |
|---|
| | 76 | private static final String STANDALONE_VALUE = "yes"; |
|---|
| | 77 | |
|---|
| | 78 | private static final String MLS_ELEMENT_NAME = "mls"; |
|---|
| | 79 | |
|---|
| | 80 | private static final String LEVEL_ELEMENT_NAME = "level"; |
|---|
| | 81 | |
|---|
| 77 | 82 | // The file |
|---|
| 78 | 83 | private File _file = null; |
|---|
| … | … | |
| 142 | 147 | // Prepare to iterate through the defined MLS Configuration data |
|---|
| 143 | 148 | Element mls = doc.getDocumentElement (); |
|---|
| 144 | | NodeList nl = mls.getElementsByTagName ("level"); |
|---|
| | 149 | NodeList nl = mls.getElementsByTagName (MLSSupport.LEVEL_ELEMENT_NAME); |
|---|
| 145 | 150 | |
|---|
| 146 | 151 | // iterate through the level definitions. |
|---|
| … | … | |
| 213 | 218 | |
|---|
| 214 | 219 | // Create the Document Element and assign it into the Document Object |
|---|
| 215 | | Element mls = doc.createElement ("mls"); |
|---|
| | 220 | Element mls = doc.createElement (MLSSupport.MLS_ELEMENT_NAME); |
|---|
| 216 | 221 | doc.appendChild (mls); |
|---|
| 217 | 222 | |
|---|
| … | … | |
| 233 | 238 | TransformerFactory tf = TransformerFactory.newInstance (); |
|---|
| 234 | 239 | Transformer t = tf.newTransformer (); |
|---|
| 235 | | t.setOutputProperty (OutputKeys.STANDALONE, "yes"); |
|---|
| 236 | | t.setOutputProperty (OutputKeys.METHOD, "xml"); |
|---|
| 237 | | StreamResult sr = new StreamResult(_file); |
|---|
| | 240 | t.setOutputProperty (OutputKeys.STANDALONE, MLSSupport.STANDALONE_VALUE); |
|---|
| | 241 | t.setOutputProperty (OutputKeys.METHOD, MLSSupport.XML_OUTPUT_TRANSFORMATION); |
|---|
| | 242 | t.setOutputProperty (OutputKeys.INDENT, MLSSupport.INDENT_VALUE); |
|---|
| | 243 | if (!_file.exists ()) |
|---|
| | 244 | { |
|---|
| | 245 | _file.createNewFile (); |
|---|
| | 246 | } |
|---|
| | 247 | StreamResult sr = new StreamResult(_file); |
|---|
| | 248 | sr.setOutputStream (new FileOutputStream(_file, false)); |
|---|
| 238 | 249 | DOMSource ds = new DOMSource(doc); |
|---|
| 239 | 250 | |
|---|
| … | … | |
| 241 | 252 | t.transform (ds, sr); |
|---|
| 242 | 253 | |
|---|
| 243 | | sr.getWriter ().close (); |
|---|
| | 254 | sr.getOutputStream ().close (); |
|---|
| 244 | 255 | } |
|---|
| 245 | 256 | catch (ParserConfigurationException pce) |
|---|
| r1825 |
r1936 |
|
| 19 | 19 | import org.eclipse.jface.wizard.Wizard; |
|---|
| 20 | 20 | import org.eclipse.swt.graphics.Image; |
|---|
| | 21 | import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; |
|---|
| 21 | 22 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
|---|
| 22 | 23 | import org.eclipse.ui.views.properties.PropertyDescriptor; |
|---|
| … | … | |
| 48 | 49 | implements IDomainShape |
|---|
| 49 | 50 | { |
|---|
| | 51 | private static final String MLS_LEVEL_PROPERTY_NAME = "MLS Level"; |
|---|
| | 52 | |
|---|
| 50 | 53 | private IPropertyDescriptor[] m_descriptors; |
|---|
| 51 | 54 | |
|---|
| … | … | |
| 118 | 121 | if (m_descriptors == null) |
|---|
| 119 | 122 | { |
|---|
| 120 | | final int nStatPropCount = 1; |
|---|
| | 123 | final int nStatPropCount = 2; |
|---|
| 121 | 124 | |
|---|
| 122 | 125 | Dictionary dictionary = getPolicy().getDictionary(); |
|---|
| … | … | |
| 163 | 166 | myDescriptors[0].setAlwaysIncompatible(true); |
|---|
| 164 | 167 | myDescriptors[0].setCategory(PROP_SECTION_BASE); |
|---|
| | 168 | |
|---|
| | 169 | // Fetch project to get the current MLS Level configuration definitions |
|---|
| | 170 | String [] values = new String [] { "mls-low", "mls-high"}; |
|---|
| | 171 | // myDescriptors[1] = new TextPropertyDescriptor(DomainShape.MLS_LEVEL_PROPERTY_NAME, Messages.mls_level); |
|---|
| | 172 | myDescriptors[1] = new ComboBoxPropertyDescriptor(DomainShape.MLS_LEVEL_PROPERTY_NAME, Messages.mls_level, values); |
|---|
| | 173 | myDescriptors[1].setCategory (PROP_SECTION_BASE); |
|---|
| 165 | 174 | |
|---|
| 166 | 175 | { |
|---|
| … | … | |
| 286 | 295 | { |
|---|
| 287 | 296 | return ((PathRdefEditContainer) propertyId).getPath((Domain) getComponent()); |
|---|
| | 297 | } |
|---|
| | 298 | |
|---|
| | 299 | if (DomainShape.MLS_LEVEL_PROPERTY_NAME.equals (propertyId)) |
|---|
| | 300 | { |
|---|
| | 301 | return "mls-low"; |
|---|
| 288 | 302 | } |
|---|
| 289 | 303 | |
|---|
| r1825 |
r1936 |
|
| 70 | 70 | public static String backflow_prop_description; |
|---|
| 71 | 71 | public static String default_prop_description; |
|---|
| | 72 | |
|---|
| | 73 | public static String mls_level; |
|---|
| 72 | 74 | } |
|---|
| r1825 |
r1936 |
|
| 55 | 55 | backflow_prop_description=Indicates how likely there is to be reverse information flow |
|---|
| 56 | 56 | default_prop_description=Indicates if this is using the default or selected access |
|---|
| | 57 | |
|---|
| | 58 | mls_level=MLS Level |
|---|
| r1910 |
r1936 |
|
| 22 | 22 | |
|---|
| 23 | 23 | |
|---|
| | 24 | import java.io.File; |
|---|
| 24 | 25 | import java.util.Arrays; |
|---|
| 25 | 26 | import java.util.Iterator; |
|---|
| 26 | 27 | |
|---|
| | 28 | import org.eclipse.core.resources.IFile; |
|---|
| 27 | 29 | import org.eclipse.core.resources.IProject; |
|---|
| 28 | 30 | import org.eclipse.core.resources.IResource; |
|---|
| … | … | |
| 30 | 32 | import org.eclipse.core.runtime.IAdaptable; |
|---|
| 31 | 33 | import org.eclipse.core.runtime.CoreException; |
|---|
| | 34 | import org.eclipse.core.runtime.IPath; |
|---|
| 32 | 35 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|---|
| 33 | 36 | import org.eclipse.core.runtime.preferences.IScopeContext; |
|---|
| … | … | |
| 35 | 38 | import org.eclipse.jface.viewers.CellEditor; |
|---|
| 36 | 39 | import org.eclipse.jface.viewers.ColorCellEditor; |
|---|
| | 40 | import org.eclipse.jface.viewers.ComboViewer; |
|---|
| 37 | 41 | import org.eclipse.jface.viewers.ICellModifier; |
|---|
| 38 | | import org.eclipse.jface.viewers.ILabelProviderListener; |
|---|
| | 42 | import org.eclipse.jface.viewers.ISelection; |
|---|
| 39 | 43 | import org.eclipse.jface.viewers.ITableLabelProvider; |
|---|
| | 44 | import org.eclipse.jface.viewers.LabelProvider; |
|---|
| | 45 | import org.eclipse.jface.viewers.StructuredSelection; |
|---|
| 40 | 46 | import org.eclipse.jface.viewers.TableViewer; |
|---|
| 41 | 47 | import org.eclipse.jface.viewers.TextCellEditor; |
|---|
| … | … | |
| 53 | 59 | import org.eclipse.swt.layout.GridLayout; |
|---|
| 54 | 60 | import org.eclipse.swt.widgets.Button; |
|---|
| 55 | | import org.eclipse.swt.widgets.Combo; |
|---|
| 56 | 61 | import org.eclipse.swt.widgets.Composite; |
|---|
| 57 | 62 | import org.eclipse.swt.widgets.Control; |
|---|
| … | … | |
| 86 | 91 | { |
|---|
| 87 | 92 | |
|---|
| | 93 | private static final int LEVEL_DEFINITION_CONTROL_VERTICAL_SPACING = 2; |
|---|
| | 94 | private static final int LEVEL_DEFINITION_CONTROL_COLUMN_LAYOUT = 4; |
|---|
| | 95 | private static final int PAGE_VERTICAL_SPACING = 3; |
|---|
| | 96 | private static final int PAGE_LAYOUT_COLUMNS = 1; |
|---|
| | 97 | private static final int RANGE_COLUMN_WIDTH = 200; |
|---|
| | 98 | private static final int NAME_COLUMN_WIDTH = 200; |
|---|
| | 99 | private static final int COLOR_COLUMN_WIDTH = 200; |
|---|
| | 100 | private static final String DEFAULT_MLS_SYSTEM_HIGH_RANGE = "mls-systemhigh"; |
|---|
| | 101 | private static final String DEFAULT_MLS_HIGH_COLOR_VALUE = "0xff0000"; |
|---|
| | 102 | private static final String DEFAULT_MLS_HIGH_LEVEL_NAME = "mls-high"; |
|---|
| | 103 | private static final String DEFAULT_MLS_LOW_COLOR_VALUE = "0xffffff"; |
|---|
| | 104 | private static final String DEFAULT_MLS_SYSTEM_LOW_RANGE = "mls-systemlow"; |
|---|
| | 105 | private static final String DEFAULT_MLS_LOW_LEVEL_NAME = "mls-low"; |
|---|
| 88 | 106 | protected Table _table = null; |
|---|
| 89 | 107 | protected TableViewer _ctv = null; |
|---|
| … | … | |
| 91 | 109 | protected Button _shiftUp = null; |
|---|
| 92 | 110 | protected Button _shiftDown = null; |
|---|
| 93 | | protected Combo _levelsDefault = null; |
|---|
| | 111 | protected Button _removeLevel = null; |
|---|
| | 112 | // protected Combo _levelsDefault = null; |
|---|
| | 113 | protected ComboViewer _levelsDefault = null; |
|---|
| 94 | 114 | protected IEclipsePreferences projPrefs = null; |
|---|
| 95 | 115 | |
|---|
| … | … | |
| 164 | 184 | setTitle (Messages.mls_settings); |
|---|
| 165 | 185 | Composite composite = new Composite (parent, SWT.NONE); |
|---|
| 166 | | GridLayout layout = new GridLayout (1, false); |
|---|
| 167 | | layout.verticalSpacing = 3; |
|---|
| | 186 | GridLayout layout = new GridLayout (MLSSettingsProjProperties.PAGE_LAYOUT_COLUMNS, false); |
|---|
| | 187 | layout.verticalSpacing = MLSSettingsProjProperties.PAGE_VERTICAL_SPACING; |
|---|
| 168 | 188 | composite.setLayout (layout); |
|---|
| 169 | 189 | |
|---|
| … | … | |
| 185 | 205 | _shiftDown.setEnabled ((j + 1) != _levels.size ()); |
|---|
| 186 | 206 | |
|---|
| | 207 | _removeLevel.setEnabled (true); |
|---|
| 187 | 208 | return; |
|---|
| 188 | 209 | } |
|---|
| … | … | |
| 192 | 213 | // information within the table control |
|---|
| 193 | 214 | TableColumn c2 = new TableColumn (_table, SWT.CENTER); |
|---|
| 194 | | c2.setText ("Color"); |
|---|
| 195 | | c2.setWidth (200); |
|---|
| | 215 | c2.setText (Messages.color_column_header); |
|---|
| | 216 | c2.setWidth (MLSSettingsProjProperties.COLOR_COLUMN_WIDTH); |
|---|
| 196 | 217 | |
|---|
| 197 | 218 | TableColumn c3 = new TableColumn (_table, SWT.LEFT); |
|---|
| 198 | | c3.setText ("Name"); |
|---|
| 199 | | c3.setWidth (200); |
|---|
| | 219 | c3.setText (Messages.name_column_header); |
|---|
| | 220 | c3.setWidth (MLSSettingsProjProperties.NAME_COLUMN_WIDTH); |
|---|
| 200 | 221 | |
|---|
| 201 | 222 | TableColumn c4 = new TableColumn (_table, SWT.LEFT); |
|---|
| 202 | | c4.setText ("Range"); |
|---|
| 203 | | c4.setWidth (200); |
|---|
| | 223 | c4.setText (Messages.range_column_header); |
|---|
| | 224 | c4.setWidth (MLSSettingsProjProperties.RANGE_COLUMN_WIDTH); |
|---|
| 204 | 225 | |
|---|
| 205 | 226 | // Prepare to load the MLS Level configuration from the |
|---|
| … | … | |
| 216 | 237 | { |
|---|
| 217 | 238 | // Establish a minimal MLS configuration |
|---|
| 218 | | // if it can't be loaded from the file system. |
|---|
| 219 | | _levels = new MLSSupport(fn.getSupportFolder ().getFile (FrameworkNature.MLS_CONFIGURATION_FILE).getFullPath ().toFile ().getAbsolutePath ()); |
|---|
| 220 | | |
|---|
| 221 | | MLSLevel mls = new MLSLevel("mls-low"); |
|---|
| 222 | | mls.setColor ("0xffffff"); |
|---|
| 223 | | mls.setRange ("mls-system-low"); |
|---|
| 224 | | mls.setOrder (0); |
|---|
| | 239 | // if it can't be loaded from the file system. |
|---|
| | 240 | IFile _if = fn.getSupportFolder ().getFile (FrameworkNature.MLS_CONFIGURATION_FILE); |
|---|
| | 241 | IPath ipFull = _if.getLocation (); |
|---|
| | 242 | File file = ipFull.toFile (); |
|---|
| | 243 | _levels = new MLSSupport(file.getAbsolutePath ()); |
|---|
| | 244 | |
|---|
| | 245 | MLSLevel mls = new MLSLevel(MLSSettingsProjProperties.DEFAULT_MLS_LOW_LEVEL_NAME); |
|---|
| | 246 | mls.setColor (MLSSettingsProjProperties.DEFAULT_MLS_LOW_COLOR_VALUE); |
|---|
| | 247 | mls.setRange (MLSSettingsProjProperties.DEFAULT_MLS_SYSTEM_LOW_RANGE); |
|---|
| | 248 | mls.setOrder (_levels.size ()); |
|---|
| 225 | 249 | _levels.add (mls); |
|---|
| 226 | 250 | |
|---|
| 227 | | mls = new MLSLevel("mls-high"); |
|---|
| 228 | | mls.setColor ("0xff0000"); |
|---|
| 229 | | mls.setRange ("mls-system-high"); |
|---|
| 230 | | mls.setOrder (1); |
|---|
| | 251 | mls = new MLSLevel(MLSSettingsProjProperties.DEFAULT_MLS_HIGH_LEVEL_NAME); |
|---|
| | 252 | mls.setColor (MLSSettingsProjProperties.DEFAULT_MLS_HIGH_COLOR_VALUE); |
|---|
| | 253 | mls.setRange (MLSSettingsProjProperties.DEFAULT_MLS_SYSTEM_HIGH_RANGE); |
|---|
| | 254 | mls.setOrder (_levels.size ()); |
|---|
| 231 | 255 | _levels.add (mls); |
|---|
| 232 | 256 | } |
|---|
| … | … | |
| 239 | 263 | |
|---|
| 240 | 264 | // Define the Column headers |
|---|
| 241 | | String[] names = new String[] { "Color", "Name", "Range" }; |
|---|
| | 265 | String[] names = new String[] { Messages.color_column_header, |
|---|
| | 266 | Messages.name_column_header, |
|---|
| | 267 | Messages.range_column_header }; |
|---|
| 242 | 268 | _ctv.setColumnProperties (names); |
|---|
| 243 | 269 | |
|---|
| … | … | |
| 254 | 280 | // by the editors are reflected back in the data model |
|---|
| 255 | 281 | // (Input object) |
|---|
| 256 | | _ctv.setCellModifier (new roleCellModifier ()); |
|---|
| | 282 | _ctv.setCellModifier (new MLSCellModifier ()); |
|---|
| 257 | 283 | |
|---|
| 258 | 284 | // Define the objects which display the data within a cell |
|---|
| 259 | | _ctv.setLabelProvider (new TableLabelProvider()); |
|---|
| | 285 | _ctv.setLabelProvider (new MLSTableLabelProvider()); |
|---|
| 260 | 286 | |
|---|
| 261 | 287 | // Define the object which knows how to convert the data model |
|---|
| … | … | |
| 280 | 306 | // associated with managing the MLS configuration |
|---|
| 281 | 307 | Composite LevelControls = new Composite(composite, SWT.BORDER); |
|---|
| 282 | | GridLayout gl2 = new GridLayout(4, false); |
|---|
| 283 | | gl2.verticalSpacing = 2; |
|---|
| | 308 | GridLayout gl2 = new GridLayout(MLSSettingsProjProperties.LEVEL_DEFINITION_CONTROL_COLUMN_LAYOUT, false); |
|---|
| | 309 | gl2.verticalSpacing = MLSSettingsProjProperties.LEVEL_DEFINITION_CONTROL_VERTICAL_SPACING; |
|---|
| 284 | 310 | LevelControls.setLayout (gl2); |
|---|
| 285 | 311 | LevelControls.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); |
|---|
| … | … | |
| 291 | 317 | |
|---|
| 292 | 318 | // Select the user's currently defined Default MLS Level |
|---|
| 293 | | String defaultMLSLevel = projPrefs.get (SEFPreferencePage.DEFAULT_MLS_LEVEL, "mls-low"); |
|---|
| 294 | | String[] levels = new String[_levels.size ()]; |
|---|
| 295 | | |
|---|
| 296 | | // Define the list of possible levels to be selected as a default |
|---|
| 297 | | Iterator _iter = _levels.iterator (); |
|---|
| 298 | | int i = 0; |
|---|
| 299 | | while (_iter.hasNext ()) |
|---|
| 300 | | { |
|---|
| 301 | | levels[i++] = ((MLSLevel)_iter.next ()) .getName (); |
|---|
| 302 | | } |
|---|
| 303 | | |
|---|
| 304 | | _levelsDefault = new Combo(LevelControls, SWT.DROP_DOWN | SWT.READ_ONLY); |
|---|
| 305 | | _levelsDefault.setItems (levels); |
|---|
| 306 | | _levelsDefault.select (_levelsDefault.indexOf (defaultMLSLevel)); |
|---|
| | 319 | String defaultMLSLevel = projPrefs.get (SEFPreferencePage.DEFAULT_MLS_LEVEL, MLSSettingsProjProperties.DEFAULT_MLS_LOW_LEVEL_NAME); |
|---|
| | 320 | |
|---|
| | 321 | _levelsDefault = new ComboViewer(LevelControls); |
|---|
| | 322 | _levelsDefault.setLabelProvider (new MLSComboLabelProvider()); |
|---|
| | 323 | _levelsDefault.setContentProvider (new ArrayContentProvider ()); |
|---|
| | 324 | _levelsDefault.setInput (_levels); |
|---|
| | 325 | _levelsDefault.setSelection (new StructuredSelection(_levels.getLevel (defaultMLSLevel))); |
|---|
| 307 | 326 | |
|---|
| 308 | 327 | // Define the controls for Adding a new MLS level |
|---|
| … | … | |
| 321 | 340 | |
|---|
| 322 | 341 | // Reset the Data Set for the table |
|---|
| 323 | | _ctv.setInput (_levels); |
|---|
| | 342 | _ctv.refresh (); |
|---|
| | 343 | _levelsDefault.refresh (); |
|---|
| 324 | 344 | |
|---|
| 325 | 345 | // Select it |
|---|
| … | … | |
| 333 | 353 | _shiftDown.setEnabled (false); |
|---|
| 334 | 354 | |
|---|
| | 355 | _removeLevel.setEnabled (true); |
|---|
| | 356 | |
|---|
| 335 | 357 | return; |
|---|
| 336 | 358 | } |
|---|
| … | … | |
| 340 | 362 | _shiftUp = new Button(LevelControls, SWT.BORDER); |
|---|
| 341 | 363 | _shiftUp.setText (Messages.shift_up); |
|---|
| | 364 | _shiftUp.setEnabled (false); |
|---|
| 342 | 365 | _shiftUp.addSelectionListener (new SelectionAdapter() |
|---|
| 343 | 366 | { |
|---|
| … | … | |
| 355 | 378 | |
|---|
| 356 | 379 | // Reset the Data Set for the table |
|---|
| 357 | | _ctv.setInput (_levels); |
|---|
| | 380 | _ctv.refresh (); |
|---|
| | 381 | _levelsDefault.refresh (); |
|---|
| 358 | 382 | |
|---|
| 359 | 383 | // Reselect the level with which the user is working |
|---|
| … | … | |
| 370 | 394 | |
|---|
| 371 | 395 | // Define a Button to allow the user to remove a MLS Level |
|---|
| 372 | | Button removeLevel = new Button(LevelControls, SWT.BORDER); |
|---|
| 373 | | removeLevel.setText (Messages.remove_level); |
|---|
| 374 | | removeLevel.addSelectionListener (new SelectionAdapter () |
|---|
| | 396 | _removeLevel = new Button(LevelControls, SWT.BORDER); |
|---|
| | 397 | _removeLevel.setText (Messages.remove_level); |
|---|
| | 398 | _removeLevel.setEnabled (false); |
|---|
| | 399 | _removeLevel.addSelectionListener (new SelectionAdapter () |
|---|
| 375 | 400 | { |
|---|
| 376 | 401 | public void widgetSelected(SelectionEvent e) |
|---|
| … | … | |
| 388 | 413 | |
|---|
| 389 | 414 | // Compress the ordering if necessary |
|---|
| 390 | | MLSLevel[] lvls = new MLSLevel[_levels.size ()]; |
|---|
| 391 | | _levels.toArray (lvls); |
|---|
| 392 | | Arrays.sort (lvls, new MLSOrderingViewerComparator()); |
|---|
| 393 | | |
|---|
| 394 | | for (j = 1; j < lvls.length; j++) |
|---|
| | 415 | Iterator _iter = _levels.iterator (); |
|---|
| | 416 | |
|---|
| | 417 | while (_iter.hasNext ()) |
|---|
| 395 | 418 | { |
|---|
| 396 | | // Check if the adjacent pair of |
|---|
| 397 | | // levels are in consecutive order |
|---|
| 398 | | if (lvls[j-1].getOrder () != (lvls[j].getOrder () - 1)) |
|---|
| | 419 | MLSLevel current = (MLSLevel)_iter.next (); |
|---|
| | 420 | |
|---|
| | 421 | if (current.getOrder () > mls.getOrder ()) |
|---|
| 399 | 422 | { |
|---|
| 400 | | lvls[j].setOrder (lvls[j].getOrder () - 1); |
|---|
| | 423 | current.setOrder (current.getOrder () - 1); |
|---|
| 401 | 424 | } |
|---|
| 402 | 425 | } |
|---|
| 403 | | |
|---|
| | 426 | |
|---|
| | 427 | // Clean up the removed element |
|---|
| | 428 | mls = null; |
|---|
| | 429 | |
|---|
| 404 | 430 | // Reset the Data Set for the table |
|---|
| 405 | | _ctv.setInput (_levels); |
|---|
| | 431 | _ctv.refresh (); |
|---|
| | 432 | _levelsDefault.refresh (); |
|---|
| 406 | 433 | |
|---|
| 407 | 434 | return; |
|---|
| … | … | |
| 412 | 439 | _shiftDown = new Button(LevelControls, SWT.BORDER); |
|---|
| 413 | 440 | _shiftDown.setText (Messages.shift_down); |
|---|
| | 441 | _shiftDown.setEnabled (false); |
|---|
| 414 | 442 | _shiftDown.addSelectionListener (new SelectionAdapter() |
|---|
| 415 | 443 | { |
|---|
| … | … | |
| 427 | 455 | |
|---|
| 428 | 456 | // Reset the Data Set for the table |
|---|
| 429 | | _ctv.setInput (_levels); |
|---|
| | 457 | _ctv.refresh (); |
|---|
| | 458 | _levelsDefault.refresh (); |
|---|
| 430 | 459 | |
|---|
| 431 | 460 | // Reselect the level with which the user is working |
|---|
| … | … | |
| 502 | 531 | try |
|---|
| 503 | 532 | { |
|---|
| 504 | | // Define the User selected Default level |
|---|
| 505 | | this.projPrefs.put (SEFPreferencePage.DEFAULT_MLS_LEVEL, this._levelsDefault.getItem (this._levelsDefault.getSelectionIndex ())); |
|---|
| 506 | | projPrefs.flush (); |
|---|
| 507 | | |
|---|
| 508 | | // Persist any changes to the configuration changes. |
|---|
| 509 | | this._levels.save (); |
|---|
| | 533 | ISelection is = this._levelsDefault.getSelection (); |
|---|
| | 534 | if (!is.isEmpty ()) |
|---|
| | 535 | { |
|---|
| | 536 | StructuredSelection ss = (StructuredSelection)is; |
|---|
| | 537 | MLSLevel mls = (MLSLevel)ss.getFirstElement (); |
|---|
| | 538 | |
|---|
| | 539 | // Define the User selected Default level |
|---|
| | 540 | this.projPrefs.put (SEFPreferencePage.DEFAULT_MLS_LEVEL, mls.getName ()); |
|---|
| | 541 | |
|---|
| | 542 | projPrefs.flush (); |
|---|
| | 543 | |
|---|
| | 544 | // Persist any changes to the configuration changes. |
|---|
| | 545 | this._levels.save (); |
|---|
| | 546 | } |
|---|
| 510 | 547 | } |
|---|
| 511 | 548 | catch (BackingStoreException e) |
|---|
| … | … | |
| 552 | 589 | |
|---|
| 553 | 590 | // Reset the Control to display the reloaded configurations |
|---|
| 554 | | this._ctv.setInput (this._levels); |
|---|
| | 591 | _ctv.refresh (); |
|---|
| | 592 | _levelsDefault.refresh (); |
|---|
| 555 | 593 | |
|---|
| 556 | 594 | // reload the default level settings |
|---|
| 557 | | String defaultMLSLevel = projPrefs.get (SEFPreferencePage.DEFAULT_MLS_LEVEL, "mls-low"); |
|---|
| 558 | | _levelsDefault.select (_levelsDefault.indexOf (defaultMLSLevel)); |
|---|
| | 595 | String defaultMLSLevel = projPrefs.get (SEFPreferencePage.DEFAULT_MLS_LEVEL, |
|---|
| | 596 | MLSSettingsProjProperties.DEFAULT_MLS_LOW_LEVEL_NAME); |
|---|
| | 597 | _levelsDefault.setSelection (new StructuredSelection(_levels.getLevel (defaultMLSLevel))); |
|---|
| 559 | 598 | |
|---|
| 560 | 599 | } |
|---|
| … | … | |
| 570 | 609 | } |
|---|
| 571 | 610 | |
|---|
| 572 | | |
|---|
| 573 | 611 | /** |
|---|
| 574 | | * TableLabelProvider |
|---|
| | 612 | * MLSComboLabelProvider |
|---|
| | 613 | * |
|---|
| | 614 | * An inner utility class responsible for helping out with the |
|---|
| | 615 | * display of the data from an MLS Level Object |
|---|
| | 616 | * |
|---|
| | 617 | * @author jjarrett |
|---|
| | 618 | * |
|---|
| | 619 | */ |
|---|
| | 620 | protected class MLSComboLabelProvider |
|---|
| | 621 | extends LabelProvider |
|---|
| | 622 | { |
|---|
| | 623 | |
|---|
| | 624 | /** |
|---|
| | 625 | * getText |
|---|
| | 626 | * |
|---|
| | 627 | * Returns the textual representation of an element within list of options |
|---|
| | 628 | * of combobox drop down list. |
|---|
| | 629 | * |
|---|
| | 630 | * @param element - The data object to be presented to the user |
|---|
| | 631 | * @return - The string representation. |
|---|
| | 632 | */ |
|---|
| | 633 | public String getText(Object element) |
|---|
| | 634 | { |
|---|
| | 635 | MLSLevel mls = (MLSLevel)element; |
|---|
| | 636 | |
|---|
| | 637 | return mls.getName (); |
|---|
| | 638 | } |
|---|
| | 639 | } |
|---|
| | 640 | |
|---|
| | 641 | /** |
|---|
| | 642 | * MLSTableLabelProvider |
|---|
| 575 | 643 | * |
|---|
| 576 | 644 | * An inner utility class responsible for helping out with the |
|---|
| … | … | |
| 580 | 648 | * |
|---|
| 581 | 649 | */ |
|---|
| 582 | | protected class TableLabelProvider |
|---|
| 583 | | implements ITableLabelProvider |
|---|
| | 650 | protected class MLSTableLabelProvider |
|---|
| | 651 | extends LabelProvider |
|---|
| | 652 | implements ITableLabelProvider |
|---|
| 584 | 653 | { |
|---|
| 585 | 654 | /** |
|---|
| … | … | |
| 670 | 739 | // reflected in the GUI. (May not actually be the case.) |
|---|
| 671 | 740 | return true; |
|---|
| 672 | | } |
|---|
| 673 | | |
|---|
| 674 | | /** |
|---|
| 675 | | * dispose |
|---|
| 676 | | * |
|---|
| 677 | | * required implementation by a base class. |
|---|
| 678 | | * |
|---|
| 679 | | */ |
|---|
| 680 | | public void dispose () |
|---|
| 681 | | {} |
|---|
| 682 | | |
|---|
| 683 | | /** |
|---|
| 684 | | * addListener |
|---|
| 685 | | * |
|---|
| 686 | | * required implementation by a base class |
|---|
| 687 | | */ |
|---|
| 688 | | public void addListener (ILabelProviderListener ipl) |
|---|
| 689 | | {} |
|---|
| 690 | | |
|---|
| 691 | | /** |
|---|
| 692 | | * addListener |
|---|
| 693 | | * |
|---|
| 694 | | * required implementation by a base class |
|---|
| 695 | | */ |
|---|
| 696 | | public void removeListener (ILabelProviderListener ipl) |
|---|
| 697 | | {} |
|---|
| | 741 | } |
|---|
| 698 | 742 | } |
|---|
| 699 | 743 | |
|---|
| … | … | |
| 707 | 751 | * |
|---|
| 708 | 752 | */ |
|---|
| 709 | | protected class roleCellModifier |
|---|
| | 753 | protected class MLSCellModifier |
|---|
| 710 | 754 | implements ICellModifier |
|---|
| 711 | 755 | { |
|---|
| … | … | |
| 721 | 765 | * |
|---|
| 722 | 766 | */ |
|---|
| 723 | | public roleCellModifier () |
|---|
| | 767 | public MLSCellModifier () |
|---|
| 724 | 768 | { |
|---|
| 725 | 769 | } |
|---|
| … | … | |
| 759 | 803 | |
|---|
| 760 | 804 | // Determine which property is being requested |
|---|
| 761 | | if (roleCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| | 805 | if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| 762 | 806 | { |
|---|
| 763 | 807 | retValue = MLSEclipseLevel.getColorRGB (mls); |
|---|
| 764 | 808 | } |
|---|
| 765 | | else if (roleCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| | 809 | else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| 766 | 810 | { |
|---|
| 767 | 811 | retValue = mls.getName (); |
|---|
| 768 | 812 | } |
|---|
| 769 | | else if (roleCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| | 813 | else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| 770 | 814 | { |
|---|
| 771 | 815 | retValue = mls.getRange (); |
|---|
| … | … | |
| 800 | 844 | |
|---|
| 801 | 845 | // Determine which property has changed |
|---|
| 802 | | if (roleCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| | 846 | if (MLSCellModifier.COLOR_PROPERTY_NAME.equals (property)) |
|---|
| 803 | 847 | { |
|---|
| 804 | 848 | // Update the Color Definition |
|---|
| 805 | 849 | MLSEclipseLevel.setColorInstance (mls, (RGB)value); |
|---|
| 806 | 850 | } |
|---|
| 807 | | else if (roleCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| | 851 | else if (MLSCellModifier.NAME_PROPERTY_NAME.equals (property)) |
|---|
| 808 | 852 | { |
|---|
| 809 | 853 | // The Name was change so the key to it needs to be changed too |
|---|
| … | … | |
| 814 | 858 | _levels.add (mls); |
|---|
| 815 | 859 | } |
|---|
| 816 | | else if (roleCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| | 860 | else if (MLSCellModifier.RANGE_PROPERTY_NAME.equals (property)) |
|---|
| 817 | 861 | { |
|---|
| 818 | 862 | mls.setRange (value.toString ()); |
|---|
| … | … | |
| 821 | 865 | // force the viewer to update itself. |
|---|
| 822 | 866 | _ctv.refresh (); |
|---|
| | 867 | _levelsDefault.refresh (); |
|---|
| 823 | 868 | |
|---|
| 824 | 869 | return; |
|---|
| r1883 |
r1936 |
|
| 30 | 30 | public static String shift_down; |
|---|
| 31 | 31 | public static String default_level; |
|---|
| 32 | | |
|---|
| | 32 | public static String color_column_header; |
|---|
| | 33 | public static String name_column_header; |
|---|
| | 34 | public static String range_column_header; |
|---|
| 33 | 35 | |
|---|
| 34 | 36 | |
|---|
| r1883 |
r1936 |
|
| 24 | 24 | shift_down=Shift Down |
|---|
| 25 | 25 | default_level=Default Level |
|---|
| | 26 | color_column_header=Color |
|---|
| | 27 | name_column_header=Name |
|---|
| | 28 | range_column_header=Range |
|---|
| 26 | 29 | |
|---|
| 27 | 30 | ## text editor preferences |
|---|
Download in other formats:
* Generating other formats may take time.