001: package com.bostechcorp.cbesb.console.client.preference;
002:
003: import com.bostechcorp.cbesb.console.client.Admin;
004: import com.bostechcorp.cbesb.console.client.Console;
005: import com.bostechcorp.cbesb.console.client.ConsoleCallback;
006: import com.bostechcorp.cbesb.console.client.StyleConstants;
007: import com.bostechcorp.cbesb.console.client.dialogs.MessageViewDialog;
008: import com.bostechcorp.cbesb.console.common.ConsoleSystemSettingInfo;
009: import com.bostechcorp.cbesb.console.common.ConsoleUserSettingInfo;
010: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
011: import com.google.gwt.core.client.GWT;
012: import com.google.gwt.user.client.ui.ClickListener;
013: import com.google.gwt.user.client.ui.Label;
014: import com.google.gwt.user.client.ui.TextBox;
015: import com.google.gwt.user.client.ui.Widget;
016:
017: public class DefaultPreferencesPanel extends PreferencesPanelBase {
018:
019: // private FlexTable orderTable;
020:
021: private ConsoleSystemSettingInfo consoleSystemSetting;
022:
023: public DefaultPreferencesPanel() {
024: super ();
025: init("0", false);
026:
027: // for Alert Monitor, we will add the Alert related preference choice
028: // if (Console.getInstance().isAlertMonitor())
029: // addSystemProperties();
030: }
031:
032: public void addSaveButtonClickListener() {
033: saveButton.addClickListener(new SaveButtonClickListener(this ));
034:
035: }
036:
037: public void refresh() {
038:
039: getConsoleSettingAsyncFromModule().getConsoleSystemSetting(
040: new RefreshCallback(this ));
041: }
042:
043: class RefreshCallback extends ConsoleCallback {
044:
045: public RefreshCallback(Admin admin) {
046: super (admin);
047:
048: }
049:
050: public void handleSuccess(Object result) {
051:
052: if (result instanceof ConsoleSystemSettingInfo) {
053: displayUserProperties((ConsoleUserSettingInfo) result);
054:
055: // textMemoryPingInterval.setText(((ConsoleSystemSettingInfo)result).getMemoryPingInterval());
056: // textCpuPingInterval.setText(((ConsoleSystemSettingInfo)result).getCpuPingInterval());
057: // textLicensePingInterval.setText(((ConsoleSystemSettingInfo)result).getLicensePingInterval());
058: // textDiskPingInterval.setText(((ConsoleSystemSettingInfo)result).getDiskPingInterval());
059: // textServerPingInterval.setText(((ConsoleSystemSettingInfo)result).getServerPingInterval());
060: // textSAPingInterval.setText(((ConsoleSystemSettingInfo)result).getSAPingInterval());
061: // textComponentPingInterval.setText(((ConsoleSystemSettingInfo)result).getComponentPingInterval());
062: // textFileStatusPingInterval.setText(((ConsoleSystemSettingInfo)result).getFileStatusPingInterval());
063: // textCustomStatusValues.setText(((ConsoleSystemSettingInfo)result).getCustomStatusValues());
064: // textErrorCountPingInterval.setText(((ConsoleSystemSettingInfo)result).getErrorCountPingInterval());
065:
066: }
067: }
068:
069: }
070:
071: class SaveButtonClickListener extends ConsoleCallback implements
072: ClickListener {
073: public SaveButtonClickListener(Admin admin) {
074: super (admin);
075: }
076:
077: public void onClick(Widget sender) {
078: if (sender == saveButton) {
079: ConsoleSystemSettingInfo consoleSystemSetting = new ConsoleSystemSettingInfo();
080: consoleSystemSetting.setUserId(userId);
081: if (setConsoleUserSetting(consoleSystemSetting))
082:
083: {
084: // if (textMemoryPingInterval.getText().equals("")
085: // || textCpuPingInterval.getText().equals("")
086: // || textLicensePingInterval.getText().equals("")
087: // || textSAPingInterval.getText().equals("")
088: // || textDiskPingInterval.getText().equals("")
089: // || textServerPingInterval.getText().equals("")
090: // || textComponentPingInterval.getText().equals("")
091: // || textFileStatusPingInterval.getText().equals("")
092: // || textErrorCountPingInterval.getText().equals("")
093: // )
094: // MessageViewDialog.showWarning(((ConsoleMessages) GWT.create(ConsoleMessages.class)).nullPropertiesMessage());
095: // else if(confirmeText(textMemoryPingInterval.getText())
096: // &&confirmeText( textCpuPingInterval.getText())
097: // &&confirmeText( textLicensePingInterval.getText())
098: // &&confirmeText( textDiskPingInterval.getText())
099: // &&confirmeText( textServerPingInterval.getText())
100: // &&confirmeText( textSAPingInterval.getText())
101: // &&confirmeText( textComponentPingInterval.getText())
102: // &&confirmeText( textFileStatusPingInterval.getText())
103: // &&confirmeText( textErrorCountPingInterval.getText())
104: // )
105: // {
106: //
107: // consoleSystemSetting.setMemoryPingInterval(textMemoryPingInterval.getText());
108: // consoleSystemSetting.setCpuPingInterval(textCpuPingInterval.getText());
109: // consoleSystemSetting.setLicensePingInterval(textLicensePingInterval.getText());
110: // consoleSystemSetting.setDiskPingInterval(textDiskPingInterval.getText());
111: // consoleSystemSetting.setServerPingInterval(textServerPingInterval.getText());
112: // consoleSystemSetting.setSAPingInterval(textSAPingInterval.getText());
113: // consoleSystemSetting.setComponentPingInterval(textComponentPingInterval.getText());
114: // consoleSystemSetting.setFileStatusPingInterval(textFileStatusPingInterval.getText());
115: // consoleSystemSetting.setCustomStatusValues(textCustomStatusValues.getText());
116: // consoleSystemSetting.setErrorCountPingInterval(textErrorCountPingInterval.getText());
117: saveConsoleSystemSetting(consoleSystemSetting);
118:
119: // getConsoleSettingAsyncFromModule().saveConsoleSystemSetting(userId,consoleSystemSetting, this);
120: // }
121: // else
122: // MessageViewDialog.showWarning(((ConsoleMessages) GWT.create(ConsoleMessages.class)).numberConfirmMessage());
123: }
124: }
125: }
126:
127: public void handleSuccess(Object result) {
128: MessageViewDialog.showInfo(((ConsoleMessages) GWT
129: .create(ConsoleMessages.class)).saveSuccessfully());
130: }
131: }
132:
133: public void saveProperties() {
134: if (consoleSystemSetting == null) {
135: consoleSystemSetting = new ConsoleSystemSettingInfo();
136: consoleSystemSetting.setUserId(userId);
137: super .saveProperties(consoleSystemSetting);
138: }
139: getConsoleSettingAsyncFromModule().saveConsoleSystemSetting(
140: userId, consoleSystemSetting,
141: new SaveButtonClickListener(this ));
142:
143: }
144:
145: public void saveConsoleSystemSetting(
146: ConsoleSystemSettingInfo consoleSystemSetting) {
147: this.consoleSystemSetting = consoleSystemSetting;
148: saveProperties();
149:
150: }
151:
152: }
|