Java Code Examples for com.intellij.ide.projectView.PresentationData#setPresentableText()
The following examples show how to use
com.intellij.ide.projectView.PresentationData#setPresentableText() .
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: TodoFileNode.java From consulo with Apache License 2.0 | 6 votes |
@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 2
Source File: TodoDirNode.java From consulo with Apache License 2.0 | 6 votes |
@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 3
Source File: PsiFileNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void updateImpl(PresentationData data) { PsiFile value = getValue(); data.setPresentableText(value.getName()); data.setIcon(IconDescriptorUpdaters.getIcon(value, Iconable.ICON_FLAG_READ_STATUS)); VirtualFile file = getVirtualFile(); if (file != null && file.is(VFileProperty.SYMLINK)) { String target = file.getCanonicalPath(); if (target == null) { data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); data.setTooltip(CommonBundle.message("vfs.broken.link")); } else { data.setTooltip(FileUtil.toSystemDependentName(target)); } } }
Example 4
Source File: VirtualFileTreeNode.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override protected void update(@NotNull PresentationData presentation) { final PsiManager psiManager = PsiManager.getInstance(myProject); final VirtualFile virtualFile = getValue(); final PsiFile psiElement = virtualFile.isValid() ? psiManager.findFile(virtualFile) : null; if (psiElement instanceof PsiDirectory) { new PsiDirectoryNode(myProject, (PsiDirectory)psiElement, getSettings()).update(presentation); } else if (psiElement != null) { new PsiFileNode(myProject, psiElement, getSettings()).update(presentation); } else { presentation.setPresentableText(virtualFile.getName()); presentation.setIcon(virtualFile.isDirectory() ? AllIcons.Nodes.Folder : virtualFile.getFileType().getIcon()); } }
Example 5
Source File: BookmarksFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
private void updateChildren() { if (myProject.isDisposed()) return; myChildren.clear(); List<Bookmark> bookmarks = myBookmarkManager.getValidBookmarks(); for (final Bookmark bookmark : bookmarks) { AbstractTreeNode<Bookmark> child = new AbstractTreeNode<Bookmark>(myProject, bookmark) { @Nonnull @Override public Collection<? extends AbstractTreeNode> getChildren() { return Collections.emptyList(); } @Override public boolean canNavigate() { return bookmark.canNavigate(); } @Override public boolean canNavigateToSource() { return bookmark.canNavigateToSource(); } @Override public void navigate(boolean requestFocus) { bookmark.navigate(requestFocus); } @Override protected void update(PresentationData presentation) { presentation.setPresentableText(bookmark.toString()); presentation.setIcon(bookmark.getIcon()); } }; child.setParent(myNode); myChildren.add(child); } myFavoritesManager.fireListeners(getListName(myProject)); }
Example 6
Source File: ModuleToDoNode.java From consulo with Apache License 2.0 | 5 votes |
@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 |
@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: FileGroupingProjectNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { if (myVirtualFile != null && myVirtualFile.isDirectory()) { presentation.setIcon(AllIcons.Nodes.TreeClosed); } else if (myVirtualFile != null) { presentation.setIcon(myVirtualFile.getFileType().getIcon()); } else { presentation.setIcon(AllIcons.FileTypes.Unknown); } presentation.setPresentableText(getValue().getName()); }
Example 9
Source File: UsageProjectTreeNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { presentation.setIcon(myUsagePresentation.getIcon()); presentation.setTooltip(myUsagePresentation.getTooltipText()); final TextChunk[] text = myUsagePresentation.getText(); updatePresentationWithTextChunks(presentation, text); presentation.setPresentableText(StringUtil.join(text, new Function<TextChunk, String>() { @Override public String fun(TextChunk chunk) { return chunk.getText(); } }, "")); }
Example 10
Source File: AbstractModuleNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(PresentationData presentation) { if (getValue().isDisposed()) { setValue(null); return; } presentation.setPresentableText(getValue().getName()); if (showModuleNameInBold()) { presentation.addText(getValue().getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } presentation.setIcon(AllIcons.Nodes.Module); }
Example 11
Source File: SimpleNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { Object newElement = updateElement(); if (getElement() != newElement) { presentation.setChanged(true); } if (newElement == null) return; Color oldColor = myColor; String oldName = myName; Image oldIcon = getIcon(); List<ColoredFragment> oldFragments = new ArrayList<ColoredFragment>(presentation.getColoredText()); myColor = UIUtil.getTreeTextForeground(); updateFileStatus(); doUpdate(); myName = getName(); presentation.setPresentableText(myName); presentation.setChanged(!Comparing.equal(new Object[]{getIcon(), myName, oldFragments, myColor}, new Object[]{oldIcon, oldName, oldFragments, oldColor})); presentation.setForcedTextForeground(myColor); presentation.setIcon(getIcon()); }
Example 12
Source File: ServersTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { Deployment deployment = getValue(); presentation.setIcon(getStatusIcon(deployment.getStatus())); presentation.setPresentableText(deployment.getName()); presentation.setTooltip(deployment.getStatusText()); }
Example 13
Source File: ServersTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { RemoteServer<?> server = getValue(); ServerConnection connection = getConnection(); presentation.setPresentableText(server.getName()); presentation.setIcon(getServerNodeIcon(server.getType().getIcon(), connection != null ? getStatusIcon(connection.getStatus()) : null)); presentation.setTooltip(connection != null ? connection.getStatusText() : null); }
Example 14
Source File: UnityScriptFileNode.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override protected void updateImpl(PresentationData data) { super.updateImpl(data); data.setPresentableText(FileUtil.getNameWithoutExtension(getValue().getName())); }
Example 15
Source File: ExternalSystemNodeDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void update(PresentationData presentation) { presentation.setPresentableText(myName); presentation.setIcon(getIcon()); presentation.setTooltip(myDescription); }
Example 16
Source File: ServersTreeStructure.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void update(PresentationData presentation) { presentation.setIcon(AllIcons.Debugger.Console); presentation.setPresentableText(getLogName()); }
Example 17
Source File: PsiDirectoryNode.java From consulo with Apache License 2.0 | 4 votes |
@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); }
Example 18
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override public void update(PresentationData presentation) { final String[] groupPath = getValue().getGroupPath(); presentation.setPresentableText(groupPath[groupPath.length - 1]); presentation.setIcon(AllIcons.Nodes.ModuleGroup); }
Example 19
Source File: TodoPackageNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void update(PresentationData data) { super.update(data); final PackageElement packageElement = getValue(); try { if (packageElement == null || !packageElement.getPackage().isValid()) { setValue(null); return; } int fileCount = getFileCount(packageElement); if (fileCount == 0){ setValue(null); return; } PsiPackage aPackage = packageElement.getPackage(); String newName; if (getStructure().areFlattenPackages()) { newName = aPackage.getQualifiedName(); } else { newName = myPresentationName != null ? myPresentationName : ""; } int nameEndOffset = newName.length(); int todoItemCount = getTodoItemCount(packageElement); newName = IdeBundle.message("node.todo.group", todoItemCount); myHighlightedRegions.clear(); TextAttributes textAttributes = new TextAttributes(); Color newColor = null; if (CopyPasteManager.getInstance().isCutElement(packageElement)) { newColor = CopyPasteManager.CUT_COLOR; } textAttributes.setForegroundColor(newColor); myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes)); EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme(); myHighlightedRegions.add( new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES))); data.setPresentableText(newName); } catch (IndexNotReadyException e) { LOG.info(e); data.setPresentableText("N/A"); } }
Example 20
Source File: ImagesProjectNode.java From intellij-sdk-docs with Apache License 2.0 | 4 votes |
@Override protected void update(PresentationData data) { data.setIcon(getValue().isDirectory() ? AllIcons.Nodes.Folder : getValue().getFileType().getIcon()); data.setPresentableText(getValue().getName()); }