*** empty log message ***
diff --git a/bundles/org.eclipse.wst.xsl.ui/plugin.xml b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
index 47d32c0..cac4584 100644
--- a/bundles/org.eclipse.wst.xsl.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
@@ -347,6 +347,12 @@
</enabledWhen>
</page>
</extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.wst.xsl.ui.internal.PreferenceInitializer">
+ </initializer>
+ </extension>
<!-- extension
point="org.eclipse.wst.sse.ui.quickFixProcessor">
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/PreferenceInitializer.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/PreferenceInitializer.java
new file mode 100644
index 0000000..733d7e4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/PreferenceInitializer.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Chase Technology Ltd - http://www.chasetechnology.co.uk
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Doug Satchwell (Chase Technology Ltd) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.internal;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+
+public class PreferenceInitializer extends AbstractPreferenceInitializer
+{
+ @Override
+ public void initializeDefaultPreferences()
+ {
+ IEclipsePreferences node = new DefaultScope().getNode(XSLUIPlugin.getDefault().getBundle().getSymbolicName());
+ node.put(XSLUIConstants.NEW_FILE_TEMPLATE_NAME, "org.eclipse.wst.xslt.templates.xsl_basic"); // default to the basic stylesheet
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizard.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizard.java
index 2261b88..803e520 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizard.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizard.java
@@ -15,6 +15,7 @@
import java.io.OutputStreamWriter;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -34,11 +35,17 @@
private NewXSLFileWizardPage fNewFilePage;
private NewXSLFileTemplatesWizardPage fNewFileTemplatesPage;
private IStructuredSelection fSelection;
+ private IWorkbench workbench;
@Override
public void addPages()
{
- fNewFilePage = new NewXSLFileWizardPage("NewFileCreationPage", new StructuredSelection(IDE.computeSelectedResources(fSelection))); //$NON-NLS-1$
+ IStructuredSelection ssel = new StructuredSelection(IDE.computeSelectedResources(fSelection));
+ // if no selection, then just select the first project we come across
+ if (ssel.isEmpty())
+ ssel = new StructuredSelection(ResourcesPlugin.getWorkspace().getRoot().getProjects()[0]);
+
+ fNewFilePage = new NewXSLFileWizardPage("NewFileCreationPage", ssel); //$NON-NLS-1$
fNewFilePage.setTitle("XSL Stylesheet");
fNewFilePage.setDescription("Create a new XSL Stylesheet.");
addPage(fNewFilePage);
@@ -49,6 +56,7 @@
public void init(IWorkbench aWorkbench, IStructuredSelection aSelection)
{
+ this.workbench = aWorkbench;
fSelection = aSelection;
setWindowTitle("New XSL Stylesheet");
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizardPage.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizardPage.java
index 9024ddf..8b55be6 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizardPage.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/wizards/NewXSLFileWizardPage.java
@@ -14,6 +14,7 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -34,7 +35,30 @@
public NewXSLFileWizardPage(String pageName, IStructuredSelection selection)
{
super(pageName, selection);
- setFileName("NewFile.xsl");
+ // find an unused file name
+ setFileName(getUnusedFilename("NewStylesheet",selection));
+ }
+
+ private String getUnusedFilename(String prefix, IStructuredSelection selection)
+ {
+ String name = prefix+".xsl";
+ if (selection.isEmpty())
+ return name;
+ Object element = selection.getFirstElement();
+ if (element instanceof IContainer)
+ {
+ IContainer c = (IContainer)element;
+ int i=0;
+ do
+ {
+ if (c.findMember(name) == null)
+ return name;
+ i++;
+ name = prefix+i+".xsl";
+ }
+ while(true);
+ }
+ return null;
}
@Override
@@ -83,7 +107,7 @@
}
return true;
}
-
+
String addDefaultExtension(String filename)
{
StringBuffer newFileName = new StringBuffer(filename);