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.SelectionAdapter;
029: import org.eclipse.swt.events.SelectionEvent;
030: import org.eclipse.swt.layout.GridData;
031: import org.eclipse.swt.widgets.Button;
032: import org.eclipse.swt.widgets.Composite;
033:
034: import com.bostechcorp.cbesb.common.i18n.I18N;
035: import com.bostechcorp.cbesb.common.i18n.Messages;
036: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.BindingComponent;
037: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ComponentFlowEditorElement;
038: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.JMS;
039: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.RoleType;
040:
041: public class JMSPropertyWizardPageMain extends
042: BindingComponentWizardPageMain {
043:
044: Button ButtonReliableDelivery;
045:
046: boolean useDefault = true;
047:
048: protected JMSPropertyWizardPageMain(String pageName) {
049: super (pageName);
050: setTitle(I18N.getString(Messages.JMS_TITLE));
051: setDescription(I18N.getString(Messages.WIZARD_ENTER_TIP));
052: }
053:
054: protected String name_text = "JMS";
055:
056: public String getComponentName() {
057: return name_text;
058: }
059:
060: public IWizardPage getNextPage() {
061: if (buttonProvider.getSelection()) {
062:
063: return getWizard().getPage("ProviderProperty");
064: } else if (ButtonReliableDelivery.getSelection()) {
065: return getWizard().getPage("ReliableMain");
066: }
067:
068: return getWizard().getPage("ConsumerProperty");
069: }
070:
071: @Override
072: public String getConsumerEndpointName() {
073: return textName.getText() + "_Input";
074: }
075:
076: @Override
077: public String getProviderEndpointName() {
078: return textName.getText() + "_Output";
079: }
080:
081: @Override
082: public void createControl(Composite parent) {
083: super .createSubControl(parent, 2);
084:
085: ButtonReliableDelivery = new Button(roleGroup, SWT.RADIO);
086: ButtonReliableDelivery.setLayoutData(new GridData(SWT.LEFT,
087: SWT.CENTER, true, false));
088: ButtonReliableDelivery.setText(I18N
089: .getString(Messages.JMS_RELIABLE_DELIVERY));
090:
091: buttonConsumer.addSelectionListener(new SelectionAdapter() {
092: public void widgetSelected(SelectionEvent e) {
093:
094: defaultSettingForNonReliableDel();
095:
096: }
097: });
098: buttonProvider.addSelectionListener(new SelectionAdapter() {
099: public void widgetSelected(SelectionEvent e) {
100: defaultSettingForNonReliableDel();
101:
102: }
103: });
104: ButtonConsumerAndProvider
105: .addSelectionListener(new SelectionAdapter() {
106: public void widgetSelected(SelectionEvent e) {
107: defaultSettingForNonReliableDel();
108:
109: }
110: });
111: ButtonReliableDelivery
112: .addSelectionListener(new SelectionAdapter() {
113: public void widgetSelected(SelectionEvent e) {
114: defaultSettingForReliableDel();
115:
116: }
117: });
118:
119: if (this .getWizard().isUpdateOperation()) {
120: modelsToControl();
121: }
122:
123: dialogChanged();
124:
125: }
126:
127: public void defaultSettingForNonReliableDel() {
128: ((JMSPropertyWizardPageConsumerProperty) this .getWizard()
129: .getPage("ConsumerProperty"))
130: .defaultSettingForNonReliableDel();
131: ((JMSPropertyWizardPageConsumerProperty2) this .getWizard()
132: .getPage("ConsumerProperty2"))
133: .defaultSettingForNonReliableDel();
134: ((JMSPropertyWizardPageProviderProperty) this .getWizard()
135: .getPage("ProviderProperty"))
136: .defaultSettingForNonReliableDel();
137:
138: }
139:
140: public void defaultSettingForReliableDel() {
141: ((JMSPropertyWizardPageConsumerProperty) this .getWizard()
142: .getPage("ConsumerProperty"))
143: .defaultSettingForReliableDel();
144: ((JMSPropertyWizardPageConsumerProperty2) this .getWizard()
145: .getPage("ConsumerProperty2"))
146: .defaultSettingForReliableDel();
147: ((JMSPropertyWizardPageProviderProperty) this .getWizard()
148: .getPage("ProviderProperty"))
149: .defaultSettingForReliableDel();
150:
151: }
152:
153: @Override
154: public void controlToModels() {
155: JMS jms = (JMS) this .getWizard().getModels();
156: try {
157:
158: if (ButtonReliableDelivery.getSelection()) {
159: jms.setRole(RoleType.RELIABLE_DELIVERY_LITERAL);
160: jms.getProvider().setEndPointName(
161: getProviderEndpointName());
162: jms.getConsumer().setEndPointName(
163: getConsumerEndpointName());
164: }
165: } catch (Exception e) {
166: e.printStackTrace();
167: }
168: super .controlToModels();
169: }
170:
171: @Override
172: public void modelsToControl() {
173: PropertyWizard wizard = this .getWizard();
174: if (!wizard.isUpdateOperation())
175: return;
176: try {
177: JMS jms = (JMS) this .getWizard().getModels();
178:
179: int modeType = jms.getRole().getValue();
180:
181: if (modeType == RoleType.RELIABLE_DELIVERY) {
182: buttonConsumer.setSelection(false);
183: buttonProvider.setSelection(false);
184: ButtonConsumerAndProvider.setSelection(false);
185: ButtonReliableDelivery.setSelection(true);
186: } else {
187: ButtonReliableDelivery.setSelection(false);
188: }
189:
190: } catch (Exception e) {
191: e.printStackTrace();
192: }
193: super .modelsToControl();
194:
195: }
196:
197: @Override
198: boolean isConsumer() {
199: return buttonConsumer.getSelection()
200: || ButtonConsumerAndProvider.getSelection()
201: || ButtonReliableDelivery.getSelection();
202: }
203:
204: @Override
205: boolean isProvider() {
206: return buttonProvider.getSelection()
207: || ButtonConsumerAndProvider.getSelection()
208: || ButtonReliableDelivery.getSelection();
209: }
210:
211: public boolean isUseDefault() {
212:
213: return ((JMSReliableDelMain) this .getWizard().getPage(
214: "ReliableMain")).getUseDefaultButton().getSelection();
215: }
216:
217: public boolean isReliableDelivery() {
218:
219: return ButtonReliableDelivery.getSelection();
220: }
221:
222: }
|