コード例 #1
0
ファイル: ProjectDecorator.java プロジェクト: x10-lang/x10dt
 public Image decorateImage(Image baseImage, Object object) {
   IResource objectResource = (IResource) object;
   if (objectResource == null) {
     return null;
   }
   if (objectResource.getType() != IResource.PROJECT) {
     // Only projects are decorated
     return null;
   }
   IProject project = (IProject) objectResource;
   boolean isJava = false;
   try {
     if (project.hasNature(X10DTCorePlugin.X10_CPP_PRJ_NATURE_ID)) {
       isJava = false;
     } else if (project.hasNature(X10DTCorePlugin.X10_PRJ_JAVA_NATURE_ID)) {
       isJava = true;
     } else {
       return null;
     }
   } catch (CoreException e) {
     X10DTUIPlugin.getInstance().getLog().log(e.getStatus());
   }
   // Overlay custom image over base image
   ImageDescriptor[] desc = new ImageDescriptor[5];
   desc[1] = X10PluginImages.DESC_OVR_X10; // This is the X10 project decoration.
   if (isJava) desc[0] = X10PluginImages.DESC_OVR_JAVA;
   DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon(baseImage, desc);
   return overlayIcon.createImage();
 }
コード例 #2
0
  @Parameters
  public static Collection<Object[]> params() throws Exception {
    project =
        ProjectUtils.copyProjectIntoWorkspace(
            X10DTUIPlugin.getInstance().getBundle(), new Path("data/X10DocProvider"));

    IFolder folder = project.getFolder("src");

    final List<Object[]> list = new ArrayList<Object[]>();

    folder.accept(
        new IResourceVisitor() {
          public boolean visit(IResource resource) throws CoreException {
            if (resource instanceof IFile) {
              if (!resource.toString().contains(".svn/")) {
                list.add(new Object[] {resource});
              }

              return false;
            }

            return true;
          }
        });

    return list;
  }
コード例 #3
0
  public static TypeHierarchyViewPart open(IMemberInfo[] candidates, IWorkbenchWindow window) {
    Assert.isTrue(candidates != null && candidates.length != 0);

    IMemberInfo input = null;
    if (candidates.length > 1) {
      String title = Messages.OpenTypeHierarchyUtil_selectionDialog_title;
      String message = Messages.OpenTypeHierarchyUtil_selectionDialog_message;
      input = SelectionConverter.selectJavaElement(candidates, window.getShell(), title, message);
    } else {
      input = candidates[0];
    }
    if (input == null) return null;

    try {
      if (X10Constants.OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE.equals(
          X10DTUIPlugin.getInstance()
              .getPreferenceStore()
              .getString(EditorActionDefinitionIds.OPEN_TYPE_HIERARCHY))) {
        return openInPerspective(window, input);
      } else {
        return openInViewPart(window, input);
      }

    } catch (Exception e) {
      //			ExceptionHandler.handle(e, window.getShell(),
      //				Messages.OpenTypeHierarchyUtil_error_open_perspective,
      //				e.getMessage());
      X10DTUIPlugin.log(e);
    }
    //			catch (JavaModelException e) {
    //			ExceptionHandler.handle(e, window.getShell(),
    //				Messages.OpenTypeHierarchyUtil_error_open_editor,
    //				e.getMessage());
    //		}
    return null;
  }
コード例 #4
0
 private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IMemberInfo input) {
   IWorkbenchPage page = window.getActivePage();
   try {
     TypeHierarchyViewPart result =
         (TypeHierarchyViewPart) page.findView(X10Constants.ID_TYPE_HIERARCHY);
     if (result != null) {
       result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
     }
     result = (TypeHierarchyViewPart) page.showView(X10Constants.ID_TYPE_HIERARCHY);
     result.setInputElement(input);
     return result;
   } catch (CoreException e) {
     //			ExceptionHandler.handle(e, window.getShell(),
     //				Messages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
     X10DTUIPlugin.log(e);
   }
   return null;
 }
コード例 #5
0
  private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IMemberInfo input)
      throws WorkbenchException, Exception {
    IWorkbench workbench = X10DTUIPlugin.getInstance().getWorkbench();
    // The problem is that the input element can be a working copy. So we first convert it to the
    // original element if
    // it exists.
    IMemberInfo perspectiveInput = input;

    if (input instanceof IMemberInfo) {
      if (!(input instanceof ITypeInfo)) {
        perspectiveInput = ((IMemberInfo) input).getDeclaringType();
      } else {
        perspectiveInput = input;
      }
    }
    ;
    IWorkbenchPage page =
        workbench.showPerspective(
            X10Constants.ID_HIERARCHYPERSPECTIVE,
            window,
            SearchUtils.getResource(perspectiveInput));

    TypeHierarchyViewPart part =
        (TypeHierarchyViewPart) page.findView(X10Constants.ID_TYPE_HIERARCHY);
    if (part != null) {
      part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
    }
    part = (TypeHierarchyViewPart) page.showView(X10Constants.ID_TYPE_HIERARCHY);
    part.setInputElement(input);
    if (input instanceof IMemberInfo) {
      if (page.getEditorReferences().length == 0) {
        SearchUtils.openEditor(input);
      }
    }
    return part;
  }