001: package com.bostechcorp.cbesb.console.client.dialogs;
002:
003: import java.util.Vector;
004:
005: import com.bostechcorp.cbesb.console.client.ICallbackHandler;
006: import com.bostechcorp.cbesb.console.client.endpoint.EndpointBase;
007: import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
008: import com.google.gwt.core.client.GWT;
009: import com.google.gwt.user.client.ui.Button;
010: import com.google.gwt.user.client.ui.FlowPanel;
011: import com.google.gwt.user.client.ui.HTML;
012: import com.google.gwt.user.client.ui.HorizontalPanel;
013: import com.google.gwt.user.client.ui.TextBox;
014: import com.google.gwt.user.client.ui.Widget;
015:
016: public class SettingDialog extends SettingDialogReadOnly implements
017: ICallbackHandler {
018:
019: // = new WaitingDialog();
020:
021: public SettingDialog(EndpointBase parentAdmin, String saName,
022: String suName, String type, String componentName,
023: String endpointName, String[][] properties) {
024: super (parentAdmin, saName, suName, type, componentName,
025: endpointName, properties);
026:
027: }
028:
029: protected void AddButton(FlowPanel flowPanel) {
030: resetButton = new Button();
031: resetButton.setText(((ConsoleMessages) GWT
032: .create(ConsoleMessages.class)).Reset());
033: resetButton.setWidth("80px");
034: resetButton.addClickListener(this );
035: flowPanel.add(resetButton);
036: saveButton = new Button();
037: saveButton.setText(((ConsoleMessages) GWT
038: .create(ConsoleMessages.class)).Save());
039: saveButton.addClickListener(this );
040: flowPanel.add(saveButton);
041: saveButton.setWidth("80px");
042:
043: super .AddButton(flowPanel);
044:
045: }
046:
047: public void onClick(Widget sender) {
048: Button button = (Button) sender;
049: if (button.getText().equals(
050: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
051: .Save())
052: && propertiesMap.size() > 0) {
053: //String[][] newProperties = new String[40][2];
054: Vector propertyList = new Vector();
055: int j = 0;
056: for (int i = 1; i < orderTable.getRowCount() - 1; i++) {
057: Widget widget = orderTable.getWidget(i, 0);
058: if (widget != null && widget instanceof HorizontalPanel) {
059: // newProperties[j][0] = ((HTML) ((HorizontalPanel) widget)
060: // .getWidget(0)).getTitle();
061: // newProperties[j][1] = ((TextBox) ((HorizontalPanel) widget)
062: // .getWidget(1)).getText();
063: String[] object = new String[2];
064: object[0] = ((HTML) ((HorizontalPanel) widget)
065: .getWidget(0)).getTitle();
066: object[1] = ((TextBox) ((HorizontalPanel) widget)
067: .getWidget(1)).getText();
068: propertyList.add(object);
069: // j++;
070: if (orderTable.getCellCount(i) < 2) {
071: continue;
072: } else {
073: widget = orderTable.getWidget(i, 1);
074: if (widget != null
075: && widget instanceof HorizontalPanel) {
076: // newProperties[j][0] = ((HTML) ((HorizontalPanel) widget)
077: // .getWidget(0)).getTitle();
078: // newProperties[j][1] = ((TextBox) ((HorizontalPanel) widget)
079: // .getWidget(1)).getText();
080: // j++;
081: String[] object2 = new String[2];
082: object2[0] = ((HTML) ((HorizontalPanel) widget)
083: .getWidget(0)).getTitle();
084: object2[1] = ((TextBox) ((HorizontalPanel) widget)
085: .getWidget(1)).getText();
086: propertyList.add(object2);
087:
088: }
089: }
090: if (orderTable.getCellCount(i) < 3) {
091: continue;
092: } else {
093: widget = orderTable.getWidget(i, 2);
094: if (widget != null
095: && widget instanceof HorizontalPanel) {
096: // newProperties[j][0] = ((HTML) ((HorizontalPanel) widget)
097: // .getWidget(0)).getTitle();
098: // newProperties[j][1] = ((TextBox) ((HorizontalPanel) widget)
099: // .getWidget(1)).getText();
100: // j++;
101: String[] object3 = new String[2];
102: object3[0] = ((HTML) ((HorizontalPanel) widget)
103: .getWidget(0)).getTitle();
104: object3[1] = ((TextBox) ((HorizontalPanel) widget)
105: .getWidget(1)).getText();
106: propertyList.add(object3);
107:
108: }
109: }
110: }
111: }
112: Object[] properties = propertyList.toArray(new Object[] {});
113: String[][] newProperties = new String[properties.length][2];
114: for (int i = 0; i < properties.length; i++) {
115: newProperties[i] = (String[]) properties[i];
116: }
117:
118: parentAdmin.setPropertyObjects(saName, suName,
119: componentName, endpointName, type, newProperties);
120:
121: } else if (button.getText().equals(
122: ((ConsoleMessages) GWT.create(ConsoleMessages.class))
123: .Reset())) {
124:
125: parentAdmin.deletePropertyObjects(saName, suName,
126: endpointName, type);
127: }
128:
129: hideDialog();
130:
131: }
132:
133: }
|