From 9e5c4e5541ab1608cd70149c06a42c193c68ff18 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 30 Jul 2008 12:06:28 +0000 Subject: Client: Added System Tray Icon Added an icon to the System Tray that shows a message whenever a new Item is recieved. --- .../fourisland/instadisc/IDItemListCellRenderer.java | 2 +- .../src/com/fourisland/instadisc/InstaDiscApp.java | 3 +++ .../src/com/fourisland/instadisc/InstaDiscView.java | 17 +++++++++++++++++ .../fourisland/instadisc/Item/Categories/Category.java | 3 +++ .../instadisc/Item/Categories/InstaDiscIcon.java | 6 ++++++ .../trunk/src/com/fourisland/instadisc/Item/Item.java | 7 +++++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 client/trunk/src/com/fourisland/instadisc/Item/Categories/InstaDiscIcon.java (limited to 'client/trunk/src') 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 { Item item = (Item) arg1; this.setIcon(Category.iconFromCategory(Wrapper.getSubscription(item.getSubscription()).getCategory())); - this.setText("" + Wrapper.getSubscription(item.getSubscription()).getTitle() + "" + item.getTitle() + " by " + item.getAuthor()); + this.setText("" + Wrapper.getSubscription(item.getSubscription()).getTitle() + ", " + item.getTitle() + " by " + item.getAuthor()); /*if (item.getUnread()) { 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; import com.fourisland.instadisc.Database.Wrapper; import com.fourisland.instadisc.FirstRun.FirstRunWizard; +import java.awt.TrayIcon; import java.io.File; import org.jdesktop.application.Application; import org.jdesktop.application.SingleFrameApplication; @@ -14,6 +15,8 @@ import org.jdesktop.application.SingleFrameApplication; */ public class InstaDiscApp extends SingleFrameApplication { + public static TrayIcon ti; + /** * At startup create and show the main frame of the application. */ 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; import com.fourisland.instadisc.Database.Item; import com.fourisland.instadisc.Database.Wrapper; +import com.fourisland.instadisc.Item.Categories.InstaDiscIcon; +import java.awt.AWTException; +import java.awt.Image; +import java.awt.SystemTray; +import java.awt.TrayIcon; import org.jdesktop.application.Action; import org.jdesktop.application.ResourceMap; import org.jdesktop.application.SingleFrameApplication; @@ -20,6 +25,7 @@ import java.util.logging.Logger; import javax.swing.DefaultListModel; import javax.swing.Timer; import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.JDialog; import javax.swing.JFrame; @@ -89,6 +95,17 @@ public class InstaDiscView extends FrameView { } } }); + + if (SystemTray.isSupported()) + { + try { + TrayIcon ti = new TrayIcon(new ImageIcon(InstaDiscIcon.instadiscicon).getImage(), "InstaDisc"); + SystemTray.getSystemTray().add(ti); + InstaDiscApp.ti = ti; + } catch (AWTException ex) { + Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); + } + } jList1.setCellRenderer(new IDItemListCellRenderer()); 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 { if (category.equals("blog-post")) { return new ImageIcon(Blogpost.blogpost); + } else if (category.equals("instadisc")) + { + return new ImageIcon(InstaDiscIcon.instadiscicon); } return null; } 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 @@ +package com.fourisland.instadisc.Item.Categories; + +public class InstaDiscIcon +{ + 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}; +} 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; import com.fourisland.instadisc.InstaDiscApp; import com.fourisland.instadisc.InstaDiscView; import com.fourisland.instadisc.XmlRpc; +import java.awt.SystemTray; +import java.awt.TrayIcon.MessageType; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; @@ -60,6 +62,11 @@ public class Item { } catch (MalformedURLException ex) { Logger.getLogger(Item.class.getName()).log(Level.SEVERE, null, ex); } + + if (SystemTray.isSupported()) + { + InstaDiscApp.ti.displayMessage("New item recieved!", Wrapper.getSubscription(headerMap.get("Subscription")).getTitle() + ", " + headerMap.get("Title") + " by " + headerMap.get("Author"), MessageType.INFO); + } ((InstaDiscView)InstaDiscApp.getApplication().getMainView()).refreshItemPane(); } -- cgit 1.4.1