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.events.SelectionAdapter;
031: import org.eclipse.swt.events.SelectionEvent;
032: import org.eclipse.swt.layout.GridData;
033: import org.eclipse.swt.widgets.Button;
034: import org.eclipse.swt.widgets.Composite;
035: import org.eclipse.swt.widgets.Label;
036: import org.eclipse.swt.widgets.Text;
037: import org.eclipse.ui.PlatformUI;
038: import org.eclipse.ui.part.FileEditorInput;
039:
040: import com.bostechcorp.cbesb.common.i18n.I18N;
041: import com.bostechcorp.cbesb.common.i18n.Messages;
042: import com.bostechcorp.cbesb.common.util.project.ProjectUtil;
043: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.Transformer;
044: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
045: import com.bostechcorp.cbesb.ui.util.browser.BaseFileBrowser;
046:
047: public class TransfomerPropertyWizardPageMain extends
048: ServiceEngineWizardPageMain {
049:
050: private Text textTRN;
051:
052: protected TransfomerPropertyWizardPageMain(String pageName) {
053: super (pageName);
054: setTitle(I18N.getString(Messages.TRANSFORMER_TITLE));// "Choose
055: setDescription(I18N.getString(Messages.DES_WIZ));
056: }
057:
058: public void createControl(Composite parent) {
059:
060: super .createSubControl(parent, 3);
061:
062: final Label trnFileLabel = new Label(topLevel, SWT.NONE);
063: trnFileLabel.setLayoutData(new GridData());
064: trnFileLabel.setText(I18N
065: .getString(Messages.TRANSFORMER_TRN_FILE));
066:
067: textTRN = new Text(topLevel, SWT.READ_ONLY | SWT.BORDER);
068: final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER,
069: true, false);
070: gridData_1.widthHint = 331;
071: textTRN.setLayoutData(gridData_1);
072: textTRN.addModifyListener(new ModifyListener() {
073: public void modifyText(ModifyEvent e) {
074:
075: dialogChanged();
076: }
077: });
078:
079: final Button button = new Button(topLevel, SWT.NONE);
080: final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
081: false, false);
082: gridData.widthHint = 64;
083: button.setLayoutData(gridData);
084: button.addSelectionListener(new SelectionAdapter() {
085: public void widgetSelected(final SelectionEvent e) {
086:
087: String projectName = ProjectUtil.getCurProjectName();
088:
089: BaseFileBrowser browser = new BaseFileBrowser(
090: ComponentFlowEditorDiagramEditorPlugin
091: .getInstance(), topLevel.getShell(),
092: textTRN, projectName, ".trn", "xlate", I18N
093: .getString(Messages.SELECT_TRN_FILE));
094: browser.open();
095: }
096: });
097: button.setText(I18N.getString(Messages.WIZARD_BROWSE));
098:
099: if (this .getWizard().isUpdateOperation()) {
100: modelsToControl();
101: }
102: dialogChanged();
103: }
104:
105: protected void dialogChanged() {
106: if (WizardUtil.whetherUseValidation == false) {
107: setPageComplete(true);
108: return;
109: }
110: if (textTRN.getText().equals("")) {
111: updateStatus(I18N
112: .getString(Messages.TRANSFORMER_TRN_FILE_REQUIRE));
113: setPageComplete(false);
114: return;
115: }
116: super .dialogChanged();
117: }
118:
119: public IWizardPage getNextPage() {
120: if (comboCCSL.getText().equals("true")) {
121:
122: return super .getNextPage();
123: }
124:
125: return null;
126: }
127:
128: @Override
129: public void controlToModels() {
130:
131: super .controlToModels();
132:
133: TransformerPropertyWizard TransformerWizard = (TransformerPropertyWizard) this
134: .getWizard();
135: if (TransformerWizard.getModels() == null)
136: return;
137: try {
138:
139: TransformerWizard.getModels().setTrnFile(textTRN.getText());
140:
141: } catch (Exception e) {
142: e.printStackTrace();
143: }
144: ;
145: }
146:
147: @Override
148: public void modelsToControl() {
149:
150: super .modelsToControl();
151:
152: TransformerPropertyWizard TransformerWizard = (TransformerPropertyWizard) this
153: .getWizard();
154: if (!TransformerWizard.isUpdateOperation())
155: return;
156: try {
157: Transformer models = TransformerWizard.getModels();
158:
159: if (models.getTrnFile() != null)
160: textTRN.setText(models.getTrnFile());
161: else
162: textTRN.setText("");
163:
164: } catch (Exception e) {
165: e.printStackTrace();
166: }
167: ;
168:
169: }
170:
171: @Override
172: public String getComponentName() {
173: return "Transformer";
174: }
175:
176: }
|