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.util.editor;
025:
026: import java.util.ArrayList;
027:
028: import org.eclipse.core.runtime.IPath;
029: import org.eclipse.jface.viewers.IStructuredSelection;
030: import org.eclipse.jface.wizard.Wizard;
031: import org.eclipse.ui.INewWizard;
032: import org.eclipse.ui.IWorkbench;
033: import org.eclipse.ui.PlatformUI;
034: import org.eclipse.ui.part.EditorPart;
035: import org.eclipse.ui.part.FileEditorInput;
036:
037: public class TestEditorWizard extends Wizard implements INewWizard {
038: @SuppressWarnings("unused")
039: private IStructuredSelection selection;
040:
041: @SuppressWarnings("unused")
042: private IWorkbench workbench;
043:
044: private EditorPart editor;
045:
046: private TestEditorWizardPage mainPage;
047:
048: private IPath projectLocation;
049:
050: private String title = "";
051:
052: private String readStyle = "";
053:
054: private String filePath = "";
055:
056: private ArrayList<String> list;
057:
058: private String root = "";
059:
060: public TestEditorWizard(EditorPart editor, String title,
061: ArrayList<String> list) {
062: this .editor = editor;
063: this .list = list;
064: FileEditorInput fileInput = (FileEditorInput) editor
065: .getEditorInput();
066: projectLocation = fileInput.getFile().getProject()
067: .getLocation();
068: setWindowTitle(title);
069: }
070:
071: public void addPages() {
072: mainPage = new TestEditorWizardPage(title, title, null, list);
073: addPage(mainPage);
074:
075: }
076:
077: /**
078: * (non-Javadoc) Method declared on IWorkbenchWizard
079: */
080: public void init(IWorkbench workbench,
081: IStructuredSelection selection) {
082: this .workbench = workbench;
083: this .selection = selection;
084: }
085:
086: /**
087: * (non-Javadoc) Method declared on IWizard
088: */
089: public boolean performFinish() {
090: filePath = ((TestEditorWizardPage) getPage(title))
091: .getTextFile().getText();
092:
093: if (((TestEditorWizardPage) getPage(title)).getButtonEOF()
094: .getSelection())
095: readStyle = "EOF";
096: else
097: readStyle = "NewLine";
098:
099: if (list != null && list.size() > 0)
100: root = ((TestEditorWizardPage) getPage(title)).getCombo()
101: .getText();
102:
103: return true;
104: }
105:
106: @Override
107: public boolean performCancel() {
108:
109: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
110: .getActivePage().closeEditor(editor, false);
111: return true;
112: }
113:
114: public IPath getProjectLocation() {
115: return projectLocation;
116: }
117:
118: public EditorPart getEditor() {
119: return editor;
120: }
121:
122: public String getFilePath() {
123: return filePath;
124: }
125:
126: public String getReadStyle() {
127: return readStyle;
128: }
129:
130: public String getRoot() {
131: return root;
132: }
133: }
|