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.ui.componentflow.componentFlowEditor.XSLT;
043: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
044: import com.bostechcorp.cbesb.ui.util.browser.BaseFileBrowser;
045:
046: public class XSLTPropertyWizardPageMain extends
047: ServiceEngineWizardPageMain {
048:
049: private Text textXSL;
050:
051: protected XSLTPropertyWizardPageMain(String pageName) {
052: super (pageName);
053: setTitle(I18N.getString(Messages.XSLT_TITLE));// "Choose
054: setDescription(I18N.getString(Messages.WIZARD_ENTER_TIP));
055: }
056:
057: public void createControl(Composite parent) {
058:
059: super .createSubControl(parent, 3);
060:
061: final Label trnFileLabel = new Label(topLevel, SWT.NONE);
062: trnFileLabel.setLayoutData(new GridData());
063: trnFileLabel.setText(I18N.getString(Messages.XSLT_SHEET));
064:
065: textXSL = new Text(topLevel, SWT.READ_ONLY | SWT.BORDER);
066: final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER,
067: true, false);
068: gridData_1.widthHint = 320;
069: textXSL.setLayoutData(gridData_1);
070: textXSL.addModifyListener(new ModifyListener() {
071: public void modifyText(ModifyEvent e) {
072:
073: dialogChanged();
074: }
075: });
076:
077: final Button browseButton = new Button(topLevel, SWT.NONE);
078: final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
079: false, false);
080: gridData.widthHint = 61;
081: browseButton.setLayoutData(gridData);
082: browseButton.setText(I18N.getString(Messages.WIZARD_BROWSE));
083: browseButton.addSelectionListener(new SelectionAdapter() {
084: public void widgetSelected(final SelectionEvent e) {
085: FileEditorInput editorInput = (FileEditorInput) PlatformUI
086: .getWorkbench().getActiveWorkbenchWindow()
087: .getActivePage().getActiveEditor()
088: .getEditorInput();
089: String projectName = editorInput.getFile().getProject()
090: .getName();
091: BaseFileBrowser browser = new BaseFileBrowser(
092: ComponentFlowEditorDiagramEditorPlugin
093: .getInstance(), topLevel.getShell(),
094: textXSL, projectName, ".xsl", "xlate", I18N
095: .getString(Messages.XSLT_SELET_FILE));
096: browser.open();
097: }
098: });
099:
100: if (this .getWizard().isUpdateOperation()) {
101: modelsToControl();
102: }
103: dialogChanged();
104: }
105:
106: protected void dialogChanged() {
107: if (WizardUtil.whetherUseValidation == false) {
108: setPageComplete(true);
109: return;
110: }
111: if (textXSL.getText().equals("")) {
112: updateStatus(I18N.getString(Messages.XSLT_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: XSLTPropertyWizard XSLTWizard = (XSLTPropertyWizard) this
134: .getWizard();
135: XSLT models = XSLTWizard.getModels();
136: if (models == null)
137: return;
138: try {
139:
140: models.setXSLTStyleSheet(textXSL.getText());
141: } catch (Exception e) {
142: e.printStackTrace();
143: }
144: ;
145: }
146:
147: @Override
148: public void modelsToControl() {
149:
150: super .modelsToControl();
151:
152: XSLTPropertyWizard XSLTWizard = (XSLTPropertyWizard) this
153: .getWizard();
154: if (!XSLTWizard.isUpdateOperation())
155: return;
156: try {
157: XSLT models = XSLTWizard.getModels();
158:
159: if (models.getXSLTStyleSheet() != null)
160: textXSL.setText(models.getXSLTStyleSheet());
161: else
162: textXSL.setText("");
163:
164: } catch (Exception e) {
165: e.printStackTrace();
166: }
167: ;
168:
169: }
170:
171: @Override
172: public String getComponentName() {
173: return "XSLT";
174: }
175:
176: }
|