1 package net.sourceforge.phpeclipse.preferences;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.resources.IProject;
6 import org.eclipse.core.resources.IProjectDescription;
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.core.runtime.NullProgressMonitor;
9 import org.eclipse.core.runtime.QualifiedName;
12 public class ProjectProperties
13 implements IObfuscatorPreferences
15 private IProject project;
17 // private static final String DEFAULT_BUILD = String.valueOf(DEFAULT_BUILD_VALUE);
19 public ProjectProperties(IProject project)
21 this.project = project;
25 public String getPublish()
28 return getProperty(PUBLISH_PROPERTY_NAME,DEFAULT_PUBLISH_DIR);
31 public boolean hasNature()
34 return project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
37 public void setPublish(String publish)
40 setProperty(PUBLISH_PROPERTY_NAME,publish,DEFAULT_PUBLISH_DIR);
44 public void setNature(boolean nature)
51 IProjectDescription description = project.getDescription();
52 String[] old = description.getNatureIds(),
53 natures= new String[old.length + 1];
54 System.arraycopy(old,0,natures,0,old.length);
55 natures[old.length] = PHPeclipsePlugin.PHP_NATURE_ID;
56 description.setNatureIds(natures);
57 project.setDescription(description,new NullProgressMonitor());
64 IProjectDescription description = project.getDescription();
65 String[] old = description.getNatureIds(),
66 natures= new String[old.length - 1];
71 if(!old[i].equals(PHPeclipsePlugin.PHP_NATURE_ID))
72 natures[j++] = old[i];
75 description.setNatureIds(natures);
76 project.setDescription(description,new NullProgressMonitor());
81 protected String getProperty(QualifiedName key,String def)
84 String value = project.getPersistentProperty(key);
85 if(value == null || value.length() == 0)
91 protected void setProperty(QualifiedName key,String value,String def)
94 if(value != null && value.length() != 0 && hasNature())
97 project.setPersistentProperty(key,null);
99 project.setPersistentProperty(key,value);