01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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;
21:
22: import javax.swing.JOptionPane;
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
39: AbstractConnectionAwareAction {
40:
41: /**
42: * @param mediator
43: * @param name
44: */
45: public OpenConversationAction(IFrameMediator mediator) {
46: super (mediator, "Chat...");
47:
48: putValue(AbstractColumbaAction.TOOLBAR_NAME, "Chat");
49:
50: putValue(AbstractColumbaAction.LARGE_ICON, ResourceLoader
51: .getIcon("internet-group-chat.png"));
52: putValue(AbstractColumbaAction.SMALL_ICON, ResourceLoader
53: .getSmallIcon("internet-group-chat.png"));
54:
55: }
56:
57: /**
58: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
59: */
60: public void actionPerformed(ActionEvent arg0) {
61:
62: String jabberId = "";
63:
64: // selected buddy in buddylist
65: IBuddyStatus buddy = (IBuddyStatus) ((IChatFrameMediator) frameMediator)
66: .getRoasterTree().getSelected();
67:
68: if (buddy != null) {
69: // use selected buddy
70: jabberId = buddy.getJabberId();
71: } else {
72: // prompt for jabber id
73: jabberId = JOptionPane.showInputDialog(FrameManager
74: .getInstance().getActiveFrame(), "Enter Jabber ID");
75: }
76: CommandProcessor.getInstance().addOp(
77: new OpenChatCommand(
78: (IChatFrameMediator) getFrameMediator(),
79: new ChatCommandReference(jabberId)));
80:
81: }
82: }
|