diff options
author | kraev | 2010-06-22 08:04:20 +0000 |
---|---|---|
committer | kraev | 2010-06-22 08:04:20 +0000 |
commit | f14c0fe6aeb55cc174632896c9183a00da964e53 (patch) | |
tree | f316cf026967aefd15ed351b21911b0e11c3ff72 /plugins | |
parent | 99ad471116601bd2e8d3dec5ab44ff34fb945e10 (diff) | |
download | webtools.javaee-f14c0fe6aeb55cc174632896c9183a00da964e53.tar.gz webtools.javaee-f14c0fe6aeb55cc174632896c9183a00da964e53.tar.xz webtools.javaee-f14c0fe6aeb55cc174632896c9183a00da964e53.zip |
[312449] 2 NPEs on new Servlet Wizard -> Browse for existing class
Diffstat (limited to 'plugins')
2 files changed, 44 insertions, 35 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java index 189ca3605..54e84c0bd 100644 --- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java +++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java @@ -92,8 +92,8 @@ public abstract class NewWebClassDataModelProvider extends NewJavaClassDataModel */ protected List interfaceList; - private String classNameCache; - private String existingClassNameCache; + private String classNameCache = ""; //$NON-NLS-1$ + private String existingClassNameCache = ""; //$NON-NLS-1$ private static boolean useAnnotations = false; diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java index daca4542d..d6b3809ff 100644 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java +++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java @@ -73,43 +73,52 @@ public class NewServletClassWizardPage extends NewWebClassWizardPage { @Override protected void handleClassButtonSelected() { getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IProject project = (IProject) model.getProperty(PROJECT); - IVirtualComponent component = ComponentCore.createComponent(project); - MultiSelectFilteredFileSelectionDialog ms = new MultiSelectFilteredFileSelectionDialog( - getShell(), - NEW_SERVLET_WIZARD_WINDOW_TITLE, - CHOOSE_SERVLET_CLASS, - JSPEXTENSIONS, - false, - project); - IContainer root = component.getRootFolder().getUnderlyingFolder(); - ms.setInput(root); - ms.open(); - if (ms.getReturnCode() == Window.OK) { - String qualifiedClassName = ""; //$NON-NLS-1$ - if (ms.getSelectedItem() == MultiSelectFilteredFileSelectionDialog.JSP) { - Object obj = ms.getFirstResult(); - if (obj != null) { - if (obj instanceof IFile) { - IFile file = (IFile) obj; - IPath pFull = file.getFullPath(); - IPath pBase = root.getFullPath(); - IPath path = pFull.removeFirstSegments(pBase.segmentCount()); - qualifiedClassName = path.makeAbsolute().toString(); - model.setProperty(IS_SERVLET_TYPE, new Boolean(false)); + try { + IProject project = (IProject) model.getProperty(PROJECT); + + if (project == null) { + // show info message + return; + } + + IVirtualComponent component = ComponentCore.createComponent(project); + MultiSelectFilteredFileSelectionDialog ms = new MultiSelectFilteredFileSelectionDialog( + getShell(), + NEW_SERVLET_WIZARD_WINDOW_TITLE, + CHOOSE_SERVLET_CLASS, + JSPEXTENSIONS, + false, + project); + IContainer root = component.getRootFolder().getUnderlyingFolder(); + ms.setInput(root); + ms.open(); + if (ms.getReturnCode() == Window.OK) { + String qualifiedClassName = ""; //$NON-NLS-1$ + if (ms.getSelectedItem() == MultiSelectFilteredFileSelectionDialog.JSP) { + Object obj = ms.getFirstResult(); + if (obj != null) { + if (obj instanceof IFile) { + IFile file = (IFile) obj; + IPath pFull = file.getFullPath(); + IPath pBase = root.getFullPath(); + IPath path = pFull.removeFirstSegments(pBase.segmentCount()); + qualifiedClassName = path.makeAbsolute().toString(); + model.setProperty(IS_SERVLET_TYPE, new Boolean(false)); + } + } + } + else { + IType type = (IType) ms.getFirstResult(); + if (type != null) { + qualifiedClassName = type.getFullyQualifiedName(); + model.setProperty(IS_SERVLET_TYPE, new Boolean(true)); } } - } - else { - IType type = (IType) ms.getFirstResult(); - if (type != null) { - qualifiedClassName = type.getFullyQualifiedName(); - model.setProperty(IS_SERVLET_TYPE, new Boolean(true)); - } + existingClassText.setText(qualifiedClassName); } - existingClassText.setText(qualifiedClassName); + } finally { + getControl().setCursor(null); } - getControl().setCursor(null); } @Override |