public int getMaxNumRowsToDisplay(List<ITestUnit> tests, int columnCount) { if (tests == null) { return HTMLRenderer.ALL_ROWS; } return HTMLRenderer.getMaxNumRowsToDisplay(tests.size(), columnCount); }
public String renderJS(String jsPath) { Set<String> resources = getResourcesWritten(); if (resources.add(jsPath)) { return "<script src=\"" + internalPath(jsPath) + "\"></script>"; } return ""; }
public String render(TableEditor editor) { return render(editor, null, null, null); }
StringBuilder result = new StringBuilder(); result.append("<div>") .append(renderCSS("css/tableeditor.min.css")); result.append(renderJS("js/prototype/prototype-1.6.1.js")); result.append(renderJS("js/tableeditor.min.js")); result.append(renderEditorToolbar(editor.getId(), editorJsVar, mode)); if (openLTable != null && (editor.isEditable() || CollectionUtils.isNotEmpty(actionLinks))) { String menuId = editor.getId() + Constants.ID_POSTFIX_MENU; result.append(renderActionMenu(menuId, editor.isEditable(), actionLinks)); IGridFilter[] filters = editor.getFilters(); IGridTable table = openLTable.getGridTable(editor.getView()); int numRows = getMaxNumRowsToDisplay(table); TableModel tableModel = TableModel.initializeTableModel(table, filters, numRows, editor.getLinkBuilder(), mode, editor.getView(), openLTable.getMetaInfoReader()); String beforeEdit = getEditorJSAction(editor.getOnBeforeEdit()); String beforeSave = getEditorJSAction(editor.getOnBeforeSave()); String afterSave = getEditorJSAction(editor.getOnAfterSave()); String error = getEditorJSAction(editor.getOnError()); String requestStart = getEditorJSAction(editor.getOnRequestStart()); String requestEnd = getEditorJSAction(editor.getOnRequestEnd()); String relativeCellToEdit = getRelativeCellToEdit(cellToEdit, table, tableModel); result.append(renderJSBody("var " + editorJsVar + " = initTableEditor(\"" + editor.getId() + "\", \""
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); TableEditor tableEditor = new TableEditor(context, component); if (tableEditor.getTable() == null) { // required attribute return; } writer.write(new HTMLRenderer().render(tableEditor)); }
private String getEnumMultiSelectComponentCode(String componentId, TableProperty tableProperty) { Class<?> instanceClass = tableProperty.getType().getComponentType(); String valueString = tableProperty.getStringValue(); String[] values = EnumUtils.getNames(instanceClass); String[] displayValues = EnumUtils.getValues(instanceClass); String id = String.format("%s:%s:enumArraySelect", componentId, tableProperty.getName()); String componentCode = new HTMLRenderer().getMultiSelectComponentCode(id, values, displayValues, valueString); return getEditorHTMLCode(id, componentCode); }
private String getEnumSelectComponentCode(String componentId, TableProperty tableProperty) { Class<?> instanceClass = tableProperty.getType(); String value = tableProperty.getStringValue(); String[] values = EnumUtils.getNames(instanceClass); String[] displayValues = EnumUtils.getValues(instanceClass); String id = String.format("%s:%s:enumSelect", componentId, tableProperty.getName()); String componentCode = new HTMLRenderer().getSingleSelectComponentCode(id, values, displayValues, value); return getEditorHTMLCode(id, componentCode); }
final String toolbarItemSeparator = "<img src=" + internalPath("img/toolbarSeparator.gif") + " class=\"item_separator\"></img>"; .append(renderEditorToolbarItem(editorId + "_save_all", editorJsVar, "img/Save.gif", "save()", "Save changes")) .append(renderEditorToolbarItem(editorId + "_undo", editorJsVar, "img/Undo.gif", "undoredo()", "Undo changes")) .append(renderEditorToolbarItem(editorId + "_redo", editorJsVar, "img/Redo.gif", "undoredo(true)", "Redo changes")) .append(renderEditorToolbarItem(editorId + "_insert_row_before", editorJsVar, "img/insert_row.gif", "doTableOperation(TableEditor.Operations.INSERT_ROW_BEFORE)", "Insert row after")) // TODO: rename method names and fields to "after" .append(renderEditorToolbarItem(editorId + "_remove_row", editorJsVar, "img/delete_row.gif", "doTableOperation(TableEditor.Operations.REMOVE_ROW)", "Remove row")) .append(renderEditorToolbarItem(editorId + "_insert_column_before", editorJsVar, "img/insert_column.gif", "doTableOperation(TableEditor.Operations.INSERT_COLUMN_BEFORE)", "Insert column before")) .append(renderEditorToolbarItem(editorId + "_remove_column", editorJsVar, "img/delete_column.gif", "doTableOperation(TableEditor.Operations.REMOVE_COLUMN)", "Remove column")) .append(renderEditorToolbarItem(editorId + "_align_left", editorJsVar, "img/alLeft.gif", "setAlignment('left', this)", "Align the text to the left")) .append(renderEditorToolbarItem(editorId + "_align_center", editorJsVar, "img/alCenter.gif", "setAlignment('center', this)", "Center the text")) .append(renderEditorToolbarItem(editorId + "_align_right", editorJsVar, "img/alRight.gif", "setAlignment('right', this)", "Align the text to the right")) .append(renderEditorToolbarItem(editorId + "_font_bold", editorJsVar, "img/bold.png", "setFontBold('" + editorId + "_font_bold" + "')", "Make the text bold")) .append(renderEditorToolbarItem(editorId + "_font_italic", editorJsVar, "img/italic.png", "setFontItalic('" + editorId + "_font_italic" + "')", "Italicize the text")) .append(renderEditorToolbarItem(editorId + "_font_underline", editorJsVar, "img/underline.png",
public String renderJSBody(String jsBody) { Set<String> resources = getResourcesWritten(); if (resources.add(jsBody)) { return "<script>" + jsBody + "</script>"; } return ""; }
protected String renderEditorToolbarItem(String itemId, String editor, String imgSrc, String action, String title) { editor = (editor == null || editor.equals("")) ? "" : editor + "."; StringBuilder result = new StringBuilder(); result.append("<img id=\"").append(itemId) .append("\" src=\"").append(internalPath(imgSrc)) .append("\" title=\"").append(title) .append("\" onclick=\"").append(editor).append(action) .append("\" class='te_toolbar_item te_toolbar_item_disabled'") .append("></img>"); return result.toString(); }
StringBuilder result = new StringBuilder(); result.append("<div>") .append(renderCSS("css/tableeditor.min.css")); result.append(renderJS("js/prototype/prototype-1.6.1.js")); result.append(renderJS("js/tableeditor.min.js")); result.append(renderEditorToolbar(editor.getId(), editorJsVar, mode)); result.append(renderActionMenu(menuId, editor.isEditable(), actionLinks)); IGridFilter[] filters = editor.getFilters(); IGridTable table = editor.getTable().getGridTable(editor.getView()); int numRows = getMaxNumRowsToDisplay(table); TableModel tableModel = TableModel.initializeTableModel(table, filters, numRows, editor.getLinkBuilder(), mode, editor.getView()); String beforeEdit = getEditorJSAction(editor.getOnBeforeEdit()); String beforeSave = getEditorJSAction(editor.getOnBeforeSave()); String afterSave = getEditorJSAction(editor.getOnAfterSave()); String error = getEditorJSAction(editor.getOnError()); String requestStart = getEditorJSAction(editor.getOnRequestStart()); String requestEnd = getEditorJSAction(editor.getOnRequestEnd()); String relativeCellToEdit = getRelativeCellToEdit(cellToEdit, table, tableModel); result.append(renderJSBody("var " + editorJsVar + " = initTableEditor(\"" + editor.getId() + "\", \"" + internalPath("ajax/") + "\",\"" + relativeCellToEdit + "\"," + actions + "," + (Constants.MODE_EDIT.equals(mode) ? 1 : 0) + "," + editor.isEditable() + ");"));
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); TableEditor tableEditor = new TableEditor(context, component); if (tableEditor.getTable() == null) { // required attribute return; } writer.write(new HTMLRenderer().render(tableEditor)); }
final String toolbarItemSeparator = "<img src=" + internalPath("img/toolbarSeparator.gif") + " class=\"item_separator\"></img>"; .append(renderEditorToolbarItem(editorId + "_save_all", editorJsVar, "img/Save.gif", "save()", "Save changes")) .append(renderEditorToolbarItem(editorId + "_undo", editorJsVar, "img/Undo.gif", "undoredo()", "Undo changes")) .append(renderEditorToolbarItem(editorId + "_redo", editorJsVar, "img/Redo.gif", "undoredo(true)", "Redo changes")) .append(renderEditorToolbarItem(editorId + "_insert_row_before", editorJsVar, "img/insert_row.gif", "doTableOperation(TableEditor.Operations.INSERT_ROW_BEFORE)", "Insert row after")) // TODO: rename method names and fields to "after" .append(renderEditorToolbarItem(editorId + "_remove_row", editorJsVar, "img/delete_row.gif", "doTableOperation(TableEditor.Operations.REMOVE_ROW)", "Remove row")) .append(renderEditorToolbarItem(editorId + "_insert_column_before", editorJsVar, "img/insert_column.gif", "doTableOperation(TableEditor.Operations.INSERT_COLUMN_BEFORE)", "Insert column before")) .append(renderEditorToolbarItem(editorId + "_remove_column", editorJsVar, "img/delete_column.gif", "doTableOperation(TableEditor.Operations.REMOVE_COLUMN)", "Remove column")) .append(renderEditorToolbarItem(editorId + "_align_left", editorJsVar, "img/alLeft.gif", "setAlignment('left', this)", "Align the text to the left")) .append(renderEditorToolbarItem(editorId + "_align_center", editorJsVar, "img/alCenter.gif", "setAlignment('center', this)", "Center the text")) .append(renderEditorToolbarItem(editorId + "_align_right", editorJsVar, "img/alRight.gif", "setAlignment('right', this)", "Align the text to the right")) .append(renderEditorToolbarItem(editorId + "_font_bold", editorJsVar, "img/bold.png", "setFontBold('" + editorId + "_font_bold" + "')", "Make the text bold")) .append(renderEditorToolbarItem(editorId + "_font_italic", editorJsVar, "img/italic.png", "setFontItalic('" + editorId + "_font_italic" + "')", "Italicize the text")) .append(renderEditorToolbarItem(editorId + "_font_underline", editorJsVar, "img/underline.png",
public String renderJSBody(String jsBody) { Set<String> resources = getResourcesWritten(); if (resources.add(jsBody)) { return "<script>" + jsBody + "</script>"; } return ""; }
protected String renderEditorToolbarItem(String itemId, String editor, String imgSrc, String action, String title) { editor = (editor == null || editor.equals("")) ? "" : editor + "."; StringBuilder result = new StringBuilder(); result.append("<img id=\"").append(itemId) .append("\" src=\"").append(internalPath(imgSrc)) .append("\" title=\"").append(title) .append("\" onclick=\"").append(editor).append(action) .append("\" class='te_toolbar_item te_toolbar_item_disabled'") .append("></img>"); return result.toString(); }
public int getMaxNumRowsToDisplay(List<ITestUnit> tests, int columnCount) { if (tests == null) { return HTMLRenderer.ALL_ROWS; } return HTMLRenderer.getMaxNumRowsToDisplay(tests.size(), columnCount); }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); TableEditor tableEditor = new TableEditor(context, component); if (tableEditor.getTable() == null) { // Required attribute return; } ExternalContext externalContext = context.getExternalContext(); Map<String, String> requestMap = externalContext.getRequestParameterMap(); String cellToEdit = requestMap.get(Constants.REQUEST_PARAM_CELL); String errorCell = requestMap.get(Constants.REQUEST_PARAM_ERROR_CELL); List<ActionLink> actionLinks = getActionLinks(component); if (tableEditor.isEditable()) { initEditorModel(externalContext, tableEditor); } beforeRender(tableEditor); writer.write(new HTMLRenderer().render(tableEditor, cellToEdit, actionLinks, errorCell)); }
public String renderCSS(String cssPath) { Set<String> resources = getResourcesWritten(); if (resources.add(cssPath)) { return "<link rel=\"stylesheet\" href=\"" + internalPath(cssPath) + "\"></link>"; } return ""; }
public String render(TableEditor editor) { return render(editor, null, null, null); }
public List<ITestUnit> getTestsToRender(List<ITestUnit> tests, int columnCount) { if (tests == null) { return null; } int rows = HTMLRenderer.getMaxNumRowsToDisplay(tests.size(), columnCount); if (rows == HTMLRenderer.ALL_ROWS) { return tests; } return tests.subList(0, Math.min(rows, tests.size())); }