001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * 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 MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.console.client.endpoint;
025:
026: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
027: import com.bostechcorp.cbesb.console.pub.JmxAssemblyObj;
028: import com.bostechcorp.cbesb.console.pub.JmxComponentObj;
029: import com.google.gwt.core.client.GWT;
030: import com.google.gwt.user.client.ui.ClickListener;
031: import com.google.gwt.user.client.ui.HTMLTable;
032: import com.google.gwt.user.client.ui.HorizontalPanel;
033: import com.google.gwt.user.client.ui.ListBox;
034: import com.google.gwt.user.client.ui.TreeItem;
035: import com.google.gwt.user.client.ui.Widget;
036:
037: public class EndpointStatusOneUser extends EndpointBaseOne {
038:
039: private HorizontalPanel toolsPanel = new HorizontalPanel();
040:
041: public EndpointStatusOneUser() {
042: this .endpointView = new EndpointViewUser(this );
043: initWidgets();
044: }
045:
046: protected void initWidgets() {
047: endpointPanel.clear();
048:
049: this .lastSaArray = this .itemArray;
050: this .lastExpandArray = this .expandArray;
051: this .lastSelLocation = this .curSelLocation;
052: saListBox = new ListBox();
053:
054: saListBox.setWidth("200px");
055: retrieveButton.setText(((ConsoleMessages) GWT
056: .create(ConsoleMessages.class)).retrieve());
057: retrieveButton.addClickListener(new ClickListener() {
058: public void onClick(Widget sender) {
059: showWaitingDialog();
060: getSANameList();
061: }
062: });
063:
064: toolsPanel.add(saListBox);
065: toolsPanel.add(retrieveButton);
066:
067: endpointPanel.add(toolsPanel);
068: endpointPanel.add(tree);
069: }
070:
071: protected void getAssemblyInfo() {
072: getJmxOperationAsyncFromModule().getAssemblyObjAndValues(
073: currentSaName, refreshCallback);
074: }
075:
076: protected void drawTree() {
077: tree.removeItems();
078: TreeItem selItem = null;
079: int len = currentAssembly.getComponentList().length + 1;
080: this .itemArray = new String[len];
081: this .expandArray = new String[len];
082: int index = 0;
083:
084: String saName = currentAssembly.getName();
085: TreeItem saItem = tree.addItem(saName);
086: saItem
087: .setUserObject(new CbesbItem(saName, TYPE_ASSEMBLY,
088: index));
089: String saExpandState = getExpandState(saName);
090: this .itemArray[index] = saName;
091: this .expandArray[index++] = saExpandState;
092:
093: if (this .lastSelLocation != null
094: && this .lastSelLocation.equals(saName)) {
095: selItem = saItem;
096: }
097:
098: for (int i = 0; i < currentAssembly.getComponentList().length; i++) {
099: JmxComponentObj component = currentAssembly
100: .getComponentList()[i];
101: TreeItem componentItem = saItem
102: .addItem(component.getName());
103: String location = saName + "_" + component.getName();
104: componentItem.setUserObject(new CbesbItem(location,
105: TYPE_COMPONENT, index));
106: if (this .lastSelLocation != null
107: && this .lastSelLocation.equals(location)) {
108: selItem = componentItem;
109: }
110: String compExpandState = getExpandState(location);
111: this .itemArray[index] = saName + "_" + component.getName();
112: this .expandArray[index++] = compExpandState;
113:
114: if (component.getEndpointList().length > 0) {
115: HTMLTable table = buildHtmlTable(component);
116: TreeItem epItem = componentItem.addItem(table);
117: String epLocation = location + "_ep";
118: epItem.setUserObject(new CbesbItem(epLocation,
119: TYPE_ENDPOINT, index));
120: if (this .lastSelLocation != null
121: && this .lastSelLocation.equals(epLocation)) {
122: selItem = epItem;
123: }
124: componentItem.setState(compExpandState.equals("1"));
125:
126: }
127: }
128: saItem.setState(saExpandState.equals("1"));
129: if (selItem != null)
130: tree.setSelectedItem(selItem);
131: tree.removeTreeListener(this );
132: tree.addTreeListener(this );
133: }
134:
135: protected void doPolling() {
136: getPollingAsyncFromModule().pollingStatusChangeBySA(
137: currentSaName, pollingCallback);
138: }
139:
140: protected boolean isChanged(JmxAssemblyObj sa) {
141: if (sa.getEndpointStatusChanged() != null)
142: return true;
143: else
144: return false;
145: }
146:
147: protected void getSANameList() {
148: stopPollingFlag();
149: getJmxOperationAsyncFromModule().getSAListForEndpointStatus(
150: currentSaName, refreshCallback);
151: }
152:
153: }
|