Search in sources :

Example 1 with WizardManager

use of org.alfresco.web.bean.wizard.WizardManager in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method addCurrentViewToStack.

/**
 * Adds the current view to the stack (if required).
 * If the current view is already the top of the stack it is not added again
 * to stop the stack from growing and growing.
 *
 * @param context FacesContext
 */
@SuppressWarnings("unchecked")
protected void addCurrentViewToStack(FacesContext context) {
    // if the current viewId is either the dialog or wizard container page
    // we need to save the state of the current dialog or wizard to the stack
    // If the current view is a normal page and it is not the same as the
    // view currently at the top of the stack (you can't launch a dialog from
    // the same page 2 times in a row so it must mean the user navigated away
    // from the first dialog) just add the viewId to the stack
    // work out what to add to the stack
    String viewId = context.getViewRoot().getViewId();
    String dialogContainer = getDialogContainer(context);
    String wizardContainer = getWizardContainer(context);
    Object objectForStack = null;
    if (viewId.equals(dialogContainer)) {
        DialogManager dlgMgr = Application.getDialogManager();
        objectForStack = dlgMgr.getState();
    } else if (viewId.equals(wizardContainer)) {
        WizardManager wizMgr = Application.getWizardManager();
        objectForStack = wizMgr.getState();
    } else {
        objectForStack = viewId;
    }
    // if the stack is currently empty add the item
    Stack stack = getViewStack(context);
    if (stack.empty()) {
        stack.push(objectForStack);
        if (logger.isDebugEnabled())
            logger.debug("Pushed item to view stack: " + objectForStack);
    } else {
        // if the item to go on to the stack and the top of
        // stack are both Strings and equals to each other
        // don't add anything to the stack to stop it
        // growing unecessarily
        Object topOfStack = stack.peek();
        if (objectForStack instanceof String && topOfStack instanceof String && topOfStack.equals(objectForStack)) {
            if (logger.isDebugEnabled())
                logger.debug("current view is already top of the view stack!");
        } else {
            stack.push(objectForStack);
            if (logger.isDebugEnabled())
                logger.debug("Pushed item to view stack: " + objectForStack);
        }
    }
}
Also used : DialogManager(org.alfresco.web.bean.dialog.DialogManager) WizardManager(org.alfresco.web.bean.wizard.WizardManager) Stack(java.util.Stack)

Example 2 with WizardManager

use of org.alfresco.web.bean.wizard.WizardManager in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method handleWizardOpen.

/**
 * Opens a wizard
 *
 * @param context FacesContext
 * @param fromAction The fromAction
 * @param name The name of the wizard to open
 */
protected void handleWizardOpen(FacesContext context, String fromAction, String name) {
    if (logger.isDebugEnabled())
        logger.debug("Opening wizard '" + name + "'");
    // firstly add the current view to the stack so we know where to go back to
    addCurrentViewToStack(context);
    WizardConfig wizard = getWizardConfig(context, name, getDispatchContextNode(context));
    if (wizard != null) {
        if (logger.isDebugEnabled())
            logger.debug("Found config for wizard '" + name + "': " + wizard);
        // set the wizard manager up with the retrieved config
        WizardManager wizardManager = Application.getWizardManager();
        wizardManager.setCurrentWizard(wizard);
        // retrieve the container page and navigate to it
        goToView(context, getWizardContainer(context));
    } else {
        // logger.warn("Failed to find configuration for wizard '" + name + "'");
        // send the dialog name as the outcome to the original handler
        handleDispatch(context, fromAction, name);
    }
}
Also used : WizardManager(org.alfresco.web.bean.wizard.WizardManager) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig)

Aggregations

WizardManager (org.alfresco.web.bean.wizard.WizardManager)2 Stack (java.util.Stack)1 DialogManager (org.alfresco.web.bean.dialog.DialogManager)1 WizardConfig (org.alfresco.web.config.WizardsConfigElement.WizardConfig)1