
org.yestech.wizard.BasePhasedScreen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yeswizard Show documentation
Show all versions of yeswizard Show documentation
A framework the allows for wizard flow control
The newest version!
/*
* YES Technology - http://yestech.org
*
* Licensed using GPL Available - http://opensource.org/licenses/gpl-license.php
*
* File name: $RCSfile: $
* Revision: $Revision: $
* Last revised by: $Author: $
* Last revision date: $Date: $
*
* Original Author: Arthur Copeland
*
*/
package org.yestech.wizard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstraction contains UI necessary to navigate the phased process (Previous,
* Next, Finish, and Cancel buttons) and supporting structures for subclassers'
* UI.
*
* @author $Author: $
* @version $Revision: $
*/
public abstract class BasePhasedScreen implements IPhasedScreen
{
//--------------------------------------------------------------------------
// M E M B E R V A R I A B L E S
//--------------------------------------------------------------------------
/**
* Holds the logger
*/
final private static Logger logger = LoggerFactory.getLogger(BasePhasedScreen.class);
private IPhasedEvent event;
/**
* Creates new PhaseFrame.
*
*/
public BasePhasedScreen()
{
}
protected IPhasedEvent getEvent()
{
return event;
}
protected void setEvent(IPhasedEvent event)
{
this.event = event;
}
/**
* Typically, data is retrieved from the Screens UI
* objects and tested for validity.
*
* If all of the data is valid, this should return true
* so that the caller can proceed (usually by storing
* the result somewhere and destroying the screen.)
* Naturally, false should be returned if there is
* any invalid data.
*
* This version in the abstract implementation does nothing and
* generally should be overridden.
*
* @return true
if the data in the dialog is acceptable,
* false
if the data fails to meet validation criteria.
*/
public boolean validateData()
{
// no data in abstract dialog, so this always returns true
return true;
}
/**
* Saves all the Parameter Data for a PhasedScreen and returns the Result
* if there is any.
*
* @return the Saved Data
*/
public abstract Object saveData();
/**
* Implements the action to occur when the Next
button
* is pressed.
*
* The default implementation calls validateData
* and, if the data is valid, then calls saveData
,
* makes the frame invisible, and calls
* dispatcher.phasedProcessHandler(SimpleDispatcher.MSG_NEXT, null);
*
* @see #validateData
* @see #saveData
* @param event
*/
public void nextPressed(IPhasedEvent event)
{
setEvent(event);
if (!validateData())
return;
saveData();
getPhasedProcess().phasedProcessHandler(PhasedEnum.MSG_NEXT, null);
}
private IPhasedProcessor getPhasedProcess()
{
return getEvent().getProcessor();
}
/**
* Implements the action to occur when the Previous button is pressed.
* The default implementation is:
* dispatcher.phasedProcessHandler(PhasedProcess.MSG_PREV, null);
*
* @param event
*/
public void prevPressed(IPhasedEvent event)
{
setEvent(event);
getPhasedProcess().phasedProcessHandler(PhasedEnum.MSG_PREV, null);
}
/**
* Implements the action to occur when the Cancel button
* is pressed
* @param event
*/
public void cancelPressed(IPhasedEvent event)
{
setEvent(event);
getPhasedProcess().phasedProcessHandler(PhasedEnum.MSG_CANCEL, null);
}
/**
* Skip to the given phase.
*
* @param newPhase value identifying the new phase.
*/
public void skipToPhase(int newPhase)
{
setEvent(event);
getPhasedProcess().phasedProcessHandler(PhasedEnum.MSG_SKIP, newPhase);
}
/**
* Implements the action to occur when the Finish button
* is pressed
* @param event
*/
public void finishPressed(IPhasedEvent event)
{
setEvent(event);
if (!validateData())
return;
saveData();
getPhasedProcess().phasedProcessHandler(PhasedEnum.MSG_FINISH, null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy