mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Drop usages of now-unneeded HtmlListCellRenderer
This commit is contained in:
@@ -44,7 +44,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SortedComboBoxModel;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -190,9 +190,9 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
updateState();
|
||||
}
|
||||
});
|
||||
myExistingLibraryComboBox.setRenderer(new HtmlListCellRenderer() {
|
||||
myExistingLibraryComboBox.setRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null) {
|
||||
append("[No library selected]");
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class JdkChooserPanel extends JPanel {
|
||||
myListModel = new DefaultListModel();
|
||||
myList = new JBList(myListModel);
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myList.setCellRenderer(new ProjectJdkListRenderer(myList.getCellRenderer()));
|
||||
myList.setCellRenderer(new ProjectJdkListRenderer());
|
||||
|
||||
myList.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ColoredListCellRendererWrapper;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -26,11 +26,7 @@ import javax.swing.*;
|
||||
* @author Eugene Zhuravlev
|
||||
* @since May 18, 2005
|
||||
*/
|
||||
public class ProjectJdkListRenderer extends HtmlListCellRenderer {
|
||||
public ProjectJdkListRenderer(final ListCellRenderer listCellRenderer) {
|
||||
super();
|
||||
}
|
||||
|
||||
public class ProjectJdkListRenderer extends ColoredListCellRendererWrapper {
|
||||
@Override
|
||||
public void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null || value instanceof Sdk) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
super(new JdkComboBoxModel(jdkModel, filter));
|
||||
myFilter = filter;
|
||||
myCreationFilter = creationFilter;
|
||||
setRenderer(new ProjectJdkListRenderer(getRenderer()) {
|
||||
setRenderer(new ProjectJdkListRenderer() {
|
||||
@Override
|
||||
public void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (JdkComboBox.this.isEnabled()) {
|
||||
|
||||
+28
-16
@@ -19,42 +19,54 @@ package com.intellij.openapi.projectRoots.impl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColoredListCellRendererWrapper;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class SdkListCellRenderer extends HtmlListCellRenderer<Sdk> {
|
||||
private String myNullText = "";
|
||||
private boolean myShowHomePath;
|
||||
public class SdkListCellRenderer extends ColoredListCellRendererWrapper<Sdk> {
|
||||
private final String myNullText;
|
||||
private final boolean myShowHomePath;
|
||||
|
||||
public SdkListCellRenderer(final ListCellRenderer listCellRenderer) {
|
||||
super();
|
||||
public SdkListCellRenderer(@NotNull String nullText) {
|
||||
this(nullText, false);
|
||||
}
|
||||
|
||||
public SdkListCellRenderer(final String nullText, final ListCellRenderer listCellRenderer) {
|
||||
super();
|
||||
myNullText = nullText;
|
||||
}
|
||||
|
||||
public SdkListCellRenderer(final String nullText, final boolean showHomePath, final ListCellRenderer listCellRenderer) {
|
||||
super();
|
||||
public SdkListCellRenderer(@NotNull String nullText, boolean showHomePath) {
|
||||
myNullText = nullText;
|
||||
myShowHomePath = showHomePath;
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #SdkListCellRenderer(String)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public SdkListCellRenderer(final ListCellRenderer listCellRenderer) {
|
||||
this("");
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #SdkListCellRenderer(String)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public SdkListCellRenderer(final String nullText, final ListCellRenderer listCellRenderer) {
|
||||
this(nullText);
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain #SdkListCellRenderer(String, boolean)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public SdkListCellRenderer(final String nullText, final boolean showHomePath, final ListCellRenderer listCellRenderer) {
|
||||
this(nullText, showHomePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCustomize(final JList list, final Sdk sdk, final int index, final boolean selected, final boolean hasFocus) {
|
||||
if (sdk != null) {
|
||||
// icon
|
||||
setIcon(getSdkIcon(sdk));
|
||||
// text
|
||||
append(sdk.getName());
|
||||
if (myShowHomePath) {
|
||||
append(" (" + FileUtil.toSystemDependentName(sdk.getHomePath()) + ")",
|
||||
append(" (" + FileUtil.toSystemDependentName(StringUtil.notNullize(sdk.getHomePath())) + ")",
|
||||
selected ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.ui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Typed version of {@link ColoredListCellRenderer}.
|
||||
*/
|
||||
public abstract class ColoredListCellRendererWrapper<T> extends ColoredListCellRenderer {
|
||||
@Override
|
||||
protected final void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
@SuppressWarnings("unchecked") final T t = (T)value;
|
||||
doCustomize(list, t, index, selected, hasFocus);
|
||||
}
|
||||
|
||||
protected abstract void doCustomize(JList list, T value, int index, boolean selected, boolean hasFocus);
|
||||
|
||||
public void append(@NotNull SimpleColoredText text) {
|
||||
int length = text.getTexts().size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String fragment = text.getTexts().get(i);
|
||||
SimpleTextAttributes attributes = text.getAttributes().get(i);
|
||||
append(fragment, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -21,7 +21,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ColoredListCellRendererWrapper;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.ui.OptionsDialog;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -103,7 +103,7 @@ public class ReadOnlyStatusDialog extends OptionsDialog {
|
||||
final String defaultChangelist = handleType.getDefaultChangelist();
|
||||
myChangelist.setModel(new CollectionComboBoxModel(changelists, defaultChangelist));
|
||||
|
||||
myChangelist.setRenderer(new HtmlListCellRenderer<String>() {
|
||||
myChangelist.setRenderer(new ColoredListCellRendererWrapper<String>() {
|
||||
@Override
|
||||
protected void doCustomize(JList list, String value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value.equals(defaultChangelist)) {
|
||||
|
||||
+2
-23
@@ -18,7 +18,6 @@ package com.intellij.openapi.vcs.changes.issueLinks;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vcs.IssueNavigationConfiguration;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -31,18 +30,10 @@ import java.util.List;
|
||||
*/
|
||||
public class IssueLinkRenderer {
|
||||
private final SimpleColoredComponent myColoredComponent;
|
||||
private final HtmlListCellRenderer myHtmlListCellRenderer;
|
||||
private final IssueNavigationConfiguration myIssueNavigationConfiguration;
|
||||
|
||||
public IssueLinkRenderer(final Project project, final SimpleColoredComponent coloredComponent) {
|
||||
myColoredComponent = coloredComponent;
|
||||
myHtmlListCellRenderer = null;
|
||||
myIssueNavigationConfiguration = IssueNavigationConfiguration.getInstance(project);
|
||||
}
|
||||
|
||||
public IssueLinkRenderer(final Project project, final HtmlListCellRenderer htmlListCellRenderer) {
|
||||
myColoredComponent = null;
|
||||
myHtmlListCellRenderer = htmlListCellRenderer;
|
||||
myIssueNavigationConfiguration = IssueNavigationConfiguration.getInstance(project);
|
||||
}
|
||||
|
||||
@@ -70,7 +61,6 @@ public class IssueLinkRenderer {
|
||||
final String piece = text.substring(pos, textRange.getStartOffset());
|
||||
pieces.add(piece);
|
||||
consumer.consume(piece);
|
||||
//append(piece, baseStyle);
|
||||
}
|
||||
final String piece = textRange.substring(text);
|
||||
pieces.add(piece);
|
||||
@@ -81,27 +71,16 @@ public class IssueLinkRenderer {
|
||||
final String piece = text.substring(pos);
|
||||
pieces.add(piece);
|
||||
consumer.consume(piece);
|
||||
//append(piece, baseStyle);
|
||||
}
|
||||
return pieces;
|
||||
}
|
||||
|
||||
private void append(final String piece, final SimpleTextAttributes baseStyle) {
|
||||
if (myColoredComponent != null) {
|
||||
myColoredComponent.append(piece, baseStyle);
|
||||
}
|
||||
else {
|
||||
myHtmlListCellRenderer.append(piece, baseStyle);
|
||||
}
|
||||
myColoredComponent.append(piece, baseStyle);
|
||||
}
|
||||
|
||||
private void append(final String piece, final SimpleTextAttributes baseStyle, final IssueNavigationConfiguration.LinkMatch match) {
|
||||
if (myColoredComponent != null) {
|
||||
myColoredComponent.append(piece, baseStyle, new SimpleColoredComponent.BrowserLauncherTag(match.getTargetUrl()));
|
||||
}
|
||||
else {
|
||||
myHtmlListCellRenderer.appendLink(piece, baseStyle, match.getTargetUrl());
|
||||
}
|
||||
myColoredComponent.append(piece, baseStyle, new SimpleColoredComponent.BrowserLauncherTag(match.getTargetUrl()));
|
||||
}
|
||||
|
||||
private static SimpleTextAttributes getLinkAttributes(final SimpleTextAttributes baseStyle) {
|
||||
|
||||
+5
-4
@@ -71,7 +71,7 @@ public class ChangeListChooserPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
myExistingListsCombo.setRenderer(new HtmlListCellRenderer() {
|
||||
myExistingListsCombo.setRenderer(new ColoredListCellRendererWrapper() {
|
||||
private final IssueLinkRenderer myLinkRenderer = new IssueLinkRenderer(myProject, this);
|
||||
|
||||
@Override
|
||||
@@ -81,7 +81,8 @@ public class ChangeListChooserPanel extends JPanel {
|
||||
|
||||
if (myExistingListsCombo.getWidth() == 0) {
|
||||
name = name.length() > 10 ? name.substring(0, 7) + " .." : name;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final FontMetrics fm = list.getFontMetrics(list.getFont());
|
||||
final int width = fm.stringWidth(name);
|
||||
final int listWidth = myExistingListsCombo.getWidth();
|
||||
@@ -92,8 +93,8 @@ public class ChangeListChooserPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
myLinkRenderer.appendTextWithLinks(name, ((LocalChangeList)value).isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
|
||||
: SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
myLinkRenderer.appendTextWithLinks(name, ((LocalChangeList)value).isDefault()
|
||||
? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.actions.MoveChangesToAnotherListAction;
|
||||
import com.intellij.openapi.vcs.changes.actions.RollbackDialogAction;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ColoredListCellRendererWrapper;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -230,7 +230,7 @@ public class MultipleChangeListBrowser extends ChangesBrowser {
|
||||
public ChangeListChooser(List<? extends ChangeList> lists) {
|
||||
super(new BorderLayout(4, 2));
|
||||
myChooser = new JComboBox();
|
||||
myChooser.setRenderer(new HtmlListCellRenderer<LocalChangeList>() {
|
||||
myChooser.setRenderer(new ColoredListCellRendererWrapper<LocalChangeList>() {
|
||||
@Override
|
||||
protected void doCustomize(JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value != null) {
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.ui.ColoredListCellRendererWrapper;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ShiftTabAction;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
|
||||
@@ -55,7 +55,7 @@ public class LanguagePanel extends AbstractInjectionPanel<BaseInjection> {
|
||||
Arrays.sort(languageIDs);
|
||||
|
||||
myLanguage.setModel(new DefaultComboBoxModel(languageIDs));
|
||||
myLanguage.setRenderer(new HtmlListCellRenderer<String>() {
|
||||
myLanguage.setRenderer(new ColoredListCellRendererWrapper<String>() {
|
||||
final Set<String> IDs = new HashSet<String>(Arrays.asList(languageIDs));
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,8 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -87,14 +88,12 @@ public class ExtendedDeviceChooserDialog extends DialogWrapper {
|
||||
};
|
||||
Disposer.register(myDisposable, myAvdCombo);
|
||||
|
||||
|
||||
myAvdCombo.getComboBox().setRenderer(new HtmlListCellRenderer() {
|
||||
myAvdCombo.getComboBox().setRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null) {
|
||||
setText(myAvdCombo.getComboBox().isEnabled()
|
||||
? "<html><font color='red'>[none]</font></html>"
|
||||
: "[none]");
|
||||
append("[none]",
|
||||
myAvdCombo.getComboBox().isEnabled() ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user