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:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent d6f9f50c39
commit dead3c3825
265 changed files with 44099 additions and 44099 deletions

View File

@@ -1,326 +1,326 @@
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.converter.XMLDateConverter;
import org.alfresco.web.ui.common.renderer.BaseRenderer;
import org.alfresco.web.ui.repo.RepoConstants;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor.MultiValueEditorEvent;
/**
* Base class for renderers of the MultiValueEditor component.
* The current items are displayed as a list of options that can be
* removed using a Remove button.
*
* @author gavinc
*/
public abstract class BaseMultiValueRenderer extends BaseRenderer
{
/** I18N message strings */
protected final static String MSG_REMOVE = "remove";
protected final static String MSG_SELECT_BUTTON = "select_button";
protected final static String MSG_ADD_TO_LIST_BUTTON = "add_to_list_button";
protected boolean highlightedRow;
// ------------------------------------------------------------------------------
// Renderer implemenation
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void decode(FacesContext context, UIComponent component)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getHiddenFieldName(component);
String value = (String)requestMap.get(fieldId);
int action = UIMultiValueEditor.ACTION_NONE;
int removeIndex = -1;
if (value != null && value.length() != 0)
{
// break up the action into it's parts
int sepIdx = value.indexOf(UIMultiValueEditor.ACTION_SEPARATOR);
if (sepIdx != -1)
{
action = Integer.parseInt(value.substring(0, sepIdx));
removeIndex = Integer.parseInt(value.substring(sepIdx+1));
}
else
{
action = Integer.parseInt(value);
}
}
if (action != UIMultiValueEditor.ACTION_NONE)
{
MultiValueEditorEvent event = new MultiValueEditorEvent(component, action, removeIndex);
component.queueEvent(event);
}
super.decode(context, component);
}
/**
* @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("static-access")
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
// reset the highlighted row flag
this.highlightedRow = false;
if (component instanceof UIMultiValueEditor)
{
ResponseWriter out = context.getResponseWriter();
Map attrs = component.getAttributes();
UIMultiValueEditor editor = (UIMultiValueEditor)component;
// start outer table
out.write("<table border='0' cellspacing='3' cellpadding='3'");
this.outputAttribute(out, attrs.get("style"), "style");
this.outputAttribute(out, attrs.get("styleClass"), "class");
out.write(">");
// render the area before the wrapped component
renderPreWrappedComponent(context, out, editor);
}
}
/**
* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
if (component instanceof UIMultiValueEditor)
{
ResponseWriter out = context.getResponseWriter();
UIMultiValueEditor editor = (UIMultiValueEditor)component;
// get hold of the node service
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
// render the area between the component and current items list
renderPostWrappedComponent(context, out, editor);
// show the currently selected items
out.write("<tr><td style='padding-top:8px'>");
out.write(editor.getSelectedItemsMsg());
out.write("</td></tr>");
out.write("<tr><td><table cellspacing='0' cellpadding='2' border='0' class='selectedItems'>");
out.write("<tr><td colspan='2' class='selectedItemsHeader'>");
out.write(Application.getMessage(context, "name"));
out.write("</td></tr>");
List currentItems = (List)editor.getValue();;
if (currentItems != null && currentItems.size() > 0)
{
for (int x = 0; x < currentItems.size(); x++)
{
Object obj = currentItems.get(x);
if (obj != null)
{
if (obj instanceof NodeRef)
{
if (nodeService.exists((NodeRef)obj))
{
renderExistingItem(context, component, out, nodeService, x, obj);
}
else
{
// remove invalid NodeRefs from the list
currentItems.remove(x);
}
}
else
{
renderExistingItem(context, component, out, nodeService, x, obj);
}
}
}
}
else
{
out.write("<tr><td class='selectedItemsRow'>");
out.write(editor.getNoSelectedItemsMsg());
out.write("</td></tr>");
}
// close tables
out.write("</table></td></tr></table>\n");
// output a hidden field containing the current value
out.write("<input type='hidden' id='");
out.write(component.getClientId(context));
out.write("_current_value");
out.write("' name='");
out.write(component.getClientId(context));
out.write("_current_value");
out.write("' value='");
if (currentItems != null && currentItems.size() > 0)
{
out.write(currentItems.toString());
}
out.write("' />");
}
}
/**
* Renders the area of the component before the wrapped component appears.
*
* @param context FacesContext
* @param out The ResponseWriter to write to
* @param editor The multi value editor component
*/
protected abstract void renderPreWrappedComponent(FacesContext context,
ResponseWriter out, UIMultiValueEditor editor) throws IOException;
/**
* Renders the area of the component after the wrapped component but before the list
* of currently selected values.
*
* @param context FacesContext
* @param out The ResponseWriter to write to
* @param editor The multi value editor component
*/
protected abstract void renderPostWrappedComponent(FacesContext context,
ResponseWriter out, UIMultiValueEditor editor) throws IOException;
/**
* Renders an existing item with a remove button
*
* @param context FacesContext
* @param component The UIComponent
* @param out Writer to write output to
* @param nodeService The NodeService
* @param index The index of the item
* @param value The item's value
* @throws IOException
*/
protected void renderExistingItem(FacesContext context, UIComponent component, ResponseWriter out,
NodeService nodeService, int index, Object value) throws IOException
{
out.write("<tr><td class='");
if (this.highlightedRow)
{
out.write("selectedItemsRowAlt");
}
else
{
out.write("selectedItemsRow");
}
out.write("'>");
if (value instanceof NodeRef)
{
String name;
if (ContentModel.TYPE_CATEGORY.equals(nodeService.getType((NodeRef)value)))
{
name = Repository.getNameForCategoryNode(nodeService, (NodeRef)value);
}
else
{
name = Repository.getNameForNode(nodeService, (NodeRef)value);
}
out.write(Utils.encode(name));
}
else if (value instanceof Date)
{
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
UIComponent childComponent = (UIComponent)component.getChildren().get(0);
Boolean showTime = (Boolean)childComponent.getAttributes().get("showTime");
if (showTime != null && showTime.booleanValue())
{
converter.setPattern(Application.getMessage(context, "date_time_pattern"));
}
else
{
converter.setPattern(Application.getMessage(context, "date_pattern"));
}
out.write(converter.getAsString(context, childComponent, value));
}
else if (value instanceof Boolean)
{
Converter converter = context.getApplication().createConverter(
RepoConstants.ALFRESCO_FACES_BOOLEAN_CONVERTER);
out.write(converter.getAsString(context,
(UIComponent)component.getChildren().get(0), value));
}
else
{
out.write(Utils.encode(value.toString()));
}
out.write("&nbsp;&nbsp;");
out.write("</td><td class='");
if (this.highlightedRow)
{
out.write("selectedItemsRowAlt");
}
else
{
out.write("selectedItemsRow");
}
out.write("'><a href='#' title='");
out.write(Application.getMessage(context, MSG_REMOVE));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, component, UIMultiValueEditor.ACTION_REMOVE + UIMultiValueEditor.ACTION_SEPARATOR + index));
out.write("\"><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/delete.gif' border='0' width='13' height='16'/></a>");
this.highlightedRow = !this.highlightedRow;
}
/**
* We use a hidden field per picker instance on the page.
*
* @return hidden field name
*/
protected String getHiddenFieldName(UIComponent component)
{
return component.getClientId(FacesContext.getCurrentInstance());
}
/**
* Generate FORM submit JavaScript for the specified action
*
* @param context FacesContext
* @param component The UIComponent
* @param action Action string
*
* @return FORM submit JavaScript
*/
protected String generateFormSubmit(FacesContext context, UIComponent component, String action)
{
return Utils.generateFormSubmit(context, component, getHiddenFieldName(component), action);
}
}
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.converter.XMLDateConverter;
import org.alfresco.web.ui.common.renderer.BaseRenderer;
import org.alfresco.web.ui.repo.RepoConstants;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor.MultiValueEditorEvent;
/**
* Base class for renderers of the MultiValueEditor component.
* The current items are displayed as a list of options that can be
* removed using a Remove button.
*
* @author gavinc
*/
public abstract class BaseMultiValueRenderer extends BaseRenderer
{
/** I18N message strings */
protected final static String MSG_REMOVE = "remove";
protected final static String MSG_SELECT_BUTTON = "select_button";
protected final static String MSG_ADD_TO_LIST_BUTTON = "add_to_list_button";
protected boolean highlightedRow;
// ------------------------------------------------------------------------------
// Renderer implemenation
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void decode(FacesContext context, UIComponent component)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getHiddenFieldName(component);
String value = (String)requestMap.get(fieldId);
int action = UIMultiValueEditor.ACTION_NONE;
int removeIndex = -1;
if (value != null && value.length() != 0)
{
// break up the action into it's parts
int sepIdx = value.indexOf(UIMultiValueEditor.ACTION_SEPARATOR);
if (sepIdx != -1)
{
action = Integer.parseInt(value.substring(0, sepIdx));
removeIndex = Integer.parseInt(value.substring(sepIdx+1));
}
else
{
action = Integer.parseInt(value);
}
}
if (action != UIMultiValueEditor.ACTION_NONE)
{
MultiValueEditorEvent event = new MultiValueEditorEvent(component, action, removeIndex);
component.queueEvent(event);
}
super.decode(context, component);
}
/**
* @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("static-access")
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
// reset the highlighted row flag
this.highlightedRow = false;
if (component instanceof UIMultiValueEditor)
{
ResponseWriter out = context.getResponseWriter();
Map attrs = component.getAttributes();
UIMultiValueEditor editor = (UIMultiValueEditor)component;
// start outer table
out.write("<table border='0' cellspacing='3' cellpadding='3'");
this.outputAttribute(out, attrs.get("style"), "style");
this.outputAttribute(out, attrs.get("styleClass"), "class");
out.write(">");
// render the area before the wrapped component
renderPreWrappedComponent(context, out, editor);
}
}
/**
* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
if (component instanceof UIMultiValueEditor)
{
ResponseWriter out = context.getResponseWriter();
UIMultiValueEditor editor = (UIMultiValueEditor)component;
// get hold of the node service
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
// render the area between the component and current items list
renderPostWrappedComponent(context, out, editor);
// show the currently selected items
out.write("<tr><td style='padding-top:8px'>");
out.write(editor.getSelectedItemsMsg());
out.write("</td></tr>");
out.write("<tr><td><table cellspacing='0' cellpadding='2' border='0' class='selectedItems'>");
out.write("<tr><td colspan='2' class='selectedItemsHeader'>");
out.write(Application.getMessage(context, "name"));
out.write("</td></tr>");
List currentItems = (List)editor.getValue();;
if (currentItems != null && currentItems.size() > 0)
{
for (int x = 0; x < currentItems.size(); x++)
{
Object obj = currentItems.get(x);
if (obj != null)
{
if (obj instanceof NodeRef)
{
if (nodeService.exists((NodeRef)obj))
{
renderExistingItem(context, component, out, nodeService, x, obj);
}
else
{
// remove invalid NodeRefs from the list
currentItems.remove(x);
}
}
else
{
renderExistingItem(context, component, out, nodeService, x, obj);
}
}
}
}
else
{
out.write("<tr><td class='selectedItemsRow'>");
out.write(editor.getNoSelectedItemsMsg());
out.write("</td></tr>");
}
// close tables
out.write("</table></td></tr></table>\n");
// output a hidden field containing the current value
out.write("<input type='hidden' id='");
out.write(component.getClientId(context));
out.write("_current_value");
out.write("' name='");
out.write(component.getClientId(context));
out.write("_current_value");
out.write("' value='");
if (currentItems != null && currentItems.size() > 0)
{
out.write(currentItems.toString());
}
out.write("' />");
}
}
/**
* Renders the area of the component before the wrapped component appears.
*
* @param context FacesContext
* @param out The ResponseWriter to write to
* @param editor The multi value editor component
*/
protected abstract void renderPreWrappedComponent(FacesContext context,
ResponseWriter out, UIMultiValueEditor editor) throws IOException;
/**
* Renders the area of the component after the wrapped component but before the list
* of currently selected values.
*
* @param context FacesContext
* @param out The ResponseWriter to write to
* @param editor The multi value editor component
*/
protected abstract void renderPostWrappedComponent(FacesContext context,
ResponseWriter out, UIMultiValueEditor editor) throws IOException;
/**
* Renders an existing item with a remove button
*
* @param context FacesContext
* @param component The UIComponent
* @param out Writer to write output to
* @param nodeService The NodeService
* @param index The index of the item
* @param value The item's value
* @throws IOException
*/
protected void renderExistingItem(FacesContext context, UIComponent component, ResponseWriter out,
NodeService nodeService, int index, Object value) throws IOException
{
out.write("<tr><td class='");
if (this.highlightedRow)
{
out.write("selectedItemsRowAlt");
}
else
{
out.write("selectedItemsRow");
}
out.write("'>");
if (value instanceof NodeRef)
{
String name;
if (ContentModel.TYPE_CATEGORY.equals(nodeService.getType((NodeRef)value)))
{
name = Repository.getNameForCategoryNode(nodeService, (NodeRef)value);
}
else
{
name = Repository.getNameForNode(nodeService, (NodeRef)value);
}
out.write(Utils.encode(name));
}
else if (value instanceof Date)
{
XMLDateConverter converter = (XMLDateConverter)context.getApplication().
createConverter(RepoConstants.ALFRESCO_FACES_XMLDATE_CONVERTER);
UIComponent childComponent = (UIComponent)component.getChildren().get(0);
Boolean showTime = (Boolean)childComponent.getAttributes().get("showTime");
if (showTime != null && showTime.booleanValue())
{
converter.setPattern(Application.getMessage(context, "date_time_pattern"));
}
else
{
converter.setPattern(Application.getMessage(context, "date_pattern"));
}
out.write(converter.getAsString(context, childComponent, value));
}
else if (value instanceof Boolean)
{
Converter converter = context.getApplication().createConverter(
RepoConstants.ALFRESCO_FACES_BOOLEAN_CONVERTER);
out.write(converter.getAsString(context,
(UIComponent)component.getChildren().get(0), value));
}
else
{
out.write(Utils.encode(value.toString()));
}
out.write("&nbsp;&nbsp;");
out.write("</td><td class='");
if (this.highlightedRow)
{
out.write("selectedItemsRowAlt");
}
else
{
out.write("selectedItemsRow");
}
out.write("'><a href='#' title='");
out.write(Application.getMessage(context, MSG_REMOVE));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, component, UIMultiValueEditor.ACTION_REMOVE + UIMultiValueEditor.ACTION_SEPARATOR + index));
out.write("\"><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/delete.gif' border='0' width='13' height='16'/></a>");
this.highlightedRow = !this.highlightedRow;
}
/**
* We use a hidden field per picker instance on the page.
*
* @return hidden field name
*/
protected String getHiddenFieldName(UIComponent component)
{
return component.getClientId(FacesContext.getCurrentInstance());
}
/**
* Generate FORM submit JavaScript for the specified action
*
* @param context FacesContext
* @param component The UIComponent
* @param action Action string
*
* @return FORM submit JavaScript
*/
protected String generateFormSubmit(FacesContext context, UIComponent component, String action)
{
return Utils.generateFormSubmit(context, component, getHiddenFieldName(component), action);
}
}

View File

@@ -1,55 +1,55 @@
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
/**
* Renders the MultiValueEditor component for use with field components
* i.e. text, checkboxes, lists etc.
*
* This renderer does not show a "select item" message or a select button,
* the wrapped component is shown immediately with an add to list button
* after it.
*
* @author gavinc
*/
public class MultiValueFieldRenderer extends BaseMultiValueRenderer
{
@Override
protected void renderPreWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
out.write("<tr><td>");
}
@SuppressWarnings("unchecked")
@Override
protected void renderPostWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
out.write("&nbsp;<input type='button' value='");
out.write(Application.getMessage(context, MSG_ADD_TO_LIST_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_ADD)));
out.write("\"/>");
// if the wrapped component is an mltext field add the icon
if (editor.getAttributes().get("mltext") != null)
{
String tooltip = Application.getMessage(context, "marker_tooltip");
out.write("<img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
out.write("</td></tr>");
}
}
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
/**
* Renders the MultiValueEditor component for use with field components
* i.e. text, checkboxes, lists etc.
*
* This renderer does not show a "select item" message or a select button,
* the wrapped component is shown immediately with an add to list button
* after it.
*
* @author gavinc
*/
public class MultiValueFieldRenderer extends BaseMultiValueRenderer
{
@Override
protected void renderPreWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
out.write("<tr><td>");
}
@SuppressWarnings("unchecked")
@Override
protected void renderPostWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
out.write("&nbsp;<input type='button' value='");
out.write(Application.getMessage(context, MSG_ADD_TO_LIST_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_ADD)));
out.write("\"/>");
// if the wrapped component is an mltext field add the icon
if (editor.getAttributes().get("mltext") != null)
{
String tooltip = Application.getMessage(context, "marker_tooltip");
out.write("<img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
out.write("</td></tr>");
}
}

View File

@@ -1,68 +1,68 @@
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
/**
* Renders the MultiValueEditor component for use with picker components.
*
* This renderer shows a "select items" message and a select button. When
* the select button is pressed the wrapped component will appear and the
* add to list button will be enabled.
*
* @author gavinc
*/
public class MultiValueSelectorRenderer extends BaseMultiValueRenderer
{
@Override
protected void renderPreWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
// show the select an item message
out.write("<tr><td>");
out.write("1. ");
out.write(editor.getSelectItemMsg());
out.write("</td></tr>");
if (editor.getAddingNewItem())
{
out.write("<tr><td style='padding-left:8px'>");
}
else
{
out.write("<tr><td style='padding-left:8px;'><input type='submit' value='");
out.write(Application.getMessage(context, MSG_SELECT_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_SELECT)));
out.write("\"/></td></tr>");
}
}
@Override
protected void renderPostWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
if (editor.getAddingNewItem())
{
out.write("</td></tr>");
}
// show the add to list button but only if something has been selected
out.write("<tr><td>2. <input type='submit'");
if (editor.getAddingNewItem() == false && editor.getLastItemAdded() != null ||
editor.getLastItemAdded() == null)
{
out.write(" disabled='true'");
}
out.write(" value='");
out.write(Application.getMessage(context, MSG_ADD_TO_LIST_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_ADD)));
out.write("\"/></td></tr>");
}
}
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.repo.component.UIMultiValueEditor;
/**
* Renders the MultiValueEditor component for use with picker components.
*
* This renderer shows a "select items" message and a select button. When
* the select button is pressed the wrapped component will appear and the
* add to list button will be enabled.
*
* @author gavinc
*/
public class MultiValueSelectorRenderer extends BaseMultiValueRenderer
{
@Override
protected void renderPreWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
// show the select an item message
out.write("<tr><td>");
out.write("1. ");
out.write(editor.getSelectItemMsg());
out.write("</td></tr>");
if (editor.getAddingNewItem())
{
out.write("<tr><td style='padding-left:8px'>");
}
else
{
out.write("<tr><td style='padding-left:8px;'><input type='submit' value='");
out.write(Application.getMessage(context, MSG_SELECT_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_SELECT)));
out.write("\"/></td></tr>");
}
}
@Override
protected void renderPostWrappedComponent(FacesContext context, ResponseWriter out,
UIMultiValueEditor editor) throws IOException
{
if (editor.getAddingNewItem())
{
out.write("</td></tr>");
}
// show the add to list button but only if something has been selected
out.write("<tr><td>2. <input type='submit'");
if (editor.getAddingNewItem() == false && editor.getLastItemAdded() != null ||
editor.getLastItemAdded() == null)
{
out.write(" disabled='true'");
}
out.write(" value='");
out.write(Application.getMessage(context, MSG_ADD_TO_LIST_BUTTON));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, editor, Integer.toString(UIMultiValueEditor.ACTION_ADD)));
out.write("\"/></td></tr>");
}
}

View File

@@ -1,52 +1,52 @@
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.apache.myfaces.renderkit.html.HtmlTextareaRenderer;
/**
* Renders a multilingual text area.
* <p>
* Renders the default output followed by an icon
* to represent multilingual properties.
* </p>
*
* @author gavinc
*/
public class MultilingualTextAreaRenderer extends HtmlTextareaRenderer
{
@Override
protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
// to workaround a bug in MyFaces where it appears a new line gets removed
// in the process view/edit process add it back (ETWOONE-91)
Object value = ((ValueHolder) uiComponent).getValue();
String valueStr = null;
if (value != null)
{
valueStr = "\r\n" + (String)value;
}
((ValueHolder) uiComponent).setValue(valueStr);
super.encodeTextArea(facesContext, uiComponent);
}
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
super.encodeEnd(facesContext, component);
String tooltip = Application.getMessage(facesContext, "marker_tooltip");
ResponseWriter out = facesContext.getResponseWriter();
out.write("<img src='");
out.write(facesContext.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
}
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.apache.myfaces.renderkit.html.HtmlTextareaRenderer;
/**
* Renders a multilingual text area.
* <p>
* Renders the default output followed by an icon
* to represent multilingual properties.
* </p>
*
* @author gavinc
*/
public class MultilingualTextAreaRenderer extends HtmlTextareaRenderer
{
@Override
protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
// to workaround a bug in MyFaces where it appears a new line gets removed
// in the process view/edit process add it back (ETWOONE-91)
Object value = ((ValueHolder) uiComponent).getValue();
String valueStr = null;
if (value != null)
{
valueStr = "\r\n" + (String)value;
}
((ValueHolder) uiComponent).setValue(valueStr);
super.encodeTextArea(facesContext, uiComponent);
}
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
super.encodeEnd(facesContext, component);
String tooltip = Application.getMessage(facesContext, "marker_tooltip");
ResponseWriter out = facesContext.getResponseWriter();
out.write("<img src='");
out.write(facesContext.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
}

View File

@@ -1,36 +1,36 @@
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
/**
* Renders a multilingual text field.
* <p>
* Renders the default output followed by an icon
* to represent multilingual properties.
* </p>
*
* @author gavinc
*/
public class MultilingualTextRenderer extends HtmlTextRenderer
{
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
super.encodeEnd(facesContext, component);
String tooltip = Application.getMessage(facesContext, "marker_tooltip");
ResponseWriter out = facesContext.getResponseWriter();
out.write("<img src='");
out.write(facesContext.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
}
package org.alfresco.web.ui.repo.renderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application;
import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
/**
* Renders a multilingual text field.
* <p>
* Renders the default output followed by an icon
* to represent multilingual properties.
* </p>
*
* @author gavinc
*/
public class MultilingualTextRenderer extends HtmlTextRenderer
{
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
super.encodeEnd(facesContext, component);
String tooltip = Application.getMessage(facesContext, "marker_tooltip");
ResponseWriter out = facesContext.getResponseWriter();
out.write("<img src='");
out.write(facesContext.getExternalContext().getRequestContextPath());
out.write("/images/icons/multilingual_marker.gif' title='");
out.write(tooltip);
out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
}

View File

@@ -1,106 +1,106 @@
package org.alfresco.web.ui.repo.renderer.property;
import java.io.IOException;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.renderer.BaseRenderer;
/**
* Renderer for a PropertySheetItem component
*
* @author gavinc
*/
public class PropertySheetItemRenderer extends BaseRenderer
{
/**
* @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
// NOTE: we close off the first <td> generated by the property sheet's grid renderer
context.getResponseWriter().write("</td>");
}
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("unchecked")
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
ResponseWriter out = context.getResponseWriter();
// make sure there are 2 or 3 child components
int count = component.getChildCount();
if (count == 2 || count == 3)
{
// get the label and the control
List<UIComponent> children = component.getChildren();
UIComponent label = children.get(0);
UIComponent control = children.get(1);
// encode the mandatory marker component if present
if (count == 3)
{
out.write("<td>");
UIComponent mandatoryMarker = children.get(2);
Utils.encodeRecursive(context, mandatoryMarker);
out.write("</td>");
}
else
{
// output an empty column
out.write("<td>&nbsp;</td>");
}
// place a style class on the label column if necessary
String labelStylceClass = (String)component.getParent().getAttributes().get("labelStyleClass");
out.write("<td");
if (labelStylceClass != null)
{
outputAttribute(out, labelStylceClass, "class");
}
// close the <td>
out.write(">");
// encode the label
Utils.encodeRecursive(context, label);
// encode the control
out.write("</td><td>");
Utils.encodeRecursive(context, control);
// NOTE: we'll allow the property sheet's grid renderer close off the last <td>
}
}
/**
* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
// we don't need to do anything in here
}
/**
* @see javax.faces.render.Renderer#getRendersChildren()
*/
public boolean getRendersChildren()
{
return true;
}
}
package org.alfresco.web.ui.repo.renderer.property;
import java.io.IOException;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.renderer.BaseRenderer;
/**
* Renderer for a PropertySheetItem component
*
* @author gavinc
*/
public class PropertySheetItemRenderer extends BaseRenderer
{
/**
* @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
// NOTE: we close off the first <td> generated by the property sheet's grid renderer
context.getResponseWriter().write("</td>");
}
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("unchecked")
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
if (component.isRendered() == false)
{
return;
}
ResponseWriter out = context.getResponseWriter();
// make sure there are 2 or 3 child components
int count = component.getChildCount();
if (count == 2 || count == 3)
{
// get the label and the control
List<UIComponent> children = component.getChildren();
UIComponent label = children.get(0);
UIComponent control = children.get(1);
// encode the mandatory marker component if present
if (count == 3)
{
out.write("<td>");
UIComponent mandatoryMarker = children.get(2);
Utils.encodeRecursive(context, mandatoryMarker);
out.write("</td>");
}
else
{
// output an empty column
out.write("<td>&nbsp;</td>");
}
// place a style class on the label column if necessary
String labelStylceClass = (String)component.getParent().getAttributes().get("labelStyleClass");
out.write("<td");
if (labelStylceClass != null)
{
outputAttribute(out, labelStylceClass, "class");
}
// close the <td>
out.write(">");
// encode the label
Utils.encodeRecursive(context, label);
// encode the control
out.write("</td><td>");
Utils.encodeRecursive(context, control);
// NOTE: we'll allow the property sheet's grid renderer close off the last <td>
}
}
/**
* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
// we don't need to do anything in here
}
/**
* @see javax.faces.render.Renderer#getRendersChildren()
*/
public boolean getRendersChildren()
{
return true;
}
}