001: package com.bostechcorp.cbesb.ui.ide.customcomponent.wizard;
002:
003: import java.util.HashMap;
004:
005: import org.eclipse.swt.SWT;
006: import org.eclipse.swt.events.SelectionAdapter;
007: import org.eclipse.swt.events.SelectionEvent;
008: import org.eclipse.swt.layout.GridData;
009: import org.eclipse.swt.layout.GridLayout;
010: import org.eclipse.swt.widgets.Button;
011: import org.eclipse.swt.widgets.Combo;
012: import org.eclipse.swt.widgets.Composite;
013: import org.eclipse.swt.widgets.Group;
014: import org.eclipse.swt.widgets.Label;
015: import org.eclipse.swt.widgets.Text;
016:
017: import com.bostechcorp.cbesb.common.i18n.I18N;
018: import com.bostechcorp.cbesb.common.i18n.Messages;
019:
020: public class ComponentPropertiesComposite extends Composite {
021:
022: private Button scheduledButton;
023: private Text text;
024: private Combo combo_3;
025: public static final String PROVIDER = "PROVIDER";
026: public static final String CONSUMER = "CONSUMER";
027: public static final String BOTH = "BOTH";
028:
029: public static final String INOUT = "IN_OUT";
030: public static final String IN = "IN_ONLY";
031: public static final String RELIABLEIN = "RELIABLE_IN";
032:
033: public static final String NAME = "name";
034: public static final String DESCRIPTION = "description";
035: public static final String COMPONENT_NAME = "component_name";
036: public static final String COMPONENT_NAME_AUX_PART1 = "component_name_AUX_PART1";
037: public static final String COMPONENT_NAME_AUX_PART2 = "component_name_AUX_PART2";
038: public static final String COMPONENT_NAME_AUX_PART3 = "component_name_AUX_PART3";
039: public static final String COMPONENT_DESCRIPTION = "component_description";
040: public static final String URI = "uri";
041: public static final String VENDOR = "vendor";
042: public static final String VERSION = "version";
043: public static final String ROLE = "role";
044: public static final String CONSUMER_MEP = "consumer_mep";
045: public static final String PROVIDER_MEP = "provider_mep";
046: public static final String DEFAULT_DEPLOY = "default_deploy";
047: public static final String DEFAULT_WSDL = "default_wsdl";
048: public static final String USE_CCSL = "use_ccsl";
049: public static final String PATH_XML = "path_xml";
050: public static final String PATH_JAVA = "path_java";
051:
052: public static final String INIT_REQUIRED = "init_required";
053: public static final String BC = "-BC-";
054: public static final String SE = "-SE-";
055: public static final String CONSUMER_IS_SCHEDULED = "is_consumer_scheduled";
056:
057: private Button useCcslButton;
058: private Button useDefautltWsdlButton;
059: private Button useDefaultDeployButton;
060: private Label providersDefaultMepLabel;
061: private Label consumersDefaultMepLabel;
062: private Combo combo_2;
063: private Combo combo_1;
064: private Combo combo;
065: private Text text_7;
066: private Text text_6;
067: private Text text_5;
068: private Text text_3;
069: private Text text_2;
070: private Text text_1;
071:
072: private HashMap<String, String> properties = new HashMap<String, String>();
073:
074: /**
075: * Create the composite
076: * @param parent
077: * @param style
078: */
079: public ComponentPropertiesComposite(Composite parent, int style,
080: HashMap<String, String> prop) {
081: super (parent, style);
082: //
083: this .properties = prop;
084: initProperties(prop);
085: //
086: final GridLayout gridLayout = new GridLayout();
087: setLayout(gridLayout);
088:
089: final Group namingPropertiesGroup = new Group(this , SWT.NONE);
090: namingPropertiesGroup.setLayoutData(new GridData(SWT.FILL,
091: SWT.CENTER, true, false));
092: namingPropertiesGroup
093: .setText(I18N
094: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_GROUP_NAMING));
095: final GridLayout gridLayout_1 = new GridLayout();
096: gridLayout_1.numColumns = 4;
097: namingPropertiesGroup.setLayout(gridLayout_1);
098:
099: final Label nameLabel = new Label(namingPropertiesGroup,
100: SWT.NONE);
101: nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
102: false, false));
103: nameLabel.setText(I18N
104: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_NAME));
105:
106: text_1 = new Text(namingPropertiesGroup, SWT.BORDER);
107: text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
108: false, 3, 1));
109:
110: final Label descriptionLabel = new Label(namingPropertiesGroup,
111: SWT.NONE);
112: descriptionLabel.setLayoutData(new GridData(SWT.FILL,
113: SWT.CENTER, false, false));
114: descriptionLabel
115: .setText(I18N
116: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_DESCRIPTION));
117:
118: text_2 = new Text(namingPropertiesGroup, SWT.BORDER);
119: text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
120: false, 3, 1));
121:
122: final Label componentnameLabel = new Label(
123: namingPropertiesGroup, SWT.NONE);
124: componentnameLabel.setLayoutData(new GridData(SWT.FILL,
125: SWT.CENTER, false, false));
126: componentnameLabel
127: .setText(I18N
128: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_COMPONENT_NAME));
129:
130: text_3 = new Text(namingPropertiesGroup, SWT.BORDER);
131: text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
132: false));
133: text_3.setText("ChainbuilderESB");
134:
135: combo_3 = new Combo(namingPropertiesGroup, SWT.READ_ONLY);
136: final GridData gridData_3 = new GridData(SWT.FILL, SWT.CENTER,
137: false, false);
138: gridData_3.widthHint = 14;
139: combo_3.setLayoutData(gridData_3);
140: combo_3.add(BC);
141: combo_3.add(SE);
142:
143: text = new Text(namingPropertiesGroup, SWT.BORDER);
144: text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
145: false));
146:
147: final Label componentUriLabel = new Label(
148: namingPropertiesGroup, SWT.NONE);
149: componentUriLabel.setLayoutData(new GridData(SWT.FILL,
150: SWT.CENTER, false, false));
151: componentUriLabel.setText(I18N
152: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_URI));
153:
154: text_5 = new Text(namingPropertiesGroup, SWT.BORDER);
155: text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
156: false, 3, 1));
157:
158: final Label vendorLabel = new Label(namingPropertiesGroup,
159: SWT.NONE);
160: vendorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
161: false, false));
162: vendorLabel.setText(I18N
163: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_VENDOR));
164:
165: text_6 = new Text(namingPropertiesGroup, SWT.BORDER);
166: text_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
167: false));
168:
169: final Label versionLabel = new Label(namingPropertiesGroup,
170: SWT.NONE);
171: final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
172: false, false);
173: gridData.widthHint = 52;
174: versionLabel.setLayoutData(gridData);
175: versionLabel
176: .setText(I18N
177: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_VERSION));
178:
179: text_7 = new Text(namingPropertiesGroup, SWT.BORDER);
180: text_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
181: false));
182:
183: final Group functionalPropertiesGroup = new Group(this ,
184: SWT.NONE);
185: functionalPropertiesGroup
186: .setText(I18N
187: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_GROUP_FUNCTIONAL));
188: functionalPropertiesGroup.setLayoutData(new GridData(SWT.FILL,
189: SWT.FILL, false, true));
190: final GridLayout gridLayout_2 = new GridLayout();
191: gridLayout_2.numColumns = 3;
192: functionalPropertiesGroup.setLayout(gridLayout_2);
193:
194: useDefaultDeployButton = new Button(functionalPropertiesGroup,
195: SWT.CHECK);
196: useDefaultDeployButton
197: .addSelectionListener(new SelectionAdapter() {
198: public void widgetSelected(SelectionEvent e) {
199: viewToModel();
200: }
201: });
202: useDefaultDeployButton.setSelection(true);
203: final GridData gridData_6 = new GridData(SWT.FILL, SWT.CENTER,
204: false, false);
205: gridData_6.widthHint = 113;
206: useDefaultDeployButton.setLayoutData(gridData_6);
207: useDefaultDeployButton
208: .setText(I18N
209: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_USE_DEPLOY));
210:
211: useDefautltWsdlButton = new Button(functionalPropertiesGroup,
212: SWT.CHECK);
213: useDefautltWsdlButton
214: .addSelectionListener(new SelectionAdapter() {
215: public void widgetSelected(SelectionEvent e) {
216: viewToModel();
217: }
218: });
219: useDefautltWsdlButton.setSelection(true);
220: final GridData gridData_8 = new GridData(SWT.FILL, SWT.CENTER,
221: false, false);
222: gridData_8.widthHint = 217;
223: useDefautltWsdlButton.setLayoutData(gridData_8);
224: useDefautltWsdlButton
225: .setText(I18N
226: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_USE_WSDL));
227:
228: useCcslButton = new Button(functionalPropertiesGroup, SWT.CHECK);
229: useCcslButton.addSelectionListener(new SelectionAdapter() {
230: public void widgetSelected(SelectionEvent e) {
231: viewToModel();
232: }
233: });
234: useCcslButton.setSelection(true);
235: final GridData gridData_4 = new GridData(SWT.FILL, SWT.CENTER,
236: false, false);
237: gridData_4.widthHint = 99;
238: useCcslButton.setLayoutData(gridData_4);
239: useCcslButton
240: .setText(I18N
241: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_USE_CCSL));
242:
243: final Label label = new Label(functionalPropertiesGroup,
244: SWT.SEPARATOR | SWT.HORIZONTAL);
245: label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
246: false, 3, 1));
247:
248: final Label componentsRoleLabel = new Label(
249: functionalPropertiesGroup, SWT.NONE);
250: final GridData gridData_7 = new GridData(SWT.FILL, SWT.CENTER,
251: false, false);
252: gridData_7.widthHint = 90;
253: componentsRoleLabel.setLayoutData(gridData_7);
254: componentsRoleLabel.setText(I18N
255: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_ROLE));
256:
257: combo = new Combo(functionalPropertiesGroup, SWT.READ_ONLY);
258: combo.addSelectionListener(new SelectionAdapter() {
259: public void widgetSelected(SelectionEvent e) {
260: checkRoleSelection();
261: }
262: });
263: combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
264: false, 2, 1));
265: combo.add(ComponentPropertiesComposite.BOTH);
266: combo.add(ComponentPropertiesComposite.CONSUMER);
267: combo.add(ComponentPropertiesComposite.PROVIDER);
268: combo.setText(ComponentPropertiesComposite.BOTH);
269:
270: consumersDefaultMepLabel = new Label(functionalPropertiesGroup,
271: SWT.NONE);
272: final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER,
273: false, false);
274: gridData_1.widthHint = 118;
275: consumersDefaultMepLabel.setLayoutData(gridData_1);
276: consumersDefaultMepLabel
277: .setText(I18N
278: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_CONSUMER_MEP));
279:
280: combo_1 = new Combo(functionalPropertiesGroup, SWT.READ_ONLY);
281: combo_1.addSelectionListener(new SelectionAdapter() {
282: public void widgetSelected(SelectionEvent e) {
283: viewToModel();
284: }
285: });
286: combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
287: false, 2, 1));
288: combo_1.add(ComponentPropertiesComposite.IN);
289: combo_1.add(ComponentPropertiesComposite.RELIABLEIN);
290: combo_1.add(ComponentPropertiesComposite.INOUT);
291: combo_1.setText(ComponentPropertiesComposite.INOUT);
292:
293: providersDefaultMepLabel = new Label(functionalPropertiesGroup,
294: SWT.NONE);
295: final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER,
296: false, false);
297: gridData_2.widthHint = 118;
298: providersDefaultMepLabel.setLayoutData(gridData_2);
299: providersDefaultMepLabel
300: .setText(I18N
301: .getString(Messages.CBCC_PROPERTIES_PAGE_LABEL_PROVIDER_MEP));
302:
303: combo_2 = new Combo(functionalPropertiesGroup, SWT.READ_ONLY);
304: combo_2.addSelectionListener(new SelectionAdapter() {
305: public void widgetSelected(SelectionEvent e) {
306: viewToModel();
307: }
308: });
309: combo_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
310: false, 2, 1));
311: combo_2.add(ComponentPropertiesComposite.IN);
312: combo_2.add(ComponentPropertiesComposite.RELIABLEIN);
313: combo_2.add(ComponentPropertiesComposite.INOUT);
314: combo_2.setText(ComponentPropertiesComposite.INOUT);
315: new Label(functionalPropertiesGroup, SWT.NONE);
316: new Label(functionalPropertiesGroup, SWT.NONE);
317:
318: scheduledButton = new Button(functionalPropertiesGroup,
319: SWT.CHECK);
320: scheduledButton.setVisible(false);
321: scheduledButton.setSelection(true);
322: scheduledButton.addSelectionListener(new SelectionAdapter() {
323: public void widgetSelected(SelectionEvent e) {
324: viewToModel();
325: }
326: });
327: final GridData gridData_5 = new GridData(SWT.FILL, SWT.CENTER,
328: false, false);
329: gridData_5.widthHint = 69;
330: scheduledButton.setLayoutData(gridData_5);
331: scheduledButton.setText("Scheduled");
332: //
333: setProperties(prop);
334: }
335:
336: protected void checkRoleSelection() {
337: if (getCombo().getText().equals(
338: ComponentPropertiesComposite.CONSUMER)) {
339: getCombo_1().setVisible(true);
340: getCombo_2().setVisible(false);
341: getConsumersDefaultMepLabel().setVisible(true);
342: getProvidersDefaultMepLabel().setVisible(false);
343: //scheduledButton.setVisible(true);
344: } else if (getCombo().getText().equals(
345: ComponentPropertiesComposite.PROVIDER)) {
346: getCombo_1().setVisible(false);
347: getCombo_2().setVisible(true);
348: getConsumersDefaultMepLabel().setVisible(false);
349: getProvidersDefaultMepLabel().setVisible(true);
350: //scheduledButton.setVisible(false);
351: } else if (getCombo().getText().equals(
352: ComponentPropertiesComposite.BOTH)) {
353: getCombo_1().setVisible(true);
354: getCombo_2().setVisible(true);
355: getConsumersDefaultMepLabel().setVisible(true);
356: getProvidersDefaultMepLabel().setVisible(true);
357: //scheduledButton.setVisible(true);
358: }
359: viewToModel();
360: }
361:
362: @Override
363: public void dispose() {
364: super .dispose();
365: }
366:
367: @Override
368: protected void checkSubclass() {
369: // Disable the check that prevents subclassing of SWT components
370: }
371:
372: protected Label getConsumersDefaultMepLabel() {
373: return consumersDefaultMepLabel;
374: }
375:
376: protected Label getProvidersDefaultMepLabel() {
377: return providersDefaultMepLabel;
378: }
379:
380: public void modelToView() {
381: text_1.setText(properties
382: .get(ComponentPropertiesComposite.NAME));
383: text_2.setText(properties
384: .get(ComponentPropertiesComposite.DESCRIPTION));
385:
386: text_3
387: .setText(properties
388: .get(ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART1));
389: combo_3
390: .setText(properties
391: .get(ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART2));
392: text
393: .setText(properties
394: .get(ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART3));
395:
396: text_5
397: .setText(properties
398: .get(ComponentPropertiesComposite.URI));
399: text_6.setText(properties
400: .get(ComponentPropertiesComposite.VENDOR));
401: text_7.setText(properties
402: .get(ComponentPropertiesComposite.VERSION));
403:
404: combo
405: .setText(properties
406: .get(ComponentPropertiesComposite.ROLE));
407: combo_1.setText(properties
408: .get(ComponentPropertiesComposite.CONSUMER_MEP));
409: combo_1.setText(properties
410: .get(ComponentPropertiesComposite.PROVIDER_MEP));
411: //scheduledButton.setSelection( Boolean.valueOf(properties.get(ComponentPropertiesComposite.CONSUMER_IS_SCHEDULED)));
412:
413: getUseCcslButton().setSelection(
414: new Boolean(properties
415: .get(ComponentPropertiesComposite.USE_CCSL))
416: .booleanValue());
417: getUseDefaultDeployButton()
418: .setSelection(
419: new Boolean(
420: properties
421: .get(ComponentPropertiesComposite.DEFAULT_DEPLOY))
422: .booleanValue());
423: getUseDefautltWsdlButton()
424: .setSelection(
425: new Boolean(
426: properties
427: .get(ComponentPropertiesComposite.DEFAULT_WSDL))
428: .booleanValue());
429:
430: }
431:
432: public void viewToModel() {
433: properties.put(ComponentPropertiesComposite.NAME, text_1
434: .getText());
435: properties.put(ComponentPropertiesComposite.DESCRIPTION, text_2
436: .getText());
437: properties.put(ComponentPropertiesComposite.COMPONENT_NAME,
438: text_3.getText() + combo_3.getText() + text.getText());
439: properties.put(
440: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART1,
441: text_3.getText());
442: properties.put(
443: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART2,
444: combo_3.getText());
445: properties.put(
446: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART3,
447: text.getText());
448: properties.put(ComponentPropertiesComposite.URI, text_5
449: .getText());
450: properties.put(ComponentPropertiesComposite.VENDOR, text_6
451: .getText());
452: properties.put(ComponentPropertiesComposite.VERSION, text_7
453: .getText());
454:
455: properties.put(ComponentPropertiesComposite.ROLE, combo
456: .getText());
457: properties.put(ComponentPropertiesComposite.CONSUMER_MEP,
458: combo_1.getText());
459: properties.put(ComponentPropertiesComposite.PROVIDER_MEP,
460: combo_2.getText());
461:
462: //properties.put(ComponentPropertiesComposite.CONSUMER_IS_SCHEDULED, Boolean.toString(scheduledButton.getSelection()));
463: properties.put(
464: ComponentPropertiesComposite.CONSUMER_IS_SCHEDULED,
465: Boolean.toString(Boolean.TRUE));
466:
467: properties.put(ComponentPropertiesComposite.USE_CCSL, Boolean
468: .toString(getUseCcslButton().getSelection()));
469: properties.put(ComponentPropertiesComposite.DEFAULT_DEPLOY,
470: Boolean.toString(getUseDefaultDeployButton()
471: .getSelection()));
472: properties.put(ComponentPropertiesComposite.DEFAULT_WSDL,
473: Boolean.toString(getUseDefautltWsdlButton()
474: .getSelection()));
475: }
476:
477: protected Button getUseDefaultDeployButton() {
478: return useDefaultDeployButton;
479: }
480:
481: protected Button getUseDefautltWsdlButton() {
482: return useDefautltWsdlButton;
483: }
484:
485: protected Button getUseCcslButton() {
486: return useCcslButton;
487: }
488:
489: /**
490: * @return the properties
491: */
492: public HashMap<String, String> getProperties() {
493: viewToModel();
494: return properties;
495: }
496:
497: /**
498: * @param properties the properties to set
499: */
500: public void setProperties(HashMap<String, String> properties) {
501: this .properties = properties;
502: modelToView();
503: }
504:
505: private void initProperties(HashMap<String, String> prop) {
506: if (prop.get(ComponentPropertiesComposite.INIT_REQUIRED) == null
507: || Boolean
508: .getBoolean(prop
509: .get(ComponentPropertiesComposite.INIT_REQUIRED))) {
510: //no more init required
511: prop.put(ComponentPropertiesComposite.INIT_REQUIRED,
512: Boolean.toString(false));
513: //other properties
514: prop.put(ComponentPropertiesComposite.NAME, "");
515: prop.put(ComponentPropertiesComposite.DESCRIPTION,
516: "Description");
517: prop.put(ComponentPropertiesComposite.COMPONENT_NAME, "");
518: prop
519: .put(
520: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART1,
521: "ChainbuilderESB");
522: prop
523: .put(
524: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART2,
525: BC);
526: prop
527: .put(
528: ComponentPropertiesComposite.COMPONENT_NAME_AUX_PART3,
529: "");
530: //prop.put(ComponentPropertiesComposite.COMPONENT_DESCRIPTION, "Component Description");
531: prop.put(ComponentPropertiesComposite.URI,
532: "http://cbesb.bostechcorp.com/");
533: prop.put(ComponentPropertiesComposite.VENDOR,
534: "Bostech Corporation");
535: prop.put(ComponentPropertiesComposite.VERSION, "1.0");
536:
537: prop.put(ComponentPropertiesComposite.ROLE,
538: ComponentPropertiesComposite.BOTH);
539: prop.put(ComponentPropertiesComposite.CONSUMER_MEP,
540: ComponentPropertiesComposite.INOUT);
541: prop.put(ComponentPropertiesComposite.PROVIDER_MEP,
542: ComponentPropertiesComposite.INOUT);
543: prop.put(
544: ComponentPropertiesComposite.CONSUMER_IS_SCHEDULED,
545: Boolean.toString(Boolean.FALSE));
546:
547: prop.put(ComponentPropertiesComposite.USE_CCSL, Boolean
548: .toString(true));
549: prop.put(ComponentPropertiesComposite.DEFAULT_DEPLOY,
550: Boolean.toString(true));
551: prop.put(ComponentPropertiesComposite.DEFAULT_WSDL, Boolean
552: .toString(true));
553:
554: //prop.put(ComponentPropertiesComposite.PATH_XML,"c:/");
555: //prop.put(ComponentPropertiesComposite.PATH_JAVA,"c:/");
556: }
557: }
558:
559: public Text getText_1() {
560: return text_1;
561: }
562:
563: public Text getText_2() {
564: return text_2;
565: }
566:
567: public Text getText_3() {
568: return text_3;
569: }
570:
571: public Text getText_5() {
572: return text_5;
573: }
574:
575: public Text getText_6() {
576: return text_6;
577: }
578:
579: public Text getText_7() {
580: return text_7;
581: }
582:
583: public Combo getCombo() {
584: return combo;
585: }
586:
587: public Combo getCombo_1() {
588: return combo_1;
589: }
590:
591: public Combo getCombo_2() {
592: return combo_2;
593: }
594:
595: public Combo getCombo_3() {
596: return combo_3;
597: }
598:
599: public Text getText() {
600: return text;
601: }
602:
603: public Button getScheduledButton() {
604: return scheduledButton;
605: }
606: }
|