Package org.eclipse.wb.internal.core.utils.exception

Examples of org.eclipse.wb.internal.core.utils.exception.DesignerException


      ClassLoader classLoader = state.getClassLoader();
      // version
      {
        String description = getWrongVersionDescription(classLoader);
        if (description != null) {
          throw new DesignerException(IExceptionConstants.INCORRECT_VERSION,
              VALID_VERSIONS_STRING,
              description);
        }
      }
    }
View Full Code Here


    String templatePathString = templatePath.toPortableString();
    // package
    IPackageFragment uiPackage;
    {
      if (!(m_file.getParent() instanceof IFolder)) {
        throw new DesignerException(IExceptionConstants.NO_FORM_PACKAGE, templatePathString);
      }
      // prepare package
      IFolder uiFolder = (IFolder) m_file.getParent();
      IJavaElement uiElement = JavaCore.create(uiFolder);
      if (!(uiElement instanceof IPackageFragment)) {
        throw new DesignerException(IExceptionConstants.NO_FORM_PACKAGE, templatePathString);
      }
      uiPackage = (IPackageFragment) uiElement;
      // has client package
      if (!Utils.isModuleSourcePackage(uiPackage)) {
        throw new DesignerException(IExceptionConstants.NOT_CLIENT_PACKAGE, templatePathString);
      }
    }
    // binder resource
    m_binderResourceName = uiPackage.getElementName().replace('.', '/') + "/" + m_file.getName();
    // try current package
    {
      String formName = StringUtils.removeEnd(m_file.getName(), ".ui.xml");
      m_formClassName = uiPackage.getElementName() + "." + formName;
      m_formType = m_javaProject.findType(m_formClassName);
      if (m_formType != null) {
        m_formFile = (IFile) m_formType.getCompilationUnit().getUnderlyingResource();
        prepareBinderClass();
        if (m_binderClassName != null) {
          return;
        }
      }
    }
    // try @UiTemplate
    IType uiTemplateType = m_javaProject.findType("com.google.gwt.uibinder.client.UiTemplate");
    List<IJavaElement> references = CodeUtils.searchReferences(uiTemplateType);
    for (IJavaElement reference : references) {
      if (reference instanceof IAnnotation) {
        IAnnotation annotation = (IAnnotation) reference;
        IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
        if (valuePairs.length == 1 && valuePairs[0].getValue() instanceof String) {
          String templateName = (String) valuePairs[0].getValue();
          // prepare ICompilationUnit
          ICompilationUnit compilationUnit =
              (ICompilationUnit) annotation.getAncestor(IJavaElement.COMPILATION_UNIT);
          // prepare qualified template name
          templateName = StringUtils.removeEnd(templateName, ".ui.xml");
          if (templateName.contains(".")) {
            templateName = templateName.replace('.', '/');
          } else {
            String packageName = compilationUnit.getPackageDeclarations()[0].getElementName();
            templateName = packageName.replace('.', '/') + "/" + templateName;
          }
          templateName += ".ui.xml";
          // if found, initialize "form" element
          if (m_binderResourceName.equals(templateName)) {
            m_formType = (IType) annotation.getParent().getParent();
            m_formClassName = m_formType.getFullyQualifiedName();
            m_formFile = (IFile) m_formType.getCompilationUnit().getUnderlyingResource();
            prepareBinderClass();
            if (m_binderClassName != null) {
              return;
            }
          }
        }
      }
    }
    // no Java form
    throw new DesignerException(IExceptionConstants.NO_FORM_TYPE, m_binderResourceName);
  }
View Full Code Here

        String objectTypeSignature = superSignature.substring(objectTypeBegin, objectTypeEnd + 1);
        String objectTypeName = CodeUtils.getResolvedTypeName(m_formType, objectTypeSignature);
        if (objectTypeName != null) {
          IType objectType = m_javaProject.findType(objectTypeName);
          if (!CodeUtils.isSuccessorOf(objectType, "com.google.gwt.user.client.ui.Widget")) {
            throw new DesignerException(IExceptionConstants.ONLY_WIDGET_BASED,
                m_formClassName,
                objectTypeName);
          }
        }
      }
View Full Code Here

          "    }",
          "  }",
          "}");
      fail();
    } catch (Throwable e) {
      DesignerException de = DesignerExceptionUtils.getDesignerException(e);
      assertEquals(de.getCode(), IExceptionConstants.NOT_CONFIGURED);
      assertTrue(DesignerExceptionUtils.isWarning(e));
    }
  }
View Full Code Here

          "    }",
          "  }",
          "}");
      fail();
    } catch (Throwable e) {
      DesignerException de = DesignerExceptionUtils.getDesignerException(e);
      assertEquals(de.getCode(), IExceptionConstants.INCORRECT_VERSION);
      assertTrue(DesignerExceptionUtils.isWarning(e));
    }
  }
View Full Code Here

          "    }",
          "  }",
          "}");
      fail();
    } catch (Throwable e) {
      DesignerException de = DesignerExceptionUtils.getDesignerException(e);
      assertEquals(de.getCode(), IExceptionConstants.NO_RESOURCES);
      assertTrue(DesignerExceptionUtils.isWarning(e));
    }
  }
View Full Code Here

  public void test_HostedModeException() throws Exception {
    int code = 123;
    Exception nested = new Exception();
    String[] parameters = new String[]{"a", "b", "c"};
    Throwable e = new HostedModeException(code, nested, parameters);
    DesignerException result = (DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(e);
    assertEquals(code, result.getCode());
    assertSame(nested, result.getCause());
    assertSame(parameters, result.getParameters());
  }
View Full Code Here

   * GWT 2.2 breaks binary compatibility.
   */
  public void test_IncompatibleClassChangeError_JClassType() throws Exception {
    Throwable e =
        new IncompatibleClassChangeError("Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected");
    DesignerException result = (DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(e);
    assertEquals(IExceptionConstants.BINARY_INCOMPAT_GWT22, result.getCode());
  }
View Full Code Here

  public void test_NPE_CompiledClass() throws Exception {
    String key = "wbp.GWT_ExceptionRewriter.simulate.CompiledClass";
    try {
      System.setProperty(key, "true");
      Throwable e = new NullPointerException();
      DesignerException result = (DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(e);
      assertEquals(IExceptionConstants.NPE_IN_COMPILED_CLASS, result.getCode());
    } finally {
      System.clearProperty(key);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wb.internal.core.utils.exception.DesignerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.