[hg] main-silver: Issue #223550 - RepositoryComboRenderer asumes...

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: Issue #223550 - RepositoryComboRenderer asumes...
  • Date: Thu, 13 Dec 2012 06:35:42 -0800

changeset 098ba08a358b in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/098ba08a358b
description:
        Issue #223550 - RepositoryComboRenderer asumes getIcon to return Icon 
(SPI declares Image)

diffstat:

 
bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboRenderer.java
      |   9 ++++-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyRepository.java
 |  18 ++++++++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (70 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboRenderer.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboRenderer.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboRenderer.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboRenderer.java
@@ -44,8 +44,10 @@
 
 import java.awt.Component;
 import java.awt.Font;
+import java.awt.Image;
 import javax.swing.DefaultListCellRenderer;
 import javax.swing.Icon;
+import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.swing.JList;
 import org.netbeans.modules.bugtracking.RepositoryImpl;
@@ -100,7 +102,12 @@
         if (result instanceof JLabel) {
             JLabel label = (JLabel) result;
             if (repo != null) {
-                label.setIcon((Icon) repo.getIcon());
+                Image icon = repo.getIcon();
+                if(icon instanceof Icon) {
+                    label.setIcon((Icon) icon);
+            } else {
+                    label.setIcon(new ImageIcon(icon));
+                }
             } else {
                 Font font = label.getFont();
                 label.setFont(new Font(font.getName(),
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyRepository.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyRepository.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyRepository.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyRepository.java
@@ -44,14 +44,16 @@
 
 import java.awt.Image;
 import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collection;
 import java.util.Collections;
+import javax.imageio.ImageIO;
 import org.netbeans.modules.bugtracking.TestIssue;
 import org.netbeans.modules.bugtracking.TestKit;
 import org.netbeans.modules.bugtracking.TestQuery;
 import org.netbeans.modules.bugtracking.TestRepository;
 import org.netbeans.modules.bugtracking.spi.*;
-import org.openide.util.ImageUtilities;
 import org.openide.util.Lookup;
 
 /**
@@ -60,8 +62,18 @@
  */
 public class DummyRepository extends TestRepository {
 
-    private static final Image icon = ImageUtilities.loadImage(
-            
"org/netbeans/modules/bugtracking/dummies/DummyRepositoryIcon.png");
+    private static final Image icon;
+
+    static {
+        try {
+            InputStream is = DummyRepository.class.getResourceAsStream(
+                    
"/org/netbeans/modules/bugtracking/dummies/DummyRepositoryIcon.png");
+            icon = ImageIO.read(is);
+            is.close();
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
 
     private final DummyBugtrackingConnector connector;
     private final String id;

[hg] main-silver: Issue #223550 - RepositoryComboRenderer asumes...

Tomas Stupka 12/13/2012

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 64 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close