mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
First cut of dialog/wizard framework
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2577 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
153
source/java/org/alfresco/web/bean/dialog/DialogManager.java
Normal file
153
source/java/org/alfresco/web/bean/dialog/DialogManager.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package org.alfresco.web.bean.dialog;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.config.DialogsConfigElement.DialogConfig;
|
||||
|
||||
/**
|
||||
* Bean that manages the dialog framework
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DialogManager
|
||||
{
|
||||
protected DialogConfig currentDialogConfig;
|
||||
protected IDialogBean currentDialog;
|
||||
|
||||
/**
|
||||
* Sets the current dialog
|
||||
*
|
||||
* @param config The configuration for the dialog to set
|
||||
*/
|
||||
public void setCurrentDialog(DialogConfig config)
|
||||
{
|
||||
this.currentDialogConfig = config;
|
||||
|
||||
String beanName = this.currentDialogConfig.getManagedBean();
|
||||
this.currentDialog = (IDialogBean)FacesHelper.getManagedBean(
|
||||
FacesContext.getCurrentInstance(), beanName);
|
||||
|
||||
if (this.currentDialog == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'");
|
||||
}
|
||||
|
||||
// initialise the managed bean
|
||||
this.currentDialog.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current dialog bean being managed
|
||||
*
|
||||
* @return The current managed bean
|
||||
*/
|
||||
public IDialogBean getBean()
|
||||
{
|
||||
return this.currentDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to use for the current dialog
|
||||
*
|
||||
* @return The icon
|
||||
*/
|
||||
public String getIcon()
|
||||
{
|
||||
return this.currentDialogConfig.getIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved title to use for the dialog
|
||||
*
|
||||
* @return The title
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
String title = this.currentDialogConfig.getTitleId();
|
||||
|
||||
if (title != null)
|
||||
{
|
||||
title = Application.getMessage(FacesContext.getCurrentInstance(), title);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = this.currentDialogConfig.getTitle();
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved description to use for the dialog
|
||||
*
|
||||
* @return The description
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
String desc = this.currentDialogConfig.getDescriptionId();
|
||||
|
||||
if (desc != null)
|
||||
{
|
||||
desc = Application.getMessage(FacesContext.getCurrentInstance(), desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
desc = this.currentDialogConfig.getDescription();
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page the dialog will use
|
||||
*
|
||||
* @return The page
|
||||
*/
|
||||
public String getPage()
|
||||
{
|
||||
return this.currentDialogConfig.getPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label to use for the finish button
|
||||
*
|
||||
* @return The finish button label
|
||||
*/
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return this.currentDialog.getFinishButtonLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the finish button on the dialog should be disabled
|
||||
*
|
||||
* @return true if the button should be disabled
|
||||
*/
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return this.currentDialog.getFinishButtonDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method handler called when the finish button of the dialog is pressed
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
return this.currentDialog.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method handler called when the cancel button of the dialog is pressed
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String cancel()
|
||||
{
|
||||
return this.currentDialog.cancel();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user