mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
UI related code/jsp fixes and cleanup to new ML space/dialog components.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,213 +46,215 @@ import org.alfresco.web.bean.repository.Node;
|
||||
*/
|
||||
public class MakeMultilingualDialog extends BaseDialogBean
|
||||
{
|
||||
private MultilingualContentService multilingualContentService;
|
||||
|
||||
private MultilingualContentService multilingualContentService;
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
/** if needed, add a new translation with content after this dialog closed */
|
||||
public static final String OPT_ADD_WITH_CONTENT = "ADD_WITH_CONTENT";
|
||||
/** if needed, add a new translation without content after this dialog closed */
|
||||
public static final String OPT_ADD_WITHOUT_CONTENT = "ADD_WITHOUT_CONTENT";
|
||||
|
||||
/** if needed, add a new translation with content after this dialog closed */
|
||||
public static final String OPT_ADD_WITH_CONTENT = "ADD_WITH_CONTENT";
|
||||
/** if needed, add a new translation without content after this dialog closed */
|
||||
public static final String OPT_ADD_WITHOUT_CONTENT = "ADD_WITHOUT_CONTENT";
|
||||
// The author is a mandatory properties
|
||||
private String author;
|
||||
|
||||
// The author is a mandatory properties
|
||||
private String author;
|
||||
// The langage of the node to make multilingual
|
||||
private String language;
|
||||
|
||||
// The langage of the node to make multilingual
|
||||
private String language;
|
||||
// set to true, a new translation will be added at the end of this dialog
|
||||
private boolean addTranslationAfter = true;
|
||||
|
||||
// set to true, a new translation will be added at the end of this dialog
|
||||
private boolean addTranslationAfter = true;
|
||||
// set if the new translation to add will be an empty document or not
|
||||
private String addingMode = OPT_ADD_WITH_CONTENT;
|
||||
|
||||
// set if the new translation to add will be an empty document or not
|
||||
private String addingMode = OPT_ADD_WITH_CONTENT;
|
||||
|
||||
// the node to edit
|
||||
protected Node editableNode;
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// setup the editable node
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
// propose the author and the language of the content for the properties of the MLContainer
|
||||
if(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR) != null)
|
||||
{
|
||||
setAuthor((String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR));
|
||||
}
|
||||
else
|
||||
{
|
||||
setAuthor("");
|
||||
}
|
||||
|
||||
if(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCALIZED) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE) != null)
|
||||
{
|
||||
setLanguage(((Locale) this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE)).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
setLanguage(null);
|
||||
}
|
||||
|
||||
addTranslationAfter = false;
|
||||
addingMode = OPT_ADD_WITH_CONTENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(this.browseBean.getDocument().getNodeRef());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
Locale loc = I18NUtil.parseLocale(getLanguage());
|
||||
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
// make this node multilingual
|
||||
NodeRef mlContainer = multilingualContentService.makeTranslation(nodeRef, loc);
|
||||
|
||||
// set the local of the current node.
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
// if the author of the node is not set, set it with the default author name of
|
||||
// the new ML Container
|
||||
String nodeAuthor = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR);
|
||||
if(nodeAuthor == null || nodeAuthor.length() < 1)
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
|
||||
// set properties of the ml container
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#doPostCommitProcessing(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the document held by the browse bean as it's just been updated
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
// go to the set add translation dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.addTranslationAfter)
|
||||
{
|
||||
if(addingMode.equalsIgnoreCase(OPT_ADD_WITHOUT_CONTENT))
|
||||
{
|
||||
return "dialog:addTranslationWithoutContent";
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTranslationlDialog dialog = (AddTranslationlDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog");
|
||||
dialog.start(null);
|
||||
return "addTranslation";
|
||||
}
|
||||
}
|
||||
// close the dialog
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return !(author != null && author.length() > 0 && language != null);
|
||||
}
|
||||
// the node to edit
|
||||
protected Node editableNode;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
// setup the editable node
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
/**
|
||||
* @return the author of the new created MLContainer
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
/**
|
||||
* @param author the author of new created MLContainer
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
// propose the author and the language of the content for the properties of the MLContainer
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR) != null)
|
||||
{
|
||||
setAuthor((String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR));
|
||||
}
|
||||
else
|
||||
{
|
||||
setAuthor("");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if a new translation must be added after this dialog closes
|
||||
*/
|
||||
public boolean isAddTranslationAfter()
|
||||
{
|
||||
return addTranslationAfter;
|
||||
}
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCALIZED) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE) != null)
|
||||
{
|
||||
setLanguage(((Locale) this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE)).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
setLanguage(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addTranslationAfter set to true, a new translation will be added after this dialog closes
|
||||
*/
|
||||
public void setAddTranslationAfter(boolean addTranslationAfter)
|
||||
{
|
||||
this.addTranslationAfter = addTranslationAfter;
|
||||
}
|
||||
addTranslationAfter = false;
|
||||
addingMode = OPT_ADD_WITH_CONTENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(this.browseBean.getDocument().getNodeRef());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
Locale loc = I18NUtil.parseLocale(getLanguage());
|
||||
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
// make this node multilingual
|
||||
NodeRef mlContainer = multilingualContentService.makeTranslation(nodeRef, loc);
|
||||
|
||||
// set the local of the current node.
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
// if the author of the node is not set, set it with the default author name of
|
||||
// the new ML Container
|
||||
String nodeAuthor = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR);
|
||||
if (nodeAuthor == null || nodeAuthor.length() < 1)
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
|
||||
// set properties of the ml container
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#doPostCommitProcessing(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the document held by the browse bean as it's just been updated
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
// go to the set add translation dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.addTranslationAfter)
|
||||
{
|
||||
if(addingMode.equalsIgnoreCase(OPT_ADD_WITHOUT_CONTENT))
|
||||
{
|
||||
return "dialog:addTranslationWithoutContent";
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTranslationlDialog dialog = (AddTranslationlDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog");
|
||||
dialog.start(null);
|
||||
return "addTranslation";
|
||||
}
|
||||
}
|
||||
|
||||
// close the dialog
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return !(author != null && author.length() > 0 && language != null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the language of the translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* @param language the language of the translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editableNode the node will become a multilingual
|
||||
*/
|
||||
public void setEditableNode(Node editableNode)
|
||||
{
|
||||
this.editableNode = editableNode;
|
||||
}
|
||||
/**
|
||||
* @return the author of the new created MLContainer
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author of new created MLContainer
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if a new translation must be added after this dialog closes
|
||||
*/
|
||||
public boolean isAddTranslationAfter()
|
||||
{
|
||||
return addTranslationAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addTranslationAfter set to true, a new translation will be added after this dialog closes
|
||||
*/
|
||||
public void setAddTranslationAfter(boolean addTranslationAfter)
|
||||
{
|
||||
this.addTranslationAfter = addTranslationAfter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the language of the translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the language of the translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editableNode the node will become a multilingual
|
||||
*/
|
||||
public void setEditableNode(Node editableNode)
|
||||
{
|
||||
this.editableNode = editableNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the new translation must be added at the end of this dialog,
|
||||
* this mode defines if the translation will be an empty document or not
|
||||
*/
|
||||
public String getAddingMode() {
|
||||
public String getAddingMode()
|
||||
{
|
||||
return addingMode;
|
||||
}
|
||||
|
||||
@@ -260,7 +262,8 @@ public class MakeMultilingualDialog extends BaseDialogBean
|
||||
* @param addingMode if the new translation must be added at the end of this dialog,
|
||||
* this mode defines if the translation will be an empty document or not
|
||||
*/
|
||||
public void setAddingMode(String addingMode) {
|
||||
public void setAddingMode(String addingMode)
|
||||
{
|
||||
this.addingMode = addingMode;
|
||||
}
|
||||
|
||||
@@ -273,16 +276,13 @@ public class MakeMultilingualDialog extends BaseDialogBean
|
||||
}
|
||||
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user