deleted dependency from net.sourceforge.phpeclipse module
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / builder / AddBuilderAction.java
index ef06dc8..1ebbf1b 100644 (file)
@@ -1,14 +1,17 @@
 package net.sourceforge.phpeclipse.wiki.builder;
 
+import java.io.InputStream;
 import java.util.Iterator;
 
 import net.sourceforge.phpeclipse.wiki.preferences.Util;
 
 import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
@@ -68,7 +71,7 @@ public class AddBuilderAction implements IObjectActionDelegate {
   public void selectionChanged(IAction action, ISelection selection) {
   }
 
-  private void addBuilder(IProject project) {
+  public static void addBuilder(IProject project) {
     IProjectDescription desc;
     try {
       desc = project.getDescription();
@@ -94,11 +97,22 @@ public class AddBuilderAction implements IObjectActionDelegate {
         desc.setBuildSpec(newCommands);
         project.setDescription(desc, null);
         // add some default wiki project settings
-        Util.setWikiTextsPath(project);
+        Util.setWikiBuilderPreferences(project);
 
+        createVelocityFile(project, "main.vm");
+        createVelocityFile(project, "export.vm");
+        createVelocityFile(project, "main.css");
       }
     } catch (CoreException e) {
       e.printStackTrace();
     }
   }
+
+  private static void createVelocityFile(IProject project, String filename) throws CoreException {
+    InputStream is = AddBuilderAction.class.getResourceAsStream(filename);
+    final IFile file = project.getFile(new Path("wpsrc/" + filename));
+    if (!file.exists()) {
+      file.create(is, true, null);
+    }
+  }
 }
\ No newline at end of file