1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixed NPE.

This commit is contained in:
Sergey Prigogin 2009-05-07 07:08:49 +00:00
parent 63d969e8fb
commit 973efe1f3e
2 changed files with 20 additions and 12 deletions

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -193,12 +194,15 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
public String getDefaultTemplateName() {
String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE);
if (name == null) {
String contentType = CProject.hasCCNature(getCurrentProject()) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
Template[] templates =
StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
IProject project = getCurrentProject();
if (project != null) {
String contentType = CProject.hasCCNature(project) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
Template[] templates =
StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
}
}
}
return name;

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.ui.wizards.filewizard;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -194,12 +195,15 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
public String getDefaultTemplateName() {
String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE);
if (name == null) {
String contentType = CProject.hasCCNature(getCurrentProject()) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
Template[] templates =
StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
IProject project = getCurrentProject();
if (project != null) {
String contentType = CProject.hasCCNature(project) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
Template[] templates =
StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
}
}
}
return name;