1
/** BEGIN COPYRIGHT BLOCK
2
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3
* Copyright (C) 2005 Red Hat, Inc.
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; version 2
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
* END COPYRIGHT BLOCK **/
21
package com.netscape.management.admserv.panel;
25
import javax.swing.event.*;
26
import com.netscape.management.client.util.*;
27
import com.netscape.management.client.console.ConsoleInfo;
28
import com.netscape.management.admserv.config.*;
29
import com.netscape.management.nmclf.SuiConstants;
33
* @version 0.1 11/23/97
34
* @author miodrag@netscape.com
36
public class LoggingConfigPanel extends PluginConfigPanel {
38
IConfigDataModel _configData;
40
static ResourceSet _resource;
41
static String _i18nLogPath, _i18nLogFile, _i18nErrorLogGroupbox,
42
_i18nAccessLogGroupbox;
45
_resource = new ResourceSet("com.netscape.management.admserv.panel.panel");
46
_i18nLogPath = _resource.getString("logging","LogPath");
47
_i18nLogFile = _resource.getString("logging","LogFile");
48
_i18nAccessLogGroupbox = _resource.getString("logging","AccessLogGroupbox");
49
_i18nErrorLogGroupbox = _resource.getString("logging","ErrorLogGroupbox");
54
public static final int topInset =
55
SuiConstants.SEPARATED_COMPONENT_SPACE;
56
public static final int rghtColInset = SuiConstants.COMPONENT_SPACE;
58
JLabel _lblAccessPath, _lblErrorPath;
59
JTextField _txtAccessPath, _txtErrorPath;
61
JLabel _lblAccessFile, _lblErrorFile;
62
JTextField _txtAccessFile, _txtErrorFile;
65
public LoggingConfigPanel(String title, ConsoleInfo consoleInfo) {
67
_configData = new CGILoggingSetup(consoleInfo);
69
setLayout(new BorderLayout());
70
add(makeConfigPanel(), BorderLayout.NORTH);
71
_help = new Help(_resource);
74
public void showHelp() {
75
_help.contextHelp("loggingHelp");
78
public IConfigDataModel getDataModel() {
82
public void setDataModel(IConfigDataModel data) {
84
if (_configData.isLoaded()) {
85
setPanelContent(_configData);
89
public void initialize() throws ConfigPanelException {
91
if (!_configData.isLoaded()) {
94
setPanelContent(_configData);
95
} catch (ConfigPanelException e) {
100
public void resetContent() {
101
setPanelContent(_configData);
104
public void applyChanges() throws ValidationException {
106
getPanelContent(_configData);
107
} catch (ValidationException e) {
112
public void registerEditComponents(EditMonitor editMonitor) {
113
editMonitor.monitor(_txtAccessFile);
114
editMonitor.monitor(_txtErrorFile);
117
public void setPanelContent(IConfigDataModel data) {
118
System.out.println("LoggingConfigPanel.setPanelContent: data: "+data.getClass().getName());
120
value = (String) data.getAttribute(AttrNames.CONFIG_ACCESSLOG);
122
_txtAccessPath.setText("");
123
_txtAccessFile.setText("");
125
int i = value.lastIndexOf('/');
126
_txtAccessPath.setText(value.substring(0, i));
127
_txtAccessFile.setText(value.substring(i+1));
130
value = (String) data.getAttribute(AttrNames.CONFIG_ERRORLOG);
132
_txtErrorPath.setText("");
133
_txtErrorFile.setText("");
135
int i = value.lastIndexOf('/');
136
_txtErrorPath.setText(value.substring(0, i));
137
_txtErrorFile.setText(value.substring(i+1));
141
public void getPanelContent(IConfigDataModel data)
142
throws ValidationException {
144
data.setAttribute(AttrNames.CONFIG_ACCESSLOG,
145
_txtAccessPath.getText()+"/"+_txtAccessFile.getText());
146
data.setAttribute(AttrNames.CONFIG_ERRORLOG,
147
_txtErrorPath.getText()+"/"+_txtErrorFile.getText());
148
} catch (ValidationException e) {
154
private JPanel makeConfigPanel() {
156
JPanel p = new JPanel();
161
p.setLayout(gbl = new GridBagLayout());
163
_lblAccessPath = new JLabel(_i18nLogPath);
164
_txtAccessPath = new SingleByteTextField(16);
165
_lblAccessFile = new JLabel(_i18nLogFile);
166
_txtAccessFile = new SingleByteTextField(16); // 324429
168
_txtAccessPath.setEditable(false);
170
//gbc.setInsets(0,leftColInset,0,0);
171
gbc.setGrid(0, 0, 1, 1);
172
gbc.setSpace(1.0, 0.0, GBC.WEST, //anchor
173
GBC.HORIZONTAL); //fill
174
p.add(createLogGroup(_i18nAccessLogGroupbox,
175
_lblAccessPath, _txtAccessPath,
176
_lblAccessFile, _txtAccessFile), gbc);
178
_lblErrorPath = new JLabel(_i18nLogPath);
179
_txtErrorPath = new SingleByteTextField(16);
180
_lblErrorFile = new JLabel(_i18nLogFile);
181
_txtErrorFile = new SingleByteTextField(16); // 324429
183
_txtErrorPath.setEditable(false);
185
//gbc.setInsets(0,leftColInset,0,0);
186
gbc.setGrid(0, 1, 1, 1);
187
gbc.setSpace(1.0, 0.0, GBC.WEST, //anchor
188
GBC.HORIZONTAL); //fill
189
p.add(createLogGroup(_i18nErrorLogGroupbox,
190
_lblErrorPath, _txtErrorPath,
191
_lblErrorFile, _txtErrorFile), gbc);
196
private JPanel createLogGroup(String groupTitle,
197
JLabel lblPath, JTextField txtPath,
198
JLabel lblFile, JTextField txtFile) {
201
JPanel group = new JPanel(gbl = new GridBagLayout());
202
group.setBorder(BaseConfigPanel.createGroupBorder(groupTitle));
204
lblPath.setFont(BaseConfigPanel.getLabelFont());
205
gbc.setInsets(0, 0, 0, 0);
206
gbc.setGrid(0, 0, 1, 1);
207
gbc.setSpace(0.0, 0.0, GBC.WEST, //anchor
209
group.add(lblPath, gbc);
211
gbc.setInsets(0, rghtColInset, 0, 0);
212
gbc.setGrid(1, 0, 1, 1);
213
gbc.setSpace(1.0, 0.0, GBC.WEST, // anchor
214
GBC.HORIZONTAL); //fill
215
group.add(txtPath, gbc);
217
lblFile.setFont(BaseConfigPanel.getLabelFont());
218
gbc.setInsets(0, 0, 0, 0);
219
gbc.setGrid(0, 1, 1, 1);
220
gbc.setSpace(0.0, 0.0, GBC.WEST, //anchor
222
group.add(lblFile, gbc);
224
gbc.setInsets(0, rghtColInset, 0, 0);
225
gbc.setGrid(1, 1, 1, 1);
226
gbc.setSpace(1.0, 0.0, GBC.WEST, // anchor
227
GBC.HORIZONTAL); //fill
228
group.add(txtFile, gbc);