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.core.resources.IWorkspaceRunnable;
027: import org.eclipse.core.runtime.CoreException;
028: import org.eclipse.core.runtime.IProgressMonitor;
029: import org.eclipse.core.runtime.OperationCanceledException;
030: import org.eclipse.gef.EditPart;
031: import org.eclipse.jface.wizard.IWizardPage;
032: import org.eclipse.jface.wizard.Wizard;
033: import org.eclipse.ui.PlatformUI;
034:
035: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.BindingComponent;
036: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ComponentFlowEditorElement;
037: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditor;
038:
039: public abstract class PropertyWizard extends Wizard {
040: protected boolean added = false;
041:
042: private boolean updated = false;
043:
044: private ComponentFlowEditorElement modelElement = null;
045:
046: private EditPart editPart = null;
047:
048: protected BaseWizardPageCCSLConsumerProperty ccslConsumerPage;
049:
050: protected BaseWizardPageCCSLProviderProperty ccslProviderPage;
051:
052: abstract public PropertyWizardPageMain getMainPage();
053:
054: /** Constructor for the BaseWizard object */
055: public PropertyWizard() {
056: this .setNeedsProgressMonitor(true);
057: }
058:
059: public ComponentFlowEditorElement getModels() {
060: return modelElement;
061: }
062:
063: public void setAddedOperation(ComponentFlowEditorElement model) {
064: modelElement = model;
065: updated = false;
066: added = true;
067: }
068:
069: public void setUpdateOperation(ComponentFlowEditorElement model) {
070: modelElement = model;
071: updated = true;
072: added = false;
073: }
074:
075: public void setUpdateOperation(ComponentFlowEditorElement model,
076: EditPart editPart) {
077: modelElement = model;
078: updated = true;
079: added = false;
080: this .editPart = editPart;
081: }
082:
083: public boolean isAddOperation() {
084: return added;
085: }
086:
087: public boolean isUpdateOperation() {
088: return updated;
089: }
090:
091: /**
092: * Description of the Method
093: *
094: * @return Description of the Return Value
095: */
096: public boolean performFinish() {
097: for (IWizardPage wizardPage : this .getPages()) {
098: PropertyWizardPage page = (PropertyWizardPage) wizardPage;
099: page.controlToModels();
100: }
101: ((ComponentFlowEditorDiagramEditor) PlatformUI.getWorkbench()
102: .getActiveWorkbenchWindow().getActivePage()
103: .getActiveEditor()).setDirty(true);
104: ((ComponentFlowEditorDiagramEditor) PlatformUI.getWorkbench()
105: .getActiveWorkbenchWindow().getActivePage()
106: .getActiveEditor()).getPropertySheetPage().refresh();
107:
108: IWorkspaceRunnable op = new IWorkspaceRunnable() {
109: public void run(IProgressMonitor monitor)
110: throws CoreException, OperationCanceledException {
111: try {
112: finishPage(monitor);
113: } catch (InterruptedException e) {
114: throw new OperationCanceledException(e.getMessage());
115: }
116: }
117: };
118: return true;
119: }
120:
121: /*
122: * (non-Javadoc)
123: *
124: * @see org.eclipse.jface.wizard.Wizard#canFinish()
125: */
126: public boolean canFinish() {
127:
128: if (getContainer().getCurrentPage() != null) {
129: if (((PropertyWizardPage) getContainer().getCurrentPage())
130: .getNextPage() == null) {
131: if (((PropertyWizardPage) getContainer()
132: .getCurrentPage()).isPageComplete()) {
133: return true;
134: }
135: }
136: }
137: return false;
138: }
139:
140: /**
141: * Subclasses should override to perform the actions of the wizard. This
142: * method is run in the wizard container's context as a workspace runnable.
143: *
144: * @param monitor
145: * Description of the Parameter
146: * @exception InterruptedException
147: * Description of the Exception
148: * @exception CoreException
149: * Description of the Exception
150: */
151: protected void finishPage(IProgressMonitor monitor)
152: throws InterruptedException, CoreException {
153: }
154:
155: public EditPart getEditPart() {
156: return editPart;
157: }
158:
159: public void setEditPart(EditPart editPart) {
160: this .editPart = editPart;
161: }
162:
163: // private boolean flag = true;
164: public void addPages() {
165: if (modelElement instanceof BindingComponent) {
166: ccslConsumerPage = new BaseWizardPageCCSLConsumerProperty(
167: "CCSLConsumerProperty");
168: addPage(ccslConsumerPage);
169: }
170: ccslProviderPage = new BaseWizardPageCCSLProviderProperty(
171: "CCSLProviderProperty");
172: addPage(ccslProviderPage);
173:
174: }
175:
176: public BaseWizardPageCCSLConsumerProperty getCcslConsumerPage() {
177: return ccslConsumerPage;
178: }
179:
180: public BaseWizardPageCCSLProviderProperty getCcslProviderPage() {
181: return ccslProviderPage;
182: }
183:
184: }
|