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.DecorativeModelElement;
036: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditor;
037:
038: public abstract class DecorativePropertyWizard extends Wizard {
039: private boolean added = false;
040:
041: private boolean updated = false;
042:
043: private DecorativeModelElement modelElement = null;
044:
045: private EditPart editPart = null;
046:
047: /** Constructor for the BaseWizard object */
048: public DecorativePropertyWizard() {
049: this .setNeedsProgressMonitor(true);
050: }
051:
052: public DecorativeModelElement getModels() {
053: return modelElement;
054: }
055:
056: public void setAddedOperation(DecorativeModelElement model) {
057: modelElement = model;
058: updated = false;
059: added = true;
060: }
061:
062: public void setUpdateOperation(DecorativeModelElement model) {
063: modelElement = model;
064: updated = true;
065: added = false;
066: }
067:
068: public void setUpdateOperation(DecorativeModelElement model,
069: EditPart editPart) {
070: modelElement = model;
071: updated = true;
072: added = false;
073: this .editPart = editPart;
074: }
075:
076: public boolean isAddOperation() {
077: return added;
078: }
079:
080: public boolean isUpdateOperation() {
081: return updated;
082: }
083:
084: /**
085: * Description of the Method
086: *
087: * @return Description of the Return Value
088: */
089: public boolean performFinish() {
090: for (IWizardPage wizardPage : this .getPages()) {
091: DecorativePropertyWizardPage page = (DecorativePropertyWizardPage) wizardPage;
092: page.controlToModels();
093: }
094: ((ComponentFlowEditorDiagramEditor) PlatformUI.getWorkbench()
095: .getActiveWorkbenchWindow().getActivePage()
096: .getActiveEditor()).setDirty(true);
097: ((ComponentFlowEditorDiagramEditor) PlatformUI.getWorkbench()
098: .getActiveWorkbenchWindow().getActivePage()
099: .getActiveEditor()).getPropertySheetPage().refresh();
100:
101: new IWorkspaceRunnable() {
102: public void run(IProgressMonitor monitor)
103: throws CoreException, OperationCanceledException {
104: try {
105: finishPage(monitor);
106: } catch (InterruptedException e) {
107: throw new OperationCanceledException(e.getMessage());
108: }
109: }
110: };
111: return true;
112: }
113:
114: /*
115: * (non-Javadoc)
116: *
117: * @see org.eclipse.jface.wizard.Wizard#canFinish()
118: */
119: public boolean canFinish() {
120:
121: if (getContainer().getCurrentPage() != null) {
122: if (((DecorativePropertyWizardPage) getContainer()
123: .getCurrentPage()).getNextPage() == null) {
124: if (((DecorativePropertyWizardPage) getContainer()
125: .getCurrentPage()).isPageComplete()) {
126: return true;
127: }
128: }
129: }
130: return false;
131: }
132:
133: /**
134: * Subclasses should override to perform the actions of the wizard. This
135: * method is run in the wizard container's context as a workspace runnable.
136: *
137: * @param monitor
138: * Description of the Parameter
139: * @exception InterruptedException
140: * Description of the Exception
141: * @exception CoreException
142: * Description of the Exception
143: */
144: protected void finishPage(IProgressMonitor monitor)
145: throws InterruptedException, CoreException {
146: }
147:
148: public EditPart getEditPart() {
149: return editPart;
150: }
151:
152: public void setEditPart(EditPart editPart) {
153: this.editPart = editPart;
154: }
155:
156: }
|