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.ui.componentflow.componentFlowEditor.diagram.wizards;
025:
026: import org.eclipse.jface.wizard.IWizardPage;
027: import org.eclipse.swt.SWT;
028: import org.eclipse.swt.events.ModifyEvent;
029: import org.eclipse.swt.events.ModifyListener;
030: import org.eclipse.swt.layout.FormAttachment;
031: import org.eclipse.swt.layout.FormData;
032: import org.eclipse.swt.layout.FormLayout;
033: import org.eclipse.swt.layout.GridData;
034: import org.eclipse.swt.layout.GridLayout;
035: import org.eclipse.swt.widgets.Combo;
036: import org.eclipse.swt.widgets.Composite;
037: import org.eclipse.swt.widgets.Label;
038: import org.eclipse.swt.widgets.Text;
039:
040: import com.bostechcorp.cbesb.common.i18n.I18N;
041: import com.bostechcorp.cbesb.common.i18n.Messages;
042: import com.bostechcorp.cbesb.common.util.SystemCharacterEncoding;
043: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.DefaultMepType;
044: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.DestinationStyleType;
045: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.JMS;
046: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ReadStyleType;
047: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.RecordTypeType;
048:
049: public class JMSPropertyWizardPageConsumerProperty extends
050: PropertyWizardPage {
051:
052: private Combo comboWriteStyle;
053:
054: private Text textReplyDestinationName;
055:
056: private Combo comboReadCharset;
057:
058: private Text textRecordsPerMessage;
059:
060: private Combo comboRecordType;
061:
062: private Combo comboReadStyle;
063:
064: private Text textTargetName;
065:
066: private Combo comboDestinationStyle;
067:
068: private Text textJNDIFactoryName;
069:
070: private Text textJNDIUrl;
071:
072: private Text textJNDIFactory;
073:
074: private Combo comboDefaultMep;
075:
076: private Label writeStyleLabel;
077:
078: private Label replyDestinationNameLabel;
079:
080: protected JMSPropertyWizardPageConsumerProperty(String pageName) {
081: super (pageName);
082: setTitle(I18N.getString(Messages.JMS_CONSUMER_TITLE));// "Choose
083: setDescription(I18N.getString(Messages.WIZARD_ENTER_TIP));
084: }
085:
086: public void createControl(Composite parent) {
087:
088: Composite topLevel = new Composite(parent, SWT.NONE);
089: topLevel.setLayout(new FormLayout());
090: topLevel.setLayoutData(new GridData(
091: GridData.VERTICAL_ALIGN_FILL
092: | GridData.HORIZONTAL_ALIGN_FILL));
093: topLevel.setFont(parent.getFont());
094: this .setControl(topLevel);
095:
096: final Composite composite = new Composite(topLevel, SWT.NONE);
097: final GridLayout gridLayout = new GridLayout();
098: gridLayout.numColumns = 2;
099: composite.setLayout(gridLayout);
100: final FormData formData = new FormData();
101: formData.right = new FormAttachment(99, 0);
102: formData.bottom = new FormAttachment(100, -5);
103: formData.top = new FormAttachment(0, 5);
104: formData.left = new FormAttachment(0, 5);
105: composite.setLayoutData(formData);
106:
107: final Label defaultmepLabel = new Label(composite, SWT.NONE);
108: defaultmepLabel.setText(I18N.getString(Messages.WIZARD_MEP));
109:
110: comboDefaultMep = new Combo(composite, SWT.READ_ONLY);
111: comboDefaultMep.setItems(new String[] { "in-only", "in-out",
112: "reliablein" });
113: if (!this .getWizard().isUpdateOperation())
114: comboDefaultMep.setText("in-only");
115:
116: comboDefaultMep.setLayoutData(new GridData(SWT.FILL,
117: SWT.CENTER, true, false));
118:
119: comboDefaultMep.addModifyListener(new ModifyListener() {
120:
121: public void modifyText(ModifyEvent e) {
122: if (comboDefaultMep.getText().equals("in-out")) {
123: textReplyDestinationName.setVisible(true);
124: comboWriteStyle.setVisible(true);
125: writeStyleLabel.setVisible(true);
126: replyDestinationNameLabel.setVisible(true);
127: } else {
128: textReplyDestinationName.setVisible(false);
129: // comboWriteCharset.setVisible(false);
130: comboWriteStyle.setVisible(false);
131: // characterSetLabel.setVisible(false);
132: writeStyleLabel.setVisible(false);
133: replyDestinationNameLabel.setVisible(false);
134:
135: }
136: }
137:
138: });
139:
140: final Label jndiInitialContextLabel = new Label(composite,
141: SWT.NONE);
142: jndiInitialContextLabel.setText(I18N
143: .getString(Messages.JMS_JNDI_FACTORY));
144:
145: textJNDIFactory = new Text(composite, SWT.BORDER);
146: if (!this .getWizard().isUpdateOperation())
147: textJNDIFactory
148: .setText("com.sun.jndi.fscontext.RefFSContextFactory");
149: textJNDIFactory.setLayoutData(new GridData(SWT.FILL,
150: SWT.CENTER, true, false));
151:
152: final Label jndiProviderUrlLabel = new Label(composite,
153: SWT.NONE);
154: jndiProviderUrlLabel.setText(I18N
155: .getString(Messages.JMS_JNDI_URL));
156:
157: textJNDIUrl = new Text(composite, SWT.BORDER);
158: if (!this .getWizard().isUpdateOperation())
159: textJNDIUrl.setText("file:/C:/CBESB/JndiDir");
160: textJNDIUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
161: true, false));
162:
163: final Label jndiConnectionFactoryLabel = new Label(composite,
164: SWT.NONE);
165: jndiConnectionFactoryLabel.setText(I18N
166: .getString(Messages.JMS_JNDI_FACTORY_NAME));
167:
168: textJNDIFactoryName = new Text(composite, SWT.BORDER);
169: textJNDIFactoryName.addModifyListener(new ModifyListener() {
170: public void modifyText(ModifyEvent e) {
171: dialogChanged();
172: }
173: });
174: textJNDIFactoryName.setLayoutData(new GridData(SWT.FILL,
175: SWT.CENTER, true, false));
176:
177: final Label oDestinationStyleLabel = new Label(composite,
178: SWT.NONE);
179: oDestinationStyleLabel.setText(I18N
180: .getString(Messages.JMS_DESTINATION_STYLE));
181:
182: comboDestinationStyle = new Combo(composite, SWT.READ_ONLY);
183: comboDestinationStyle
184: .setItems(new String[] { "queue", "topic" });
185: comboDestinationStyle.setLayoutData(new GridData(SWT.FILL,
186: SWT.CENTER, true, false));
187: if (!this .getWizard().isUpdateOperation())
188: comboDestinationStyle.setText("queue");
189: final Label oTargetDestinationLabel = new Label(composite,
190: SWT.NONE);
191: oTargetDestinationLabel.setText(I18N
192: .getString(Messages.JMS_TARGET_DESTINATION_NAME));
193:
194: textTargetName = new Text(composite, SWT.BORDER);
195: textTargetName.addModifyListener(new ModifyListener() {
196: public void modifyText(ModifyEvent e) {
197: dialogChanged();
198: }
199: });
200: textTargetName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
201: true, false));
202:
203: final Label readStyleLabel = new Label(composite, SWT.NONE);
204: readStyleLabel.setText(I18N.getString(Messages.READ_STYLE));
205:
206: comboReadStyle = new Combo(composite, SWT.READ_ONLY);
207: comboReadStyle.setItems(new String[] { "raw", "newline" });
208: if (!this .getWizard().isUpdateOperation())
209: comboReadStyle.setText("raw");
210: comboReadStyle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
211: true, false));
212:
213: final Label recordTypeLabel = new Label(composite, SWT.NONE);
214: recordTypeLabel.setText(I18N.getString(Messages.REC_TYPE));
215:
216: comboRecordType = new Combo(composite, SWT.READ_ONLY);
217: comboRecordType.setItems(new String[] { "string", "xml",
218: "binary" });
219: if (!this .getWizard().isUpdateOperation())
220: comboRecordType.setText("string");
221: comboRecordType.setLayoutData(new GridData(SWT.FILL,
222: SWT.CENTER, true, false));
223:
224: final Label recordsPerMessageLabel = new Label(composite,
225: SWT.NONE);
226: recordsPerMessageLabel.setText(I18N
227: .getString(Messages.REC_PER_MES));
228:
229: textRecordsPerMessage = new Text(composite, SWT.BORDER);
230: textRecordsPerMessage.setLayoutData(new GridData(SWT.FILL,
231: SWT.CENTER, true, false));
232: textRecordsPerMessage.addModifyListener(new ModifyListener() {
233: public void modifyText(ModifyEvent e) {
234: dialogChanged();
235: }
236: });
237:
238: textRecordsPerMessage.setText("0");
239:
240: final Label oCharacterSetLabel = new Label(composite, SWT.NONE);
241: oCharacterSetLabel.setText(I18N.getString(Messages.CHAR_SET));
242:
243: comboReadCharset = new Combo(composite, SWT.DROP_DOWN);
244: comboReadCharset.setItems(SystemCharacterEncoding
245: .getSupportedCharacterSets());
246:
247: comboReadCharset.setText("SYSTEM_DEFAULT");
248: comboReadCharset.setLayoutData(new GridData(SWT.FILL,
249: SWT.CENTER, true, false));
250:
251: replyDestinationNameLabel = new Label(composite, SWT.NONE);
252: replyDestinationNameLabel.setVisible(false);
253: replyDestinationNameLabel.setText(I18N
254: .getString(Messages.JMS_REPLY_DESTINATION_NAME));
255:
256: textReplyDestinationName = new Text(composite, SWT.BORDER);
257: textReplyDestinationName.setVisible(false);
258: textReplyDestinationName.setLayoutData(new GridData(SWT.FILL,
259: SWT.CENTER, true, false));
260:
261: writeStyleLabel = new Label(composite, SWT.NONE);
262: writeStyleLabel.setVisible(false);
263: writeStyleLabel.setText(I18N.getString(Messages.WRI_STYLE));
264:
265: comboWriteStyle = new Combo(composite, SWT.READ_ONLY);
266: comboWriteStyle.setItems(new String[] { "raw", "newline" });
267: comboWriteStyle.setVisible(false);
268: comboWriteStyle.setText("raw");
269: comboWriteStyle.setLayoutData(new GridData(SWT.FILL,
270: SWT.CENTER, true, false));
271:
272: if (this .getWizard().isUpdateOperation()) {
273: modelsToControl();
274: } else {
275: if (((JMSPropertyWizardPageMain) super .getWizard()
276: .getMainPage()).isReliableDelivery()) {
277: defaultSettingForReliableDel();
278: }
279: }
280: dialogChanged();
281: }
282:
283: public void defaultSettingForReliableDel() {
284: comboDefaultMep.select(2);
285: textJNDIFactory
286: .setText("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
287: textJNDIUrl.setText("tcp://localhost:61616");
288: textJNDIFactoryName.setText("ConnectionFactory");
289: comboDestinationStyle.select(0);
290: String projectName = this .getWizard().getMainPage()
291: .getProjectName();
292: String modelName = this .getWizard().getMainPage().getTextName()
293: .getText();
294: textTargetName.setText("dynamicQueues/" + projectName + "_"
295: + modelName + "_request");
296: comboReadStyle.select(0);
297: comboRecordType.select(0);
298: textRecordsPerMessage.setText("0");
299: comboReadCharset.setText("SYSTEM_DEFAULT");
300:
301: }
302:
303: public void defaultSettingForNonReliableDel() {
304: comboDefaultMep.select(0);
305: textJNDIFactory
306: .setText("com.sun.jndi.fscontext.RefFSContextFactory");
307: textJNDIUrl.setText("file:/C:/CBESB/JndiDir");
308: textJNDIFactoryName.setText("");
309: comboDestinationStyle.select(0);
310: textTargetName.setText("");
311: comboReadStyle.select(0);
312: comboRecordType.select(0);
313: textRecordsPerMessage.setText("0");
314: comboReadCharset.setText("SYSTEM_DEFAULT");
315: }
316:
317: private void dialogChanged() {
318: if (WizardUtil.whetherUseValidation == false) {
319: setPageComplete(true);
320: return;
321: }
322: if (textJNDIFactoryName.getText().equals("")) {
323: updateStatus(I18N
324: .getString(Messages.JMS_JNDI_FACTORY_NAME_REQUIRE));
325: setPageComplete(false);
326: return;
327: } else if (textTargetName.getText().equals("")) {
328: updateStatus(I18N
329: .getString(Messages.JMS_JNDI_TARGET_DESTINATION_NAME_REQUIRE));
330: setPageComplete(false);
331: return;
332: } else {
333: String recordPerMsg = textRecordsPerMessage.getText();
334: if (!WizardUtil.isNumber(recordPerMsg)) {
335: updateStatus(I18N
336: .getString(Messages.JMS_RECORDS_PER_MESSAGE_INTEGER));
337: setPageComplete(false);
338: return;
339: }
340: }
341:
342: setPageComplete(true);
343: updateStatus(null);
344: }
345:
346: private void updateStatus(String message) {
347: setErrorMessage(message);
348: // this.getWizard().canFinish();
349: }
350:
351: @Override
352: public void controlToModels() {
353:
354: JMSPropertyWizard JMSWizard = (JMSPropertyWizard) this
355: .getWizard();
356:
357: JMS models = JMSWizard.getModels();
358: if (models == null)
359: return;
360: try {
361: models.getJmsConsumer().setDefaultMep(
362: DefaultMepType.get(comboDefaultMep.getText()));
363: models.getJmsConsumer()
364: .setDestinationStyle(
365: DestinationStyleType
366: .getByName(comboDestinationStyle
367: .getText()));
368: models.getJmsConsumer().setCharset(
369: comboReadCharset.getText());
370: models.getJmsConsumer().setJndiConnectionFactoryName(
371: textJNDIFactoryName.getText());
372: models.getJmsConsumer().setJndiInitialContextFactory(
373: textJNDIFactory.getText());
374: models.getJmsConsumer().setJndiProviderUrl(
375: textJNDIUrl.getText());
376: models.getJmsConsumer().setReadStyle(
377: ReadStyleType.get(comboReadStyle.getText()));
378: models.getJmsConsumer().setRecordsPerMessage(
379: textRecordsPerMessage.getText());
380: models.getJmsConsumer().setRecordType(
381: RecordTypeType.get(comboRecordType.getText()));
382: models.getJmsConsumer().setReplyDestinationName(
383: textReplyDestinationName.getText());
384: models.getJmsConsumer().setTargetDestinationName(
385: textTargetName.getText());
386: models.getJmsConsumer().setWriteStyle(
387: ReadStyleType.get(comboWriteStyle.getText()));
388:
389: /*models.getJmsConsumer().setTransaction(true);
390: models.getJmsConsumer().setRetry(true);
391: models.getJmsConsumer().setMaxRetryCount(Integer.parseInt(maxRetryCount.getText()));
392: models.getJmsConsumer().setRetryInterval(Integer.parseInt(retryInterval.getText()));
393: models.getJmsConsumer().setDLQ(dlq.getText());
394: models.getJmsConsumer().setEnableQuery(true);
395: models.getJmsConsumer().setQueryExpression(queryExpression.getText());*/
396:
397: } catch (Exception e) {
398: e.printStackTrace();
399: }
400: ;
401:
402: }
403:
404: public IWizardPage getNextPage() {
405: if (((JMSPropertyWizardPageMain) super .getWizard()
406: .getMainPage()).isReliableDelivery()) {
407: return super .getWizard().getPage("ConsumerProperty2");
408: }
409: if (this .getWizard().getMainPage().isProvider()) {
410:
411: return getWizard().getPage("ProviderProperty");
412: }
413: if (this .getWizard().getMainPage().isUseCCSL()) {
414:
415: return super .getWizard().getCcslConsumerPage();
416: }
417: return super .getNextPage();
418: }
419:
420: @Override
421: public void modelsToControl() {
422:
423: JMSPropertyWizard JMSWizard = (JMSPropertyWizard) this
424: .getWizard();
425: if (!JMSWizard.isUpdateOperation())
426: return;
427: try {
428: JMS models = JMSWizard.getModels();
429: String mepType = models.getJmsConsumer().getDefaultMep()
430: .getLiteral();
431: comboDefaultMep.select(comboDefaultMep.indexOf(mepType));
432:
433: comboDestinationStyle.select(comboDestinationStyle
434: .indexOf(models.getJmsConsumer()
435: .getDestinationStyle().getLiteral()));
436: comboReadCharset.select(comboReadCharset.indexOf(models
437: .getJmsConsumer().getCharset()));
438: comboRecordType.select(comboRecordType.indexOf(models
439: .getJmsConsumer().getRecordType().getLiteral()));
440: comboReadStyle.select(comboReadStyle.indexOf(models
441: .getJmsConsumer().getReadStyle().getLiteral()));
442: comboWriteStyle.select(comboWriteStyle.indexOf(models
443: .getJmsConsumer().getWriteStyle().getLiteral()));
444: if (models.getJmsConsumer().getJndiConnectionFactoryName() != null)
445: textJNDIFactoryName.setText(models.getJmsConsumer()
446: .getJndiConnectionFactoryName());
447: else
448: textJNDIFactoryName.setText("");
449:
450: if (models.getJmsConsumer().getJndiInitialContextFactory() != null)
451: textJNDIFactory.setText(models.getJmsConsumer()
452: .getJndiInitialContextFactory());
453: else
454: textJNDIFactory.setText("");
455:
456: if (models.getJmsConsumer().getJndiProviderUrl() != null)
457: textJNDIUrl.setText(models.getJmsConsumer()
458: .getJndiProviderUrl());
459: else
460: textJNDIUrl.setText("");
461:
462: if (models.getJmsConsumer().getRecordsPerMessage() != null)
463: textRecordsPerMessage.setText(models.getJmsConsumer()
464: .getRecordsPerMessage());
465: else
466: textRecordsPerMessage.setText("");
467:
468: if (models.getJmsConsumer().getTargetDestinationName() != null)
469: textTargetName.setText(models.getJmsConsumer()
470: .getTargetDestinationName());
471: else
472: textTargetName.setText("");
473:
474: if (mepType.equalsIgnoreCase("in-out")) {
475: replyDestinationNameLabel.setVisible(true);
476: textReplyDestinationName.setVisible(true);
477: writeStyleLabel.setVisible(true);
478: comboWriteStyle.setVisible(true);
479: comboWriteStyle
480: .select(comboWriteStyle.indexOf(models
481: .getJmsConsumer().getWriteStyle()
482: .getLiteral()));
483:
484: if (models.getJmsConsumer().getReplyDestinationName() != null)
485: textReplyDestinationName
486: .setText(models.getJmsConsumer()
487: .getReplyDestinationName());
488: else
489: textReplyDestinationName.setText("");
490: }
491:
492: } catch (Exception e) {
493: e.printStackTrace();
494: }
495: ;
496:
497: }
498: }
|