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.Composite;
033: import org.eclipse.swt.widgets.Label;
034: import org.eclipse.swt.widgets.Text;
035:
036: import com.bostechcorp.cbesb.common.i18n.I18N;
037: import com.bostechcorp.cbesb.common.i18n.Messages;
038: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FileProvider;
039:
040: public class FilePropertyWizardWritePageProperty extends
041: PropertyWizardPage {
042:
043: private Text textFilePattern;
044:
045: private Text textStageDir;
046:
047: private Text textDestinationDirectory;
048:
049: protected FilePropertyWizardWritePageProperty(String pageName) {
050: super (pageName);
051: setTitle(I18N.getString(Messages.WRITE_MODE_PRO));// "Choose
052: setDescription(I18N.getString(Messages.WRITE_PAGE_PRO_DES));
053: }
054:
055: public void createControl(Composite parent) {
056:
057: Composite topLevel = new Composite(parent, SWT.NONE);
058: final GridLayout gridLayout = new GridLayout();
059: gridLayout.numColumns = 2;
060: topLevel.setLayout(gridLayout);
061: topLevel.setLayoutData(new GridData(
062: GridData.VERTICAL_ALIGN_FILL
063: | GridData.HORIZONTAL_ALIGN_FILL));
064: topLevel.setFont(parent.getFont());
065:
066: this .setControl(topLevel);
067:
068: final Label labelDestinationDir = new Label(topLevel, SWT.NONE);
069: labelDestinationDir
070: .setText(I18N.getString(Messages.DESTIN_DIR));
071:
072: textDestinationDirectory = new Text(topLevel, SWT.BORDER);
073: textDestinationDirectory
074: .addModifyListener(new ModifyListener() {
075: public void modifyText(ModifyEvent e) {
076: dialogChanged();
077: }
078: });
079: textDestinationDirectory.setLayoutData(new GridData(SWT.FILL,
080: SWT.CENTER, true, false));
081:
082: final Label labelStageDir = new Label(topLevel, SWT.NONE);
083: labelStageDir.setText(I18N.getString(Messages.STA_DIR));
084:
085: textStageDir = new Text(topLevel, SWT.BORDER);
086: textStageDir.addModifyListener(new ModifyListener() {
087: public void modifyText(ModifyEvent e) {
088: dialogChanged();
089: }
090: });
091: textStageDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
092: true, false));
093:
094: final Label labelFilePattern = new Label(topLevel, SWT.NONE);
095: labelFilePattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
096: false, false));
097: labelFilePattern.setText(I18N.getString(Messages.FILE_PAT));
098:
099: textFilePattern = new Text(topLevel, SWT.BORDER);
100: textFilePattern.addModifyListener(new ModifyListener() {
101: public void modifyText(ModifyEvent e) {
102: dialogChanged();
103: }
104: });
105: textFilePattern.setLayoutData(new GridData(SWT.FILL,
106: SWT.CENTER, true, false));
107: if (this .getWizard().isUpdateOperation()) {
108: modelsToControl();
109: }
110:
111: dialogChanged();
112: }
113:
114: @Override
115: public void controlToModels() {
116:
117: FilePropertyWizard fileWizard = (FilePropertyWizard) this
118: .getWizard();
119: if (fileWizard.getModels() == null)
120: return;
121: try {
122: FileProvider fileProvider = fileWizard.getModels()
123: .getFileProvider();
124: fileProvider.setDestDir(textDestinationDirectory.getText());
125: fileProvider.setStageDir(textStageDir.getText());
126: fileProvider.setFilePattern(textFilePattern.getText());
127: } catch (Exception e) {
128: e.printStackTrace();
129: }
130: }
131:
132: private void dialogChanged() {
133: if (WizardUtil.whetherUseValidation == false) {
134: setPageComplete(true);
135: return;
136: }
137: if (textDestinationDirectory.getText().equals("")) {
138: updateStatus(I18N.getString(Messages.DESTIN_DIR_REQ));
139: setPageComplete(false);
140: return;
141: } else if (textStageDir.getText().equals("")) {
142: updateStatus(I18N.getString(Messages.STAGE_DIR_REQ));
143: setPageComplete(false);
144: return;
145: } else if (textFilePattern.getText().equals("")) {
146: updateStatus(I18N.getString(Messages.FILE_PAT_REQ));
147: setPageComplete(false);
148: return;
149: }
150: setPageComplete(true);
151: updateStatus(null);
152: }
153:
154: private void updateStatus(String message) {
155: setErrorMessage(message);
156: }
157:
158: public IWizardPage getNextPage() {
159:
160: return super .getNextPage();
161: }
162:
163: @Override
164: public void modelsToControl() {
165:
166: FilePropertyWizard fileWizard = (FilePropertyWizard) this
167: .getWizard();
168: try {
169: FileProvider fileProvider = fileWizard.getModels()
170: .getFileProvider();
171: if (fileProvider.getDestDir() != null)
172: textDestinationDirectory.setText(fileProvider
173: .getDestDir());
174: else
175: textDestinationDirectory.setText("");
176:
177: if (fileProvider.getDestDir() != null)
178: textFilePattern.setText(fileProvider.getFilePattern());
179: else
180: textFilePattern.setText("");
181:
182: if (fileProvider.getStageDir() != null)
183: textStageDir.setText(fileProvider.getStageDir());
184: else
185: textStageDir.setText("");
186: } catch (Exception e) {
187: e.printStackTrace();
188: }
189: }
190: }
|