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 java.util.HashMap;
027:
028: import org.eclipse.jface.wizard.IWizardPage;
029: import org.eclipse.swt.SWT;
030: import org.eclipse.swt.events.ModifyEvent;
031: import org.eclipse.swt.events.ModifyListener;
032: import org.eclipse.swt.layout.GridData;
033: import org.eclipse.swt.layout.GridLayout;
034: import org.eclipse.swt.widgets.Combo;
035: import org.eclipse.swt.widgets.Composite;
036: import org.eclipse.swt.widgets.Label;
037: import org.eclipse.swt.widgets.Text;
038:
039: import com.bostechcorp.cbesb.common.i18n.I18N;
040: import com.bostechcorp.cbesb.common.i18n.Messages;
041: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.DefaultMepType;
042: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FTPConsumer;
043: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.PatternModel;
044: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.Scheduler;
045: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.componentflowFactory;
046:
047: public class FTPPropertyWizardPageReadFilePath extends
048: PropertyWizardPage {
049:
050: private Text textTransferDirectory;
051:
052: private Text textFilePattern;
053:
054: private Text textStageDirectory;
055:
056: private Text textSourceDir;
057:
058: private Combo matchCombo;
059:
060: private HashMap<String, Object> detailMap = new HashMap<String, Object>();
061:
062: private Scheduler scheduler = componentflowFactory.eINSTANCE
063: .createScheduler();
064:
065: private SchedulerGroup tiggerMethodGroup;
066:
067: private Combo comboDefaultMep;
068:
069: protected FTPPropertyWizardPageReadFilePath(String pageName) {
070: super (pageName);
071: setTitle(I18N.getString(Messages.READ_PRO_WIZ));// "Choose
072: setDescription(I18N.getString(Messages.READ_PRO_WIZ_DES1));
073:
074: /*
075: * setTitle(I18N.getString(Messages.IDE_CHOOSE_TRN_FILE));// "Choose
076: * setDescription(I18N.getString(Messages.IDE_CHOOSE_TRNFILE_DESC));//
077: * "Choose
078: */
079:
080: }
081:
082: public void createControl(Composite parent) {
083:
084: Composite topLevel = new Composite(parent, SWT.NONE);
085: final GridLayout gridLayout = new GridLayout();
086: gridLayout.numColumns = 2;
087: topLevel.setLayout(gridLayout);
088: topLevel.setLayoutData(new GridData(
089: GridData.VERTICAL_ALIGN_FILL
090: | GridData.HORIZONTAL_ALIGN_FILL));
091: topLevel.setFont(parent.getFont());
092:
093: // super.createControl(parent);
094:
095: //
096: this .setControl(topLevel);
097:
098: Label messageExchangePatternLabel = new Label(topLevel,
099: SWT.NONE);
100: final GridData gridData_1 = new GridData(87, SWT.DEFAULT);
101: messageExchangePatternLabel.setLayoutData(gridData_1);
102: messageExchangePatternLabel.setText(I18N
103: .getString(Messages.WIZARD_MEP));
104:
105: comboDefaultMep = new Combo(topLevel, SWT.READ_ONLY);
106: comboDefaultMep.setLayoutData(new GridData(SWT.FILL,
107: SWT.CENTER, true, false));
108: comboDefaultMep.setItems(new String[] { "in-only", "in-out",
109: "reliablein" });
110: if (!this .getWizard().isUpdateOperation())
111: comboDefaultMep.setText("in-only");
112: final Label labelSource = new Label(topLevel, SWT.NONE);
113: final GridData gridData = new GridData(SWT.FILL, SWT.FILL,
114: false, false);
115: gridData.widthHint = 136;
116: labelSource.setLayoutData(gridData);
117: labelSource.setText(I18N.getString(Messages.SOURCE_DIR));
118:
119: textSourceDir = new Text(topLevel, SWT.BORDER);
120: textSourceDir.addModifyListener(new ModifyListener() {
121: public void modifyText(ModifyEvent e) {
122: dialogChanged();
123: }
124: });
125: textSourceDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
126: true, false));
127:
128: final Label transferLabel = new Label(topLevel, SWT.NONE);
129: transferLabel.setText(I18N.getString(Messages.TRA_DIR));
130:
131: textTransferDirectory = new Text(topLevel, SWT.BORDER);
132: textTransferDirectory.setLayoutData(new GridData(SWT.FILL,
133: SWT.CENTER, true, false));
134:
135: final Label labelStage = new Label(topLevel, SWT.NONE);
136: labelStage.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
137: false, false));
138: labelStage.setText(I18N.getString(Messages.STA_DIR));
139:
140: textStageDirectory = new Text(topLevel, SWT.BORDER);
141: textStageDirectory.addModifyListener(new ModifyListener() {
142: public void modifyText(ModifyEvent e) {
143: dialogChanged();
144: }
145: });
146: textStageDirectory.setLayoutData(new GridData(SWT.FILL,
147: SWT.CENTER, true, false));
148:
149: final Label labelPattern = new Label(topLevel, SWT.NONE);
150: labelPattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
151: false, false));
152: labelPattern.setText(I18N.getString(Messages.FILE_PAT));
153:
154: textFilePattern = new Text(topLevel, SWT.BORDER);
155: if (!this .getWizard().isUpdateOperation())
156: textFilePattern.setText("*");
157: textFilePattern.setLayoutData(new GridData(SWT.FILL,
158: SWT.CENTER, true, false));
159:
160: final Label matchModeLabel = new Label(topLevel, SWT.NONE);
161: matchModeLabel.setText(I18N
162: .getString(Messages.FILE_PATTERN_MATHCH));
163:
164: matchCombo = new Combo(topLevel, SWT.READ_ONLY);
165: matchCombo.setItems(new String[] { "Glob", "RegExpr" });
166: matchCombo.setText("Glob");
167: matchCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
168: true, false));
169:
170: if (this .getWizard().isUpdateOperation()) {
171: modelsToControl();
172: }
173:
174: tiggerMethodGroup = new SchedulerGroup(topLevel, SWT.NONE, I18N
175: .getString(Messages.SCAN_INT), "5000", detailMap, this
176: .getWizard().isUpdateOperation());
177:
178: tiggerMethodGroup.setLayoutData(new GridData(SWT.FILL,
179: SWT.CENTER, false, false, 2, 1));
180:
181: dialogChanged();
182: }
183:
184: private void dialogChanged() {
185: if (WizardUtil.whetherUseValidation == false) {
186: setPageComplete(true);
187: return;
188: }
189: if (textSourceDir.getText().equals("")) {
190: updateStatus(I18N.getString(Messages.SOURCE_DIR_REQ));
191: setPageComplete(false);
192: return;
193: } else if (textStageDirectory.getText().equals("")) {
194: updateStatus(I18N.getString(Messages.STAGE_DIR_REQ));
195: setPageComplete(false);
196: return;
197: }
198: setPageComplete(true);
199: updateStatus(null);
200: }
201:
202: private void updateStatus(String message) {
203: setErrorMessage(message);
204: }
205:
206: @Override
207: public void controlToModels() {
208:
209: FTPPropertyWizard FtpWizard = (FTPPropertyWizard) this
210: .getWizard();
211: if (FtpWizard.getModels() == null)
212: return;
213: try {
214: FTPConsumer ftpConsumer = FtpWizard.getModels()
215: .getFtpBase().getFtpConsumer();
216: ftpConsumer.setSourceDir(textSourceDir.getText());
217: ftpConsumer.setStageDir(textStageDirectory.getText());
218: ftpConsumer.setFilePattern(textFilePattern.getText());
219: ftpConsumer.setTransferDir(textTransferDirectory.getText());
220:
221: if (tiggerMethodGroup != null)
222: tiggerMethodGroup.controlToModel();
223: ftpConsumer.setUseScheduler(new Boolean((String) detailMap
224: .get("useschedule")));
225: if (new Boolean((String) detailMap.get("useschedule")))
226: SchedulerHelper.copy((Scheduler) detailMap
227: .get("scheduler"), ftpConsumer.getScheduler());
228: else
229: ftpConsumer.setScanInterval((String) detailMap
230: .get("scaninterval"));
231: ftpConsumer.setMatchModel(PatternModel.get(matchCombo
232: .getText()));
233: ftpConsumer.setDefaultMep(DefaultMepType
234: .get(comboDefaultMep.getText()));
235: } catch (Exception e) {
236: e.printStackTrace();
237: }
238: }
239:
240: public IWizardPage getNextPage() {
241:
242: return super .getNextPage();
243: }
244:
245: @Override
246: public void modelsToControl() {
247:
248: FTPPropertyWizard FtpWizard = (FTPPropertyWizard) this
249: .getWizard();
250: if (!FtpWizard.isUpdateOperation())
251: return;
252: try {
253: FTPConsumer ftpConsumer = FtpWizard.getModels()
254: .getFtpBase().getFtpConsumer();
255: if (ftpConsumer.getSourceDir() != null)
256: textSourceDir.setText(ftpConsumer.getSourceDir());
257: else
258: textSourceDir.setText("");
259:
260: if (ftpConsumer.getStageDir() != null)
261: textStageDirectory.setText(ftpConsumer.getStageDir());
262: else
263: textStageDirectory.setText("");
264:
265: if (ftpConsumer.getFilePattern() != null)
266: textFilePattern.setText(ftpConsumer.getFilePattern());
267: else
268: textFilePattern.setText("");
269:
270: if (ftpConsumer.getTransferDir() != null)
271: textTransferDirectory.setText(ftpConsumer
272: .getTransferDir());
273: else
274: textTransferDirectory.setText("");
275:
276: matchCombo.select(matchCombo.indexOf(ftpConsumer
277: .getMatchModel().getLiteral()));
278:
279: Scheduler modelScheduler = ftpConsumer.getScheduler();
280: SchedulerHelper.copy(modelScheduler, scheduler);
281: detailMap.put("scheduler", scheduler);
282: detailMap.put("useschedule", new Boolean(ftpConsumer
283: .isUseScheduler()).toString());
284: detailMap
285: .put("scaninterval", ftpConsumer.getScanInterval());
286: comboDefaultMep.select(comboDefaultMep.indexOf(ftpConsumer
287: .getDefaultMep().getLiteral()));
288:
289: } catch (Exception e) {
290: e.printStackTrace();
291: }
292: }
293:
294: public Combo getComboDefaultMep() {
295: return comboDefaultMep;
296: }
297: }
|