. Checkpoint of the "Define Web Content Forms" dialog

- Up-to-date with latest wireframes (e.g. removal of scripts, addition of filename path property)
 - List of selected Forms show detail on selected workflow, filepath and templates
 - Form Details button navigates to working Form Details dialog
 - Select Templates button navigates to working Manage Presentation Templates dialog

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4284 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-11-03 18:28:15 +00:00
parent 3730a608ee
commit c6b9543984
12 changed files with 520 additions and 69 deletions

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -50,6 +51,7 @@ import org.alfresco.web.bean.wizard.BaseWizardBean;
import org.alfresco.web.bean.wizard.InviteUsersWizard.UserGroupRole;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.RenderingEngine;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.common.component.UISelectList;
import org.alfresco.web.ui.wcm.WebResources;
@@ -65,6 +67,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
private static final String MSG_DESCRIPTION = "description";
private static final String MSG_NAME = "name";
private static final String MSG_USERROLES = "create_website_summary_users";
private static final String MSG_FORM_SUMMARY = "website_form_summary";
private static final String MSG_NONE = "value_not_set";
private static final String ROLE_CONTENT_MANAGER = "ContentManager";
@@ -108,7 +112,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.title = null;
this.description = null;
this.formsDataModel = null;
this.forms = new ArrayList<FormWrapper>();
this.forms = new ArrayList<FormWrapper>(8);
// init the dependant bean we are using for the invite users pages
InviteWebsiteUsersWizard wiz = getInviteUsersWizard();
@@ -346,7 +350,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
for (Form form : forms)
{
UIListItem item = new UIListItem();
item.setValue(form.getName());
item.setValue(form);
item.setLabel(form.getName());
item.setDescription((String)this.nodeService.getProperty(
form.getNodeRef(), ContentModel.PROP_DESCRIPTION));
@@ -366,7 +370,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
int index = selectList.getRowIndex();
if (index != -1)
{
this.forms.add(new FormWrapper((String)this.formsList.get(index).getValue()));
Form form = (Form)this.formsList.get(index).getValue();
this.forms.add(new FormWrapper(form));
}
}
@@ -670,19 +675,27 @@ public class CreateWebsiteWizard extends BaseWizardBean
*/
public static class FormWrapper
{
private String name;
private Form form;
private String title;
private String description;
private String workflow;
private String filenamePattern;
private List<PresentationTemplate> templates = new ArrayList<PresentationTemplate>(8);
FormWrapper(String name)
FormWrapper(Form form)
{
this.name = name;
this.title = name;
this.form = form;
this.title = form.getName();
}
public Form getForm()
{
return this.form;
}
public String getName()
{
return this.name;
return this.form.getName();
}
public String getTitle()
@@ -705,9 +718,121 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.description = description;
}
/**
* @return Returns the workflow.
*/
public String getWorkflow()
{
return this.workflow;
}
/**
* @param workflow The workflow to set.
*/
public void setWorkflow(String workflow)
{
this.workflow = workflow;
}
/**
* @return Returns the filename pattern.
*/
public String getFilenamePattern()
{
return this.filenamePattern;
}
/**
* @param filenamePattern The filename pattern to set.
*/
public void setFilenamePattern(String filenamePattern)
{
this.filenamePattern = filenamePattern;
}
/**
* @return Returns the presentation templates.
*/
public List<PresentationTemplate> getTemplates()
{
return this.templates;
}
/**
* @param templates The presentation templates to set.
*/
public void setTemplates(List<PresentationTemplate> templates)
{
this.templates = templates;
}
/**
* @return Human readable summary of the configuration for this form
*/
public String getDetails()
{
return "Using workflow 'default-workflow', <none> pre-script, <none> post-script, no templates selected.";
String none = '<' + Application.getMessage(FacesContext.getCurrentInstance(), MSG_NONE) + '>';
return MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_FORM_SUMMARY),
this.workflow != null ? this.workflow : none,
this.filenamePattern != null ? this.filenamePattern : none,
this.templates != null ? this.templates.size() : 0);
}
}
public static class PresentationTemplate
{
private RenderingEngine engine;
private String title;
private String description;
private String filenamePattern;
public PresentationTemplate(RenderingEngine engine, String filenamePattern)
{
this.engine = engine;
this.filenamePattern = filenamePattern;
}
public RenderingEngine getRenderingEngine()
{
return this.engine;
}
public String getTitle()
{
if (this.title == null)
{
this.title = (String)Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getNodeService().getProperty(
engine.getNodeRef(), ContentModel.PROP_NAME);
}
return this.title;
}
public String getDescription()
{
if (this.description == null)
{
this.description = (String)Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getNodeService().getProperty(
engine.getNodeRef(), ContentModel.PROP_DESCRIPTION);
}
return this.description;
}
/**
* @return Returns the filename pattern.
*/
public String getFilenamePattern()
{
return this.filenamePattern;
}
/**
* @param filenamePattern The filename pattern to set.
*/
public void setFilenamePattern(String filenamePattern)
{
this.filenamePattern = filenamePattern;
}
}
}

View File

@@ -21,10 +21,16 @@ import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.bean.TemplateSupportBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.CreateWebsiteWizard.FormWrapper;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,9 +46,8 @@ public class FormDetailsDialog extends BaseDialogBean
private String title;
private String description;
private String preScript;
private String postScript;
private String[] workflowSelectedValue;
private String filenamePattern;
private String[] workflowSelectedValue = {"default"};
/**
@@ -71,6 +76,14 @@ public class FormDetailsDialog extends BaseDialogBean
{
this.websiteWizard = wizard;
}
/**
* @return an object representing the form for the current action
*/
public FormWrapper getActionForm()
{
return this.websiteWizard.getActionForm();
}
/**
* @return Returns the description.
@@ -79,7 +92,7 @@ public class FormDetailsDialog extends BaseDialogBean
{
if (this.description == null)
{
this.description = this.websiteWizard.getActionForm().getDescription();
this.description = getActionForm().getDescription();
}
return this.description;
}
@@ -99,7 +112,7 @@ public class FormDetailsDialog extends BaseDialogBean
{
if (this.title == null)
{
this.title = this.websiteWizard.getActionForm().getTitle();
this.title = getActionForm().getTitle();
}
return this.title;
}
@@ -113,35 +126,23 @@ public class FormDetailsDialog extends BaseDialogBean
}
/**
* @return Returns the post-save Script.
* @return Returns the filename pattern
*/
public String getPostScript()
public String getFilenamePattern()
{
return this.postScript;
if (this.filenamePattern == null)
{
this.filenamePattern = getActionForm().getFilenamePattern();
}
return this.filenamePattern;
}
/**
* @param postScript The post-save Script to set.
* @param pattern The filename pattern to set.
*/
public void setPostScript(String postScript)
public void setFilenamePattern(String pattern)
{
this.postScript = postScript;
}
/**
* @return Returns the pre-save Script.
*/
public String getPreScript()
{
return this.preScript;
}
/**
* @param preScript The pre-save Script to set.
*/
public void setPreScript(String preScript)
{
this.preScript = preScript;
this.filenamePattern = pattern;
}
/**
@@ -160,10 +161,20 @@ public class FormDetailsDialog extends BaseDialogBean
this.workflowSelectedValue = workflowSelectedValue;
}
/**
* @return List of UIListItem object representing the available workflows for the template
*/
public List<UIListItem> getWorkflowList()
{
List<UIListItem> items = new ArrayList<UIListItem>();
UIListItem item = new UIListItem();
item.setValue("default");
item.setLabel("Default");
item.setDescription("Default adhoc workflow");
item.setImage(WebResources.IMAGE_WORKFLOW_32);
items.add(item);
return items;
}
@@ -177,7 +188,24 @@ public class FormDetailsDialog extends BaseDialogBean
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// TODO: push values from title/description etc. back into action FormWrapper!
// push values from title/description etc. back into action FormWrapper
FormWrapper form = getActionForm();
if (this.title != null)
{
form.setTitle(this.title);
}
if (this.description != null)
{
form.setDescription(this.description);
}
if (this.filenamePattern != null)
{
form.setFilenamePattern(this.filenamePattern);
}
if (this.workflowSelectedValue != null && this.workflowSelectedValue.length != 0)
{
form.setWorkflow(this.workflowSelectedValue[0]);
}
return outcome;
}
}

View File

@@ -0,0 +1,186 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.wcm.CreateWebsiteWizard.FormWrapper;
import org.alfresco.web.bean.wcm.CreateWebsiteWizard.PresentationTemplate;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.common.component.UISelectList;
import org.alfresco.web.ui.wcm.WebResources;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.RenderingEngine;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Kevin Roast
*/
public class FormTemplatesDialog extends BaseDialogBean
{
private static final String COMPONENT_TEMPLATELIST = "template-list";
private static final Log logger = LogFactory.getLog(FormTemplatesDialog.class);
protected AVMService avmService;
protected CreateWebsiteWizard websiteWizard;
/** datamodel for table of selected presentation templates */
private DataModel templatesDataModel = null;
/** list of objects describing the selected presentation templates*/
private List<PresentationTemplate> templates = null;
/** transient list of template UIListItem objects */
private List<UIListItem> templateList = null;
/**
* @param avmService The avmService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* @param wizard The Create Website Wizard to set.
*/
public void setCreateWebsiteWizard(CreateWebsiteWizard wizard)
{
this.websiteWizard = wizard;
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map)
*/
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.templatesDataModel = null;
this.templates = new ArrayList<PresentationTemplate>(getActionForm().getTemplates().size());
this.templates.addAll(getActionForm().getTemplates());
}
/**
* @return an object representing the form for the current action
*/
public FormWrapper getActionForm()
{
return this.websiteWizard.getActionForm();
}
public DataModel getTemplatesDataModel()
{
if (this.templatesDataModel == null)
{
this.templatesDataModel = new ListDataModel();
}
this.templatesDataModel.setWrappedData(this.templates);
return this.templatesDataModel;
}
public void setTemplatesDataModel(DataModel templatesDataModel)
{
this.templatesDataModel = templatesDataModel;
}
/**
* @return List of UIListItem objects representing the available presentation templates for selection
*/
public List<UIListItem> getTemplatesList()
{
Form form = getActionForm().getForm();
List<RenderingEngine> engines = form.getRenderingEngines();
List<UIListItem> items = new ArrayList<UIListItem>(engines.size());
for (RenderingEngine engine : engines)
{
PresentationTemplate wrapper = new PresentationTemplate(engine, null);
UIListItem item = new UIListItem();
item.setValue(wrapper);
item.setLabel(wrapper.getTitle());
item.setDescription(wrapper.getDescription());
item.setImage(WebResources.IMAGE_TEMPLATE_32);
items.add(item);
}
this.templateList = items;
return items;
}
/**
* Action handler to add a template to the list for this form
*/
public void addTemplate(ActionEvent event)
{
UISelectList selectList = (UISelectList)event.getComponent().findComponent(COMPONENT_TEMPLATELIST);
int index = selectList.getRowIndex();
if (index != -1)
{
PresentationTemplate template = (PresentationTemplate)this.templateList.get(index).getValue();
// clone the PresentationTemplate into one the user can modify
this.templates.add(new PresentationTemplate(template.getRenderingEngine(), template.getFilenamePattern()));
}
}
/**
* Remove a presentation template from the selected list
*/
public void removeTemplate(ActionEvent event)
{
PresentationTemplate wrapper = (PresentationTemplate)this.templatesDataModel.getRowData();
if (wrapper != null)
{
this.templates.remove(wrapper);
}
}
/**
* @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
{
List<PresentationTemplate> list = getActionForm().getTemplates();
list.clear();
for (PresentationTemplate wrapper : this.templates)
{
list.add(wrapper);
}
return outcome;
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#getFinishButtonDisabled()
*/
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
}

View File

@@ -35,4 +35,5 @@ public class WebResources extends org.alfresco.web.ui.common.WebResources
public static final String IMAGE_LOCK_OWNER = "/images/icons/locked_owner.gif";
public static final String IMAGE_PERSON = "/images/icons/person.gif";
public static final String IMAGE_GROUP = "/images/icons/group.gif";
public static final String IMAGE_WORKFLOW_32 = "/images/icons/workflow_large.gif";
}

View File

@@ -25,4 +25,5 @@ public class WebResources extends org.alfresco.web.ui.repo.WebResources
public static final String IMAGE_SANDBOX_32 = "/images/icons/sandbox_large.gif";
public static final String IMAGE_USERSANDBOX_32 = "/images/icons/user_sandbox_large.gif";
public static final String IMAGE_WEBFORM_32 = "/images/icons/webform_large.gif";
public static final String IMAGE_TEMPLATE_32 = "/images/icons/template_large.gif";
}