From 29c5bd6450386e32cc58ed5f8ad817f26121067c Mon Sep 17 00:00:00 2001 From: Eirik Bakke Date: Sat, 25 Jan 2025 14:31:46 -0500 Subject: [PATCH] More work on centralizing icon loading to ImageUtilities. This is a follow-up on https://github.com/apache/netbeans/pull/8114 and https://github.com/apache/netbeans/pull/8109 . To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon. This PR, combined with the previously mentioned PRs, handles most of the remaining cases. Specifically: * Search for 'new ImageIcon(' and rewrite each case to use ImageUtilities to load icons instead. * Search for 'instanceof ImageIcon' and generalize to 'instanceof Icon' when appropriate. * Search for 'getLookAndFeel*getDisabledIcon' and switch to ImageUtilities.createDisabledIcon. --- .../customizers/common/InputDialog.java | 5 +- .../configbean/customizers/common/Util.java | 31 ------- .../web/beans/actions/InterceptorPanel.java | 14 +--- .../web/monitor/client/SortButton.java | 11 +-- .../web/monitor/client/TransactionView.java | 27 +++---- .../design/view/widget/ButtonWidget.java | 5 +- .../ant/module/loader/AntActionInstance.java | 10 +-- .../tools/ant/module/run/TargetExecutor.java | 9 ++- .../editor/completion/GsfCompletionItem.java | 80 ------------------- .../db/dataview/output/DataViewUI.java | 26 +++--- .../querybuilder/QueryBuilder.java | 9 ++- .../querybuilder/QueryBuilderGraphFrame.java | 18 ++--- .../support/CompletionUtilities.java | 9 +-- .../editor/errorstripe/AnnotationView.java | 4 +- .../editor/macros/storage/ui/TableSorter.java | 6 +- .../modules/git/ui/branch/CreateBranch.java | 2 +- .../ui/checkout/AbstractCheckoutRevision.java | 2 +- .../modules/git/ui/commit/GitCommitPanel.java | 4 +- .../modules/git/ui/stash/SaveStash.java | 2 +- .../modules/git/ui/tag/CreateTag.java | 2 +- .../HtmlPaletteCompletionProvider.java | 3 +- .../nbproject/project.xml | 8 ++ .../lib/terminalemulator/support/FindBar.java | 7 +- .../modules/lsp/client/LSPBindings.java | 2 +- .../bindings/CompletionProviderImpl.java | 3 +- .../mercurial/ui/commit/CommitPanel.java | 4 +- .../refactoring/spi/impl/ErrorPanel.java | 13 +-- .../views/debugging/ThreadsHistoryAction.java | 13 +-- .../subversion/ui/commit/CommitPanel.java | 5 +- .../modules/openfile/PackagePanel.java | 6 +- .../util/common/VCSCommitParameters.java | 6 +- .../ui/api/FileReferenceCompletion.java | 3 +- .../completion/AttributeResultItem.java | 8 +- .../completion/CompletionResultItem.java | 2 +- .../schema/completion/ElementResultItem.java | 8 +- .../schema/completion/ValueResultItem.java | 5 +- .../xml/text/completion/IconStore.java | 73 ----------------- .../netbeans/modules/form/FormToolBar.java | 3 +- .../delegates/GridBagCustomizer.java | 4 +- .../editor/java/JavaCompletionItem.java | 29 +++---- .../editor/overridden/IsOverriddenPopup.java | 3 +- .../editor/CommandCompletionProvider.java | 2 +- .../modules/jshell/editor/ConsoleEditor.java | 8 +- .../SpringXMLConfigCompletionItem.java | 2 +- .../completion/impl/ResourcePathItem.java | 2 +- .../modules/php/api/framework/BadgeIcon.java | 5 +- .../php/editor/completion/FSCompletion.java | 3 +- .../editor/completion/PHPCompletionItem.java | 2 +- .../editor/completion/TplCompletionItem.java | 3 +- .../netbeans/swing/etable/ETableHeader.java | 38 +-------- .../src/org/openide/awt/Actions.java | 9 --- .../modules/options/keymap/TableSorter.java | 6 +- .../org/netbeans/modules/print/util/UI.java | 5 +- .../lib.profiler.ui/nbproject/project.xml | 8 ++ .../tree/MethodNameTreeCellRenderer.java | 13 +-- .../profiler/ui/cpu/CPUJavaNameRenderer.java | 8 +- .../ui/jdbc/JDBCJavaNameRenderer.java | 8 +- .../ui/memory/MemoryJavaNameRenderer.java | 4 +- .../modules/profiler/api/icons/Icons.java | 8 +- .../profiler/heapwalk/model/BrowserUtils.java | 7 +- .../javascript2/editor/FSCompletionItem.java | 3 +- .../javascript2/editor/JsCompletionItem.java | 12 +-- .../requirejs/editor/FSCompletionItem.java | 5 +- .../editor/MappingCompletionItem.java | 2 +- 64 files changed, 202 insertions(+), 445 deletions(-) delete mode 100644 ide/xml.text/src/org/netbeans/modules/xml/text/completion/IconStore.java diff --git a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/InputDialog.java b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/InputDialog.java index fbc30d59aa78..31658f8657c4 100644 --- a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/InputDialog.java +++ b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/InputDialog.java @@ -48,6 +48,7 @@ import org.netbeans.modules.j2ee.sun.share.configbean.Utils; import org.openide.awt.Mnemonics; import org.openide.util.HelpCtx; +import org.openide.util.ImageUtilities; /* A modal dialog object with Ok, Cancel, Help buttons and an optional required @@ -287,7 +288,7 @@ public void showErrors() { // Add warning message JLabel label = new JLabel(); - label.setIcon(Util.warningMessageIcon); + label.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/resources/warningIcon.png")); label.setText("" + message + ""); // NOI18N label.getAccessibleContext().setAccessibleName(bundle.getString("ASCN_WarningMessage")); // NOI18N label.getAccessibleContext().setAccessibleDescription(message); @@ -308,7 +309,7 @@ public void showErrors() { // Add error message JLabel label = new JLabel(); - label.setIcon(Util.errorMessageIcon); + label.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/resources/errorIcon.png")); label.setText("" + message + ""); // NOI18N label.getAccessibleContext().setAccessibleName(bundle.getString("ASCN_ErrorMessage")); // NOI18N label.getAccessibleContext().setAccessibleDescription(message); diff --git a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/Util.java b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/Util.java index 2b420807cb05..02917c6c0a64 100644 --- a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/Util.java +++ b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/Util.java @@ -20,10 +20,7 @@ package org.netbeans.modules.j2ee.sun.share.configbean.customizers.common; import java.awt.Color; -import javax.swing.ImageIcon; import javax.swing.UIManager; -import org.netbeans.modules.j2ee.sun.share.configbean.Utils; -import org.openide.ErrorManager; /** @@ -35,34 +32,6 @@ public class Util { private Util() { } - /** Error/warning message icons. - */ - private static final String errorIconPath = - "org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/resources/errorIcon.png"; // NOI18N - private static final String warningIconPath = - "org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/resources/warningIcon.png"; // NOI18N - - public static ImageIcon errorMessageIcon; - public static ImageIcon warningMessageIcon; - - static { - // Diagnostic test code to try to get more information about a suspicious intermittant exception - // (This is circa NB 4.1, so it may not be necessary anymore). - try { - errorMessageIcon = new ImageIcon(Utils.getResourceURL(errorIconPath, InputDialog.class)); - } catch(NullPointerException ex) { - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); - errorMessageIcon = null; - } - try { - warningMessageIcon = new ImageIcon(Utils.getResourceURL(warningIconPath, InputDialog.class)); - } catch(NullPointerException ex) { - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); - warningMessageIcon = null; - } - } - - /** !PW Foreground color for error message text when in the NetBeans IDE. * See http://ui.netbeans.org/docs/inline_errors/index.html, about * halfway down, for specification. (Was light blue: [89, 79, 191]) diff --git a/enterprise/web.beans/src/org/netbeans/modules/web/beans/actions/InterceptorPanel.java b/enterprise/web.beans/src/org/netbeans/modules/web/beans/actions/InterceptorPanel.java index be924b29d32c..de20fa43db64 100644 --- a/enterprise/web.beans/src/org/netbeans/modules/web/beans/actions/InterceptorPanel.java +++ b/enterprise/web.beans/src/org/netbeans/modules/web/beans/actions/InterceptorPanel.java @@ -24,16 +24,13 @@ */ package org.netbeans.modules.web.beans.actions; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import org.openide.filesystems.FileObject; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.Utilities; @@ -58,14 +55,7 @@ public InterceptorPanel( JButton approveButton, String bindingName, myInterceptorName.getDocument().addDocumentListener( createValidationListener( approveButton ) ); myInterceptorName.setText( getProposedName() ); - URL errorUrl; - try { - errorUrl = new URL("nbresloc:/org/netbeans/modules/dialogs/error.gif"); - myStatusLbl.setIcon( new ImageIcon( errorUrl )); - } - catch (MalformedURLException e) { - assert false; - } + myStatusLbl.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/dialogs/error.gif")); myStatusLbl.setVisible( false ); } diff --git a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/SortButton.java b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/SortButton.java index 9facd5785587..a5e77a7f3e76 100644 --- a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/SortButton.java +++ b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/SortButton.java @@ -27,7 +27,7 @@ import java.awt.event.ActionListener; import java.util.logging.Logger; import javax.swing.Icon; -import javax.swing.ImageIcon; +import org.openide.util.ImageUtilities; import javax.swing.JButton; import org.openide.util.NbBundle; @@ -41,12 +41,9 @@ class SortButton extends JButton { public SortButton(final DisplayTable dt) { super(); - icon[0] = new ImageIcon(TransactionView.class.getResource - ("/org/netbeans/modules/web/monitor/client/icons/unsorted.gif")); // NOI18N) - icon[1] = new ImageIcon(TransactionView.class.getResource - ("/org/netbeans/modules/web/monitor/client/icons/a2z.gif")); // NOI18N - icon[2] = new ImageIcon(TransactionView.class.getResource - ("/org/netbeans/modules/web/monitor/client/icons/z2a.gif")); // NOI18N + icon[0] = ImageUtilities.loadIcon("org/netbeans/modules/web/monitor/client/icons/unsorted.gif"); // NOI18N) + icon[1] = ImageUtilities.loadIcon("org/netbeans/modules/web/monitor/client/icons/a2z.gif"); // NOI18N + icon[2] = ImageUtilities.loadIcon("org/netbeans/modules/web/monitor/client/icons/z2a.gif"); // NOI18N setIcon(icon[state]); setBorder(null); setBorderPainted(false); diff --git a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/TransactionView.java b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/TransactionView.java index a62f147d5d30..f5f10f0adc9c 100644 --- a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/TransactionView.java +++ b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/TransactionView.java @@ -61,6 +61,7 @@ import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.netbeans.modules.web.monitor.data.DataRecord; +import org.openide.util.ImageUtilities; /** * Update title does not work like it should. Maybe there is a getName @@ -127,8 +128,7 @@ public HelpCtx getHelpCtx() { * retrieve any data until the Monitor is opened. */ private TransactionView() { - setIcon(new ImageIcon(TransactionView.class.getResource - ("/org/netbeans/modules/web/monitor/client/icons/menuitem.gif")).getImage()); + setIcon(ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/menuitem.gif")); setToolTipText(NbBundle.getMessage(TransactionView.class, "MON_Window_Tooltip")); controller = Controller.getInstance(); initialize(); @@ -285,16 +285,16 @@ private void createLogPanel() { )); buttonPanel.setFloatable (false); - JButton updateButton = new JButton(new ImageIcon(TransactionView.class.getResource - ("/org/netbeans/modules/web/monitor/client/icons/update.gif"))); // NOI18N + JButton updateButton = new JButton(ImageUtilities.loadIcon( + "org/netbeans/modules/web/monitor/client/icons/update.gif")); // NOI18N updateButton.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("MON_Reload_all_17")); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { controller.getTransactions(); }}); - timeAButton = new JToggleButton(new ImageIcon( - TransactionView.class.getResource("/org/netbeans/modules/web/monitor/client/icons/timesortA.gif")), false); + timeAButton = new JToggleButton(ImageUtilities.loadIcon( + "org/netbeans/modules/web/monitor/client/icons/timesortA.gif"), false); timeAButton.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("MON_Order_transactions_15")); timeAButton.addActionListener(new ActionListener() { @@ -310,8 +310,8 @@ public void actionPerformed(ActionEvent e) { } }}); - timeDButton = new JToggleButton(new ImageIcon( - TransactionView.class.getResource("/org/netbeans/modules/web/monitor/client/icons/timesortB.gif")), true); + timeDButton = new JToggleButton(ImageUtilities.loadIcon( + "org/netbeans/modules/web/monitor/client/icons/timesortB.gif"), true); timeDButton.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("MON_Order_transactions_16")); timeDButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -327,8 +327,8 @@ public void actionPerformed(ActionEvent e) { }}); - alphaButton = new JToggleButton(new ImageIcon( - TransactionView.class.getResource("/org/netbeans/modules/web/monitor/client/icons/a2z.gif")), false); + alphaButton = new JToggleButton(ImageUtilities.loadIcon( + "/org/netbeans/modules/web/monitor/client/icons/a2z.gif"), false); alphaButton.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("MON_Order_transactions_14")); alphaButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -345,10 +345,9 @@ public void actionPerformed(ActionEvent e) { }}); - timestampButton = new - JToggleButton(new ImageIcon( - TransactionView.class.getResource("/org/netbeans/modules/web/monitor/client/icons/timestamp.gif")), - TransactionNode.showTimeStamp()); + timestampButton = new JToggleButton( + ImageUtilities.loadIcon("org/netbeans/modules/web/monitor/client/icons/timestamp.gif"), + TransactionNode.showTimeStamp()); timestampButton.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("MON_Show_time_25")); timestampButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/enterprise/websvc.design/src/org/netbeans/modules/websvc/design/view/widget/ButtonWidget.java b/enterprise/websvc.design/src/org/netbeans/modules/websvc/design/view/widget/ButtonWidget.java index 1cdb6bd0836e..d0698559da9f 100644 --- a/enterprise/websvc.design/src/org/netbeans/modules/websvc/design/view/widget/ButtonWidget.java +++ b/enterprise/websvc.design/src/org/netbeans/modules/websvc/design/view/widget/ButtonWidget.java @@ -36,7 +36,7 @@ import java.util.HashMap; import java.util.Map; import javax.swing.Action; -import javax.swing.ImageIcon; +import javax.swing.Icon; import javax.swing.JButton; import org.netbeans.api.visual.action.ActionFactory; import org.netbeans.api.visual.action.SelectProvider; @@ -47,6 +47,7 @@ import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.Scene; import org.netbeans.api.visual.widget.Widget; +import org.openide.util.ImageUtilities; /** * @author Ajit Bhate @@ -261,7 +262,7 @@ private static String getActionName(Action action) { private static Image getActionIcon(Action action) { Object icon = action.getValue(Action.SMALL_ICON); - return (icon instanceof ImageIcon ? ((ImageIcon)icon).getImage(): null); + return (icon instanceof Icon ? ImageUtilities.icon2Image((Icon)icon): null); } private static String getActionTooltip(Action action) { diff --git a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/loader/AntActionInstance.java b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/loader/AntActionInstance.java index 38ed61c55eca..680af746a1d1 100644 --- a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/loader/AntActionInstance.java +++ b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/loader/AntActionInstance.java @@ -26,12 +26,9 @@ import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Arrays; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JMenuItem; @@ -49,6 +46,7 @@ import org.openide.cookies.InstanceCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.util.ImageUtilities; import org.openide.util.actions.Presenter; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; @@ -163,11 +161,7 @@ public void run() { return Actions.cutAmpersand(pname); } } else if (Action.SMALL_ICON.equals (key)) { - try { - return new ImageIcon(new URL("nbresloc:/org/apache/tools/ant/module/resources/AntIcon.gif")); - } catch (MalformedURLException e) { - throw new AssertionError(e); - } + return ImageUtilities.loadImageIcon("org/apache/tools/ant/module/resources/AntIcon.gif", false); } else if (Action.MNEMONIC_KEY.equals (key)) { Element el = proj.getProjectElement (); if (el != null) { diff --git a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java index 54e6ae934a12..519f8f5a8df5 100644 --- a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java +++ b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java @@ -64,6 +64,7 @@ import org.openide.filesystems.FileRenameEvent; import org.openide.filesystems.FileUtil; import org.openide.util.Cancellable; +import org.openide.util.ImageUtilities; import org.openide.util.Mutex; import org.openide.util.NbBundle; import org.openide.util.Pair; @@ -203,7 +204,7 @@ public StopAction() { @Override public Object getValue(String key) { if (key.equals(Action.SMALL_ICON)) { - return new ImageIcon(TargetExecutor.class.getResource("/org/apache/tools/ant/module/resources/stop.png")); + return ImageUtilities.loadImageIcon("org/apache/tools/ant/module/resources/stop.png", false); } else if (key.equals(Action.SHORT_DESCRIPTION)) { return NbBundle.getMessage(TargetExecutor.class, "TargetExecutor.StopAction.stop"); } else { @@ -259,9 +260,9 @@ private void reinit(TargetExecutor prototype) { public Object getValue(String key) { if (key.equals(Action.SMALL_ICON)) { if (withModifications) { - return new ImageIcon(TargetExecutor.class.getResource("/org/apache/tools/ant/module/resources/rerun-mod.png")); + return ImageUtilities.loadImageIcon("org/apache/tools/ant/module/resources/rerun-mod.png", false); } else { - return new ImageIcon(TargetExecutor.class.getResource("/org/apache/tools/ant/module/resources/rerun.png")); + return ImageUtilities.loadImageIcon("org/apache/tools/ant/module/resources/rerun.png", false); } } else if (key.equals(Action.SHORT_DESCRIPTION)) { if (withModifications) { @@ -332,7 +333,7 @@ private static final class OptionsAction extends AbstractAction { // #59396 @Override public Object getValue(String key) { if (key.equals(Action.SMALL_ICON)) { - return new ImageIcon(TargetExecutor.class.getResource("/org/apache/tools/ant/module/resources/options.png")); + return ImageUtilities.loadImageIcon("org/apache/tools/ant/module/resources/options.png", false); } else if (key.equals(Action.SHORT_DESCRIPTION)) { return NbBundle.getMessage(TargetExecutor.class, "TargetExecutor.OptionsAction"); } else { diff --git a/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionItem.java b/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionItem.java index ea1dbf49c8b3..2a4c3a324938 100644 --- a/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionItem.java +++ b/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionItem.java @@ -238,88 +238,8 @@ protected ImageIcon getIcon() { ImageIcon imageIcon = org.netbeans.modules.csl.navigation.Icons.getElementIcon(item.getKind(), item.getModifiers()); // TODO - cache! return imageIcon; -// -// -// ElementKind kind = item.getKind(); -// switch (kind) { -// case CONSTRUCTOR: -// case METHOD: -// return getMethodIcon(); -// case ATTRIBUTE: -// case FIELD: -// return getFieldIcon(); -// case CLASS: -// case INTERFACE: -// return getClassIcon(); -// case MODULE: -// return getModuleIcon(); -// case CONSTANT: -// return getConstantIcon(); -// case VARIABLE: -// return getVariableIcon(); -// case KEYWORD: -// return getKeywordIcon(); -// case OTHER: -// } -// -// return null; } -// protected ImageIcon getMethodIcon() { -// Set modifiers = item.getModifiers(); -// -// boolean isStatic = modifiers.contains(Modifier.STATIC); -//// int level = getProtectionLevel(elem.getModifiers()); -// -// ImageIcon cachedIcon = icon[isStatic?1:0][level]; -// if (cachedIcon != null) { -// return cachedIcon; -// } -// -// String iconPath = METHOD_PUBLIC; -// if (isStatic) { -// switch (level) { -// case PRIVATE_LEVEL: -// iconPath = METHOD_ST_PRIVATE; -// break; -// -// case PACKAGE_LEVEL: -// iconPath = METHOD_ST_PACKAGE; -// break; -// -// case PROTECTED_LEVEL: -// iconPath = METHOD_ST_PROTECTED; -// break; -// -// case PUBLIC_LEVEL: -// iconPath = METHOD_ST_PUBLIC; -// break; -// } -// }else{ -// switch (level) { -// case PRIVATE_LEVEL: -// iconPath = METHOD_PRIVATE; -// break; -// -// case PACKAGE_LEVEL: -// iconPath = METHOD_PACKAGE; -// break; -// -// case PROTECTED_LEVEL: -// iconPath = METHOD_PROTECTED; -// break; -// -// case PUBLIC_LEVEL: -// iconPath = METHOD_PUBLIC; -// break; -// } -// } -// ImageIcon newIcon = new ImageIcon(org.openide.util.Utilities.loadImage(iconPath)); -// icon[isStatic?1:0][level] = newIcon; -// return newIcon; -// } - - @Override protected void substituteText(final JTextComponent c, int offset, int len, String toAdd) { if (completionResult != null) { diff --git a/ide/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java b/ide/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java index e3a684569d2b..10adab52e082 100644 --- a/ide/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java +++ b/ide/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java @@ -36,7 +36,6 @@ import java.awt.event.MouseListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.net.URL; import java.util.Set; import javax.swing.AbstractButton; @@ -61,6 +60,7 @@ import org.netbeans.modules.db.dataview.table.MultiColPatternFilter; import org.netbeans.modules.db.dataview.table.ResultSetJXTable; import static org.netbeans.modules.db.dataview.table.SuperPatternFilter.MODE.LITERAL_FIND; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; /** @@ -72,7 +72,7 @@ "LBL_fetched_rows=Fetched Rows:" }) class DataViewUI extends JPanel { - private static final String IMG_PREFIX = "/org/netbeans/modules/db/dataview/images/"; // NOI18N + private static final String IMG_PREFIX = "org/netbeans/modules/db/dataview/images/"; // NOI18N private final JButton[] editButtons = new JButton[5]; private final DataViewTableUI dataPanel; @@ -237,8 +237,7 @@ public void actionPerformed(ActionEvent e) { dataPanelScrollPane.setRowHeaderView(rowHeader); dataPanelScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowHeader.getTableHeader()); - URL url = getClass().getResource(IMG_PREFIX + "preferences-desktop.png"); // NOI18N - ImageIcon icon = new ImageIcon(url); + ImageIcon icon = ImageUtilities.loadImageIcon(IMG_PREFIX + "preferences-desktop.png", false); // NOI18N JButton cornerButton = new JButton() { @Override protected void paintComponent(Graphics g) { @@ -432,8 +431,7 @@ private void initToolbarWest(JToolBar toolbar, ActionListener outputListener, bo toolbar.addSeparator(new Dimension(10, 10)); //add refresh button - URL url = getClass().getResource(IMG_PREFIX + "refresh.png"); // NOI18N - refreshButton = new JButton(new ImageIcon(url)); + refreshButton = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "refresh.png")); // NOI18N refreshButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_refresh")); refreshButton.addActionListener(outputListener); processButton(refreshButton); @@ -515,9 +513,7 @@ private void processKeyEvents() { } private void initVerticalToolbar(ActionListener outputListener) { - - URL url = getClass().getResource(IMG_PREFIX + "row_add.png"); // NOI18N - insert = new JButton(new ImageIcon(url)); + insert = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "row_add.png")); // NOI18N insert.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_insert")+" (Alt+I)"); insert.setMnemonic('I'); insert.addActionListener(outputListener); @@ -525,24 +521,21 @@ private void initVerticalToolbar(ActionListener outputListener) { processButton(insert); editButtons[0] = insert; - url = getClass().getResource(IMG_PREFIX + "row_delete.png"); // NOI18N - deleteRow = new JButton(new ImageIcon(url)); + deleteRow = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "row_delete.png")); // NOI18N deleteRow.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_deleterow")); deleteRow.addActionListener(outputListener); deleteRow.setEnabled(false); processButton(deleteRow); editButtons[1] = deleteRow; - url = getClass().getResource(IMG_PREFIX + "row_commit.png"); // NOI18N - commit = new JButton(new ImageIcon(url)); + commit = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "row_commit.png")); // NOI18N commit.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_commit_all")); commit.addActionListener(outputListener); commit.setEnabled(false); processButton(commit); editButtons[2] = commit; - url = getClass().getResource(IMG_PREFIX + "cancel_edits.png"); // NOI18N - cancel = new JButton(new ImageIcon(url)); + cancel = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "cancel_edits.png")); // NOI18N cancel.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_cancel_edits_all")); cancel.addActionListener(outputListener); cancel.setEnabled(false); @@ -550,8 +543,7 @@ private void initVerticalToolbar(ActionListener outputListener) { editButtons[3] = cancel; //add truncate button - url = getClass().getResource(IMG_PREFIX + "table_truncate.png"); // NOI18N - truncateButton = new JButton(new ImageIcon(url)); + truncateButton = new JButton(ImageUtilities.loadIcon(IMG_PREFIX + "table_truncate.png")); // NOI18N truncateButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_truncate_table")+" (Alt+T)"); truncateButton.setMnemonic('T'); truncateButton.addActionListener(outputListener); diff --git a/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilder.java b/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilder.java index 8b49cd719614..51081974bc64 100644 --- a/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilder.java +++ b/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilder.java @@ -49,6 +49,7 @@ import java.util.List; import java.util.logging.Level; +import java.awt.Image; import org.netbeans.api.db.explorer.ConnectionManager; import org.netbeans.modules.db.sql.visualeditor.QueryEditorUILogger; @@ -77,6 +78,7 @@ import org.netbeans.api.db.explorer.DatabaseConnection; import org.netbeans.api.db.sql.support.SQLIdentifiers; +import org.openide.util.ImageUtilities; import org.openide.util.Exceptions; /** @@ -201,10 +203,9 @@ private QueryBuilder(DatabaseConnection dbconn, String statement, VisualSQLEdito setLayout(new java.awt.BorderLayout()); - ImageIcon imgIcon = - new ImageIcon(getClass().getResource("/org/netbeans/modules/db/sql/visualeditor/resources/query-editor-tab.png")); // NOI18N - if (imgIcon != null) - setIcon(imgIcon.getImage()); + Image icon = ImageUtilities.loadImage("org/netbeans/modules/db/sql/visualeditor/resources/query-editor-tab.png"); // NOI18N + if (icon != null) + setIcon(icon); _queryBuilderPane = new QueryBuilderPane(this); diff --git a/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilderGraphFrame.java b/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilderGraphFrame.java index 0574c3a646c4..dba9b4c10c23 100644 --- a/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilderGraphFrame.java +++ b/ide/db.sql.visualeditor/src/org/netbeans/modules/db/sql/visualeditor/querybuilder/QueryBuilderGraphFrame.java @@ -98,6 +98,7 @@ import org.netbeans.api.visual.action.PopupMenuProvider; import org.netbeans.api.visual.action.ActionFactory; import org.netbeans.api.visual.action.SelectProvider; +import org.openide.util.ImageUtilities; import org.openide.util.Exceptions; /** @@ -162,12 +163,6 @@ public class QueryBuilderGraphFrame extends JPanel private boolean _inputTableAddCriteria = false; - java.net.URL url_primary_key = - getClass().getResource("/org/netbeans/modules/db/sql/visualeditor/resources/primaryKey.gif"); // NOI18N - java.net.URL url_foreign_key = - getClass().getResource("/org/netbeans/modules/db/sql/visualeditor/resources/foreignKey.gif"); // NOI18N - - // Constructor // Note that this takes as parameter the models that underlie the other three panes. @@ -1052,12 +1047,13 @@ QBNodeComponent createNode(JoinTable joinTable, List selectColumnNames) { // JLabel (String text, Icon image, SwingConstants.LEFT); // We used to use toUpperCase() during comparison, but drop that now that we are // canonicalizing table/column names. - if (primaryKeys.contains(columnName.trim())) - dbData[i][1] = new ImageIcon(url_primary_key); - else if (foreignKeyCols.contains(columnName.trim())) - dbData[i][1] = new ImageIcon(url_foreign_key); - else + if (primaryKeys.contains(columnName.trim())) { + dbData[i][1] = ImageUtilities.loadImageIcon("org/netbeans/modules/db/sql/visualeditor/resources/primaryKey.gif", false); + } else if (foreignKeyCols.contains(columnName.trim())) { + dbData[i][1] = ImageUtilities.loadImageIcon("org/netbeans/modules/db/sql/visualeditor/resources/foreignKey.gif", false); + } else { dbData[i][1] = null; + } dbData[i][2] = columnName; _queryBuilderInputTable.addRow(tableSpec, columnName); diff --git a/ide/editor.completion/src/org/netbeans/spi/editor/completion/support/CompletionUtilities.java b/ide/editor.completion/src/org/netbeans/spi/editor/completion/support/CompletionUtilities.java index 89a5e7201911..1b45e3cd3e7d 100644 --- a/ide/editor.completion/src/org/netbeans/spi/editor/completion/support/CompletionUtilities.java +++ b/ide/editor.completion/src/org/netbeans/spi/editor/completion/support/CompletionUtilities.java @@ -144,12 +144,11 @@ public static int getPreferredWidth(String leftHtmlText, String rightHtmlText, * to be black for all parts of the rendered strings. */ public static void renderHtml(ImageIcon icon, String leftHtmlText, String rightHtmlText, - Graphics g, Font defaultFont, Color defaultColor, - int width, int height, boolean selected) { + Graphics g, Font defaultFont, Color defaultColor, + int width, int height, boolean selected) + { if (icon != null) { - // The image of the ImageIcon should already be loaded - // so no ImageObserver should be necessary - g.drawImage(icon.getImage(), BEFORE_ICON_GAP, (height - icon.getIconHeight()) /2, null); + icon.paintIcon(null, g, BEFORE_ICON_GAP, (height - icon.getIconHeight()) /2); } int iconWidth = BEFORE_ICON_GAP + (icon != null ? icon.getIconWidth() : ICON_WIDTH) + AFTER_ICON_GAP; int rightTextX = width - AFTER_RIGHT_TEXT_GAP; diff --git a/ide/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java b/ide/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java index 61d33e10a136..ab9caf6aae43 100644 --- a/ide/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java +++ b/ide/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java @@ -38,7 +38,6 @@ import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JLayeredPane; import javax.swing.JScrollPane; @@ -67,6 +66,7 @@ import org.openide.ErrorManager; import org.netbeans.modules.editor.errorstripe.privatespi.Status; import org.openide.text.NbDocument; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; @@ -110,7 +110,7 @@ public class AnnotationView extends JComponent implements FoldHierarchyListener, private DocumentListener weakDocL; static { - busyIcon = new ImageIcon(AnnotationView.class.getResource("resources/hodiny.gif")); + busyIcon = ImageUtilities.loadIcon("org/netbeans/modules/editor/errorstripe/resources/hodiny.gif"); } // public AnnotationView(JTextComponent pane) { diff --git a/ide/editor.macros/src/org/netbeans/modules/editor/macros/storage/ui/TableSorter.java b/ide/editor.macros/src/org/netbeans/modules/editor/macros/storage/ui/TableSorter.java index 0e38e390e40d..5d353385a71d 100644 --- a/ide/editor.macros/src/org/netbeans/modules/editor/macros/storage/ui/TableSorter.java +++ b/ide/editor.macros/src/org/netbeans/modules/editor/macros/storage/ui/TableSorter.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.event.TableModelEvent; @@ -40,6 +39,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; +import org.openide.util.ImageUtilities; public class TableSorter extends AbstractTableModel { @@ -176,9 +176,9 @@ protected Icon getHeaderRendererIcon(int column, int size) { return null; } if (directive.direction == DESCENDING) { - return new ImageIcon(getClass().getResource("/org/netbeans/modules/editor/macros/storage/ui/columnsSortedDesc.png")); // NOI18N + return ImageUtilities.loadIcon("org/netbeans/modules/editor/macros/storage/ui/columnsSortedDesc.png"); // NOI18N } else { - return new ImageIcon(getClass().getResource("/org/netbeans/modules/editor/macros/storage/ui/columnsSortedAsc.png")); // NOI18N + return ImageUtilities.loadIcon("org/netbeans/modules/editor/macros/storage/ui/columnsSortedAsc.png"); // NOI18N } } diff --git a/ide/git/src/org/netbeans/modules/git/ui/branch/CreateBranch.java b/ide/git/src/org/netbeans/modules/git/ui/branch/CreateBranch.java index e7552e9ede11..c0c416691281 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/branch/CreateBranch.java +++ b/ide/git/src/org/netbeans/modules/git/ui/branch/CreateBranch.java @@ -51,7 +51,7 @@ public class CreateBranch implements DocumentListener { private boolean revisionValid = false; private String msgInvalidName; private String branchName; - private final Icon ICON_ERROR = org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/info.png", false); //NOI18N + private final Icon ICON_ERROR = org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/info.png"); //NOI18N private final Map existingBranches; private final Set localBranchNames; private boolean internalChange; diff --git a/ide/git/src/org/netbeans/modules/git/ui/checkout/AbstractCheckoutRevision.java b/ide/git/src/org/netbeans/modules/git/ui/checkout/AbstractCheckoutRevision.java index 82dcf7244700..88c7e6a433e6 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/checkout/AbstractCheckoutRevision.java +++ b/ide/git/src/org/netbeans/modules/git/ui/checkout/AbstractCheckoutRevision.java @@ -55,7 +55,7 @@ public abstract class AbstractCheckoutRevision implements DocumentListener, Acti private boolean branchNameRecommended = true; private String branchName; private final Map branches; - private final Icon ICON_ERROR = org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/info.png", false); //NOI18N + private final Icon ICON_ERROR = org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/info.png"); //NOI18N private boolean autoSelectedCreateBranch = true; protected AbstractCheckoutRevision (RepositoryInfo info, RevisionDialogController revisionPicker) { diff --git a/ide/git/src/org/netbeans/modules/git/ui/commit/GitCommitPanel.java b/ide/git/src/org/netbeans/modules/git/ui/commit/GitCommitPanel.java index 066fa309ea22..c173c56c4f8b 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/commit/GitCommitPanel.java +++ b/ide/git/src/org/netbeans/modules/git/ui/commit/GitCommitPanel.java @@ -82,12 +82,12 @@ public class GitCommitPanel extends VCSCommitPanel { static final GitCommitFilter FILTER_HEAD_VS_WORKING = new GitCommitFilter( "HEAD_VS_WORKING", - org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/head_vs_working.png", false), + org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/head_vs_working.png"), NbBundle.getMessage(GitCommitPanel.class, "ParametersPanel.tgbHeadVsWorking.toolTipText"), true); static final GitCommitFilter FILTER_HEAD_VS_INDEX = new GitCommitFilter( "HEAD_VS_INDEX", - org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/head_vs_index.png", false), + org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/head_vs_index.png"), NbBundle.getMessage(GitCommitPanel.class, "ParametersPanel.tgbHeadVsIndex.toolTipText"), false); diff --git a/ide/git/src/org/netbeans/modules/git/ui/stash/SaveStash.java b/ide/git/src/org/netbeans/modules/git/ui/stash/SaveStash.java index a3cd564b238b..82e2e3686615 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/stash/SaveStash.java +++ b/ide/git/src/org/netbeans/modules/git/ui/stash/SaveStash.java @@ -50,7 +50,7 @@ class SaveStash implements DocumentListener { private JButton okButton; private DialogDescriptor dd; private final File repository; - private final Icon ICON_INFO = org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/info.png", false); //NOI18N + private final Icon ICON_INFO = org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/info.png"); //NOI18N private final File[] roots; SaveStash (File repository, File[] roots, GitBranch activeBranch) { diff --git a/ide/git/src/org/netbeans/modules/git/ui/tag/CreateTag.java b/ide/git/src/org/netbeans/modules/git/ui/tag/CreateTag.java index c6c8d9b0ee78..97439dbba095 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/tag/CreateTag.java +++ b/ide/git/src/org/netbeans/modules/git/ui/tag/CreateTag.java @@ -57,7 +57,7 @@ class CreateTag implements DocumentListener, ActionListener { private final Task branchCheckTask; private String tagName; private final File repository; - private final Icon ICON_INFO = org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/git/resources/icons/info.png", false); //NOI18N + private final Icon ICON_INFO = org.openide.util.ImageUtilities.loadIcon("org/netbeans/modules/git/resources/icons/info.png"); //NOI18N CreateTag (File repository, String initialRevision, String initialTagName) { this.repository = repository; diff --git a/ide/html.editor/src/org/netbeans/modules/html/editor/completion/HtmlPaletteCompletionProvider.java b/ide/html.editor/src/org/netbeans/modules/html/editor/completion/HtmlPaletteCompletionProvider.java index 0ea71a6d3aa8..e397610e3ce9 100644 --- a/ide/html.editor/src/org/netbeans/modules/html/editor/completion/HtmlPaletteCompletionProvider.java +++ b/ide/html.editor/src/org/netbeans/modules/html/editor/completion/HtmlPaletteCompletionProvider.java @@ -54,6 +54,7 @@ import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; import org.openide.windows.TopComponent; /** @@ -298,7 +299,7 @@ public String getRightHtmlText() { } public ImageIcon getIcon() { - return new ImageIcon(icon); + return ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(icon)); } @Override diff --git a/ide/lib.terminalemulator/nbproject/project.xml b/ide/lib.terminalemulator/nbproject/project.xml index 4f8c931e2154..0d314e589ba6 100644 --- a/ide/lib.terminalemulator/nbproject/project.xml +++ b/ide/lib.terminalemulator/nbproject/project.xml @@ -33,6 +33,14 @@ 7.82 + + org.openide.util.ui + + + + 9.37 + + diff --git a/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/support/FindBar.java b/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/support/FindBar.java index 35e1eb25bae0..009b72c7cb1a 100644 --- a/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/support/FindBar.java +++ b/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/support/FindBar.java @@ -41,6 +41,7 @@ import javax.swing.KeyStroke; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import org.openide.util.ImageUtilities; /** * A panel to facilitate text searches with the following elements: @@ -84,7 +85,7 @@ public interface Owner { private final class CloseAction extends AbstractAction { public CloseAction() { - super(Catalog.get("CTL_Close"), new ImageIcon(FindBar.class.getResource("find_close.png"))); + super(Catalog.get("CTL_Close"), ImageUtilities.loadIcon("org/netbeans/lib/terminalemulator/support/find_close.png")); } @Override @@ -99,7 +100,7 @@ public void actionPerformed(ActionEvent e) { private final class NextAction extends AbstractAction { public NextAction() { - super(Catalog.get("CTL_Next"), new ImageIcon(FindBar.class.getResource("find_next.png"))); // NOI18N + super(Catalog.get("CTL_Next"), ImageUtilities.loadIcon("org/netbeans/lib/terminalemulator/support/find_next.png")); // NOI18N } @Override @@ -114,7 +115,7 @@ public void actionPerformed(ActionEvent e) { private final class PrevAction extends AbstractAction { public PrevAction() { - super(Catalog.get("CTL_Previous"), new ImageIcon(FindBar.class.getResource("find_previous.png"))); // NOI18N + super(Catalog.get("CTL_Previous"), ImageUtilities.loadIcon("org/netbeans/lib/terminalemulator/support/find_previous.png")); // NOI18N } @Override diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index 5794f2d46505..bbcef631eba2 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -246,7 +246,7 @@ private static void startFailed(ServerDescription description, String mimeType) description.failedCount++; if (description.failedCount == INVALID_START_MAX_COUNT) { NotificationDisplayer.getDefault().notify(Bundle.TITLE_FailedToStart(mimeType), - ImageUtilities.loadImageIcon("/org/netbeans/modules/lsp/client/resources/error_16.png", false), + ImageUtilities.loadIcon("org/netbeans/modules/lsp/client/resources/error_16.png"), Bundle.DETAIL_FailedToStart(), null); } diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java index 200f6c9a8094..c4e1022dd926 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java @@ -193,8 +193,7 @@ protected void query(CompletionResultSet resultSet, Document doc, int caretOffse } String sortText = i.getSortText() != null ? i.getSortText() : i.getLabel(); CompletionItemKind kind = i.getKind(); - Icon ic = Icons.getCompletionIcon(kind); - ImageIcon icon = new ImageIcon(ImageUtilities.icon2Image(ic)); + ImageIcon icon = ImageUtilities.icon2ImageIcon(Icons.getCompletionIcon(kind)); resultSet.addItem(new org.netbeans.spi.editor.completion.CompletionItem() { @Override public void defaultAction(JTextComponent jtc) { diff --git a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java index 77c3b9d4cb93..29b0c794c7c5 100644 --- a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java +++ b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java @@ -385,10 +385,10 @@ private void initComponents() { jLabel1.setLabelFor(messageTextArea); Mnemonics.setLocalizedText(jLabel1, getMessage("CTL_CommitForm_Message")); // NOI18N - recentLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/mercurial/resources/icons/recent_messages.png"))); // NOI18N + recentLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/mercurial/resources/icons/recent_messages.png")); // NOI18N recentLink.setToolTipText(getMessage("CTL_CommitForm_RecentMessages")); // NOI18N - templateLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/mercurial/resources/icons/load_template.png"))); // NOI18N + templateLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/mercurial/resources/icons/load_template.png")); // NOI18N templateLink.setToolTipText(getMessage("CTL_CommitForm_LoadTemplate")); // NOI18N Mnemonics.setLocalizedText(cbAllFiles, getMessage("CTL_CommitForm_CommitAllFiles.text")); //NOI18N diff --git a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ErrorPanel.java b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ErrorPanel.java index 47eb1d6c2590..ef40812a7d9a 100644 --- a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ErrorPanel.java +++ b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ErrorPanel.java @@ -19,10 +19,11 @@ package org.netbeans.modules.refactoring.spi.impl; import java.awt.Dimension; import java.awt.GridBagConstraints; -import javax.swing.ImageIcon; +import javax.swing.Icon; import javax.swing.JPanel; import org.netbeans.modules.refactoring.api.Problem; import org.netbeans.modules.refactoring.spi.ui.RefactoringUI; +import org.openide.util.ImageUtilities; /** * @@ -30,7 +31,7 @@ */ public class ErrorPanel extends javax.swing.JPanel { - private static ImageIcon fatalImage = null, nonFatalImage = null; + private static Icon fatalImage = null, nonFatalImage = null; private RefactoringUI ui; /** Creates new form ErrorPanel */ @@ -81,16 +82,16 @@ public void setProblems(Problem problem) { errors.add(jp, gridBagConstraints); } - static ImageIcon getFatalErrorIcon() { + static Icon getFatalErrorIcon() { if (fatalImage == null) { - fatalImage = new ImageIcon(ErrorPanel.class.getResource("/org/netbeans/modules/refactoring/api/resources/error.png")); //NOI18N + fatalImage = ImageUtilities.loadIcon("org/netbeans/modules/refactoring/api/resources/error.png"); //NOI18N } return fatalImage; } - static ImageIcon getNonfatalErrorIcon() { + static Icon getNonfatalErrorIcon() { if (nonFatalImage == null) { - nonFatalImage = new ImageIcon(ErrorPanel.class.getResource("/org/netbeans/modules/refactoring/api/resources/warning.png")); //NOI18N + nonFatalImage = ImageUtilities.loadIcon("org/netbeans/modules/refactoring/api/resources/warning.png"); //NOI18N } return nonFatalImage; } diff --git a/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/ThreadsHistoryAction.java b/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/ThreadsHistoryAction.java index bd718ff7ac61..975283fe4c65 100644 --- a/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/ThreadsHistoryAction.java +++ b/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/ThreadsHistoryAction.java @@ -28,7 +28,6 @@ import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; -import java.lang.reflect.Method; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; @@ -36,10 +35,7 @@ import java.util.Set; import javax.swing.AbstractAction; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.KeyStroke; -import org.netbeans.api.debugger.DebuggerManager; -import org.netbeans.api.debugger.Session; import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport; import org.netbeans.spi.debugger.ui.DebuggingView.DVThread; import org.netbeans.spi.debugger.ui.DebuggingView.Deadlock; @@ -193,19 +189,16 @@ public static List getThreads() { } private static class ThreadStatusIcon implements Icon { - - private Image image; - private ImageIcon iconBase; + private Icon iconBase; private boolean isCurrent; private boolean isAtBreakpoint; private boolean isInDeadlock; ThreadStatusIcon(Image image, boolean isCurrent, boolean isAtBreakpoint, boolean isInDeadlock) { - this.image = image; this.isCurrent = isCurrent; this.isAtBreakpoint = isAtBreakpoint; this.isInDeadlock = isInDeadlock; - iconBase = new ImageIcon(image); + this.iconBase = ImageUtilities.image2Icon(image); } @Override @@ -228,7 +221,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { Color originalColor = g.getColor(); g.setColor(c.getBackground()); g.fillRect(x, y, width, height); - g.drawImage(image, x + width, y, iconBase.getImageObserver()); + iconBase.paintIcon(c, g, x + width, y); if (primaryColor != null) { g.setColor(primaryColor); g.fillRect(x, y, DebuggingViewComponent.BAR_WIDTH, height); diff --git a/ide/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java b/ide/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java index 5a800e5d407e..68b29091e10f 100644 --- a/ide/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java +++ b/ide/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java @@ -101,6 +101,7 @@ import static javax.swing.LayoutStyle.ComponentPlacement.RELATED; import javax.swing.text.Keymap; import org.openide.awt.TabbedPaneFactory; +import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Utilities; import org.openide.util.actions.CallbackSystemAction; @@ -362,10 +363,10 @@ private void initComponents() { jLabel1.setLabelFor(messageTextArea); Mnemonics.setLocalizedText(jLabel1, getMessage("CTL_CommitForm_Message")); // NOI18N - recentLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/recent_messages.png"))); // NOI18N + recentLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/subversion/resources/icons/recent_messages.png")); // NOI18N recentLink.setToolTipText(getMessage("CTL_CommitForm_RecentMessages")); // NOI18N - templateLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/load_template.png"))); // NOI18N + templateLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/subversion/resources/icons/load_template.png")); // NOI18N templateLink.setToolTipText(getMessage("CTL_CommitForm_LoadTemplate")); // NOI18N messageTextArea.setColumns(70); //this determines the preferred width of the whole dialog diff --git a/ide/utilities/src/org/netbeans/modules/openfile/PackagePanel.java b/ide/utilities/src/org/netbeans/modules/openfile/PackagePanel.java index a864116693ff..2604b66c2dbd 100644 --- a/ide/utilities/src/org/netbeans/modules/openfile/PackagePanel.java +++ b/ide/utilities/src/org/netbeans/modules/openfile/PackagePanel.java @@ -40,6 +40,8 @@ import javax.swing.ListCellRenderer; import javax.swing.ListSelectionModel; import java.awt.event.*; +import javax.swing.ImageIcon; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; @@ -109,8 +111,8 @@ private void initComponents2() { list.setSelectionMode (ListSelectionModel.SINGLE_SELECTION); if (pkgLevel != -1) list.setSelectedIndex (pkgLevel); list.setCellRenderer (new ListCellRenderer () { - private Icon folderIcon = new ImageIcon (OpenFile.class.getResource ("folder.gif")); // NOI18N - private Icon rootFolderIcon = new ImageIcon (OpenFile.class.getResource ("rootFolder.gif")); // NOI18N + private Icon folderIcon = ImageUtilities.loadIcon("org/netbeans/modules/openfile/folder.gif"); // NOI18N + private Icon rootFolderIcon = ImageUtilities.loadIcon("org/netbeans/modules/openfile/rootFolder.gif"); // NOI18N private final JLabel lab = new JLabel(); public Component getListCellRendererComponent (JList lst, Object value, int index, boolean isSelected, boolean cellHasFocus) { diff --git a/ide/versioning.util/src/org/netbeans/modules/versioning/util/common/VCSCommitParameters.java b/ide/versioning.util/src/org/netbeans/modules/versioning/util/common/VCSCommitParameters.java index d27c00e66b5c..1168108700be 100644 --- a/ide/versioning.util/src/org/netbeans/modules/versioning/util/common/VCSCommitParameters.java +++ b/ide/versioning.util/src/org/netbeans/modules/versioning/util/common/VCSCommitParameters.java @@ -32,7 +32,6 @@ import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; @@ -48,6 +47,7 @@ import org.openide.util.ChangeSupport; import org.openide.util.NbBundle; import static javax.swing.LayoutStyle.ComponentPlacement.RELATED; +import org.openide.util.ImageUtilities; /** * @@ -92,7 +92,7 @@ public void addChangeListener(ChangeListener listener) { public static JLabel createRecentMessagesLink(final JTextArea text, final Preferences preferences) { final JLabel recentLink = new JLabel(); - recentLink.setIcon(new ImageIcon(VCSCommitParameters.class.getResource("/org/netbeans/modules/versioning/util/resources/recent_messages.png"))); // NOI18N + recentLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/versioning/util/resources/recent_messages.png")); // NOI18N recentLink.setToolTipText(getMessage("CTL_CommitForm_RecentMessages")); // NOI18N recentLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -121,7 +121,7 @@ protected JLabel getRecentMessagesLink(final JTextArea text) { protected static JLabel createMessagesTemplateLink(final JTextArea text, final Preferences preferences, final String helpCtxId) { final JLabel templateLink = new JLabel(); - templateLink.setIcon(new ImageIcon(VCSCommitParameters.class.getResource("/org/netbeans/modules/versioning/util/resources/load_template.png"))); // NOI18N + templateLink.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/versioning/util/resources/load_template.png")); // NOI18N templateLink.setToolTipText(getMessage("CTL_CommitForm_LoadTemplate")); // NOI18N templateLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); diff --git a/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java b/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java index ba0300142137..3cf525b7b0ad 100644 --- a/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java +++ b/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java @@ -238,7 +238,8 @@ public static ImageIcon getIcon(FileObject fo) { return PACKAGE_ICON; } else { try { - return new ImageIcon(DataObject.find(fo).getNodeDelegate().getIcon(java.beans.BeanInfo.ICON_COLOR_16x16)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon( + DataObject.find(fo).getNodeDelegate().getIcon(java.beans.BeanInfo.ICON_COLOR_16x16))); } catch (DataObjectNotFoundException e) { Logger.getLogger(FileReferenceCompletion.class.getName()).log(Level.INFO, "Cannot find icon for " + fo.getNameExt(), e); } diff --git a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/AttributeResultItem.java b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/AttributeResultItem.java index 6f04d2e171c9..2634f4984a9e 100644 --- a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/AttributeResultItem.java +++ b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/AttributeResultItem.java @@ -18,7 +18,6 @@ */ package org.netbeans.modules.xml.schema.completion; -import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import org.netbeans.api.lexer.Token; import org.netbeans.api.lexer.TokenId; @@ -27,6 +26,7 @@ import org.netbeans.modules.xml.axi.AbstractAttribute; import org.netbeans.modules.xml.schema.completion.spi.CompletionContext; import org.netbeans.modules.xml.schema.completion.CompletionPaintComponent.AttributePaintComponent; +import org.openide.util.ImageUtilities; /** * @@ -42,8 +42,7 @@ public class AttributeResultItem extends CompletionResultItem { public AttributeResultItem(AbstractAttribute attribute, CompletionContext context) { super(attribute, context); itemText = attribute.getName(); - icon = new ImageIcon(CompletionResultItem.class. - getResource(ICON_LOCATION + ICON_ATTRIBUTE)); + icon = ImageUtilities.loadIcon(ICON_LOCATION + ICON_ATTRIBUTE); } /** @@ -52,8 +51,7 @@ public AttributeResultItem(AbstractAttribute attribute, CompletionContext contex public AttributeResultItem(AbstractAttribute attribute, String prefix, CompletionContext context) { super(attribute, context); itemText = prefix + ":" + attribute.getName(); - icon = new ImageIcon(CompletionResultItem.class. - getResource(ICON_LOCATION + ICON_ATTRIBUTE)); + icon = ImageUtilities.loadIcon(ICON_LOCATION + ICON_ATTRIBUTE); } private int caretOffset = -1; diff --git a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/CompletionResultItem.java b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/CompletionResultItem.java index 390b6caeb505..721efc981a88 100644 --- a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/CompletionResultItem.java +++ b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/CompletionResultItem.java @@ -55,7 +55,7 @@ public abstract class CompletionResultItem implements CompletionItem { ICON_ELEMENT = "element.png", //NOI18N ICON_ATTRIBUTE = "attribute.png", //NOI18N ICON_VALUE = "value.png", //NOI18N - ICON_LOCATION = "/org/netbeans/modules/xml/schema/completion/resources/"; //NOI18N + ICON_LOCATION = "org/netbeans/modules/xml/schema/completion/resources/"; //NOI18N protected boolean shift = false; protected String typedChars; diff --git a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ElementResultItem.java b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ElementResultItem.java index 9cd39017a721..6792b4a07677 100644 --- a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ElementResultItem.java +++ b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ElementResultItem.java @@ -18,7 +18,6 @@ */ package org.netbeans.modules.xml.schema.completion; -import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import org.netbeans.api.lexer.TokenSequence; import org.netbeans.api.xml.lexer.XMLTokenId; @@ -31,6 +30,7 @@ import org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl; import org.netbeans.modules.xml.schema.completion.util.CompletionUtil; import org.netbeans.modules.xml.schema.model.Attribute.Use; +import org.openide.util.ImageUtilities; /** * @@ -51,8 +51,7 @@ public ElementResultItem(AbstractElement element, CompletionContext context, TokenSequence tokenSequence) { super(element, context, tokenSequence); itemText = element.getName(); - icon = new ImageIcon(CompletionResultItem.class.getResource( - ICON_LOCATION + ICON_ELEMENT)); + icon = ImageUtilities.loadIcon(ICON_LOCATION + ICON_ELEMENT); } /** @@ -62,8 +61,7 @@ public ElementResultItem(AbstractElement element, CompletionContext context, public ElementResultItem(AbstractElement element, String prefix, CompletionContextImpl context) { super(element, context); itemText = prefix + ":" + element.getName(); - icon = new ImageIcon(CompletionResultItem.class. - getResource(ICON_LOCATION + ICON_ELEMENT)); + icon = ImageUtilities.loadIcon(ICON_LOCATION + ICON_ELEMENT); } @Override diff --git a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ValueResultItem.java b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ValueResultItem.java index 2f41277a316b..4762e2d7fcab 100644 --- a/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ValueResultItem.java +++ b/ide/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/ValueResultItem.java @@ -18,7 +18,6 @@ */ package org.netbeans.modules.xml.schema.completion; -import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import org.netbeans.api.lexer.TokenId; import org.netbeans.api.lexer.TokenSequence; @@ -26,6 +25,7 @@ import org.netbeans.modules.xml.axi.AXIComponent; import org.netbeans.modules.xml.schema.completion.CompletionPaintComponent.ValuePaintComponent; import org.netbeans.modules.xml.schema.completion.spi.CompletionContext; +import org.openide.util.ImageUtilities; /** * @@ -38,8 +38,7 @@ public class ValueResultItem extends CompletionResultItem { public ValueResultItem(AXIComponent forComponent, String value, CompletionContext context) { super(forComponent, context); this.itemText = value; - this.icon = new ImageIcon(CompletionResultItem.class. - getResource(ICON_LOCATION + ICON_VALUE)); + this.icon = ImageUtilities.loadIcon(ICON_LOCATION + ICON_VALUE); } @Override diff --git a/ide/xml.text/src/org/netbeans/modules/xml/text/completion/IconStore.java b/ide/xml.text/src/org/netbeans/modules/xml/text/completion/IconStore.java deleted file mode 100644 index 95b933c3781f..000000000000 --- a/ide/xml.text/src/org/netbeans/modules/xml/text/completion/IconStore.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.netbeans.modules.xml.text.completion; - -import java.util.HashMap; - -import javax.swing.ImageIcon; - -/** - * @author Sandeep Singh Randhawa - * @version 0.1 - */ -final class IconStore extends Object { - - public static final String EMPTY_TAG = "/org/netbeans/modules/xml/text/completion/resources/emptyTag"; - public static final String END_TAG = "/org/netbeans/modules/xml/text/completion/resources/endTag"; - public static final String CHILDREN = "/org/netbeans/modules/xml/text/completion/resources/typeChildren"; - public static final String MIXED = "/org/netbeans/modules/xml/text/completion/resources/typeMixed"; - public static final String PCDATA = "/org/netbeans/modules/xml/text/completion/resources/typePCDATA"; - - public static final String TYPE_ENTITY = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITY"; - public static final String TYPE_ENTITIES = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITIES"; - public static final String TYPE_ENUMERATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeEn"; - public static final String TYPE_ID = "/org/netbeans/modules/xml/text/completion/resources/attTypeID"; - public static final String TYPE_IDREF = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREF"; - public static final String TYPE_IDREFS = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREFS"; - public static final String TYPE_NMTOKEN = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKEN"; - public static final String TYPE_NMTOKENS = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKENS"; - public static final String TYPE_NOTATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeNOTATION"; - public static final String TYPE_CDATA = "/org/netbeans/modules/xml/text/completion/resources/typeCDATA"; - - public static final String SPACER_16 = "/org/netbeans/modules/xml/text/completion/resources/spacer_16"; - public static final String SPACER_8 = "/org/netbeans/modules/xml/text/completion/resources/spacer_8"; - public static final String ICON_SUFFIX = ".gif"; - - /** HashMap{@link java.util.HashMap } that acts as a store for the icons. - */ - private static HashMap iconsMap = new HashMap<>(); - - /** Main method to retrieve the ImageIcon{@link javax.swing.ImageIcon} - * @param name Name of the icon to retrieve. In most instances would be one of the variables of - * this class. - * @return ImageIcon{@link javax.swing.ImageIcon} - */ - - public static ImageIcon getImageIcon(String name){ - if(name == null) - name = SPACER_16; - - if(iconsMap.containsKey(name)) - return iconsMap.get(name); - else{ - iconsMap.put(name, new ImageIcon(IconStore.class.getResource(name + ICON_SUFFIX))); - return iconsMap.get(name); - } - } -} diff --git a/java/form/src/org/netbeans/modules/form/FormToolBar.java b/java/form/src/org/netbeans/modules/form/FormToolBar.java index a83c2b59655c..5c6695075ac1 100644 --- a/java/form/src/org/netbeans/modules/form/FormToolBar.java +++ b/java/form/src/org/netbeans/modules/form/FormToolBar.java @@ -104,8 +104,7 @@ public FormToolBar(FormDesigner designer, JToolBar toolbar) { // palette button paletteButton = new JToggleButton( - new ImageIcon(getClass().getResource( - "/org/netbeans/modules/form/resources/beansButton.gif")), // NOI18N + ImageUtilities.loadIcon("org/netbeans/modules/form/resources/beansButton.gif"), // NOI18N false); paletteButton.addActionListener(listener); paletteButton.addMouseListener(listener); diff --git a/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/GridBagCustomizer.java b/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/GridBagCustomizer.java index 4526e5bd423f..d475a133beb2 100644 --- a/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/GridBagCustomizer.java +++ b/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/GridBagCustomizer.java @@ -57,8 +57,8 @@ public final class GridBagCustomizer extends JPanel implements Customizer static final int PLUS = 1; static final int MINUS = -1; - private static final ImageIcon REMAINDER_ICON = new ImageIcon( - GridBagCustomizer.class.getResource("/org/netbeans/modules/form/layoutsupport/resources/remainder.gif")); // NOI18N + private static final Icon REMAINDER_ICON = ImageUtilities.loadIcon( + "org/netbeans/modules/form/layoutsupport/resources/remainder.gif"); // NOI18N // private DesignGridBagLayout designLayout; private GridBagLayoutSupport layoutSupport; diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java index 09945ede0eaa..3d23de5c24c3 100644 --- a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java +++ b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java @@ -87,6 +87,7 @@ import org.netbeans.swing.plaf.LFCustoms; import static javax.lang.model.type.TypeKind.VOID; +import javax.swing.Icon; /** * @@ -618,7 +619,7 @@ public void run() { abstract static class WhiteListJavaCompletionItem extends JavaCompletionItem { private static final String WARNING = "org/netbeans/modules/java/editor/resources/warning_badge.gif"; //NOI18N - private static ImageIcon warningIcon; + private static Icon warningIcon; private final WhiteListQuery.WhiteList whiteList; private final List> handles; private Boolean isBlackListed; @@ -683,10 +684,10 @@ public final ImageIcon getIcon() { return base; } if (warningIcon == null) { - warningIcon = ImageUtilities.loadImageIcon(WARNING, false); + warningIcon = ImageUtilities.loadIcon(WARNING); } assert warningIcon != null; - return new ImageIcon(ImageUtilities.mergeImages(base.getImage(), warningIcon.getImage(), 8, 8)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(base, warningIcon, 8, 8)); } protected ImageIcon getBaseIcon() { @@ -2214,9 +2215,9 @@ protected ImageIcon getBaseIcon() { return merged; } ImageIcon superIcon = super.getBaseIcon(); - merged = new ImageIcon( ImageUtilities.mergeImages( - superIcon.getImage(), - implement ? implementBadge.getImage() : overrideBadge.getImage(), + merged = ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons( + superIcon, + implement ? implementBadge : overrideBadge, 16 - 8, 16 - 8) ); @@ -2298,7 +2299,7 @@ static class GetterSetterMethodItem extends JavaCompletionItem { private static final String SETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/setter_badge.png"; //NOI18N private static final String PARAMETER_NAME_COLOR = Utilities.getHTMLColor(224, 160, 65); - private static ImageIcon superIcon; + private static Icon superIcon; private static ImageIcon[] merged_icons = new ImageIcon[2]; protected ElementHandle elementHandle; @@ -2394,16 +2395,16 @@ protected String getRightHtmlText() { protected ImageIcon getIcon() { if (merged_icons[setter ? 1 : 0] == null) { if (superIcon == null) { - superIcon = ImageUtilities.loadImageIcon(METHOD_PUBLIC, false); + superIcon = ImageUtilities.loadIcon(METHOD_PUBLIC); } if (setter) { - ImageIcon setterBadge = ImageUtilities.loadImageIcon(SETTER_BADGE_PATH, false); - merged_icons[1] = new ImageIcon(ImageUtilities.mergeImages(superIcon.getImage(), - setterBadge.getImage(), 16 - 8, 16 - 8)); + Icon setterBadge = ImageUtilities.loadIcon(SETTER_BADGE_PATH); + merged_icons[1] = ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(superIcon, + setterBadge, 16 - 8, 16 - 8)); } else { - ImageIcon getterBadge = ImageUtilities.loadImageIcon(GETTER_BADGE_PATH, false); - merged_icons[0] = new ImageIcon(ImageUtilities.mergeImages(superIcon.getImage(), - getterBadge.getImage(), 16 - 8, 16 - 8)); + Icon getterBadge = ImageUtilities.loadIcon(GETTER_BADGE_PATH); + merged_icons[0] = ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(superIcon, + getterBadge, 16 - 8, 16 - 8)); } } return merged_icons[setter ? 1 : 0]; diff --git a/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java b/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java index 6c10dd7127e4..aa083268f8fe 100644 --- a/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java +++ b/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java @@ -30,7 +30,6 @@ import java.util.List; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListModel; @@ -211,7 +210,7 @@ public Component getListCellRendererComponent( g.setColor(fgColor); // Render the item - CompletionUtilities.renderHtml(new ImageIcon(ImageUtilities.icon2Image(getIcon())), getText(), null, g, getFont(), fgColor, getWidth(), getHeight(), selected); + CompletionUtilities.renderHtml(ImageUtilities.icon2ImageIcon(getIcon()), getText(), null, g, getFont(), fgColor, getWidth(), getHeight(), selected); } } diff --git a/java/jshell.support/src/org/netbeans/modules/jshell/editor/CommandCompletionProvider.java b/java/jshell.support/src/org/netbeans/modules/jshell/editor/CommandCompletionProvider.java index 697970da6015..ed81b1be5672 100644 --- a/java/jshell.support/src/org/netbeans/modules/jshell/editor/CommandCompletionProvider.java +++ b/java/jshell.support/src/org/netbeans/modules/jshell/editor/CommandCompletionProvider.java @@ -337,7 +337,7 @@ protected ImageIcon getIcon() { n = f.getLookup().lookup(Node.class); } if (n != null) { - return new ImageIcon(n.getIcon(BeanInfo.ICON_COLOR_16x16)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(n.getIcon(BeanInfo.ICON_COLOR_16x16))); } } } diff --git a/java/jshell.support/src/org/netbeans/modules/jshell/editor/ConsoleEditor.java b/java/jshell.support/src/org/netbeans/modules/jshell/editor/ConsoleEditor.java index f6c284a39e79..69888016ff05 100644 --- a/java/jshell.support/src/org/netbeans/modules/jshell/editor/ConsoleEditor.java +++ b/java/jshell.support/src/org/netbeans/modules/jshell/editor/ConsoleEditor.java @@ -25,7 +25,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.Action; -import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JLabel; @@ -58,6 +57,7 @@ import org.openide.text.CloneableEditor; import org.openide.text.CloneableEditorSupport; import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.windows.TopComponent; @@ -572,11 +572,7 @@ private JComponent prepareInitPanel() { JLabel l = initializingPanel; if (initializingPanel == null) { l = new JLabel(Bundle.MSG_Initializing(), JLabel.LEADING); - l.setIcon(new ImageIcon( - getClass().getClassLoader().getResource( - "org/netbeans/modules/jshell/resources/wait16.gif" - ) - )); + l.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/jshell/resources/wait16.gif")); initializingPanel = l; } return initializingPanel; diff --git a/java/spring.beans/src/org/netbeans/modules/spring/beans/completion/SpringXMLConfigCompletionItem.java b/java/spring.beans/src/org/netbeans/modules/spring/beans/completion/SpringXMLConfigCompletionItem.java index f4733e2a1dc1..39e3e1e871ac 100644 --- a/java/spring.beans/src/org/netbeans/modules/spring/beans/completion/SpringXMLConfigCompletionItem.java +++ b/java/spring.beans/src/org/netbeans/modules/spring/beans/completion/SpringXMLConfigCompletionItem.java @@ -795,7 +795,7 @@ public boolean instantSubstitution(JTextComponent component) { @Override protected ImageIcon getIcon() { - return new ImageIcon(getTreeFolderIcon()); + return ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(getTreeFolderIcon())); } @Override diff --git a/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ResourcePathItem.java b/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ResourcePathItem.java index 18cfa1f8c66f..d19d0f481c37 100644 --- a/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ResourcePathItem.java +++ b/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ResourcePathItem.java @@ -62,7 +62,7 @@ protected int getCaretShift(Document d) { @Override protected ImageIcon getIcon() { if (icon == null) { - icon = new ImageIcon(target.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16)); + icon = ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(target.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16))); } return icon; } diff --git a/php/php.api.framework/src/org/netbeans/modules/php/api/framework/BadgeIcon.java b/php/php.api.framework/src/org/netbeans/modules/php/api/framework/BadgeIcon.java index 8f06c5821f26..de26878cc995 100644 --- a/php/php.api.framework/src/org/netbeans/modules/php/api/framework/BadgeIcon.java +++ b/php/php.api.framework/src/org/netbeans/modules/php/api/framework/BadgeIcon.java @@ -21,7 +21,8 @@ import java.awt.Image; import java.net.URL; -import javax.swing.ImageIcon; +import javax.swing.Icon; +import org.openide.util.ImageUtilities; import org.openide.util.Parameters; /** @@ -46,7 +47,7 @@ public BadgeIcon(Image image, URL url) { boolean assertions = false; assert assertions = true; if (assertions) { - ImageIcon imageIcon = new ImageIcon(image); + Icon imageIcon = ImageUtilities.image2Icon(image); if (imageIcon.getIconWidth() != 8) { throw new IllegalArgumentException("The width of an image must be 8 px"); } diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/FSCompletion.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/FSCompletion.java index cc25a80fffbc..b2c8e3c0d545 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/FSCompletion.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/FSCompletion.java @@ -65,6 +65,7 @@ import org.openide.loaders.DataObject; import org.openide.util.BaseUtilities; import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; import org.openide.util.Utilities; /** @@ -296,7 +297,7 @@ public FSCompletionItem(FileObject file, String prefix, int anchor) throws IOExc DataObject od = DataObject.find(file); - icon = new ImageIcon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16)); + icon = ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16))); this.anchor = anchor; diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java index 2ec01950f2ce..206827c56741 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java @@ -2133,7 +2133,7 @@ public ElementKind getKind() { private static ImageIcon icon() { if (interfaceIcon == null) { - interfaceIcon = new ImageIcon(ImageUtilities.loadImage(PHP_INTERFACE_ICON)); + interfaceIcon = ImageUtilities.loadImageIcon(PHP_INTERFACE_ICON, false); } return interfaceIcon; } diff --git a/php/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/TplCompletionItem.java b/php/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/TplCompletionItem.java index b4325aaf7ed4..aaa1966feed0 100644 --- a/php/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/TplCompletionItem.java +++ b/php/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/TplCompletionItem.java @@ -34,6 +34,7 @@ import javax.swing.text.JTextComponent; import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; import org.netbeans.spi.editor.completion.support.CompletionUtilities; +import org.openide.util.ImageUtilities; /** * Code completion result item base class @@ -208,7 +209,7 @@ public void render(Graphics g, Font defaultFont, Color defaultColor, Color backg } protected ImageIcon getIcon() { - return new ImageIcon(getClass().getResource("/org/netbeans/modules/php/smarty/resources/tpl-cc-icon.png")); + return ImageUtilities.loadImageIcon("org/netbeans/modules/php/smarty/resources/tpl-cc-icon.png", false); } protected String getLeftHtmlText() { diff --git a/platform/o.n.swing.outline/src/org/netbeans/swing/etable/ETableHeader.java b/platform/o.n.swing.outline/src/org/netbeans/swing/etable/ETableHeader.java index f999638184c4..2ed46b422864 100644 --- a/platform/o.n.swing.outline/src/org/netbeans/swing/etable/ETableHeader.java +++ b/platform/o.n.swing.outline/src/org/netbeans/swing/etable/ETableHeader.java @@ -37,6 +37,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import org.openide.util.ImageUtilities; /** * The ETable header renderer. @@ -179,7 +180,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, if (customIcon == null) { label.setIcon(sortIcon); } else { - label.setIcon(mergeIcons(customIcon, sortIcon, 16, 0, label)); + label.setIcon(ImageUtilities.mergeIcons(customIcon, sortIcon, 16, 0)); } } } @@ -242,39 +243,4 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.drawLine(x + 8, y + 6, x + 4, y + 2); } } - - /** - * Utility method merging 2 icons. - */ - private static Icon mergeIcons(Icon icon1, Icon icon2, int x, int y, Component c) { - int w = 0, h = 0; - if (icon1 != null) { - w = icon1.getIconWidth(); - h = icon1.getIconHeight(); - } - if (icon2 != null) { - w = icon2.getIconWidth() + x > w ? icon2.getIconWidth() + x : w; - h = icon2.getIconHeight() + y > h ? icon2.getIconHeight() + y : h; - } - if (w < 1) w = 16; - if (h < 1) h = 16; - - java.awt.image.ColorModel model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment (). - getDefaultScreenDevice ().getDefaultConfiguration (). - getColorModel (java.awt.Transparency.BITMASK); - java.awt.image.BufferedImage buffImage = new java.awt.image.BufferedImage (model, - model.createCompatibleWritableRaster (w, h), model.isAlphaPremultiplied (), null); - - java.awt.Graphics g = buffImage.createGraphics (); - if (icon1 != null) { - icon1.paintIcon(c, g, 0, 0); - } - if (icon2 != null) { - icon2.paintIcon(c, g, x, y); - } - g.dispose(); - - return new ImageIcon(buffImage); - } - } diff --git a/platform/openide.awt/src/org/openide/awt/Actions.java b/platform/openide.awt/src/org/openide/awt/Actions.java index d5ea2db39c18..fa598c5838b1 100644 --- a/platform/openide.awt/src/org/openide/awt/Actions.java +++ b/platform/openide.awt/src/org/openide/awt/Actions.java @@ -103,15 +103,6 @@ public Actions() {} */ private static Icon nonNullIcon(Icon i) { return null; - - /*if (i != null) { - return i; - } else { - if (BLANK_ICON == null) { - BLANK_ICON = new ImageIcon(Utilities.loadImage("org/openide/resources/actions/empty.gif", true)); // NOI18N - } - return BLANK_ICON; - }*/ } /** Method that finds the keydescription assigned to this action. diff --git a/platform/options.keymap/src/org/netbeans/modules/options/keymap/TableSorter.java b/platform/options.keymap/src/org/netbeans/modules/options/keymap/TableSorter.java index 8d241c15b87f..9be107b4b748 100644 --- a/platform/options.keymap/src/org/netbeans/modules/options/keymap/TableSorter.java +++ b/platform/options.keymap/src/org/netbeans/modules/options/keymap/TableSorter.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.event.TableModelEvent; @@ -41,6 +40,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; +import org.openide.util.ImageUtilities; /** * TableSorter is a decorator for TableModels; adding sorting @@ -223,9 +223,9 @@ protected Icon getHeaderRendererIcon(int column, int size) { return null; } if (directive.direction == DESCENDING) { - return new ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/columnsSortedDesc.png")); // NOI18N + return ImageUtilities.loadIcon("org/netbeans/modules/options/keymap/columnsSortedDesc.png"); // NOI18N } else { - return new ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/columnsSortedAsc.png")); // NOI18N + return ImageUtilities.loadIcon("org/netbeans/modules/options/keymap/columnsSortedAsc.png"); // NOI18N } } diff --git a/platform/print/src/org/netbeans/modules/print/util/UI.java b/platform/print/src/org/netbeans/modules/print/util/UI.java index 2e171df02041..1c1decc6ff6f 100644 --- a/platform/print/src/org/netbeans/modules/print/util/UI.java +++ b/platform/print/src/org/netbeans/modules/print/util/UI.java @@ -65,6 +65,7 @@ import org.openide.awt.Mnemonics; import org.openide.loaders.DataObject; import org.openide.nodes.Node; +import org.openide.util.ImageUtilities; import org.openide.windows.TopComponent; import org.openide.util.Lookup; import org.openide.util.NbBundle; @@ -269,11 +270,11 @@ private static void print(String message, int type) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, type)); } - public static ImageIcon icon(Class clazz, String name) { + public static Icon icon(Class clazz, String name) { if (name == null) { return null; } - return new ImageIcon(clazz.getResource("image/" + name + ".gif")); // NOI18N + return ImageUtilities.loadIcon("org/netbeans/modules/print/util/image/" + name + ".gif"); // NOI18N } public static Node getSelectedNode() { diff --git a/profiler/lib.profiler.ui/nbproject/project.xml b/profiler/lib.profiler.ui/nbproject/project.xml index d3b8d70f7d09..63a73be0fba2 100644 --- a/profiler/lib.profiler.ui/nbproject/project.xml +++ b/profiler/lib.profiler.ui/nbproject/project.xml @@ -69,6 +69,14 @@ 8.9 + + org.openide.util.ui + + + + 9.37 + + diff --git a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/components/tree/MethodNameTreeCellRenderer.java b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/components/tree/MethodNameTreeCellRenderer.java index 7f13650632c2..a0d2e623cfa6 100644 --- a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/components/tree/MethodNameTreeCellRenderer.java +++ b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/components/tree/MethodNameTreeCellRenderer.java @@ -27,6 +27,7 @@ import org.netbeans.lib.profiler.ui.UIUtils; import org.netbeans.modules.profiler.api.icons.Icons; import org.netbeans.modules.profiler.api.icons.ProfilerIcons; +import org.openide.util.ImageUtilities; /** @@ -71,11 +72,11 @@ protected Icon getClosedIcon(Object value) { return threadIcon; } } else if (cct.isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getClosedIcon(value)); + return ImageUtilities.createDisabledIcon(super.getClosedIcon(value)); } } else if (value instanceof PresoObjAllocCCTNode) { if (((PresoObjAllocCCTNode)value).isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getClosedIcon(value)); + return ImageUtilities.createDisabledIcon(super.getClosedIcon(value)); } } @@ -165,11 +166,11 @@ protected Icon getLeafIcon(Object value) { return threadIcon; } } else if (cct.isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getLeafIcon(value)); + return ImageUtilities.createDisabledIcon(super.getLeafIcon(value)); } } else if (value instanceof PresoObjAllocCCTNode) { if (((PresoObjAllocCCTNode)value).isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getLeafIcon(value)); + return ImageUtilities.createDisabledIcon(super.getLeafIcon(value)); } } @@ -188,11 +189,11 @@ protected Icon getOpenIcon(Object value) { return threadIcon; } } else if (cct.isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getOpenIcon(value)); + return ImageUtilities.createDisabledIcon(super.getOpenIcon(value)); } } else if (value instanceof PresoObjAllocCCTNode) { if (((PresoObjAllocCCTNode)value).isFiltered()) { - return UIManager.getLookAndFeel().getDisabledIcon(this, super.getOpenIcon(value)); + return ImageUtilities.createDisabledIcon(super.getOpenIcon(value)); } } diff --git a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/cpu/CPUJavaNameRenderer.java b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/cpu/CPUJavaNameRenderer.java index 09233ebc572e..84fdfcc2021f 100644 --- a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/cpu/CPUJavaNameRenderer.java +++ b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/cpu/CPUJavaNameRenderer.java @@ -20,11 +20,11 @@ package org.netbeans.lib.profiler.ui.cpu; import javax.swing.Icon; -import javax.swing.UIManager; import org.netbeans.lib.profiler.results.cpu.PrestimeCPUCCTNode; import org.netbeans.lib.profiler.ui.swing.renderer.JavaNameRenderer; import org.netbeans.modules.profiler.api.icons.Icons; import org.netbeans.modules.profiler.api.icons.ProfilerIcons; +import org.openide.util.ImageUtilities; /** * @@ -33,9 +33,9 @@ public class CPUJavaNameRenderer extends JavaNameRenderer { private static final Icon THREAD_ICON = Icons.getIcon(ProfilerIcons.THREAD); - private static final Icon THREAD_ICON_DISABLED = UIManager.getLookAndFeel().getDisabledIcon(null, THREAD_ICON); + private static final Icon THREAD_ICON_DISABLED = ImageUtilities.createDisabledIcon(THREAD_ICON); private static final Icon LEAF_ICON = Icons.getIcon(ProfilerIcons.NODE_LEAF); - private static final Icon LEAF_ICON_DISABLED = UIManager.getLookAndFeel().getDisabledIcon(null, LEAF_ICON); + private static final Icon LEAF_ICON_DISABLED = ImageUtilities.createDisabledIcon(LEAF_ICON); private final Icon icon; private final Icon iconDisabled; @@ -46,7 +46,7 @@ public CPUJavaNameRenderer() { public CPUJavaNameRenderer(String iconKey) { this.icon = Icons.getIcon(iconKey); - this.iconDisabled = UIManager.getLookAndFeel().getDisabledIcon(null, icon); + this.iconDisabled = ImageUtilities.createDisabledIcon(icon); } public void setValue(Object value, int row) { diff --git a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/jdbc/JDBCJavaNameRenderer.java b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/jdbc/JDBCJavaNameRenderer.java index a2a9d8f7cb89..73c44ebab744 100644 --- a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/jdbc/JDBCJavaNameRenderer.java +++ b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/jdbc/JDBCJavaNameRenderer.java @@ -26,12 +26,12 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; -import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; import org.netbeans.lib.profiler.results.memory.PresoObjAllocCCTNode; import org.netbeans.lib.profiler.ui.swing.renderer.JavaNameRenderer; import org.netbeans.modules.profiler.api.icons.Icons; import org.netbeans.modules.profiler.api.icons.ProfilerIcons; +import org.openide.util.ImageUtilities; /** * @@ -40,9 +40,9 @@ final class JDBCJavaNameRenderer extends JavaNameRenderer { private static final Icon SQL_ICON = Icons.getIcon(ProfilerIcons.SQL_QUERY); - private static final Icon SQL_ICON_DISABLED = UIManager.getLookAndFeel().getDisabledIcon(null, SQL_ICON); + private static final Icon SQL_ICON_DISABLED = ImageUtilities.createDisabledIcon(SQL_ICON); private static final Icon LEAF_ICON = Icons.getIcon(ProfilerIcons.NODE_LEAF); - private static final Icon LEAF_ICON_DISABLED = UIManager.getLookAndFeel().getDisabledIcon(null, LEAF_ICON); + private static final Icon LEAF_ICON_DISABLED = ImageUtilities.createDisabledIcon(LEAF_ICON); private final Icon icon; private final Icon iconDisabled; @@ -56,7 +56,7 @@ public JDBCJavaNameRenderer() { public JDBCJavaNameRenderer(String iconKey) { this.icon = Icons.getIcon(iconKey); - this.iconDisabled = UIManager.getLookAndFeel().getDisabledIcon(null, icon); + this.iconDisabled = ImageUtilities.createDisabledIcon(icon); } public void setValue(Object value, int row) { diff --git a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/memory/MemoryJavaNameRenderer.java b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/memory/MemoryJavaNameRenderer.java index 63006fbe1049..6d0a01ca2192 100644 --- a/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/memory/MemoryJavaNameRenderer.java +++ b/profiler/lib.profiler.ui/src/org/netbeans/lib/profiler/ui/memory/MemoryJavaNameRenderer.java @@ -19,12 +19,12 @@ package org.netbeans.lib.profiler.ui.memory; import javax.swing.Icon; -import javax.swing.UIManager; import org.netbeans.lib.profiler.results.memory.PresoObjAllocCCTNode; import org.netbeans.lib.profiler.ui.swing.renderer.JavaNameRenderer; import org.netbeans.modules.profiler.api.icons.Icons; import org.netbeans.modules.profiler.api.icons.LanguageIcons; import org.netbeans.modules.profiler.api.icons.ProfilerIcons; +import org.openide.util.ImageUtilities; /** * @@ -34,7 +34,7 @@ public class MemoryJavaNameRenderer extends JavaNameRenderer { private static final Icon CLASS_ICON = Icons.getIcon(LanguageIcons.CLASS); private static final Icon REVERSE_ICON = Icons.getIcon(ProfilerIcons.NODE_REVERSE); - private static final Icon REVERSE_ICON_DISABLED = UIManager.getLookAndFeel().getDisabledIcon(null, REVERSE_ICON); + private static final Icon REVERSE_ICON_DISABLED = ImageUtilities.createDisabledIcon(REVERSE_ICON); public void setValue(Object value, int row) { if (value instanceof PresoObjAllocCCTNode) { diff --git a/profiler/profiler.api/src/org/netbeans/modules/profiler/api/icons/Icons.java b/profiler/profiler.api/src/org/netbeans/modules/profiler/api/icons/Icons.java index e8e8d6e1a4b3..d8dccfbe4e41 100644 --- a/profiler/profiler.api/src/org/netbeans/modules/profiler/api/icons/Icons.java +++ b/profiler/profiler.api/src/org/netbeans/modules/profiler/api/icons/Icons.java @@ -23,6 +23,7 @@ import javax.swing.Icon; import javax.swing.ImageIcon; import org.netbeans.modules.profiler.spi.IconsProvider; +import org.openide.util.ImageUtilities; import org.openide.util.Lookup; /** @@ -50,8 +51,11 @@ public static Icon getIcon(String key) { */ public static ImageIcon getImageIcon(String key) { Image image = getImage(key); - if (image == null) return null; - else return new ImageIcon(image); + if (image == null) { + return null; + } else { + return ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(image)); + } } /** diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/model/BrowserUtils.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/model/BrowserUtils.java index cc6dfd764097..cb04cf4e0583 100644 --- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/model/BrowserUtils.java +++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/model/BrowserUtils.java @@ -22,7 +22,6 @@ import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -250,15 +249,15 @@ public static HeapWalkerNode computeChildrenToNearestGCRoot(InstanceNode instanc } public static ImageIcon createGCRootIcon(ImageIcon icon) { - return new ImageIcon(ImageUtilities.mergeImages(icon.getImage(), ICON_GCROOT.getImage(), 0, 0)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(icon, ICON_GCROOT, 0, 0)); } public static ImageIcon createLoopIcon(ImageIcon icon) { - return new ImageIcon(ImageUtilities.mergeImages(icon.getImage(), ICON_LOOP.getImage(), 0, 0)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(icon, ICON_LOOP, 0, 0)); } public static ImageIcon createStaticIcon(ImageIcon icon) { - return new ImageIcon(ImageUtilities.mergeImages(icon.getImage(), ICON_STATIC.getImage(), 0, 0)); + return ImageUtilities.icon2ImageIcon(ImageUtilities.mergeIcons(icon, ICON_STATIC, 0, 0)); } public static HeapWalkerNode[] lazilyCreateChildren(final HeapWalkerNode parent, final ChildrenComputer childrenComputer) { diff --git a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/FSCompletionItem.java b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/FSCompletionItem.java index d0b6ee090e57..90bd4442082c 100644 --- a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/FSCompletionItem.java +++ b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/FSCompletionItem.java @@ -33,6 +33,7 @@ import org.netbeans.modules.csl.spi.ParserResult; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; +import org.openide.util.ImageUtilities; /** * @@ -52,7 +53,7 @@ public FSCompletionItem(final FileObject file, final String prefix, final boolea this.element = new FSElementHandle(file); DataObject od = DataObject.find(file); - icon = new ImageIcon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16)); + icon = ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16))); this.anchor = anchor; this.addExtension = addExtension; diff --git a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCompletionItem.java b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCompletionItem.java index 1e41e0f98872..4e4bbf61a061 100644 --- a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCompletionItem.java +++ b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCompletionItem.java @@ -338,7 +338,7 @@ public String getCustomInsertTemplate() { public ImageIcon getIcon() { if (getModifiers().contains(Modifier.PROTECTED)) { if(priviligedIcon == null) { - priviligedIcon = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/methodPriviliged.png")); //NOI18N + priviligedIcon = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/methodPriviliged.png", false); //NOI18N } return priviligedIcon; } @@ -408,17 +408,17 @@ public JsGeneratorCompletionItem(ElementHandle element, CompletionRequest reques public ImageIcon getIcon() { if (getModifiers().contains(Modifier.PUBLIC)) { if (publicGenerator == null) { - publicGenerator = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/generatorPublic.png")); //NOI18N + publicGenerator = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/generatorPublic.png", false); //NOI18N } return publicGenerator; } else if (getModifiers().contains(Modifier.PRIVATE)) { if (privateGenerator == null) { - privateGenerator = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/generatorPrivate.png")); //NOI18N + privateGenerator = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/generatorPrivate.png", false); //NOI18N } return privateGenerator; } else if (getModifiers().contains(Modifier.PROTECTED)) { if (priviligedGenerator == null) { - priviligedGenerator = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/generatorPriviliged.png")); //NOI18N + priviligedGenerator = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/generatorPriviliged.png", false); //NOI18N } return priviligedGenerator; } @@ -439,7 +439,7 @@ public JsCallbackCompletionItem(IndexedElement.FunctionIndexedElement element, C @Override public ImageIcon getIcon() { if (callbackIcon == null) { - callbackIcon = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/methodCallback.png")); //NOI18N + callbackIcon = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/methodCallback.png", false); //NOI18N } return callbackIcon; } @@ -572,7 +572,7 @@ public String getRhsHtml(HtmlFormatter formatter) { @Override public ImageIcon getIcon() { if (keywordIcon == null) { - keywordIcon = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/editor/resources/javascript.png")); //NOI18N + keywordIcon = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/editor/resources/javascript.png", false); //NOI18N } return keywordIcon; } diff --git a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/FSCompletionItem.java b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/FSCompletionItem.java index 68abd3cc56db..889a1a425e25 100644 --- a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/FSCompletionItem.java +++ b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/FSCompletionItem.java @@ -20,10 +20,8 @@ import java.beans.BeanInfo; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; import javax.swing.ImageIcon; import org.netbeans.modules.csl.api.CompletionProposal; @@ -35,6 +33,7 @@ import org.netbeans.modules.csl.spi.ParserResult; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; +import org.openide.util.ImageUtilities; /** * @@ -54,7 +53,7 @@ public FSCompletionItem(final FileObject file, final String prefix, final boolea this.element = new FSElementHandle(file); DataObject od = DataObject.find(file); - icon = new ImageIcon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16)); + icon = ImageUtilities.icon2ImageIcon(ImageUtilities.image2Icon(od.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16))); this.anchor = anchor; this.addExtension = addExtension; diff --git a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/MappingCompletionItem.java b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/MappingCompletionItem.java index 7323f9589cdd..3cbbb167f08c 100644 --- a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/MappingCompletionItem.java +++ b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/editor/MappingCompletionItem.java @@ -75,7 +75,7 @@ public boolean equals(Object o) { public ImageIcon getIcon() { if (REQUIREJS_ICON == null) { - REQUIREJS_ICON = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javascript2/requirejs/resources/requirejs.png")); //NOI18N + REQUIREJS_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/javascript2/requirejs/resources/requirejs.png", false); //NOI18N } return REQUIREJS_ICON; }