added button to start tests.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / resourcesview / PHPProject.java
index 775c6d7..e42cf0a 100644 (file)
@@ -29,12 +29,20 @@ import org.xml.sax.XMLReader;
 
 public class PHPProject implements IProjectNature, PHPElement {
   protected IProject fProject;
-  protected List loadPathEntries;
-  protected boolean scratched;
+ // protected IndexFileReader fIndexManager;
+  protected List fLoadPathEntries;
+  protected boolean fScratched;
 
   public PHPProject() {
   }
 
+  public void addLoadPathEntry(IProject anotherPHPProject) {
+    fScratched = true;
+
+    LoadPathEntry newEntry = new LoadPathEntry(anotherPHPProject);
+    getLoadPathEntries().add(newEntry);
+  }
+
   public void configure() throws CoreException {
     // get project description and then the associated build commands 
     IProjectDescription desc = fProject.getDescription();
@@ -66,96 +74,32 @@ public class PHPProject implements IProjectNature, PHPElement {
   public void deconfigure() throws CoreException {
   }
 
-  public IProject getProject() {
-    return fProject;
-  }
-
-  protected IProject getProject(String name) {
-    return PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
-  }
-
-  public void setProject(IProject aProject) {
-    fProject = aProject;
-  }
-
-  public void addLoadPathEntry(IProject anotherPHPProject) {
-    scratched = true;
-
-    LoadPathEntry newEntry = new LoadPathEntry(anotherPHPProject);
-    getLoadPathEntries().add(newEntry);
-  }
-
-  public void removeLoadPathEntry(IProject anotherPHPProject) {
-    Iterator entries = getLoadPathEntries().iterator();
-    while (entries.hasNext()) {
-      LoadPathEntry entry = (LoadPathEntry) entries.next();
-      if (entry.getType() == LoadPathEntry.TYPE_PROJECT
-        && entry.getProject().getName().equals(anotherPHPProject.getName())) {
-        getLoadPathEntries().remove(entry);
-        scratched = true;
-        break;
-      }
-    }
-  }
-
   public List getLoadPathEntries() {
-    if (loadPathEntries == null) {
+    if (fLoadPathEntries == null) {
       loadLoadPathEntries();
     }
 
-    return loadPathEntries;
-  }
-
-  public List getReferencedProjects() {
-    List referencedProjects = new ArrayList();
-
-    Iterator iterator = getLoadPathEntries().iterator();
-    while (iterator.hasNext()) {
-      LoadPathEntry pathEntry = (LoadPathEntry) iterator.next();
-      if (pathEntry.getType() == LoadPathEntry.TYPE_PROJECT)
-        referencedProjects.add(pathEntry.getProject());
-    }
-
-    return referencedProjects;
-  }
-
-  protected void loadLoadPathEntries() {
-    loadPathEntries = new ArrayList();
-
-    IFile loadPathsFile = getLoadPathEntriesFile();
-
-    XMLReader reader = null;
-    try {
-      reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
-      reader.setContentHandler(getLoadPathEntriesContentHandler());
-      reader.parse(new InputSource(loadPathsFile.getContents()));
-    } catch (Exception e) {
-      //the file is nonextant or unreadable
-    }
+    return fLoadPathEntries;
   }
 
   protected ContentHandler getLoadPathEntriesContentHandler() {
     return new ContentHandler() {
-      public void characters(char[] arg0, int arg1, int arg2)
-        throws SAXException {
+      public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
       }
 
       public void endDocument() throws SAXException {
       }
 
-      public void endElement(String arg0, String arg1, String arg2)
-        throws SAXException {
+      public void endElement(String arg0, String arg1, String arg2) throws SAXException {
       }
 
       public void endPrefixMapping(String arg0) throws SAXException {
       }
 
-      public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
-        throws SAXException {
+      public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
       }
 
-      public void processingInstruction(String arg0, String arg1)
-        throws SAXException {
+      public void processingInstruction(String arg0, String arg1) throws SAXException {
       }
 
       public void setDocumentLocator(Locator arg0) {
@@ -167,23 +111,16 @@ public class PHPProject implements IProjectNature, PHPElement {
       public void startDocument() throws SAXException {
       }
 
-      public void startElement(
-        String namespaceURI,
-        String localName,
-        String qName,
-        Attributes atts)
-        throws SAXException {
+      public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
         if ("pathentry".equals(qName))
           if ("project".equals(atts.getValue("type"))) {
             IPath referencedProjectPath = new Path(atts.getValue("path"));
-            IProject referencedProject =
-              getProject(referencedProjectPath.lastSegment());
-            loadPathEntries.add(new LoadPathEntry(referencedProject));
+            IProject referencedProject = getProject(referencedProjectPath.lastSegment());
+            fLoadPathEntries.add(new LoadPathEntry(referencedProject));
           }
       }
 
-      public void startPrefixMapping(String arg0, String arg1)
-        throws SAXException {
+      public void startPrefixMapping(String arg0, String arg1) throws SAXException {
       }
     };
   }
@@ -192,25 +129,11 @@ public class PHPProject implements IProjectNature, PHPElement {
     return fProject.getFile(".loadpath");
   }
 
-  public void save() throws CoreException {
-    if (scratched) {
-      InputStream xmlPath =
-        new ByteArrayInputStream(getLoadPathXML().getBytes());
-      IFile loadPathsFile = getLoadPathEntriesFile();
-      if (!loadPathsFile.exists())
-        loadPathsFile.create(xmlPath, true, null);
-      else
-        loadPathsFile.setContents(xmlPath, true, false, null);
-
-      scratched = false;
-    }
-  }
-
   protected String getLoadPathXML() {
     StringBuffer buffer = new StringBuffer();
     buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><loadpath>");
 
-    Iterator pathEntriesIterator = loadPathEntries.iterator();
+    Iterator pathEntriesIterator = fLoadPathEntries.iterator();
 
     while (pathEntriesIterator.hasNext()) {
       LoadPathEntry entry = (LoadPathEntry) pathEntriesIterator.next();
@@ -221,8 +144,73 @@ public class PHPProject implements IProjectNature, PHPElement {
     return buffer.toString();
   }
 
+  public IProject getProject() {
+    return fProject;
+  }
+
+  protected IProject getProject(String name) {
+    return PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
+  }
+
+  public List getReferencedProjects() {
+    List referencedProjects = new ArrayList();
+
+    Iterator iterator = getLoadPathEntries().iterator();
+    while (iterator.hasNext()) {
+      LoadPathEntry pathEntry = (LoadPathEntry) iterator.next();
+      if (pathEntry.getType() == LoadPathEntry.TYPE_PROJECT)
+        referencedProjects.add(pathEntry.getProject());
+    }
+
+    return referencedProjects;
+  }
+
   public IResource getUnderlyingResource() {
     return fProject;
   }
 
+  protected void loadLoadPathEntries() {
+    fLoadPathEntries = new ArrayList();
+
+    IFile loadPathsFile = getLoadPathEntriesFile();
+
+    XMLReader reader = null;
+    try {
+      reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+      reader.setContentHandler(getLoadPathEntriesContentHandler());
+      reader.parse(new InputSource(loadPathsFile.getContents()));
+    } catch (Exception e) {
+      //the file is nonextant or unreadable
+    }
+  }
+
+  public void removeLoadPathEntry(IProject anotherPHPProject) {
+    Iterator entries = getLoadPathEntries().iterator();
+    while (entries.hasNext()) {
+      LoadPathEntry entry = (LoadPathEntry) entries.next();
+      if (entry.getType() == LoadPathEntry.TYPE_PROJECT && entry.getProject().getName().equals(anotherPHPProject.getName())) {
+        getLoadPathEntries().remove(entry);
+        fScratched = true;
+        break;
+      }
+    }
+  }
+
+  public void save() throws CoreException {
+    if (fScratched) {
+      InputStream xmlPath = new ByteArrayInputStream(getLoadPathXML().getBytes());
+      IFile loadPathsFile = getLoadPathEntriesFile();
+      if (!loadPathsFile.exists())
+        loadPathsFile.create(xmlPath, true, null);
+      else
+        loadPathsFile.setContents(xmlPath, true, false, null);
+
+      fScratched = false;
+    }
+  }
+
+  public void setProject(IProject aProject) {
+    fProject = aProject;
+  }
+
 }