avoid weird NPE (EA-18265 - NPE: ComponentItemDialog.isOKEnabled); some cleanup
authorDmitry Jemerov <yole@jetbrains.com>
Fri, 20 Aug 2010 14:34:07 +0000 (18:34 +0400)
committerDmitry Jemerov <yole@jetbrains.com>
Fri, 20 Aug 2010 14:34:07 +0000 (18:34 +0400)
plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java

index 1437744be915acb10e0de95da9017406bd7612a5..567b306f412926efe8bfd6632d10861c4c44c06b 100644 (file)
@@ -322,17 +322,18 @@ public final class ComponentItemDialog extends DialogWrapper {
   private boolean isOKEnabled() {
     myErrorLabel.setText(" ");
     if (myClassRadioButton.isSelected()) {
-      final PsiManager psiManager = PsiManager.getInstance(myProject);
-      if (!JavaPsiFacade.getInstance(psiManager.getProject()).getNameHelper().isQualifiedName(myDocument.getText())) {
+      if (myDocument == null) {  // why?
+        return false;
+      }
+      final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(myProject);
+      if (!javaPsiFacade.getNameHelper().isQualifiedName(myDocument.getText())) {
         if (myDocument.getTextLength() > 0) {
           myErrorLabel.setText(UIDesignerBundle.message("add.component.error.qualified.name.required"));
         }
         return false;
       }
-      PsiClass psiClass =
-        JavaPsiFacade.getInstance(psiManager.getProject()).findClass(myDocument.getText(), ProjectScope.getAllScope(myProject));
-      PsiClass componentClass =
-        JavaPsiFacade.getInstance(psiManager.getProject()).findClass(JComponent.class.getName(), ProjectScope.getAllScope(myProject));
+      PsiClass psiClass = javaPsiFacade.findClass(myDocument.getText(), ProjectScope.getAllScope(myProject));
+      PsiClass componentClass = javaPsiFacade.findClass(JComponent.class.getName(), ProjectScope.getAllScope(myProject));
       if (psiClass != null && componentClass != null && !InheritanceUtil.isInheritorOrSelf(psiClass, componentClass, true)) {
         myErrorLabel.setText(UIDesignerBundle.message("add.component.error.component.required"));
         return false;