make icons a bit lazier to reduce class load time

This commit is contained in:
Alexey Kudravtsev
2017-04-26 13:38:44 +03:00
parent 551d75ef9c
commit 95207fd561
6 changed files with 12 additions and 27 deletions
@@ -49,7 +49,6 @@ import java.awt.*;
import java.io.File;
public class OrderEntryAppearanceServiceImpl extends OrderEntryAppearanceService {
private static final Icon EXCLUDE_FOLDER_ICON = IconLoader.getDisabledIcon(PlatformIcons.FOLDER_ICON);
private static final String NO_JDK = ProjectBundle.message("jdk.missing.item");
@@ -162,7 +161,7 @@ public class OrderEntryAppearanceServiceImpl extends OrderEntryAppearanceService
return formatRelativePath(folder, PlatformIcons.FOLDER_ICON);
}
else if (folder instanceof ExcludeFolder) {
return formatRelativePath(folder, EXCLUDE_FOLDER_ICON);
return formatRelativePath(folder, IconLoader.getDisabledIcon(PlatformIcons.FOLDER_ICON));
}
else {
throw new RuntimeException(folder.getClass().getName());
@@ -23,8 +23,6 @@ import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.SizedIcon;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBUI.ScalableJBIcon;
import com.intellij.util.ui.JBUI.ScalableJBIcon.Scale;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -34,7 +32,6 @@ import javax.swing.*;
*/
public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>{
public static final DefaultLookupItemRenderer INSTANCE = new DefaultLookupItemRenderer();
private static final Icon SAMPLE_ICON = PlatformIcons.CLASS_ICON;
@Override
public void renderElement(final LookupItem item, final LookupElementPresentation presentation) {
@@ -50,8 +47,8 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
public static Icon getRawIcon(final LookupElement item, boolean real) {
Icon icon = _getRawIcon(item, real);
if (icon instanceof ScalableIcon) icon = ((ScalableIcon)icon).scale(1f);
if (icon != null && icon.getIconHeight() > SAMPLE_ICON.getIconHeight()) {
return new SizedIcon(icon, icon.getIconWidth(), SAMPLE_ICON.getIconHeight());
if (icon != null && icon.getIconHeight() > PlatformIcons.CLASS_ICON.getIconHeight()) {
return new SizedIcon(icon, icon.getIconWidth(), PlatformIcons.CLASS_ICON.getIconHeight());
}
return icon;
}
@@ -70,7 +67,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
return EmptyIcon.ICON_0;
}
return EmptyIcon.create(SAMPLE_ICON.getIconWidth() * 2, SAMPLE_ICON.getIconHeight());
return EmptyIcon.create(PlatformIcons.CLASS_ICON.getIconWidth() * 2, PlatformIcons.CLASS_ICON.getIconHeight());
}
if (o instanceof Iconable && !(o instanceof PsiElement)) {
@@ -68,11 +68,6 @@ import static com.intellij.ui.RowsDnDSupport.RefinedDropSupport.Position.*;
class RunConfigurable extends BaseConfigurable {
private static final Icon ADD_ICON = IconUtil.getAddIcon();
private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon();
private static final Icon SHARED_ICON = AllIcons.Nodes.Shared;
private static final Icon NON_SHARED_ICON = EmptyIcon.ICON_16;
@NonNls private static final Object DEFAULTS = new Object() {
@Override
public String toString() {
@@ -194,7 +189,7 @@ class RunConfigurable extends BaseConfigurable {
}
if (shared != null) {
Icon icon = getIcon();
LayeredIcon layeredIcon = new LayeredIcon(icon, shared ? SHARED_ICON : NON_SHARED_ICON);
LayeredIcon layeredIcon = new LayeredIcon(icon, shared ? AllIcons.Nodes.Shared : EmptyIcon.ICON_16);
setIcon(layeredIcon);
setIconTextGap(0);
} else {
@@ -491,7 +486,7 @@ class RunConfigurable extends BaseConfigurable {
panel.setBorder(new EmptyBorder(30, 0, 0, 0));
panel.add(new JLabel("Press the"));
ActionLink addIcon = new ActionLink("", ADD_ICON, myAddAction);
ActionLink addIcon = new ActionLink("", IconUtil.getAddIcon(), myAddAction);
addIcon.setBorder(new EmptyBorder(0, 0, 0, 5));
panel.add(addIcon);
@@ -1104,7 +1099,7 @@ class RunConfigurable extends BaseConfigurable {
private class MyToolbarAddAction extends AnAction implements AnActionButtonRunnable {
public MyToolbarAddAction() {
super(ExecutionBundle.message("add.new.run.configuration.acrtion.name"),
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), ADD_ICON);
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), IconUtil.getAddIcon());
registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
@@ -1162,7 +1157,7 @@ class RunConfigurable extends BaseConfigurable {
public MyRemoveAction() {
super(ExecutionBundle.message("remove.run.configuration.action.name"),
ExecutionBundle.message("remove.run.configuration.action.name"), REMOVE_ICON);
ExecutionBundle.message("remove.run.configuration.action.name"), IconUtil.getRemoveIcon());
registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree);
}
@@ -154,13 +154,11 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final Map<String, AbstractProjectViewPane> myId2Pane = new LinkedHashMap<>();
private final Collection<AbstractProjectViewPane> myUninitializedPanes = new THashSet<>();
static final DataKey<ProjectViewImpl> DATA_KEY = DataKey.create("com.intellij.ide.projectView.impl.ProjectViewImpl");
private static final DataKey<ProjectViewImpl> DATA_KEY = DataKey.create("com.intellij.ide.projectView.impl.ProjectViewImpl");
private DefaultActionGroup myActionGroup;
private String mySavedPaneId = ProjectViewPane.ID;
private String mySavedPaneSubId;
//private static final Icon COMPACT_EMPTY_MIDDLE_PACKAGES_ICON = IconLoader.getIcon("/objectBrowser/compactEmptyPackages.png");
//private static final Icon HIDE_EMPTY_MIDDLE_PACKAGES_ICON = IconLoader.getIcon("/objectBrowser/hideEmptyPackages.png");
@NonNls private static final String ELEMENT_NAVIGATOR = "navigator";
@NonNls private static final String ELEMENT_PANES = "panes";
@NonNls private static final String ELEMENT_PANE = "pane";
@@ -44,8 +44,6 @@ import static java.awt.event.KeyEvent.VK_SPACE;
public class ActionButton extends JComponent implements ActionButtonComponent, AnActionHolder, Accessible {
private static final Icon ourEmptyIcon = EmptyIcon.ICON_18;
private JBDimension myMinimumButtonSize;
private PropertyChangeListener myPresentationListener;
private Icon myDisabledIcon;
@@ -243,7 +241,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
*/
protected Icon getIcon() {
Icon icon = isButtonEnabled() ? myIcon : myDisabledIcon;
return icon == null ? ourEmptyIcon : icon;
return icon == null ? EmptyIcon.ICON_18 : icon;
}
public void updateIcon() {
+2 -4
View File
@@ -81,8 +81,6 @@ import java.util.zip.ZipFile;
* @since Nov 22, 2004
*/
public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType {
private static final Icon ADD_SDK = DevkitIcons.Add_sdk;
private static final Icon SDK_CLOSED = DevkitIcons.Sdk_closed;
private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.devkit.projectRoots.IdeaJdk");
@NonNls private static final String LIB_DIR_NAME = "lib";
@@ -95,7 +93,7 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType {
@Override
public Icon getIcon() {
return SDK_CLOSED;
return DevkitIcons.Sdk_closed;
}
@NotNull
@@ -107,7 +105,7 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType {
@Override
@NotNull
public Icon getIconForAddAction() {
return ADD_SDK;
return DevkitIcons.Add_sdk;
}
@Override