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.Group;
035: import org.eclipse.swt.widgets.Label;
036: import org.eclipse.swt.widgets.Text;
037:
038: import com.bostechcorp.cbesb.common.i18n.I18N;
039: import com.bostechcorp.cbesb.common.i18n.Messages;
040: import com.bostechcorp.cbesb.common.util.SystemCharacterEncoding;
041:
042: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FTPProvider;
043: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FileActionType;
044: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ReadStyleType;
045:
046: public class FTPPropertyWizardPageWriteStyleAndArchive extends
047: PropertyWizardPage {
048:
049: private Combo comboAction;
050:
051: private Text textArchiveFilePattern;
052:
053: private Text textArchiveDir;
054:
055: private Combo comboCharacterSet;
056:
057: private Combo comboWriteStyle;
058:
059: protected FTPPropertyWizardPageWriteStyleAndArchive(String pageName) {
060: super (pageName);
061: setTitle(I18N.getString(Messages.WRI_MODE_PRO));// "Choose
062: setDescription(I18N.getString(Messages.WRI_MODE_PRO_DES1));
063: }
064:
065: public void createControl(Composite parent) {
066:
067: Composite topLevel = new Composite(parent, SWT.NONE);
068: final GridLayout gridLayout = new GridLayout();
069: gridLayout.verticalSpacing = 10;
070: gridLayout.numColumns = 2;
071: topLevel.setLayout(gridLayout);
072: topLevel.setLayoutData(new GridData(
073: GridData.VERTICAL_ALIGN_FILL
074: | GridData.HORIZONTAL_ALIGN_FILL));
075: topLevel.setFont(parent.getFont());
076: this .setControl(topLevel);
077:
078: Label pleaseEnterTheLabel_1;
079:
080: final Group actionGroup;
081:
082: final Label pleaseEnterTheLabel = new Label(topLevel, SWT.NONE);
083: pleaseEnterTheLabel
084: .setLayoutData(new GridData(GridData.BEGINNING,
085: GridData.CENTER, false, false, 2, 1));
086: pleaseEnterTheLabel.setText(I18N.getString(Messages.INF));
087:
088: final Label labelWriteStyle = new Label(topLevel, SWT.NONE);
089: labelWriteStyle.setText(I18N.getString(Messages.WRI_STYLE));
090:
091: comboWriteStyle = new Combo(topLevel, SWT.READ_ONLY);
092: comboWriteStyle.setLayoutData(new GridData(SWT.FILL,
093: SWT.CENTER, true, false));
094: comboWriteStyle.add("raw");
095: comboWriteStyle.add("newline");
096: if (!this .getWizard().isUpdateOperation())
097: comboWriteStyle.setText("raw");
098:
099: final Label labelCharacterSet = new Label(topLevel, SWT.NONE);
100: labelCharacterSet.setText(I18N.getString(Messages.CHAR_SET));
101:
102: comboCharacterSet = new Combo(topLevel, SWT.READ_ONLY);
103: comboCharacterSet.setLayoutData(new GridData(SWT.FILL,
104: SWT.CENTER, true, false));
105: // comboCharacterSet.setItems(new String[] {"SYSTEM_DEFAULT",
106: // "ISO-8859-1", "USASCII", "UTF-8", "UTF-16BE", "UTF-16LE",
107: // "windows-1252", "EUC-JP", "Shift_JIS", "Big5", "Big5-HKSCS"});
108: comboCharacterSet.setItems(SystemCharacterEncoding
109: .getSupportedCharacterSets());
110:
111: if (!this .getWizard().isUpdateOperation())
112: comboCharacterSet.setText("SYSTEM_DEFAULT");
113: pleaseEnterTheLabel_1 = new Label(topLevel, SWT.NONE);
114: pleaseEnterTheLabel_1
115: .setLayoutData(new GridData(GridData.BEGINNING,
116: GridData.CENTER, false, false, 2, 1));
117: pleaseEnterTheLabel_1.setText(I18N.getString(Messages.INF1));
118: actionGroup = new Group(topLevel, SWT.NONE);
119: final GridLayout gridLayout_2 = new GridLayout();
120: gridLayout_2.verticalSpacing = 10;
121: actionGroup.setLayout(gridLayout_2);
122: final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
123: false, false, 2, 1);
124: gridData.heightHint = 126;
125: gridData.widthHint = 502;
126: actionGroup.setLayoutData(gridData);
127: actionGroup.setText(I18N.getString(Messages.ACT));
128:
129: comboAction = new Combo(actionGroup, SWT.READ_ONLY);
130: comboAction.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
131: true, false));
132: comboAction.setItems(new String[] { "delete", "archive" });
133: if (!this .getWizard().isUpdateOperation())
134: comboAction.setText("delete");
135:
136: comboAction.addModifyListener(new ModifyListener() {
137:
138: public void modifyText(ModifyEvent e) {
139:
140: if (comboAction.getText().equals("archive")) {
141: textArchiveDir.setEnabled(true);
142: textArchiveFilePattern.setEnabled(true);
143: dialogChanged();
144: } else if (comboAction.getText().equals("delete")) {
145: textArchiveDir.setEnabled(false);
146: textArchiveFilePattern.setEnabled(false);
147: dialogChanged();
148: }
149: }
150:
151: });
152:
153: final Composite compositeAction = new Composite(actionGroup,
154: SWT.NONE);
155: final GridLayout gridLayout_1 = new GridLayout();
156: gridLayout_1.numColumns = 2;
157: compositeAction.setLayout(gridLayout_1);
158: final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER,
159: true, false);
160: gridData_1.heightHint = 62;
161: gridData_1.widthHint = 482;
162: compositeAction.setLayoutData(gridData_1);
163:
164: final Label labelArchiveDir = new Label(compositeAction,
165: SWT.NONE);
166: labelArchiveDir.setText(I18N.getString(Messages.ARC_DIR));
167:
168: textArchiveDir = new Text(compositeAction, SWT.BORDER);
169: final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER,
170: true, false);
171: gridData_2.widthHint = 376;
172: textArchiveDir.setLayoutData(gridData_2);
173: textArchiveDir.addModifyListener(new ModifyListener() {
174: public void modifyText(ModifyEvent e) {
175: dialogChanged();
176: }
177: });
178: textArchiveDir.setEnabled(false);
179:
180: final Label labelArchiveFilePattern = new Label(
181: compositeAction, SWT.NONE);
182: labelArchiveFilePattern.setText(I18N
183: .getString(Messages.ARC_FILE_PAT));
184:
185: textArchiveFilePattern = new Text(compositeAction, SWT.BORDER);
186: textArchiveFilePattern.setLayoutData(new GridData(SWT.FILL,
187: SWT.CENTER, true, false));
188: if (!this .getWizard().isUpdateOperation()) {
189: textArchiveFilePattern.setEnabled(false);
190: }
191: if (this .getWizard().isUpdateOperation()) {
192: modelsToControl();
193: }
194: dialogChanged();
195: }
196:
197: private void dialogChanged() {
198:
199: if (WizardUtil.whetherUseValidation == false) {
200: setPageComplete(true);
201: return;
202: }
203: if (comboAction.getText().equals("archive")) {
204: if (textArchiveDir.getText().equals("")) {
205: updateStatus(I18N.getString(Messages.ARC_DIR_REQ));
206: setPageComplete(false);
207: return;
208: }
209: }
210: setPageComplete(true);
211: updateStatus(null);
212: }
213:
214: private void updateStatus(String message) {
215: setErrorMessage(message);
216: // this.getWizard().canFinish();
217: }
218:
219: @Override
220: public void controlToModels() {
221:
222: FTPPropertyWizard FtpWizard = (FTPPropertyWizard) this
223: .getWizard();
224: if (FtpWizard.getModels() == null)
225: return;
226: try {
227: FTPProvider ftpProvider = FtpWizard.getModels()
228: .getFtpBase().getFtpProvider();
229: ftpProvider.setWriteStyle(ReadStyleType
230: .getByName(comboWriteStyle.getText()));
231:
232: ftpProvider.setCharset(comboCharacterSet.getText());
233:
234: ftpProvider.getFileCompletion().setAction(
235: FileActionType.get(comboAction.getText()));
236: if (comboAction.getText().equals("archive")) {
237: ftpProvider.getFileCompletion().setAction(
238: FileActionType.get(comboAction.getText()));
239:
240: ftpProvider.getFileCompletion().setArchiveDirectory(
241: textArchiveDir.getText());
242: ftpProvider.getFileCompletion().setArchiveFilePattern(
243: textArchiveFilePattern.getText());
244: }
245:
246: } catch (Exception e) {
247: e.printStackTrace();
248: }
249: }
250:
251: public IWizardPage getNextPage() {
252: if (getWizard().getMainPage().isUseCCSL()) {
253: if (this .getWizard().getMainPage().isConsumer()) {
254: return getWizard().getCcslConsumerPage();
255: } else
256: return getWizard().getCcslProviderPage();
257: }
258:
259: return null;
260: }
261:
262: @Override
263: public void modelsToControl() {
264:
265: FTPPropertyWizard FtpWizard = (FTPPropertyWizard) this
266: .getWizard();
267: if (!FtpWizard.isUpdateOperation())
268: return;
269: try {
270: FTPProvider ftpProvider = FtpWizard.getModels()
271: .getFtpBase().getFtpProvider();
272: comboWriteStyle.select(comboWriteStyle.indexOf(ftpProvider
273: .getWriteStyle().getName()));
274: comboCharacterSet.select(comboCharacterSet
275: .indexOf(ftpProvider.getCharset()));
276:
277: comboAction.select(comboAction.indexOf(ftpProvider
278: .getFileCompletion().getAction().getName()));
279: if (ftpProvider.getFileCompletion().getAction().getName()
280: .equals("archive")) {
281: textArchiveDir.setEnabled(true);
282: textArchiveFilePattern.setEnabled(true);
283:
284: if (ftpProvider.getFileCompletion()
285: .getArchiveDirectory() != null)
286: textArchiveDir.setText(ftpProvider
287: .getFileCompletion().getArchiveDirectory());
288: else
289: textArchiveDir.setText("");
290:
291: if (ftpProvider.getFileCompletion()
292: .getArchiveFilePattern() != null)
293: textArchiveFilePattern.setText(ftpProvider
294: .getFileCompletion()
295: .getArchiveFilePattern());
296: else
297: textArchiveFilePattern.setText("");
298:
299: } else {
300: textArchiveDir.setEnabled(false);
301: textArchiveFilePattern.setEnabled(false);
302: }
303: } catch (Exception e) {
304: e.printStackTrace();
305: }
306: }
307: }
|