From: Stig T. <jw...@us...> - 2005-03-24 14:00:22
|
Update of /cvsroot/mailsomething/mailsomething/src/net/sf/mailsomething/gui/mail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27170/net/sf/mailsomething/gui/mail Modified Files: MailboxTreeCellRenderer.java MailboxTableModel.java FilterConfig.java MailboxTable.java Log Message: Index: MailboxTreeCellRenderer.java =================================================================== RCS file: /cvsroot/mailsomething/mailsomething/src/net/sf/mailsomething/gui/mail/MailboxTreeCellRenderer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MailboxTreeCellRenderer.java 3 Apr 2004 07:56:49 -0000 1.1 --- MailboxTreeCellRenderer.java 24 Mar 2005 14:00:11 -0000 1.2 *************** *** 17,20 **** --- 17,21 ---- import net.sf.mailsomething.gui.GuiUser; import net.sf.mailsomething.mail.Hierachy; + import net.sf.mailsomething.mail.Mailbox; import net.sf.mailsomething.mail.MessageHolder; *************** *** 137,144 **** --- 138,149 ---- MessageHolder mholder = null; + + Mailbox m = null; try { mholder = (MessageHolder) node.getMailbox(); + + m = (Mailbox)node.getMailbox(); } catch (ClassCastException f) { *************** *** 152,159 **** --- 157,169 ---- name += " (" + mholder.getMessageCount() + ") "; + } else if (messageCountStyle == MESSAGECOUNT_TOTALSTYLE) { name += " (" + mholder.getMessageCount() + ") "; + + if(m != null) + name += " " + m.getExists(); + } else if (messageCountStyle == MESSAGECOUNT_INCOMINGCOUNT) { Index: MailboxTable.java =================================================================== RCS file: /cvsroot/mailsomething/mailsomething/src/net/sf/mailsomething/gui/mail/MailboxTable.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MailboxTable.java 21 Mar 2005 17:16:40 -0000 1.4 --- MailboxTable.java 24 Mar 2005 14:00:11 -0000 1.5 *************** *** 24,28 **** --- 24,35 ---- import java.io.*; + import net.sf.classifier4J.IClassifier; + import net.sf.classifier4J.bayesian.BayesianClassifier; + import net.sf.classifier4J.bayesian.IWordsDataSource; + import net.sf.classifier4J.bayesian.SimpleWordsDataSource; import net.sf.mailsomething.mail.*; + import net.sf.mailsomething.mail.db.CachedJDBCWordDataSource; + import net.sf.mailsomething.mail.db.HSQLConnectionManager; + import net.sf.mailsomething.mail.db.JDBCWordsDataSource; import net.sf.mailsomething.util.event.LListenerAdapter; import net.sf.mailsomething.util.event.ListenerProxy; *************** *** 206,209 **** --- 213,222 ---- //new MarkMessage(); + new MarkSpam(); + + new MarkNotSpam(); + + new ClassifyAll(); + popupMenu = new TransparentMenu(getActionMap()); *************** *** 263,277 **** } - /*public void setSelectionRow(int row) { - - //System.out.println("setselectionrow"); - - } - public void setRowSelectionInterval(int row, int row2) { - - //System.out.println("setselectionrow"); - - }*/ public void init(MessageHolder mailbox) { --- 276,280 ---- *************** *** 426,434 **** return; } ! ! //if(e.getMailbox() != mailbox) return; ! ! ////System.out.println("messageselectionchanged - table"); ! int n = e.getIndex(); --- 429,433 ---- return; } ! int n = e.getIndex(); *************** *** 437,447 **** } /** ! * Description of the Method ! * ! *@param e Description of Parameter */ - //public void mailboxSelectionChanged(MailboxSelectionEvent e) { - public void valueChanged(TreeSelectionEvent e) { --- 436,447 ---- } + /** ! * ! * Recieves treeselectionevents, from selections in ! * a mailboxtree. If the mailboxtable is dynamic we ! * change the mailbox to show. ! * */ public void valueChanged(TreeSelectionEvent e) { *************** *** 1840,1843 **** --- 1840,2082 ---- } + + + class MarkSpam extends GuiAction { + + public MarkSpam() { + super( + MailboxTable.this, + "Mark spam", + KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), + "ctrl + m"); + + } + + public void actionPerformed(ActionEvent e) { + + MailboxHolder parent = (MailboxHolder)mailbox; + + while(parent.getParentMailbox() != null) { + + parent = parent.getParentMailbox(); + + } + + try { + + MailAccount a = (MailAccount)parent; + + if(a.getClassifier() == null) { + + CachedJDBCWordDataSource wds = + new CachedJDBCWordDataSource(new HSQLConnectionManager()); + + //IWordsDataSource wds = new SimpleWordsDataSource(); + IClassifier classifier = new BayesianClassifier(wds); + + a.setClassifier(classifier); + } + + if(a.getClassifier() != null) { + int[] selectedRows = getSelectedRows(); + + + for (int i = 0; i < selectedRows.length; i++) { + + Message message = mailbox.getMessage(selectedRows[i]); + + /*String header = ""; + + Object[] fields = message.getFieldNames(); + + for(int j = 0; j < fields.length; j++) { + + header += message.getField(fields[j].toString()) + " "; + + } + + System.out.println(header);*/ + + //message. + + ((BayesianClassifier)a.getClassifier()).teachMatch(message.getSubject()); + ((BayesianClassifier)a.getClassifier()).teachMatch(message.getFrom().getEmail()); + + + } + + } + + } catch (Exception f) { + + f.printStackTrace(); + } + + } + + + + } + + + + + class MarkNotSpam extends GuiAction { + + public MarkNotSpam() { + super( + MailboxTable.this, + "Mark not spam", + KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), + "ctrl + u"); + + } + + public void actionPerformed(ActionEvent e) { + + MailboxHolder parent = (MailboxHolder)mailbox; + + while(parent.getParentMailbox() != null) { + + parent = parent.getParentMailbox(); + + } + + try { + + MailAccount a = (MailAccount)parent; + + if(a.getClassifier() == null) { + + CachedJDBCWordDataSource wds = + new CachedJDBCWordDataSource(new HSQLConnectionManager()); + + //IWordsDataSource wds = new SimpleWordsDataSource(); + IClassifier classifier = new BayesianClassifier(wds); + + a.setClassifier(classifier); + } + + if(a.getClassifier() != null) { + int[] selectedRows = getSelectedRows(); + + + for (int i = 0; i < selectedRows.length; i++) { + + Message message = mailbox.getMessage(selectedRows[i]); + + /*String header = ""; + + Object[] fields = message.getFieldNames(); + + for(int j = 0; j < fields.length; j++) { + + header += message.getField(fields[j].toString()) + " "; + + } + + System.out.println(header);*/ + + //message. + + ((BayesianClassifier)a.getClassifier()).teachNonMatch(message.getSubject()); + //((BayesianClassifier)a.getClassifier()).teachMatch(message.getFrom().getEmail()); + + + } + + } + + } catch (Exception f) { + + f.printStackTrace(); + } + + } + + + + } + + + class ClassifyAll extends GuiAction { + + public ClassifyAll() { + super( + MailboxTable.this, + "Classify all", + KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK), + "ctrl + y"); + + } + + public void actionPerformed(ActionEvent e) { + + MailboxHolder parent = (MailboxHolder)mailbox; + + while(parent.getParentMailbox() != null) { + + parent = parent.getParentMailbox(); + + } + + try { + + MailAccount a = (MailAccount)parent; + + if(a.getClassifier() == null) { + + CachedJDBCWordDataSource wds = + new CachedJDBCWordDataSource(new HSQLConnectionManager()); + + + //IWordsDataSource wds = new SimpleWordsDataSource(); + IClassifier classifier = new BayesianClassifier(wds); + + a.setClassifier(classifier); + } + + if(a.getClassifier() != null) { + + + Message[] messages = mailbox.getMessages(); + + + for (int i = 0; i < messages.length; i++) { + + + /*String header = ""; + + Object[] fields = messages[i].getFieldNames(); + + for(int j = 0; j < fields.length; j++) { + + header += messages[i].getField(fields[j].toString()) + " "; + + } + ((BayesianClassifier)a.getClassifier()).teachMatch(); + ((BayesianClassifier)a.getClassifier()).teachMatch(message.getFrom().getEmail()); + */ + + + double dd = a.getClassifier().classify(messages[i].getSubject()); + + messages[i].setField("X-spamvalue", "" + dd); + + + } + + } + + } catch (Exception f) { + + f.printStackTrace(); + } + + } + + + + } class Cut extends GuiAction implements ClipboardOwner { *************** *** 2113,2116 **** --- 2352,2357 ---- actions[4] = new ShowCollumnAction("Attachments"); + + actions[4] = new ShowCollumnAction("X-spam"); return actions; Index: FilterConfig.java =================================================================== RCS file: /cvsroot/mailsomething/mailsomething/src/net/sf/mailsomething/gui/mail/FilterConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FilterConfig.java 21 Mar 2005 17:16:39 -0000 1.2 --- FilterConfig.java 24 Mar 2005 14:00:11 -0000 1.3 *************** *** 91,95 **** matchAny.addActionListener(listener); matchAll.addActionListener(listener); ! if(filter.getMatchType() == MailboxFilter.MATCHALL) matchAll.setSelected(true); else matchAny.setSelected(true); --- 91,95 ---- matchAny.addActionListener(listener); matchAll.addActionListener(listener); ! if(filter.getMatchType() == MailboxFilter.MATCH_ALL) matchAll.setSelected(true); else matchAny.setSelected(true); *************** *** 221,227 **** } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.all"))) { ! filter.setMatchType(MailboxFilter.MATCHALL); } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.any"))) { ! filter.setMatchType(MailboxFilter.MATCHANY); } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.copy"))) { filter.setActionType(MailboxFilter.COPY); --- 221,227 ---- } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.all"))) { ! filter.setMatchType(MailboxFilter.MATCH_ALL); } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.any"))) { ! filter.setMatchType(MailboxFilter.MATCH_ANY); } else if (e.getActionCommand().equals(PropertyManager.getString("filter.radio.copy"))) { filter.setActionType(MailboxFilter.COPY); Index: MailboxTableModel.java =================================================================== RCS file: /cvsroot/mailsomething/mailsomething/src/net/sf/mailsomething/gui/mail/MailboxTableModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MailboxTableModel.java 21 Mar 2005 17:16:39 -0000 1.3 --- MailboxTableModel.java 24 Mar 2005 14:00:11 -0000 1.4 *************** *** 121,124 **** --- 121,128 ---- return new Boolean(m.hasAttachments()); + } else if (header[column].equalsIgnoreCase("X-spam")) { + + return m.getField("X-spamvalue"); + } *************** *** 175,178 **** --- 179,186 ---- return "Att"; + } else if (header[column].equalsIgnoreCase("X-spam")) { + + return ("Spam score"); + } |