Changeset 1574
- Timestamp:
- 03/23/07 14:22:13 (2 years ago)
- Files:
-
- trunk/framework-plugin/src/com/tresys/framework/compiler/dictionary/Dictionary.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkBuilder.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java (modified) (6 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/messages.properties (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/preferences/PreferenceInitializer.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/Messages.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/NewProjectPage.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/NewSystemPage.java (modified) (12 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/messages.properties (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/compiler/dictionary/Dictionary.java
r1396 r1574 66 66 errorHandler.CriticalError(e.toString() 67 67 + "\nCritical error opening file: " + dictFilename 68 + " not found");68 + " not found"); 69 69 } catch (Exception e) { 70 70 errorHandler.CriticalError(e.toString() trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkBuilder.java
r1567 r1574 12 12 13 13 import java.io.StringReader; 14 import java.util.Collection; 14 15 import java.util.Iterator; 15 16 import java.util.Map; … … 214 215 { 215 216 getProject ().refreshLocal (IResource.DEPTH_INFINITE, null); 216 Vector systems = FrameworkNature.getNature (getProject ()).getSystems (); 217 for (int i = 0; i < systems.size (); i++) 218 { 219 buildSystem ((SELinuxSystem) systems.elementAt (i)); 217 Collection systems = FrameworkNature.getNature (getProject ()).getSystems (); 218 for (Iterator itr = systems.iterator(); itr.hasNext(); ) 219 { 220 SELinuxSystem sys = (SELinuxSystem) itr.next(); 221 buildSystem(sys); 220 222 } 221 223 } … … 282 284 FrameworkNature.deleteMarkers(getProject ()); 283 285 nature.forceDictionaryReload (); 284 if (nature.getSystems () != null) 285 { 286 for (int i = 0; i < nature.getSystems ().size (); i++) 287 { 288 ((SELinuxSystem) nature.getSystems ().elementAt (i)).forcePolicyReload (); 289 ((SELinuxSystem) nature.getSystems ().elementAt (i)).forceLinkageReload (); 290 ((SELinuxSystem) nature.getSystems ().elementAt (i)).forceSystemResourcesReload (); 286 Collection systems = nature.getSystems(); 287 if (systems != null) 288 { 289 for (Iterator itr = systems.iterator(); itr.hasNext(); ) 290 { 291 SELinuxSystem sys = (SELinuxSystem) itr.next(); 292 sys.forcePolicyReload (); 293 sys.forceLinkageReload (); 294 sys.forceSystemResourcesReload (); 291 295 } 292 296 } trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java
r1567 r1574 17 17 import java.io.InputStreamReader; 18 18 import java.net.URL; 19 import java.util.Collection; 19 20 import java.util.Enumeration; 21 import java.util.HashSet; 20 22 import java.util.Iterator; 23 import java.util.Set; 21 24 import java.util.Vector; 22 25 … … 78 81 private IProject m_project; 79 82 80 private Vector/*<IFile>*/ m_systems;83 private Set/*<IFile>*/ m_systems; 81 84 82 85 public final static String m_makeFile = "Makefile"; … … 276 279 { 277 280 // Add the dictionary on the IProject so that it can be used elsewhere 278 Vector systems = getSystems (); 279 for (int i = 0; i < systems.size (); i++) 281 Collection systems = getSystems (); 282 283 284 for (Iterator itr1 = systems.iterator(); itr1.hasNext(); ) 280 285 { 281 ((SELinuxSystem) systems.elementAt (i)).forcePolicyReload(); //setPolicy (null); 282 ((SELinuxSystem) systems.elementAt (i)).forceSystemResourcesReload(); //setSystemResources (null); 286 SELinuxSystem sys = (SELinuxSystem) itr1.next(); 287 sys.forcePolicyReload(); //setPolicy (null); 288 sys.forceSystemResourcesReload(); //setSystemResources (null); 283 289 } 284 290 } … … 378 384 379 385 380 public VectorgetSystems()386 public Collection getSystems() 381 387 { 382 388 if (m_systems == null) 383 389 { 384 m_systems = new Vector();390 m_systems = new HashSet (); 385 391 try 386 392 { … … 418 424 public SELinuxSystem getSystem (IResource i_res) 419 425 { 420 Vectorvec = getSystems();426 Collection vec = getSystems(); 421 427 if (vec == null) 422 428 return null; … … 441 447 public void addSystem(SELinuxSystem system) 442 448 { 443 m_systems.add(system); 449 Collection systems = getSystems(); 450 451 systems.add(system); 444 452 } 445 453 446 454 public void removeSystem (SELinuxSystem i_system) 447 455 { 456 Collection systems = getSystems(); 448 457 m_systems.remove(i_system); 449 458 } trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/messages.properties
r1530 r1574 14 14 enter_deletion=entry connection deletion 15 15 enter_move_end=move entryConnection ending point 16 enter_move_start=move entryConnection starting point 16 17 access_move_start=move connection starting point 17 18 access_move_end=move connection endpoint trunk/framework-plugin/src/com/tresys/framework/plugin/preferences/PreferenceInitializer.java
r1512 r1574 53 53 String basePath = Platform.asLocalURL(basePathURL).getPath(); 54 54 store.setDefault(SEFPreferencePage.BASE_DICT_PATH, basePath + "resources/dictionary/dictionary.fdic"); 55 store.setDefault(SEFPreferencePage.BASE_POLICY_PATH, basePath + "refpolicy"); 55 //store.setDefault(SEFPreferencePage.BASE_POLICY_PATH, basePath + "refpolicy"); 56 store.setDefault(SEFPreferencePage.BASE_POLICY_PATH, ""); 56 57 57 58 } trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/Messages.java
r1517 r1574 23 23 public static String system_name_label; 24 24 public static String err_specify_project; 25 public static String err_spe icfy_system;25 public static String err_specify_system; 26 26 27 27 … … 32 32 public static String dictionary_label; 33 33 public static String reference_policy_label; 34 public static String err_spaces_in_name; 35 public static String err_slash_in_name; 36 public static String err_decimal_in_name; 34 37 public static String err_specify_dictionary; 35 38 public static String err_dict_not_file; … … 58 61 public static String file_copy_wait_message; 59 62 public static String please_wait; 63 public static String system_exists; 60 64 61 65 static trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/NewProjectPage.java
r1502 r1574 146 146 if (!super.validatePage ()) 147 147 return false; 148 148 149 //Additional check: system name does not contain any spaces 150 String projName = getProjectName(); 151 char[] projNameChars = new char[projName.length()]; 152 projName.getChars(0, projName.length(), projNameChars, 0); 153 154 for (int i = 0; i < projNameChars.length; i++) 155 { 156 if (Character.isSpaceChar(projNameChars[i])) 157 { 158 setErrorMessage(Messages.err_spaces_in_name); 159 return false; 160 } 161 } 162 163 //Strings to check the dictionary and refrence policy 149 164 String dictFileName = getDictFileName (); 150 165 String refPolName = getRefPolName (); trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/NewSystemPage.java
r1336 r1574 13 13 package com.tresys.framework.plugin.wizards; 14 14 15 import java.io.File; 15 16 import java.util.Vector; 16 17 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 20 import org.eclipse.core.runtime.preferences.IScopeContext; 18 21 import org.eclipse.jface.wizard.WizardPage; 19 22 import org.eclipse.swt.SWT; 20 23 24 import org.eclipse.core.resources.IFolder; 21 25 import org.eclipse.core.resources.IProject; 22 26 import org.eclipse.core.resources.IWorkspaceRoot; 27 import org.eclipse.core.resources.ProjectScope; 23 28 import org.eclipse.core.resources.ResourcesPlugin; 24 29 … … 31 36 import org.eclipse.swt.layout.GridLayout; 32 37 38 import org.eclipse.swt.widgets.Button; 33 39 import org.eclipse.swt.widgets.Combo; 34 40 import org.eclipse.swt.widgets.Composite; … … 36 42 import org.eclipse.swt.widgets.Text; 37 43 44 import com.tresys.framework.plugin.SEFramework_Plugin; 38 45 import com.tresys.framework.plugin.builder.FrameworkNature; 46 import com.tresys.framework.plugin.preferences.SEFPreferencePage; 47 import com.tresys.slide.plugin.nature.PolicyProjectNature; 48 import com.tresys.slide.utility.DialogUtil; 39 49 40 50 public class NewSystemPage 41 51 extends WizardPage 42 52 { 43 44 Text ProjectName = null; 45 Text txtSystemName = null; 46 47 Text dictName; 48 Text refPolName; 49 53 private Text txtSystemName = null; 54 private Text refPolFileName; 55 56 private Button refPolSearchButton; 57 50 58 private IProject selected_project; 51 59 private Vector availableProjects; … … 78 86 public void createControl(Composite parent) 79 87 { 88 //Composite used for Project and System Name layout 80 89 Composite composite = new Composite (parent, SWT.NONE); 81 GridLayout layout = new GridLayout(); 82 composite.setLayout(layout); 83 layout.numColumns = 2; 84 layout.verticalSpacing = 7; 85 86 //Setting up project drop-down menu 90 composite.setLayout(new GridLayout (2, false)); 91 composite.setLayoutData(new GridData (GridData.HORIZONTAL_ALIGN_FILL)); 92 93 //SETTING UP PROJECT DROP-DOWN MENU--------------------------------------- 87 94 { 88 95 Label label = new Label (composite, SWT.NULL); … … 101 108 } 102 109 } 103 104 GridData data = new GridData();105 data.widthHint = 150;106 comboProject.setLayoutData(data);107 110 } 108 111 109 // Name of system112 //GETTING THE NAME OF THE SYSTEM---------------------------------------- 110 113 { 111 114 Label label = new Label (composite, SWT.NULL); … … 117 120 } 118 121 119 122 //Setting data layout for project and system name 123 GridData data = new GridData(); 124 data.widthHint = 300; 125 data.grabExcessHorizontalSpace = true; 126 comboProject.setLayoutData(data); 127 txtSystemName.setLayoutData(data); 128 129 //GET THE LOCATION FOR THE REFERENCE POLICY----------------------------- 130 //Composite for Reference Policy data area 131 Composite dataArea = new Composite (composite, SWT.NONE); 132 133 dataArea.setLayout (new GridLayout (3, false)); 134 dataArea.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); 135 136 { 137 Label refPolDirLabel = new Label (dataArea, SWT.NONE); 138 refPolDirLabel.setText (Messages.reference_policy_label); 139 refPolDirLabel.setLayoutData(new GridData()); 140 141 refPolFileName = new Text (dataArea, SWT.SINGLE | SWT.BORDER); 142 refPolFileName.setLayoutData(new GridData (GridData.FILL_HORIZONTAL)); 143 144 refPolSearchButton = new Button (dataArea, SWT.PUSH); 145 refPolSearchButton.setText (Messages.browse); 146 refPolSearchButton.setLayoutData(new GridData ()); 147 refPolSearchButton.addSelectionListener (new SelectionAdapter () 148 149 { 150 public void widgetSelected (SelectionEvent e) 151 { 152 refPolFileName.setText (DialogUtil.DirectorySelector (getShell (),refPolFileName.getText ())); 153 } 154 }); 155 156 } 157 158 //Setting up layout for data information for reference policy directory 159 GridData theData = new GridData (GridData.HORIZONTAL_ALIGN_FILL); 160 theData.minimumWidth = 300; 161 theData.grabExcessHorizontalSpace = true; 162 refPolFileName.setLayoutData(theData); 163 164 //Add listeners to the system name, project, and reference policy directory 120 165 txtSystemName.addModifyListener(m_modifyText); 121 166 comboProject.addModifyListener(m_modifyText); … … 125 170 } 126 171 }); 127 172 173 refPolFileName.addModifyListener(m_modifyText); 174 PullPrefsFromWorkspace(); 175 128 176 setControl(composite); 129 177 updateStatus(null); … … 132 180 133 181 /** 182 * Copy the preference to the workspace --- The Base Policy Path 183 * 184 */ 185 protected void PullPrefsFromWorkspace () 186 { 187 IScopeContext currProjScope = new ProjectScope (selected_project); 188 IEclipsePreferences projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); 189 190 refPolFileName.setText(projPrefs.get(SEFPreferencePage.BASE_POLICY_PATH, null)); 191 } 192 193 /** 134 194 * populate the m_projects array 135 195 * … … 158 218 } 159 219 160 /*Verify that a project has been selected and a system name entered*/ 220 /** 221 * Verify that a project has been selected, a system name entered(and same name does not exist), and 222 * that a reference policy directory has been selected that 223 * */ 161 224 public void DialogChanged() 162 225 { 163 226 IProject selectedProj = getProject(); 164 String theSystemName = getSystemName(); 165 227 String sysName = getSystemName(); 228 String refPolName = getRefPolFileName(); 229 230 //Check that a project was selected ------------------------------------ 166 231 if ( selectedProj == null ) 167 232 { … … 171 236 } 172 237 173 if ( theSystemName.length() == 0 ) 174 { 175 updateStatus(Messages.err_speicfy_system); 238 //Check the System name information ----------------------------------- 239 240 //Check that a name was entered for the system 241 if ( sysName.length() == 0 ) 242 { 243 updateStatus(Messages.err_specify_system); 176 244 setPageComplete(false); 177 245 return; 178 } 246 } 247 248 //Check that the system name has not been used yet for the project 249 if ( systemNameExists(sysName) ) 250 { 251 updateStatus(Messages.system_exists); 252 setPageComplete(false); 253 return; 254 } 255 256 //Check that the system name does not include '/' '\' or ' ' or start with a '.' 257 char[] sysNameChars = new char[sysName.length()]; 258 sysName.getChars(0, sysName.length(), sysNameChars, 0); 259 260 if ( sysNameChars[0] == '.') 261 { 262 updateStatus(Messages.err_decimal_in_name); 263 setPageComplete(false); 264 return; 265 } 266 267 for (int i = 0; i < sysNameChars.length; i++) 268 { 269 if (Character.isSpaceChar(sysNameChars[i])) 270 { 271 updateStatus(Messages.err_spaces_in_name); 272 setPageComplete(false); 273 return; 274 } 275 276 if (sysNameChars[i] == '/' || sysNameChars[i] == '\\') 277 { 278 updateStatus(Messages.err_slash_in_name); 279 setPageComplete(false); 280 return; 281 } 282 283 284 } 285 286 287 //Check reference policy information ----------------------------------- 288 289 //Checking that there is input 290 if (refPolName.length () == 0) 291 { 292 setErrorMessage (Messages.err_specify_refpolicy); 293 return; 294 } 295 296 // Check that it is a directory 297 File policyDir = new File (refPolName); 298 if (!policyDir.isDirectory ()) 299 { 300 setErrorMessage (Messages.err_selection_not_directory); 301 return; 302 } 303 304 //Check if 'Makefile' present, 'policy' directory exists, and if 'global_tunables' exist 305 if (!PolicyProjectNature.isValidRefPolicyDir (refPolName)) 306 { 307 setErrorMessage (Messages.err_not_refpol_directory); 308 return; 309 } 179 310 180 311 updateStatus(null); … … 188 319 } 189 320 190 /*Get the SystemName*/ 321 /** 322 * Get the SystemName 323 * @return String - the name of the system 324 */ 191 325 public String getSystemName() 192 326 { … … 195 329 196 330 /** 197 * get the selected project 198 * @return project that has been selected 331 * Check that the name for the system does not already exists for the Project 332 * by verifying that the file <project name>/src/selinux-policy-<i_systemName> does not 333 * already exist 334 * @return boolean - true if system name already exists for project 335 */ 336 public boolean systemNameExists(String i_systemName) 337 { 338 //Get the system folder for the project with the i_systemName 339 IFolder project_systemFolder = selected_project.getFolder("/src/selinux-policy-" + i_systemName); 340 341 //if the system folder exists for project, return true 342 if (project_systemFolder.exists() ) 343 return true; 344 345 //return false if the system folder does not already exist 346 else 347 return false; 348 } 349 350 /** 351 * Return the name of the file that contains reference policy 352 * @return String - name of reference policy directory 353 */ 354 public String getRefPolFileName() 355 { 356 return refPolFileName.getText ().trim (); 357 } 358 359 /** 360 * Get the selected project 361 * @return IProject - project that has been selected 199 362 */ 200 363 public IProject getProject () trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/messages.properties
r1517 r1574 36 36 37 37 err_specify_project = You must select a project 38 err_spe icfy_system = You must specify a system name38 err_specify_system = You must specify a system name 39 39 40 40 ## new project wizard … … 48 48 reference_policy_label = Reference Policy Directory: 49 49 50 err_spaces_in_name = The name cannot include spaces 51 err_slash_in_name = The name cannot include any backword or forward slashes 52 err_decimal_in_name = The name cannot start with a decimal 50 53 err_specify_dictionary = Dictionary location must be specified 51 54 err_dict_not_file = The dictionary entry is not a file … … 60 63 cds_file=CDS Framework File 61 64 create_file_description=This wizard creates a new CDSFramework File 65 66 ## new system wizard 67 system_exists = The system name given already exists. Enter a unique system name for the project. 62 68 63 69 ## preferences
