mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use constants
This commit is contained in:
+1
-1
@@ -626,7 +626,7 @@ public String getAccessorsVisibility() {
|
||||
|
||||
private static final Icon OVERRIDING_METHOD_ICON = IconLoader.getIcon("/general/overridingMethod.png");
|
||||
private static final Icon IMPLEMENTING_METHOD_ICON = IconLoader.getIcon("/general/implementingMethod.png");
|
||||
private static final Icon EMPTY_OVERRIDE_ICON = new EmptyIcon(16, 16);
|
||||
private static final Icon EMPTY_OVERRIDE_ICON = EmptyIcon.ICON_16;
|
||||
|
||||
private class MyTableRenderer extends DefaultTableCellRenderer {
|
||||
public Component getTableCellRendererComponent(JTable table, final Object value,
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
|
||||
int flags = Iconable.ICON_FLAG_VISIBILITY;
|
||||
if (!real) {
|
||||
if (item.getObject() instanceof String) {
|
||||
return new EmptyIcon(0, 0);
|
||||
return EmptyIcon.ICON_0;
|
||||
}
|
||||
|
||||
return new EmptyIcon(SAMPLE_ICON.getIconWidth() * 2, SAMPLE_ICON.getIconHeight());
|
||||
|
||||
@@ -39,7 +39,7 @@ import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
public class LookupCellRenderer implements ListCellRenderer {
|
||||
private Icon myEmptyIcon = new EmptyIcon(5);
|
||||
private Icon myEmptyIcon = EmptyIcon.create(5);
|
||||
private final Font NORMAL_FONT;
|
||||
private final Font BOLD_FONT;
|
||||
private final FontMetrics myNormalMetrics;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import java.awt.*;
|
||||
*/
|
||||
@SuppressWarnings({"GtkPreferredJComboBoxRenderer"})
|
||||
public class InspectionListCellRenderer extends DefaultListCellRenderer {
|
||||
private static final EmptyIcon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class EditRunConfigurationsAction extends AnAction{
|
||||
public EditRunConfigurationsAction() {
|
||||
LayeredIcon icon = new LayeredIcon(2);
|
||||
icon.setIcon(IconLoader.getIcon("/actions/editSource.png"),0,2,2);
|
||||
icon.setIcon(new EmptyIcon(18), 1);
|
||||
icon.setIcon(EmptyIcon.ICON_18, 1);
|
||||
getTemplatePresentation().setIcon(icon);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.usages.impl.NullUsage;
|
||||
import com.intellij.usages.impl.UsageNode;
|
||||
import com.intellij.usages.impl.UsageViewImpl;
|
||||
import com.intellij.usages.rules.UsageInFile;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -55,8 +56,10 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0));
|
||||
Color fileBgColor = getBackgroundColor(isSelected, usage);
|
||||
panel.setBackground(isSelected ? UIUtil.getListSelectionBackground() : fileBgColor == null ? list.getBackground() : fileBgColor);
|
||||
panel.setForeground(isSelected ? UIUtil.getListSelectionForeground() : list.getForeground());
|
||||
final Color bg = UIUtil.getListSelectionBackground();
|
||||
final Color fg = UIUtil.getListSelectionForeground();
|
||||
panel.setBackground(isSelected ? bg : fileBgColor == null ? list.getBackground() : fileBgColor);
|
||||
panel.setForeground(isSelected ? fg : list.getForeground());
|
||||
|
||||
if (usage == null) {
|
||||
panel.setLayout(new BorderLayout());
|
||||
@@ -85,9 +88,11 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
TextChunk[] text = presentation.getText();
|
||||
|
||||
if (column == 1) {
|
||||
textChunks.setIcon(presentation.getIcon());
|
||||
final Icon icon = presentation.getIcon();
|
||||
textChunks.setIcon(icon == null ? EmptyIcon.ICON_16 : icon);
|
||||
if (text.length != 0) {
|
||||
SimpleTextAttributes attributes =
|
||||
SimpleTextAttributes attributes = isSelected ?
|
||||
new SimpleTextAttributes(bg, fg, fg, SimpleTextAttributes.STYLE_ITALIC) :
|
||||
deriveAttributesWithColor(SimpleTextAttributes.fromTextAttributes(text[0].getAttributes()), fileBgColor);
|
||||
textChunks.append(text[0].getText(), attributes);
|
||||
}
|
||||
@@ -96,8 +101,6 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
for (int i = 1; i < text.length; i++) {
|
||||
TextChunk textChunk = text[i];
|
||||
final SimpleTextAttributes attrs = SimpleTextAttributes.fromTextAttributes(textChunk.getAttributes());
|
||||
final Color bg = UIUtil.getListSelectionBackground();
|
||||
final Color fg = UIUtil.getListSelectionForeground();
|
||||
SimpleTextAttributes attributes = isSelected ?
|
||||
new SimpleTextAttributes(bg, fg, fg, attrs.getStyle()) : deriveAttributesWithColor(attrs, fileBgColor);
|
||||
textChunks.append(textChunk.getText(), attributes);
|
||||
|
||||
@@ -466,7 +466,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
|
||||
if (closedIcon == null && openIcon != null) closedIcon = openIcon;
|
||||
if (openIcon == null && closedIcon != null) openIcon = closedIcon;
|
||||
if (openIcon == null) {
|
||||
openIcon = closedIcon = new EmptyIcon(5, 5);
|
||||
openIcon = closedIcon = EmptyIcon.create(5);
|
||||
}
|
||||
|
||||
final MyItemLabel label =
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel {
|
||||
|
||||
private final ActionManager myActionManager = ActionManager.getInstance();
|
||||
|
||||
private static final EmptyIcon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
private String myPattern;
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public abstract class AbstractMemberSelectionTable<T extends PsiElement, M exten
|
||||
protected static final int ABSTRACT_COLUMN = 2;
|
||||
protected static final Icon OVERRIDING_METHOD_ICON = IconLoader.getIcon("/general/overridingMethod.png");
|
||||
protected static final Icon IMPLEMENTING_METHOD_ICON = IconLoader.getIcon("/general/implementingMethod.png");
|
||||
protected static final Icon EMPTY_OVERRIDE_ICON = new EmptyIcon(16, 16);
|
||||
protected static final Icon EMPTY_OVERRIDE_ICON = EmptyIcon.ICON_16;
|
||||
protected final String myAbstractColumnHeader;
|
||||
protected static final String DISPLAY_NAME_COLUMN_HEADER = RefactoringBundle.message("member.column");
|
||||
protected List<M> myMemberInfos;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
private volatile boolean myIsScheduled = false;
|
||||
private T myParam;
|
||||
private WeakReference<Component> myLastTarget = null;
|
||||
private static final EmptyIcon EMPTY_ICON = new EmptyIcon(16, 16);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_16;
|
||||
private boolean myNeedReadAction;
|
||||
private boolean myDone;
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ public abstract class FileColorSettingsTable extends StripeTable {
|
||||
|
||||
myManager = manager;
|
||||
|
||||
setIcon(new EmptyIcon(16));
|
||||
setIcon(EmptyIcon.ICON_16);
|
||||
}
|
||||
|
||||
private void setIconColor(final Color color) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ActiveIcon implements Icon {
|
||||
}
|
||||
|
||||
protected void setIcons(@Nullable final Icon regular, @Nullable final Icon inactive) {
|
||||
myRegular = regular != null ? regular : new EmptyIcon(0);
|
||||
myRegular = regular != null ? regular : EmptyIcon.ICON_0;
|
||||
myInactive = inactive != null ? inactive : myRegular;
|
||||
}
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ public class SimpleTree extends Tree implements CellEditorListener {
|
||||
public Icon getEmptyHandle() {
|
||||
if (myEmptyHandle == null) {
|
||||
final Icon expand = getExpandedHandle();
|
||||
myEmptyHandle = expand != null ? new EmptyIcon(expand) : new EmptyIcon(0, 0);
|
||||
myEmptyHandle = expand != null ? new EmptyIcon(expand) : EmptyIcon.create(0);
|
||||
}
|
||||
|
||||
return myEmptyHandle;
|
||||
|
||||
@@ -158,7 +158,7 @@ public class IconUtil {
|
||||
private static Icon createEmptyIconLike(final String baseIconPath) {
|
||||
Icon baseIcon = IconLoader.findIcon(baseIconPath);
|
||||
if (baseIcon == null) {
|
||||
return new EmptyIcon(16, 16);
|
||||
return EmptyIcon.ICON_16;
|
||||
}
|
||||
return new EmptyIcon(baseIcon.getIconWidth(), baseIcon.getIconHeight());
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class AnimatedIcon extends JComponent implements Disposable {
|
||||
if (icons.length > 0) {
|
||||
myEmptyPassiveIcon = new EmptyIcon(icons[0]);
|
||||
} else {
|
||||
myEmptyPassiveIcon = new EmptyIcon(0);
|
||||
myEmptyPassiveIcon = EmptyIcon.ICON_0;
|
||||
}
|
||||
|
||||
setOpaque(false);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class ShowFilePathAction extends AnAction {
|
||||
eachIcon = FileSystemView.getFileSystemView().getSystemIcon(ioFile);
|
||||
}
|
||||
else {
|
||||
eachIcon = new EmptyIcon(16, 16);
|
||||
eachIcon = EmptyIcon.ICON_16;
|
||||
}
|
||||
|
||||
icons.add(eachIcon);
|
||||
@@ -208,4 +208,4 @@ public class ShowFilePathAction extends AnAction {
|
||||
return PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ import java.util.Set;
|
||||
public class CustomizableActionsPanel {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.ui.customization.CustomizableActionsPanel");
|
||||
|
||||
private static final Icon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
private static final Icon QUICK_LIST_ICON = IconLoader.getIcon("/actions/quickList.png");
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.beans.PropertyChangeListener;
|
||||
public class ActionButton extends JComponent implements ActionButtonComponent {
|
||||
private static final Insets ICON_INSETS = new Insets(2, 2, 2, 2);
|
||||
|
||||
private static final Icon ourEmptyIcon = new EmptyIcon(18, 18);
|
||||
private static final Icon ourEmptyIcon = EmptyIcon.ICON_18;
|
||||
|
||||
private Dimension myMinimumButtonSize;
|
||||
private PropertyChangeListener myActionButtonSynchronizer;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ import java.util.Set;
|
||||
|
||||
public class ActionMenuItem extends JMenuItem {
|
||||
private static final Icon ourCheckedIcon = new SizedIcon(Icons.CHECK_ICON, 18, 18);
|
||||
private static final Icon ourUncheckedIcon = new EmptyIcon(18, 18);
|
||||
private static final Icon ourUncheckedIcon = EmptyIcon.ICON_18;
|
||||
|
||||
private final ActionRef<AnAction> myAction;
|
||||
private final Presentation myPresentation;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
public class FileTypeRenderer extends DefaultListCellRenderer {
|
||||
private static final Icon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
private final FileTypeListProvider myFileTypeListProvider;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class ActionsTree {
|
||||
private static final Icon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
private static final Icon QUICK_LIST_ICON = IconLoader.getIcon("/actions/quickList.png");
|
||||
private static final Icon OPEN_ICON = new DefaultTreeCellRenderer().getOpenIcon();
|
||||
private static final Icon CLOSE_ICON = new DefaultTreeCellRenderer().getClosedIcon();
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class QuickListPanel {
|
||||
private static final Icon EMPTY_ICON = new EmptyIcon(18, 18);
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
private static final Icon QUICK_LIST_ICON = IconLoader.getIcon("/actions/quickList.png");
|
||||
private JButton myRemoveActionButton;
|
||||
@@ -372,4 +372,4 @@ public class QuickListPanel {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
|
||||
public MyTitleButton(AnAction action) {
|
||||
myAction = action;
|
||||
myButton = new InplaceButton(null, new EmptyIcon(16), this) {
|
||||
myButton = new InplaceButton(null, EmptyIcon.ICON_16, this) {
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return MyTitleButton.this.isActive();
|
||||
|
||||
@@ -218,7 +218,7 @@ public class AbstractPopup implements JBPopup {
|
||||
myHeaderAlwaysFocusable = headerAlwaysFocusable;
|
||||
myMovable = movable;
|
||||
|
||||
ActiveIcon actualIcon = titleIcon == null ? new ActiveIcon(new EmptyIcon(0)) : titleIcon;
|
||||
ActiveIcon actualIcon = titleIcon == null ? new ActiveIcon(EmptyIcon.ICON_0) : titleIcon;
|
||||
|
||||
myHeaderPanel = new JPanel(new BorderLayout());
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
private IconButton myCancelButton;
|
||||
private MouseChecker myCancelOnMouseOutCallback;
|
||||
private boolean myCancelOnWindow;
|
||||
private ActiveIcon myTitleIcon = new ActiveIcon(new EmptyIcon(0));
|
||||
private ActiveIcon myTitleIcon = new ActiveIcon(EmptyIcon.ICON_0);
|
||||
private boolean myCancelKeyEnabled = true;
|
||||
private boolean myLocateByContent = false;
|
||||
private boolean myPlacewithinScreen = true;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.util.ui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ColorIcon extends EmptyIcon {
|
||||
private final Color myColor;
|
||||
|
||||
public ColorIcon(int size, @NotNull Color color) {
|
||||
super(size, size);
|
||||
myColor = color;
|
||||
}
|
||||
|
||||
public Color getIconColor() {
|
||||
return myColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
|
||||
final int iconWidth = getIconWidth();
|
||||
final int iconHeight = getIconHeight();
|
||||
g.setColor(getIconColor());
|
||||
g.fillRect(i, j, iconWidth, iconHeight);
|
||||
}
|
||||
}
|
||||
@@ -20,30 +20,56 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
* @author Konstantin Bulenkov
|
||||
*
|
||||
* @see com.intellij.util.ui.ColorIcon
|
||||
*/
|
||||
public class EmptyIcon implements Icon {
|
||||
private final int myWidth;
|
||||
private final int myHeight;
|
||||
private static final HashMap<Integer, Icon> cache = new HashMap<Integer, Icon>();
|
||||
public static final Icon ICON_16 = create(16);
|
||||
public static final Icon ICON_18 = create(18);
|
||||
public static final Icon ICON_8 = create(8);
|
||||
public static final Icon ICON_0 = create(0);
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public static Icon create(int size) {
|
||||
Icon icon = cache.get(size);
|
||||
if (icon == null && size < 129) {
|
||||
cache.put(size, icon = new EmptyIcon(size, size));
|
||||
}
|
||||
return icon == null ? new EmptyIcon(size, size) : icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use EmptyIcon.create for caching
|
||||
*
|
||||
* @param size icon's size
|
||||
*/
|
||||
public EmptyIcon(int size) {
|
||||
this(size, size);
|
||||
}
|
||||
|
||||
public EmptyIcon(int width, int height) {
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public EmptyIcon(@NotNull Icon template) {
|
||||
this(template.getIconWidth(), template.getIconHeight());
|
||||
public EmptyIcon(@NotNull Icon base) {
|
||||
this(base.getIconWidth(), base.getIconHeight());
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return myWidth;
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return myHeight;
|
||||
return height;
|
||||
}
|
||||
|
||||
public void paintIcon(Component component, Graphics g, int i, int j) {
|
||||
@@ -55,13 +81,14 @@ public class EmptyIcon implements Icon {
|
||||
|
||||
final EmptyIcon icon = (EmptyIcon)o;
|
||||
|
||||
if (myHeight != icon.myHeight) return false;
|
||||
if (myWidth != icon.myWidth) return false;
|
||||
if (height != icon.height) return false;
|
||||
if (width != icon.width) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myWidth + myHeight;
|
||||
int sum = width + height;
|
||||
return sum * (sum + 1)/2 + width;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ final class LanguageReference extends StringLiteralReference {
|
||||
// // IDEA-10012
|
||||
// return new LanguageLookupValue(s, StdFileTypes.JSP.getIcon(), "Expression Language");
|
||||
}
|
||||
return LookupElementBuilder.create(s).setIcon(new EmptyIcon(16));
|
||||
return LookupElementBuilder.create(s).setIcon(EmptyIcon.ICON_16);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ public class InjectLanguageAction implements IntentionAction {
|
||||
final Language language = InjectedLanguage.findLanguageById(value);
|
||||
assert language != null;
|
||||
final FileType ft = language.getAssociatedFileType();
|
||||
setIcon(ft != null ? ft.getIcon() : new EmptyIcon(16));
|
||||
setIcon(ft != null ? ft.getIcon() : EmptyIcon.ICON_16);
|
||||
setText(value + (ft != null ? " (" + ft.getDescription() + ")" : ""));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.ui.ColorChooser;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomManager;
|
||||
@@ -103,16 +104,8 @@ public class AndroidColorAnnotator implements Annotator {
|
||||
@NotNull
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return new EmptyIcon(ICON_SIZE) {
|
||||
@Override
|
||||
public void paintIcon(Component component, Graphics g, int i, int j) {
|
||||
Color color = getCurrentColor();
|
||||
if (color != null) {
|
||||
g.setColor(color);
|
||||
g.fillRect(i, j, getIconWidth(), getIconHeight());
|
||||
}
|
||||
}
|
||||
};
|
||||
final Color color = getCurrentColor();
|
||||
return color == null ? EmptyIcon.create(ICON_SIZE) : new ColorIcon(ICON_SIZE, color);
|
||||
}
|
||||
|
||||
// see android.graphics.Color#parseColor in android.jar library
|
||||
|
||||
Reference in New Issue
Block a user