diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-07-30 12:06:28 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-07-30 12:06:28 +0000 |
commit | 9e5c4e5541ab1608cd70149c06a42c193c68ff18 (patch) | |
tree | ee8bcdcc4411bd5fe9835dee8a05f73ebc8107b1 /client/trunk/src/com/fourisland | |
parent | 5e07f647fd361b8a082d053606dd9d132224606a (diff) | |
download | instadisc-9e5c4e5541ab1608cd70149c06a42c193c68ff18.tar.gz instadisc-9e5c4e5541ab1608cd70149c06a42c193c68ff18.tar.bz2 instadisc-9e5c4e5541ab1608cd70149c06a42c193c68ff18.zip |
Client: Added System Tray Icon
Added an icon to the System Tray that shows a message whenever a new Item is recieved.
Diffstat (limited to 'client/trunk/src/com/fourisland')
6 files changed, 37 insertions, 1 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java b/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java index 644217f..39c6445 100644 --- a/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java +++ b/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java | |||
@@ -24,7 +24,7 @@ public class IDItemListCellRenderer extends JLabel implements ListCellRenderer { | |||
24 | Item item = (Item) arg1; | 24 | Item item = (Item) arg1; |
25 | 25 | ||
26 | this.setIcon(Category.iconFromCategory(Wrapper.getSubscription(item.getSubscription()).getCategory())); | 26 | this.setIcon(Category.iconFromCategory(Wrapper.getSubscription(item.getSubscription()).getCategory())); |
27 | this.setText("<HTML><I>" + Wrapper.getSubscription(item.getSubscription()).getTitle() + "</I><B>" + item.getTitle() + "</B> by " + item.getAuthor()); | 27 | this.setText("<HTML><I>" + Wrapper.getSubscription(item.getSubscription()).getTitle() + "</I>, <B>" + item.getTitle() + "</B> by " + item.getAuthor()); |
28 | 28 | ||
29 | /*if (item.getUnread()) { | 29 | /*if (item.getUnread()) { |
30 | this.setBackground(Color.YELLOW); | 30 | this.setBackground(Color.YELLOW); |
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscApp.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscApp.java index cd3f1dd..dffb663 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscApp.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscApp.java | |||
@@ -5,6 +5,7 @@ package com.fourisland.instadisc; | |||
5 | 5 | ||
6 | import com.fourisland.instadisc.Database.Wrapper; | 6 | import com.fourisland.instadisc.Database.Wrapper; |
7 | import com.fourisland.instadisc.FirstRun.FirstRunWizard; | 7 | import com.fourisland.instadisc.FirstRun.FirstRunWizard; |
8 | import java.awt.TrayIcon; | ||
8 | import java.io.File; | 9 | import java.io.File; |
9 | import org.jdesktop.application.Application; | 10 | import org.jdesktop.application.Application; |
10 | import org.jdesktop.application.SingleFrameApplication; | 11 | import org.jdesktop.application.SingleFrameApplication; |
@@ -14,6 +15,8 @@ import org.jdesktop.application.SingleFrameApplication; | |||
14 | */ | 15 | */ |
15 | public class InstaDiscApp extends SingleFrameApplication { | 16 | public class InstaDiscApp extends SingleFrameApplication { |
16 | 17 | ||
18 | public static TrayIcon ti; | ||
19 | |||
17 | /** | 20 | /** |
18 | * At startup create and show the main frame of the application. | 21 | * At startup create and show the main frame of the application. |
19 | */ | 22 | */ |
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index 70be2c1..d9a6c8a 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java | |||
@@ -5,6 +5,11 @@ package com.fourisland.instadisc; | |||
5 | 5 | ||
6 | import com.fourisland.instadisc.Database.Item; | 6 | import com.fourisland.instadisc.Database.Item; |
7 | import com.fourisland.instadisc.Database.Wrapper; | 7 | import com.fourisland.instadisc.Database.Wrapper; |
8 | import com.fourisland.instadisc.Item.Categories.InstaDiscIcon; | ||
9 | import java.awt.AWTException; | ||
10 | import java.awt.Image; | ||
11 | import java.awt.SystemTray; | ||
12 | import java.awt.TrayIcon; | ||
8 | import org.jdesktop.application.Action; | 13 | import org.jdesktop.application.Action; |
9 | import org.jdesktop.application.ResourceMap; | 14 | import org.jdesktop.application.ResourceMap; |
10 | import org.jdesktop.application.SingleFrameApplication; | 15 | import org.jdesktop.application.SingleFrameApplication; |
@@ -20,6 +25,7 @@ import java.util.logging.Logger; | |||
20 | import javax.swing.DefaultListModel; | 25 | import javax.swing.DefaultListModel; |
21 | import javax.swing.Timer; | 26 | import javax.swing.Timer; |
22 | import javax.swing.Icon; | 27 | import javax.swing.Icon; |
28 | import javax.swing.ImageIcon; | ||
23 | import javax.swing.JDialog; | 29 | import javax.swing.JDialog; |
24 | import javax.swing.JFrame; | 30 | import javax.swing.JFrame; |
25 | 31 | ||
@@ -89,6 +95,17 @@ public class InstaDiscView extends FrameView { | |||
89 | } | 95 | } |
90 | } | 96 | } |
91 | }); | 97 | }); |
98 | |||
99 | if (SystemTray.isSupported()) | ||
100 | { | ||
101 | try { | ||
102 | TrayIcon ti = new TrayIcon(new ImageIcon(InstaDiscIcon.instadiscicon).getImage(), "InstaDisc"); | ||
103 | SystemTray.getSystemTray().add(ti); | ||
104 | InstaDiscApp.ti = ti; | ||
105 | } catch (AWTException ex) { | ||
106 | Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); | ||
107 | } | ||
108 | } | ||
92 | 109 | ||
93 | jList1.setCellRenderer(new IDItemListCellRenderer()); | 110 | jList1.setCellRenderer(new IDItemListCellRenderer()); |
94 | jList1.setModel(lm); | 111 | jList1.setModel(lm); |
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java index 497d323..29914b9 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java | |||
@@ -21,6 +21,9 @@ public class Category { | |||
21 | if (category.equals("blog-post")) | 21 | if (category.equals("blog-post")) |
22 | { | 22 | { |
23 | return new ImageIcon(Blogpost.blogpost); | 23 | return new ImageIcon(Blogpost.blogpost); |
24 | } else if (category.equals("instadisc")) | ||
25 | { | ||
26 | return new ImageIcon(InstaDiscIcon.instadiscicon); | ||
24 | } | 27 | } |
25 | return null; | 28 | return null; |
26 | } | 29 | } |
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Categories/InstaDiscIcon.java b/client/trunk/src/com/fourisland/instadisc/Item/Categories/InstaDiscIcon.java new file mode 100644 index 0000000..3405a3e --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/Item/Categories/InstaDiscIcon.java | |||
@@ -0,0 +1,6 @@ | |||
1 | package com.fourisland.instadisc.Item.Categories; | ||
2 | |||
3 | public class InstaDiscIcon | ||
4 | { | ||
5 | public static byte[] instadiscicon = new byte[] {-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16,0,0,0,16,8,6,0,0,0,31,-13,-1,97,0,0,0,1,115,82,71,66,0,-82,-50,28,-23,0,0,0,6,98,75,71,68,0,-1,0,-1,0,-1,-96,-67,-89,-109,0,0,0,9,112,72,89,115,0,0,11,19,0,0,11,19,1,0,-102,-100,24,0,0,0,7,116,73,77,69,7,-40,7,30,11,31,50,57,-121,120,-95,0,0,0,25,116,69,88,116,67,111,109,109,101,110,116,0,67,114,101,97,116,101,100,32,119,105,116,104,32,71,73,77,80,87,-127,14,23,0,0,0,93,73,68,65,84,56,-53,-27,-111,49,14,-64,32,12,3,125,81,-1,-1,-27,116,75,35,74,84,104,-70,-43,3,-125,37,-50,-40,72,73,-18,114,109,-118,-39,101,-72,124,-87,-124,18,-57,44,57,65,60,7,13,80,-84,122,-10,67,-99,0,-102,-102,-78,-95,-81,-118,29,106,-64,-53,10,-70,85,0,1,-21,-55,-107,124,-47,11,-65,63,-30,127,1,49,-20,-47,-8,29,-12,-123,78,107,58,29,23,-107,-38,-46,31,0,0,0,0,73,69,78,68,-82,66,96,-126,-1}; | ||
6 | } | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Item.java b/client/trunk/src/com/fourisland/instadisc/Item/Item.java index e67b1ec..71e6f06 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/Item.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/Item.java | |||
@@ -8,6 +8,8 @@ import com.fourisland.instadisc.Database.Wrapper; | |||
8 | import com.fourisland.instadisc.InstaDiscApp; | 8 | import com.fourisland.instadisc.InstaDiscApp; |
9 | import com.fourisland.instadisc.InstaDiscView; | 9 | import com.fourisland.instadisc.InstaDiscView; |
10 | import com.fourisland.instadisc.XmlRpc; | 10 | import com.fourisland.instadisc.XmlRpc; |
11 | import java.awt.SystemTray; | ||
12 | import java.awt.TrayIcon.MessageType; | ||
11 | import java.net.MalformedURLException; | 13 | import java.net.MalformedURLException; |
12 | import java.net.URL; | 14 | import java.net.URL; |
13 | import java.util.HashMap; | 15 | import java.util.HashMap; |
@@ -60,6 +62,11 @@ public class Item { | |||
60 | } catch (MalformedURLException ex) { | 62 | } catch (MalformedURLException ex) { |
61 | Logger.getLogger(Item.class.getName()).log(Level.SEVERE, null, ex); | 63 | Logger.getLogger(Item.class.getName()).log(Level.SEVERE, null, ex); |
62 | } | 64 | } |
65 | |||
66 | if (SystemTray.isSupported()) | ||
67 | { | ||
68 | InstaDiscApp.ti.displayMessage("New item recieved!", Wrapper.getSubscription(headerMap.get("Subscription")).getTitle() + ", " + headerMap.get("Title") + " by " + headerMap.get("Author"), MessageType.INFO); | ||
69 | } | ||
63 | 70 | ||
64 | ((InstaDiscView)InstaDiscApp.getApplication().getMainView()).refreshItemPane(); | 71 | ((InstaDiscView)InstaDiscApp.getApplication().getMainView()).refreshItemPane(); |
65 | } | 72 | } |