1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +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.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -193,7 +194,9 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
public String getDefaultTemplateName() { public String getDefaultTemplateName() {
String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE); String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE);
if (name == null) { if (name == null) {
String contentType = CProject.hasCCNature(getCurrentProject()) ? IProject project = getCurrentProject();
if (project != null) {
String contentType = CProject.hasCCNature(project) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
Template[] templates = Template[] templates =
StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null); StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
@ -201,6 +204,7 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
name = templates[0].getName(); name = templates[0].getName();
} }
} }
}
return name; return name;
} }

View file

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