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.GridData;
031: import org.eclipse.swt.layout.GridLayout;
032: import org.eclipse.swt.widgets.Combo;
033: import org.eclipse.swt.widgets.Composite;
034: import org.eclipse.swt.widgets.Label;
035: import org.eclipse.swt.widgets.Text;
036:
037: import com.bostechcorp.cbesb.common.i18n.I18N;
038: import com.bostechcorp.cbesb.common.i18n.Messages;
039: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.JDBC;
040:
041: public class JDBCPropertyDetailPage extends PropertyWizardPage {
042:
043: private Text textDefaultPageSize;
044:
045: private Text textTransactionTimeout;
046:
047: private Text textExecHandlerClass;
048:
049: private Text textConnectionRetries;
050:
051: private Combo comboAutoCommit;
052:
053: private Text textUser;
054:
055: private Text textConnectionInterva;
056:
057: private Text textRequestHandlerClass;
058:
059: private Text textPassword;
060:
061: private Text textConnectionURL;
062:
063: private Text textDriver;
064:
065: protected JDBCPropertyDetailPage(String pageName) {
066: super (pageName);
067: setTitle(I18N.getString(Messages.JDBC_TITLE));// "Choose
068: setDescription(I18N.getString(Messages.WIZARD_ENTER_TIP));
069: }
070:
071: public void createControl(Composite parent) {
072: final Composite topLevel = new Composite(parent, SWT.NONE);
073: final GridLayout gridLayout = new GridLayout();
074: gridLayout.horizontalSpacing = 10;
075: gridLayout.numColumns = 2;
076: topLevel.setLayout(gridLayout);
077: topLevel.setLayoutData(new GridData(
078: GridData.VERTICAL_ALIGN_FILL
079: | GridData.HORIZONTAL_ALIGN_FILL));
080: topLevel.setFont(parent.getFont());
081:
082: // super.createControl(parent);
083:
084: //
085: this .setControl(topLevel);
086:
087: final Label fixedOffsetLabel = new Label(topLevel, SWT.NONE);
088: fixedOffsetLabel.setText(I18N.getString(Messages.JDBC_DRIVER));
089:
090: textDriver = new Text(topLevel, SWT.BORDER);
091: textDriver.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
092: true, false));
093: textDriver.addModifyListener(new ModifyListener() {
094: public void modifyText(ModifyEvent e) {
095:
096: dialogChanged();
097: }
098: });
099:
100: final Label fixedLengthLabel = new Label(topLevel, SWT.NONE);
101: fixedLengthLabel.setText(I18N.getString(Messages.JDBC_URL));
102:
103: textConnectionURL = new Text(topLevel, SWT.BORDER);
104: textConnectionURL.setLayoutData(new GridData(SWT.FILL,
105: SWT.CENTER, true, false));
106: textConnectionURL.addModifyListener(new ModifyListener() {
107: public void modifyText(ModifyEvent e) {
108:
109: dialogChanged();
110: }
111: });
112:
113: final Label dilimiterLabel = new Label(topLevel, SWT.NONE);
114: dilimiterLabel.setText(I18N.getString(Messages.JDBC_USER));
115:
116: textUser = new Text(topLevel, SWT.BORDER);
117: textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
118: false));
119:
120: final Label scriptEngineLabel = new Label(topLevel, SWT.NONE);
121: scriptEngineLabel.setText(I18N
122: .getString(Messages.JDBC_PASSWORD));
123:
124: textPassword = new Text(topLevel, SWT.PASSWORD | SWT.BORDER);
125: textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
126: true, false));
127:
128: final Label scriptClassLabel = new Label(topLevel, SWT.NONE);
129: scriptClassLabel.setText(I18N
130: .getString(Messages.JDBC_REQUEST_HANDLDER));
131:
132: textRequestHandlerClass = new Text(topLevel, SWT.BORDER);
133: if (!this .getWizard().isUpdateOperation())
134: textRequestHandlerClass
135: .setText("com.bostechcorp.cbesb.runtime.component.jdbc.processors.JdbcDefaultRequestHandler");
136: textRequestHandlerClass.setLayoutData(new GridData(SWT.FILL,
137: SWT.CENTER, true, false));
138: textRequestHandlerClass.addModifyListener(new ModifyListener() {
139: public void modifyText(ModifyEvent e) {
140:
141: dialogChanged();
142: }
143: });
144:
145: final Label execHandlerLabel = new Label(topLevel, SWT.NONE);
146: execHandlerLabel.setText(I18N
147: .getString(Messages.JDBC_EXEC_HANDLER));
148:
149: textExecHandlerClass = new Text(topLevel, SWT.BORDER);
150: if (!this .getWizard().isUpdateOperation())
151: textExecHandlerClass
152: .setText("com.bostechcorp.cbesb.runtime.component.jdbc.processors.JdbcDefaultExecutionHandler");
153: textExecHandlerClass.setLayoutData(new GridData(SWT.FILL,
154: SWT.CENTER, true, false));
155: textExecHandlerClass.addModifyListener(new ModifyListener() {
156: public void modifyText(ModifyEvent e) {
157:
158: dialogChanged();
159: }
160: });
161:
162: final Label scriptMethodLabel = new Label(topLevel, SWT.NONE);
163: scriptMethodLabel.setText(I18N
164: .getString(Messages.JDBC_AUTO_COMMIT));
165:
166: comboAutoCommit = new Combo(topLevel, SWT.READ_ONLY);
167: comboAutoCommit.setItems(new String[] { "true", "false" });
168: if (!this .getWizard().isUpdateOperation())
169: comboAutoCommit.setText("true");
170: comboAutoCommit.setLayoutData(new GridData(SWT.FILL,
171: SWT.CENTER, true, false));
172:
173: final Label indexLabel = new Label(topLevel, SWT.NONE);
174: indexLabel.setText(I18N
175: .getString(Messages.JDBC_CONNECTION_RETRIES));
176:
177: textConnectionRetries = new Text(topLevel, SWT.BORDER);
178: if (!this .getWizard().isUpdateOperation())
179: textConnectionRetries.setText("3");
180: textConnectionRetries.setLayoutData(new GridData(SWT.FILL,
181: SWT.CENTER, true, false));
182: textConnectionRetries.addModifyListener(new ModifyListener() {
183: public void modifyText(ModifyEvent e) {
184: dialogChanged();
185: }
186: });
187:
188: final Label extenssionLabel = new Label(topLevel, SWT.NONE);
189: extenssionLabel.setText(I18N
190: .getString(Messages.JDBC_CONNECTION_INTERVAL));
191:
192: textConnectionInterva = new Text(topLevel, SWT.BORDER);
193: if (!this .getWizard().isUpdateOperation())
194: textConnectionInterva.setText("3000");
195: textConnectionInterva.setLayoutData(new GridData(SWT.FILL,
196: SWT.CENTER, true, false));
197: textConnectionInterva.addModifyListener(new ModifyListener() {
198: public void modifyText(ModifyEvent e) {
199: dialogChanged();
200: }
201: });
202: final Label transactionTimeoutLabel = new Label(topLevel,
203: SWT.NONE);
204: transactionTimeoutLabel.setText(I18N
205: .getString(Messages.JDBC_TRANSACTION_TIMEOUT));
206:
207: textTransactionTimeout = new Text(topLevel, SWT.BORDER);
208: textTransactionTimeout.setLayoutData(new GridData(SWT.FILL,
209: SWT.CENTER, true, false));
210: if (!this .getWizard().isUpdateOperation())
211: textTransactionTimeout.setText("30000");
212: textTransactionTimeout.addModifyListener(new ModifyListener() {
213: public void modifyText(ModifyEvent e) {
214: dialogChanged();
215: }
216: });
217: final Label defaultPageSizeLabel = new Label(topLevel, SWT.NONE);
218: defaultPageSizeLabel.setText(I18N
219: .getString(Messages.JDBC_DEFAULT_PAGE_SIZE));
220:
221: textDefaultPageSize = new Text(topLevel, SWT.BORDER);
222: textDefaultPageSize.setLayoutData(new GridData(SWT.FILL,
223: SWT.CENTER, true, false));
224: if (!this .getWizard().isUpdateOperation())
225: textDefaultPageSize.setText("-1");
226:
227: if (this .getWizard().isUpdateOperation()) {
228: modelsToControl();
229: }
230: dialogChanged();
231: }
232:
233: protected void dialogChanged() {
234: if (WizardUtil.whetherUseValidation == false) {
235: setPageComplete(true);
236: return;
237: }
238: if (textDriver.getText().equals("")) {
239: setErrorMessage(I18N
240: .getString(Messages.JDBC_ERROR_DRIVER_REQUIRE));
241: setPageComplete(false);
242: return;
243: }
244: if (textConnectionURL.getText().equals("")) {
245: setErrorMessage(I18N
246: .getString(Messages.JDBC_ERROR_URL_REQUIRE));
247: setPageComplete(false);
248: return;
249: }
250: if (textRequestHandlerClass.getText().equals("")) {
251: setErrorMessage(I18N
252: .getString(Messages.JDBC_ERROR_REQUESTHANDLER_REQUIRE));
253: setPageComplete(false);
254: return;
255: }
256: if (textExecHandlerClass.getText().equals("")) {
257: setErrorMessage(I18N
258: .getString(Messages.JDBC_ERROR_EXECHANDLER_REQUIRE));
259: setPageComplete(false);
260: return;
261: }
262: if (!textConnectionInterva.getText().equals("")) {
263: String recordPerMsg = textConnectionInterva.getText();
264: if (!WizardUtil.isNumber(recordPerMsg)) {
265: setErrorMessage(I18N
266: .getString(Messages.JDBC_ERROR_CONNECTIONINTERVAL_INTEGER));
267: setPageComplete(false);
268: return;
269: }
270: }
271: if (!textConnectionRetries.getText().equals("")) {
272: String recordPerMsg = textConnectionRetries.getText();
273: if (!WizardUtil.isNumber(recordPerMsg)) {
274: setErrorMessage(I18N
275: .getString(Messages.JDBC_ERROR_CONNECTION_RETRIES_INTEGER));
276: setPageComplete(false);
277: return;
278: }
279: }
280: if (!textTransactionTimeout.getText().equals("")) {
281: String recordPerMsg = textTransactionTimeout.getText();
282: if (!WizardUtil.isNumber(recordPerMsg)) {
283: setErrorMessage(I18N
284: .getString(Messages.JDBC_ERROR_TIME_OUT_INTEGER));
285: setPageComplete(false);
286: return;
287: }
288: }
289: setErrorMessage(null);
290: setPageComplete(true);
291: }
292:
293: public IWizardPage getNextPage() {
294: if (((JDBCPropertyWizardPageMain) super .getWizard()
295: .getMainPage()).getComboCCSL().getText().equals("true")) {
296: return super .getNextPage();
297: }
298:
299: return null;
300: }
301:
302: @Override
303: public void controlToModels() {
304:
305: JDBCPropertyWizard JDBCWizard = (JDBCPropertyWizard) this
306: .getWizard();
307: JDBC models = JDBCWizard.getModels();
308: if (models == null)
309: return;
310: try {
311:
312: models.setAutoCommit(comboAutoCommit.getText());
313: models
314: .setConnectionIterval(textConnectionInterva
315: .getText());
316: models
317: .setConnectionRetries(textConnectionRetries
318: .getText());
319: models.setURL(textConnectionURL.getText());
320: models.setDriver(textDriver.getText());
321:
322: models.setPassword(textPassword.getText());
323: models.setUser(textUser.getText());
324: models.setTransactionTimeout(textTransactionTimeout
325: .getText());
326: models.setDefaultPageSize(textDefaultPageSize.getText());
327: models.setRequestHandler(textRequestHandlerClass.getText());
328: models.setExecHandler(textExecHandlerClass.getText());
329: } catch (Exception e) {
330: e.printStackTrace();
331: }
332: }
333:
334: @Override
335: public void modelsToControl() {
336: JDBCPropertyWizard JDBCWizard = (JDBCPropertyWizard) this
337: .getWizard();
338: JDBC models = JDBCWizard.getModels();
339: if (models == null)
340: return;
341: try {
342:
343: comboAutoCommit.select(comboAutoCommit.indexOf(models
344: .getAutoCommit().toString()));
345:
346: if (models.getConnectionIterval() != null)
347: textConnectionInterva.setText(models
348: .getConnectionIterval());
349: else
350: textConnectionInterva.setText("");
351:
352: if (models.getConnectionRetries() != null)
353: textConnectionRetries.setText(models
354: .getConnectionRetries());
355: else
356: textConnectionRetries.setText("");
357:
358: if (models.getURL() != null)
359: textConnectionURL.setText(models.getURL());
360: else
361: textConnectionURL.setText("");
362:
363: if (models.getDriver() != null)
364: textDriver.setText(models.getDriver());
365: else
366: textDriver.setText("");
367:
368: if (models.getRequestHandler() != null)
369: textRequestHandlerClass.setText(models
370: .getRequestHandler());
371: else
372: textRequestHandlerClass.setText("");
373:
374: if (models.getPassword() != null)
375: textPassword.setText(models.getPassword());
376: else
377: textPassword.setText("");
378:
379: if (models.getUser() != null)
380: textUser.setText(models.getUser());
381: else
382: textUser.setText("");
383:
384: if (models.getTransactionTimeout() != null)
385: textTransactionTimeout.setText(models
386: .getTransactionTimeout());
387: else
388: textTransactionTimeout.setText("");
389:
390: if (models.getDefaultPageSize() != null)
391: textDefaultPageSize
392: .setText(models.getDefaultPageSize());
393: else
394: textDefaultPageSize.setText("");
395:
396: if (models.getExecHandler() != null)
397: textExecHandlerClass.setText(models.getExecHandler());
398: else
399: textExecHandlerClass.setText("");
400:
401: } catch (Exception e) {
402: e.printStackTrace();
403: }
404: }
405:
406: }
|