Changeset 2244
- Timestamp:
- 06/24/08 14:05:32 (3 months ago)
- Files:
-
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/DomainShape.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/EntryConnection.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/ResourceShape.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/DomainShape.java
r2204 r2244 10 10 package com.tresys.framework.plugin.editor.policy.graphic.model; 11 11 12 import java.util.ArrayList; 13 import java.util.Arrays; 12 14 import java.util.Collection; 13 15 import java.util.Iterator; … … 22 24 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; 23 25 import org.eclipse.ui.views.properties.IPropertyDescriptor; 24 import org.eclipse.ui.views.properties.PropertyDescriptor;25 26 import org.eclipse.ui.views.properties.TextPropertyDescriptor; 26 27 … … 114 115 public IPropertyDescriptor [] getPropertyDescriptors() 115 116 { 116 if( hasCustomization () )117 return new IPropertyDescriptor[]{};118 119 117 Dictionary dictionary = getSystem ().getDictionary(); 120 118 121 // if (m_descriptors == null) 122 { 123 int nStatPropCount = 1; 124 125 // vector of rdefs (not control rdefs) 126 Vector rdefVec = new Vector (); 127 Vector controlVec = new Vector (); 128 { 129 Map rdefMap = dictionary.GetRdefs(); 130 Iterator itr = rdefMap.values().iterator (); 119 Map rdefMap = dictionary.GetRdefs (); 120 int nRdefCount = rdefMap.size (); 121 122 // abilities 123 Map abilityMap = null; 124 int nAbilityCount = 0; 125 126 { 127 abilityMap = getSystem ().getLinkage().GetAvailiableAbilities(); 128 nAbilityCount = abilityMap.size(); 129 } 130 131 132 MLSSupport mlsSupport = getMLSSupport (); 133 ArrayList myDescriptor = new ArrayList (nAbilityCount + nRdefCount*2 + 5); 134 { 135 IPropertyDescriptor [] parentDescriptors = super.getPropertyDescriptors(); 136 if (parentDescriptors != null) 137 myDescriptor.addAll (Arrays.asList (parentDescriptors)); 138 } 139 140 //Set validator to be used by cell editor. When value not valid, message will be returned 141 if (!hasCustomization ()) 142 { 143 TextPropertyDescriptor descriptor = new TextPropertyDescriptor(NAME_PROP, DISPLAY_NAME_NAME); 144 145 descriptor.setValidator( new NameValidator()); 146 descriptor.setAlwaysIncompatible(true); 147 descriptor.setCategory(PROP_SECTION_BASE); 148 149 myDescriptor.add (descriptor); 150 } 151 // Fetch project to get the current MLS Level configuration definitions 152 if (mlsSupport != null) 153 { 154 ComboBoxPropertyDescriptor descriptor = new ComboBoxPropertyDescriptor(MLS_PROP, DISPLAY_NAME_MLS, mlsSupport.getLevelNames ()); 155 descriptor.setCategory (PROP_SECTION_BASE); 156 157 myDescriptor.add (descriptor); 158 } 159 160 if (!hasCustomization ()) 161 { 162 for (Iterator itr = rdefMap.values().iterator (); itr.hasNext(); ) 163 { 164 Rdef rdef = (Rdef) itr.next(); 165 String sName = rdef.GetName(); 166 167 if (rdef.isNetworkRdef ()) 168 continue; 169 170 String sCategory = PROP_SECTION_RDEF; 171 if (rdef.isControlRdef()) 172 { 173 sCategory = PROP_SECTION_CONTROL_RDEF; 174 sName = sName.substring(0, sName.length() -1); 175 } 176 177 CheckboxPropertyDescriptor descriptor = new CheckboxPropertyDescriptor (rdef, sName); 178 descriptor.setCategory(sCategory); 179 180 String sDesc = null; 181 NameValuePair description = rdef.GetNameValuePair (INameValue.DESCRIPTION); 182 if (description != null) 183 sDesc = description.GetValue ().toString (); 184 descriptor.setDescription (sDesc); 131 185 132 while (itr.hasNext()) 133 { 134 Rdef item = (Rdef) itr.next(); 135 136 if (item.isControlRdef()) 137 controlVec.add (item); 138 else if (!item.isNetworkRdef ()) 139 rdefVec.add (item); 140 } 141 } 142 143 int nRdefCount = rdefVec.size(); 144 int nControlCount = controlVec.size (); 145 146 // abilities 147 Map abilityMap = null; 148 int nAbilityCount = 0; 149 150 // Policy pol = getPolicy (); 151 // if (pol != null) 152 { 153 abilityMap = getSystem ().getLinkage().GetAvailiableAbilities(); 154 nAbilityCount = abilityMap.size(); 155 } 156 157 158 MLSSupport mlsSupport = getMLSSupport (); 159 if (mlsSupport != null) 160 { 161 nStatPropCount ++; 162 } 163 164 IPropertyDescriptor [] parentDescriptors = super.getPropertyDescriptors(); 165 PropertyDescriptor [] myDescriptors = new PropertyDescriptor[nAbilityCount + nRdefCount + nControlCount + nStatPropCount]; 166 167 myDescriptors[0] = new TextPropertyDescriptor(NAME_PROP, DISPLAY_NAME_NAME); 168 169 //Set validator to be used by cell editor. When value not valid, message will be returned 170 myDescriptors[0].setValidator( new NameValidator()); 171 myDescriptors[0].setAlwaysIncompatible(true); 172 myDescriptors[0].setCategory(PROP_SECTION_BASE); 173 174 // Fetch project to get the current MLS Level configuration definitions 175 if (mlsSupport != null) 176 { 177 myDescriptors[1] = new ComboBoxPropertyDescriptor(MLS_PROP, DISPLAY_NAME_MLS, mlsSupport.getLevelNames ()); 178 myDescriptors[1].setCategory (PROP_SECTION_BASE); 179 } 180 181 182 { 183 Iterator itr = rdefVec.iterator(); 184 int nBaseLoc = nStatPropCount; 185 186 for (int i = 0; i < nRdefCount && itr.hasNext(); i++) 187 { 188 Rdef rdef = (Rdef) itr.next(); 189 String sName = rdef.GetName(); 190 myDescriptors[i + nBaseLoc] = new CheckboxPropertyDescriptor (rdef, sName); 191 myDescriptors[i + nBaseLoc].setCategory(PROP_SECTION_RDEF); 192 193 String sDesc = null; 194 NameValuePair description = rdef.GetNameValuePair (INameValue.DESCRIPTION); 195 if (description != null) 196 sDesc = description.GetValue ().toString (); 197 myDescriptors[i + nBaseLoc].setDescription (sDesc); 198 } 199 } 200 201 { 202 Iterator itr = controlVec.iterator(); 203 int nBaseLoc = nStatPropCount + nRdefCount; 204 205 for (int i = 0; i < nControlCount && itr.hasNext(); i++) 206 { 207 Rdef rdef = (Rdef) itr.next(); 208 String sName = rdef.GetName(); 209 sName = sName.substring(0, sName.length() -1); 210 myDescriptors[i + nBaseLoc] = new CheckboxPropertyDescriptor (rdef, sName); 211 myDescriptors[i + nBaseLoc].setCategory(PROP_SECTION_CONTROL_RDEF); 212 213 String sDesc = null; 214 NameValuePair description = rdef.GetNameValuePair (INameValue.DESCRIPTION); 215 if (description != null) 216 sDesc = description.GetValue ().toString (); 217 myDescriptors[i + nBaseLoc].setDescription (sDesc); 218 } 219 } 220 221 if (abilityMap != null) 222 { 223 Iterator itr = abilityMap.values().iterator(); 224 int nBaseLoc = nStatPropCount + nRdefCount + nControlCount; 225 226 for (int i = 0; i < nAbilityCount && itr.hasNext (); i++) 227 { 228 Ability ability = (Ability) itr.next (); 229 myDescriptors[i + nBaseLoc] = new CheckboxPropertyDescriptor (ability, ability.getName()); 230 myDescriptors[i + nBaseLoc].setCategory(PROP_SECTION_ABILITY); 231 232 String sDesc = null; 233 NameValuePair description = ability.GetNameValuePair (INameValue.DESCRIPTION); 234 if (description != null) 235 sDesc = description.GetValue ().toString (); 236 myDescriptors[i + nBaseLoc].setDescription (sDesc); 237 } 238 } 186 myDescriptor.add (descriptor); 187 } 188 } 189 190 if (!hasCustomization () && abilityMap != null) 191 { 192 for (Iterator itr = abilityMap.values().iterator(); itr.hasNext (); ) 193 { 194 Ability ability = (Ability) itr.next (); 195 CheckboxPropertyDescriptor descriptor = new CheckboxPropertyDescriptor (ability, ability.getName()); 196 descriptor.setCategory(PROP_SECTION_ABILITY); 197 198 String sDesc = null; 199 NameValuePair description = ability.GetNameValuePair (INameValue.DESCRIPTION); 200 if (description != null) 201 sDesc = description.GetValue ().toString (); 202 descriptor.setDescription (sDesc); 239 203 240 m_descriptors = new IPropertyDescriptor [parentDescriptors.length + myDescriptors.length]; 241 System.arraycopy(parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 242 System.arraycopy(myDescriptors, 0, m_descriptors, parentDescriptors.length, myDescriptors.length); 243 244 } 245 246 IPropertyDescriptor [] returnDescriptors = m_descriptors; 204 myDescriptor.add (descriptor); 205 } 206 } 207 247 208 248 209 Domain dom = (Domain) getComponent(); 249 210 if (dom != null && dom.GetChildren().isEmpty()) 250 211 { 251 // Dictionary dictionary = getPolicy().getDictionary(); 252 Vector pathDescriptor = new Vector (); 253 254 { 255 Map rdefMap = dictionary.GetRdefs(); 256 Iterator itr = rdefMap.values().iterator (); 212 for (Iterator itr = rdefMap.values ().iterator (); itr.hasNext(); ) 213 { 214 Rdef item = (Rdef) itr.next(); 257 215 258 while (itr.hasNext()) 216 if (item.isControlRdef()) 217 continue; 218 219 if (!dom.contains(item)) 220 continue; 221 222 if (item.GetSysResourceState (SystemResourceTypes.dir) != SysResourceState.No 223 || item.GetSysResourceState (SystemResourceTypes.file) != SysResourceState.No) 259 224 { 260 Rdef item = (Rdef) itr.next(); 261 262 if (item.isControlRdef()) 263 continue; 264 265 if (!dom.contains(item)) 266 continue; 267 268 if (item.GetSysResourceState (SystemResourceTypes.dir) != SysResourceState.No 269 || item.GetSysResourceState (SystemResourceTypes.file) != SysResourceState.No) 270 { 271 PathPropertyDescriptor descriptor = new PathPropertyDescriptor (new PathRdefEditContainer (item), item.GetName()); 272 descriptor.setCategory(PROP_SECTION_PATH); 273 pathDescriptor.add(descriptor); 274 } 225 PathPropertyDescriptor descriptor = new PathPropertyDescriptor (new PathRdefEditContainer (item), item.GetName()); 226 descriptor.setCategory(PROP_SECTION_PATH); 227 228 myDescriptor.add (descriptor); 275 229 } 276 230 } 277 278 returnDescriptors = new IPropertyDescriptor [m_descriptors.length + pathDescriptor.size()]; 279 returnDescriptors = (IPropertyDescriptor []) pathDescriptor.toArray(returnDescriptors); 280 System.arraycopy(m_descriptors, 0, returnDescriptors, pathDescriptor.size(), m_descriptors.length); 281 } 282 283 return returnDescriptors; 231 } 232 233 m_descriptors = new IPropertyDescriptor [myDescriptor.size ()]; 234 m_descriptors = (IPropertyDescriptor []) myDescriptor.toArray (m_descriptors); 235 236 return m_descriptors; 237 238 // return returnDescriptors; 284 239 } 285 240 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/EntryConnection.java
r2096 r2244 300 300 sDesc = description.GetValue ().toString (); 301 301 enterDefn[j+1].setDescription (sDesc); 302 }302 } 303 303 } 304 304 trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java
r2239 r2244 257 257 public IPropertyDescriptor[] getPropertyDescriptors () 258 258 { 259 if( hasCustomization () )260 return new IPropertyDescriptor[]{};261 262 IPropertyDescriptor[] parentDescriptors = super.getPropertyDescriptors ();263 259 264 260 265 261 MLSSupport mlsSupport = getMLSSupport (); 266 262 ArrayList myDescriptors = new ArrayList (); 267 263 { 264 IPropertyDescriptor[] parentDescriptors = super.getPropertyDescriptors (); 265 if (parentDescriptors != null) 266 myDescriptors.addAll (Arrays.asList (parentDescriptors)); 267 } 268 268 // Set validator to be used by cell editor. When value not valid, 269 269 // message will be returned 270 TextPropertyDescriptor text_desc = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 271 text_desc.setValidator (new NameValidator ()); 272 text_desc.setAlwaysIncompatible (true); 273 text_desc.setCategory (PROP_SECTION_BASE); 274 myDescriptors.add (text_desc); 275 270 if (!hasCustomization ()) 271 { 272 TextPropertyDescriptor text_desc = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 273 text_desc.setValidator (new NameValidator ()); 274 text_desc.setAlwaysIncompatible (true); 275 text_desc.setCategory (PROP_SECTION_BASE); 276 myDescriptors.add (text_desc); 277 } 278 276 279 // Fetch project to get the current MLS Level configuration 277 280 // definitions 278 281 if (mlsSupport != null) 279 282 { 280 ComboBoxPropertyDescriptor combo_desc = new ComboBoxPropertyDescriptor (MLS_PROP, DISPLAY_NAME_MLS, mlsSupport 281 .getLevelNames ()); 283 ComboBoxPropertyDescriptor combo_desc = new ComboBoxPropertyDescriptor (MLS_PROP, DISPLAY_NAME_MLS, mlsSupport.getLevelNames ()); 282 284 combo_desc.setCategory (PROP_SECTION_BASE); 283 285 myDescriptors.add (combo_desc); 284 286 } 285 287 288 if (!hasCustomization ()) 286 289 { 287 290 ComboBoxPropertyDescriptor prop_desc = new ComboBoxPropertyDescriptor (NETWORK_TYPE_PROP, DISPLAY_NAME_NETWORK_TYPE, getRDefsArray ()); … … 377 380 } 378 381 379 m_descriptors = new IPropertyDescriptor[parentDescriptors.length + myDescriptors.size ()]; 380 381 System.arraycopy (parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 382 System.arraycopy (myDescriptors.toArray (), 0, m_descriptors, parentDescriptors.length, myDescriptors.size ()); 383 382 m_descriptors = new IPropertyDescriptor[myDescriptors.size ()]; 383 m_descriptors = (IPropertyDescriptor []) myDescriptors.toArray (m_descriptors); 384 384 385 385 return m_descriptors; trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/ResourceShape.java
r2204 r2244 10 10 package com.tresys.framework.plugin.editor.policy.graphic.model; 11 11 12 import java.util.ArrayList; 13 import java.util.Arrays; 12 14 import java.util.HashSet; 13 15 import java.util.Iterator; … … 20 22 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; 21 23 import org.eclipse.ui.views.properties.IPropertyDescriptor; 22 import org.eclipse.ui.views.properties.PropertyDescriptor;23 24 import org.eclipse.ui.views.properties.TextPropertyDescriptor; 24 25 … … 117 118 public IPropertyDescriptor [] getPropertyDescriptors() 118 119 { 119 if (hasCustomization ()) 120 return new IPropertyDescriptor[]{}; 121 122 int nStatPropCount = 1; 123 124 // if (m_descriptors == null) 125 { 126 IPropertyDescriptor [] parentDescriptors = super.getPropertyDescriptors(); 127 120 { 128 121 Vector rdefs = getRDefs(); 129 130 122 int nRdefCount = rdefs.size(); 131 123 124 ArrayList myDescriptors = new ArrayList (nRdefCount*2 + 5); 125 { 126 IPropertyDescriptor [] parentDescriptors = super.getPropertyDescriptors(); 127 if (parentDescriptors != null) 128 myDescriptors.addAll (Arrays.asList (parentDescriptors)); 129 } 132 130 MLSSupport mlsSupport = getMLSSupport (); 133 if (mlsSupport != null)134 {135 nStatPropCount ++;136 }137 138 PropertyDescriptor [] myDescriptors = new PropertyDescriptor[nStatPropCount + nRdefCount];139 131 140 132 //Set validator to be used by cell editor. When value not valid, message will be returned 141 myDescriptors[0] = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 142 myDescriptors[0].setValidator (new NameValidator()); 143 myDescriptors[0].setAlwaysIncompatible(true); 144 myDescriptors[0].setCategory(PROP_SECTION_BASE); 133 if (!hasCustomization ()) 134 { 135 TextPropertyDescriptor descriptor = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 136 descriptor.setValidator (new NameValidator()); 137 descriptor.setAlwaysIncompatible(true); 138 descriptor.setCategory(PROP_SECTION_BASE); 139 140 myDescriptors.add (descriptor); 141 } 145 142 146 143 // Fetch project to get the current MLS Level configuration definitions 147 144 if (mlsSupport != null) 148 145 { 149 myDescriptors[1] = new ComboBoxPropertyDescriptor(MLS_PROP, DISPLAY_NAME_MLS, mlsSupport.getLevelNames ()); 150 myDescriptors[1].setCategory (PROP_SECTION_BASE); 151 } 152 153 Vector pathDescriptor = new Vector (); 146 ComboBoxPropertyDescriptor descriptor = new ComboBoxPropertyDescriptor(MLS_PROP, DISPLAY_NAME_MLS, mlsSupport.getLevelNames ()); 147 descriptor.setCategory (PROP_SECTION_BASE); 148 149 myDescriptors.add (descriptor); 150 } 151 154 152 Resource comp = (Resource) getComponent(); 155 153 156 154 { 157 Iterator itr = rdefs.iterator ();158 int nBaseLoc = nStatPropCount;159 160 for (int i = 0; i < nRdefCount &&itr.hasNext(); i++)155 for (Iterator itr = rdefs.iterator (); itr.hasNext (); ) 156 // int nBaseLoc = nStatPropCount; 157 158 // for (int i = 0; itr.hasNext(); i++) 161 159 { 162 160 Rdef rdef = (Rdef) itr.next(); 163 myDescriptors[i + nBaseLoc] = new CheckboxPropertyDescriptor (rdef, rdef.GetName()); 164 myDescriptors[i + nBaseLoc].setCategory(PROP_SECTION_RDEF); 161 if (!hasCustomization ()) 162 { 163 CheckboxPropertyDescriptor descriptor = new CheckboxPropertyDescriptor (rdef, rdef.GetName()); 164 descriptor.setCategory(PROP_SECTION_RDEF); 165 166 { 167 String sDesc = null; 168 NameValuePair description = rdef.GetNameValuePair (INameValue.DESCRIPTION); 169 if (description != null) 170 sDesc = description.GetValue ().toString (); 171 descriptor.setDescription (sDesc); 172 173 myDescriptors.add (descriptor); 174 } 175 } 165 176 166 {167 String sDesc = null;168 NameValuePair description = rdef.GetNameValuePair (INameValue.DESCRIPTION);169 if (description != null)170 sDesc = description.GetValue ().toString ();171 myDescriptors[i + nBaseLoc].setDescription (sDesc);172 }173 174 177 if (!comp.contains(rdef)) 175 178 continue; … … 180 183 PathPropertyDescriptor descriptor = new PathPropertyDescriptor (new PathRdefEditContainer (rdef), rdef.GetName()); 181 184 descriptor.setCategory(PROP_SECTION_PATH); 182 pathDescriptor.add(descriptor);185 myDescriptors.add(descriptor); 183 186 } 184 187 } 185 188 } 186 189 187 PathPropertyDescriptor [] pathDescriptors = new PathPropertyDescriptor [pathDescriptor.size()]; 188 pathDescriptors = (PathPropertyDescriptor []) pathDescriptor.toArray(pathDescriptors); 189 190 191 m_descriptors = new IPropertyDescriptor [parentDescriptors.length + myDescriptors.length + pathDescriptors.length]; 192 System.arraycopy (parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 193 System.arraycopy (myDescriptors, 0, m_descriptors, parentDescriptors.length, myDescriptors.length); 194 System.arraycopy (pathDescriptors, 0, m_descriptors, parentDescriptors.length + myDescriptors.length, pathDescriptors.length); 190 // PathPropertyDescriptor [] pathDescriptors = new PathPropertyDescriptor [pathDescriptor.size()]; 191 // pathDescriptors = (PathPropertyDescriptor []) pathDescriptor.toArray(pathDescriptors); 192 193 194 m_descriptors = new IPropertyDescriptor [myDescriptors.size ()]; 195 m_descriptors = (IPropertyDescriptor []) myDescriptors.toArray (m_descriptors); 196 // System.arraycopy (parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 197 // System.arraycopy (myDescriptors, 0, m_descriptors, parentDescriptors.length, myDescriptors.length); 198 // System.arraycopy (pathDescriptors, 0, m_descriptors, parentDescriptors.length + myDescriptors.length, pathDescriptors.length); 195 199 } 196 200
