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:
025: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards;
026:
027: import org.eclipse.jface.wizard.IWizardPage;
028: import org.eclipse.swt.SWT;
029: import org.eclipse.swt.layout.GridData;
030: import org.eclipse.swt.layout.GridLayout;
031: import org.eclipse.swt.widgets.Combo;
032: import org.eclipse.swt.widgets.Composite;
033: import org.eclipse.swt.widgets.Label;
034:
035: import com.bostechcorp.cbesb.common.i18n.I18N;
036: import com.bostechcorp.cbesb.common.i18n.Messages;
037: import com.bostechcorp.cbesb.common.util.SystemCharacterEncoding;
038:
039: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FileProvider;
040: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ReadStyleType;
041:
042: public class FilePropertyWizardPageWriteFile extends PropertyWizardPage {
043:
044: private Combo comboCharacterSet;
045:
046: private Combo comboWriteStyle;
047:
048: protected FilePropertyWizardPageWriteFile(String pageName) {
049: super (pageName);
050: setTitle(I18N.getString(Messages.WRITE_MODE_PRO));// "Choose
051: setDescription(I18N.getString(Messages.PAGE_WRITE_FILE_DES));
052:
053: /*
054: * setTitle(I18N.getString(Messages.IDE_CHOOSE_TRN_FILE));// "Choose
055: * setDescription(I18N.getString(Messages.IDE_CHOOSE_TRNFILE_DESC));//
056: * "Choose
057: */
058:
059: }
060:
061: public void createControl(Composite parent) {
062:
063: Composite topLevel = new Composite(parent, SWT.NONE);
064: final GridLayout gridLayout = new GridLayout();
065: gridLayout.numColumns = 2;
066: topLevel.setLayout(gridLayout);
067: topLevel.setLayoutData(new GridData(
068: GridData.VERTICAL_ALIGN_FILL
069: | GridData.HORIZONTAL_ALIGN_FILL));
070: topLevel.setFont(parent.getFont());
071:
072: // super.createControl(parent);
073:
074: //
075: this .setControl(topLevel);
076:
077: final Label labelWriteStyle = new Label(topLevel, SWT.NONE);
078: labelWriteStyle.setText(I18N.getString(Messages.WRI_STYLE));
079:
080: comboWriteStyle = new Combo(topLevel, SWT.READ_ONLY);
081: comboWriteStyle.setLayoutData(new GridData(SWT.FILL,
082: SWT.CENTER, true, false));
083: comboWriteStyle.add("raw");
084: comboWriteStyle.add("newline");
085: if (!this .getWizard().isUpdateOperation())
086: comboWriteStyle.setText("raw");
087:
088: final Label labelCharacterSet = new Label(topLevel, SWT.NONE);
089: labelCharacterSet.setLayoutData(new GridData(SWT.FILL,
090: SWT.FILL, false, false));
091: labelCharacterSet.setText(I18N.getString(Messages.CHAR_SET));
092:
093: comboCharacterSet = new Combo(topLevel, SWT.DROP_DOWN
094: | SWT.READ_ONLY);
095: comboCharacterSet.setLayoutData(new GridData(SWT.FILL,
096: SWT.CENTER, true, false));
097:
098: // comboCharacterSet.setItems(new String[] {"SYSTEM_DEFAULT",
099: // "ISO-8859-1", "USASCII", "UTF-8", "UTF-16BE", "UTF-16LE",
100: // "windows-1252", "EUC-JP", "Shift_JIS", "Big5", "Big5-HKSCS"});
101: comboCharacterSet.setItems(SystemCharacterEncoding
102: .getSupportedCharacterSets());
103:
104: if (!this .getWizard().isUpdateOperation())
105: comboCharacterSet.setText("SYSTEM_DEFAULT");
106:
107: if (this .getWizard().isUpdateOperation()) {
108: modelsToControl();
109: }
110:
111: }
112:
113: @Override
114: public void controlToModels() {
115:
116: FilePropertyWizard fileWizard = (FilePropertyWizard) this
117: .getWizard();
118: if (fileWizard.getModels() == null)
119: return;
120: try {
121: FileProvider fileProvider = fileWizard.getModels()
122: .getFileProvider();
123: fileProvider.setWriteStyle(ReadStyleType
124: .getByName(comboWriteStyle.getText()));
125:
126: fileProvider.setCharset(comboCharacterSet.getText());
127: } catch (Exception e) {
128: e.printStackTrace();
129: }
130: }
131:
132: public IWizardPage getNextPage() {
133: if (getWizard().getMainPage().isUseCCSL()) {
134: if (getWizard().getMainPage().isConsumer()) {
135: return getWizard().getCcslConsumerPage();
136: } else
137: return getWizard().getCcslProviderPage();
138:
139: }
140:
141: return null;
142: }
143:
144: @Override
145: public void modelsToControl() {
146:
147: FilePropertyWizard fileWizard = (FilePropertyWizard) this
148: .getWizard();
149: if (!fileWizard.isUpdateOperation())
150: return;
151: try {
152: comboWriteStyle.select(comboWriteStyle.indexOf(fileWizard
153: .getModels().getFileProvider().getWriteStyle()
154: .getName()));
155: comboCharacterSet.select(comboCharacterSet
156: .indexOf(fileWizard.getModels().getFileProvider()
157: .getCharset()));
158: } catch (Exception e) {
159: e.printStackTrace();
160: }
161: }
162: }
|