com.intellij.ide.projectView.PresentationData Java Examples
The following examples show how to use
com.intellij.ide.projectView.PresentationData.
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: RunConfigurationNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(PresentationData presentation) { RunnerAndConfigurationSettings configurationSettings = getConfigurationSettings(); boolean isStored = RunManager.getInstance(getProject()).hasSettings(configurationSettings); presentation.addText(configurationSettings.getName(), isStored ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); RunDashboardContributor contributor = RunDashboardContributor.getContributor(configurationSettings.getType()); Image icon = null; if (contributor != null) { DashboardRunConfigurationStatus status = contributor.getStatus(this); if (DashboardRunConfigurationStatus.STARTED.equals(status)) { icon = getExecutorIcon(); } else if (DashboardRunConfigurationStatus.FAILED.equals(status)) { icon = status.getIcon(); } } if (icon == null) { icon = RunManagerEx.getInstanceEx(getProject()).getConfigurationIcon(configurationSettings); } presentation.setIcon(isStored ? icon : ImageEffects.grayed(icon)); if (contributor != null) { contributor.updatePresentation(presentation, this); } }
Example #2
Source File: NodeDecorationBaseTest.java From GitToolBox with Apache License 2.0 | 6 votes |
@Test @DisplayName("Status is shown when location is hidden") void statusWhenLocationBeforeStatusAndLocationNotShown() { config.setDecorationParts(Lists.newArrayList( DecorationPartConfig.builder() .withType(DecorationPartType.BRANCH) .build(), DecorationPartConfig.builder() .withType(DecorationPartType.STATUS) .build() )); PresentationData presentationData = apply(presentationData(true)); DecorationData decorationData = getDecorationData(presentationData); assertThat(decorationData.text).matches(decorationPattern(BRANCH_NAME, AHEAD_BEHIND)); }
Example #3
Source File: ArtifactRootElementImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public PackagingElementPresentation createPresentation(@Nonnull final ArtifactEditorContext context) { return new PackagingElementPresentation() { @Override public String getPresentableName() { return CompilerBundle.message("packaging.element.text.output.root"); } @Override public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { presentationData.setIcon(context.getArtifactType().getIcon()); presentationData.addText(getPresentableName(), mainAttributes); } @Override public int getWeight() { return 0; } }; }
Example #4
Source File: BreakpointsFavoriteListProvider.java From consulo with Apache License 2.0 | 6 votes |
private void replicate(DefaultMutableTreeNode source, AbstractTreeNode destination, final List<AbstractTreeNode<Object>> destinationChildren) { final ArrayList<AbstractTreeNode<Object>> copyChildren = new ArrayList<AbstractTreeNode<Object>>(); AbstractTreeNode<Object> copy = new AbstractTreeNode<Object>(myProject, source.getUserObject()) { @Nonnull @Override public Collection<? extends AbstractTreeNode> getChildren() { return copyChildren; } @Override protected void update(PresentationData presentation) { } }; for (int i = 0; i < source.getChildCount(); i++) { final TreeNode treeNode = source.getChildAt(i); if (treeNode instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode sourceChild = (DefaultMutableTreeNode)treeNode; replicate(sourceChild, copy, copyChildren); } } if (checkNavigatable(copy)) { destinationChildren.add(copy); copy.setParent(destination); } }
Example #5
Source File: NewProjectTreeStructure.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public NodeDescriptor createDescriptor(@Nonnull Object element, @Nullable NodeDescriptor parentDescriptor) { return new PresentableNodeDescriptor(null, parentDescriptor) { @Override protected void update(PresentationData presentation) { if (element instanceof NewModuleContextNode) { boolean isGroup = element instanceof NewModuleContextGroup; presentation.addText(((NewModuleContextNode)element).getName().getValue(), isGroup ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); presentation.setIcon(((NewModuleContextNode)element).getImage()); } } @Override public Object getElement() { return element; } }; }
Example #6
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(PresentationData presentation) { final Collection<ArtifactProblemDescription> problems = ((ArtifactEditorImpl)myContext.getThisArtifactEditor()).getValidationManager().getProblems(this); if (problems == null || problems.isEmpty()) { super.update(presentation); return; } StringBuilder buffer = StringBuilderSpinAllocator.alloc(); final String tooltip; boolean isError = false; try { for (ArtifactProblemDescription problem : problems) { isError |= problem.getSeverity() == ProjectStructureProblemType.Severity.ERROR; buffer.append(problem.getMessage(false)).append("<br>"); } tooltip = XmlStringUtil.wrapInHtml(buffer); } finally { StringBuilderSpinAllocator.dispose(buffer); } getElementPresentation().render(presentation, addErrorHighlighting(isError, SimpleTextAttributes.REGULAR_ATTRIBUTES), addErrorHighlighting(isError, SimpleTextAttributes.GRAY_ATTRIBUTES)); presentation.setTooltip(tooltip); }
Example #7
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 #8
Source File: PresentableNodeDescriptor.java From consulo with Apache License 2.0 | 6 votes |
protected final boolean apply(PresentationData presentation, @Nullable PresentationData before) { setIcon(presentation.getIcon()); myName = presentation.getPresentableText(); myColor = presentation.getForcedTextForeground(); boolean updated = before == null || !presentation.equals(before); if (myUpdatedPresentation == null) { myUpdatedPresentation = createPresentation(); } myUpdatedPresentation.copyFrom(presentation); if (myTemplatePresentation != null) { myUpdatedPresentation.applyFrom(myTemplatePresentation); } updated |= myUpdatedPresentation.isChanged(); myUpdatedPresentation.setChanged(false); return updated; }
Example #9
Source File: BlazePsiDirectoryRootNode.java From intellij with Apache License 2.0 | 6 votes |
@Override protected void updateImpl(PresentationData data) { super.updateImpl(data); WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(getProject()); PsiDirectory psiDirectory = getValue(); assert psiDirectory != null; WorkspacePath workspacePath = workspaceRoot.workspacePathFor(psiDirectory.getVirtualFile()); String text = workspacePath.relativePath(); for (BlazePsiDirectoryRootNodeNameModifier modifier : BlazePsiDirectoryRootNodeNameModifier.EP_NAME.getExtensions()) { text = modifier.modifyRootNodeName(text); } data.setPresentableText(text); data.clearText(); data.addText(text, SimpleTextAttributes.REGULAR_ATTRIBUTES); data.setLocationString(""); }
Example #10
Source File: SourceItemNodeBase.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { final Artifact artifact = myArtifactEditor.getArtifact(); if (!myArtifact.equals(artifact)) { myArtifact = artifact; } super.update(presentation); }
Example #11
Source File: ColoredNodeDecoration.java From GitToolBox with Apache License 2.0 | 5 votes |
private void setName(PresentationData data) { if (PresentationDataUtil.hasEmptyColoredTextValue(data)) { String presentableText = data.getPresentableText(); if (presentableText != null) { data.addText(presentableText, coloredUi.getNameAttributes()); } } }
Example #12
Source File: GlobalConfigsTreeStructure.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
private void updatePresentation() { PresentationData presentation = getPresentation(); presentation.clear(); presentation.addText(myName, SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); if (myModule != null) presentation.addText(" (" + myModule.getName() + ")", SimpleTextAttributes.GRAYED_ITALIC_ATTRIBUTES); update(presentation); }
Example #13
Source File: IgnoreViewNodeDecorator.java From idea-gitignore with MIT License | 5 votes |
/** * Modifies the presentation of a project view node. * * @param node the node to modify (use {@link ProjectViewNode#getValue()} to get the object represented by the * node). * @param data the current presentation of the node, which you can modify as necessary. */ @Override public void decorate(ProjectViewNode node, PresentationData data) { final VirtualFile file = node.getVirtualFile(); if (file == null) { return; } if (manager.isFileTracked(file) && manager.isFileIgnored(file)) { Utils.addColoredText( data, IgnoreBundle.message("projectView.tracked"), GRAYED_SMALL_ATTRIBUTES ); } else if (ignoreSettings.isHideIgnoredFiles() && file.isDirectory()) { int count = ContainerUtil.filter( file.getChildren(), child -> manager.isFileIgnored(child) && !manager.isFileTracked(child) ).size(); if (count > 0) { Utils.addColoredText( data, IgnoreBundle.message("projectView.containsHidden", count), GRAYED_SMALL_ATTRIBUTES ); } } }
Example #14
Source File: SvnProjectViewNodeDecorator.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override public void decorate(ProjectViewNode node, PresentationData data) { if (node != null) { Project project = node.getProject(); if (project != null) { SvnToolBoxProjectState config = SvnToolBoxProjectState.getInstance(project); if (config.showingAnyDecorations()) { SvnToolBoxApp svnToolBox = SvnToolBoxApp.getInstance(); SvnToolBoxProject svnToolBoxProject = SvnToolBoxProject.getInstance(project); LogStopwatch watch = LogStopwatch.debugStopwatch(svnToolBoxProject.sequence(), () -> "Decorator").start(); NodeDecoration decoration = svnToolBox.decorationFor(node); watch.tick("Decoration selected {0}", decoration); if (LOG.isDebugEnabled()) { final int seq = svnToolBoxProject.sequence().get(); LOG.debug("[", seq, "] Node: ", decoration.getClass().getName(), " ", node, " ", node.getClass().getName()); } if (decoration.getType() == NodeDecorationType.Module) { if (config.showProjectViewModuleDecoration) { decoration.decorate(node, data); watch.tick("Module decoration"); } } else if (config.showProjectViewSwitchedDecoration) { decoration.decorate(node, data); watch.tick("Switched decoration"); } watch.stop(); } } } }
Example #15
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 #16
Source File: PackageDecoration.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override protected void applyDecorationUnderSvn(ProjectViewNode node, PresentationData data) { ProjectViewStatus status = getBranchStatusAndCache(node); if (shouldApplyDecoration(status)) { data.addText(formatBranchName(status)); } }
Example #17
Source File: AbstractNodeDecoration.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override public final void decorate(ProjectViewNode node, PresentationData data) { Supplier<Integer> PV_SEQ = SvnToolBoxProject.getInstance(node.getProject()).sequence(); if (isUnderSvn(node, PV_SEQ)) { LogStopwatch watch = LogStopwatch.debugStopwatch(PV_SEQ, () -> "Decorate").start(); applyDecorationUnderSvn(node, data); watch.stop(); } }
Example #18
Source File: ModuleDecoration.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override protected void applyDecorationUnderSvn(ProjectViewNode node, PresentationData data) { ProjectViewStatus status = getBranchStatusAndCache(node); if (shouldApplyDecoration(status)) { data.addText(formatBranchName(status)); } }
Example #19
Source File: PackageElementNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(final PresentationData presentation) { if (getValue() != null && getValue().getPackage().isValid()) { updateValidData(presentation); } else { setValue(null); } }
Example #20
Source File: AbstractTreeBuilderTest.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public NodeDescriptor doCreateDescriptor(final Object element, final NodeDescriptor parentDescriptor) { return new PresentableNodeDescriptor(null, parentDescriptor) { @Override protected void update(PresentationData presentation) { onElementAction("update", (NodeElement)element); presentation.clear(); presentation.addText(new ColoredFragment(getElement().toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES)); if (myChanges.contains(element)) { myChanges.remove(element); presentation.setChanged(true); } } @javax.annotation.Nullable @Override public PresentableNodeDescriptor getChildToHighlightAt(int index) { return null; } @Override public Object getElement() { return element; } @Override public String toString() { List<ColoredFragment> coloredText = getPresentation().getColoredText(); StringBuilder result = new StringBuilder(); for (ColoredFragment each : coloredText) { result.append(each.getText()); } return result.toString(); } }; }
Example #21
Source File: TodoDirNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void setupIcon(PresentationData data, PsiDirectory psiDirectory) { final VirtualFile virtualFile = psiDirectory.getVirtualFile(); if (ProjectRootsUtil.isModuleContentRoot(virtualFile, psiDirectory.getProject())) { data.setIcon(IconDescriptorUpdaters.getIcon(psiDirectory, 0)); } else { super.setupIcon(data, psiDirectory); } }
Example #22
Source File: PresentableNodeDescriptor.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public final boolean update() { if (shouldUpdateData()) { PresentationData before = getPresentation().clone(); PresentationData updated = getUpdatedPresentation(); return shouldApply() && apply(updated, before); } return false; }
Example #23
Source File: OptionsTree.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(PresentationData presentation) { super.update(presentation); String displayName = UnifiedConfigurableComparator.getConfigurableDisplayName(myConfigurable); if (getParent() instanceof Root) { presentation.addText(displayName, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } else { presentation.addText(displayName, SimpleTextAttributes.REGULAR_ATTRIBUTES); } }
Example #24
Source File: LibraryElementPresentation.java From consulo with Apache License 2.0 | 5 votes |
@Override public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { if (myLibrary != null) { presentationData.setIcon(AllIcons.Nodes.PpLib); presentationData.addText(myLibraryName, mainAttributes); presentationData.addText(getLibraryTableComment(myLibrary), commentAttributes); } else { presentationData.addText(myLibraryName + " (" + (myModuleName != null ? "module '" + myModuleName + "'" : myLevel) + ")", SimpleTextAttributes.ERROR_ATTRIBUTES); } }
Example #25
Source File: PresentableNodeDescriptor.java From consulo with Apache License 2.0 | 5 votes |
private PresentationData getUpdatedPresentation() { PresentationData presentation = myUpdatedPresentation != null ? myUpdatedPresentation : createPresentation(); myUpdatedPresentation = presentation; presentation.clear(); update(presentation); if (shouldPostprocess()) { postprocess(presentation); } return presentation; }
Example #26
Source File: ModuleElementPresentation.java From consulo with Apache License 2.0 | 5 votes |
@Override public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { final Module module = findModule(); presentationData.setIcon(myContentFolderType.getIcon()); String moduleName; if (module != null) { moduleName = module.getName(); final ModifiableModuleModel moduleModel = myContext.getModifiableModuleModel(); if (moduleModel != null) { final String newName = moduleModel.getNewName(module); if (newName != null) { moduleName = newName; } } } else if (myModulePointer != null) { moduleName = myModulePointer.getName(); } else { moduleName = "<unknown>"; } presentationData .addText(CompilerBundle.message("node.text.0.1.compile.output", moduleName, StringUtil.toLowerCase(myContentFolderType.getName())), module != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES); }
Example #27
Source File: ExtractedDirectoryPresentation.java From consulo with Apache License 2.0 | 5 votes |
public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { presentationData.setIcon(AllIcons.Nodes.ExtractedFolder); final String parentPath = PathUtil.getParentPath(myJarPath); if (myFile == null || !myFile.isDirectory()) { mainAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; final VirtualFile parentFile = LocalFileSystem.getInstance().findFileByPath(parentPath); if (parentFile == null) { commentAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; } } presentationData.addText("Extracted '" + PathUtil.getFileName(myJarPath) + myPathInJar + "'", mainAttributes); presentationData.addText(" (" + parentPath + ")", commentAttributes); }
Example #28
Source File: DirectoryCopyPresentation.java From consulo with Apache License 2.0 | 5 votes |
public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { presentationData.setIcon(AllIcons.Nodes.CopyOfFolder); if (myFile == null || !myFile.isDirectory()) { mainAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; final VirtualFile parentFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(mySourcePath)); if (parentFile == null) { commentAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; } } presentationData.addText(CompilerBundle.message("node.text.0.directory.content", mySourceFileName), mainAttributes); presentationData.addText(" (" + mySourcePath + ")", commentAttributes); }
Example #29
Source File: AbstractTreeNode.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void postprocess(@Nonnull PresentationData presentation) { if (hasProblemFileBeneath()) { presentation.setAttributesKey(FILESTATUS_ERRORS); } setForcedForeground(presentation); }
Example #30
Source File: AbstractTreeNode.java From consulo with Apache License 2.0 | 5 votes |
private void setForcedForeground(@Nonnull PresentationData presentation) { final FileStatus status = getFileStatus(); Color fgColor = getFileStatusColor(status); fgColor = fgColor == null ? status.getColor() : fgColor; if (valueIsCut()) { fgColor = CopyPasteManager.CUT_COLOR; } if (presentation.getForcedTextForeground() == null) { presentation.setForcedTextForeground(fgColor); } }