use of com.intellij.ide.projectView.PresentationData in project intellij-community by JetBrains.
the class AbstractProjectViewPSIPane method createComponent.
@Override
public JComponent createComponent() {
if (myComponent != null)
return myComponent;
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
myTree = createTree(treeModel);
enableDnD();
myComponent = ScrollPaneFactory.createScrollPane(myTree);
if (Registry.is("error.stripe.enabled")) {
ErrorStripePainter painter = new ErrorStripePainter(true);
Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {
@Override
protected void update(ErrorStripePainter painter, int index, Object object) {
if (object instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
object = node.getUserObject();
}
if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
object = null;
}
super.update(painter, index, object);
}
@Override
protected ErrorStripe getErrorStripe(Object object) {
if (object instanceof PresentableNodeDescriptor) {
PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
PresentationData presentation = node.getPresentation();
TextAttributesKey key = presentation.getTextAttributesKey();
if (key != null) {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
return ErrorStripe.create(attributes.getEffectColor(), 1);
}
}
}
return null;
}
});
}
myTreeStructure = createStructure();
BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
installComparator(treeBuilder);
setTreeBuilder(treeBuilder);
initTree();
Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {
private boolean showing;
@Override
public void showNotify() {
if (!showing) {
showing = true;
restoreExpandedPaths();
}
}
@Override
public void hideNotify() {
if (showing) {
showing = false;
saveExpandedPaths();
}
}
}));
return myComponent;
}
use of com.intellij.ide.projectView.PresentationData in project intellij-community by JetBrains.
the class DirectoryPresentationProvider method getPresentation.
@Override
public ItemPresentation getPresentation(@NotNull final PsiDirectory directory) {
final VirtualFile vFile = directory.getVirtualFile();
final Project project = directory.getProject();
final String locationString = vFile.getPath();
if (ProjectRootsUtil.isProjectHome(directory)) {
final Icon projectIcon = PlatformUtils.isJetBrainsProduct() ? AllIcons.Nodes.IdeaProject : IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
return new PresentationData(project.getName(), locationString, projectIcon, null);
}
if (ProjectRootsUtil.isModuleContentRoot(directory)) {
final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
assert module != null : directory;
return new PresentationData(module.getName(), locationString, PlatformIcons.CONTENT_ROOT_ICON_CLOSED, null);
}
if (ProjectRootsUtil.isSourceRoot(directory)) {
SourceFolder sourceRoot = ProjectRootsUtil.getModuleSourceRoot(vFile, project);
if (sourceRoot != null) {
Icon icon = SourceRootPresentation.getSourceRootIcon(sourceRoot);
return new PresentationData(directory.getName(), locationString, icon, null);
}
}
return new PresentationData(directory.getName(), locationString, PlatformIcons.DIRECTORY_CLOSED_ICON, null);
}
use of com.intellij.ide.projectView.PresentationData in project intellij-community by JetBrains.
the class BreakpointsFavoriteListProvider method replicate.
private void replicate(DefaultMutableTreeNode source, AbstractTreeNode destination, final List<AbstractTreeNode<Object>> destinationChildren) {
final ArrayList<AbstractTreeNode<Object>> copyChildren = new ArrayList<>();
AbstractTreeNode<Object> copy = new AbstractTreeNode<Object>(myProject, source.getUserObject()) {
@NotNull
@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);
}
}
use of com.intellij.ide.projectView.PresentationData in project android by JetBrains.
the class AbstractPsModelNode method doUpdate.
@Override
protected void doUpdate() {
PresentationData presentation = getTemplatePresentation();
presentation.clearText();
presentation.addText(myName, REGULAR_ATTRIBUTES);
}
Aggregations