From b37b47f9fb4442ba574f70cf9c70134e612eadce Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 31 Jul 2008 22:41:29 +0000 Subject: Client: Added filters --- .../com/fourisland/instadisc/ActionFilterForm.form | 180 ++++++++++++++ .../com/fourisland/instadisc/ActionFilterForm.java | 234 ++++++++++++++++++ .../fourisland/instadisc/AddSubscriptionForm.form | 6 +- .../fourisland/instadisc/AddSubscriptionForm.java | 10 +- .../fourisland/instadisc/AdvancedSettingsForm.form | 40 ++-- .../fourisland/instadisc/AdvancedSettingsForm.java | 30 +-- .../com/fourisland/instadisc/Database/Filter.java | 63 +++++ .../com/fourisland/instadisc/Database/Wrapper.java | 73 +++++- .../com/fourisland/instadisc/FirstRun/Step1.form | 20 +- .../com/fourisland/instadisc/FirstRun/Step1.java | 14 +- .../com/fourisland/instadisc/FirstRun/Step2.form | 52 ++-- .../com/fourisland/instadisc/FirstRun/Step2.java | 43 ++-- .../com/fourisland/instadisc/FirstRun/Step3.form | 8 +- .../com/fourisland/instadisc/FirstRun/Step3.java | 6 +- .../instadisc/IDFilterListCellRenderer.java | 45 ++++ .../instadisc/IDItemListCellRenderer.java | 11 +- .../com/fourisland/instadisc/InstaDiscView.form | 3 + .../com/fourisland/instadisc/InstaDiscView.java | 10 + .../instadisc/Item/Categories/Category.java | 19 +- .../src/com/fourisland/instadisc/Item/Item.java | 2 +- .../instadisc/Item/SubscriptionFile.java | 24 ++ .../fourisland/instadisc/ManageFiltersForm.form | 170 +++++++++++++ .../fourisland/instadisc/ManageFiltersForm.java | 266 +++++++++++++++++++++ .../instadisc/ManageSubscriptionsForm.form | 5 +- .../instadisc/ManageSubscriptionsForm.java | 14 +- .../resources/ActionFilterForm.properties | 12 + .../resources/ManageFiltersForm.properties | 7 + 27 files changed, 1237 insertions(+), 130 deletions(-) create mode 100644 client/trunk/src/com/fourisland/instadisc/ActionFilterForm.form create mode 100644 client/trunk/src/com/fourisland/instadisc/ActionFilterForm.java create mode 100644 client/trunk/src/com/fourisland/instadisc/Database/Filter.java create mode 100644 client/trunk/src/com/fourisland/instadisc/IDFilterListCellRenderer.java create mode 100644 client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.form create mode 100644 client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java create mode 100644 client/trunk/src/com/fourisland/instadisc/resources/ActionFilterForm.properties create mode 100644 client/trunk/src/com/fourisland/instadisc/resources/ManageFiltersForm.properties (limited to 'client/trunk/src/com/fourisland') diff --git a/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.form b/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.form new file mode 100644 index 0000000..33eddf1 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.form @@ -0,0 +1,180 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.java b/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.java new file mode 100644 index 0000000..d1e8c04 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/ActionFilterForm.java @@ -0,0 +1,234 @@ +/* + * ActionFilterForm.java + * + * Created on July 31, 2008, 5:28 PM + */ +package com.fourisland.instadisc; + +import com.fourisland.instadisc.Database.Filter; +import com.fourisland.instadisc.Database.Wrapper; +import com.fourisland.instadisc.Item.Categories.Category; +import javax.swing.DefaultComboBoxModel; + +/** + * + * @author hatkirby + */ +public class ActionFilterForm extends javax.swing.JDialog { + + /** Creates new form ActionFilterForm */ + public ActionFilterForm(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + + jComboBox1.setModel(cbm); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox(); + jCheckBox1 = new javax.swing.JCheckBox(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.fourisland.instadisc.InstaDiscApp.class).getContext().getResourceMap(ActionFilterForm.class); + jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + jComboBox1.setName("jComboBox1"); // NOI18N + + jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N + jCheckBox1.setName("jCheckBox1"); // NOI18N + + jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N + jLabel4.setName("jLabel4"); // NOI18N + + jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N + jLabel5.setName("jLabel5"); // NOI18N + + jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N + jLabel6.setName("jLabel6"); // NOI18N + + jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N + jTextField1.setName("jTextField1"); // NOI18N + + jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N + jButton1.setName("jButton1"); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N + jButton2.setName("jButton2"); // NOI18N + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 391, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBox1, 0, 346, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCheckBox1)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)))))) + .addGroup(layout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(324, Short.MAX_VALUE) + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel4) + .addComponent(jCheckBox1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + f.setField((String) jComboBox1.getSelectedItem()); + f.setEqual(jCheckBox1.isSelected()); + f.setTest(jTextField1.getText()); + + Wrapper.addFilter(f); + + setVisible(false); + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + setVisible(false); + }//GEN-LAST:event_jButton1ActionPerformed + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + + public void run() { + ActionFilterForm dialog = new ActionFilterForm(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables + DefaultComboBoxModel cbm = new DefaultComboBoxModel(); + Filter f; + + public void setFilter(Filter filter) { + String[] semantics = Category.getRequiredSemantics(Wrapper.getSubscription(filter.getSubscription()).getCategory()); + int i = 0; + + cbm.addElement("Author"); + for (i = 0; i < semantics.length; i++) { + cbm.addElement(semantics[i]); + } + + if (filter.getID() == -65536) { + jLabel1.setText("Add Filter"); + } else { + jComboBox1.setSelectedIndex(0); + for (i = 0; i < semantics.length; i++) { + if (semantics[i].equals(filter.getField())) { + jComboBox1.setSelectedIndex(i+1); + break; + } + } + + jCheckBox1.setSelected(filter.getEqual()); + jTextField1.setText(filter.getTest()); + } + + f = filter; + } +} diff --git a/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.form b/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.form index c381e8d..4a74d18 100644 --- a/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.form +++ b/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.form @@ -36,7 +36,7 @@ - + @@ -57,8 +57,8 @@ - - + + diff --git a/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.java b/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.java index 7b0fc08..c51bdbc 100644 --- a/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.java +++ b/client/trunk/src/com/fourisland/instadisc/AddSubscriptionForm.java @@ -91,9 +91,9 @@ public class AddSubscriptionForm extends javax.swing.JDialog { .addComponent(jButton1)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGap(12, 12, 12) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, 0, 0, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)))))) @@ -105,8 +105,8 @@ public class AddSubscriptionForm extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2) - .addGap(18, 18, 18) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) diff --git a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form index f8e9990..6fb22bd 100644 --- a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form +++ b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.form @@ -22,8 +22,12 @@ - - + + + + + + @@ -41,23 +45,19 @@ - - - - - - - - + + + + @@ -66,27 +66,27 @@ - + - - - + + + - - - + + + - - - + + + diff --git a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java index 2a07123..753bbe3 100644 --- a/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java +++ b/client/trunk/src/com/fourisland/instadisc/AdvancedSettingsForm.java @@ -92,9 +92,12 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) @@ -109,16 +112,13 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSpinner2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(12, 12, 12) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 351, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGroup(layout.createSequentialGroup() - .addGap(36, 36, 36) - .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(341, Short.MAX_VALUE) - .addComponent(jButton1))) + .addComponent(jButton1)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 351, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( @@ -127,20 +127,20 @@ public class AdvancedSettingsForm extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel4) + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel6) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) .addContainerGap()) ); diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Filter.java b/client/trunk/src/com/fourisland/instadisc/Database/Filter.java new file mode 100644 index 0000000..39bcd74 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/Database/Filter.java @@ -0,0 +1,63 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.fourisland.instadisc.Database; + +import com.sleepycat.persist.model.Entity; +import com.sleepycat.persist.model.PrimaryKey; + +/** + * + * @author hatkirby + */ +@Entity +public class Filter { + + @PrimaryKey + private Integer id; + private String subscription; + private String field; + private Boolean equal; + private String test; + + public Integer getID() { + return id; + } + + public String getSubscription() { + return subscription; + } + + public String getField() { + return field; + } + + public Boolean getEqual() { + return equal; + } + + public String getTest() { + return test; + } + + public void setID(Integer id) { + this.id = id; + } + + public void setSubscription(String subscription) { + this.subscription = subscription; + } + + public void setField(String field) { + this.field = field; + } + + public void setEqual(Boolean equal) { + this.equal = equal; + } + + public void setTest(String test) { + this.test = test; + } +} diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java index 3aed859..92c84cc 100644 --- a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java +++ b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java @@ -28,6 +28,7 @@ public class Wrapper { public static PrimaryIndex idConfig; public static PrimaryIndex item; public static PrimaryIndex subscription; + public static PrimaryIndex filter; public static void init(String loc) { @@ -50,6 +51,7 @@ public class Wrapper { idConfig = es.getPrimaryIndex(String.class, IDConfig.class); item = es.getPrimaryIndex(Integer.class, Item.class); subscription = es.getPrimaryIndex(String.class, Subscription.class); + filter = es.getPrimaryIndex(Integer.class, Filter.class); } catch (DatabaseException ex) { Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); } @@ -223,7 +225,7 @@ public class Wrapper { } } } - + public static Subscription[] getAllSubscription() { synchronized (subscription) { try { @@ -248,11 +250,9 @@ public class Wrapper { } } } - - public static void deleteSubscription(String url) - { - synchronized (subscription) - { + + public static void deleteSubscription(String url) { + synchronized (subscription) { try { subscription.delete(url); } catch (DatabaseException ex) { @@ -260,4 +260,65 @@ public class Wrapper { } } } + + public static void addFilter(Filter f) { + if (f.getID() == -65536) { + f.setID(Integer.decode(Wrapper.getConfig("nextFilterID"))); + Wrapper.setConfig("nextFilterID", Integer.toString(Integer.decode(Wrapper.getConfig("nextFilterID")) + 1)); + } + + synchronized (filter) { + try { + filter.put(f); + } catch (DatabaseException ex) { + Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + public static Filter getFilter(Integer id) { + synchronized (filter) { + try { + return filter.get(id); + } catch (DatabaseException ex) { + Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + } + } + + public static void deleteFilter(Integer id) { + synchronized (filter) { + try { + filter.delete(id); + } catch (DatabaseException ex) { + Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + public static Filter[] getAllFilter() { + synchronized (filter) { + try { + Iterator i = filter.entities().iterator(); + Filter[] temp = new Filter[0]; + int len = 0; + + while (i.hasNext()) { + Filter[] temp2 = new Filter[len + 1]; + int j = 0; + for (j = 0; j < len; j++) { + temp2[j] = temp[j]; + } + temp2[len] = i.next(); + temp = temp2; + } + + return temp; + } catch (DatabaseException ex) { + Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); + return new Filter[0]; + } + } + } } diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.form b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.form index b392e54..b33a49c 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.form +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.form @@ -22,17 +22,19 @@ - + + + + + + - - - - - - + + + @@ -44,10 +46,10 @@ - + - + diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.java index 4a29d15..e96b275 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step1.java @@ -53,15 +53,17 @@ public class Step1 extends javax.swing.JDialog { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(448, Short.MAX_VALUE) + .addComponent(jButton1) + .addContainerGap()) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) .addGroup(layout.createSequentialGroup() .addGap(12, 12, 12) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jButton1) - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel1)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -70,10 +72,10 @@ public class Step1 extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel3) + .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); pack(); diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form index ba0b98c..666f518 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form @@ -23,30 +23,34 @@ - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + - - - - - - + @@ -57,29 +61,29 @@ - + - + - + - + - + + - diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java index 99aee3f..6831417 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java @@ -87,36 +87,38 @@ public class Step2 extends javax.swing.JDialog { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) .addGroup(layout.createSequentialGroup() - .addGap(12, 12, 12) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel3) - .addComponent(jLabel4)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) - .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) - .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jButton1)) + .addComponent(jLabel1) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) + .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) + .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)))) .addGroup(layout.createSequentialGroup() - .addGap(12, 12, 12) + .addGap(24, 24, 24) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel6) + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) @@ -131,8 +133,8 @@ public class Step2 extends javax.swing.JDialog { .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jButton1) - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton1))) ); pack(); @@ -169,6 +171,7 @@ public class Step2 extends javax.swing.JDialog { Wrapper.setConfig("centralServerURL", jTextField3.getText()); Wrapper.setConfig("itemBufferSize", "10"); Wrapper.setConfig("verIDBufferSize", "100"); + Wrapper.setConfig("nextFilterID", "0"); Wrapper.setConfig("initCheck", "done"); StepEndResults.ok = true; diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.form b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.form index bd32a05..990c340 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.form +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.form @@ -25,7 +25,7 @@ - + @@ -46,13 +46,13 @@ - + - + - + diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.java index e37e4f3..269466d 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step3.java @@ -56,7 +56,7 @@ public class Step3 extends javax.swing.JDialog { .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGap(165, 165, 165) + .addGap(164, 164, 164) .addComponent(jButton1)) .addGroup(layout.createSequentialGroup() .addContainerGap() @@ -73,10 +73,10 @@ public class Step3 extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); pack(); diff --git a/client/trunk/src/com/fourisland/instadisc/IDFilterListCellRenderer.java b/client/trunk/src/com/fourisland/instadisc/IDFilterListCellRenderer.java new file mode 100644 index 0000000..db006f9 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/IDFilterListCellRenderer.java @@ -0,0 +1,45 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.fourisland.instadisc; + +import com.fourisland.instadisc.Database.Filter; +import java.awt.Component; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +/** + * + * @author hatkirby + */ +class IDFilterListCellRenderer extends JLabel implements ListCellRenderer { + + public Component getListCellRendererComponent(JList arg0, Object arg1, int arg2, boolean arg3, boolean arg4) { + Filter filter = (Filter) arg1; + + if (filter.getID() == -65536) + { + this.setText("Add new filter"); + } else { + this.setText(filter.getField() + " " + (filter.getEqual() ? "=" : "!=") + " " + filter.getTest()); + } + + if (arg3) { + this.setForeground(arg0.getSelectionForeground()); + this.setBackground(arg0.getSelectionBackground()); + } else { + this.setForeground(arg0.getForeground()); + this.setBackground(arg0.getBackground()); + } + + this.setOpaque(true); + this.setFont(arg0.getFont()); + this.setEnabled(arg0.isEnabled()); + + return this; + } + +} diff --git a/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java b/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java index b5204e6..21924e8 100644 --- a/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java +++ b/client/trunk/src/com/fourisland/instadisc/IDItemListCellRenderer.java @@ -22,11 +22,16 @@ 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()); + + if (item.getAuthor().equals("")) { + this.setText("" + Wrapper.getSubscription(item.getSubscription()).getTitle() + ", " + item.getTitle() + ""); + } else { + this.setText("" + Wrapper.getSubscription(item.getSubscription()).getTitle() + ", " + item.getTitle() + " by " + item.getAuthor()); + } /*if (item.getUnread()) { - this.setBackground(Color.YELLOW); - } else */{ + this.setBackground(Color.YELLOW); + } else */ { if (arg3) { this.setForeground(arg0.getSelectionForeground()); this.setBackground(arg0.getSelectionBackground()); diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form index b000ed9..f4be5c3 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form @@ -113,6 +113,9 @@ + + + diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index 3c58bfc..e2f6dda 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java @@ -219,6 +219,11 @@ public class InstaDiscView extends FrameView { jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N jMenuItem3.setName("jMenuItem3"); // NOI18N + jMenuItem3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem3ActionPerformed(evt); + } + }); jMenu1.add(jMenuItem3); jMenuItem4.setText(resourceMap.getString("jMenuItem4.text")); // NOI18N @@ -315,6 +320,11 @@ public class InstaDiscView extends FrameView { asf.setVisible(true); }//GEN-LAST:event_jMenuItem5ActionPerformed + private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed + ManageFiltersForm mff = new ManageFiltersForm(new JFrame(), true); + mff.setVisible(true); + }//GEN-LAST:event_jMenuItem3ActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JList jList1; private javax.swing.JMenu jMenu1; 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 aa2bee6..bc8bfac 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java @@ -38,10 +38,25 @@ public class Category { public static boolean checkForRequiredSemantics(HashMap headerMap) { boolean good = true; String category = Wrapper.getSubscription(headerMap.get("Subscription")).getCategory(); - if (category.equals("forum-post")) { - good = (good ? WellFormedItem.checkForRequiredHeader(headerMap, "forum") : false); + String[] semantics = getRequiredSemantics(category); + int i=0; + + for (i=0;i= Integer.decode(Wrapper.getConfig("itemBufferSize"))) { diff --git a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java index adca86e..2d8ad07 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java @@ -4,8 +4,10 @@ */ package com.fourisland.instadisc.Item; +import com.fourisland.instadisc.Database.Filter; import com.fourisland.instadisc.Database.Subscription; import com.fourisland.instadisc.Database.Wrapper; +import com.fourisland.instadisc.XmlRpc; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; @@ -33,6 +35,28 @@ public class SubscriptionFile { Logger.getLogger(SubscriptionFile.class.getName()).log(Level.SEVERE, null, ex); } } + + public static void deleteSubscription(Subscription s, boolean deleteFromData) + { + if (deleteFromData) + { + Wrapper.deleteSubscription(s.getURL()); + } + + XmlRpc xmlrpc = new XmlRpc("deleteSubscription"); + xmlrpc.addParam(s.getURL()); + xmlrpc.execute(); + + int i=0; + Filter f[] = Wrapper.getAllFilter(); + for (i=0;i + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java new file mode 100644 index 0000000..cd4426e --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java @@ -0,0 +1,266 @@ +/* + * ManageFiltersForm.java + * + * Created on July 31, 2008, 4:08 PM + */ +package com.fourisland.instadisc; + +import com.fourisland.instadisc.Database.Filter; +import com.fourisland.instadisc.Database.Subscription; +import com.fourisland.instadisc.Database.Wrapper; +import javax.swing.DefaultListModel; +import javax.swing.JFrame; + +/** + * + * @author hatkirby + */ +public class ManageFiltersForm extends javax.swing.JDialog { + + /** Creates new form ManageFiltersForm */ + public ManageFiltersForm(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + + jList1.setModel(lm); + jList2.setModel(lm2); + + jList1.setCellRenderer(new IDSubscriptionListCellRenderer()); + jList2.setCellRenderer(new IDFilterListCellRenderer()); + + refreshSubscriptionPane(); + + if (!lm.isEmpty()) { + jList1.setSelectedIndex(0); + + refreshFilterPane(); + jList2.setSelectedIndex(0); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList(); + jScrollPane2 = new javax.swing.JScrollPane(); + jList2 = new javax.swing.JList(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.fourisland.instadisc.InstaDiscApp.class).getContext().getResourceMap(ManageFiltersForm.class); + jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(625, 17)); + + jScrollPane1.setName("jScrollPane1"); // NOI18N + + jList1.setName("jList1"); // NOI18N + jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jList1ValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jList1); + + jScrollPane2.setName("jScrollPane2"); // NOI18N + + jList2.setName("jList2"); // NOI18N + jList2.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jList2ValueChanged(evt); + } + }); + jScrollPane2.setViewportView(jList2); + + jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N + jButton1.setName("jButton1"); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N + jButton2.setName("jButton2"); // NOI18N + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N + jButton3.setName("jButton3"); // NOI18N + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGap(12, 12, 12) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(301, Short.MAX_VALUE) + .addComponent(jButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton3))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton3) + .addComponent(jButton2) + .addComponent(jButton1)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged + refreshFilterPane(); + }//GEN-LAST:event_jList1ValueChanged + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + setVisible(false); + }//GEN-LAST:event_jButton3ActionPerformed + + private void jList2ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList2ValueChanged + Filter filter = (Filter) jList2.getSelectedValue(); + try { + if (filter.getID() == -65536) { + jButton1.setText("Add"); + jButton2.setEnabled(false); + } else { + jButton1.setText("Edit"); + jButton2.setEnabled(true); + } + } catch (Exception ex) { + jButton1.setText("Edit"); + jButton1.setEnabled(false); + jButton2.setEnabled(false); + } + }//GEN-LAST:event_jList2ValueChanged + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + Wrapper.deleteFilter(((Filter) jList2.getSelectedValue()).getID()); + refreshFilterPane(); + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + ActionFilterForm aff = new ActionFilterForm(new JFrame(), true); + aff.setFilter((Filter) jList2.getSelectedValue()); + aff.setVisible(true); + refreshFilterPane(); + }//GEN-LAST:event_jButton1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + + public void run() { + ManageFiltersForm dialog = new ManageFiltersForm(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JList jList1; + private javax.swing.JList jList2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + // End of variables declaration//GEN-END:variables + DefaultListModel lm = new DefaultListModel(); + DefaultListModel lm2 = new DefaultListModel(); + + public void refreshSubscriptionPane() { + lm.clear(); + Subscription[] subscriptions = Wrapper.getAllSubscription(); + int i = 0; + for (i = 0; i < subscriptions.length; i++) { + lm.addElement(subscriptions[i]); + } + + jList1.setEnabled(!lm.isEmpty()); + jList2.setEnabled(!lm.isEmpty()); + jButton1.setEnabled(!lm.isEmpty()); + jButton2.setEnabled(!lm.isEmpty()); + + if (lm.isEmpty()) { + lm2.clear(); + } + } + + public void refreshFilterPane() { + lm2.clear(); + + Filter addNew = new Filter(); + addNew.setID(-65536); + addNew.setSubscription(((Subscription) jList1.getSelectedValue()).getURL()); + lm2.addElement(addNew); + + Filter[] filters = Wrapper.getAllFilter(); + int i = 0; + for (i = 0; i < filters.length; i++) { + if (filters[i].getSubscription().equals(((Subscription) jList1.getSelectedValue()).getURL())) { + lm2.addElement(filters[i]); + } + } + } +} diff --git a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.form b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.form index f9efe54..897f8a8 100644 --- a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.form +++ b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.form @@ -29,13 +29,13 @@ - +
@@ -74,6 +74,9 @@ + + +
diff --git a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java index 6eeac2c..94a8075 100644 --- a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java +++ b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java @@ -8,6 +8,7 @@ package com.fourisland.instadisc; import com.fourisland.instadisc.Database.Subscription; import com.fourisland.instadisc.Database.Wrapper; +import com.fourisland.instadisc.Item.SubscriptionFile; import javax.swing.DefaultListModel; /** @@ -51,6 +52,7 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(1061, 71)); jScrollPane1.setName("jScrollPane1"); // NOI18N @@ -84,12 +86,12 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { .addGroup(layout.createSequentialGroup() .addGap(12, 12, 12) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel2, 0, 0, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jButton2))))) + .addComponent(jButton2)) + .addComponent(jLabel2, 0, 0, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( @@ -98,7 +100,7 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -115,11 +117,7 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { if (!jList1.isSelectionEmpty()) { Subscription subscription = (Subscription) jList1.getSelectedValue(); - Wrapper.deleteSubscription(subscription.getURL()); - - XmlRpc xmlrpc = new XmlRpc("deleteSubscription"); - xmlrpc.addParam(subscription.getURL()); - xmlrpc.execute(); + SubscriptionFile.deleteSubscription(subscription, true); refreshSubscriptionPane(); } diff --git a/client/trunk/src/com/fourisland/instadisc/resources/ActionFilterForm.properties b/client/trunk/src/com/fourisland/instadisc/resources/ActionFilterForm.properties new file mode 100644 index 0000000..ebf3a91 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/resources/ActionFilterForm.properties @@ -0,0 +1,12 @@ +jLabel1.text=Edit Filter +#NOI18N +jLabel1.font=DejaVu Sans-Plain-18 +jLabel2.text=You can choose the conditions that Items are filtered out upon here. +jLabel3.text=Field: +jCheckBox1.text= +jLabel4.text=Remove if Equal: +jLabel5.text=If this is set, Items are filtered out when the field set above is equal to the text set below. If unset, Items are kept when the field specified above is equal to the text below. +jLabel6.text=Test Value: +jTextField1.text= +jButton1.text=Cancel +jButton2.text=OK diff --git a/client/trunk/src/com/fourisland/instadisc/resources/ManageFiltersForm.properties b/client/trunk/src/com/fourisland/instadisc/resources/ManageFiltersForm.properties new file mode 100644 index 0000000..a163ede --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/resources/ManageFiltersForm.properties @@ -0,0 +1,7 @@ +jLabel1.text=Manage Filters +#NOI18N +jLabel1.font=DejaVu Sans-Plain-18 +jLabel2.text=You can filter out specific Items that you don't want using Filters. For more information, see Filters. +jButton1.text=Edit +jButton2.text=Delete +jButton3.text=Done -- cgit 1.4.1