Java Code Examples for com.intellij.ide.projectView.PresentationData#setLocationString()

The following examples show how to use com.intellij.ide.projectView.PresentationData#setLocationString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeCoverageProjectViewClassDecorator.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public void decorate(@SuppressWarnings("rawtypes") ProjectViewNode node, PresentationData data) {
  CoverageDataManager manager = getCoverageDataManager();
  CoverageSuitesBundle currentSuite = manager.getCurrentSuitesBundle();

  Project project = node.getProject();
  BlazeCoverageAnnotator annotator = getAnnotator(project, currentSuite);
  if (annotator == null) {
    return;
  }
  PsiFile file = getPsiFileForJavaClass(getPsiElement(node));
  if (file == null) {
    return;
  }
  String string = annotator.getFileCoverageInformationString(file, currentSuite, manager);
  if (string != null) {
    data.setLocationString(string);
  }
}
 
Example 2
Source File: CSharpElementTreeNode.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredUIAccess
protected void updateImpl(PresentationData presentationData)
{
	DotNetNamedElement value = getValue();

	presentationData.setPresentableText(getPresentableText(value));

	if(BitUtil.isSet(myFlags, ALLOW_GRAY_FILE_NAME))
	{
		PsiFile containingFile = value.getContainingFile();
		if(containingFile != null)
		{
			if(!Comparing.equal(FileUtil.getNameWithoutExtension(containingFile.getName()), value.getName()))
			{
				presentationData.setLocationString(containingFile.getName());
			}
		}
	}
}
 
Example 3
Source File: TodoDirNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateImpl(@Nonnull PresentationData data) {
  super.updateImpl(data);
  int fileCount = getFileCount(getValue());
  if (getValue() == null || !getValue().isValid() || fileCount == 0) {
    setValue(null);
    return;
  }

  VirtualFile directory = getValue().getVirtualFile();
  boolean isProjectRoot = !ProjectRootManager.getInstance(getProject()).getFileIndex().isInContent(directory);
  String newName = isProjectRoot || getStructure().getIsFlattenPackages() ? getValue().getVirtualFile().getPresentableUrl() : getValue().getName();

  int todoItemCount = getTodoItemCount(getValue());
  data.setLocationString(IdeBundle.message("node.todo.group", todoItemCount));
  data.setPresentableText(newName);
}
 
Example 4
Source File: TodoFileNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateImpl(@Nonnull PresentationData data) {
  super.updateImpl(data);
  String newName;
  if (myBuilder.getTodoTreeStructure().isPackagesShown()) {
    newName = getValue().getName();
  }
  else {
    newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl();
  }

  data.setPresentableText(newName);
  int todoItemCount;
  try {
    todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue());
  }
  catch (IndexNotReadyException e) {
    return;
  }
  if (todoItemCount > 0) {
    data.setLocationString(IdeBundle.message("node.todo.items", todoItemCount));
  }
}
 
Example 5
Source File: NodeDecorationBaseTest.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
PresentationData presentationData(boolean location) {
  PresentationData data = presentationData();
  if (location) {
    data.setLocationString(LOCATION_PATH);
  }
  return data;
}
 
Example 6
Source File: ModuleToDoNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull PresentationData presentation) {
  if (DumbService.getInstance(getProject()).isDumb()) return;
  String newName = getValue().getName();
  int todoItemCount = getTodoItemCount(getValue());
  presentation.setLocationString(IdeBundle.message("node.todo.group", todoItemCount));
  presentation.setIcon(AllIcons.Nodes.Module);
  presentation.setPresentableText(newName);
}
 
Example 7
Source File: NamedLibraryElementNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(PresentationData presentation) {
  presentation.setPresentableText(getValue().getName());
  final OrderEntry orderEntry = getValue().getOrderEntry();

  if (orderEntry instanceof ModuleExtensionWithSdkOrderEntry) {
    final ModuleExtensionWithSdkOrderEntry sdkOrderEntry = (ModuleExtensionWithSdkOrderEntry)orderEntry;
    final Sdk sdk = sdkOrderEntry.getSdk();
    presentation.setIcon(SdkUtil.getIcon(((ModuleExtensionWithSdkOrderEntry)orderEntry).getSdk()));
    if (sdk != null) { //jdk not specified
      final String path = sdk.getHomePath();
      if (path != null) {
        presentation.setLocationString(FileUtil.toSystemDependentName(path));
      }
    }
    presentation.setTooltip(null);
  }
  else if (orderEntry instanceof LibraryOrderEntry) {
    presentation.setIcon(getIconForLibrary(orderEntry));
    presentation.setTooltip(StringUtil.capitalize(IdeBundle.message("node.projectview.library", ((LibraryOrderEntry)orderEntry).getLibraryLevel())));
  }
  else if(orderEntry instanceof OrderEntryWithTracking) {
    Image icon = null;
    CellAppearanceEx cellAppearance = OrderEntryAppearanceService.getInstance().forOrderEntry(orderEntry);
    if(cellAppearance instanceof ModifiableCellAppearanceEx) {
      icon = ((ModifiableCellAppearanceEx)cellAppearance).getIcon();
    }
    presentation.setIcon(icon == null ? AllIcons.Toolbar.Unknown : icon);
  }
}
 
Example 8
Source File: FavoritesListNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void update(PresentationData presentation) {
  presentation.setIcon(AllIcons.Toolwindows.ToolWindowFavorites);
  presentation.setPresentableText(myName);
  presentation.setLocationString(myDescription);
}
 
Example 9
Source File: PsiDirectoryNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void updateImpl(PresentationData data) {
  final Project project = getProject();
  final PsiDirectory psiDirectory = getValue();
  final VirtualFile directoryFile = psiDirectory.getVirtualFile();

  final Object parentValue = getParentValue();
  if (ProjectRootsUtil.isModuleContentRoot(directoryFile, project)) {
    ProjectFileIndex fi = ProjectRootManager.getInstance(project).getFileIndex();
    Module module = fi.getModuleForFile(directoryFile);

    data.setPresentableText(directoryFile.getName());
    if (module != null) {
      if (!(parentValue instanceof Module)) {
        if (Comparing.equal(module.getName(), directoryFile.getName())) {
          data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
        else {
          data.addText(directoryFile.getName() + " ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          data.addText("[" + module.getName() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
      }
      else {
        data.addText(directoryFile.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }

      if (parentValue instanceof Module || parentValue instanceof Project) {
        final String location = FileUtil.getLocationRelativeToUserHome(directoryFile.getPresentableUrl());
        data.addText(" (" + location + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else if (ProjectRootsUtil.isSourceOrTestRoot(directoryFile, project)) {
        if (ProjectRootsUtil.isInTestSource(directoryFile, project)) {
          data.addText(" (test source root)", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
        else {
          data.addText(" (source root)",  SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
      }

      setupIcon(data, psiDirectory);

      return;
    }
  }

  final String name = parentValue instanceof Project
                      ? psiDirectory.getVirtualFile().getPresentableUrl()
                      : BaseProjectViewDirectoryHelper.getNodeName(getSettings(), parentValue, psiDirectory);
  if (name == null) {
    setValue(null);
    return;
  }

  data.setPresentableText(name);
  if (ProjectRootsUtil.isLibraryRoot(directoryFile, project)) {
    data.setLocationString("library home");
  }
  else {
    data.setLocationString(BaseProjectViewDirectoryHelper.getLocationString(psiDirectory));
  }

  setupIcon(data, psiDirectory);
}