KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > filter > plugins > PlaySoundFilterAction


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16

17 package org.columba.mail.filter.plugins;
18
19 import java.io.File JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import org.columba.api.command.ICommand;
23 import org.columba.api.command.ICommandReference;
24 import org.columba.api.command.IWorkerStatusController;
25 import org.columba.core.command.Command;
26 import org.columba.core.filter.AbstractFilterAction;
27 import org.columba.core.filter.IFilterAction;
28 import org.columba.core.folder.DefaultFolderCommandReference;
29 import org.columba.core.folder.api.IFolder;
30
31 /**
32  * @author freddy
33  *
34  * To change this generated comment edit the template variable "typecomment":
35  * Window>Preferences>Java>Templates.
36  * To enable and disable the creation of type comments go to
37  * Window>Preferences>Java>Code Generation.
38  */

39 public class PlaySoundFilterAction extends AbstractFilterAction {
40
41     /**
42      * @see org.columba.mail.filter.plugins.AbstractFilterAction#getCommand()
43      */

44     public ICommand getCommand(
45         IFilterAction filterAction,
46         IFolder srcFolder,
47         Object JavaDoc[] uids)
48         throws Exception JavaDoc {
49
50         // just a simple example
51
for (int i = 0; i < uids.length; i++) {
52             System.out.println("Hello World for message-uid=" + uids[i]);
53         }
54
55         // for time consuming tasks you need to create
56
// your own Command
57

58         DefaultFolderCommandReference r =
59              new DefaultFolderCommandReference(srcFolder, uids);
60
61         PlaySoundCommand c = new PlaySoundCommand(r);
62
63         return c;
64
65     }
66
67     /**
68      *
69      * @author freddy
70      *
71      * To change this generated comment edit the template variable "typecomment":
72      * Window>Preferences>Java>Templates.
73      * To enable and disable the creation of type comments go to
74      * Window>Preferences>Java>Code Generation.
75      */

76     class PlaySoundCommand extends Command {
77         public PlaySoundCommand(ICommandReference reference) {
78             super(reference);
79         }
80
81         public void execute(IWorkerStatusController worker) throws Exception JavaDoc {
82
83             // you need a sound.wav in your program folder
84
File JavaDoc soundFile = new File JavaDoc("sound.wav");
85             URL JavaDoc url = soundFile.toURL();
86
87             PlaySound.play(url);
88         }
89     }
90 }
91
Popular Tags