PHP perspective and new Project Wizard
authorkhartlage <khartlage>
Tue, 3 Dec 2002 21:05:22 +0000 (21:05 +0000)
committerkhartlage <khartlage>
Tue, 3 Dec 2002 21:05:22 +0000 (21:05 +0000)
28 files changed:
net.sourceforge.phpeclipse/.classpath
net.sourceforge.phpeclipse/.project
net.sourceforge.phpeclipse/build.xml
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/LoadPathEntry.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorActionDefinitionIds.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/MainActionGroup.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElement.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElementAdapterFactory.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPFile.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPProject.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPResourcesView.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPViewerFilter.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/ResourceAdapterFactory.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPWizardMessages.properties

index ae79f9d..bee2fe3 100644 (file)
     <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.help_2.0.0/help.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.help_2.0.0/helpsrc.zip"/>
     <classpathentry kind="var"
+        path="ECLIPSE_HOME/plugins/org.eclipse.debug.ui_2.0.0/dtui.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.debug.ui_2.0.0/dtuisrc.zip"/>
+    <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.3/xmlParserAPIs.jar"/>
+    <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.3/xercesImpl.jar"/>
+    <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.0.0/runtime.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.core.runtime_2.0.0/runtimesrc.zip"/>
     <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.0.0/boot.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.core.boot_2.0.0/bootsrc.zip"/>
index a74b8f8..8acc1f7 100644 (file)
@@ -3,6 +3,7 @@
        <name>net.sourceforge.phpeclipse</name>
        <comment></comment>
        <projects>
+               <project>org.rubypeople.rdt.core</project>
        </projects>
        <buildSpec>
                <buildCommand>
index 75914da..56c4566 100644 (file)
@@ -8,7 +8,7 @@
 
        <target name="init" depends="properties">
                <property name="plugin" value="net.sourceforge.phpeclipse"/>
-               <property name="version.suffix" value="_1.0.2"/>
+               <property name="version.suffix" value="_1.0.3"/>
                <property name="full.name" value="${plugin}${version.suffix}"/>
                <property name="temp.folder" value="${basedir}/temp.folder"/>
                <property name="plugin.destination" value="${basedir}"/>
@@ -40,7 +40,7 @@
                <delete dir="${temp.folder}/phpeclipse.jar.bin"/>
                <mkdir dir="${temp.folder}/phpeclipse.jar.bin"/>
                <!-- compile the source code -->
-               <javac destdir="${temp.folder}/phpeclipse.jar.bin" failonerror="false" verbose="true" debug="on" includeAntRuntime="no" bootclasspath="${bootclasspath}" classpath="../../plugins/org.eclipse.core.resources.win32_2.0.0/resources.jar;PHPEclipse.jar;../../plugins/org.eclipse.swt_2.0.0/ws/${ws}/swt.jar;../../plugins/org.eclipse.core.boot_2.0.0/bin;../../plugins/org.eclipse.core.runtime_2.0.0/runtime.jar;../../plugins/org.eclipse.core.boot_2.0.0/boot.jar;../../plugins/org.eclipse.ui.win32_2.0.0/workbench.jar;../../plugins/org.eclipse.swt_2.0.0/bin;../../plugins/org.eclipse.core.resources_2.0.0/bin;../../plugins/org.eclipse.core.resources_2.0.0/resources.jar;../../plugins/org.eclipse.swt.win32_2.0.0/ws/${ws}/swt.jar;../../plugins/org.eclipse.help_2.0.0/bin;../../plugins/org.eclipse.ui_2.0.0/workbench.jar;../../plugins/org.eclipse.core.runtime_2.0.0/bin;../../plugins/org.eclipse.help_2.0.0/help.jar;../../plugins/org.eclipse.ui_2.0.0/bin;../../plugins/org.eclipse.ui.win32_2.0.0/workbenchwin32.jar">
+               <javac destdir="${temp.folder}/phpeclipse.jar.bin" failonerror="false" verbose="true" debug="on" includeAntRuntime="no" bootclasspath="${bootclasspath}" classpath="../../plugins/org.eclipse.core.resources.win32_2.0.0/resources.jar;../../plugins/org.apache.xerces_4.0.3/xmlParserAPIs.jar;../../plugins/org.eclipse.debug.ui_2.0.0/dtui.jar;../../plugins/org.eclipse.swt_2.0.0/ws/${ws}/swt.jar;../../plugins/org.apache.xerces_4.0.3/xercesImpl.jar;../../plugins/org.eclipse.debug.ui_2.0.0/bin;../../plugins/org.eclipse.core.boot_2.0.0/bin;../../plugins/org.eclipse.core.runtime_2.0.0/runtime.jar;../../plugins/org.eclipse.core.boot_2.0.0/boot.jar;../../plugins/org.eclipse.ui.win32_2.0.0/workbench.jar;../../plugins/org.apache.xerces_4.0.3/bin;../../plugins/org.eclipse.swt_2.0.0/bin;../../plugins/org.eclipse.core.resources_2.0.0/bin;../../plugins/org.eclipse.core.resources_2.0.0/resources.jar;../../plugins/org.eclipse.swt.win32_2.0.0/ws/${ws}/swt.jar;../../plugins/org.eclipse.help_2.0.0/bin;../../plugins/org.eclipse.ui_2.0.0/workbench.jar;../../plugins/org.eclipse.core.runtime_2.0.0/bin;../../plugins/org.eclipse.help_2.0.0/help.jar;../../plugins/org.eclipse.ui_2.0.0/bin;../../plugins/org.eclipse.ui.win32_2.0.0/workbenchwin32.jar">
                        <src path="src/"/>
                </javac>
                <!-- copy necessary resources -->
index 1d7f7bd..8ef16ae 100644 (file)
@@ -2,7 +2,17 @@
 #
 #########################################
 pluginName=PHP Plugin
-providerName = EclipseProject.de
+providerName=EclipseProject.de
+naturePHP.name=PHP Project
+
+perspectivePHP.name=PHP
+viewPHPResources.name=PHP Resources
+
+newWizardCategory.name=PHP
+newWizardPHPProject.name=PHP Project
+newWizardPHPFile.name=PHP File
+
+propertyPagePHPProject.name=PHP Project Properties
 
 #
 # Extension point names
@@ -12,3 +22,12 @@ phpConsoleView=PHP Console
 phpFileExtension=php
 php3FileExtension=php3
 php4FileExtension=php4
+
+#
+# Action sets
+#
+
+php.menu.label=&PHP
+phpActionSet.label=PHP Actions
+phpUncommentAction.label=&Uncomment@Ctrl+\\
+phpCommentAction.label=&Comment@Ctrl+/
\ No newline at end of file
index 369460f..a54447b 100644 (file)
       <import plugin="org.eclipse.ui"/>
       <import plugin="org.eclipse.help"/>
       <import plugin="org.eclipse.swt"/>
+      <import plugin="org.eclipse.debug.ui"/>
+      <import plugin="org.apache.xerces"/>
    </requires>
 
+
+   <extension
+         id="phpnature"
+         name="%naturePHP.name"
+         point="org.eclipse.core.resources.natures">
+      <runtime>
+         <run
+               class="net.sourceforge.phpeclipse.PHPProject">
+         </run>
+      </runtime>
+   </extension>
+   <extension
+         point="org.eclipse.team.core.fileTypes">
+      <fileTypes
+            type="text"
+            extension="php">
+      </fileTypes>
+      <fileTypes
+            type="text"
+            extension="php3">
+      </fileTypes>
+      <fileTypes
+            type="text"
+            extension="php4">
+      </fileTypes>
+      <fileTypes
+            type="text"
+            extension="inc">
+      </fileTypes>
+      <fileTypes
+            type="text"
+            extension="html">
+      </fileTypes>
+      <fileTypes
+            type="text"
+            extension="htm">
+      </fileTypes>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+            name="%perspectivePHP.name"
+            icon="icons/obj16/php.gif"
+            class="net.sourceforge.phpeclipse.PHPPerspectiveFactory"
+            id="net.sourceforge.phpeclipse.PHPPerspective">
+      </perspective>
+   </extension>
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <category
+            name="%newWizardCategory.name"
+            id="net.sourceforge.phpeclipse.wizards.NewWizardCategoryPHP">
+      </category>
+      <wizard
+            name="%newWizardPHPProject.name"
+            icon="icons/obj16/php.gif"
+            category="net.sourceforge.phpeclipse.wizards.NewWizardCategoryPHP"
+            class="net.sourceforge.phpeclipse.wizards.NewProjectCreationWizard"
+            project="true"
+            id="net.sourceforge.phpeclipse.wizards.NewWizardProjectCreation">
+         <description>
+            Create a new PHP project.
+         </description>
+      </wizard>
+   </extension>
+ <!--   <extension
+         point="org.eclipse.ui.newWizards">
+      <category
+            name="%newWizardCategory.name"
+            id="net.sourceforge.phpeclipse.wizardCategory">
+      </category>
+      <wizard
+            name="%newWizardPHPFile.name"
+            icon="icons/obj16/phpedit.gif"
+            category="net.sourceforge.phpeclipse.wizardCategory"
+            class="net.sourceforge.phpeclipse.wizards.PHPFileWizard"
+            id="net.sourceforge.phpeclipse.wizards.PHPFileWizard">
+         <description>
+            Create a basic PHP file.
+         </description>
+      </wizard>
+   </extension> -->
+   <extension
+         point="org.eclipse.ui.projectNatureImages">
+      <image
+            icon="icons/obj16/php.gif"
+            natureId="net.sourceforge.phpeclipse.phpnature"
+            id="net.sourceforge.phpeclipse..ProjectNatureImagePHP">
+      </image>
+   </extension>
+   <extension
+         point="org.eclipse.ui.propertyPages">
+      <page
+            objectClass="org.eclipse.core.resources.IProject"
+            name="%propertyPagePHPProject.name"
+            class="net.sourceforge.phpeclipse.preferences.PHPProjectPropertyPage"
+            id="net.sourceforge.phpeclipse.preferences.PropertyPagePHPProject">
+         <filter
+               name="nature"
+               value="net.sourceforge.phpeclipse.phpnature">
+         </filter>
+      </page>
+      <page
+            objectClass="net.sourceforge.phpeclipse.PHPProject"
+            name="%propertyPagePHPProject.name"
+            class="net.sourceforge.phpeclipse.preferences.PHPProjectPropertyPage"
+            id="net.sourceforge.phpeclipse.preferences.PropertyPagePHPProject">
+         <filter
+               name="nature"
+               value="net.sourceforge.phpeclipse.phpnature">
+         </filter>
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            name="%viewPHPResources.name"
+            icon="icons/obj16/php.gif"
+            class="net.sourceforge.phpeclipse.resourcesview.PHPResourcesView"
+            id="net.sourceforge.phpeclipse.resourcesview.ViewPHPResources">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.actionDefinitions">
+      <actionDefinition
+            id="net.sourceforge.phpeclipse.phpeditor.comment">
+      </actionDefinition>
+      <actionDefinition
+            id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+      </actionDefinition>
+   </extension>
+   <extension
+         point="org.eclipse.ui.acceleratorSets">
+      <acceleratorSet
+            scopeId="org.eclipse.ui.textEditorScope"
+            configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
+         <accelerator
+               key="Ctrl+/"
+               id="net.sourceforge.phpeclipse.phpeditor.comment">
+         </accelerator>
+         <accelerator
+               key="Ctrl+\"
+               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+         </accelerator>
+      </acceleratorSet>
+   </extension>
    <extension
          point="org.eclipse.ui.actionSets">
       <actionSet
                id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
          </action>
       </actionSet>
+      <actionSet
+            label="%phpActionSet.label"
+            visible="false"
+            id="net.sourceforge.phpeclipse.phpeditor.actions.phpActionSet">
+         <menu
+               label="%php.menu.label"
+               path="edit"
+               id="net.sourceforge.phpeclipse.phpeditor.menu">
+            <separator
+                  name="editGroup">
+            </separator>
+         </menu>
+         <action
+               definitionId="net.sourceforge.phpeclipse.phpeditor.uncomment"
+               accelerator="Ctrl+Shift+\\"
+               label="%phpUncommentAction.label"
+               retarget="true"
+               menubarPath="net.sourceforge.phpeclipse.phpeditor.menu/editGroup"
+               id="net.sourceforge.phpeclipse.phpeditor.actions.Uncomment">
+         </action>
+         <action
+               definitionId="net.sourceforge.phpeclipse.phpeditor.comment"
+               accelerator="Ctrl+Shift+/"
+               label="%phpCommentAction.label"
+               retarget="true"
+               menubarPath="net.sourceforge.phpeclipse.phpeditor.menu/editGroup"
+               id="net.sourceforge.phpeclipse.phpeditor.actions.Comment">
+         </action>
+      </actionSet>
    </extension>
    <extension
          point="org.eclipse.ui.editors">
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="php"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
       </editor>
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="php3"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
       </editor>
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="php4"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
       </editor>
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="inc"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
             id="net.sourceforge.phpeclipse.PHPEditor">
-      </editor>   
+      </editor>
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="htm"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
             id="net.sourceforge.phpeclipse.PHPEditor">
-      </editor>   
+      </editor>
       <editor
             name="%phpEditorName"
-            icon="icons/obj16/php.gif"
+            icon="icons/obj16/phpedit.gif"
             extensions="html"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
             id="net.sourceforge.phpeclipse.PHPEditor">
-      </editor>   
+      </editor>
    </extension>
    <extension
          point="org.eclipse.ui.popupMenus">
-      
       <objectContribution
             objectClass="org.eclipse.core.resources.IFile"
             nameFilter="*.php"
                id="net.sourceforge.phpeclipse.actions.externalParserAction">
          </action>
       </objectContribution>
-      
       <objectContribution
             objectClass="org.eclipse.core.resources.IFile"
             nameFilter="*.php"
                id="net.sourceforge.phpeclipse.actions.showAction">
          </action>
       </objectContribution>
-      
       <viewerContribution
             targetID="#PHPEditorContext"
             id="net.sourceforge.phpeclipse.actions.popup.editor">
       </page>
       <page
             name="PHP Editor"
+            category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
             class="net.sourceforge.phpeclipse.PHPSyntaxPreferencePage"
-            id="net.sourceforge.phpeclipse.preference.PHPSyntaxPreferencePage"
-            category= "net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage">
+            id="net.sourceforge.phpeclipse.preference.PHPSyntaxPreferencePage">
       </page>
    </extension>
    <extension
       </view>
    </extension>
    <extension
-         point="org.eclipse.ui.newWizards">
-      <category
-            name="PHP"
-            id="net.sourceforge.phpeclipse.wizardCategory">
-      </category>
-      <wizard
-            name="PHP File"
-            icon="icons/obj16/java.gif"
-            category="net.sourceforge.phpeclipse.wizardCategory"
-            class="net.sourceforge.phpeclipse.wizards.PHPFileWizard"
-            id="net.sourceforge.phpeclipse.wizards.PHPFileWizard">
-      </wizard>
-   </extension>
-   <extension
          point="org.eclipse.help.toc">
       <toc
             file="phphelp.xml"
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/LoadPathEntry.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/LoadPathEntry.java
new file mode 100644 (file)
index 0000000..9008abf
--- /dev/null
@@ -0,0 +1,38 @@
+package net.sourceforge.phpeclipse;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+
+public class LoadPathEntry {
+       public static final String TYPE_PROJECT = "project";
+       
+       protected IProject project;
+       protected String type;
+
+       public LoadPathEntry(IProject aProjectEntry) {
+               project = aProjectEntry;
+               type = TYPE_PROJECT;
+       }
+
+       public IPath getPath() {
+               return project.getFullPath();
+       }
+       
+       public IProject getProject() {
+               return project;
+       }
+       
+       public String getType() {
+               return type;
+       }
+       
+       public String toXML() {
+               StringBuffer buffer = new StringBuffer();
+               
+               buffer.append("<pathentry type=\"");
+               buffer.append(type + "\" ");
+               buffer.append("path=\"" + getPath() + "\"/>");
+               
+               return buffer.toString();
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java
new file mode 100644 (file)
index 0000000..81943ac
--- /dev/null
@@ -0,0 +1,93 @@
+package net.sourceforge.phpeclipse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import net.sourceforge.phpeclipse.resourcesview.*;
+import net.sourceforge.phpeclipse.resourcesview.PHPFile;
+import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
+public class PHPCore {
+
+  public static IProject[] getPHPProjects() {
+    List phpProjectsList = new ArrayList();
+    IProject[] workspaceProjects = PHPeclipsePlugin.getDefault().getWorkspace().getRoot().getProjects();
+
+    for (int i = 0; i < workspaceProjects.length; i++) {
+      IProject iProject = workspaceProjects[i];
+      if (isPHPProject(iProject))
+        phpProjectsList.add(iProject);
+    }
+
+    IProject[] phpProjects = new IProject[phpProjectsList.size()];
+    return (IProject[]) phpProjectsList.toArray(phpProjects); 
+  }
+
+  public static PHPProject getPHPProject(String name) {
+    IProject aProject = PHPeclipsePlugin.getDefault().getWorkspace().getRoot().getProject(name);
+    if (isPHPProject(aProject)) {
+      PHPProject thePHPProject = new PHPProject();
+      thePHPProject.setProject(aProject);
+      return thePHPProject;
+    }
+    return null;
+  }
+
+  public static boolean isPHPProject(IProject aProject) {
+    try {
+      return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
+    } catch (CoreException e) {
+    }
+
+    return false;
+  }
+
+  public static PHPFile create(IFile aFile) {
+    if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+    if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+    if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+    if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+    if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+    if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
+      return new PHPFile(aFile);
+
+    return null;
+  }
+
+  public static PHPProject create(IProject aProject) {
+    try {
+      if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
+        PHPProject project = new PHPProject();
+        project.setProject(aProject);
+        return project;
+      }
+    } catch (CoreException e) {
+      System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString());
+    }
+
+    return null; 
+  }
+
+  public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException {
+    if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
+      IProjectDescription description = project.getDescription();
+      String[] prevNatures = description.getNatureIds();
+      String[] newNatures = new String[prevNatures.length + 1];
+      System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+      newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
+      description.setNatureIds(newNatures);
+      project.setDescription(description, monitor);
+    }
+  }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
new file mode 100644 (file)
index 0000000..059485c
--- /dev/null
@@ -0,0 +1,44 @@
+
+package net.sourceforge.phpeclipse;
+
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+public class PHPPerspectiveFactory implements IPerspectiveFactory {
+
+       public PHPPerspectiveFactory() {
+               super();
+       }
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               
+               IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea", IPageLayout.LEFT, (float)0.25, editorArea);
+               phpResourcesArea.addView(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
+               
+               IFolderLayout consoleArea = layout.createFolder("consoleArea", IPageLayout.BOTTOM, (float)0.75, editorArea);
+               
+               consoleArea.addView(IPageLayout.ID_TASK_LIST);
+    consoleArea.addView(IDebugUIConstants.ID_CONSOLE_VIEW);
+    consoleArea.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+    
+    layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea);
+    
+               layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
+               
+               layout.addShowViewShortcut(IDebugUIConstants.ID_CONSOLE_VIEW);
+
+               layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
+    
+    // views - standard workbench
+    layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+    layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+    
+    // new actions - PHP project creation wizards
+    layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+    layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+       }
+
+}
index 9fce1a0..7c46c83 100644 (file)
@@ -16,12 +16,19 @@ import java.util.ResourceBundle;
 
 import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
+import net.sourceforge.phpeclipse.resourcesview.*;
+
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IPluginDescriptor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.swt.widgets.Shell;
@@ -47,8 +54,10 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
   /**
    * The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
    */
-  public static final String ID_PLUGIN = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
-
+  public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
+  public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature";
+  public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + ".resourcesview.ViewPHPResources"; //$NON-NLS-1$
   //The shared instance.
   private static PHPeclipsePlugin plugin;
   //Resource bundle.
@@ -188,7 +197,10 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
   //  public static void log(Throwable e) {
   //    log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$
   //  }
-
+  
+  public static void log(Throwable e) {
+    log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
+  }
   public static boolean isDebug() {
     return getDefault().isDebugging();
   }
@@ -262,4 +274,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     PreferenceConverter.setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT);
 
   }
+  
+    public void startup() throws CoreException {
+    super.startup();
+    IAdapterManager manager= Platform.getAdapterManager();
+    manager.registerAdapters(new PHPElementAdapterFactory(), PHPElement.class);
+    manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
+  }
 }
\ No newline at end of file
index 54a3038..6f35ce5 100644 (file)
@@ -30,6 +30,9 @@ import org.eclipse.ui.texteditor.TextEditorAction;
  */
 public class PHPActionContributor extends TextEditorActionContributor {
 
+  public static final String COMMENT = "net.sourceforge.phpeclipse.phpeditor.comment";
+  public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.uncomment";
+  
   protected RetargetTextEditorAction fContentAssistProposal;
   protected RetargetTextEditorAction fContentAssistTip;
   protected TextEditorAction fTogglePresentation;
@@ -77,6 +80,10 @@ public class PHPActionContributor extends TextEditorActionContributor {
     fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
     fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
 
+    IActionBars bars= getActionBars();    
+    bars.setGlobalActionHandler(COMMENT, getAction(editor, "Comment"));
+    bars.setGlobalActionHandler(UNCOMMENT, getAction(editor, "Uncomment"));
+    
     fTogglePresentation.setEditor(editor);
     fTogglePresentation.update();
 
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java
new file mode 100644 (file)
index 0000000..cc4f0c3
--- /dev/null
@@ -0,0 +1,21 @@
+package net.sourceforge.phpeclipse.phpeditor;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionGroup;
+
+public class PHPActionGroup extends ActionGroup {
+  protected PHPEditor editor;
+  protected String menuGroupId;
+
+  public PHPActionGroup(PHPEditor editor, String menuGroupId) {
+    this.editor = editor;
+    this.menuGroupId = menuGroupId;
+  }
+
+  public void fillContextMenu(IMenuManager menu) {
+    super.fillContextMenu(menu);
+
+    menu.add(editor.getAction("Comment"));
+    menu.add(editor.getAction("Uncomment"));
+  }
+}
index 2c19dd5..71ff3fb 100644 (file)
@@ -18,11 +18,13 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.help.IHelp;
 import org.eclipse.help.IHelpResource;
+import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
 import org.eclipse.jface.text.ITextSelection;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.util.IPropertyChangeListener;
@@ -32,6 +34,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.editors.text.TextEditor;
 import org.eclipse.ui.help.WorkbenchHelp;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.TextOperationAction;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 /**
@@ -39,6 +42,7 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
  */
 public class PHPEditor extends TextEditor {
 
+  protected PHPActionGroup actionGroup;
   /** The outline page */
   private PHPContentOutlinePage fOutlinePage;
 
@@ -69,6 +73,17 @@ public class PHPEditor extends TextEditor {
         "ContentAssistTip.",
         this,
         ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
+
+    Action action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX);
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
+    setAction("Comment", action);
+
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX);
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
+    setAction("Uncomment", action);
+
+    actionGroup = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+
   }
 
   /** The <code>JavaEditor</code> implementation of this 
@@ -135,8 +150,9 @@ public class PHPEditor extends TextEditor {
    */
   public void editorContextMenuAboutToShow(MenuManager menu) {
     super.editorContextMenuAboutToShow(menu);
-    addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
-    addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+  //  addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
+  //  addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+    actionGroup.fillContextMenu(menu);
   }
 
   /** The <code>JavaEditor</code> implementation of this 
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorActionDefinitionIds.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorActionDefinitionIds.java
new file mode 100644 (file)
index 0000000..3239f9d
--- /dev/null
@@ -0,0 +1,12 @@
+package net.sourceforge.phpeclipse.phpeditor;
+
+public interface PHPEditorActionDefinitionIds {
+       /**
+        * Value: net.sourceforge.phpeclipse.phpeditor.comment\r  */
+       public static final String COMMENT= "net.sourceforge.phpeclipse.phpeditor.comment";
+
+       /**
+        * Value: net.sourceforge.phpeclipse.phpeditor.uncomment
+        */
+       public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.uncomment";
+}
index 05b94a6..87fb2bb 100644 (file)
@@ -17,6 +17,12 @@ ContentAssistTip.tooltip=Content Tip
 ContentAssistTip.image=
 ContentAssistTip.description=Content Tip
 
+Comment.label=Comment@Ctrl+/
+Comment.tooltip=Comment selected lines
+
+Uncomment.label=Uncomment@Ctrl+\
+Uncomment.tooltip=Uncomment selected lines
+
 TogglePresentation.label=Change Presentation
 TogglePresentation.tooltip=Enable/Disable Segmented Source Viewer
 TogglePresentation.image=togglepresentation.gif
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java
new file mode 100644 (file)
index 0000000..dfda1e6
--- /dev/null
@@ -0,0 +1,36 @@
+package net.sourceforge.phpeclipse.preferences;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class PHPPreferencesMessages {
+
+
+  private static final String RESOURCE_BUNDLE= "net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages";//$NON-NLS-1$
+
+       private static ResourceBundle resourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+       private PHPPreferencesMessages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return resourceBundle.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+       
+       public static String getFormattedString(String key, String arg) {
+               return getFormattedString(key, new String[] { arg });
+       }
+       
+       public static String getFormattedString(String key, String[] args) {
+               return MessageFormat.format(getString(key), args);      
+       }
+       
+       public static ResourceBundle getResourceBundle() {
+               return resourceBundle;
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties
new file mode 100644 (file)
index 0000000..2b558f0
--- /dev/null
@@ -0,0 +1,18 @@
+#########################################
+# PHPProjectLibraryPage
+#########################################
+
+PHPProjectLibraryPage.elementNotIProject=ERROR: Element not IProject
+PHPProjectLibraryPage.project=Project
+PHPProjectLibraryPage.tabName=Projects
+
+
+#########################################
+# Property Pages
+#########################################
+
+PHPProjectPropertyPage.phpProjectClosed=The project selected is a PHP project, but is closed.
+PHPProjectPropertyPage.performOkExceptionDialogTitle=Unable to save
+PHPProjectPropertyPage.performOkExceptionDialogMessage=ERROR: Unable to save project properties.
+
+
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java
new file mode 100644 (file)
index 0000000..98d1cff
--- /dev/null
@@ -0,0 +1,147 @@
+package net.sourceforge.phpeclipse.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbench; 
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.resourcesview.PHPProject; 
+
+public class PHPProjectLibraryPage {
+       protected PHPProject workingProject;
+
+       protected PHPProjectLibraryPage(PHPProject theWorkingProject) {
+               super();
+               workingProject = theWorkingProject;
+       }
+
+       protected Control getControl(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new FillLayout());
+
+               Table projectsTable = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+               projectsTable.setHeaderVisible(false);
+               projectsTable.setLinesVisible(false);
+               projectsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+               TableColumn tableColumn = new TableColumn(projectsTable, SWT.NONE);
+               tableColumn.setWidth(200);
+               tableColumn.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.project")); //$NON-NLS-1$
+
+               CheckboxTableViewer projectsTableViewer = new CheckboxTableViewer(projectsTable);
+               projectsTableViewer.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               projectCheckedUnchecked(event);
+                       }
+               });
+
+               projectsTableViewer.setContentProvider(getContentProvider());
+               projectsTableViewer.setLabelProvider(getLabelProvider());
+
+               projectsTableViewer.setInput(getWorkspaceProjects());
+               projectsTableViewer.setCheckedElements(workingProject.getReferencedProjects().toArray());
+
+               return composite;
+       }
+
+       protected void projectCheckedUnchecked(CheckStateChangedEvent event) {
+               IProject checkEventProject = (IProject) event.getElement();
+               if (event.getChecked())
+                       getWorkingProject().addLoadPathEntry(checkEventProject);
+               else
+                       getWorkingProject().removeLoadPathEntry(checkEventProject);
+       }
+
+       protected PHPProject getWorkingProject() {
+               return workingProject;
+       }
+
+       protected List getWorkspaceProjects() {
+               IWorkspaceRoot root = PHPeclipsePlugin.getWorkspace().getRoot();
+               return Arrays.asList(root.getProjects());
+       }
+
+       protected ITableLabelProvider getLabelProvider() {
+               ITableLabelProvider labelProvider = new ITableLabelProvider() {
+                       public Image getColumnImage(Object element, int columnIndex) {
+                               IWorkbench workbench= PHPeclipsePlugin.getDefault().getWorkbench();
+                               return workbench.getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
+                       }
+
+                       public String getColumnText(Object element, int columnIndex) {
+                               if (element instanceof IProject)
+                                       return ((IProject) element).getName();
+
+                               return PHPPreferencesMessages.getString("PHPProjectLibraryPage.elementNotIProject"); //$NON-NLS-1$
+                       }
+
+                       public void addListener(ILabelProviderListener listener) {}
+
+                       public void dispose() {}
+
+                       public boolean isLabelProperty(Object element, String property) {
+                               return false;
+                       }
+
+                       public void removeListener(ILabelProviderListener listener) {}
+               };
+
+               return labelProvider;
+       }
+
+       protected IContentProvider getContentProvider() {
+               IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
+                       protected List phpProjects;
+
+                       public Object[] getElements(Object inputElement) {
+                               return phpProjects.toArray();
+                       }
+
+                       public void dispose() {}
+
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                               phpProjects = new ArrayList();
+
+                               if (!(newInput instanceof List))
+                                       return;
+
+                               Iterator workspaceProjectsIterator = ((List) newInput).iterator();
+                               while (workspaceProjectsIterator.hasNext()) {
+                                       Object anObject = workspaceProjectsIterator.next();
+                                       if (anObject instanceof IProject) {
+                                               IProject project = (IProject) anObject;
+                                               if (project.getName() != workingProject.getProject().getName()) {
+                                                       try {
+                                                               if (project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID))
+                                                                       phpProjects.add(project);
+                                                       } catch (CoreException e) {}
+                                               }
+                                       }
+                               }
+                       }
+               };
+
+               return contentProvider;
+       }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java
new file mode 100644 (file)
index 0000000..fa07e17
--- /dev/null
@@ -0,0 +1,97 @@
+package net.sourceforge.phpeclipse.preferences;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class PHPProjectPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
+       protected PHPProjectLibraryPage projectsPage;
+       protected PHPProject workingProject;
+       
+       public PHPProjectPropertyPage() {
+       }
+
+       protected Control createContents(Composite parent)  {
+               noDefaultAndApplyButton();
+
+               workingProject = getPHPProject();
+               if (workingProject == null || !workingProject.getProject().isOpen())
+                       return createClosedProjectPageContents(parent);
+
+               return createProjectPageContents(parent);
+       }
+       
+       protected PHPProject getPHPProject() {
+               IAdaptable selectedElement = getElement();
+               if (selectedElement == null)
+                       return null;
+
+               if (selectedElement instanceof PHPProject)
+                       return (PHPProject) selectedElement;
+                       
+               if (selectedElement instanceof IProject) {
+                       IProject simpleProject = (IProject) selectedElement;
+                       try {
+                               if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
+                                       PHPProject phpProject = new PHPProject();
+                                       phpProject.setProject(simpleProject);
+                                       return phpProject;
+                               }
+                       } catch(CoreException e) {
+                               PHPeclipsePlugin.log(e);
+                       }
+               }
+               
+               return null;
+       }
+       
+       protected Control createClosedProjectPageContents(Composite parent) {
+               Label label = new Label(parent, SWT.NONE);
+               label.setText(PHPPreferencesMessages.getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$
+               
+               return label;
+       }
+       
+       protected Control createProjectPageContents(Composite parent) {
+               TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+               tabFolder.setLayout(new GridLayout());  
+               tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+               tabFolder.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               //tabChanged(e.item);
+                       }       
+               });
+
+               projectsPage = new PHPProjectLibraryPage(workingProject);               
+               TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+               tabItem.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$
+//             tabItem.setData(projectsPage);
+               tabItem.setControl(projectsPage.getControl(tabFolder));
+
+               return tabFolder;
+       }
+       public boolean performOk() {
+               try {
+                       projectsPage.getWorkingProject().save();
+               } catch (CoreException e) {
+      PHPeclipsePlugin.log(e);
+               }
+               return super.performOk();
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/MainActionGroup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/MainActionGroup.java
new file mode 100644 (file)
index 0000000..3ad7a7b
--- /dev/null
@@ -0,0 +1,150 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.RefreshAction;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.views.framelist.FrameList;
+import org.eclipse.ui.views.navigator.IResourceNavigator;
+import org.eclipse.ui.views.navigator.OpenActionGroup;
+import org.eclipse.ui.views.navigator.RefactorActionGroup;
+import org.eclipse.ui.views.navigator.ResourcePatternFilter;
+import org.eclipse.ui.views.navigator.ResourceSorter;
+
+public class MainActionGroup extends ActionGroup {
+
+       private OpenActionGroup openActionGroup;
+       private RefactorActionGroup refactorActionGroup;
+       private PropertyDialogAction propertyDialogAction ;
+       private RefreshAction refreshAction ;
+
+       public MainActionGroup(PHPResourcesView phpResourcesView) {
+               ResourceNavigatorAdapter adapter = new ResourceNavigatorAdapter(phpResourcesView) ;
+               this.openActionGroup = new OpenActionGroup(adapter);
+               this.refactorActionGroup = new RefactorActionGroup(adapter);
+               Shell shell = phpResourcesView.getSite().getShell();
+               propertyDialogAction = new PropertyDialogAction(shell, phpResourcesView.getViewer());
+               refreshAction = new RefreshAction(shell) ;
+       }
+
+       public void fillContextMenu(IMenuManager menu) {
+               this.openActionGroup.fillContextMenu(menu);
+               menu.add(new Separator());
+               this.refactorActionGroup.fillContextMenu(menu);
+               menu.add(new Separator());
+               menu.add(refreshAction) ;               
+               menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+               menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$ 
+               menu.add(propertyDialogAction) ;
+
+       }
+
+       public void setContext(ActionContext actionContext) {
+               this.openActionGroup.setContext(actionContext);
+               this.refactorActionGroup.setContext(actionContext);
+       }
+
+       public void runDefaultAction(IStructuredSelection selection) {
+               this.openActionGroup.runDefaultAction(selection);
+       }
+
+       class ResourceNavigatorAdapter implements IResourceNavigator {
+               PHPResourcesView phpResourcesView;
+               ResourceNavigatorAdapter(PHPResourcesView phpResourcesView) {
+                       this.phpResourcesView = phpResourcesView;
+               }
+
+               public FrameList getFrameList() {
+                       return null;
+               }
+
+               public ResourcePatternFilter getPatternFilter() {
+                       return null;
+               }
+
+               public ResourceSorter getSorter() {
+                       return null;
+               }
+
+               public TreeViewer getViewer() {
+                       return phpResourcesView.getViewer();
+               }
+
+               public IWorkingSet getWorkingSet() {
+                       return null;
+               }
+
+               public void setFiltersPreference(String[] patterns) {
+               }
+
+               public void setSorter(ResourceSorter sorter) {
+               }
+
+               public void setWorkingSet(IWorkingSet workingSet) {
+               }
+
+               public IViewSite getViewSite() {
+                       return phpResourcesView.getViewSite();
+               }
+
+               public void init(IViewSite arg0, IMemento arg1) throws PartInitException {
+               }
+
+               public void init(IViewSite arg0) throws PartInitException {
+               }
+
+               public void saveState(IMemento arg0) {
+               }
+
+               public void addPropertyListener(IPropertyListener arg0) {
+               }
+
+               public void createPartControl(Composite arg0) {
+               }
+
+               public void dispose() {
+               }
+
+               public IWorkbenchPartSite getSite() {
+                       return phpResourcesView.getSite();
+               }
+
+               public String getTitle() {
+                       return phpResourcesView.getTitle();
+               }
+
+               public Image getTitleImage() {
+                       return phpResourcesView.getTitleImage();
+               }
+
+               public String getTitleToolTip() {
+                       return phpResourcesView.getTitleToolTip();
+               }
+
+               public void removePropertyListener(IPropertyListener arg0) {
+               }
+
+               public void setFocus() {
+               }
+
+               public Object getAdapter(Class arg0) {
+                       return phpResourcesView.getAdapter(arg0);
+               }
+
+       }
+
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElement.java
new file mode 100644 (file)
index 0000000..d04eca9
--- /dev/null
@@ -0,0 +1,7 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.core.resources.IResource;
+
+public interface PHPElement {
+       public IResource getUnderlyingResource();
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElementAdapterFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPElementAdapterFactory.java
new file mode 100644 (file)
index 0000000..e921f2c
--- /dev/null
@@ -0,0 +1,32 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+public class PHPElementAdapterFactory implements IAdapterFactory {
+       
+       protected static Class[] ADAPTERS_I_CREATE = new Class[] {
+               IResource.class
+       };
+
+       public PHPElementAdapterFactory() {
+               super();
+       }
+
+       public Object getAdapter(Object adaptableObject, Class adapterType) {
+               PHPElement phpElement = (PHPElement) adaptableObject;
+               
+               if (IResource.class.equals(adapterType))
+                       return getResource(phpElement);
+
+               return null;
+       }
+
+       public Class[] getAdapterList() {
+               return ADAPTERS_I_CREATE;
+       }
+
+       protected IResource getResource(PHPElement phpElement) {
+               return phpElement.getUnderlyingResource();
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPFile.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPFile.java
new file mode 100644 (file)
index 0000000..fb36859
--- /dev/null
@@ -0,0 +1,28 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Represents an entire PHP (<code>.php</code> source file).
+ */
+public class PHPFile implements PHPElement {
+       public static final String EXTENSION = "php";
+  public static final String EXTENSION1 = "php3";
+  public static final String EXTENSION2 = "php4";
+  public static final String EXTENSION3 = "inc";
+  public static final String EXTENSION4 = "html";
+  public static final String EXTENSION5 = "htm";
+
+       protected IFile underlyingFile;
+
+       public PHPFile(IFile theUnderlyingFile) {
+               super();
+               underlyingFile = theUnderlyingFile;
+       }
+
+       public IResource getUnderlyingResource() {
+               return underlyingFile;
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPProject.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPProject.java
new file mode 100644 (file)
index 0000000..859733a
--- /dev/null
@@ -0,0 +1,176 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import net.sourceforge.phpeclipse.LoadPathEntry;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+public class PHPProject implements IProjectNature, PHPElement {
+       protected IProject project;
+       protected List loadPathEntries;
+       protected boolean scratched;
+
+       public PHPProject() {}
+
+       public void configure() throws CoreException {}
+
+       public void deconfigure() throws CoreException {}
+
+       public IProject getProject() {
+               return project;
+       }
+
+       protected IProject getProject(String name) {
+               return PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
+       }
+
+       public void setProject(IProject aProject) {
+               project = 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) {
+                       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
+               }
+       }
+
+       protected ContentHandler getLoadPathEntriesContentHandler() {
+               return new ContentHandler() {
+                       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 endPrefixMapping(String arg0) throws SAXException {}
+
+                       public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {}
+
+                       public void processingInstruction(String arg0, String arg1) throws SAXException {}
+
+                       public void setDocumentLocator(Locator arg0) {}
+
+                       public void skippedEntity(String arg0) throws SAXException {}
+
+                       public void startDocument() 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));
+                                       }
+                       }
+
+                       public void startPrefixMapping(String arg0, String arg1) throws SAXException {}
+               };
+       }
+
+       protected IFile getLoadPathEntriesFile() {
+               return project.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();
+
+               while (pathEntriesIterator.hasNext()) {
+                       LoadPathEntry entry = (LoadPathEntry) pathEntriesIterator.next();
+                       buffer.append(entry.toXML());
+               }
+
+               buffer.append("</loadpath>");
+               return buffer.toString();
+       }
+       public IResource getUnderlyingResource() {
+               return project;
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPResourcesView.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPResourcesView.java
new file mode 100644 (file)
index 0000000..1e95b5a
--- /dev/null
@@ -0,0 +1,116 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.ui.part.ViewPart;
+
+public class PHPResourcesView extends ViewPart implements ISetSelectionTarget, IMenuListener {
+  protected TreeViewer viewer;
+  protected MainActionGroup mainActionGroup;
+
+  public PHPResourcesView() {
+
+  }
+
+  public void createPartControl(Composite parent) {
+    this.setViewer(new TreeViewer(parent));
+
+    this.getViewer().addFilter(new PHPViewerFilter());
+    this.getViewer().setContentProvider(new WorkbenchContentProvider());
+    this.getViewer().setLabelProvider(new WorkbenchLabelProvider());
+    this.getViewer().setInput(getInitialInput());
+
+    this.getViewer().addOpenListener(new IOpenListener() {
+      public void open(OpenEvent event) {
+        getMainActionGroup().runDefaultAction((IStructuredSelection) event.getSelection());
+      }
+    });
+
+    MenuManager menuMgr = new MenuManager("net.sourceforge.phpeclipse.PHPPopupMenu"); //$NON-NLS-1$
+    menuMgr.setRemoveAllWhenShown(true);
+    menuMgr.addMenuListener(this);
+
+    Menu fContextMenu = menuMgr.createContextMenu(this.getViewer().getTree());
+    this.getViewer().getTree().setMenu(fContextMenu);
+
+    // Register viewer with site. This must be done before making the actions.
+    IWorkbenchPartSite site = getSite();
+    site.registerContextMenu(menuMgr, viewer);
+  }
+
+  public void selectReveal(ISelection selection) {
+    viewer.setSelection(selection, true);
+  }
+
+  protected IContainer getInitialInput() {
+    IAdaptable input = getSite().getPage().getInput();
+    IResource resource = null;
+    if (input instanceof IResource) {
+      resource = (IResource) input;
+    } else {
+      resource = (IResource) input.getAdapter(IResource.class);
+    }
+    if (resource != null) {
+      switch (resource.getType()) {
+        case IResource.FILE :
+          return resource.getParent();
+        case IResource.FOLDER :
+        case IResource.PROJECT :
+        case IResource.ROOT :
+          return (IContainer) resource;
+        default :
+          break;
+      }
+    }
+    return PHPeclipsePlugin.getWorkspace().getRoot();
+  }
+
+  public void setFocus() {
+    this.getViewer().getControl().setFocus();
+  }
+
+  public void menuAboutToShow(IMenuManager manager) {
+    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+    this.getMainActionGroup().setContext(new ActionContext(selection));
+    this.getMainActionGroup().fillContextMenu(manager);
+    this.getMainActionGroup().setContext(null);
+  }
+
+  public MainActionGroup getMainActionGroup() {
+    if (mainActionGroup == null) {
+      // lazy initialization, because this.getSite() delivers null in constructor
+      mainActionGroup = new MainActionGroup(this);
+    }
+    return mainActionGroup;
+  }
+
+  public void setMainActionGroup(MainActionGroup mainActionGroup) {
+    this.mainActionGroup = mainActionGroup;
+  }
+
+  public TreeViewer getViewer() {
+    return viewer;
+  }
+
+  protected void setViewer(TreeViewer viewer) {
+    this.viewer = viewer;
+  }
+
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPViewerFilter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/PHPViewerFilter.java
new file mode 100644 (file)
index 0000000..c8c9759
--- /dev/null
@@ -0,0 +1,25 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class PHPViewerFilter extends ViewerFilter {
+
+       public PHPViewerFilter() {
+               super();
+       }
+
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (element instanceof IFolder)
+                       return true;
+
+               IAdaptable adaptable = (IAdaptable) element;
+               PHPElement phpElement = (PHPElement) adaptable.getAdapter(PHPElement.class);
+               if (phpElement != null)
+                       return true;
+
+               return false;
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/ResourceAdapterFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/resourcesview/ResourceAdapterFactory.java
new file mode 100644 (file)
index 0000000..1cc64d2
--- /dev/null
@@ -0,0 +1,42 @@
+package net.sourceforge.phpeclipse.resourcesview;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+import net.sourceforge.phpeclipse.PHPCore;
+import net.sourceforge.phpeclipse.resourcesview.PHPElement;
+import net.sourceforge.phpeclipse.resourcesview.PHPFile;
+import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
+public class ResourceAdapterFactory implements IAdapterFactory {
+
+       protected static Class[] ADAPTERS_I_CREATE = new Class[] { PHPElement.class, PHPFile.class, PHPProject.class };
+
+       public ResourceAdapterFactory() {
+               super();
+       }
+
+       public Object getAdapter(Object adaptableObject, Class adapterType) {
+               if (PHPFile.class.equals(adapterType))
+                       return PHPCore.create((IFile) adaptableObject);
+
+               if (PHPProject.class.equals(adapterType))
+                       return PHPCore.create((IProject) adaptableObject);
+
+               if (PHPElement.class.equals(adapterType)) {
+                       if (adaptableObject instanceof IFile)
+                               return PHPCore.create((IFile) adaptableObject);
+
+                       if (adaptableObject instanceof IProject)
+                               return PHPCore.create((IProject) adaptableObject);
+               }
+
+               return null;
+       }
+
+       public Class[] getAdapterList() {
+               return ADAPTERS_I_CREATE;
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java
new file mode 100644 (file)
index 0000000..d5ee680
--- /dev/null
@@ -0,0 +1,99 @@
+package net.sourceforge.phpeclipse.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.PHPCore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+public class NewProjectCreationWizard extends BasicNewResourceWizard implements INewWizard, IExecutableExtension {
+       protected WizardNewProjectCreationPage projectPage;
+       protected IConfigurationElement configurationElement;
+       protected IProject newProject;
+       
+       public NewProjectCreationWizard() {
+               setWindowTitle(PHPWizardMessages.getString("NewProjectCreationWizard.windowTitle"));
+       }
+
+       public boolean performFinish() {
+               IRunnableWithProgress projectCreationOperation = new WorkspaceModifyDelegatingOperation(getProjectCreationRunnable());
+
+               try {
+                       getContainer().run(false, true, projectCreationOperation);
+               } catch (Exception e) { 
+                       PHPeclipsePlugin.log(e);
+                       return false;
+               }
+
+               BasicNewProjectResourceWizard.updatePerspective(configurationElement);
+               selectAndReveal(newProject);
+
+               return true;
+       }
+
+       protected IRunnableWithProgress getProjectCreationRunnable() {
+               return new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               int remainingWorkUnits = 10;
+                               monitor.beginTask(PHPWizardMessages.getString("NewProjectCreationWizard.projectCreationMessage"), remainingWorkUnits);
+
+                               IWorkspace workspace = PHPeclipsePlugin.getWorkspace();
+                               newProject = projectPage.getProjectHandle();
+                               
+                               IProjectDescription description = workspace.newProjectDescription(newProject.getName());
+                               IPath path = Platform.getLocation();
+                               IPath customPath = projectPage.getLocationPath();
+                               if (!path.equals(customPath)) {
+                                       path = customPath;
+                                       description.setLocation(path);
+                               }
+
+                               try {
+                                       if (!newProject.exists()) {
+                                               newProject.create(description, new SubProgressMonitor(monitor, 1));
+                                               remainingWorkUnits--;
+                                       }
+                                       if (!newProject.isOpen()) {
+                                               newProject.open(new SubProgressMonitor(monitor, 1));
+                                               remainingWorkUnits--;
+                                       }
+                                       PHPCore.addPHPNature(newProject, new SubProgressMonitor(monitor, remainingWorkUnits));
+                               } catch (CoreException e) {
+                                       throw new InvocationTargetException(e);
+                               } finally {
+                                       monitor.done();
+                               }
+                       }
+               };
+       }
+
+       public void addPages() {
+               super.addPages();
+
+               projectPage = new WizardNewProjectCreationPage(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageName"));
+               projectPage.setTitle(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageTitle"));
+               projectPage.setDescription(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageDescription"));
+
+               addPage(projectPage);
+       }
+
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+               configurationElement = config;
+       }
+
+}
\ No newline at end of file
index 23c9370..33e0dda 100644 (file)
@@ -18,4 +18,11 @@ WizardPage.selectNewFileContainer=Select new file container.
 Wizard.error=An error occured
 Wizard.Monitor.creating=Creating 
 Wizard.Monitor.openingFile=Opening file for editing...
-Wizard.Monitor.containerDoesNotExistException=The given container does not exist.
\ No newline at end of file
+Wizard.Monitor.containerDoesNotExistException=The given container does not exist.
+
+NewProjectCreationWizard.windowTitle=New
+NewProjectCreationWizard.projectCreationMessage=Creating new PHP Project
+
+WizardNewProjectCreationPage.pageName=Create PHP Project
+WizardNewProjectCreationPage.pageTitle=PHP Project
+WizardNewProjectCreationPage.pageDescription=Create a new PHP Project
\ No newline at end of file