001: /**
002: *
003: */package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards;
004:
005: import org.eclipse.jface.wizard.IWizardPage;
006: import org.eclipse.swt.SWT;
007: import org.eclipse.swt.events.ModifyEvent;
008: import org.eclipse.swt.events.ModifyListener;
009: import org.eclipse.swt.events.SelectionAdapter;
010: import org.eclipse.swt.events.SelectionEvent;
011: import org.eclipse.swt.layout.GridData;
012: import org.eclipse.swt.layout.GridLayout;
013: import org.eclipse.swt.widgets.Button;
014: import org.eclipse.swt.widgets.Combo;
015: import org.eclipse.swt.widgets.Composite;
016: import org.eclipse.swt.widgets.Group;
017: import org.eclipse.swt.widgets.Label;
018: import org.eclipse.swt.widgets.Text;
019:
020: import com.bostechcorp.cbesb.common.i18n.I18N;
021: import com.bostechcorp.cbesb.common.i18n.Messages;
022: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.JMS;
023:
024: /**
025: * @author LPS
026: *
027: */
028: public class JMSPropertyWizardPageConsumerProperty2 extends
029: PropertyWizardPage {
030:
031: //private Text expression_text;
032: //private Button jmsSelectorButton;
033: private static final String[] NO_YES = new String[] { "No", "Yes" };
034: private Text text_1;
035: private Text text;
036: private Combo retry_combo;
037: private Combo transactional_combo;
038: private Label dlqLabel;
039: private Text dlq;
040:
041: protected JMSPropertyWizardPageConsumerProperty2(String pageName) {
042: super (pageName);
043: setTitle(I18N.getString(Messages.JMS_CONSUMER_TITLE));// "Choose
044: setDescription(I18N.getString(Messages.WIZARD_ENTER_TIP));
045: }
046:
047: /* (non-Javadoc)
048: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.PropertyWizardPage#controlToModels()
049: */
050: @Override
051: public void controlToModels() {
052: JMSPropertyWizard JMSWizard = (JMSPropertyWizard) this
053: .getWizard();
054:
055: JMS models = JMSWizard.getModels();
056: if (models == null)
057: return;
058: try {
059: boolean tansaction = false;
060: boolean retry = false;
061:
062: if (transactional_combo.getText().equals(NO_YES[1])) {
063: tansaction = true;
064: }
065: if (retry_combo.getText().equals(NO_YES[1])) {
066: retry = true;
067: }
068:
069: models.getJmsConsumer().setTransaction(tansaction);
070: models.getJmsConsumer().setRetry(retry);
071:
072: models.getJmsConsumer().setRetryInterval(
073: Integer.parseInt(text.getText()));
074: models.getJmsConsumer().setMaxRetryCount(
075: Integer.parseInt(text_1.getText()));
076: models.getJmsConsumer().setDLQ(dlq.getText());
077: //models.getJmsConsumer().setQueryExpression(expression_text.getText());
078: //models.getJmsConsumer().setEnableQuery(getJmsSelectorButton().getSelection());
079: } catch (Exception e) {
080: e.printStackTrace();
081: }
082: }
083:
084: public boolean isUseDefault() {
085:
086: return ((JMSReliableDelMain) this .getWizard().getPage(
087: "ReliableMain")).getUseDefaultButton().getSelection();
088: }
089:
090: /* (non-Javadoc)
091: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.PropertyWizardPage#modelsToControl()
092: */
093: @Override
094: public void modelsToControl() {
095: JMSPropertyWizard JMSWizard = (JMSPropertyWizard) this
096: .getWizard();
097: if (!JMSWizard.isUpdateOperation())
098: return;
099: try {
100: JMS models = JMSWizard.getModels();
101: if (models.getJmsConsumer().isTransaction()) {
102: transactional_combo.setText(NO_YES[1]);
103: if (models.getJmsConsumer().isRetry()) {
104: retry_combo.setText(NO_YES[1]);
105: text.setText(""
106: + models.getJmsConsumer()
107: .getRetryInterval());
108: text_1.setText(""
109: + models.getJmsConsumer()
110: .getMaxRetryCount());
111: }
112: }
113: dlq.setText(models.getJmsConsumer().getDLQ());
114: } catch (Exception e) {
115: e.printStackTrace();
116: }
117: }
118:
119: /* (non-Javadoc)
120: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
121: */
122: public void createControl(Composite parent) {
123: Composite topLevel = new Composite(parent, SWT.NONE);
124: topLevel.setLayout(new GridLayout());
125: topLevel.setLayoutData(new GridData(
126: GridData.VERTICAL_ALIGN_FILL
127: | GridData.HORIZONTAL_ALIGN_FILL));
128: topLevel.setFont(parent.getFont());
129: this .setControl(topLevel);
130:
131: final Group transactionPropertyesGroup = new Group(topLevel,
132: SWT.NONE);
133: transactionPropertyesGroup.setText("Transaction Propertyes");
134: transactionPropertyesGroup.setLayoutData(new GridData(SWT.FILL,
135: SWT.CENTER, true, false));
136: final GridLayout gridLayout = new GridLayout();
137: gridLayout.numColumns = 2;
138: transactionPropertyesGroup.setLayout(gridLayout);
139:
140: final Label transactionalLabel = new Label(
141: transactionPropertyesGroup, SWT.NONE);
142: transactionalLabel.setText("Transactional");
143:
144: transactional_combo = new Combo(transactionPropertyesGroup,
145: SWT.READ_ONLY);
146: transactional_combo.setItems(NO_YES);
147: transactional_combo.setText(NO_YES[1]);
148: transactional_combo
149: .addSelectionListener(new SelectionAdapter() {
150: public void widgetSelected(final SelectionEvent e) {
151: enableControls();
152: }
153: });
154: transactional_combo.setLayoutData(new GridData(SWT.FILL,
155: SWT.CENTER, true, false));
156:
157: final Label retryLabel = new Label(transactionPropertyesGroup,
158: SWT.NONE);
159: retryLabel.setText("Retry");
160:
161: retry_combo = new Combo(transactionPropertyesGroup,
162: SWT.READ_ONLY);
163: retry_combo.setItems(NO_YES);
164: retry_combo.setText(NO_YES[1]);
165: retry_combo.addSelectionListener(new SelectionAdapter() {
166: public void widgetSelected(final SelectionEvent e) {
167: enableControls();
168: }
169: });
170: retry_combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
171: true, false));
172:
173: final Label retryIntervalLabel = new Label(
174: transactionPropertyesGroup, SWT.NONE);
175: retryIntervalLabel.setText("Retry Interval");
176:
177: text = new Text(transactionPropertyesGroup, SWT.BORDER);
178: text.setText("60");
179: text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
180: false));
181:
182: final Label maximumRetryCountsLabel = new Label(
183: transactionPropertyesGroup, SWT.NONE);
184: maximumRetryCountsLabel.setText("Retry Count");
185:
186: text_1 = new Text(transactionPropertyesGroup, SWT.BORDER);
187: text_1.setText("60000");
188: text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
189: false));
190:
191: ModifyListener modifyListener = new ModifyListener() {
192: public void modifyText(ModifyEvent e) {
193: dialogChanged();
194: }
195: };
196: text.addModifyListener(modifyListener);
197: text_1.addModifyListener(modifyListener);
198:
199: dlqLabel = new Label(transactionPropertyesGroup, SWT.NONE);
200: dlqLabel.setText(I18N.getString(Messages.DLQ));
201:
202: dlq = new Text(transactionPropertyesGroup, SWT.BORDER);
203: dlq.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
204: false));
205: /*jmsSelectorButton = new Button(transactionPropertyesGroup, SWT.CHECK);
206: jmsSelectorButton.addSelectionListener(new SelectionAdapter() {
207: public void widgetSelected(final SelectionEvent e) {
208: expression_text.setEditable(getJmsSelectorButton().getSelection());
209: }
210: });
211: jmsSelectorButton.setText("JMS Expression");
212:
213: expression_text = new Text(transactionPropertyesGroup, SWT.BORDER);
214: expression_text.setEditable(false);
215: expression_text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));*/
216: new Label(transactionPropertyesGroup, SWT.NONE);
217:
218: if (this .getWizard().isUpdateOperation()) {
219: modelsToControl();
220: } else {
221: if (((JMSPropertyWizardPageMain) super .getWizard()
222: .getMainPage()).isReliableDelivery()) {
223: defaultSettingForReliableDel();
224: }
225: }
226: dialogChanged();
227: enableControls();
228: }
229:
230: public void defaultSettingForReliableDel() {
231: transactional_combo.select(1);
232: retry_combo.select(1);
233: text.setText("60");
234: text_1.setText("60000");
235:
236: String projectName = this .getWizard().getMainPage()
237: .getProjectName();
238: String modelName = this .getWizard().getMainPage().getTextName()
239: .getText();
240: dlq.setText("dynamicQueues/" + projectName + "_" + modelName
241: + "_dlq");
242:
243: enableControls();
244: }
245:
246: public void defaultSettingForNonReliableDel() {
247:
248: transactional_combo.select(1);
249: retry_combo.select(1);
250: text.setText("60");
251: text_1.setText("60000");
252: dlq.setText("");
253: enableControls();
254: }
255:
256: protected void enableControls() {
257: if (transactional_combo.getText().equals(NO_YES[1])) {
258: retry_combo.setEnabled(true);
259: if (retry_combo.getText().equals(NO_YES[1])) {
260: text.setEnabled(true);
261: text_1.setEnabled(true);
262:
263: } else {
264: text.setEnabled(false);
265: text_1.setEnabled(false);
266:
267: }
268: } else {
269: retry_combo.setEnabled(false);
270: text.setEnabled(false);
271: text_1.setEnabled(false);
272:
273: }
274: }
275:
276: private void dialogChanged() {
277: if (text.getText().equals("")) {
278: updateStatus("Retry Interval is not specifyed");
279: setPageComplete(false);
280: return;
281: } else if (text_1.getText().equals("")) {
282: updateStatus("Maximum retry count is not specifyed");
283: setPageComplete(false);
284: return;
285: }
286:
287: try {
288: Integer.parseInt(text.getText());
289: } catch (NumberFormatException e) {
290: updateStatus("Retry Intyerval is not a number");
291: setPageComplete(false);
292: return;
293: }
294:
295: try {
296: Integer.parseInt(text_1.getText());
297: } catch (NumberFormatException e) {
298: updateStatus("Maximum repry count is not a number");
299: setPageComplete(false);
300: return;
301: }
302:
303: setPageComplete(true);
304: updateStatus(null);
305: }
306:
307: private void updateStatus(String message) {
308: setErrorMessage(message);
309: }
310:
311: @Override
312: public IWizardPage getNextPage() {
313: if (this .getWizard().getMainPage().isProvider()) {
314:
315: return getWizard().getPage("ProviderProperty");
316: }
317: if (this .getWizard().getMainPage().isUseCCSL()) {
318:
319: return super .getWizard().getCcslConsumerPage();
320: }
321: return super .getNextPage();
322: }
323: /*protected Button getJmsSelectorButton() {
324: return jmsSelectorButton;
325: }*/
326: }
|