public String getText(Object element) {
    if (!(element instanceof IResource)) return null;

    IResource resource = (IResource) element;
    String text = null;

    if (!resource.exists()) text = SearchMessages.FileLabelProvider_removed_resource_label;
    else {
      IPath path = resource.getFullPath().removeLastSegments(1);
      if (path.getDevice() == null) path = path.makeRelative();
      if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) {
        text = fLabelProvider.getText(resource);
        if (path != null && fOrder == SHOW_LABEL_PATH) {
          fArgs[0] = text;
          fArgs[1] = path.toString();
          text = MessageFormat.format(fgSeparatorFormat, fArgs);
        }
      } else {
        if (path != null) text = path.toString();
        else text = ""; // $NON-NLS-1$
        if (fOrder == SHOW_PATH_LABEL) {
          fArgs[0] = text;
          fArgs[1] = fLabelProvider.getText(resource);
          text = MessageFormat.format(fgSeparatorFormat, fArgs);
        }
      }
    }

    int matchCount = 0;
    AbstractTextSearchResult result = fPage.getInput();
    if (result != null) matchCount = result.getMatchCount(element);
    if (matchCount <= 1) return text;
    String format = SearchMessages.FileLabelProvider_count_format;
    return MessageFormat.format(format, new Object[] {text, new Integer(matchCount)});
  }
  /*
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Label label = new Label(composite, SWT.LEFT);
    label.setText(fInstruction);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fResourceGroup =
        new SelectResourcesBlock(
            composite,
            ResourcesPlugin.getWorkspace().getRoot(),
            getResourceProvider(IResource.FOLDER | IResource.PROJECT),
            WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
            getResourceProvider(IResource.FILE),
            WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
            SWT.NONE,
            useHeightHint(parent));
    fResourceGroup.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateSelectionCount();
          }
        });

    fCountIndication = new Label(composite, SWT.LEFT);
    fCountIndication.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    createSelectionButtonGroup(composite);

    setInitialSelection();
    return composite;
  }
  /**
   * Creates the checkbox tree and list for selecting resources.
   *
   * @param parent the parent control
   */
  protected final void createResourcesGroup(Composite parent) {

    // create the input element, which has the root resource
    // as its only child
    List input = new ArrayList();
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
      if (projects[i].isOpen()) {
        input.add(projects[i]);
      }
    }

    this.resourceGroup =
        new ResourceTreeAndListGroup(
            parent,
            input,
            getResourceProvider(IResource.FOLDER | IResource.PROJECT),
            WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
            getResourceProvider(IResource.FILE),
            WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
            SWT.NONE,
            DialogUtil.inRegularFontMode(parent));

    ICheckStateListener listener =
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateWidgetEnablements();
          }
        };

    this.resourceGroup.addCheckStateListener(listener);
  }
Пример #4
0
 /*
  * (non-Javadoc)
  *
  * @see net.kbserve.pyjdt.properties.models.ICPEType#getIcon()
  */
 @Override
 public Image getIcon() {
   if (getPath() != null) {
     IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(getPath());
     if (resource != null) {
       WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
       return workbenchLabelProvider.getImage(resource);
     }
   }
   System.out.println("Using default icon for " + getPath());
   return getDefaultIcon();
 }
  public Image getImage(Object element) {
    if (!(element instanceof IResource)) return null;

    IResource resource = (IResource) element;
    Image image = fLabelProvider.getImage(resource);
    return image;
  }
Пример #6
0
 @Override
 public StyledString getStyledText(Object element) {
   if (element instanceof INode) {
     return this.cmlLabelProvider.getStyledText(element);
   }
   return workbenchLabelProvider.getStyledText(element);
 }
Пример #7
0
 @Override
 public Image getImage(Object element) {
   if (element instanceof INode) {
     return this.cmlLabelProvider.getImage(element);
   }
   return workbenchLabelProvider.getImage(element);
 }
  @Override
  public StyledString getStyledText(Object element) {
    if (element instanceof IResource) {
      IResource resource = (IResource) element;

      // Un-analyzed resources are grey.
      if (!DartCore.isAnalyzed(resource)) {
        return new StyledString(resource.getName(), StyledString.QUALIFIER_STYLER);
      }

      StyledString string = new StyledString(resource.getName());

      DartElement dartElement = DartCore.create(resource);

      // Append the library name to library units.
      if (dartElement instanceof CompilationUnit) {
        if (((CompilationUnit) dartElement).definesLibrary()) {
          DartLibrary library = ((CompilationUnit) dartElement).getLibrary();

          string.append(" [" + library.getDisplayName() + "]", StyledString.QUALIFIER_STYLER);
        }
      }

      return string;
    }

    return workbenchLabelProvider.getStyledText(element);
  }
  /**
   * Returns a new drill down viewer for this dialog.
   *
   * @param heightHint height hint for the drill down composite
   */
  private void createTreeViewer(int heightHint) {
    // Create drill down.
    DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
    GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true);
    spec.widthHint = SIZING_SELECTION_PANE_WIDTH;
    spec.heightHint = heightHint;
    drillDown.setLayoutData(spec);

    // Create tree viewer inside drill down.
    treeViewer = new TreeViewer(drillDown, SWT.NONE);
    drillDown.setChildTree(treeViewer);
    ChangeLogContainerContentProvider cp = new ChangeLogContainerContentProvider();
    cp.showClosedProjects(showClosedProjects);
    treeViewer.setContentProvider(cp);
    treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    treeViewer.setComparator(new ViewerComparator());
    treeViewer.setUseHashlookup(true);
    treeViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            containerSelectionChanged((IContainer) selection.getFirstElement()); // allow null
          }
        });
    treeViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
              Object item = ((IStructuredSelection) selection).getFirstElement();
              if (item == null) {
                return;
              }
              if (treeViewer.getExpandedState(item)) {
                treeViewer.collapseToLevel(item, 1);
              } else {
                treeViewer.expandToLevel(item, 1);
              }
            }
          }
        });

    /*
     * This helps in displaying all folders under the document
     * root as well as the actual root itself.
     */
    ChangeLogRootContainer root = new ChangeLogRootContainer(this.initialSelection.getProject());
    // This has to be done after the viewer has been laid out
    treeViewer.setInput(root);
  }
Пример #10
0
 private String getParentLabel(IResource resource) {
   IResource parent = resource.getParent();
   String text;
   if (parent.getType() == IResource.ROOT) {
     // Get readable name for workspace root ("Workspace"), without duplicating language-specific
     // string here.
     text = labelProvider.getText(parent);
   } else {
     text = parent.getFullPath().makeRelative().toString();
   }
   if (text == null) {
     return ""; //$NON-NLS-1$
   }
   return text;
 }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
   */
  @Override
  public Image getImage(Object element) {
    if (element instanceof TreeNode) {
      TreeNode treeNode = (TreeNode) element;
      element = treeNode.data;
    }
    if (element instanceof ICustomLineElement) {
      return fLineMatchImage;
    }
    if (element instanceof ICustomModule) {
      return SharedUiPlugin.getImageCache().get(UIConstants.PY_FILE_ICON);
    }
    if (!(element instanceof IResource)) {
      return null;
    }

    IResource resource = (IResource) element;
    Image image = fLabelProvider.getImage(resource);
    return image;
  }
  @Override
  public Image getImage(Object element) {
    if (element instanceof IResource) {
      IResource resource = (IResource) element;

      if (!DartCore.isAnalyzed(resource)) {
        if (resource instanceof IFile) {
          return DartToolsPlugin.getImage(IGNORE_FILE_ICON);
        }

        if (resource instanceof IFolder) {
          return DartToolsPlugin.getImage(IGNORE_FOLDER_ICON);
        }
      }

      if (resource instanceof IFile
          && resource.getParent() instanceof IProject
          && resource.getName().equals(DartCore.BUILD_DART_FILE_NAME)) {
        return DartToolsPlugin.getImage(BUILD_FILE_ICON);
      }

      DartElement dartElement = DartCore.create(resource);

      // Return a different icon for library units.
      if (dartElement instanceof CompilationUnit) {
        if (((CompilationUnit) dartElement).definesLibrary()) {
          return DartToolsPlugin.getImage(LIBRARY_ICON);
        }
      }

      if (element instanceof IFolder) {
        IFolder folder = (IFolder) element;

        if (DartCore.isPackagesDirectory(folder)) {
          return DartToolsPlugin.getImage(PACKAGES_FOLDER_ICON);
        }
      }
    }

    return workbenchLabelProvider.getImage(element);
  }
  @Override
  public Image getImage(final Object node) {
    if (node instanceof DifferenceReport) {
      return null;
    } else if (node instanceof Mapping) {
      Mapping mapping = (Mapping) node;
      MappingHelper helper = mapping.getHelper();
      if (helper instanceof DifferenceDescriptor) {
        final DifferenceDescriptor desc = (DifferenceDescriptor) helper;
        final DifferenceType type = desc.getType();
        if (type.getValue() == DifferenceType.DELETION) {
          final List<EObject> inputs = mapping.getInputs();
          final EObject input = inputs.isEmpty() ? null : inputs.get(0);
          if (input != null) {
            return lpImageLabelProvider.getImage(input);
          }
        } else {
          final List<EObject> outputs = mapping.getOutputs();
          final EObject output = outputs.isEmpty() ? null : outputs.get(0);
          final List<EObject> inputs = mapping.getInputs();
          final EObject input = inputs.isEmpty() ? null : inputs.get(0);
          if (output != null) {
            return lpImageLabelProvider.getImage(output);
          } else if (input != null) {
            return lpImageLabelProvider.getImage(input);
          }
        }
      }
    } else if (node instanceof EObject) {
      return lpImageLabelProvider.getImage(node);
    }

    if (node instanceof ModelWorkspaceItem) {
      return workbenchProvider.getImage(((ModelWorkspaceItem) node).getResource());
    }
    return null;
  }
Пример #14
0
    @Override
    public Image getImage(Object element) {
      if (element instanceof IMarker) {
        IMarker marker = (IMarker) element;

        if (marker != null && marker.exists()) {
          Image image = AnnotationTypesExtManager.getModel().getImageForMarker(marker);

          if (image != null) {
            image = decorateImage(marker, image);
          } else {
            try {
              image = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider().getImage(marker);
            } catch (Throwable t) {

            }
          }

          return image;
        }
      }

      return null;
    }
Пример #15
0
 public void dispose() {
   super.dispose();
   fLabelProvider.dispose();
 }
Пример #16
0
 @Override
 public Image getImage(Object element) {
   return workbenchLabelProvider.getImage(element);
 }
 @Override
 public String getText(Object element) {
   return workbenchLabelProvider.getText(element);
 }
 @Override
 public void addListener(ILabelProviderListener listener) {
   workbenchLabelProvider.addListener(listener);
 }
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
  */
 public void dispose() {
   super.dispose();
   lp.dispose();
 }
Пример #20
0
 @Override
 public Color getBackground(Object element) {
   return workbenchLabelProvider.getBackground(element);
 }
Пример #21
0
 @Override
 protected void configureViewer(final CheckboxTableViewer viewer) {
   viewer.setContentProvider(new ArrayContentProvider());
   viewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
   viewer.setInput(fProjects);
 }
 @Override
 public boolean isLabelProperty(Object element, String property) {
   return workbenchLabelProvider.isLabelProperty(element, property);
 }
 @Override
 public void dispose() {
   workbenchLabelProvider.dispose();
 }
Пример #24
0
 public boolean isLabelProperty(Object element, String property) {
   return fLabelProvider.isLabelProperty(element, property);
 }
Пример #25
0
 @Override
 public Font getFont(Object element) {
   return workbenchLabelProvider.getFont(element);
 }
Пример #26
0
 public void removeListener(ILabelProviderListener listener) {
   super.removeListener(listener);
   fLabelProvider.removeListener(listener);
 }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
   */
  public String getText(Object element) {
    IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) element;
    switch (entry.getType()) {
      case IRuntimeClasspathEntry.PROJECT:
        IResource res = entry.getResource();
        IJavaElement proj = JavaCore.create(res);
        if (proj == null) {
          return entry.getPath().lastSegment();
        } else {
          return lp.getText(proj);
        }
      case IRuntimeClasspathEntry.ARCHIVE:
        IPath path = entry.getPath();
        if (path == null) {
          return MessageFormat.format("Invalid path: {0}", new Object[] {"null"}); // $NON-NLS-1$
        }
        if (!path.isAbsolute() || !path.isValidPath(path.toString())) {
          return MessageFormat.format("Invalid path: {0}", new Object[] {path.toOSString()});
        }
        String[] segments = path.segments();
        StringBuffer displayPath = new StringBuffer();
        if (segments.length > 0) {
          String device = path.getDevice();
          if (device != null) {
            displayPath.append(device);
            displayPath.append(File.separator);
          }
          for (int i = 0; i < segments.length - 1; i++) {
            displayPath.append(segments[i]).append(File.separator);
          }
          displayPath.append(segments[segments.length - 1]);

          // getDevice means that's a absolute path.
          if (path.getDevice() != null && !path.toFile().exists()) {
            displayPath.append(" (missing) ");
          }
        } else {
          displayPath.append(path.toOSString());
        }
        return displayPath.toString();
      case IRuntimeClasspathEntry.VARIABLE:
        path = entry.getPath();
        IPath srcPath = entry.getSourceAttachmentPath();
        StringBuffer buf = new StringBuffer(path.toString());
        if (srcPath != null) {
          buf.append(" ["); // $NON-NLS-1$
          buf.append(srcPath.toString());
          IPath rootPath = entry.getSourceAttachmentRootPath();
          if (rootPath != null) {
            buf.append(IPath.SEPARATOR);
            buf.append(rootPath.toString());
          }
          buf.append(']');
        }
        // append JRE name if we can compute it
        if (path.equals(new Path(JavaRuntime.JRELIB_VARIABLE)) && fLaunchConfiguration != null) {
          try {
            IVMInstall vm = JavaRuntime.computeVMInstall(fLaunchConfiguration);
            buf.append(" - "); // $NON-NLS-1$
            buf.append(vm.getName());
          } catch (CoreException e) {
          }
        }
        return buf.toString();
      case IRuntimeClasspathEntry.CONTAINER:
        path = entry.getPath();
        if (fLaunchConfiguration != null) {
          try {
            IJavaProject project = null;
            try {
              project = JavaRuntime.getJavaProject(fLaunchConfiguration);
            } catch (CoreException e) {
            }
            if (project == null) {
            } else {
              IClasspathContainer container =
                  JavaCore.getClasspathContainer(entry.getPath(), project);
              if (container != null) {
                if (container.getDescription().startsWith("Persisted container")) {
                  return container.getPath().toString();
                } else {
                  return container.getDescription();
                }
              }
            }
          } catch (CoreException e) {
          }
        }
        return entry.getPath().toString();
      case IRuntimeClasspathEntry.OTHER:
        IRuntimeClasspathEntry delegate = entry;
        if (entry instanceof ClasspathEntry) {
          delegate = ((ClasspathEntry) entry).getDelegate();
        }
        String name = lp.getText(delegate);
        if (name == null || name.length() == 0) {
          return ((IRuntimeClasspathEntry2) delegate).getName();
        }
        return name;
    }
    return ""; //$NON-NLS-1$
  }
Пример #28
0
 public void addListener(ILabelProviderListener listener) {
   super.addListener(listener);
   fLabelProvider.addListener(listener);
 }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
   */
  public Image getImage(Object element) {
    IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) element;
    IResource resource = entry.getResource();
    switch (entry.getType()) {
      case IRuntimeClasspathEntry.PROJECT:
        IJavaElement proj = JavaCore.create(resource);
        if (proj == null) {
          return PlatformUI.getWorkbench()
              .getSharedImages()
              .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
        } else {
          return lp.getImage(proj);
        }
      case IRuntimeClasspathEntry.ARCHIVE:
        if (resource instanceof IContainer) {
          return lp.getImage(resource);
        }
        if (resource != null && resource.getLocation().toFile().isDirectory()) {
          return PlatformUI.getWorkbench()
              .getSharedImages()
              .getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_FOLDER);
        }

        boolean external = resource == null;
        boolean source = true; // (entry.getSourceAttachmentPath() != null &&
        // !Path.EMPTY.equals(entry.getSourceAttachmentPath()));
        String key = null;
        if (external) {
          IPath path = entry.getPath();
          if (path != null) {
            File file = path.toFile();
            if (file.exists() && file.isDirectory()) {
              key = ISharedImages.IMG_OBJS_PACKFRAG_ROOT;
            } else {
              key = ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE;
            }
          }

        } else {
          if (source) {
            key = ISharedImages.IMG_OBJS_JAR_WITH_SOURCE;
          } else {
            key = ISharedImages.IMG_OBJS_JAR;
          }
        }
        return JavaUI.getSharedImages().getImage(key);
      case IRuntimeClasspathEntry.VARIABLE:
        return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_ENV_VAR);
      case IRuntimeClasspathEntry.CONTAINER:
        return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY);
      case IRuntimeClasspathEntry.OTHER:
        IRuntimeClasspathEntry delegate = entry;
        if (entry instanceof ClasspathEntry) {
          delegate = ((ClasspathEntry) entry).getDelegate();
        }
        Image image = lp.getImage(delegate);
        if (image != null) {
          return image;
        }
        if (resource == null) {
          return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY);
        }
        return lp.getImage(resource);
    }
    return null;
  }
 @Override
 public void removeListener(ILabelProviderListener listener) {
   workbenchLabelProvider.removeListener(listener);
 }