mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added support for closing multiple dialogs/wizards
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6798 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -60,6 +60,8 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
|||||||
public final static String WIZARD_PREFIX = "wizard" + OUTCOME_SEPARATOR;
|
public final static String WIZARD_PREFIX = "wizard" + OUTCOME_SEPARATOR;
|
||||||
public final static String CLOSE_DIALOG_OUTCOME = DIALOG_PREFIX + "close";
|
public final static String CLOSE_DIALOG_OUTCOME = DIALOG_PREFIX + "close";
|
||||||
public final static String CLOSE_WIZARD_OUTCOME = WIZARD_PREFIX + "close";
|
public final static String CLOSE_WIZARD_OUTCOME = WIZARD_PREFIX + "close";
|
||||||
|
public final static String CLOSE_MULTIPLE_START = "[";
|
||||||
|
public final static String CLOSE_MULTIPLE_END = "]";
|
||||||
public final static String EXTERNAL_CONTAINER_SESSION = "externalDialogContainer";
|
public final static String EXTERNAL_CONTAINER_SESSION = "externalDialogContainer";
|
||||||
|
|
||||||
protected String dialogContainer = null;
|
protected String dialogContainer = null;
|
||||||
@@ -199,6 +201,35 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
|||||||
return closing;
|
return closing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getNumberToClose(String outcome)
|
||||||
|
{
|
||||||
|
int toClose = 1;
|
||||||
|
|
||||||
|
int idxStart = outcome.indexOf(CLOSE_MULTIPLE_START);
|
||||||
|
if (outcome != null && idxStart != -1)
|
||||||
|
{
|
||||||
|
int idxEnd = outcome.indexOf(CLOSE_MULTIPLE_END);
|
||||||
|
if (idxEnd != -1)
|
||||||
|
{
|
||||||
|
String closeNum = outcome.substring(idxStart+1, idxEnd);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
toClose = Integer.parseInt(closeNum);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
logger.warn("Could not determine number of containers to close, defaulting to 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Closing " + toClose + " levels of container");
|
||||||
|
}
|
||||||
|
|
||||||
|
return toClose;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the given fromAction represents a step in the wizard
|
* Determines whether the given fromAction represents a step in the wizard
|
||||||
* i.e. next or back
|
* i.e. next or back
|
||||||
@@ -670,21 +701,48 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
|||||||
{
|
{
|
||||||
// there isn't an overidden outcome so go back to the previous view
|
// there isn't an overidden outcome so go back to the previous view
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Closing " + closingItem + ", going back to previous page");
|
logger.debug("Closing " + closingItem);
|
||||||
|
|
||||||
// if the top of the stack is not a dialog or wizard just get the
|
// determine how many levels of dialog we need to close
|
||||||
// view id and navigate back to it.
|
int numberToClose = getNumberToClose(outcome);
|
||||||
|
|
||||||
// if the top of the stack is a dialog or wizard retrieve the state
|
Object stackObject = null;
|
||||||
// and setup the appropriate manager with that state, then get the
|
if (numberToClose == 1)
|
||||||
// appropriate container page and navigate to it.
|
{
|
||||||
|
// just closing one dialog so get the item from the top of the stack
|
||||||
|
stackObject = getViewStack(context).pop();
|
||||||
|
|
||||||
Object topOfStack = getViewStack(context).pop();
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Popped item from the top of the view stack: " + stackObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check there are enough items on the stack, if there
|
||||||
|
// isn't just get the last one (effectively going back
|
||||||
|
// to the beginning)
|
||||||
|
Stack viewStack = getViewStack(context);
|
||||||
|
int itemsOnStack = viewStack.size();
|
||||||
|
if (itemsOnStack < numberToClose)
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Returning to first item on the view stack as there aren't " +
|
||||||
|
numberToClose + " containers to close!");
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
numberToClose = itemsOnStack;
|
||||||
logger.debug("Popped item from the top of the view stack: " + topOfStack);
|
}
|
||||||
|
|
||||||
String newViewId = getViewIdFromStackObject(context, topOfStack);
|
// pop the right object from the stack
|
||||||
|
for (int x = 1; x <= numberToClose; x++)
|
||||||
|
{
|
||||||
|
stackObject = viewStack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Popped item from the stack: " + stackObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the appropriate view id for the stack object
|
||||||
|
String newViewId = getViewIdFromStackObject(context, stackObject);
|
||||||
|
|
||||||
// go to the appropraite page
|
// go to the appropraite page
|
||||||
goToView(context, newViewId);
|
goToView(context, newViewId);
|
||||||
@@ -748,6 +806,13 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
|||||||
{
|
{
|
||||||
String viewId = null;
|
String viewId = null;
|
||||||
|
|
||||||
|
// if the top of the stack is not a dialog or wizard just get the
|
||||||
|
// view id and navigate back to it.
|
||||||
|
|
||||||
|
// if the top of the stack is a dialog or wizard retrieve the state
|
||||||
|
// and setup the appropriate manager with that state, then get the
|
||||||
|
// appropriate container page and navigate to it.
|
||||||
|
|
||||||
if (topOfStack instanceof String)
|
if (topOfStack instanceof String)
|
||||||
{
|
{
|
||||||
viewId = (String)topOfStack;
|
viewId = (String)topOfStack;
|
||||||
|
Reference in New Issue
Block a user