diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/TableItem.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/TableItem.java index 3ceca1542e5e..f1f171dd38d3 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/TableItem.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/TableItem.java @@ -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; } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java index fd89eb2e280c..ad3849b93b33 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java @@ -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); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java index 484e9cdbb68d..86723688984f 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java @@ -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("", 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 ""; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/ModuleDependenciesAnalyzer.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/ModuleDependenciesAnalyzer.java index 576aae2c12bb..678d6da86a1e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/ModuleDependenciesAnalyzer.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/ModuleDependenciesAnalyzer.java @@ -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); } } diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java rename to java/idea-ui/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java index 87c227c866ad..4056059cdac9 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/HttpUrlCellAppearance.java @@ -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. diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java rename to java/idea-ui/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java index cd0424a6e22a..8cf6b18eb594 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java @@ -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. diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java rename to java/idea-ui/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java index 820d6195defc..efb412c767ae 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/util/ValidFileCellAppearance.java @@ -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. diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java index c6a91c932872..4543a97691e7 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java @@ -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; diff --git a/platform/lang-impl/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java b/platform/lang-impl/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java index 0a9661e55581..75bef8e15566 100644 --- a/platform/lang-impl/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java +++ b/platform/lang-impl/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java @@ -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 { 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(); diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/ModifiableCellAppearanceEx.java b/platform/platform-api/src/com/intellij/openapi/roots/ui/ModifiableCellAppearanceEx.java new file mode 100644 index 000000000000..4d3398ee92d5 --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/roots/ui/ModifiableCellAppearanceEx.java @@ -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); +} diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CellAppearance.java b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CellAppearance.java index e6097e2f880d..5e5cb447470c 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CellAppearance.java +++ b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CellAppearance.java @@ -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(); diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CompositeAppearance.java b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CompositeAppearance.java index 9fa96bce7e2d..ec927b3894f6 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CompositeAppearance.java +++ b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/CompositeAppearance.java @@ -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 mySections = new ArrayList(); 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(appearance.mySections).equals(new ArrayList(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(appearance.mySections).equals(new ArrayList(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 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 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); } } diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ModifiableCellAppearance.java b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ModifiableCellAppearance.java index 6b47416e9278..353297d23c7c 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ModifiableCellAppearance.java +++ b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/ModifiableCellAppearance.java @@ -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(); diff --git a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/SimpleTextCellAppearance.java b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/SimpleTextCellAppearance.java index d3e91e8d27fb..e598f3f62fde 100644 --- a/platform/platform-api/src/com/intellij/openapi/roots/ui/util/SimpleTextCellAppearance.java +++ b/platform/platform-api/src/com/intellij/openapi/roots/ui/util/SimpleTextCellAppearance.java @@ -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; diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntBuildFileNodeDescriptor.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntBuildFileNodeDescriptor.java index 9e19929db773..4e44046f303b 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntBuildFileNodeDescriptor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntBuildFileNodeDescriptor.java @@ -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() { diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntNodeDescriptor.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntNodeDescriptor.java index d300b9faa5b1..d820b1478a27 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntNodeDescriptor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntNodeDescriptor.java @@ -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(); } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntTargetNodeDescriptor.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntTargetNodeDescriptor.java index a3c2581a7e65..9a2487103900 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntTargetNodeDescriptor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntTargetNodeDescriptor.java @@ -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); + } } \ No newline at end of file diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java index c70268dd5b95..86712d278ee2 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java @@ -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; }