# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/radim/devel/nb/nb_all/openide/util # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/openide/util/Utilities.java *** /home/radim/devel/nb/nb_all/openide/util/src/org/openide/util/Utilities.java Base (1.19) --- /home/radim/devel/nb/nb_all/openide/util/src/org/openide/util/Utilities.java Locally Modified (Based On 1.19) *************** *** 26,31 **** --- 26,32 ---- import java.awt.Dialog; import java.awt.Dimension; import java.awt.Frame; + import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Image; *************** *** 38,43 **** --- 39,45 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; + import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; import java.io.IOException; *************** *** 74,79 **** --- 76,84 ---- import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Action; + import javax.swing.Icon; + import javax.swing.ImageIcon; + import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JSeparator; *************** *** 2574,2579 **** --- 2579,2602 ---- return IconManager.getIcon(resourceID, false); } + /** + * Converts given icon to a {@link java.awt.Image}. + * + * @param icon {@link javax.swing.Icon} to be converted. + * @since 7.3 + */ + public static final Image icon2Image(Icon icon) { + if (icon instanceof ImageIcon) { + return ((ImageIcon) icon).getImage(); + } else { + BufferedImage bImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics g = bImage.getGraphics(); + icon.paintIcon(new JLabel(), g, 0, 0); + g.dispose(); + return bImage; + } + } + /** Builds a popup menu from actions for provided context specified by * Lookup. * Takes list of actions and for actions whic are instances of Index: apichanges.xml *** /home/radim/devel/nb/nb_all/openide/util/apichanges.xml Base (1.16) --- /home/radim/devel/nb/nb_all/openide/util/apichanges.xml Locally Modified (Based On 1.16) *************** *** 26,31 **** --- 26,49 ---- Actions API + + + Added Utilities.icon2Image method to perform conversion from Icon to Image + + + + + +

+ Conversion from Icon to Image is done + at various places and newly introduced method avoids the need to + duplicate the same code. +

+
+ + +
+ Added Exceptions class as a replacement for ErrorManager