001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2008 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: *
023: * $Id$
024: */
025:
026: package com.bostechcorp.cbesb.console.client.preference;
027:
028: import com.bostechcorp.cbesb.console.client.Admin;
029: import com.bostechcorp.cbesb.console.client.ConsoleCallback;
030: import com.bostechcorp.cbesb.console.client.StyleConstants;
031: import com.bostechcorp.cbesb.console.client.dialogs.MessageViewDialog;
032: import com.bostechcorp.cbesb.console.client.preference.DefaultPreferencesPanel.RefreshCallback;
033: import com.bostechcorp.cbesb.console.client.preference.DefaultPreferencesPanel.SaveButtonClickListener;
034: import com.bostechcorp.cbesb.console.common.ConsoleSystemSettingInfo;
035: import com.bostechcorp.cbesb.console.common.ConsoleUserSettingInfo;
036: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
037: import com.google.gwt.core.client.GWT;
038: import com.google.gwt.user.client.ui.ClickListener;
039: import com.google.gwt.user.client.ui.FlexTable;
040: import com.google.gwt.user.client.ui.Label;
041: import com.google.gwt.user.client.ui.PushButton;
042: import com.google.gwt.user.client.ui.TextBox;
043: import com.google.gwt.user.client.ui.Widget;
044:
045: /**
046: * @author rui.hou
047: *
048: */
049: public class AlertSettingsPreferencePanel extends PreferencesPanelBase {
050: private TextBox textMemoryPingInterval = new TextBox();
051: private TextBox textCpuPingInterval = new TextBox();
052: private TextBox textLicensePingInterval = new TextBox();
053: private TextBox textDiskPingInterval = new TextBox();
054: private TextBox textServerPingInterval = new TextBox();
055: private TextBox textSAPingInterval = new TextBox();
056: private TextBox textComponentPingInterval = new TextBox();
057: private TextBox textFileStatusPingInterval = new TextBox();
058: private TextBox textCustomStatusValues = new TextBox();
059: private TextBox textErrorCountPingInterval = new TextBox();
060:
061: private Label memoryPingIntervalLabel = new Label(
062: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
063: .memoryPingInterval()
064: + ":");
065: private Label cpuPingIntervalLabel = new Label(
066: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
067: .cpuPingInterval()
068: + ":");
069: private Label licensePingIntervalLabel = new Label(
070: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
071: .licensePingInterval()
072: + ":");
073: private Label diskPingIntervalLabel = new Label(
074: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
075: .diskPingInterval()
076: + ":");
077: private Label serverPingIntervalLabel = new Label(
078: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
079: .serverPingInterval()
080: + ":");
081: private Label sAPingIntervalLabel = new Label(
082: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
083: .sAPingInterval()
084: + ":");;
085: private Label componentPingIntervalLabel = new Label(
086: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
087: .componentPingInterval()
088: + ":");;
089: private Label fileStatusPingIntervalLabel = new Label(
090: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
091: .fileStatusPingInterval()
092: + ":");;
093: private Label customStatusValuesLabel = new Label(
094: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
095: .customStatusValues()
096: + ":");
097: private Label errorCountPingIntervalLabel = new Label(
098: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
099: .errorCountPingInterval()
100: + ":");
101: private ConsoleSystemSettingInfo consoleSystemSetting;
102:
103: // private orderTable;
104: // private PushButton saveButton;
105:
106: public AlertSettingsPreferencePanel() {
107: super ();
108: init("0", false);
109: initTable();
110: }
111:
112: private void initTable() {
113: // this.orderTable=super.orderTable;
114: cleanCells(orderTable);
115: int countForProporty = 1;
116: int countForUnit = 1;
117: for (int i = countForProporty; i < countForProporty + 8; i++) {
118: orderTable.getRowFormatter().setStyleName(i,
119: StyleConstants.TABLE_TD_STYLE);
120: }
121: // orderTable.setWidget(countForProporty, 0, cpuPingIntervalLabel);
122: // orderTable.setWidget(countForProporty, 1, textCpuPingInterval);
123: // countForProporty++;
124:
125: orderTable.setWidget(countForProporty, 0,
126: licensePingIntervalLabel);
127: orderTable.setWidget(countForProporty, 1,
128: textLicensePingInterval);
129: countForProporty++;
130:
131: // orderTable.setWidget(countForProporty, 0, diskPingIntervalLabel);
132: // orderTable.setWidget(countForProporty, 1, textDiskPingInterval);
133: // countForProporty++;
134:
135: orderTable.setWidget(countForProporty, 0,
136: serverPingIntervalLabel);
137: orderTable.setWidget(countForProporty, 1,
138: textServerPingInterval);
139: countForProporty++;
140:
141: orderTable.setWidget(countForProporty, 0, sAPingIntervalLabel);
142: orderTable.setWidget(countForProporty, 1, textSAPingInterval);
143: countForProporty++;
144:
145: orderTable.setWidget(countForProporty, 0,
146: componentPingIntervalLabel);
147: orderTable.setWidget(countForProporty, 1,
148: textComponentPingInterval);
149: countForProporty++;
150:
151: orderTable.setWidget(countForProporty, 0,
152: fileStatusPingIntervalLabel);
153: orderTable.setWidget(countForProporty, 1,
154: textFileStatusPingInterval);
155: countForProporty++;
156:
157: orderTable.setWidget(countForProporty, 0,
158: memoryPingIntervalLabel);
159: orderTable.setWidget(countForProporty, 1,
160: textMemoryPingInterval);
161: countForProporty++;
162:
163: orderTable.setWidget(countForProporty, 0,
164: errorCountPingIntervalLabel);
165: orderTable.setWidget(countForProporty, 1,
166: textErrorCountPingInterval);
167: countForProporty++;
168:
169: orderTable.setWidget(countForProporty, 0,
170: customStatusValuesLabel);
171: orderTable.setWidget(countForProporty, 1,
172: textCustomStatusValues);
173: countForProporty++;
174:
175: for (int i = countForUnit; i < countForUnit + 7; i++) {
176: // if((orderTable.getCellFormatter().getElement(i)).get)
177: Label unitLabel = new Label(" "
178: + ((ConsoleMessages) GWT
179: .create(ConsoleMessages.class)).timeUnit()
180: + " ");
181: orderTable.setWidget(i, 2, unitLabel);
182:
183: }
184: orderTable.setWidget(countForUnit + 7, 2, new Label(" "));
185: }
186:
187: public void addSaveButtonClickListener() {
188: saveButton.addClickListener(new SaveButtonClickListener(this ));
189:
190: }
191:
192: public void refresh() {
193:
194: getConsoleSettingAsyncFromModule().getConsoleSystemSetting(
195: new RefreshCallback(this ));
196: }
197:
198: class RefreshCallback extends ConsoleCallback {
199:
200: public RefreshCallback(Admin admin) {
201: super (admin);
202:
203: }
204:
205: public void handleSuccess(Object result) {
206:
207: if (result instanceof ConsoleSystemSettingInfo) {
208: displayUserProperties((ConsoleUserSettingInfo) result);
209:
210: textMemoryPingInterval
211: .setText(((ConsoleSystemSettingInfo) result)
212: .getMemoryPingInterval());
213: // textCpuPingInterval.setText(((ConsoleSystemSettingInfo)result).getCpuPingInterval());
214: textLicensePingInterval
215: .setText(((ConsoleSystemSettingInfo) result)
216: .getLicensePingInterval());
217: // textDiskPingInterval.setText(((ConsoleSystemSettingInfo)result).getDiskPingInterval());
218: textServerPingInterval
219: .setText(((ConsoleSystemSettingInfo) result)
220: .getServerPingInterval());
221: textSAPingInterval
222: .setText(((ConsoleSystemSettingInfo) result)
223: .getSAPingInterval());
224: textComponentPingInterval
225: .setText(((ConsoleSystemSettingInfo) result)
226: .getComponentPingInterval());
227: textFileStatusPingInterval
228: .setText(((ConsoleSystemSettingInfo) result)
229: .getFileStatusPingInterval());
230: textCustomStatusValues
231: .setText(((ConsoleSystemSettingInfo) result)
232: .getCustomStatusValues());
233: textErrorCountPingInterval
234: .setText(((ConsoleSystemSettingInfo) result)
235: .getErrorCountPingInterval());
236:
237: }
238: }
239:
240: }
241:
242: class SaveButtonClickListener extends ConsoleCallback implements
243: ClickListener {
244: public SaveButtonClickListener(Admin admin) {
245: super (admin);
246: }
247:
248: public void onClick(Widget sender) {
249: if (sender == saveButton) {
250: ConsoleSystemSettingInfo consoleSystemSetting = new ConsoleSystemSettingInfo();
251: consoleSystemSetting.setUserId(userId);
252: if (setConsoleUserSetting(consoleSystemSetting))
253:
254: {
255: if (textMemoryPingInterval.getText().equals("")
256: // || textCpuPingInterval.getText().equals("")
257: || textLicensePingInterval.getText()
258: .equals("")
259: || textSAPingInterval.getText().equals("")
260: // || textDiskPingInterval.getText().equals("")
261: || textServerPingInterval.getText().equals(
262: "")
263: || textComponentPingInterval.getText()
264: .equals("")
265: || textFileStatusPingInterval.getText()
266: .equals("")
267: || textErrorCountPingInterval.getText()
268: .equals(""))
269: MessageViewDialog
270: .showWarning(((ConsoleMessages) GWT
271: .create(ConsoleMessages.class))
272: .nullPropertiesMessage());
273: else if (confirmeText(textMemoryPingInterval
274: .getText())
275: // &&confirmeText( textCpuPingInterval.getText())
276: && confirmeText(textLicensePingInterval
277: .getText())
278: // &&confirmeText( textDiskPingInterval.getText())
279: && confirmeText(textServerPingInterval
280: .getText())
281: && confirmeText(textSAPingInterval
282: .getText())
283: && confirmeText(textComponentPingInterval
284: .getText())
285: && confirmeText(textFileStatusPingInterval
286: .getText())
287: && confirmeText(textErrorCountPingInterval
288: .getText())) {
289:
290: consoleSystemSetting
291: .setMemoryPingInterval(textMemoryPingInterval
292: .getText());
293: // consoleSystemSetting.setCpuPingInterval(textCpuPingInterval.getText());
294: consoleSystemSetting
295: .setLicensePingInterval(textLicensePingInterval
296: .getText());
297: // consoleSystemSetting.setDiskPingInterval(textDiskPingInterval.getText());
298: consoleSystemSetting
299: .setServerPingInterval(textServerPingInterval
300: .getText());
301: consoleSystemSetting
302: .setSAPingInterval(textSAPingInterval
303: .getText());
304: consoleSystemSetting
305: .setComponentPingInterval(textComponentPingInterval
306: .getText());
307: consoleSystemSetting
308: .setFileStatusPingInterval(textFileStatusPingInterval
309: .getText());
310: consoleSystemSetting
311: .setCustomStatusValues(textCustomStatusValues
312: .getText());
313: consoleSystemSetting
314: .setErrorCountPingInterval(textErrorCountPingInterval
315: .getText());
316:
317: getConsoleSettingAsyncFromModule()
318: .saveConsoleSystemSetting(userId,
319: consoleSystemSetting, this );
320: } else
321: MessageViewDialog
322: .showWarning(((ConsoleMessages) GWT
323: .create(ConsoleMessages.class))
324: .numberConfirmMessage());
325: }
326: }
327: }
328:
329: public void handleSuccess(Object result) {
330: MessageViewDialog.showInfo(((ConsoleMessages) GWT
331: .create(ConsoleMessages.class)).saveSuccessfully());
332: }
333: }
334:
335: public void cleanCells(FlexTable flexTable) {
336: int rows = flexTable.getRowCount();
337: for (int i = 1; i < rows; i++) {
338: flexTable.removeRow(1);
339: }
340: }
341:
342: public void saveProperties() {
343: if (consoleSystemSetting == null) {
344: consoleSystemSetting = new ConsoleSystemSettingInfo();
345: consoleSystemSetting.setUserId(userId);
346: super .saveProperties(consoleSystemSetting);
347: }
348: getConsoleSettingAsyncFromModule().saveConsoleSystemSetting(
349: userId, consoleSystemSetting,
350: new SaveButtonClickListener(this ));
351:
352: }
353:
354: public void saveConsoleSystemSetting(
355: ConsoleSystemSettingInfo consoleSystemSetting) {
356: this.consoleSystemSetting = consoleSystemSetting;
357: saveProperties();
358:
359: }
360:
361: }
|