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.about;
027:
028: import com.bostechcorp.cbesb.console.client.Admin;
029: import com.bostechcorp.cbesb.console.client.Console;
030: import com.bostechcorp.cbesb.console.client.ConsoleCallback;
031: import com.bostechcorp.cbesb.console.client.StyleConstants;
032: import com.bostechcorp.cbesb.console.common.ConsoleSystemSettingInfo;
033: import com.bostechcorp.cbesb.console.common.ConsoleUserSettingInfo;
034: import com.bostechcorp.cbesb.console.common.Constants;
035: import com.bostechcorp.cbesb.console.common.VersionInfo;
036: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
037: import com.bostechcorp.cbesb.console.rpc.ConsoleSetting;
038: import com.bostechcorp.cbesb.console.rpc.ConsoleSettingAsync;
039: import com.bostechcorp.cbesb.console.rpc.ConsoleVersionOperation;
040: import com.bostechcorp.cbesb.console.rpc.ConsoleVersionOperationAsync;
041: import com.bostechcorp.cbesb.console.rpc.ErrorDbOperations;
042: import com.bostechcorp.cbesb.console.rpc.ErrorDbOperationsAsync;
043: import com.google.gwt.core.client.GWT;
044: import com.google.gwt.user.client.rpc.ServiceDefTarget;
045: import com.google.gwt.user.client.ui.Button;
046: import com.google.gwt.user.client.ui.FlexTable;
047: import com.google.gwt.user.client.ui.HasHorizontalAlignment;
048: import com.google.gwt.user.client.ui.HasVerticalAlignment;
049: import com.google.gwt.user.client.ui.Label;
050: import com.google.gwt.user.client.ui.VerticalPanel;
051:
052: /**
053: * @author rui.hou
054: *
055: */
056: public class VersionPanel extends Admin {
057: /**
058: *
059: */
060: private FlexTable versionTable = new FlexTable();
061: private Label productNameLabel;
062: private Label versionLabel;
063: private Label buildTimeLabel;
064:
065: public VersionPanel() {
066: createWidget();
067: }
068:
069: /* (non-Javadoc)
070: * @see com.bostechcorp.cbesb.console.client.Admin#onHide()
071: */
072: public void onHide() {
073: // TODO Auto-generated method stub
074:
075: }
076:
077: /* (non-Javadoc)
078: * @see com.bostechcorp.cbesb.console.client.Admin#onShow()
079: */
080: public void onShow() {
081:
082: // getJmxOperationAsyncFromModule().getVersionInfo(((Button)sender).getText(), this);
083: readVersionInfo();
084:
085: }
086:
087: /* (non-Javadoc)
088: * @see com.bostechcorp.cbesb.console.client.Admin#refresh()
089: */
090: public void refresh() {
091: // getConsoleVersionOperationAsyncFromModule().getVersionInfo(new RefreshCallback(this));
092:
093: readVersionInfo();
094: }
095:
096: private void readVersionInfo() {
097: showWaitingDialog();
098: ConsoleVersionOperationAsync op;
099: op = (ConsoleVersionOperationAsync) GWT
100: .create(ConsoleVersionOperation.class);
101: ServiceDefTarget jmxConnectTarget = (ServiceDefTarget) op;
102: String relativeUrl = GWT.getModuleBaseURL()
103: + Constants.VERSION_OPERATION;
104: jmxConnectTarget.setServiceEntryPoint(relativeUrl);
105: op.getVersionInfo(new ReadVersionInfoListener(this ));
106:
107: }
108:
109: protected void createWidget() {
110: final VerticalPanel verticalPanel = new VerticalPanel();
111: initWidget(verticalPanel);
112: verticalPanel.setSize("100%", "100%");
113: initVersionTable();
114: verticalPanel.add(versionTable);
115: }
116:
117: private void initVersionTable() {
118: versionTable.clear();
119: versionTable.setWidth("100%");
120:
121: versionTable.setStyleName(StyleConstants.TABLE_STYLE);
122: versionTable.getRowFormatter().setStyleName(0,
123: StyleConstants.TABLE_HEADER_STYLE);
124: for (int i = 1; i < 4; i++) {
125: versionTable.getRowFormatter().setStyleName(i,
126: StyleConstants.TABLE_TD_STYLE);
127: }
128:
129: versionTable.setHTML(0, 0, "<h4>"
130: + ((ConsoleMessages) GWT.create(ConsoleMessages.class))
131: .versionInformation() + "</h4>");
132: versionTable.getFlexCellFormatter().setColSpan(0, 0, 2);
133: productNameLabel = new Label(((ConsoleMessages) GWT
134: .create(ConsoleMessages.class)).ProductName()
135: + ":");
136: versionTable.setWidget(1, 0, productNameLabel);
137:
138: versionLabel = new Label(((ConsoleMessages) GWT
139: .create(ConsoleMessages.class)).Version()
140: + ":");
141: versionTable.setWidget(2, 0, versionLabel);
142:
143: buildTimeLabel = new Label(((ConsoleMessages) GWT
144: .create(ConsoleMessages.class)).BuildTime()
145: + ":");
146: versionTable.setWidget(3, 0, buildTimeLabel);
147:
148: // if(Console.getInstance().isAlertMonitor())
149: // versionTable.setText(1, 1, "ChainBuilder ESB Admin Console Professional");
150: // else
151: // versionTable.setText(1, 1, "ChainBuilder ESB Admin Console Standard");
152: // versionTable.setText(2, 1, "1.2.0");
153: // versionTable.setText(3, 1, "2008/01/04 11:25");
154:
155: }
156:
157: public ConsoleVersionOperationAsync getConsoleVersionOperationAsyncFromModule() {
158: ConsoleVersionOperationAsync op;
159: op = (ConsoleVersionOperationAsync) GWT
160: .create(ConsoleVersionOperation.class);
161: ServiceDefTarget jmxConnectTarget = (ServiceDefTarget) op;
162: String relativeUrl = GWT.getModuleBaseURL()
163: + Constants.VERSION_OPERATION;
164: jmxConnectTarget.setServiceEntryPoint(relativeUrl);
165: return op;
166: }
167:
168: class ReadVersionInfoListener extends ConsoleCallback {
169:
170: public ReadVersionInfoListener(Admin admin) {
171: super (admin);
172:
173: }
174:
175: public void handleSuccess(Object result) {
176:
177: if (result instanceof VersionInfo) {
178:
179: VersionInfo ver = (VersionInfo) result;
180: if (ver.getProductName() == null) {
181: if (Console.getInstance().isAlertMonitor())
182: ver
183: .setProductName("ChainBuilder ESB Admin Console Professional");
184: else
185: ver
186: .setProductName("ChainBuilder ESB Admin Console Standard");
187: }
188: versionTable.setText(1, 1, ver.getProductName());
189: versionTable.setText(2, 1, ver.getVersion());
190: versionTable.setText(3, 1, ver.getBuildTime());
191:
192: }
193: }
194:
195: }
196: }
|