]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/gui/IRCInterface.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / gui / IRCInterface.java
1 /*****************************************************/\r
2 /*          This java file is a part of the          */\r
3 /*                                                   */\r
4 /*           -  Plouf's Java IRC Client  -           */\r
5 /*                                                   */\r
6 /*   Copyright (C)  2002 - 2005 Philippe Detournay   */\r
7 /*                                                   */\r
8 /*         All contacts : theplouf@yahoo.com         */\r
9 /*                                                   */\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
14 /*  the License.                                     */\r
15 /*                                                   */\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
21 /*                                                   */\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
27 /*                                                   */\r
28 /*****************************************************/\r
29 \r
30 package irc.gui;\r
31 \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
37 import irc.Source;\r
38 \r
39 import java.awt.Component;\r
40 \r
41 /**\r
42  * The common root class for all PJIRC user interfaces.\r
43  */\r
44 public abstract class IRCInterface extends irc.plugin.Plugin {\r
45         /**\r
46          * The IRCInterfaceListener group.\r
47          */\r
48         protected ListenerGroup _listenerGroup;\r
49 \r
50         private Interpretor _nullInterpretor;\r
51 \r
52         /**\r
53          * Create a new IRCInterface with the given IRCConfiguration instance.\r
54          * \r
55          * @param ircConfiguration\r
56          *          the global IRCConfiguration instance.\r
57          */\r
58         public IRCInterface(IRCConfiguration ircConfiguration) {\r
59                 super(ircConfiguration);\r
60                 _listenerGroup = new ListenerGroup();\r
61                 _nullInterpretor = new NullInterpretor(_ircConfiguration);\r
62         }\r
63 \r
64         /**\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
68          * \r
69          * @param source\r
70          *          the newly activated source.\r
71          */\r
72         protected void triggerActiveChanged(GUISource source) {\r
73                 if (EventDispatcher.isEventThread())\r
74                         _listenerGroup.sendEvent("activeChanged", source, this);\r
75                 else\r
76                         _listenerGroup.sendEventAsync("activeChanged", source, this);\r
77         }\r
78 \r
79         /**\r
80          * Add an IRCInterfaceListener on this interface.\r
81          * \r
82          * @param lis\r
83          *          the listener to add.\r
84          */\r
85         public void addIRCInterfaceListener(IRCInterfaceListener lis) {\r
86                 _listenerGroup.addListener(lis);\r
87         }\r
88 \r
89         /**\r
90          * Remove an existing IRCInterfaceListener from this interface.\r
91          * \r
92          * @param lis\r
93          *          the listener to remove.\r
94          */\r
95         public void removeIRCInterfaceListener(IRCInterfaceListener lis) {\r
96                 _listenerGroup.removeListener(lis);\r
97         }\r
98 \r
99         /**\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
102          * \r
103          * @return the active gui source.\r
104          */\r
105         public GUISource getActive() {\r
106                 return null;\r
107         }\r
108 \r
109         /**\r
110          * Set the active source. For instance, the one that should have the keybord\r
111          * focus.\r
112          * \r
113          * @param source\r
114          *          the new source to be active.\r
115          */\r
116         public void setActive(GUISource source) {\r
117                 // nothing here\r
118         }\r
119 \r
120         /**\r
121          * Return the GUISource that belongs to the given source, or null if there is\r
122          * no such mapping available.\r
123          * \r
124          * @param source\r
125          *          source to get the GUI source from.\r
126          * @return the GUISource, or null if there is no such mapping.\r
127          */\r
128         public GUISource getGUISource(Source source) {\r
129                 return null;\r
130         }\r
131 \r
132         /**\r
133          * Get the default interpretor to be used when an unknown command is entered\r
134          * by the user.\r
135          * \r
136          * @return the default interpretor.\r
137          */\r
138         public Interpretor getInterpretor() {\r
139                 return _nullInterpretor;\r
140         }\r
141 \r
142         /**\r
143          * Get the component associated with this interface.\r
144          * \r
145          * @return the interface component, or null if no component is defined.\r
146          */\r
147         public Component getComponent() {\r
148                 return null;\r
149         }\r
150 \r
151 } // IRCInterface\r