Exemplo n.º 1
0
  @Override
  protected boolean validatePage() {
    IStatus status =
        JavaConventions.validateCompilationUnitName(
            this.getFileName() + ".java", CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
    if (!status.isOK()) {
      setErrorMessage(status.getMessage());
      return false;
    }
    IProject project =
        ResourcesPlugin.getWorkspace().getRoot().getProject(getContainerFullPath().segment(0));

    // This may need to change depending on how we want to deal with localized components in future.
    LocatePlugin locatePlugin = LocatePlugin.getDefault();
    try {
      LocalizedComponentsLocateResult result =
          locatePlugin.getLocalizedComponentsLocateResult(project, getFileName());
      if (result.getResources().length > 0) {
        setErrorMessage("A component by that name already exists");
        return false;
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // Check that we aren't going to create a wocomponent inside another wocomponent
    IPath path = getContainerFullPath();
    if (path.lastSegment().endsWith(".wo")) {
      setErrorMessage("Cannot create a component within another component");
      return false;
    }

    return super.validatePage();
  }
Exemplo n.º 2
0
 protected String packageNameForComponent(String componentName) {
   IProject project =
       ResourcesPlugin.getWorkspace().getRoot().getProject(getContainerFullPath().segment(0));
   try {
     LocalizedComponentsLocateResult result =
         LocatePlugin.getDefault().getLocalizedComponentsLocateResult(project, componentName);
     IType javaType;
     if (result != null && (javaType = result.getDotJavaType()) != null) {
       return javaType.getPackageFragment().getElementName();
     }
   } catch (CoreException e) {
     e.printStackTrace();
   } catch (LocateException e) {
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 3
0
 protected IPath componentPathForPackage(IPackageFragment _selection) {
   try {
     LocatePlugin locate = LocatePlugin.getDefault();
     for (IJavaElement element : _selection.getChildren()) {
       String componentName = locate.fileNameWithoutExtension(element.getElementName());
       LocalizedComponentsLocateResult result =
           locate.getLocalizedComponentsLocateResult(
               _selection.getJavaProject().getProject(), componentName);
       IFolder[] components = result.getComponents();
       if (components.length > 0) {
         IContainer selectionPath = components[0].getParent();
         return selectionPath.getFullPath();
       }
     }
   } catch (CoreException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (LocateException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }