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: DatabaseConnectDialog.java 4144 2007-01-04 03:46:20Z lzheng $
023: */
024: package com.bostechcorp.cbesb.console.client.dialogs;
025:
026: import com.bostechcorp.cbesb.console.client.ClientUtils;
027: import com.bostechcorp.cbesb.console.client.components.ComponentsCurrentBase;
028: import com.bostechcorp.cbesb.console.common.JmxComponentInfo;
029: import com.bostechcorp.cbesb.console.common.ServiceAssemblyObj;
030: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
031: import com.google.gwt.core.client.GWT;
032: import com.google.gwt.user.client.rpc.AsyncCallback;
033: import com.google.gwt.user.client.ui.Button;
034: import com.google.gwt.user.client.ui.ClickListener;
035: import com.google.gwt.user.client.ui.DialogBox;
036: import com.google.gwt.user.client.ui.FlexTable;
037: import com.google.gwt.user.client.ui.HasAlignment;
038: import com.google.gwt.user.client.ui.HasVerticalAlignment;
039: import com.google.gwt.user.client.ui.HorizontalPanel;
040: import com.google.gwt.user.client.ui.Label;
041: import com.google.gwt.user.client.ui.VerticalPanel;
042: import com.google.gwt.user.client.ui.Widget;
043:
044: public class UninstallConfirmDialog extends DialogBox implements
045: AsyncCallback {
046:
047: VerticalPanel mainPanel = new VerticalPanel();
048: //VerticalPanel mainPanel2 = new VerticalPanel();
049:
050: Label waitLabel = new Label(((ConsoleMessages) GWT
051: .create(ConsoleMessages.class))
052: .Check_for_dependence_service_unit());
053: ComponentsCurrentBase parent;
054: String componentName;
055: String action;
056:
057: public UninstallConfirmDialog(ComponentsCurrentBase p,
058: String action, String componentName) {
059: parent = p;
060: setText(action);
061: this .componentName = componentName;
062: this .action = action;
063: mainPanel.add(waitLabel);
064: setWidget(mainPanel);
065: this .setPopupPosition(80, 140);
066:
067: parent.getJmxOperationAsyncFromModule().getDependences(
068: componentName, this );
069: }
070:
071: public void delete() {
072: hide();
073: waitLabel.removeFromParent();
074: mainPanel.removeFromParent();
075: this .removeFromParent();
076: }
077:
078: public void onSuccess(Object o) {
079:
080: JmxComponentInfo info = (JmxComponentInfo) o;
081:
082: if (info.getComponentDependences().length == 0) {
083: parent.continueOperation(action, componentName);
084: delete();
085: return;
086: }
087: show();
088: waitLabel.setText(((ConsoleMessages) GWT
089: .create(ConsoleMessages.class))
090: .depended_sa_also_be_stopped(this .componentName));
091:
092: FlexTable table = new FlexTable();
093: int curRow = 0;
094:
095: table.setWidth("600px");
096: table.setBorderWidth(3);
097: table.setHTML(curRow, 0, "<h3>"
098: + ((ConsoleMessages) GWT.create(ConsoleMessages.class))
099: .Service_Assemblies() + "</h3>");
100: table.setHTML(curRow, 1, "<h3>"
101: + ((ConsoleMessages) GWT.create(ConsoleMessages.class))
102: .Service_Unit() + "</h3>");
103: table.getFlexCellFormatter().setVerticalAlignment(curRow, 0,
104: HasVerticalAlignment.ALIGN_MIDDLE);
105:
106: curRow++;
107: for (int i = 0; i < info.getComponentDependences().length; i++) {
108: ServiceAssemblyObj sa = info.getComponentDependences()[i];
109: table.setHTML(curRow, 0, sa.getName());
110: table.getFlexCellFormatter().setRowSpan(curRow, 0,
111: sa.getServiceUnits().length);
112: for (int j = 0; j < sa.getServiceUnits().length; j++) {
113: if (j == 0)
114: table.setHTML(curRow, 1, sa.getServiceUnits()[j]);
115: else
116: table.setHTML(curRow, 0, sa.getServiceUnits()[j]);
117: curRow++;
118: }
119: }
120:
121: final VerticalPanel verticalPanel = new VerticalPanel();
122: verticalPanel.add(table);
123:
124: verticalPanel.setSpacing(9);
125: final HorizontalPanel horizontalPanel = new HorizontalPanel();
126: verticalPanel.add(horizontalPanel);
127: horizontalPanel
128: .setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
129: horizontalPanel.setWidth("100%");
130: final Button continueBtn = new Button(((ConsoleMessages) GWT
131: .create(ConsoleMessages.class)).Continue());
132: continueBtn.addClickListener(new ClickListener() {
133: public void onClick(Widget w) {
134: parent.continueOperation(action, componentName);
135: }
136: });
137: horizontalPanel.add(continueBtn);
138: final Button abortBtn = new Button(((ConsoleMessages) GWT
139: .create(ConsoleMessages.class)).Abort());
140: abortBtn.addClickListener(new ClickListener() {
141: public void onClick(Widget w) {
142: parent.delConfirmDlg();
143: }
144: });
145: horizontalPanel.add(abortBtn);
146: mainPanel.add(verticalPanel);
147: }
148:
149: public void onFailure(Throwable t) {
150: if (!ClientUtils.checkTimeOut(t)) {
151: waitLabel.removeFromParent();
152: }
153: }
154:
155: }
|