mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migration to cell appearance services
This commit is contained in:
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class TableItem {
|
||||
private final String myUrl;
|
||||
private final CellAppearance myCellAppearance;
|
||||
private final CellAppearanceEx myCellAppearance;
|
||||
|
||||
public TableItem(@NotNull final VirtualFile file) {
|
||||
myUrl = file.getUrl();
|
||||
@@ -48,7 +48,7 @@ class TableItem {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CellAppearance getCellAppearance() {
|
||||
public CellAppearanceEx getCellAppearance() {
|
||||
return myCellAppearance;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.dependencyAnalysis.AnalyzeDependenciesDialog;
|
||||
@@ -39,7 +40,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryPro
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.SdkProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -625,9 +625,9 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
return elements;
|
||||
}
|
||||
|
||||
private static CellAppearance getCellAppearance(final ClasspathTableItem<?> item,
|
||||
final StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
private static CellAppearanceEx getCellAppearance(final ClasspathTableItem<?> item,
|
||||
final StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
final OrderEntryAppearanceService service = OrderEntryAppearanceService.getInstance(context.getProject());
|
||||
if (item instanceof InvalidJdkItem) {
|
||||
return service.forJdk(null, false, selected, true);
|
||||
|
||||
+20
-13
@@ -27,18 +27,15 @@ import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.openapi.roots.ModuleSourceOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -138,7 +135,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
if (value instanceof MyNode && !(value instanceof MyRootNode)) {
|
||||
final MyNode node = (MyNode)value;
|
||||
PathNode<?> n = (PathNode<?>)node.getUserObject();
|
||||
CellAppearance a = n.getAppearance(selected, node.isDisplayInBold());
|
||||
CellAppearanceEx a = n.getAppearance(selected, node.isDisplayInBold());
|
||||
a.customize(this);
|
||||
}
|
||||
}
|
||||
@@ -466,13 +463,13 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appearance for renderring in master list
|
||||
* Get appearance for rendering in master list
|
||||
*
|
||||
* @param selected true if selected
|
||||
* @param bold true if bold
|
||||
* @return the result appearance
|
||||
*/
|
||||
public abstract CellAppearance getAppearance(boolean selected, boolean bold);
|
||||
public abstract CellAppearanceEx getAppearance(boolean selected, boolean bold);
|
||||
|
||||
/**
|
||||
* @retrun the string cut so it would fit the banner (the prefix is dropped)
|
||||
@@ -514,7 +511,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
return;
|
||||
}
|
||||
ModuleDependenciesAnalyzer.OrderPathElement e = (ModuleDependenciesAnalyzer.OrderPathElement)userObject;
|
||||
final CellAppearance appearance = e.getAppearance(selected);
|
||||
final CellAppearanceEx appearance = e.getAppearance(selected);
|
||||
appearance.customize(this);
|
||||
}
|
||||
}
|
||||
@@ -538,8 +535,8 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean selected, final boolean isBold) {
|
||||
return new CellAppearance() {
|
||||
public CellAppearanceEx getAppearance(boolean selected, final boolean isBold) {
|
||||
return new CellAppearanceEx() {
|
||||
@Override
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
component.setIcon(getIcon());
|
||||
@@ -556,6 +553,11 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
component.append(" (" + PathUtil.getParentPath(p) + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
throw new UnsupportedOperationException("Rendering in combo box not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return getDisplayName();
|
||||
@@ -611,17 +613,22 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean selected, final boolean isBold) {
|
||||
public CellAppearanceEx getAppearance(boolean selected, final boolean isBold) {
|
||||
if (myExplanation.entry() instanceof ModuleSourceOrderEntry) {
|
||||
ModuleSourceOrderEntry e = (ModuleSourceOrderEntry)myExplanation.entry();
|
||||
if (e.getOwnerModule() == myModule) {
|
||||
return new CellAppearance() {
|
||||
return new CellAppearanceEx() {
|
||||
@Override
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
component.setIcon(ModuleType.get(myModule).getNodeIcon(false));
|
||||
component.append("<This Module>", SimpleTextAttributes.SYNTHETIC_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
throw new UnsupportedOperationException("Rendering in combo box not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "<This Module>";
|
||||
|
||||
+4
-4
@@ -18,8 +18,8 @@ package com.intellij.openapi.roots.ui.configuration.dependencyAnalysis;
|
||||
import com.intellij.ide.presentation.VirtualFilePresentation;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -202,7 +202,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
if (!myProduction || !myCompile) {
|
||||
CompilerModuleExtension e = CompilerModuleExtension.getInstance(m);
|
||||
final OrderPath p = new OrderPath(myStack);
|
||||
for (String u : e.getOutputRootUrls(!myCompile ? !myProduction : level > 0 ? !myProduction : false)) {
|
||||
for (String u : e.getOutputRootUrls(!myCompile ? !myProduction : level > 0 && !myProduction)) {
|
||||
addUrlPath(p, u);
|
||||
}
|
||||
addEntryPath(orderEntry, p);
|
||||
@@ -307,7 +307,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
* @return the appearance to use for rendering
|
||||
*/
|
||||
@NotNull
|
||||
public abstract CellAppearance getAppearance(boolean isSelected);
|
||||
public abstract CellAppearanceEx getAppearance(boolean isSelected);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,7 +368,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean isSelected) {
|
||||
public CellAppearanceEx getAppearance(boolean isSelected) {
|
||||
return OrderEntryAppearanceService.getInstance(myEntry.getOwnerModule().getProject()).forOrderEntry(myEntry, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,14 @@
|
||||
package com.intellij.ide.structureView.impl;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.ModifiableCellAppearance;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDocCommentOwner;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMember;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
|
||||
@@ -32,24 +32,16 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
public class StructureNodeRenderer extends ColoredTreeCellRenderer {
|
||||
public void customizeCellRenderer(
|
||||
JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus
|
||||
) {
|
||||
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
forNodeDescriptorInTree(value, expanded).customize(this);
|
||||
}
|
||||
|
||||
public static CellAppearance forNodeDescriptorInTree(Object node, boolean expanded) {
|
||||
public static CellAppearanceEx forNodeDescriptorInTree(Object node, boolean expanded) {
|
||||
NodeDescriptor descriptor = getNodeDescriptor(node);
|
||||
if (descriptor == null) return FileAppearanceService.getInstance().empty();
|
||||
String name = descriptor.toString();
|
||||
Object psiElement = descriptor.getElement();
|
||||
ModifiableCellAppearance result;
|
||||
ModifiableCellAppearanceEx result;
|
||||
if (psiElement instanceof PsiElement && !((PsiElement)psiElement).isValid()) {
|
||||
result = CompositeAppearance.single(name);
|
||||
}
|
||||
@@ -72,32 +64,6 @@ public class StructureNodeRenderer extends ColoredTreeCellRenderer {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static CellAppearance forElementInClass(PsiMember psiMember, PsiClass psiClass) {
|
||||
boolean isOwnMethod = psiMember.getContainingClass().getQualifiedName().equals(psiClass.getQualifiedName());
|
||||
String name = getNameOf(psiMember);
|
||||
psiMember.getIcon(Iconable.ICON_FLAG_VISIBILITY);
|
||||
if (isOwnMethod) {
|
||||
return CompositeAppearance.single(name, applyDeprecation(psiMember, SimpleTextAttributes.REGULAR_ATTRIBUTES));
|
||||
} else {
|
||||
CompositeAppearance.DequeEnd ending = new CompositeAppearance().getEnding();
|
||||
ending.addText(name, applyDeprecation(psiMember, SimpleTextAttributes.DARK_TEXT));
|
||||
ending.addComment(psiClass.getName(), applyDeprecation(psiClass, SimpleTextAttributes.GRAY_ATTRIBUTES));
|
||||
return ending.getAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getNameOf(PsiElement psiElement) {
|
||||
if (psiElement instanceof PsiMethod)
|
||||
return PsiFormatUtil.formatMethod((PsiMethod)psiElement,
|
||||
PsiSubstitutor.EMPTY,
|
||||
PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER |
|
||||
PsiFormatUtilBase.SHOW_PARAMETERS,
|
||||
PsiFormatUtilBase.SHOW_TYPE
|
||||
);
|
||||
return psiElement.toString();
|
||||
}
|
||||
|
||||
|
||||
private static boolean isInheritedMember(Object node, PsiClass psiClass) {
|
||||
PsiClass treeParentClass = getTreeParentClass(node);
|
||||
return treeParentClass != psiClass;
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -301,7 +301,7 @@ public abstract class ChooseLibrariesDialogBase extends DialogWrapper {
|
||||
private static class LibraryDescriptor extends LibrariesTreeNodeBase<Library> {
|
||||
protected LibraryDescriptor(final Project project, final NodeDescriptor parentDescriptor, final Library element) {
|
||||
super(project, parentDescriptor, element);
|
||||
final CellAppearance appearance = OrderEntryAppearanceService.getInstance(project).forLibrary(element, false);
|
||||
final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance(project).forLibrary(element, false);
|
||||
final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
|
||||
appearance.customize(coloredComponent);
|
||||
final PresentationData templatePresentation = getTemplatePresentation();
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public interface ModifiableCellAppearanceEx extends CellAppearanceEx {
|
||||
void setIcon(@Nullable Icon icon);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,9 @@ package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain com.intellij.openapi.roots.ui.CellAppearanceEx} (to remove in IDEA 12).
|
||||
*/
|
||||
public interface CellAppearance {
|
||||
void customize(SimpleColoredComponent component);
|
||||
String getText();
|
||||
|
||||
+55
-41
@@ -17,7 +17,7 @@ package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -31,54 +31,66 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
// todo: move to lang-impl ?
|
||||
public class CompositeAppearance implements ModifiableCellAppearance, CellAppearanceEx {
|
||||
public class CompositeAppearance implements ModifiableCellAppearanceEx, ModifiableCellAppearance {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.util.CompositeAppearance");
|
||||
|
||||
private Icon myIcon;
|
||||
private final ArrayList<TextSection> mySections = new ArrayList<TextSection>();
|
||||
private int myInsertionIndex = 0;
|
||||
|
||||
public synchronized void customize(SimpleColoredComponent component) {
|
||||
for (TextSection section : mySections) {
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
component.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
synchronized (mySections) {
|
||||
for (TextSection section : mySections) {
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
component.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
}
|
||||
component.setIcon(myIcon);
|
||||
}
|
||||
component.setIcon(myIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
for (TextSection section : mySections) {
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
renderer.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
synchronized (mySections) {
|
||||
for (TextSection section : mySections) {
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
renderer.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
}
|
||||
setIcon(myIcon);
|
||||
}
|
||||
setIcon(myIcon);
|
||||
}
|
||||
|
||||
public synchronized Icon getIcon() {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public synchronized void setIcon(@Nullable final Icon icon) {
|
||||
myIcon = icon;
|
||||
}
|
||||
|
||||
public synchronized String getText() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (TextSection section : mySections) {
|
||||
buffer.append(section.TEXT);
|
||||
public Icon getIcon() {
|
||||
synchronized (mySections) {
|
||||
return myIcon;
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public synchronized boolean equals(Object obj) {
|
||||
if (!(obj instanceof CompositeAppearance)) return false;
|
||||
CompositeAppearance appearance = (CompositeAppearance)obj;
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
return appearance.mySections.equals(mySections);
|
||||
public void setIcon(@Nullable final Icon icon) {
|
||||
synchronized (mySections) {
|
||||
myIcon = icon;
|
||||
}
|
||||
else {
|
||||
return new ArrayList<TextSection>(appearance.mySections).equals(new ArrayList<TextSection>(mySections));
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
synchronized (mySections) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (TextSection section : mySections) {
|
||||
buffer.append(section.TEXT);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
synchronized (mySections) {
|
||||
if (!(obj instanceof CompositeAppearance)) return false;
|
||||
CompositeAppearance appearance = (CompositeAppearance)obj;
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
return appearance.mySections.equals(mySections);
|
||||
}
|
||||
else {
|
||||
return new ArrayList<TextSection>(appearance.mySections).equals(new ArrayList<TextSection>(mySections));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +98,15 @@ public class CompositeAppearance implements ModifiableCellAppearance, CellAppear
|
||||
return getText().hashCode();
|
||||
}
|
||||
|
||||
protected synchronized void addSectionAt(int index, @NotNull TextSection section) {
|
||||
mySections.add(index, section);
|
||||
for (Iterator<TextSection> iterator = mySections.iterator(); iterator.hasNext();) {
|
||||
TextSection textSection = iterator.next();
|
||||
if (textSection == null) {
|
||||
LOG.error("index: " + index + " size: " + mySections.size());
|
||||
iterator.remove();
|
||||
protected void addSectionAt(int index, @NotNull TextSection section) {
|
||||
synchronized (mySections) {
|
||||
mySections.add(index, section);
|
||||
for (Iterator<TextSection> iterator = mySections.iterator(); iterator.hasNext();) {
|
||||
TextSection textSection = iterator.next();
|
||||
if (textSection == null) {
|
||||
LOG.error("index: " + index + " size: " + mySections.size());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +217,7 @@ public class CompositeAppearance implements ModifiableCellAppearance, CellAppear
|
||||
|
||||
private class DequeBeginning extends DequeEnd {
|
||||
public void addSection(TextSection section) {
|
||||
synchronized (CompositeAppearance.this) {
|
||||
synchronized (mySections) {
|
||||
addSectionAt(0, section);
|
||||
myInsertionIndex++;
|
||||
}
|
||||
@@ -212,7 +226,7 @@ public class CompositeAppearance implements ModifiableCellAppearance, CellAppear
|
||||
|
||||
private class DequeEnding extends DequeEnd {
|
||||
public void addSection(TextSection section) {
|
||||
synchronized (CompositeAppearance.this) {
|
||||
synchronized (mySections) {
|
||||
addSectionAt(myInsertionIndex, section);
|
||||
myInsertionIndex++;
|
||||
}
|
||||
@@ -221,7 +235,7 @@ public class CompositeAppearance implements ModifiableCellAppearance, CellAppear
|
||||
|
||||
private class DequeSuffix extends DequeEnd {
|
||||
public void addSection(TextSection section) {
|
||||
synchronized (CompositeAppearance.this) {
|
||||
synchronized (mySections) {
|
||||
addSectionAt(mySections.size(), section);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
* @deprecated please use {@linkplain com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx} (to remove in IDEA 12).
|
||||
*/
|
||||
public interface ModifiableCellAppearance extends CellAppearance {
|
||||
Icon getIcon();
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
|
||||
// todo: move to lang-impl ?
|
||||
public class SimpleTextCellAppearance implements ModifiableCellAppearance, CellAppearanceEx {
|
||||
public class SimpleTextCellAppearance implements ModifiableCellAppearanceEx, ModifiableCellAppearance {
|
||||
private Icon myIcon;
|
||||
private final SimpleTextAttributes myTextAttributes;
|
||||
private final String myText;
|
||||
|
||||
+19
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -61,8 +63,22 @@ final class AntBuildFileNodeDescriptor extends AntNodeDescriptor {
|
||||
}
|
||||
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
if (myAppearance != null) myAppearance.customize(component);
|
||||
else super.customize(component);
|
||||
if (myAppearance != null) {
|
||||
myAppearance.customize(component);
|
||||
}
|
||||
else {
|
||||
super.customize(component);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
if (myAppearance != null) {
|
||||
myAppearance.customize(renderer);
|
||||
}
|
||||
else {
|
||||
super.customize(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAutoExpand() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,11 +17,13 @@ package com.intellij.lang.ant.config.explorer;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
abstract class AntNodeDescriptor extends NodeDescriptor implements CellAppearance {
|
||||
abstract class AntNodeDescriptor extends NodeDescriptor implements CellAppearanceEx {
|
||||
public AntNodeDescriptor(Project project, NodeDescriptor parentDescriptor) {
|
||||
super(project, parentDescriptor);
|
||||
}
|
||||
@@ -32,6 +34,11 @@ abstract class AntNodeDescriptor extends NodeDescriptor implements CellAppearanc
|
||||
component.append(toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
renderer.append(toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,12 +30,14 @@ import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -127,7 +129,7 @@ final class AntTargetNodeDescriptor extends AntNodeDescriptor {
|
||||
} else return false;
|
||||
}
|
||||
|
||||
public CellAppearance getHighlightedText() {
|
||||
public CellAppearanceEx getHighlightedText() {
|
||||
return myHighlightedText;
|
||||
}
|
||||
|
||||
@@ -141,4 +143,12 @@ final class AntTargetNodeDescriptor extends AntNodeDescriptor {
|
||||
String toolTipText = getTarget().getNotEmptyDescription();
|
||||
component.setToolTipText(toolTipText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
getHighlightedText().customize(renderer);
|
||||
renderer.setIcon(getOpenIcon());
|
||||
String toolTipText = getTarget().getNotEmptyDescription();
|
||||
renderer.setToolTipText(toolTipText);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.ModifiableCellAppearance;
|
||||
import com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -75,8 +75,8 @@ public class AllJarsUnderDirEntry implements AntClasspathEntry {
|
||||
|
||||
public CellAppearanceEx getAppearance() {
|
||||
CellAppearanceEx appearance = FileAppearanceService.getInstance().forIoFile(myDir);
|
||||
if (appearance instanceof ModifiableCellAppearance) {
|
||||
((ModifiableCellAppearance)appearance).setIcon(ALL_JARS_IN_DIR_ICON);
|
||||
if (appearance instanceof ModifiableCellAppearanceEx) {
|
||||
((ModifiableCellAppearanceEx)appearance).setIcon(ALL_JARS_IN_DIR_ICON);
|
||||
}
|
||||
return appearance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user