Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornitind2010-08-17 02:17:03 +0000
committernitind2010-08-17 02:17:03 +0000
commit6b9e59dc404b5f171963f38a163ee382be86ef74 (patch)
tree2fd56985582194cbbcf85fa2239081f5ce485623
parent8c333a56ff8e813a9e64fad78cb218e2ba75a90a (diff)
downloadwebtools.jsdt.core-6b9e59dc404b5f171963f38a163ee382be86ef74.tar.gz
webtools.jsdt.core-6b9e59dc404b5f171963f38a163ee382be86ef74.tar.xz
webtools.jsdt.core-6b9e59dc404b5f171963f38a163ee382be86ef74.zip
[268125] [preferences] Comment templates are ignored when creating new file
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java23
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java5
2 files changed, 23 insertions, 5 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java
index 32f09a61..1501c043 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSFileWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* 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
@@ -15,17 +15,25 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
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.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.internal.corext.codemanipulation.StubUtility;
+import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
+import org.eclipse.wst.jsdt.ui.CodeGeneration;
class NewJSFileWizardPage extends WizardNewFileCreationPage {
@@ -252,6 +260,15 @@ path.append("/"); //$NON-NLS-1$
return path;
}
-
-
+
+ public void addFileComment(IFile file) {
+ IJavaScriptUnit cu= JavaScriptCore.createCompilationUnitFrom(file);
+ try {
+ cu.becomeWorkingCopy(new NullProgressMonitor());
+ cu.getBuffer().setContents(CodeGeneration.getFileComment(cu, StubUtility.getLineDelimiterUsed(cu)));
+ cu.commitWorkingCopy(true, new NullProgressMonitor());
+ } catch (CoreException e) {
+ JavaScriptPlugin.log(e);
+ }
+ }
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java
index 074398db..a5732dc0 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/wizards/NewJSWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* 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
@@ -71,7 +71,8 @@ public class NewJSWizard extends Wizard implements INewWizard {
// create a new empty file
IFile file = fNewFilePage.createNewFile();
-
+ // add comment to created file
+ fNewFilePage.addFileComment(file);
// if there was problem with creating file, it will be null, so make
// sure to check
if (file != null) {

Back to the top