Search in sources :

Example 1 with DialogManager

use of org.alfresco.web.bean.dialog.DialogManager 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 DialogManager

use of org.alfresco.web.bean.dialog.DialogManager in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method handleDialogOpen.

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

Aggregations

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