From f99de43a85997f9fe6fcbbf862844d9f4d79119a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 1 Sep 2008 19:21:05 +0000 Subject: Client: Added Unread flag manipulation Closes #49 --- .../com/fourisland/instadisc/Database/Wrapper.java | 14 +++++++ .../com/fourisland/instadisc/InstaDiscView.form | 11 +++++ .../com/fourisland/instadisc/InstaDiscView.java | 49 +++++++++++++++++++++- .../fourisland/instadisc/UnreadFlagPopupMenu.java | 37 ++++++++++++++++ .../instadisc/resources/InstaDiscView.properties | 1 + 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 client/trunk/src/com/fourisland/instadisc/UnreadFlagPopupMenu.java (limited to 'client/trunk/src') diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java index 40040d9..1448893 100644 --- a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java +++ b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java @@ -453,4 +453,18 @@ public class Wrapper { } } } + + public static Item getItem(Integer id) { + synchronized (item) + { + try + { + return item.get(id); + } catch (DatabaseException ex) + { + Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + } + } } diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form index 5ca439a..c08ee2f 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form @@ -40,6 +40,8 @@ + + @@ -136,6 +138,15 @@ + + + + + + + + + diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index a7a3308..3448197 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java @@ -9,6 +9,7 @@ import com.fourisland.instadisc.Item.Categories.InstaDiscIcon; import java.awt.AWTException; import java.awt.SystemTray; import java.awt.TrayIcon; +import java.awt.event.MouseEvent; import org.jdesktop.application.Action; import org.jdesktop.application.ResourceMap; import org.jdesktop.application.SingleFrameApplication; @@ -150,6 +151,7 @@ public class InstaDiscView extends FrameView { jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); + jMenuItem8 = new javax.swing.JMenuItem(); jMenuItem5 = new javax.swing.JMenuItem(); javax.swing.JMenu helpMenu = new javax.swing.JMenu(); jMenuItem6 = new javax.swing.JMenuItem(); @@ -170,6 +172,12 @@ public class InstaDiscView extends FrameView { public void mouseClicked(java.awt.event.MouseEvent evt) { jList1MouseClicked(evt); } + public void mousePressed(java.awt.event.MouseEvent evt) { + jList1MousePressed(evt); + } + public void mouseReleased(java.awt.event.MouseEvent evt) { + jList1MouseReleased(evt); + } }); jList1.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { @@ -253,6 +261,15 @@ public class InstaDiscView extends FrameView { }); jMenu1.add(jMenuItem4); + jMenuItem8.setText(resourceMap.getString("jMenuItem8.text")); // NOI18N + jMenuItem8.setName("jMenuItem8"); // NOI18N + jMenuItem8.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem8ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem8); + jMenuItem5.setText(resourceMap.getString("jMenuItem5.text")); // NOI18N jMenuItem5.setName("jMenuItem5"); // NOI18N jMenuItem5.addActionListener(new java.awt.event.ActionListener() { @@ -324,7 +341,7 @@ public class InstaDiscView extends FrameView { setStatusBar(statusPanel); }// //GEN-END:initComponents private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked - if (evt.getClickCount() == 2) { + if ((evt.getButton() == MouseEvent.BUTTON1) && (evt.getClickCount() == 2)) { Item item = (Item) jList1.getSelectedValue(); try { @@ -397,6 +414,35 @@ public class InstaDiscView extends FrameView { cpf.setVisible(true); }//GEN-LAST:event_jMenuItem7ActionPerformed + private void jList1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseReleased + int i = jList1.locationToIndex(evt.getPoint()); + if ((evt.isPopupTrigger()) && (i != -1)) + { + jList1.setSelectedIndex(i); + new UnreadFlagPopupMenu((Item) jList1.getSelectedValue()).show(jList1, evt.getX(), evt.getY()); + } + }//GEN-LAST:event_jList1MouseReleased + + private void jList1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MousePressed + int i = jList1.locationToIndex(evt.getPoint()); + if ((evt.isPopupTrigger()) && (i != -1)) + { + jList1.setSelectedIndex(i); + new UnreadFlagPopupMenu((Item) jList1.getSelectedValue()).show(jList1, evt.getX(), evt.getY()); + } + }//GEN-LAST:event_jList1MousePressed + + private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed + Item[] items = Wrapper.getAllItem(); + int i = 0; + for (i=0; i < items.length; i++) + { + Wrapper.setUnreadFlagItem(items[i].getID(), false); + } + + refreshItemPane(); + }//GEN-LAST:event_jMenuItem8ActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JList jList1; private javax.swing.JMenu jMenu1; @@ -407,6 +453,7 @@ public class InstaDiscView extends FrameView { private javax.swing.JMenuItem jMenuItem5; private javax.swing.JMenuItem jMenuItem6; private javax.swing.JMenuItem jMenuItem7; + private javax.swing.JMenuItem jMenuItem8; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JPanel mainPanel; diff --git a/client/trunk/src/com/fourisland/instadisc/UnreadFlagPopupMenu.java b/client/trunk/src/com/fourisland/instadisc/UnreadFlagPopupMenu.java new file mode 100644 index 0000000..25cca54 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/UnreadFlagPopupMenu.java @@ -0,0 +1,37 @@ +package com.fourisland.instadisc; + +import com.fourisland.instadisc.Database.Item; +import com.fourisland.instadisc.Database.Wrapper; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JList; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +public class UnreadFlagPopupMenu extends JPopupMenu +{ + private Item item; + + public UnreadFlagPopupMenu(Item item) + { + super(); + this.item = item; + + JMenuItem action = new JMenuItem("Mark as " + (item.getUnread() ? "Read" : "Unread")); + action.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent arg0) { + flipUnreadFlag(); + } + }); + + add(action); + } + + private void flipUnreadFlag() + { + Wrapper.setUnreadFlagItem(item.getID(), !item.getUnread()); + + ((InstaDiscView) InstaDiscApp.getApplication().getMainView()).refreshItemPane(); + } +} \ No newline at end of file diff --git a/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties b/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties index d7bcf10..927eecf 100644 --- a/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties +++ b/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties @@ -38,3 +38,4 @@ jMenuItem4.text=Request Retained Items jMenuItem5.text=Advanced Settings jMenuItem6.text=InstaDisc Website jMenuItem7.text=Change Password +jMenuItem8.text=Mark all as Read -- cgit 1.4.1