KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > demo > logging > PanelHandler


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.demo.logging;
20
21 import java.awt.BorderLayout JavaDoc;
22 import java.awt.Button JavaDoc;
23 import java.awt.Panel JavaDoc;
24 import java.awt.TextArea JavaDoc;
25 import java.awt.event.ActionEvent JavaDoc;
26 import java.awt.event.ActionListener JavaDoc;
27
28 import sync4j.syncclient.common.logging.Handler;
29
30 import sync4j.syncclient.demo.Language;
31 import sync4j.syncclient.demo.MainWindow;
32
33 /**
34  * The synchronization panel.
35  *
36  * @author Fabio Maggi @ Funambol
37  * @author Alessandro Morandi, Giorgio Orsi
38  * @version $Id: PanelHandler.java,v 1.3 2005/01/19 11:01:11 fabius Exp $
39  */

40 public class PanelHandler extends Panel JavaDoc
41 implements ActionListener JavaDoc, Handler {
42
43     //---------------------------------------------------------- Constants
44

45     //---------------------------------------------------------- Private data
46

47     //
48
// The window containing this panel
49
//
50
private MainWindow mw = null ;
51
52     private TextArea JavaDoc syncLog = null ;
53     private Button JavaDoc butOk = null ;
54
55     private Language ln = new Language() ;
56
57     //---------------------------------------------------------- Public methods
58

59
60     public void printMessage(String JavaDoc s) {
61         log(s);
62     }
63
64     /**
65      * Creates the panel.
66      *
67      * @param mw the window containing this panel
68      */

69     public PanelHandler(MainWindow mw) {
70
71         this.mw = mw;
72
73         setLayout(new BorderLayout JavaDoc());
74
75         syncLog = new TextArea JavaDoc();
76         syncLog.setEditable(false);
77
78         butOk = new Button JavaDoc (ln.getString ("ok") ) ;
79         butOk.setActionCommand ("ok" ) ;
80         butOk.addActionListener (this ) ;
81         butOk.setEnabled (false ) ;
82
83         add (syncLog , BorderLayout.CENTER ) ;
84         add (butOk , BorderLayout.SOUTH ) ;
85
86     }
87
88     /**
89      * Invoked when an action occurs (i.e. a button is pressed).
90      *
91      * @param evt the occurred action
92      */

93     public void actionPerformed(ActionEvent JavaDoc evt) {
94         if (evt.getActionCommand().equals("ok")) {
95             syncLog.setText("");
96             mw.refresh();
97         }
98     }
99
100     /**
101      * Sets the "Ok" button to the specified value
102      *
103      * @param value the value to set the button to
104      */

105     public void setButton(boolean value) {
106         butOk.setEnabled(value);
107     }
108
109     //---------------------------------------------------------- Protected methods
110

111     /**
112      * Shows in the log window the specified message
113      *
114      * @param msg the message to be shown
115      */

116     protected void log(String JavaDoc msg) {
117         syncLog.append(msg + "\n") ;
118     }
119
120     //---------------------------------------------------------- Private methods
121

122 }
Popular Tags