Java Code Examples for com.intellij.ide.projectView.PresentationData#addText()
The following examples show how to use
com.intellij.ide.projectView.PresentationData#addText() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: FileDecoration.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(getName(node), SimpleTextAttributes.REGULAR_ATTRIBUTES); data.addText(formatBranchName(status)); } }
Example 8
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 9
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 10
Source File: Utils.java From idea-gitignore with MIT License | 5 votes |
/** * Adds ColoredFragment to the node's presentation. * * @param data node's presentation data * @param text text to add * @param attributes custom {@link SimpleTextAttributes} */ public static void addColoredText(@NotNull PresentationData data, @NotNull String text, @NotNull SimpleTextAttributes attributes) { if (data.getColoredText().isEmpty()) { data.addText(data.getPresentableText(), REGULAR_ATTRIBUTES); } data.addText(" " + text, attributes); }
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: Unity3dProjectViewNodeDecorator.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void decorate(ProjectViewNode node, PresentationData data) { Project project = node.getProject(); if(project == null) { return; } VirtualFile virtualFile = node.getVirtualFile(); if(virtualFile == null || virtualFile.getFileType() != Unity3dMetaFileType.INSTANCE) { return; } Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(project); if(rootModuleExtension == null) { return; } if(Unity3dMetaFileProjectViewProvider.haveOwnerFile(virtualFile)) { return; } data.clearText(); data.addText(virtualFile.getName(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); String nameWithoutExtension = virtualFile.getNameWithoutExtension(); data.setTooltip("File(directory) '" + nameWithoutExtension + "' is not exists, meta file can be deleted."); }
Example 13
Source File: SyncStatusNodeDecorator.java From intellij with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public void decorate(ProjectViewNode node, PresentationData data) { Project project = node.getProject(); if (project == null) { return; } BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (projectData == null) { return; } PsiFileAndName fileAndName = toPsiFile(projectData, node); if (fileAndName == null) { return; } VirtualFile vf = fileAndName.psiFile.getVirtualFile(); SyncStatus status = vf == null ? null : SyncStatusContributor.getSyncStatus(project, projectData, vf); if (status == SyncStatus.UNSYNCED) { data.clearText(); data.addText(fileAndName.name, SimpleTextAttributes.GRAY_ATTRIBUTES); data.addText(" (unsynced)", SimpleTextAttributes.GRAY_ATTRIBUTES); return; } if (status == SyncStatus.IN_PROGRESS) { data.clearText(); data.addText(fileAndName.name, SimpleTextAttributes.REGULAR_ATTRIBUTES); data.addText(" (syncing...)", SimpleTextAttributes.GRAY_ATTRIBUTES); } }
Example 14
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 15
Source File: GraphQLConfigSchemaNode.java From js-graphql-intellij-plugin with MIT License | 4 votes |
@Override protected void update(PresentationData presentation) { super.update(presentation); final int style = representsCurrentFile() ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN; presentation.addText(getName(), new SimpleTextAttributes(style, getColor())); }
Example 16
Source File: TfsErrorTreeNode.java From azure-devops-intellij with MIT License | 4 votes |
@Override protected void update(final PresentationData presentation) { super.update(presentation); presentation.addText(message, getErrorAttributes()); presentation.setIcon(PlatformIcons.ERROR_INTRODUCTION_ICON); }
Example 17
Source File: DirectoryElementPresentation.java From consulo with Apache License 2.0 | 4 votes |
@Override public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { presentationData.setIcon(AllIcons.Nodes.TreeClosed); presentationData.addText(myElement.getDirectoryName(), mainAttributes); }
Example 18
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 19
Source File: CertificateTreeBuilder.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void update(PresentationData presentation) { CertificateWrapper wrapper = getElement(); SimpleTextAttributes attr = wrapper.isValid() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : STRIKEOUT_ATTRIBUTES; presentation.addText(wrapper.getSubjectField(COMMON_NAME), attr); }
Example 20
Source File: ArtifactElementPresentation.java From consulo with Apache License 2.0 | 4 votes |
public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { final Artifact artifact = findArtifact(); Image icon = artifact != null ? artifact.getArtifactType().getIcon() : AllIcons.Nodes.Artifact; presentationData.setIcon(icon); presentationData.addText(getPresentableName(), artifact != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES); }