always use getIcon instead of findIcon

This commit is contained in:
Alexey Kudravtsev
2009-09-30 18:06:58 +04:00
parent aee3c19478
commit 90fbcd9e76
24 changed files with 64 additions and 59 deletions
@@ -465,7 +465,7 @@ public class OverrideImplementUtil {
super.fillToolbarActions(group);
if (toImplement) return;
final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement", IconLoader.findIcon("/general/show_to_implement.png")) {
final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement", IconLoader.getIcon("/general/show_to_implement.png")) {
@Override
public boolean isSelected(AnActionEvent e) {
return merge.get().booleanValue();
@@ -598,7 +598,7 @@ public class EditorSearchComponent extends JPanel implements DataProvider {
private class ShowHistoryAction extends AnAction implements DumbAware {
private ShowHistoryAction() {
getTemplatePresentation().setIcon(IconLoader.findIcon("/actions/search.png"));
getTemplatePresentation().setIcon(IconLoader.getIcon("/actions/search.png"));
getTemplatePresentation().setDescription("Search history");
getTemplatePresentation().setText("Search History");
@@ -619,7 +619,7 @@ public class EditorSearchComponent extends JPanel implements DataProvider {
private class FindAllAction extends AnAction implements DumbAware {
private FindAllAction() {
getTemplatePresentation().setIcon(IconLoader.findIcon("/actions/export.png"));
getTemplatePresentation().setIcon(IconLoader.getIcon("/actions/export.png"));
getTemplatePresentation().setDescription("Export matches to Find tool window");
getTemplatePresentation().setText("Find All");
registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES).getShortcutSet(), mySearchField);
@@ -37,10 +37,7 @@ public class RawCommandLineEditor extends JPanel {
Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow");
}
});
final Icon icon = IconLoader.findIcon("/actions/showViewer.png");
if (icon != null) {
myTextField.setButtonIcon(icon);
}
myTextField.setButtonIcon(IconLoader.getIcon("/actions/showViewer.png"));
add(myTextField, BorderLayout.CENTER);
setDescriptor(null);
}
@@ -78,7 +78,7 @@ public class SearchTextField extends JPanel {
}
}
else {
myToggleHistoryLabel = new JLabel(IconLoader.findIcon("/actions/search.png"));
myToggleHistoryLabel = new JLabel(IconLoader.getIcon("/actions/search.png"));
myToggleHistoryLabel.setOpaque(true);
myToggleHistoryLabel.setBackground(myTextField.getBackground());
myToggleHistoryLabel.addMouseListener(new MouseAdapter() {
@@ -90,7 +90,7 @@ public class SearchTextField extends JPanel {
add(myToggleHistoryLabel, BorderLayout.WEST);
}
myClearFieldLabel = new JLabel(IconLoader.findIcon("/actions/cleanLight.png"));
myClearFieldLabel = new JLabel(IconLoader.getIcon("/actions/cleanLight.png"));
myClearFieldLabel.setOpaque(true);
myClearFieldLabel.setBackground(myTextField.getBackground());
add(myClearFieldLabel, BorderLayout.EAST);
@@ -363,4 +363,4 @@ public class SearchTextField extends JPanel {
protected boolean preprocessEventForTextField(KeyEvent e) {
return false;
}
}
}
@@ -80,6 +80,10 @@ public final class IconLoader {
@Nullable
/**
* Might return null if icon was not found.
* Use only if you expected null return value, otherwise see {@link IconLoader#getIcon(java.lang.String)}
*/
public static Icon findIcon(@NonNls final String path) {
int stackFrameCount = 2;
Class callerClass = Reflection.getCallerClass(stackFrameCount);
@@ -110,6 +114,10 @@ public final class IconLoader {
}
@Nullable
/**
* Might return null if icon was not found.
* Use only if you expected null return value, otherwise see {@link IconLoader#getIcon(java.lang.String, java.lang.Class)}
*/
public static Icon findIcon(@NotNull final String path, @NotNull final Class aClass) {
URL url = aClass.getResource(path);
return findIcon(url);
@@ -55,7 +55,7 @@ public class Settings implements Configurable {
@Nullable
public Icon getIcon() {
return IconLoader.findIcon("icon.png");
return IconLoader.getIcon("icon.png");
}
@Nullable
@@ -157,7 +157,7 @@ public class NewActionDialog extends DialogWrapper implements ActionData {
myFirstKeystrokeEdit.getDocument().addDocumentListener(listener);
myClearFirstKeystroke.setText(null);
final Icon icon = IconLoader.findIcon("/actions/cancel.png");
final Icon icon = IconLoader.getIcon("/actions/cancel.png");
final Dimension size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
myClearFirstKeystroke.setIcon(icon);
myClearFirstKeystroke.setPreferredSize(size);
@@ -42,7 +42,7 @@ public class GitShowAllSubmittedFilesAction extends AnAction implements DumbAwar
* A constructor
*/
public GitShowAllSubmittedFilesAction() {
super(GitBundle.message("show.all.paths.affected.action.name"), null, IconLoader.findIcon("/icons/allRevisions.png"));
super(GitBundle.message("show.all.paths.affected.action.name"), null, IconLoader.getIcon("/icons/allRevisions.png"));
}
/**
@@ -24,23 +24,23 @@ import javax.swing.*;
*/
public interface GroovyIcons {
Icon FILE_TYPE = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/groovy_fileType.png");
Icon GROOVY_ICON_16x16 = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/groovy_16x16.png");
Icon GROOVY_ICON_32x32 = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/groovy_32x32.png");
Icon CLASS = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/class.png");
Icon ABSTRACT_CLASS = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/abstractClass.png");
Icon INTERFACE = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/interface.png");
Icon ANNOTATION_TYPE = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/annotationType.png");
Icon ENUM = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/enum.png");
Icon PROPERTY = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/property.png");
Icon METHOD = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/method.png");
Icon DYNAMIC = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/dynamicProperty.png");
Icon DEF = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/def.png");
Icon FIELD = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/field.png");
Icon VARIABLE = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/field.png");
Icon FILE_TYPE = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/groovy_fileType.png");
Icon GROOVY_ICON_16x16 = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/groovy_16x16.png");
Icon GROOVY_ICON_32x32 = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/groovy_32x32.png");
Icon CLASS = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/class.png");
Icon ABSTRACT_CLASS = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/abstractClass.png");
Icon INTERFACE = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/interface.png");
Icon ANNOTATION_TYPE = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/annotationType.png");
Icon ENUM = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/enum.png");
Icon PROPERTY = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/property.png");
Icon METHOD = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/method.png");
Icon DYNAMIC = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/dynamicProperty.png");
Icon DEF = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/def.png");
Icon FIELD = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/field.png");
Icon VARIABLE = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/field.png");
Icon NO_GROOVY_SDK = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/no_groovy_sdk.png");
Icon GROOVY_SDK = IconLoader.findIcon("/org/jetbrains/plugins/groovy/images/groovy_sdk.png");
Icon NO_GROOVY_SDK = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/no_groovy_sdk.png");
Icon GROOVY_SDK = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/groovy_sdk.png");
Icon DYNAMIC_PROPERTY_TOOL_WINDOW_ICON = IconLoader.getIcon("/org/jetbrains/plugins/groovy/images/dynamicProperty.png");
@@ -51,7 +51,7 @@ public class ShowAllSubmittedFilesAction extends AnAction implements DumbAware {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.actions.ShowAllSubmittedFilesAction");
public ShowAllSubmittedFilesAction() {
super(SvnBundle.message("action.name.show.all.paths.affected"), null, IconLoader.findIcon("/icons/allRevisions.png"));
super(SvnBundle.message("action.name.show.all.paths.affected"), null, IconLoader.getIcon("/icons/allRevisions.png"));
}
public void update(AnActionEvent e) {
@@ -211,7 +211,7 @@ public class PropertiesComponent extends JPanel {
public void update(AnActionEvent e) {
e.getPresentation().setText("Close");
e.getPresentation().setDescription("Close this tool window");
e.getPresentation().setIcon(IconLoader.findIcon("/actions/cancel.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/cancel.png"));
}
public void actionPerformed(AnActionEvent e) {
@@ -224,7 +224,7 @@ public class PropertiesComponent extends JPanel {
public void update(AnActionEvent e) {
e.getPresentation().setText("Refresh");
e.getPresentation().setDescription("Reload properties");
e.getPresentation().setIcon(IconLoader.findIcon("/actions/sync.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/sync.png"));
e.getPresentation().setEnabled(myFile != null);
}
@@ -240,7 +240,7 @@ public class PropertiesComponent extends JPanel {
e.getPresentation().setText("Edit Keywords");
e.getPresentation().setDescription("Manage svn:keywords property");
if (!CONTEXT_ID.equals(e.getPlace())) {
e.getPresentation().setIcon(IconLoader.findIcon("/actions/properties.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/properties.png"));
}
e.getPresentation().setEnabled(myFile != null && myFile.isFile());
}
@@ -277,7 +277,7 @@ public class PropertiesComponent extends JPanel {
e.getPresentation().setText("Delete Property");
e.getPresentation().setDescription("Delete selected property");
if (!CONTEXT_ID.equals(e.getPlace())) {
e.getPresentation().setIcon(IconLoader.findIcon("/general/remove.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/general/remove.png"));
}
e.getPresentation().setEnabled(myFile != null && getSelectedPropertyName() != null);
}
@@ -299,7 +299,7 @@ public class PropertiesComponent extends JPanel {
e.getPresentation().setText("Add Property");
e.getPresentation().setDescription("Add new property");
if (!CONTEXT_ID.equals(e.getPlace())) {
e.getPresentation().setIcon(IconLoader.findIcon("/general/add.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/general/add.png"));
}
e.getPresentation().setEnabled(myFile != null);
}
@@ -332,7 +332,7 @@ public class PropertiesComponent extends JPanel {
e.getPresentation().setText("Edit Property");
e.getPresentation().setDescription("Edit selected property value");
if (!CONTEXT_ID.equals(e.getPlace())) {
e.getPresentation().setIcon(IconLoader.findIcon("/actions/editSource.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/editSource.png"));
}
e.getPresentation().setEnabled(myFile != null && getSelectedPropertyName() != null);
}
@@ -373,7 +373,7 @@ public class PropertiesComponent extends JPanel {
public void update(final AnActionEvent e) {
super.update(e);
e.getPresentation().setIcon(IconLoader.findIcon("/general/autoscrollFromSource.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/general/autoscrollFromSource.png"));
e.getPresentation().setText("Follow Selection");
e.getPresentation().setDescription("Follow Selection");
// change file
@@ -358,7 +358,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public void update(AnActionEvent e) {
e.getPresentation().setText(SvnBundle.message("action.name.refresh"));
e.getPresentation().setDescription(SvnBundle.message("repository.browser.refresh.action"));
e.getPresentation().setIcon(IconLoader.findIcon("/actions/sync.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/sync.png"));
e.getPresentation().setEnabled(getRepositoryBrowser().getSelectedNode() != null);
}
@@ -380,7 +380,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
if (e.getPlace().equals(PLACE_TOOLBAR)) {
e.getPresentation().setDescription(SvnBundle.message("repository.browser.add.location.action"));
e.getPresentation().setText(SvnBundle.message("repository.browser.add.location.action"));
e.getPresentation().setIcon(IconLoader.findIcon("/general/add.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/general/add.png"));
}
}
@@ -409,7 +409,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
if (e.getPlace().equals(PLACE_TOOLBAR)) {
e.getPresentation().setDescription(SvnBundle.message("repository.browser.edit.location.menu.item"));
e.getPresentation().setText(SvnBundle.message("repository.browser.edit.location.menu.item"));
e.getPresentation().setIcon(IconLoader.findIcon("/actions/editSource.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/editSource.png"));
}
e.getPresentation().setEnabled(node != null && node.getParent() instanceof RepositoryTreeRootNode);
}
@@ -451,7 +451,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public void update(AnActionEvent e) {
RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode();
e.getPresentation().setText(SvnBundle.message("repository.browser.discard.location.action"), true);
e.getPresentation().setIcon(IconLoader.findIcon("/general/remove.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/general/remove.png"));
e.getPresentation().setEnabled(node != null && node.getParent() instanceof RepositoryTreeRootNode);
}
@@ -889,7 +889,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public void update(final AnActionEvent e) {
e.getPresentation().setDescription(SvnBundle.message("repository.browser.details.action"));
e.getPresentation().setText(SvnBundle.message("repository.browser.details.action"));
e.getPresentation().setIcon(IconLoader.findIcon("/actions/annotate.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/annotate.png"));
super.update(e);
}
@@ -1169,7 +1169,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public void update(AnActionEvent e) {
e.getPresentation().setText("Close");
e.getPresentation().setDescription("Close this tool window");
e.getPresentation().setIcon(IconLoader.findIcon("/actions/cancel.png"));
e.getPresentation().setIcon(IconLoader.getIcon("/actions/cancel.png"));
}
}
@@ -435,7 +435,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
private class MyRefresh extends AnAction {
private MyRefresh() {
super(SvnBundle.message("committed.changes.action.merge.highlighting.refresh.text"),
SvnBundle.message("committed.changes.action.merge.highlighting.refresh.description"), IconLoader.findIcon("/actions/sync.png"));
SvnBundle.message("committed.changes.action.merge.highlighting.refresh.description"), IconLoader.getIcon("/actions/sync.png"));
}
@Override
@@ -45,6 +45,6 @@ public class XPathFileType extends LanguageFileType {
}
public Icon getIcon() {
return IconLoader.findIcon("/icons/xpath.png");
return IconLoader.getIcon("/icons/xpath.png");
}
}
@@ -212,7 +212,7 @@ public class XPathFunctionCallImpl extends XPathElementImpl implements XPathFunc
}
public Icon getIcon(int i) {
return IconLoader.findIcon("/icons/function.png");
return IconLoader.getIcon("/icons/function.png");
}
public void accept(@NotNull PsiElementVisitor visitor) {
@@ -32,7 +32,7 @@ class AddAssociationAction extends AnAction {
private final FileAssociationsManager myManager;
public AddAssociationAction(FileAssociationsManager manager) {
super("Add...", "Add File Association", IconLoader.findIcon("/general/add.png"));
super("Add...", "Add File Association", IconLoader.getIcon("/general/add.png"));
myManager = manager;
}
@@ -41,7 +41,7 @@ import java.util.List;
class AssociationsEditor {
private static final String KEY = "#XsltSupport.AssociationsEditor";
private static final Icon LINK_OVERLAY = IconLoader.findIcon("/icons/association_small.png");
private static final Icon LINK_OVERLAY = IconLoader.getIcon("/icons/association_small.png");
private JPanel myComponent;
private JPanel myToolbar;
@@ -191,7 +191,7 @@ class AssociationsEditor {
class RemoveAssociationAction extends AnAction {
public RemoveAssociationAction() {
super(null, "Remove Association", IconLoader.findIcon("/general/remove.png"));
super(null, "Remove Association", IconLoader.getIcon("/general/remove.png"));
}
public void actionPerformed(AnActionEvent e) {
@@ -29,7 +29,7 @@ import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
public class AssociationsGroup extends ActionGroup {
public AssociationsGroup() {
getTemplatePresentation().setIcon(IconLoader.findIcon("/icons/association.png"));
getTemplatePresentation().setIcon(IconLoader.getIcon("/icons/association.png"));
}
@NotNull
@@ -49,7 +49,7 @@ public class FileAssociationsConfigurable implements SearchableConfigurable, Non
}
public Icon getIcon() {
return IconLoader.findIcon("/icons/association_large.png");
return IconLoader.getIcon("/icons/association_large.png");
}
@NotNull
@@ -58,7 +58,7 @@ public class XsltTreeStructureProvider implements TreeStructureProvider {
}
private static class XsltFileNode extends PsiFileNode {
private static final Icon LINK_OVERLAY = IconLoader.findIcon("/icons/association_small.png");
private static final Icon LINK_OVERLAY = IconLoader.getIcon("/icons/association_small.png");
private final FileAssociationsManager myInstance;
private final XsltConfig myConfig;
@@ -40,7 +40,7 @@ public class XsltTemplateImpl extends XsltElementImpl implements XsltTemplate {
@Override
public Icon getIcon(int flags) {
return IconLoader.findIcon("/icons/template.png");
return IconLoader.getIcon("/icons/template.png");
}
@Override
@@ -101,4 +101,4 @@ public class XsltTemplateImpl extends XsltElementImpl implements XsltTemplate {
public boolean isAbstract() {
return "true".equals(getTag().getAttributeValue("abstract", XsltSupport.PLUGIN_EXTENSIONS_NS));
}
}
}
@@ -72,7 +72,7 @@ class XsltRunSettingsEditor extends SettingsEditor<XsltRunConfiguration> {
private final JTable myParams;
public AddParameterAction(JTable params) {
super("Add", "Add Parameter", IconLoader.findIcon("/general/add.png"));
super("Add", "Add Parameter", IconLoader.getIcon("/general/add.png"));
myParams = params;
}
@@ -85,7 +85,7 @@ class XsltRunSettingsEditor extends SettingsEditor<XsltRunConfiguration> {
private final JTable myParams;
public RemoveParameterAction(Table paramModel) {
super("Remove", "Remove Parameter", IconLoader.findIcon("/general/remove.png"));
super("Remove", "Remove Parameter", IconLoader.getIcon("/general/remove.png"));
myParams = paramModel;
}
@@ -234,7 +234,7 @@ class XsltRunSettingsEditor extends SettingsEditor<XsltRunConfiguration> {
public Component getListCellRendererComponent(JList jList, Object object, int i, boolean b, boolean b1) {
if (object == null) {
super.getListCellRendererComponent(jList, StdFileTypes.ARCHIVE, i, b, b1);
setIcon(IconLoader.findIcon("/actions/cancel.png"));
setIcon(IconLoader.getIcon("/actions/cancel.png"));
setText("Disabled");
return this;
}
@@ -33,7 +33,7 @@ public class XPathConfigurable implements Configurable {
}
public Icon getIcon() {
return IconLoader.findIcon("/icons/xml_big.png");
return IconLoader.getIcon("/icons/xml_big.png");
}
@Nullable
@@ -115,7 +115,7 @@ public class XPathEvalAction extends XPathAction {
private static final Logger LOG = Logger.getInstance("org.intellij.plugins.xpathView.XPathEvalAction");
private final Icon myIcon = IconLoader.findIcon("/icons/xml.png");
private final Icon myIcon = IconLoader.getIcon("/icons/xml.png");
protected void updateToolbar(AnActionEvent event) {
super.updateToolbar(event);