1 17 package org.columba.mail.spam.command; 18 19 import org.columba.api.command.ICommandReference; 20 import org.columba.api.command.IWorkerStatusController; 21 import org.columba.core.command.Command; 22 import org.columba.core.command.StatusObservableImpl; 23 import org.columba.core.logging.Logging; 24 import org.columba.mail.command.IMailFolderCommandReference; 25 import org.columba.mail.folder.IMailbox; 26 import org.columba.mail.spam.SpamController; 27 28 33 public class LearnMessageAsSpamCommand extends Command { 34 35 38 public LearnMessageAsSpamCommand(ICommandReference reference) { 39 super(reference); 40 } 41 42 45 public void execute(IWorkerStatusController worker) throws Exception { 46 47 IMailFolderCommandReference r = (IMailFolderCommandReference) getReference(); 49 50 Object [] uids = r.getUids(); 52 53 IMailbox srcFolder = (IMailbox) r.getSourceFolder(); 55 56 ((StatusObservableImpl) srcFolder.getObservable()).setWorker(worker); 58 59 if (uids.length > 1) { 61 worker.setDisplayText("Training messages..."); 63 worker.setProgressBarMaximum(uids.length); 64 } 65 66 for (int j = 0; j < uids.length; j++) { 67 if (worker.cancelled()) { 68 break; 69 } 70 71 try { 72 73 SpamController.getInstance().trainMessageAsSpam(srcFolder, 75 uids[j]); 76 77 if (uids.length > 1) { 78 worker.setProgressBarValue(j); 79 } 80 } catch (Exception e) { 81 if (Logging.DEBUG) { 82 e.printStackTrace(); 83 } 84 } 85 } 86 87 } 88 } | Popular Tags |