001: package com.bostechcorp.cbesb.console.client.dialogs;
002:
003: import com.bostechcorp.cbesb.console.client.AdminEndPoints;
004: import com.bostechcorp.cbesb.console.client.ConsoleImageBundle;
005: import com.bostechcorp.cbesb.console.common.JmxEndpointInfo;
006: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
007: import com.google.gwt.core.client.GWT;
008: import com.google.gwt.user.client.ui.ClickListener;
009: import com.google.gwt.user.client.ui.DialogBox;
010: import com.google.gwt.user.client.ui.FlexTable;
011: import com.google.gwt.user.client.ui.HasHorizontalAlignment;
012: import com.google.gwt.user.client.ui.Label;
013: import com.google.gwt.user.client.ui.PushButton;
014: import com.google.gwt.user.client.ui.VerticalPanel;
015: import com.google.gwt.user.client.ui.Widget;
016:
017: public abstract class EndpointOperDialogBase extends DialogBox {
018: protected AdminEndPoints parent = null;
019: public ConsoleImageBundle images = (ConsoleImageBundle) GWT
020: .create(ConsoleImageBundle.class);
021: protected String endpointName = "";
022: protected String curStatus = "";
023: protected String componentName = "";
024: protected String assemblyName = "";
025:
026: public void init() {
027: setText(endpointName
028: + ((ConsoleMessages) GWT.create(ConsoleMessages.class))
029: .Operation());
030:
031: final VerticalPanel verticalPanel = new VerticalPanel();
032: setWidget(verticalPanel);
033: verticalPanel
034: .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
035: verticalPanel.setSize("100%", "100%");
036:
037: final FlexTable flexTable = new FlexTable();
038: verticalPanel.add(flexTable);
039: flexTable.setSize("90%", "90%");
040:
041: final PushButton startButton;
042: if (JmxEndpointInfo.isDownStatus(curStatus)) {
043: startButton = new PushButton(this .images.startButton()
044: .createImage());
045: startButton.setTitle(((ConsoleMessages) GWT
046: .create(ConsoleMessages.class)).Start());
047:
048: } else {
049: startButton = new PushButton(this .images.shutdownButton()
050: .createImage());
051: startButton.setTitle(((ConsoleMessages) GWT
052: .create(ConsoleMessages.class)).Stop());
053:
054: }
055: startButton.setWidth("24px");
056: startButton.setHeight("24px");
057: flexTable.setWidget(2, 0, startButton);
058: startButton.addClickListener(new ClickListener() {
059: public void onClick(final Widget sender) {
060: PushButton b = (PushButton) sender;
061: if (b.getTitle()
062: .equals(
063: ((ConsoleMessages) GWT
064: .create(ConsoleMessages.class))
065: .Start())) {
066: startEndpoint();
067: } else if (b.getTitle().equals(
068: ((ConsoleMessages) GWT
069: .create(ConsoleMessages.class)).Stop())) {
070: stopEndpoint();
071:
072: }
073:
074: hide();
075: }
076: });
077: flexTable.getCellFormatter().setWidth(2, 0, "50%");
078: flexTable.getCellFormatter().setHorizontalAlignment(2, 0,
079: HasHorizontalAlignment.ALIGN_CENTER);
080:
081: final Label pleaseChooseTheLabel = new Label(
082: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
083: .chooseOperation());
084: flexTable.setWidget(0, 0, pleaseChooseTheLabel);
085: flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
086: flexTable.getCellFormatter().setWidth(0, 0, "50%");
087: flexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
088: flexTable.getCellFormatter().setWidth(1, 0, "50%");
089:
090: final PushButton cycleButton = new PushButton(this .images
091: .cycleButton().createImage());
092: cycleButton.setWidth("24px");
093: cycleButton.setHeight("24px");
094: if (!JmxEndpointInfo.isDownStatus(curStatus))
095: flexTable.setWidget(2, 1, cycleButton);
096: cycleButton.addClickListener(new ClickListener() {
097: public void onClick(final Widget sender) {
098: cycleEndpoint();
099: hide();
100:
101: }
102: });
103: flexTable.getCellFormatter().setHorizontalAlignment(2, 2,
104: HasHorizontalAlignment.ALIGN_RIGHT);
105: cycleButton.setTitle(((ConsoleMessages) GWT
106: .create(ConsoleMessages.class)).Cycle());
107:
108: final PushButton closeButton = new PushButton();
109: flexTable.setWidget(3, 1, closeButton);
110: closeButton.addClickListener(new ClickListener() {
111: public void onClick(final Widget sender) {
112: close();
113: }
114: });
115: flexTable.getCellFormatter().setHorizontalAlignment(3, 1,
116: HasHorizontalAlignment.ALIGN_RIGHT);
117: closeButton.setText(((ConsoleMessages) GWT
118: .create(ConsoleMessages.class)).close());
119: this .setPopupPosition(200, 140);
120:
121: show();
122: this .center();
123: }
124:
125: public abstract void startEndpoint();
126:
127: public abstract void stopEndpoint();
128:
129: public abstract void cycleEndpoint();
130:
131: public void close() {
132: hide();
133: parent.operDialog = null;
134: }
135:
136: }
|