mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,83 +1,83 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a category selector component.
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class AjaxTagPickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_AJAX_TAG_PICKER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
// the category selector component is used whatever mode the property sheet is in
|
||||
return generate(context, item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _selected id suffix.
|
||||
// We also enable real time so the page load check disabled
|
||||
// the ok button if necessary, as the control is used the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_selected");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ControlType getControlType()
|
||||
{
|
||||
return ControlType.SELECTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UIComponent setupMultiValuePropertyIfNecessary(
|
||||
FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem property, PropertyDefinition propertyDef,
|
||||
UIComponent component)
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a category selector component.
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class AjaxTagPickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_AJAX_TAG_PICKER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
// the category selector component is used whatever mode the property sheet is in
|
||||
return generate(context, item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _selected id suffix.
|
||||
// We also enable real time so the page load check disabled
|
||||
// the ok button if necessary, as the control is used the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_selected");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ControlType getControlType()
|
||||
{
|
||||
return ControlType.SELECTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UIComponent setupMultiValuePropertyIfNecessary(
|
||||
FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem property, PropertyDefinition propertyDef,
|
||||
UIComponent component)
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,64 +1,64 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to manage associations.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AssociationGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String optionsSize = null;
|
||||
|
||||
public String getAvailableOptionsSize()
|
||||
{
|
||||
return this.optionsSize;
|
||||
}
|
||||
|
||||
public void setAvailableOptionsSize(String optionsSize)
|
||||
{
|
||||
this.optionsSize = optionsSize;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_ASSOC_EDITOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
// set the size of the list (if provided)
|
||||
if (this.optionsSize != null)
|
||||
{
|
||||
component.getAttributes().put("availableOptionsSize", this.optionsSize);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
// Only so this however id the component is not read-only
|
||||
|
||||
if (item.isReadOnly() == false)
|
||||
{
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to manage associations.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AssociationGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String optionsSize = null;
|
||||
|
||||
public String getAvailableOptionsSize()
|
||||
{
|
||||
return this.optionsSize;
|
||||
}
|
||||
|
||||
public void setAvailableOptionsSize(String optionsSize)
|
||||
{
|
||||
this.optionsSize = optionsSize;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_ASSOC_EDITOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
// set the size of the list (if provided)
|
||||
if (this.optionsSize != null)
|
||||
{
|
||||
component.getAttributes().put("availableOptionsSize", this.optionsSize);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
// Only so this however id the component is not read-only
|
||||
|
||||
if (item.isReadOnly() == false)
|
||||
{
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,71 +1,71 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a category selector component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CategorySelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_CATEGORY_SELECTOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
// the category selector component is used whatever mode the property sheet is in
|
||||
return generate(context, item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _selected id suffix.
|
||||
// We also enable real time so the page load check disabled
|
||||
// the ok button if necessary, as the control is used the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_selected");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ControlType getControlType()
|
||||
{
|
||||
return ControlType.SELECTOR;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a category selector component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CategorySelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_CATEGORY_SELECTOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
// the category selector component is used whatever mode the property sheet is in
|
||||
return generate(context, item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _selected id suffix.
|
||||
// We also enable real time so the page load check disabled
|
||||
// the ok button if necessary, as the control is used the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_selected");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ControlType getControlType()
|
||||
{
|
||||
return ControlType.SELECTOR;
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.common.converter.BooleanLabelConverter;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a checkbox component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CheckboxGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_SELECT_BOOLEAN);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_CHECKBOX);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propertySheet.inEditMode() == false)
|
||||
{
|
||||
// if there isn't a custom converter add the boolean
|
||||
// converter as a default
|
||||
createAndSetConverter(context, BooleanLabelConverter.CONVERTER_ID,
|
||||
component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// a checkbox will always have one value or another so there
|
||||
// is no need to create a mandatory validation rule
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.common.converter.BooleanLabelConverter;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a checkbox component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CheckboxGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_SELECT_BOOLEAN);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_CHECKBOX);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propertySheet.inEditMode() == false)
|
||||
{
|
||||
// if there isn't a custom converter add the boolean
|
||||
// converter as a default
|
||||
createAndSetConverter(context, BooleanLabelConverter.CONVERTER_ID,
|
||||
component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// a checkbox will always have one value or another so there
|
||||
// is no need to create a mandatory validation rule
|
||||
}
|
||||
}
|
||||
|
@@ -1,64 +1,64 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to manage child associations.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class ChildAssociationGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String optionsSize = null;
|
||||
|
||||
public String getAvailableOptionsSize()
|
||||
{
|
||||
return this.optionsSize;
|
||||
}
|
||||
|
||||
public void setAvailableOptionsSize(String optionsSize)
|
||||
{
|
||||
this.optionsSize = optionsSize;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_CHILD_ASSOC_EDITOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
// set the size of the list (if provided)
|
||||
if (this.optionsSize != null)
|
||||
{
|
||||
component.getAttributes().put("availableOptionsSize", this.optionsSize);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
// But only do this if the component is not read-only
|
||||
|
||||
if (item.isReadOnly() == false)
|
||||
{
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to manage child associations.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class ChildAssociationGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String optionsSize = null;
|
||||
|
||||
public String getAvailableOptionsSize()
|
||||
{
|
||||
return this.optionsSize;
|
||||
}
|
||||
|
||||
public void setAvailableOptionsSize(String optionsSize)
|
||||
{
|
||||
this.optionsSize = optionsSize;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_CHILD_ASSOC_EDITOR);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
// set the size of the list (if provided)
|
||||
if (this.optionsSize != null)
|
||||
{
|
||||
component.getAttributes().put("availableOptionsSize", this.optionsSize);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
// But only do this if the component is not read-only
|
||||
|
||||
if (item.isReadOnly() == false)
|
||||
{
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,185 +1,185 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.common.converter.XMLDateConverter;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a date picker component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DatePickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private boolean initialiseIfNull = false;
|
||||
private int yearCount = 30;
|
||||
private int startYear = Calendar.getInstance().get(Calendar.YEAR) + 2;
|
||||
private String noneLabel = null;
|
||||
|
||||
private static final String MSG_DATE = "date_pattern";
|
||||
|
||||
/**
|
||||
* @return Returns the year to start counting back from
|
||||
*/
|
||||
public int getStartYear()
|
||||
{
|
||||
return startYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startYear Sets the year to start counting back from
|
||||
*/
|
||||
public void setStartYear(int startYear)
|
||||
{
|
||||
this.startYear = startYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the number of years to show
|
||||
*/
|
||||
public int getYearCount()
|
||||
{
|
||||
return yearCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param yearCount Sets the number of years to show
|
||||
*/
|
||||
public void setYearCount(int yearCount)
|
||||
{
|
||||
this.yearCount = yearCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Determines whether the control should initially show
|
||||
* today's date if the model value is null
|
||||
*/
|
||||
public boolean isInitialiseIfNull()
|
||||
{
|
||||
return initialiseIfNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initialiseIfNull Determines whether the control should
|
||||
* initially show today's date if the model value is null.
|
||||
* This will also hide the None button thus disallowing
|
||||
* the user to set the date back to null.
|
||||
*/
|
||||
public void setInitialiseIfNull(boolean initialiseIfNull)
|
||||
{
|
||||
this.initialiseIfNull = initialiseIfNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label to use when there is no date set.
|
||||
*
|
||||
* @return The 'None' label to use
|
||||
*/
|
||||
public String getNoneLabel()
|
||||
{
|
||||
return this.noneLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label to use when there is no date set.
|
||||
* Setting this to null will use the default label.
|
||||
*
|
||||
* @param noneLabel The 'None' label
|
||||
*/
|
||||
public void setNoneLabel(String noneLabel)
|
||||
{
|
||||
this.noneLabel = noneLabel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_DATE_PICKER_RENDERER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
component.getAttributes().put("startYear", this.startYear);
|
||||
component.getAttributes().put("yearCount", this.yearCount);
|
||||
component.getAttributes().put("initialiseIfNull", new Boolean(this.initialiseIfNull));
|
||||
component.getAttributes().put("style", "margin-right: 7px;");
|
||||
if (this.noneLabel != null)
|
||||
{
|
||||
component.getAttributes().put("noneLabel", this.noneLabel);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the default converter for the date component
|
||||
// we can cast this as we know it is an UIOutput type
|
||||
((UIOutput)component).setConverter(getDefaultConverter(context));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the client validation rule with real time validation enabled
|
||||
// so that the initial page load checks the state of the date
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, idSuffix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default converter for the date component
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @return XMLDateConverter
|
||||
*/
|
||||
protected Converter getDefaultConverter(FacesContext context)
|
||||
{
|
||||
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
|
||||
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
|
||||
converter.setType("date");
|
||||
converter.setPattern(Application.getMessage(context, MSG_DATE));
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.common.converter.XMLDateConverter;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a date picker component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DatePickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private boolean initialiseIfNull = false;
|
||||
private int yearCount = 30;
|
||||
private int startYear = Calendar.getInstance().get(Calendar.YEAR) + 2;
|
||||
private String noneLabel = null;
|
||||
|
||||
private static final String MSG_DATE = "date_pattern";
|
||||
|
||||
/**
|
||||
* @return Returns the year to start counting back from
|
||||
*/
|
||||
public int getStartYear()
|
||||
{
|
||||
return startYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startYear Sets the year to start counting back from
|
||||
*/
|
||||
public void setStartYear(int startYear)
|
||||
{
|
||||
this.startYear = startYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the number of years to show
|
||||
*/
|
||||
public int getYearCount()
|
||||
{
|
||||
return yearCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param yearCount Sets the number of years to show
|
||||
*/
|
||||
public void setYearCount(int yearCount)
|
||||
{
|
||||
this.yearCount = yearCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Determines whether the control should initially show
|
||||
* today's date if the model value is null
|
||||
*/
|
||||
public boolean isInitialiseIfNull()
|
||||
{
|
||||
return initialiseIfNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initialiseIfNull Determines whether the control should
|
||||
* initially show today's date if the model value is null.
|
||||
* This will also hide the None button thus disallowing
|
||||
* the user to set the date back to null.
|
||||
*/
|
||||
public void setInitialiseIfNull(boolean initialiseIfNull)
|
||||
{
|
||||
this.initialiseIfNull = initialiseIfNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label to use when there is no date set.
|
||||
*
|
||||
* @return The 'None' label to use
|
||||
*/
|
||||
public String getNoneLabel()
|
||||
{
|
||||
return this.noneLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label to use when there is no date set.
|
||||
* Setting this to null will use the default label.
|
||||
*
|
||||
* @param noneLabel The 'None' label
|
||||
*/
|
||||
public void setNoneLabel(String noneLabel)
|
||||
{
|
||||
this.noneLabel = noneLabel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_DATE_PICKER_RENDERER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
component.getAttributes().put("startYear", this.startYear);
|
||||
component.getAttributes().put("yearCount", this.yearCount);
|
||||
component.getAttributes().put("initialiseIfNull", new Boolean(this.initialiseIfNull));
|
||||
component.getAttributes().put("style", "margin-right: 7px;");
|
||||
if (this.noneLabel != null)
|
||||
{
|
||||
component.getAttributes().put("noneLabel", this.noneLabel);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the default converter for the date component
|
||||
// we can cast this as we know it is an UIOutput type
|
||||
((UIOutput)component).setConverter(getDefaultConverter(context));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the client validation rule with real time validation enabled
|
||||
// so that the initial page load checks the state of the date
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, idSuffix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default converter for the date component
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @return XMLDateConverter
|
||||
*/
|
||||
protected Converter getDefaultConverter(FacesContext context)
|
||||
{
|
||||
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
|
||||
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
|
||||
converter.setType("date");
|
||||
converter.setPattern(Application.getMessage(context, MSG_DATE));
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
@@ -1,45 +1,45 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.ui.common.converter.XMLDateConverter;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
|
||||
/**
|
||||
* Generates a date time picker component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DateTimePickerGenerator extends DatePickerGenerator
|
||||
{
|
||||
private static final String MSG_DATE_TIME = "date_time_pattern";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = super.generate(context, id);
|
||||
|
||||
// add the attribute to show the time
|
||||
component.getAttributes().put("showTime", Boolean.TRUE);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default converter for the date time component
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @return XMLDateConverter
|
||||
*/
|
||||
protected Converter getDefaultConverter(FacesContext context)
|
||||
{
|
||||
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
|
||||
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
|
||||
converter.setType("both");
|
||||
converter.setPattern(Application.getMessage(context, MSG_DATE_TIME));
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.ui.common.converter.XMLDateConverter;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
|
||||
/**
|
||||
* Generates a date time picker component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DateTimePickerGenerator extends DatePickerGenerator
|
||||
{
|
||||
private static final String MSG_DATE_TIME = "date_time_pattern";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = super.generate(context, id);
|
||||
|
||||
// add the attribute to show the time
|
||||
component.getAttributes().put("showTime", Boolean.TRUE);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default converter for the date time component
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @return XMLDateConverter
|
||||
*/
|
||||
protected Converter getDefaultConverter(FacesContext context)
|
||||
{
|
||||
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
|
||||
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
|
||||
converter.setType("both");
|
||||
converter.setPattern(Application.getMessage(context, MSG_DATE_TIME));
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
@@ -1,79 +1,79 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to represent a separator.
|
||||
* <p>The HTML to be used for the separator is configured via the
|
||||
* <code>setHtml</code> method.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class HtmlSeparatorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String html = "";
|
||||
|
||||
/**
|
||||
* Returns the HTML configured to be used for this separator
|
||||
*
|
||||
* @return The HTML to display
|
||||
*/
|
||||
public String getHtml()
|
||||
{
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTML to display for the separator
|
||||
*
|
||||
* @param html The HTML
|
||||
*/
|
||||
public void setHtml(String html)
|
||||
{
|
||||
this.html = html;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = this.createOutputTextComponent(context, id);
|
||||
component.getAttributes().put("escape", Boolean.FALSE);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = this.generate(context, item.getName());
|
||||
|
||||
// set the HTML to use
|
||||
component.getAttributes().put("value", getResolvedHtml(component, item));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved HTML to use for the separator.
|
||||
* <p>In the default case we just return the HTML set
|
||||
* via setHtml however subclasses may choose to generate
|
||||
* the resulting HTML using a combination of the HTML set
|
||||
* via setHtml and the given PropertySheetItem.
|
||||
*
|
||||
* @param component The JSF component representing the separator
|
||||
* @param item The separator item
|
||||
* @return The resolved HTML
|
||||
*/
|
||||
protected String getResolvedHtml(UIComponent component, PropertySheetItem item)
|
||||
{
|
||||
// In the default case we just return the HTML set via setHtml
|
||||
|
||||
return this.html;
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a component to represent a separator.
|
||||
* <p>The HTML to be used for the separator is configured via the
|
||||
* <code>setHtml</code> method.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class HtmlSeparatorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected String html = "";
|
||||
|
||||
/**
|
||||
* Returns the HTML configured to be used for this separator
|
||||
*
|
||||
* @return The HTML to display
|
||||
*/
|
||||
public String getHtml()
|
||||
{
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTML to display for the separator
|
||||
*
|
||||
* @param html The HTML
|
||||
*/
|
||||
public void setHtml(String html)
|
||||
{
|
||||
this.html = html;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = this.createOutputTextComponent(context, id);
|
||||
component.getAttributes().put("escape", Boolean.FALSE);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = this.generate(context, item.getName());
|
||||
|
||||
// set the HTML to use
|
||||
component.getAttributes().put("value", getResolvedHtml(component, item));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved HTML to use for the separator.
|
||||
* <p>In the default case we just return the HTML set
|
||||
* via setHtml however subclasses may choose to generate
|
||||
* the resulting HTML using a combination of the HTML set
|
||||
* via setHtml and the given PropertySheetItem.
|
||||
*
|
||||
* @param component The JSF component representing the separator
|
||||
* @param item The separator item
|
||||
* @return The resolved HTML
|
||||
*/
|
||||
protected String getResolvedHtml(UIComponent component, PropertySheetItem item)
|
||||
{
|
||||
// In the default case we just return the HTML set via setHtml
|
||||
|
||||
return this.html;
|
||||
}
|
||||
}
|
@@ -1,50 +1,50 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Interface definition for objects that dynamically generate components.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public interface IComponentGenerator
|
||||
{
|
||||
/**
|
||||
* Dynamically generates a component in a default state
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param id Optional id for the newly created component, if null
|
||||
* is passed a unique id is generated
|
||||
* @return The component instance
|
||||
*/
|
||||
UIComponent generate(FacesContext context, String id);
|
||||
|
||||
/**
|
||||
* Dynamically generates a component for the given property sheet item.
|
||||
* The generated component is also setup appropriately for it's model
|
||||
* definition and added to the given property sheet.
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param propertySheet The property sheet component
|
||||
* @param item The wrappper component representing the item to generate,
|
||||
* either a property, association or child association
|
||||
* @return The component instance
|
||||
*/
|
||||
UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item);
|
||||
|
||||
/**
|
||||
* Determines whether the component will be enabled when rendered.
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param control The control being rendered
|
||||
* @param propDef The definition of the property
|
||||
* @return true if the component should be enabled
|
||||
*/
|
||||
boolean isEnabledInEditMode (FacesContext context, UIComponent control, PropertyDefinition propDef);
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Interface definition for objects that dynamically generate components.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public interface IComponentGenerator
|
||||
{
|
||||
/**
|
||||
* Dynamically generates a component in a default state
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param id Optional id for the newly created component, if null
|
||||
* is passed a unique id is generated
|
||||
* @return The component instance
|
||||
*/
|
||||
UIComponent generate(FacesContext context, String id);
|
||||
|
||||
/**
|
||||
* Dynamically generates a component for the given property sheet item.
|
||||
* The generated component is also setup appropriately for it's model
|
||||
* definition and added to the given property sheet.
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param propertySheet The property sheet component
|
||||
* @param item The wrappper component representing the item to generate,
|
||||
* either a property, association or child association
|
||||
* @return The component instance
|
||||
*/
|
||||
UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item);
|
||||
|
||||
/**
|
||||
* Determines whether the component will be enabled when rendered.
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param control The control being rendered
|
||||
* @param propDef The definition of the property
|
||||
* @return true if the component should be enabled
|
||||
*/
|
||||
boolean isEnabledInEditMode (FacesContext context, UIComponent control, PropertyDefinition propDef);
|
||||
}
|
||||
|
@@ -1,35 +1,35 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a text field component to represent a label.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class LabelGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
return createOutputTextComponent(context, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = generate(context, "label_" + item.getName());
|
||||
|
||||
// add the component to the property sheet item
|
||||
item.getChildren().add(component);
|
||||
|
||||
// TODO: setup the 'for' attribute to associate with it the control
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a text field component to represent a label.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class LabelGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
return createOutputTextComponent(context, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = generate(context, "label_" + item.getName());
|
||||
|
||||
// add the component to the property sheet item
|
||||
item.getChildren().add(component);
|
||||
|
||||
// TODO: setup the 'for' attribute to associate with it the control
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
@@ -1,75 +1,75 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Link Generator.
|
||||
*
|
||||
* Generates a link tag which opend the URL into a new browsers window.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class LinkGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private boolean inEditMode = false;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.IComponentGenerator#generate(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = null;
|
||||
if (this.inEditMode == false)
|
||||
{
|
||||
component = context.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
|
||||
component.setRendererType("javax.faces.Link");
|
||||
component.getAttributes().put("target", "new");
|
||||
}
|
||||
else
|
||||
{
|
||||
component = context.getApplication().createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXT);
|
||||
}
|
||||
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.BaseComponentGenerator#createComponent(javax.faces.context.FacesContext, org.alfresco.web.ui.repo.component.property.UIPropertySheet, org.alfresco.web.ui.repo.component.property.PropertySheetItem)
|
||||
*/
|
||||
@Override
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item)
|
||||
{
|
||||
this.inEditMode = propertySheet.inEditMode();
|
||||
return this.generate(context, item.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.BaseComponentGenerator#setupProperty(javax.faces.context.FacesContext, org.alfresco.web.ui.repo.component.property.UIPropertySheet, org.alfresco.web.ui.repo.component.property.PropertySheetItem, org.alfresco.service.cmr.dictionary.PropertyDefinition, javax.faces.component.UIComponent)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void setupProperty(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
super.setupProperty(context, propertySheet, item, propertyDef, component);
|
||||
|
||||
if (component.getRendererType().equals("javax.faces.Link") == true)
|
||||
{
|
||||
// Add child text component
|
||||
UIOutput output = createOutputTextComponent(context, "linklabel_" + component.getId());
|
||||
output.setValueBinding("value", component.getValueBinding("value"));
|
||||
component.getChildren().add(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Link Generator.
|
||||
*
|
||||
* Generates a link tag which opend the URL into a new browsers window.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class LinkGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private boolean inEditMode = false;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.IComponentGenerator#generate(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = null;
|
||||
if (this.inEditMode == false)
|
||||
{
|
||||
component = context.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
|
||||
component.setRendererType("javax.faces.Link");
|
||||
component.getAttributes().put("target", "new");
|
||||
}
|
||||
else
|
||||
{
|
||||
component = context.getApplication().createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXT);
|
||||
}
|
||||
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.BaseComponentGenerator#createComponent(javax.faces.context.FacesContext, org.alfresco.web.ui.repo.component.property.UIPropertySheet, org.alfresco.web.ui.repo.component.property.PropertySheetItem)
|
||||
*/
|
||||
@Override
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item)
|
||||
{
|
||||
this.inEditMode = propertySheet.inEditMode();
|
||||
return this.generate(context, item.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.generator.BaseComponentGenerator#setupProperty(javax.faces.context.FacesContext, org.alfresco.web.ui.repo.component.property.UIPropertySheet, org.alfresco.web.ui.repo.component.property.PropertySheetItem, org.alfresco.service.cmr.dictionary.PropertyDefinition, javax.faces.component.UIComponent)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void setupProperty(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item, PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
super.setupProperty(context, propertySheet, item, propertyDef, component);
|
||||
|
||||
if (component.getRendererType().equals("javax.faces.Link") == true)
|
||||
{
|
||||
// Add child text component
|
||||
UIOutput output = createOutputTextComponent(context, "linklabel_" + component.getId());
|
||||
output.setValueBinding("value", component.getValueBinding("value"));
|
||||
component.getChildren().add(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +1,59 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.component.UIMimeTypeSelector;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
import org.alfresco.web.ui.repo.converter.MimeTypeConverter;
|
||||
|
||||
/**
|
||||
* Generates a MIME type selector component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MimeTypeSelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(UIMimeTypeSelector.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (propertySheet.inEditMode() == false)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there isn't a custom converter add the mime type
|
||||
// converter as a default
|
||||
createAndSetConverter(context, MimeTypeConverter.CONVERTER_ID,
|
||||
component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// a mime type selector will always have one value or another
|
||||
// so there is no need to create a mandatory validation rule.
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.component.UIMimeTypeSelector;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
import org.alfresco.web.ui.repo.converter.MimeTypeConverter;
|
||||
|
||||
/**
|
||||
* Generates a MIME type selector component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MimeTypeSelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(UIMimeTypeSelector.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
if (propertySheet.inEditMode() == false)
|
||||
{
|
||||
if (property.getConverter() != null)
|
||||
{
|
||||
// create and add the custom converter
|
||||
createAndSetConverter(context, property.getConverter(), component);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there isn't a custom converter add the mime type
|
||||
// converter as a default
|
||||
createAndSetConverter(context, MimeTypeConverter.CONVERTER_ID,
|
||||
component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// a mime type selector will always have one value or another
|
||||
// so there is no need to create a mandatory validation rule.
|
||||
}
|
||||
}
|
||||
|
@@ -1,37 +1,37 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a multilingual text area component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MultilingualTextAreaGenerator extends TextAreaGenerator
|
||||
{
|
||||
@Override
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = super.generateAndAdd(context, propertySheet, item);
|
||||
|
||||
if ((component instanceof UIInput) && (component instanceof UISelectOne) == false)
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXTAREA_RENDERER);
|
||||
}
|
||||
else if ((component instanceof UIOutput))
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXT_RENDERER);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a multilingual text area component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MultilingualTextAreaGenerator extends TextAreaGenerator
|
||||
{
|
||||
@Override
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = super.generateAndAdd(context, propertySheet, item);
|
||||
|
||||
if ((component instanceof UIInput) && (component instanceof UISelectOne) == false)
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXTAREA_RENDERER);
|
||||
}
|
||||
else if ((component instanceof UIOutput))
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXT_RENDERER);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
@@ -1,33 +1,33 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a multilingual text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MultilingualTextFieldGenerator extends TextFieldGenerator
|
||||
{
|
||||
@Override
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = super.generateAndAdd(context, propertySheet, item);
|
||||
|
||||
if ((component instanceof UISelectOne) == false &&
|
||||
(component instanceof UIMultiValueEditor) == false)
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXT_RENDERER);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates a multilingual text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MultilingualTextFieldGenerator extends TextFieldGenerator
|
||||
{
|
||||
@Override
|
||||
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = super.generateAndAdd(context, propertySheet, item);
|
||||
|
||||
if ((component instanceof UISelectOne) == false &&
|
||||
(component instanceof UIMultiValueEditor) == false)
|
||||
{
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_MLTEXT_RENDERER);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
@@ -1,81 +1,81 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.el.ValueBinding;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.component.UIListItems;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates the image picker component with rounded corners for selecting
|
||||
* an icon for a space.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class SpaceIconPickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
// create the outer component
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_IMAGE_PICKER);
|
||||
|
||||
// setup the outer component
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_RADIO_PANEL_RENDERER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
component.getAttributes().put("columns", new Integer(6));
|
||||
component.getAttributes().put("spacing", new Integer(4));
|
||||
component.getAttributes().put("panelBorder", "blue");
|
||||
component.getAttributes().put("panelBgcolor", "#D3E6FE");
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupProperty(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do the standard setup
|
||||
super.setupProperty(context, propertySheet, item, propertyDef, component);
|
||||
|
||||
// if the property sheet is in edit mode we also need to setup the
|
||||
// list of icons the user can select from
|
||||
if (propertySheet.inEditMode())
|
||||
{
|
||||
// create the list items child component
|
||||
UIListItems items = (UIListItems)context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_LIST_ITEMS);
|
||||
|
||||
// setup the value binding for the list of icons, this needs
|
||||
// to be sensitive to the bean used for the property sheet
|
||||
// we therefore need to get the value binding expression and
|
||||
// extract the bean name and then add '.icons' to the end,
|
||||
// this means any page that uses this component must supply
|
||||
// a getIcons method that returns a List of UIListItem's
|
||||
ValueBinding binding = propertySheet.getValueBinding("value");
|
||||
String expression = binding.getExpressionString();
|
||||
String beanName = expression.substring(2, expression.indexOf(".")+1);
|
||||
if (beanName.equals("DialogManager.") || beanName.equals("WizardManager."))
|
||||
{
|
||||
// deal with the special dialog and wizard manager beans by
|
||||
// adding .bean
|
||||
beanName = beanName + "bean.";
|
||||
}
|
||||
String newExpression = "#{" + beanName + "icons}";
|
||||
|
||||
ValueBinding vb = context.getApplication().createValueBinding(newExpression);
|
||||
items.setValueBinding("value", vb);
|
||||
|
||||
// add the list items component to the image picker component
|
||||
component.getChildren().add(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.el.ValueBinding;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.component.UIListItems;
|
||||
import org.alfresco.web.ui.repo.RepoConstants;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
|
||||
/**
|
||||
* Generates the image picker component with rounded corners for selecting
|
||||
* an icon for a space.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class SpaceIconPickerGenerator extends BaseComponentGenerator
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
// create the outer component
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_IMAGE_PICKER);
|
||||
|
||||
// setup the outer component
|
||||
component.setRendererType(RepoConstants.ALFRESCO_FACES_RADIO_PANEL_RENDERER);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
component.getAttributes().put("columns", new Integer(6));
|
||||
component.getAttributes().put("spacing", new Integer(4));
|
||||
component.getAttributes().put("panelBorder", "blue");
|
||||
component.getAttributes().put("panelBgcolor", "#D3E6FE");
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupProperty(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do the standard setup
|
||||
super.setupProperty(context, propertySheet, item, propertyDef, component);
|
||||
|
||||
// if the property sheet is in edit mode we also need to setup the
|
||||
// list of icons the user can select from
|
||||
if (propertySheet.inEditMode())
|
||||
{
|
||||
// create the list items child component
|
||||
UIListItems items = (UIListItems)context.getApplication().
|
||||
createComponent(RepoConstants.ALFRESCO_FACES_LIST_ITEMS);
|
||||
|
||||
// setup the value binding for the list of icons, this needs
|
||||
// to be sensitive to the bean used for the property sheet
|
||||
// we therefore need to get the value binding expression and
|
||||
// extract the bean name and then add '.icons' to the end,
|
||||
// this means any page that uses this component must supply
|
||||
// a getIcons method that returns a List of UIListItem's
|
||||
ValueBinding binding = propertySheet.getValueBinding("value");
|
||||
String expression = binding.getExpressionString();
|
||||
String beanName = expression.substring(2, expression.indexOf(".")+1);
|
||||
if (beanName.equals("DialogManager.") || beanName.equals("WizardManager."))
|
||||
{
|
||||
// deal with the special dialog and wizard manager beans by
|
||||
// adding .bean
|
||||
beanName = beanName + "bean.";
|
||||
}
|
||||
String newExpression = "#{" + beanName + "icons}";
|
||||
|
||||
ValueBinding vb = context.getApplication().createValueBinding(newExpression);
|
||||
items.setValueBinding("value", vb);
|
||||
|
||||
// add the list items component to the image picker component
|
||||
component.getChildren().add(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,23 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.component.UIStoreSelector;
|
||||
|
||||
/**
|
||||
* Generates a content store selector component.
|
||||
*/
|
||||
public class StoreSelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(UIStoreSelector.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.repo.component.UIStoreSelector;
|
||||
|
||||
/**
|
||||
* Generates a content store selector component.
|
||||
*/
|
||||
public class StoreSelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(UIStoreSelector.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,72 +1,72 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
|
||||
/**
|
||||
* Generates a text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class TextAreaGenerator extends TextFieldGenerator
|
||||
{
|
||||
private int rows = 3;
|
||||
private int columns = 32;
|
||||
|
||||
/**
|
||||
* @return Returns the number of columns
|
||||
*/
|
||||
public int getColumns()
|
||||
{
|
||||
return columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columns Sets the number of columns
|
||||
*/
|
||||
public void setColumns(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the number of rows
|
||||
*/
|
||||
public int getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rows Sets the number of rows
|
||||
*/
|
||||
public void setRows(int rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXTAREA);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
component.getAttributes().put("rows", this.rows);
|
||||
component.getAttributes().put("cols", this.columns);
|
||||
|
||||
// MNT-10171 Exception thrown if Share metadata is longer than 1024 characters
|
||||
if (ContentModel.PROP_DESCRIPTION.getLocalName().equals(id))
|
||||
{
|
||||
// add 'onfocus' event for adding 'maxlength' attribute
|
||||
component.getAttributes().put("onfocus", "addMaxLengthForDescriptionTextArea(this)");
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
|
||||
/**
|
||||
* Generates a text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class TextAreaGenerator extends TextFieldGenerator
|
||||
{
|
||||
private int rows = 3;
|
||||
private int columns = 32;
|
||||
|
||||
/**
|
||||
* @return Returns the number of columns
|
||||
*/
|
||||
public int getColumns()
|
||||
{
|
||||
return columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columns Sets the number of columns
|
||||
*/
|
||||
public void setColumns(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the number of rows
|
||||
*/
|
||||
public int getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rows Sets the number of rows
|
||||
*/
|
||||
public void setRows(int rows)
|
||||
{
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXTAREA);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
component.getAttributes().put("rows", this.rows);
|
||||
component.getAttributes().put("cols", this.columns);
|
||||
|
||||
// MNT-10171 Exception thrown if Share metadata is longer than 1024 characters
|
||||
if (ContentModel.PROP_DESCRIPTION.getLocalName().equals(id))
|
||||
{
|
||||
// add 'onfocus' event for adding 'maxlength' attribute
|
||||
component.getAttributes().put("onfocus", "addMaxLengthForDescriptionTextArea(this)");
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
@@ -1,334 +1,334 @@
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UISelectItems;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.FloatConverter;
|
||||
import javax.faces.convert.IntegerConverter;
|
||||
import javax.faces.convert.LongConverter;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
|
||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet.ClientValidation;
|
||||
|
||||
/**
|
||||
* Generates a text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class TextFieldGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private int size = 35;
|
||||
private int maxLength = 1024;
|
||||
|
||||
/**
|
||||
* @return Returns the default size for a text field
|
||||
*/
|
||||
public int getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size Sets the size of a text field
|
||||
*/
|
||||
public void setSize(int size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the max length for the text field
|
||||
*/
|
||||
public int getMaxLength()
|
||||
{
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxLength Sets the max length of the text field
|
||||
*/
|
||||
public void setMaxLength(int maxLength)
|
||||
{
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXT);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
component.getAttributes().put("size", this.size);
|
||||
component.getAttributes().put("maxlength", this.maxLength);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = null;
|
||||
|
||||
if (propertySheet.inEditMode())
|
||||
{
|
||||
// if the field has the list of values constraint
|
||||
// and it is editable a SelectOne component is
|
||||
// required otherwise create the standard edit component
|
||||
ListOfValuesConstraint constraint = getListOfValuesConstraint(
|
||||
context, propertySheet, item);
|
||||
|
||||
PropertyDefinition propDef = this.getPropertyDefinition(context,
|
||||
propertySheet.getNode(), item.getName());
|
||||
|
||||
if (constraint != null && item.isReadOnly() == false &&
|
||||
propDef != null && propDef.isProtected() == false)
|
||||
{
|
||||
component = context.getApplication().createComponent(
|
||||
UISelectOne.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, item.getName());
|
||||
|
||||
// create the list of choices
|
||||
UISelectItems itemsComponent = (UISelectItems)context.getApplication().
|
||||
createComponent("javax.faces.SelectItems");
|
||||
|
||||
List<String> values = constraint.getAllowedValues();
|
||||
List<SelectItem> items = new ArrayList<SelectItem>(values.size());
|
||||
for (String value : values)
|
||||
{
|
||||
Object obj = null;
|
||||
|
||||
// we need to setup the list with objects of the correct type
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.INT))
|
||||
{
|
||||
obj = Integer.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
obj = Long.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE))
|
||||
{
|
||||
obj = Double.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT))
|
||||
{
|
||||
obj = Float.valueOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = value;
|
||||
}
|
||||
|
||||
// retrieve the display label
|
||||
String label = constraint.getDisplayLabel(value, dataDictionary.getDictionaryService());
|
||||
if (label == null)
|
||||
{
|
||||
label = value;
|
||||
}
|
||||
|
||||
items.add(new SelectItem(obj, label));
|
||||
}
|
||||
|
||||
itemsComponent.setValue(items);
|
||||
|
||||
// add the items as a child component
|
||||
component.getChildren().add(itemsComponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the standard component in edit mode
|
||||
component = generate(context, item.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create an output text component in view mode
|
||||
component = createOutputTextComponent(context, item.getName());
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking,
|
||||
String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else if (component instanceof UISelectOne)
|
||||
{
|
||||
// when there is a list of values constraint there
|
||||
// will always be a value so validation is not required.
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the client validation rule with real time validation enabled
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, idSuffix);
|
||||
|
||||
// add event handler to kick off real time checks
|
||||
component.getAttributes().put("onkeyup", "processButtonState();");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupConstraints(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do the default processing first
|
||||
super.setupConstraints(context, propertySheet, property,
|
||||
propertyDef, component);
|
||||
|
||||
// if the property type is a number based type and the property
|
||||
// sheet is in edit mode and validation is turned, on add the
|
||||
// validateIsNumber validation function
|
||||
if (propertySheet.inEditMode() && propertySheet.isValidationEnabled() &&
|
||||
propertyDef != null)
|
||||
{
|
||||
// check the type of the property is a number
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
List<String> params = new ArrayList<String>(3);
|
||||
|
||||
// add the value parameter
|
||||
String value = "document.getElementById('" +
|
||||
component.getClientId(context) + "')";
|
||||
params.add(value);
|
||||
|
||||
// add the validation failed message to show
|
||||
String msg = Application.getMessage(context, "validation_is_number");
|
||||
addStringConstraintParam(params,
|
||||
MessageFormat.format(msg, new Object[] {property.getResolvedDisplayLabel()}));
|
||||
|
||||
// add the validation case to the property sheet
|
||||
propertySheet.addClientValidation(new ClientValidation("validateIsNumber",
|
||||
params, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of values constraint for the item, if it has one
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param propertySheet The property sheet being generated
|
||||
* @param item The item being generated
|
||||
* @return The constraint if the item has one, null otherwise
|
||||
*/
|
||||
protected ListOfValuesConstraint getListOfValuesConstraint(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item)
|
||||
{
|
||||
ListOfValuesConstraint lovConstraint = null;
|
||||
|
||||
// get the property definition for the item
|
||||
PropertyDefinition propertyDef = getPropertyDefinition(context,
|
||||
propertySheet.getNode(), item.getName());
|
||||
|
||||
if (propertyDef != null)
|
||||
{
|
||||
// go through the constaints and see if it has the
|
||||
// list of values constraint
|
||||
List<ConstraintDefinition> constraints = propertyDef.getConstraints();
|
||||
for (ConstraintDefinition constraintDef : constraints)
|
||||
{
|
||||
Constraint constraint = constraintDef.getConstraint();
|
||||
|
||||
if (constraint instanceof ListOfValuesConstraint)
|
||||
{
|
||||
lovConstraint = (ListOfValuesConstraint)constraint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lovConstraint;
|
||||
}
|
||||
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do default processing
|
||||
super.setupConverter(context, propertySheet, property, propertyDef, component);
|
||||
|
||||
// if there isn't a converter and the property has a list of values constraint
|
||||
// on a number property we need to add the appropriate one.
|
||||
if (propertySheet.inEditMode() && propertyDef != null &&
|
||||
component instanceof UIOutput)
|
||||
{
|
||||
Converter converter = ((UIOutput)component).getConverter();
|
||||
if (converter == null)
|
||||
{
|
||||
ListOfValuesConstraint constraint = getListOfValuesConstraint(context,
|
||||
propertySheet, property);
|
||||
if (constraint != null)
|
||||
{
|
||||
String converterId = null;
|
||||
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.INT))
|
||||
{
|
||||
converterId = IntegerConverter.CONVERTER_ID;
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
converterId = LongConverter.CONVERTER_ID;
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE))
|
||||
{
|
||||
// NOTE: the constant for the double converter is wrong in MyFaces!!
|
||||
converterId = "javax.faces.Double";
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.FLOAT))
|
||||
{
|
||||
converterId = FloatConverter.CONVERTER_ID;
|
||||
}
|
||||
|
||||
if (converterId != null)
|
||||
{
|
||||
createAndSetConverter(context, converterId, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UISelectItems;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.FloatConverter;
|
||||
import javax.faces.convert.IntegerConverter;
|
||||
import javax.faces.convert.LongConverter;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
|
||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.ui.common.ComponentConstants;
|
||||
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet.ClientValidation;
|
||||
|
||||
/**
|
||||
* Generates a text field component.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class TextFieldGenerator extends BaseComponentGenerator
|
||||
{
|
||||
private int size = 35;
|
||||
private int maxLength = 1024;
|
||||
|
||||
/**
|
||||
* @return Returns the default size for a text field
|
||||
*/
|
||||
public int getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size Sets the size of a text field
|
||||
*/
|
||||
public void setSize(int size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the max length for the text field
|
||||
*/
|
||||
public int getMaxLength()
|
||||
{
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxLength Sets the max length of the text field
|
||||
*/
|
||||
public void setMaxLength(int maxLength)
|
||||
{
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(ComponentConstants.JAVAX_FACES_INPUT);
|
||||
component.setRendererType(ComponentConstants.JAVAX_FACES_TEXT);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
component.getAttributes().put("size", this.size);
|
||||
component.getAttributes().put("maxlength", this.maxLength);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet,
|
||||
PropertySheetItem item)
|
||||
{
|
||||
UIComponent component = null;
|
||||
|
||||
if (propertySheet.inEditMode())
|
||||
{
|
||||
// if the field has the list of values constraint
|
||||
// and it is editable a SelectOne component is
|
||||
// required otherwise create the standard edit component
|
||||
ListOfValuesConstraint constraint = getListOfValuesConstraint(
|
||||
context, propertySheet, item);
|
||||
|
||||
PropertyDefinition propDef = this.getPropertyDefinition(context,
|
||||
propertySheet.getNode(), item.getName());
|
||||
|
||||
if (constraint != null && item.isReadOnly() == false &&
|
||||
propDef != null && propDef.isProtected() == false)
|
||||
{
|
||||
component = context.getApplication().createComponent(
|
||||
UISelectOne.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, item.getName());
|
||||
|
||||
// create the list of choices
|
||||
UISelectItems itemsComponent = (UISelectItems)context.getApplication().
|
||||
createComponent("javax.faces.SelectItems");
|
||||
|
||||
List<String> values = constraint.getAllowedValues();
|
||||
List<SelectItem> items = new ArrayList<SelectItem>(values.size());
|
||||
for (String value : values)
|
||||
{
|
||||
Object obj = null;
|
||||
|
||||
// we need to setup the list with objects of the correct type
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.INT))
|
||||
{
|
||||
obj = Integer.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
obj = Long.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE))
|
||||
{
|
||||
obj = Double.valueOf(value);
|
||||
}
|
||||
else if (propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT))
|
||||
{
|
||||
obj = Float.valueOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = value;
|
||||
}
|
||||
|
||||
// retrieve the display label
|
||||
String label = constraint.getDisplayLabel(value, dataDictionary.getDictionaryService());
|
||||
if (label == null)
|
||||
{
|
||||
label = value;
|
||||
}
|
||||
|
||||
items.add(new SelectItem(obj, label));
|
||||
}
|
||||
|
||||
itemsComponent.setValue(items);
|
||||
|
||||
// add the items as a child component
|
||||
component.getChildren().add(itemsComponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the standard component in edit mode
|
||||
component = generate(context, item.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create an output text component in view mode
|
||||
component = createOutputTextComponent(context, item.getName());
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking,
|
||||
String idSuffix)
|
||||
{
|
||||
if (component instanceof UIMultiValueEditor)
|
||||
{
|
||||
// Override the setup of the mandatory validation
|
||||
// so we can send the _current_value id suffix.
|
||||
// We also enable real time so the page load
|
||||
// check disables the ok button if necessary, as the user
|
||||
// adds or removes items from the multi value list the
|
||||
// page will be refreshed and therefore re-check the status.
|
||||
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, "_current_value");
|
||||
}
|
||||
else if (component instanceof UISelectOne)
|
||||
{
|
||||
// when there is a list of values constraint there
|
||||
// will always be a value so validation is not required.
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the client validation rule with real time validation enabled
|
||||
super.setupMandatoryValidation(context, propertySheet, item,
|
||||
component, true, idSuffix);
|
||||
|
||||
// add event handler to kick off real time checks
|
||||
component.getAttributes().put("onkeyup", "processButtonState();");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setupConstraints(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do the default processing first
|
||||
super.setupConstraints(context, propertySheet, property,
|
||||
propertyDef, component);
|
||||
|
||||
// if the property type is a number based type and the property
|
||||
// sheet is in edit mode and validation is turned, on add the
|
||||
// validateIsNumber validation function
|
||||
if (propertySheet.inEditMode() && propertySheet.isValidationEnabled() &&
|
||||
propertyDef != null)
|
||||
{
|
||||
// check the type of the property is a number
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propertyDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
List<String> params = new ArrayList<String>(3);
|
||||
|
||||
// add the value parameter
|
||||
String value = "document.getElementById('" +
|
||||
component.getClientId(context) + "')";
|
||||
params.add(value);
|
||||
|
||||
// add the validation failed message to show
|
||||
String msg = Application.getMessage(context, "validation_is_number");
|
||||
addStringConstraintParam(params,
|
||||
MessageFormat.format(msg, new Object[] {property.getResolvedDisplayLabel()}));
|
||||
|
||||
// add the validation case to the property sheet
|
||||
propertySheet.addClientValidation(new ClientValidation("validateIsNumber",
|
||||
params, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of values constraint for the item, if it has one
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param propertySheet The property sheet being generated
|
||||
* @param item The item being generated
|
||||
* @return The constraint if the item has one, null otherwise
|
||||
*/
|
||||
protected ListOfValuesConstraint getListOfValuesConstraint(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item)
|
||||
{
|
||||
ListOfValuesConstraint lovConstraint = null;
|
||||
|
||||
// get the property definition for the item
|
||||
PropertyDefinition propertyDef = getPropertyDefinition(context,
|
||||
propertySheet.getNode(), item.getName());
|
||||
|
||||
if (propertyDef != null)
|
||||
{
|
||||
// go through the constaints and see if it has the
|
||||
// list of values constraint
|
||||
List<ConstraintDefinition> constraints = propertyDef.getConstraints();
|
||||
for (ConstraintDefinition constraintDef : constraints)
|
||||
{
|
||||
Constraint constraint = constraintDef.getConstraint();
|
||||
|
||||
if (constraint instanceof ListOfValuesConstraint)
|
||||
{
|
||||
lovConstraint = (ListOfValuesConstraint)constraint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lovConstraint;
|
||||
}
|
||||
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
// do default processing
|
||||
super.setupConverter(context, propertySheet, property, propertyDef, component);
|
||||
|
||||
// if there isn't a converter and the property has a list of values constraint
|
||||
// on a number property we need to add the appropriate one.
|
||||
if (propertySheet.inEditMode() && propertyDef != null &&
|
||||
component instanceof UIOutput)
|
||||
{
|
||||
Converter converter = ((UIOutput)component).getConverter();
|
||||
if (converter == null)
|
||||
{
|
||||
ListOfValuesConstraint constraint = getListOfValuesConstraint(context,
|
||||
propertySheet, property);
|
||||
if (constraint != null)
|
||||
{
|
||||
String converterId = null;
|
||||
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.INT))
|
||||
{
|
||||
converterId = IntegerConverter.CONVERTER_ID;
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
converterId = LongConverter.CONVERTER_ID;
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE))
|
||||
{
|
||||
// NOTE: the constant for the double converter is wrong in MyFaces!!
|
||||
converterId = "javax.faces.Double";
|
||||
}
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.FLOAT))
|
||||
{
|
||||
converterId = FloatConverter.CONVERTER_ID;
|
||||
}
|
||||
|
||||
if (converterId != null)
|
||||
{
|
||||
createAndSetConverter(context, converterId, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user