mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge from HEAD to WCM-DEV2.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -59,6 +59,11 @@ public abstract class BaseDialogBean implements IDialogBean
|
||||
this.isFinished = false;
|
||||
}
|
||||
|
||||
public void restored()
|
||||
{
|
||||
// do nothing by default, subclasses can override if necessary
|
||||
}
|
||||
|
||||
public String cancel()
|
||||
{
|
||||
return getDefaultCancelOutcome();
|
||||
@@ -126,6 +131,16 @@ public abstract class BaseDialogBean implements IDialogBean
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param browseBean The BrowseBean to set.
|
||||
*/
|
||||
|
@@ -20,11 +20,10 @@ import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DialogManager
|
||||
public final class DialogManager
|
||||
{
|
||||
protected IDialogBean currentDialog;
|
||||
protected DialogConfig currentDialogConfig;
|
||||
protected Map<String, String> currentDialogParams;
|
||||
private DialogState currentDialogState;
|
||||
private Map<String, String> paramsToApply;
|
||||
|
||||
/**
|
||||
* Action handler used to setup parameters for the dialog being launched
|
||||
@@ -38,7 +37,7 @@ public class DialogManager
|
||||
if (component instanceof UIActionLink)
|
||||
{
|
||||
// store the parameters
|
||||
this.currentDialogParams = ((UIActionLink)component).getParameterMap();
|
||||
this.paramsToApply = ((UIActionLink)component).getParameterMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,22 +48,48 @@ public class DialogManager
|
||||
*/
|
||||
public void setCurrentDialog(DialogConfig config)
|
||||
{
|
||||
this.currentDialogConfig = config;
|
||||
|
||||
String beanName = this.currentDialogConfig.getManagedBean();
|
||||
this.currentDialog = (IDialogBean)FacesHelper.getManagedBean(
|
||||
String beanName = config.getManagedBean();
|
||||
IDialogBean dialog = (IDialogBean)FacesHelper.getManagedBean(
|
||||
FacesContext.getCurrentInstance(), beanName);
|
||||
|
||||
if (this.currentDialog == null)
|
||||
if (dialog == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'");
|
||||
}
|
||||
|
||||
// initialise the managed bean
|
||||
this.currentDialog.init(this.currentDialogParams);
|
||||
dialog.init(this.paramsToApply);
|
||||
|
||||
// reset the current parameters so subsequent dialogs don't get them
|
||||
this.currentDialogParams = null;
|
||||
this.paramsToApply = null;
|
||||
|
||||
// create the DialogState object
|
||||
this.currentDialogState = new DialogState(config, dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the currently active dialog
|
||||
*
|
||||
* @return Current dialog's state
|
||||
*/
|
||||
public DialogState getState()
|
||||
{
|
||||
return this.currentDialogState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the dialog represented by the given DialogState object.
|
||||
* NOTE: The dialog's restored() method is also called during this
|
||||
* method.
|
||||
*
|
||||
* @param state The DialogState for the dialog to restore
|
||||
*/
|
||||
public void restoreState(DialogState state)
|
||||
{
|
||||
this.currentDialogState = state;
|
||||
|
||||
// retrieve the dialog and call it's restored() method
|
||||
this.currentDialogState.getDialog().restored();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +99,7 @@ public class DialogManager
|
||||
*/
|
||||
public DialogConfig getCurrentDialog()
|
||||
{
|
||||
return this.currentDialogConfig;
|
||||
return this.currentDialogState.getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +109,7 @@ public class DialogManager
|
||||
*/
|
||||
public IDialogBean getBean()
|
||||
{
|
||||
return this.currentDialog;
|
||||
return this.currentDialogState.getDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +119,7 @@ public class DialogManager
|
||||
*/
|
||||
public String getIcon()
|
||||
{
|
||||
return this.currentDialogConfig.getIcon();
|
||||
return this.currentDialogState.getConfig().getIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +130,7 @@ public class DialogManager
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
this.currentDialogConfig.getErrorMessageId());
|
||||
this.currentDialogState.getConfig().getErrorMessageId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,15 +140,23 @@ public class DialogManager
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
String title = this.currentDialogConfig.getTitleId();
|
||||
// try and get the title directly from the dialog
|
||||
String title = this.currentDialogState.getDialog().getTitle();
|
||||
|
||||
if (title != null)
|
||||
if (title == null)
|
||||
{
|
||||
title = Application.getMessage(FacesContext.getCurrentInstance(), title);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = this.currentDialogConfig.getTitle();
|
||||
// try and get the title via a message bundle key
|
||||
title = this.currentDialogState.getConfig().getTitleId();
|
||||
|
||||
if (title != null)
|
||||
{
|
||||
title = Application.getMessage(FacesContext.getCurrentInstance(), title);
|
||||
}
|
||||
else
|
||||
{
|
||||
// try and get the title from the configuration
|
||||
title = this.currentDialogState.getConfig().getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
return title;
|
||||
@@ -136,15 +169,23 @@ public class DialogManager
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
String desc = this.currentDialogConfig.getDescriptionId();
|
||||
// try and get the description directly from the dialog
|
||||
String desc = this.currentDialogState.getDialog().getDescription();
|
||||
|
||||
if (desc != null)
|
||||
if (desc == null)
|
||||
{
|
||||
desc = Application.getMessage(FacesContext.getCurrentInstance(), desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
desc = this.currentDialogConfig.getDescription();
|
||||
// try and get the description via a message bundle key
|
||||
desc = this.currentDialogState.getConfig().getDescriptionId();
|
||||
|
||||
if (desc != null)
|
||||
{
|
||||
desc = Application.getMessage(FacesContext.getCurrentInstance(), desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
// try and get the description from the configuration
|
||||
desc = this.currentDialogState.getConfig().getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
return desc;
|
||||
@@ -158,7 +199,7 @@ public class DialogManager
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
return this.currentDialogConfig.getActionsConfigId();
|
||||
return this.currentDialogState.getConfig().getActionsConfigId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +209,7 @@ public class DialogManager
|
||||
*/
|
||||
public String getPage()
|
||||
{
|
||||
return this.currentDialogConfig.getPage();
|
||||
return this.currentDialogState.getConfig().getPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +219,7 @@ public class DialogManager
|
||||
*/
|
||||
public boolean isOKButtonVisible()
|
||||
{
|
||||
return this.currentDialogConfig.isOKButtonVisible();
|
||||
return this.currentDialogState.getConfig().isOKButtonVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,10 +232,10 @@ public class DialogManager
|
||||
List<DialogButtonConfig> buttons = null;
|
||||
|
||||
// get a list of buttons to display from the configuration
|
||||
List<DialogButtonConfig> cfgButtons = this.currentDialogConfig.getButtons();
|
||||
List<DialogButtonConfig> cfgButtons = this.currentDialogState.getConfig().getButtons();
|
||||
|
||||
// get a list of buttons added dynamically by the dialog
|
||||
List<DialogButtonConfig> dynButtons = this.currentDialog.getAdditionalButtons();
|
||||
List<DialogButtonConfig> dynButtons = this.currentDialogState.getDialog().getAdditionalButtons();
|
||||
|
||||
if (cfgButtons != null && dynButtons != null)
|
||||
{
|
||||
@@ -223,7 +264,7 @@ public class DialogManager
|
||||
*/
|
||||
public String getCancelButtonLabel()
|
||||
{
|
||||
return this.currentDialog.getCancelButtonLabel();
|
||||
return this.currentDialogState.getDialog().getCancelButtonLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +274,7 @@ public class DialogManager
|
||||
*/
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return this.currentDialog.getFinishButtonLabel();
|
||||
return this.currentDialogState.getDialog().getFinishButtonLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +284,7 @@ public class DialogManager
|
||||
*/
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return this.currentDialog.getFinishButtonDisabled();
|
||||
return this.currentDialogState.getDialog().getFinishButtonDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +294,7 @@ public class DialogManager
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
return this.currentDialog.finish();
|
||||
return this.currentDialogState.getDialog().finish();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,6 +304,6 @@ public class DialogManager
|
||||
*/
|
||||
public String cancel()
|
||||
{
|
||||
return this.currentDialog.cancel();
|
||||
return this.currentDialogState.getDialog().cancel();
|
||||
}
|
||||
}
|
||||
|
53
source/java/org/alfresco/web/bean/dialog/DialogState.java
Normal file
53
source/java/org/alfresco/web/bean/dialog/DialogState.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package org.alfresco.web.bean.dialog;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.config.DialogsConfigElement.DialogConfig;
|
||||
|
||||
/**
|
||||
* Object responsible for holding the current state of an active dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public final class DialogState
|
||||
{
|
||||
private DialogConfig config;
|
||||
private IDialogBean dialog;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param config The configuration for the dialog
|
||||
* @param dialog The dialog bean instance
|
||||
*/
|
||||
public DialogState(DialogConfig config, IDialogBean dialog)
|
||||
{
|
||||
this.config = config;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration for the dialog
|
||||
*
|
||||
* @return The dialog configuration
|
||||
*/
|
||||
public DialogConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bean representing the dialog instance
|
||||
*
|
||||
* @return The dialog bean instance
|
||||
*/
|
||||
public IDialogBean getDialog()
|
||||
{
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return AlfrescoNavigationHandler.DIALOG_PREFIX + this.config.getName();
|
||||
}
|
||||
}
|
@@ -19,6 +19,11 @@ public interface IDialogBean
|
||||
*/
|
||||
public void init(Map<String, String> parameters);
|
||||
|
||||
/**
|
||||
* Called when the dialog is restored after a nested dialog is closed
|
||||
*/
|
||||
public void restored();
|
||||
|
||||
/**
|
||||
* Method handler called when the cancel button of the dialog is pressed
|
||||
*
|
||||
@@ -60,4 +65,22 @@ public interface IDialogBean
|
||||
* @return true if the button should be disabled
|
||||
*/
|
||||
public boolean getFinishButtonDisabled();
|
||||
|
||||
/**
|
||||
* Returns the title to be used for the dialog
|
||||
* <p>If this returns null the DialogManager will
|
||||
* lookup the title via the dialog configuration</p>
|
||||
*
|
||||
* @return The title or null if the title is to be acquired via configuration
|
||||
*/
|
||||
public String getTitle();
|
||||
|
||||
/**
|
||||
* Returns the description to be used for the dialog
|
||||
* <p>If this returns null the DialogManager will
|
||||
* lookup the description via the dialog configuration</p>
|
||||
*
|
||||
* @return The title or null if the title is to be acquired via configuration
|
||||
*/
|
||||
public String getDescription();
|
||||
}
|
||||
|
Reference in New Issue
Block a user