1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2005 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
32 import irc.EventDispatcher;
\r
33 import irc.IRCConfiguration;
\r
34 import irc.Interpretor;
\r
35 import irc.ListenerGroup;
\r
36 import irc.NullInterpretor;
\r
39 import java.awt.Component;
\r
42 * The common root class for all PJIRC user interfaces.
\r
44 public abstract class IRCInterface extends irc.plugin.Plugin {
\r
46 * The IRCInterfaceListener group.
\r
48 protected ListenerGroup _listenerGroup;
\r
50 private Interpretor _nullInterpretor;
\r
53 * Create a new IRCInterface with the given IRCConfiguration instance.
\r
55 * @param ircConfiguration
\r
56 * the global IRCConfiguration instance.
\r
58 public IRCInterface(IRCConfiguration ircConfiguration) {
\r
59 super(ircConfiguration);
\r
60 _listenerGroup = new ListenerGroup();
\r
61 _nullInterpretor = new NullInterpretor(_ircConfiguration);
\r
65 * Trigger the "activeChanged" event for all IRCInterfaceListeners. If this
\r
66 * method is called in the event thread, event dispatching will be
\r
67 * synchroneous. Otherwise, asynchroneous event will be dispatched.
\r
70 * the newly activated source.
\r
72 protected void triggerActiveChanged(GUISource source) {
\r
73 if (EventDispatcher.isEventThread())
\r
74 _listenerGroup.sendEvent("activeChanged", source, this);
\r
76 _listenerGroup.sendEventAsync("activeChanged", source, this);
\r
80 * Add an IRCInterfaceListener on this interface.
\r
83 * the listener to add.
\r
85 public void addIRCInterfaceListener(IRCInterfaceListener lis) {
\r
86 _listenerGroup.addListener(lis);
\r
90 * Remove an existing IRCInterfaceListener from this interface.
\r
93 * the listener to remove.
\r
95 public void removeIRCInterfaceListener(IRCInterfaceListener lis) {
\r
96 _listenerGroup.removeListener(lis);
\r
100 * Get the active source. For instance, return the keyboard focused source.
\r
101 * May be null if no particular source should be considered as being active.
\r
103 * @return the active gui source.
\r
105 public GUISource getActive() {
\r
110 * Set the active source. For instance, the one that should have the keybord
\r
114 * the new source to be active.
\r
116 public void setActive(GUISource source) {
\r
121 * Return the GUISource that belongs to the given source, or null if there is
\r
122 * no such mapping available.
\r
125 * source to get the GUI source from.
\r
126 * @return the GUISource, or null if there is no such mapping.
\r
128 public GUISource getGUISource(Source source) {
\r
133 * Get the default interpretor to be used when an unknown command is entered
\r
136 * @return the default interpretor.
\r
138 public Interpretor getInterpretor() {
\r
139 return _nullInterpretor;
\r
143 * Get the component associated with this interface.
\r
145 * @return the interface component, or null if no component is defined.
\r
147 public Component getComponent() {
\r