changeset 6:5e281961d0e3

Use new IconDescriptor API.
author Mario Torre <neugens.limasoftware@gmail.com>
date Mon, 11 Feb 2013 22:08:33 +0100
parents 8953d6ef1f06
children d49a2bbf53b0
files client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/IconResources.java client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingSchedulerView.java
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/IconResources.java	Thu Feb 07 18:33:33 2013 +0100
+++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/IconResources.java	Mon Feb 11 22:08:33 2013 +0100
@@ -37,6 +37,9 @@
 package com.redhat.thermostat.tutorial.schedule.client.common;
 
 import com.redhat.thermostat.client.ui.IconDescriptor;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * Class to hold {@link IconDescriptor} for the icons used by the plugin GUI.
@@ -54,14 +57,22 @@
 
     public static IconDescriptor getLoadFileIcon() {
         if (loadFile == null) {
-            loadFile = IconDescriptor.loadIcon("com/redhat/thermostat/tutorial/schedule/client/common/load.png");
+            try {
+                loadFile = IconDescriptor.loadIcon(IconResources.class.getClassLoader(), "com/redhat/thermostat/tutorial/schedule/client/common/load.png");
+            } catch (IOException ex) {
+                Logger.getLogger(IconResources.class.getName()).log(Level.SEVERE, null, ex);
+            }
         }
         return loadFile;
     }
 
     public static IconDescriptor getPresentationIcon() {
         if (presentation == null) {
-            presentation = IconDescriptor.loadIcon("com/redhat/thermostat/tutorial/schedule/client/common/presentation.png");
+            try {
+                presentation = IconDescriptor.loadIcon(IconResources.class.getClassLoader(), "com/redhat/thermostat/tutorial/schedule/client/common/presentation.png");
+            } catch (IOException ex) {
+                Logger.getLogger(IconResources.class.getName()).log(Level.SEVERE, null, ex);
+            }
         }
         return presentation;
     }
--- a/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingSchedulerView.java	Thu Feb 07 18:33:33 2013 +0100
+++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingSchedulerView.java	Mon Feb 11 22:08:33 2013 +0100
@@ -39,6 +39,7 @@
 import com.redhat.thermostat.client.swing.SwingComponent;
 import com.redhat.thermostat.client.swing.components.ActionButton;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
+import com.redhat.thermostat.client.swing.components.Icon;
 import com.redhat.thermostat.client.swing.components.ToolbarButton;
 import com.redhat.thermostat.tutorial.schedule.client.common.ClockView;
 import com.redhat.thermostat.tutorial.schedule.client.common.IconResources;
@@ -48,7 +49,6 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.File;
-import javax.swing.ImageIcon;
 import javax.swing.JFileChooser;
 import javax.swing.filechooser.FileFilter;
 
@@ -62,7 +62,7 @@
 
     public SwingSchedulerView() {
         uiComponent = new HeaderPanel(ClockUtils.localize(LocaleResources.HEADER_LABEL));
-        ToolbarButton loadSchedule = new ActionButton(new ImageIcon(IconResources.getLoadFileIcon().getData().array()),
+        ToolbarButton loadSchedule = new ActionButton(new Icon(IconResources.getLoadFileIcon()),
                                                       ClockUtils.localize(LocaleResources.LOAD_SCHEDULE));
         loadSchedule.getToolbarButton().addActionListener(new ActionListener() {
             @Override