001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.wizard;
015:
016: import org.jetbrains.annotations.NotNull;
017: import org.jetbrains.annotations.Nullable;
018:
019: import java.util.LinkedHashSet;
020:
021: /**
022: * User: Martin
023: * Date: 20.01.2006
024: * Time: 09:21:00
025: */
026: public abstract class AbstractWizardPage implements WizardPage {
027: @NotNull
028: private LinkedHashSet<WizardPageListener> wizardPageListeners;
029:
030: @Nullable
031: private WizardPage previousWizardPage;
032: @Nullable
033: private WizardPage nextWizardPage;
034: @NotNull
035: private WizardDialog wizardDialog;
036:
037: public AbstractWizardPage() {
038: wizardPageListeners = new LinkedHashSet<WizardPageListener>();
039: }
040:
041: @NotNull
042: public WizardDialog getWizardDialog() {
043: return wizardDialog;
044: }
045:
046: public void setWizardDialog(@NotNull
047: WizardDialog wizardDialog) {
048: this .wizardDialog = wizardDialog;
049: }
050:
051: public void setPrevious(@Nullable
052: WizardPage previousWizardPage) {
053: this .previousWizardPage = previousWizardPage;
054: }
055:
056: public void setNext(@Nullable
057: WizardPage nextWizardPage) {
058: this .nextWizardPage = nextWizardPage;
059: }
060:
061: @Nullable
062: public WizardPage getPrevious() {
063: return previousWizardPage;
064: }
065:
066: @Nullable
067: public WizardPage getNext() {
068: return nextWizardPage;
069: }
070:
071: public boolean hasNext() {
072: return nextWizardPage != null;
073: }
074:
075: public boolean canNext() {
076: return nextWizardPage != null;
077: }
078:
079: public boolean hasPrevious() {
080: return previousWizardPage != null;
081: }
082:
083: public boolean canPrevious() {
084: return previousWizardPage != null;
085: }
086:
087: public boolean canCancel() {
088: return true;
089: }
090:
091: public boolean canFinish() {
092: return true;
093: }
094:
095: public void addWizardPageListener(@NotNull
096: WizardPageListener wizardPageListener) {
097: wizardPageListeners.add(wizardPageListener);
098: }
099:
100: public void removeWizardPageListener(@NotNull
101: WizardPageListener wizardPageListener) {
102: wizardPageListeners.remove(wizardPageListener);
103: }
104:
105: protected void fireWizardPageStateChanged() {
106: LinkedHashSet<WizardPageListener> set = new LinkedHashSet<WizardPageListener>(
107: wizardPageListeners);
108:
109: for (WizardPageListener wizardPageListener : set) {
110: wizardPageListener.stateChanged();
111: }
112: }
113: }
|