Changeset 1338

Show
Ignore:
Timestamp:
11/07/06 09:04:19 (2 years ago)
Author:
dsugar
Message:

fix problem when deleting project - it was trying to build again during delete.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/gefeditor/src/com/tresys/framework/plugin/builder/FrameworkBuilder.java

    r1337 r1338  
    9090                                        if (currResource.getFileExtension ().equals (m_fpolExt)) 
    9191                                        { 
    92                                                 BuildPolicy (GetSystemFromResource (currResource), 
    93                                                         (IFile) currResource); 
     92                                                BuildPolicy (GetSystemFromResource (currResource), (IFile) currResource); 
    9493                                        } 
    9594                                        else if (currResource.getFileExtension ().equals (m_flnkExt)) 
     
    159158                                { 
    160159                                        if (currResource.getName ().equals (m_confDir) 
    161                                                 && currResource.getParent () == currResource 
    162                                                         .getProject ()) 
     160                                                && currResource.getParent () == currResource.getProject ()) 
    163161                                        { 
    164162                                                supportFiles = new Vector (); 
    165163                                        } 
    166164                                        else if (!currResource.getName ().startsWith (".") 
    167                                                 && currResource.getParent ().getProjectRelativePath () 
    168                                                         .toString ().equals (m_srcDir)) 
    169                                         { 
    170                                                 getNature (currResource.getProject ()).get_systems () 
    171                                                         .remove (GetSystemFromResource (currResource)); 
     165                                                && currResource.getParent ().getProjectRelativePath ().toString ().equals (m_srcDir)) 
     166                                        { 
     167                                                getNature (currResource.getProject ()).get_systems ().remove (GetSystemFromResource (currResource)); 
    172168                                        } 
    173169                                } 
     
    241237                if (m_projPrefs == null) 
    242238                { 
    243                         Utility 
    244                                 .SetProjectErrorHandler (new GUIProjectErrorHandler (project)); 
     239                        Utility.SetProjectErrorHandler (new GUIProjectErrorHandler (project)); 
    245240 
    246241                        IScopeContext currProjScope = new ProjectScope (project); 
    247242 
    248243                        m_projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); 
    249                         m_projPrefs.addPreferenceChangeListener (new IEclipsePreferences.IPreferenceChangeListener () { 
    250                                         public void preferenceChange (PreferenceChangeEvent event) 
    251                                         { 
    252                                                 // if the base dictionary is changed in the project 
    253                                                 // rebuild it. 
    254                                                 if (event.getKey ().equals ( 
    255                                                         SEFPreferencePage.BASE_DICT_PATH)) 
     244                        m_projPrefs.addPreferenceChangeListener (new IEclipsePreferences.IPreferenceChangeListener ()  
     245                        { 
     246                                public void preferenceChange (PreferenceChangeEvent event) 
     247                                { 
     248                                        // if the base dictionary is changed in the project 
     249                                        // rebuild it. 
     250                                        if (event.getNewValue() == null) 
     251                                                return; 
     252                                         
     253                                        if (event.getKey ().equals (SEFPreferencePage.BASE_DICT_PATH)) 
     254                                        { 
     255                                                try 
    256256                                                { 
    257                                                         try 
    258                                                         { 
    259                                                                 clean (null); 
    260                                                         } 
    261                                                         catch (CoreException ce) 
    262                                                         {} 
    263                                                         fullBuild (null); 
     257                                                        clean (null); 
    264258                                                } 
    265                                         } 
    266                                 }); 
     259                                                catch (CoreException ce) 
     260                                                {} 
     261                                                fullBuild (null); 
     262                                        } 
     263                                } 
     264                        }); 
    267265                } 
    268266 
     
    272270 
    273271                Enumeration eFlnks = SEFramework_Plugin.getDefault ().getBundle () 
    274                         .findEntries ("resources" + IPath.SEPARATOR + "link", "*." + m_flnkExt, 
    275                                 true); 
     272                        .findEntries ("resources" + IPath.SEPARATOR + "link", "*." + m_flnkExt, true); 
    276273                while (eFlnks.hasMoreElements ()) 
    277274                { 
     
    290287                        findAllSupportFiles ((IFolder) supportFolder); 
    291288 
    292                 Utility.SetDebug (SEFramework_Plugin.getDefault () 
    293                         .getPreferenceStore ().getBoolean (SEFPreferencePage.VERBOSE_COMPILE)); 
     289                Utility.SetDebug (SEFramework_Plugin.getDefault ().getPreferenceStore ().getBoolean (SEFPreferencePage.VERBOSE_COMPILE)); 
    294290        } 
    295291 
     
    435431                { 
    436432                        deleteMarkers (dictionaryFile); 
    437                         GUIErrorHandler currFileHandler = new GUIErrorHandler ( 
    438                                 dictionaryFile); 
    439  
    440                         theDict.AddDictionaryReader (new InputStreamReader (dictionaryFile 
    441                                 .getContents ()), currFileHandler); 
     433                        GUIErrorHandler currFileHandler = new GUIErrorHandler (dictionaryFile); 
     434 
     435                        theDict.AddDictionaryReader (new InputStreamReader (dictionaryFile.getContents ()), currFileHandler); 
    442436                        return currFileHandler.GetErrorCount (); 
    443437                } 
    444438                catch (CoreException e) 
    445439                { 
    446                         Utility.ProjectError ("Error adding " + dictionaryFile.getName () 
    447                                 + " to the dictionary"); 
     440                        Utility.ProjectError ("Error adding " + dictionaryFile.getName () + " to the dictionary"); 
    448441                        e.printStackTrace (); 
    449442                        return 1; 
     
    473466                                                flnkHandler = new GUIErrorHandler (currFile); 
    474467 
    475                                                 fileReader = new InputStreamReader (currFile 
    476                                                         .getContents ()); 
     468                                                fileReader = new InputStreamReader (currFile.getContents ()); 
    477469                                        } 
    478470                                        else 
    479471                                        { 
    480472                                                File currFile = currPath.toFile (); 
    481                                                 flnkHandler = new CLIErrorHandler (currFile 
    482                                                         .getAbsolutePath ()); 
     473                                                flnkHandler = new CLIErrorHandler (currFile.getAbsolutePath ()); 
    483474                                                FileInputStream fstr = new FileInputStream (currFile); 
    484475                                                fileReader = new InputStreamReader (fstr); 
     
    506497                for (int j = 0; j < getNature (currProj).get_systems ().size (); j++) 
    507498                { 
    508                         SELinuxSystem system = (SELinuxSystem) getNature (currProj) 
    509                                 .get_systems ().elementAt (j); 
     499                        SELinuxSystem system = (SELinuxSystem) getNature (currProj).get_systems ().elementAt (j); 
    510500                        if (system.getLinkage () != null) 
    511501                        { 
     
    529519                if (getNature (system.getProject ()).getDictionary () == null) 
    530520                { 
    531                         Utility 
    532                                 .ProjectError ("No Policies can be built until a valid dictionary is made"); 
     521                        Utility.ProjectError ("No Policies can be built until a valid dictionary is made"); 
    533522                        return; 
    534523                } 
    535                 Policy thePolicy = new Policy (getNature (policyFile.getProject ()) 
    536                         .getDictionary (), system.getLinkage ()); 
     524                Policy thePolicy = new Policy (getNature (policyFile.getProject ()).getDictionary (), system.getLinkage ()); 
    537525                thePolicy.setValidInterfaces (system.getValidInterfaces ()); 
    538526                thePolicy.setBasePolicyBooleans (system.getAllBooleans ()); 
     
    541529                { 
    542530                        GUIErrorHandler policyHandler = new GUIErrorHandler (policyFile); 
    543                         thePolicy.AddPolicyReader (new InputStreamReader (policyFile 
    544                                 .getContents ()), policyHandler); 
     531                        thePolicy.AddPolicyReader (new InputStreamReader (policyFile.getContents ()), policyHandler); 
    545532                } 
    546533                catch (CoreException ce) 
    547534                { 
    548                         Utility.ProjectError ("Error adding " + policyFile.getName () 
    549                                 + " to the policy"); 
     535                        Utility.ProjectError ("Error adding " + policyFile.getName () + " to the policy"); 
    550536                        ce.printStackTrace (); 
    551537                } 
     
    570556                        GUIErrorHandler handler = new GUIErrorHandler (sysResFile); 
    571557 
    572                         sysRes.AddSystemResourcesReader (new InputStreamReader (sysResFile 
    573                                 .getContents ()), handler); 
     558                        sysRes.AddSystemResourcesReader (new InputStreamReader (sysResFile.getContents ()), handler); 
    574559                        int numErrors = handler.GetErrorCount (); 
    575                         Utility.Debug (" Found " + numErrors + " errors while parsing " 
    576                                 + sysResFile.getName ()); 
     560                        Utility.Debug (" Found " + numErrors + " errors while parsing " + sysResFile.getName ()); 
    577561                        system.setSystemResources (sysRes); 
    578562                } 
    579563                catch (CoreException ce) 
    580564                { 
    581                         Utility.ProjectError ("Error adding " + sysResFile.getName () 
    582                                 + " to the policy"); 
     565                        Utility.ProjectError ("Error adding " + sysResFile.getName () + " to the policy"); 
    583566                        ce.printStackTrace (); 
    584567                } 
     
    592575        private void BuildLinkage (SELinuxSystem system) 
    593576        { 
    594                 String flaskPath = system.getSystemPath () + File.separatorChar 
    595                         + "policy" + File.separatorChar + "flask"; 
     577                String flaskPath = system.getSystemPath () + File.separatorChar + "policy" + File.separatorChar + "flask"; 
    596578                String permWeightPath = null; 
    597579 
     
    599581                        SEFPreferencePage.PERM_WEIGHT_PATH).equals ("")) 
    600582                { 
    601                         permWeightPath = SEFramework_Plugin.getDefault () 
    602                                 .getPreferenceStore ().getString ( 
    603                                         SEFPreferencePage.PERM_WEIGHT_PATH); 
     583                        permWeightPath = SEFramework_Plugin.getDefault ().getPreferenceStore ().getString (SEFPreferencePage.PERM_WEIGHT_PATH); 
    604584                } 
    605585 
     
    612592                } 
    613593 
    614                 theLinkage.LNFILESPATH = system.getProject ().getLocation () 
    615                         .toOSString (); 
     594                theLinkage.LNFILESPATH = system.getProject ().getLocation ().toOSString (); 
    616595 
    617596                if (allBaseDomains != null) 
     
    641620                try 
    642621                { 
    643                         resource.deleteMarkers (GUIErrorHandler.MARKER_TYPE, false, 
    644                                 IResource.DEPTH_ZERO); 
     622                        resource.deleteMarkers (GUIErrorHandler.MARKER_TYPE, false, IResource.DEPTH_ZERO); 
    645623                } 
    646624                catch (CoreException ce) 
     
    691669         * @throws CoreException 
    692670         */ 
    693         protected void incrementalBuild (IResourceDelta delta, 
    694                                                                                 IProgressMonitor monitor) 
     671        protected void incrementalBuild (IResourceDelta delta, IProgressMonitor monitor) 
    695672                throws CoreException 
    696673        { 
     
    718695                        for (int i = 0; i < nature.get_systems ().size (); i++) 
    719696                        { 
    720                                 ((SELinuxSystem) nature.get_systems ().elementAt (i)) 
    721                                         .setPolicy (null); 
    722                                 ((SELinuxSystem) nature.get_systems ().elementAt (i)) 
    723                                         .setLinkage (null); 
    724                                 ((SELinuxSystem) nature.get_systems ().elementAt (i)) 
    725                                         .setSystemResources (null); 
     697                                ((SELinuxSystem) nature.get_systems ().elementAt (i)).setPolicy (null); 
     698                                ((SELinuxSystem) nature.get_systems ().elementAt (i)).setLinkage (null); 
     699                                ((SELinuxSystem) nature.get_systems ().elementAt (i)).setSystemResources (null); 
    726700                        } 
    727701                } 
     
    734708                        if (currProject == null) 
    735709                                return null; 
    736                         return ((FrameworkNature) currProject 
    737                                 .getNature (FrameworkNature.NATURE_ID)); 
     710                        return ((FrameworkNature) currProject.getNature (FrameworkNature.NATURE_ID)); 
    738711                } 
    739712                catch (CoreException ce) 
     
    745718        public static SELinuxSystem GetSystemFromResource (IResource res) 
    746719        { 
    747                 Vector systems = FrameworkBuilder.getNature (res.getProject ()) 
    748                         .get_systems (); 
     720                Vector systems = FrameworkBuilder.getNature (res.getProject ()).get_systems (); 
    749721                if (systems == null) 
    750722                        return null; 
     
    753725                        if (((SELinuxSystem) systems.elementAt (i)).getFolder () 
    754726                                .getFullPath ().isPrefixOf (res.getFullPath ())) 
     727                        { 
    755728                                return (SELinuxSystem) systems.elementAt (i); 
     729                        } 
    756730                } 
    757731                return null; 
     
    767741                        thePolicy.setBasePolicyBooleans (system.getAllBooleans ()); 
    768742                        deleteMarkers (system.getFPolFile ()); 
    769                         QuickCompileGUIErrorHandler policyHandler = new QuickCompileGUIErrorHandler ( 
    770                                 system.getFPolFile (), doc); 
    771                         thePolicy.AddPolicyReader (new StringReader (doc.get ()), 
    772                                 policyHandler); 
     743                        QuickCompileGUIErrorHandler policyHandler = new QuickCompileGUIErrorHandler (system.getFPolFile (), doc); 
     744                        thePolicy.AddPolicyReader (new StringReader (doc.get ()), policyHandler); 
    773745                        //                      system.setPolicy (thePolicy); 
    774746                }