KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > chat > ui > action > OpenConversationAction


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.chat.ui.action;
19
20 import java.awt.event.ActionEvent JavaDoc;
21
22 import javax.swing.JOptionPane JavaDoc;
23
24 import org.columba.api.gui.frame.IFrameMediator;
25 import org.columba.chat.command.ChatCommandReference;
26 import org.columba.chat.command.OpenChatCommand;
27 import org.columba.chat.model.api.IBuddyStatus;
28 import org.columba.chat.resourceloader.ResourceLoader;
29 import org.columba.chat.ui.frame.api.IChatFrameMediator;
30 import org.columba.core.command.CommandProcessor;
31 import org.columba.core.gui.action.AbstractColumbaAction;
32 import org.columba.core.gui.frame.FrameManager;
33
34 /**
35  * @author fdietz
36  *
37  */

38 public class OpenConversationAction extends AbstractConnectionAwareAction {
39
40     /**
41      * @param mediator
42      * @param name
43      */

44     public OpenConversationAction(IFrameMediator mediator) {
45         super(mediator, "Chat...");
46
47         putValue(AbstractColumbaAction.TOOLBAR_NAME, "Chat");
48
49         putValue(AbstractColumbaAction.LARGE_ICON, ResourceLoader
50                 .getIcon("internet-group-chat.png"));
51         putValue(AbstractColumbaAction.SMALL_ICON, ResourceLoader
52                 .getSmallIcon("internet-group-chat.png"));
53
54     }
55
56     /**
57      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
58      */

59     public void actionPerformed(ActionEvent JavaDoc arg0) {
60
61         String JavaDoc jabberId = "";
62
63         // selected buddy in buddylist
64
IBuddyStatus buddy = (IBuddyStatus) ((IChatFrameMediator) frameMediator)
65                 .getRoasterTree().getSelected();
66
67         if (buddy != null) {
68             // use selected buddy
69
jabberId = buddy.getJabberId();
70         } else {
71             // prompt for jabber id
72
jabberId = JOptionPane.showInputDialog(FrameManager.getInstance()
73                     .getActiveFrame(), "Enter Jabber ID");
74         }
75         CommandProcessor.getInstance()
76         .addOp(
77                 new OpenChatCommand((IChatFrameMediator) getFrameMediator(),new ChatCommandReference(
78                         jabberId)));
79
80     }
81 }
Popular Tags