protected void encodeOverlays(WidgetBuilder wb, List<Overlay> overlays, String propertyName) throws IOException { StringBuilder sb = SharedStringBuilder.get(SB_DIAGRAM); if (overlays != null && !overlays.isEmpty()) { int overlaysSize = overlays.size(); wb.append(",").append(propertyName).append(":["); for (int j = 0; j < overlaysSize; j++) { Overlay overlay = overlays.get(j); sb.setLength(0); wb.append(overlay.toJS(sb)); if (j < (overlaysSize - 1)) { wb.append(","); } } wb.append("]"); } }
protected void encodePaginatorConfig(FacesContext context, Pageable pageable, WidgetBuilder wb) throws IOException { String clientId = pageable.getClientId(context); String paginatorPosition = pageable.getPaginatorPosition(); String paginatorContainers = null; String currentPageTemplate = pageable.getCurrentPageReportTemplate(); if (paginatorPosition.equalsIgnoreCase("both")) { paginatorContainers = "'" + clientId + "_paginator_top','" + clientId + "_paginator_bottom'"; } else { paginatorContainers = "'" + clientId + "_paginator_" + paginatorPosition + "'"; } wb.append(",paginator:{") .append("id:[").append(paginatorContainers).append("]") .append(",rows:").append(pageable.getRows()) .append(",rowCount:").append(pageable.getRowCount()) .append(",page:").append(pageable.getPage()); if (currentPageTemplate != null) { String currentPageTemplateTmp = currentPageTemplate.replace("'", "\\'"); wb.append(",currentPageTemplate:'").append(currentPageTemplateTmp).append("'"); } if (pageable.getPageLinks() != 10) { wb.append(",pageLinks:").append(pageable.getPageLinks()); } if (!pageable.isPaginatorAlwaysVisible()) { wb.append(",alwaysVisible:false"); } wb.append("}"); }
String scope = endPoint.getScope(); wb.append("{uuid:'").append(endPoint.getId()).append("'") .append(",element:'").append(elementClientId).append("'") .append(",anchor:'").append(endPoint.getAnchor().toString()).append("'"); wb.append(",maxConnections:").append(maxConnections); wb.append(",paintStyle:").append(style); wb.append(",hoverPaintStyle:").append(hoverStyle); wb.append(",isSource:true"); wb.append(",isTarget:true"); wb.append(",cssClass:'").append(styleClass).append("'"); wb.append(",hoverClass:'").append(hoverStyleClass).append("'"); wb.append(",scope:'").append(scope).append("'"); wb.append(",endpoint:").append(endPoint.toJS(sb)); wb.append("}");
protected void encodeIconStates(FacesContext context, Tree tree, WidgetBuilder wb) throws IOException { Map<String, UITreeNode> nodes = tree.getTreeNodes(); wb.append(",iconStates:{"); boolean firstWritten = false; for (Iterator<String> it = nodes.keySet().iterator(); it.hasNext(); ) { String type = it.next(); UITreeNode node = nodes.get(type); String expandedIcon = node.getExpandedIcon(); String collapsedIcon = node.getCollapsedIcon(); if (expandedIcon != null && collapsedIcon != null) { if (firstWritten) { wb.append(","); } wb.append("'" + node.getType() + "' : {"); wb.append("expandedIcon:'" + expandedIcon + "'"); wb.append(",collapsedIcon:'" + collapsedIcon + "'"); wb.append("}"); firstWritten = true; } } wb.append("}"); }
protected void encodeDefaults(WidgetBuilder wb, DiagramModel model) throws IOException { StringBuilder sb = SharedStringBuilder.get(SB_DIAGRAM); Connector defaultConnector = model.getDefaultConnector(); if (defaultConnector != null) { String paintStyle = defaultConnector.getPaintStyle(); String hoverPaintStyle = defaultConnector.getHoverPaintStyle(); wb.append(",defaultConnector:").append(defaultConnector.toJS(sb)); wb.append(",containment:").append("" + model.isContainment()); if (paintStyle != null) { wb.append(",paintStyle:").append(paintStyle); } if (hoverPaintStyle != null) { wb.append(",hoverPaintStyle:").append(hoverPaintStyle); } sb.setLength(0); } encodeOverlays(wb, model.getDefaultConnectionOverlays(), "connectionOverlays"); if (!model.isConnectionsDetachable()) { wb.append(",connectionsDetachable:false"); } int maxConnections = model.getMaxConnections(); if (maxConnections != 1) { wb.append(",maxConnections:").append(maxConnections); } }
protected void encodeEndPoints(WidgetBuilder wb, DiagramModel model, String clientId) throws IOException { List<Element> elements = model.getElements(); if (elements != null && !elements.isEmpty()) { int elementsSize = elements.size(); wb.append(",endPoints:["); for (int i = 0; i < elementsSize; i++) { Element element = elements.get(i); String elementClientId = clientId + "-" + element.getId(); List<EndPoint> endPoints = element.getEndPoints(); if (endPoints != null && !endPoints.isEmpty()) { int endPointsSize = endPoints.size(); for (int j = 0; j < endPointsSize; j++) { EndPoint endPoint = endPoints.get(j); encodeEndPoint(wb, endPoint, elementClientId); if (j < (endPointsSize - 1)) { wb.append(","); } } } if (i < (elementsSize - 1)) { wb.append(","); } } wb.append("]"); } }
int connectionsSize = connections.size(); wb.append(",connections:["); for (int i = 0; i < connectionsSize; i++) { Connection connection = connections.get(i); List<Overlay> overlays = connection.getOverlays(); wb.append("{uuids:['").append(connection.getSource().getId()).append("'") .append(",'").append(connection.getTarget().getId()).append("']"); wb.append(",connector:").append(connector.toJS(sb)); wb.append(",paintStyle:").append(paintStyle); wb.append(",hoverPaintStyle:").append(hoverPaintStyle); wb.append(",detachable:false"); wb.append("}"); wb.append(","); wb.append("]");
private void encodeScript(FacesContext context, TextEditor editor) throws IOException { String clientId = editor.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.init("TextEditor", editor.resolveWidgetVar(), clientId) .attr("toolbarVisible", editor.isToolbarVisible()) .attr("readOnly", editor.isReadonly(), false) .attr("placeholder", editor.getPlaceholder(), null) .attr("height", editor.getHeight(), Integer.MIN_VALUE); List formats = editor.getFormats(); if (formats != null) { wb.append(",formats:["); for (int i = 0; i < formats.size(); i++) { if (i != 0) { wb.append(","); } wb.append("\"" + EscapeUtils.forJavaScript((String) formats.get(i)) + "\""); } wb.append("]"); } encodeClientBehaviors(context, editor); wb.finish(); }
protected void encodeUnits(FacesContext context, Layout layout, WidgetBuilder wb) throws IOException { for (UIComponent child : layout.getChildren()) { if (child.isRendered() && child instanceof LayoutUnit) { LayoutUnit unit = (LayoutUnit) child; wb.append(",").append(unit.getPosition()).append(":{") .append("paneSelector:'#").append(ComponentUtils.escapeSelector(unit.getClientId(context))).append("'") .attr("size", unit.getSize()) .attr("resizable", unit.isResizable()) .attr("closable", unit.isCollapsible()) .attr("minSize", unit.getMinSize(), 50) .attr("maxSize", unit.getMaxSize(), 0) .attr("spacing_open", unit.getGutter(), 6); if (unit.isCollapsible()) { wb.attr("spacing_closed", unit.getCollapseSize()); } wb.attr("initHidden", !unit.isVisible(), false) .attr("initClosed", unit.isCollapsed(), false) .attr("fxName", unit.getEffect(), null) .attr("fxSpeed", unit.getEffectSpeed(), null) .attr("resizerTip", layout.getResizeTitle(), null) .attr("togglerTip_closed", layout.getExpandTitle(), null); wb.append("}"); } } } }
wb.append(",header:{left:'") .append(schedule.getLeftHeaderTemplate()).append("'") .attr("center", schedule.getCenterHeaderTemplate()) .attr("right", schedule.getRightHeaderTemplate()) .append("}"); wb.append(",weekNumberCalculation: function(){ return ") .append(schedule.getWeekNumberCalculator()) .append("}");
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Droppable droppable = (Droppable) component; String clientId = droppable.getClientId(context); renderDummyMarkup(context, component, clientId); UIComponent target = SearchExpressionFacade.resolveComponent( context, droppable, droppable.getFor(), SearchExpressionHint.PARENT_FALLBACK); WidgetBuilder wb = getWidgetBuilder(context); wb.init("Droppable", droppable.resolveWidgetVar(), clientId) .attr("target", target.getClientId(context)) .attr("disabled", droppable.isDisabled(), false) .attr("hoverClass", droppable.getHoverStyleClass(), null) .attr("activeClass", droppable.getActiveStyleClass(), null) .attr("accept", droppable.getAccept(), null) .attr("scope", droppable.getScope(), null) .attr("tolerance", droppable.getTolerance(), null) .attr("greedy", droppable.isGreedy(), false); if (droppable.getOnDrop() != null) { wb.append(",onDrop:").append(droppable.getOnDrop()); } encodeClientBehaviors(context, droppable); wb.finish(); }
protected void encodeOverlays(WidgetBuilder wb, List<Overlay> overlays, String propertyName) throws IOException { StringBuilder sb = SharedStringBuilder.get(SB_DIAGRAM); if (overlays != null && !overlays.isEmpty()) { int overlaysSize = overlays.size(); wb.append(",").append(propertyName).append(":["); for (int j = 0; j < overlaysSize; j++) { Overlay overlay = overlays.get(j); sb.setLength(0); wb.append(overlay.toJS(sb)); if (j < (overlaysSize - 1)) { wb.append(","); } } wb.append("]"); } }
protected void encodeScript(FacesContext context, Growl growl) throws IOException { WidgetBuilder wb = getWidgetBuilder(context); wb.initWithDomReady("Growl", growl.resolveWidgetVar(), growl.getClientId(context)); wb.attr("sticky", growl.isSticky(), false) .attr("life", growl.getLife(), 6000) .attr("escape", growl.isEscape(), true) .append(",msgs:"); encodeMessages(context, growl); wb.finish(); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Droppable droppable = (Droppable) component; UIComponent target = SearchExpressionFacade.resolveComponent( context, droppable, droppable.getFor(), SearchExpressionHint.PARENT_FALLBACK); String clientId = droppable.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.initWithDomReady("Droppable", droppable.resolveWidgetVar(), clientId) .attr("target", target.getClientId(context)) .attr("disabled", droppable.isDisabled(), false) .attr("hoverClass", droppable.getHoverStyleClass(), null) .attr("activeClass", droppable.getActiveStyleClass(), null) .attr("accept", droppable.getAccept(), null) .attr("scope", droppable.getScope(), null) .attr("tolerance", droppable.getTolerance(), null); if (droppable.getOnDrop() != null) { wb.append(",onDrop:").append(droppable.getOnDrop()); } encodeClientBehaviors(context, droppable); wb.finish(); }