use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class AssessmentTreeComponentRenderer method renderAssessmentItemLink.
/**
* @param sb
* @param component
* @param itemNode
* @return The event used or null
*/
private Event renderAssessmentItemLink(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
String key = itemNode.getKey().toString();
Form form = component.getQtiItem().getRootForm();
String dispatchId = component.getQtiItem().getFormDispatchId();
TestSessionController testSessionController = component.getTestSessionController();
TestSessionState testSessionState = testSessionController.getTestSessionState();
TestPart testPart = testSessionController.getCurrentTestPart();
TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
Event event;
if (testPart == null || testPart.getNavigationMode() == NavigationMode.NONLINEAR) {
if (testSessionState.isEnded() || currentTestPartSessionState.isEnded()) {
if (itemNode.getEffectiveItemSessionControl().isAllowReview() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
event = Event.reviewItem;
} else {
event = null;
}
} else {
event = Event.selectItem;
}
} else {
event = null;
}
if (event == null) {
sb.append("<span class='o_assessmentitem_nav_disabled'>");
} else {
sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", event.name()), new NameValuePair("item", key))).append(";\" class='o_sel_assessmentitem'>");
}
String title;
if (component.isShowTitles()) {
title = StringHelper.escapeHtml(itemNode.getSectionPartTitle());
} else {
int num = component.getCandidateSessionContext().getNumber(itemNode);
title = translator.translate("question.title", new String[] { Integer.toString(num) });
}
sb.append("<span class='questionTitle'>").append(title).append("</span>");
if (event == null) {
sb.append("</span>");
} else {
sb.append("</a>");
}
return event;
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class FolderComponentRenderer method renderList.
private void renderList(StringOutput target, FolderComponent fc, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
VFSContainer currentContainer = fc.getCurrentContainer();
boolean canWrite = currentContainer.canWrite() == VFSConstants.YES;
boolean canCreateFolder = true;
if (currentContainer.getLocalSecurityCallback() != null && !currentContainer.getLocalSecurityCallback().canCreateFolder()) {
canCreateFolder = false;
}
boolean canDelete = false;
boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
boolean canMail = fc.isCanMail();
for (Iterator<VFSItem> iter = fc.getCurrentContainerChildren().iterator(); iter.hasNext(); ) {
VFSItem child = iter.next();
if (child.canDelete() == VFSConstants.YES) {
canDelete = true;
break;
}
}
String formName = "folder" + CodeHelper.getRAMUniqueID();
target.append("<form method=\"post\" id=\"").append(formName).append("\" action=\"");
ubu.buildURI(target, new String[] { VelocityContainer.COMMAND_ID }, new String[] { FolderRunController.FORM_ACTION }, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
target.append("\" ");
if (iframePostEnabled) {
// add ajax iframe target
target.append("\" onsubmit=\"o_XHRSubmit('").append(formName).append("');\">");
target.append("<input id=\"o_mai_").append(formName).append("\" type=\"hidden\" name=\"multi_action_identifier\" value=\"\"").append(" />");
} else {
target.append("\" onsubmit=\"if ( b_briefcase_isChecked('").append(formName).append("', '").append(Formatter.escapeSingleAndDoubleQuotes(StringHelper.escapeHtml(translator.translate("alert")).toString())).append("')) { if(o_info.linkbusy) return false; else o_beforeserver(); return true; } else {return false; }\">");
}
target.append("<div class=\"o_bc_createactions clearfix\"><ul class='nav navbar-nav navbar-right'>");
if (canWrite) {
if (canVersion) {
// deleted files
target.append("<li><a class=\"o_bc_deletedfiles\"");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "dfiles")).append("><i class='o_icon o_icon_recycle o_icon-fw'></i> ").append(translator.translate("dfiles")).append("</a></li>");
}
if (canWrite) {
if (fc.getExternContainerForCopy() != null && (fc.getExternContainerForCopy().getLocalSecurityCallback() == null || fc.getExternContainerForCopy().getLocalSecurityCallback().canCopy())) {
// option copy file
target.append("<li><a class=\"o_bc_copy\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "copyfile")).append("><i class='o_icon o_icon_copy o_icon-fw'></i> ").append(translator.translate("copyfile")).append("</a></li>");
}
// option upload
target.append("<li><a class='o_bc_upload' ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "ul")).append("><i class='o_icon o_icon_upload o_icon-fw'></i> ").append(translator.translate("ul")).append("</a></li>");
if (canCreateFolder) {
// option new folder
target.append("<li><a class=\"b_bc_newfolder\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "cf")).append("><i class='o_icon o_icon_new_folder o_icon-fw'></i> ").append(translator.translate("cf")).append("</a></li>");
}
// option new file
target.append("<li><a class=\"b_bc_newfile\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "cfile")).append("><i class='o_icon o_icon_new_document o_icon-fw'></i> ").append(translator.translate("cfile")).append("</a></li>");
}
}
// placeholder for the search
target.append("</ul></div>");
// add current file bread crumb path
crumbRenderer.render(fc, target, ubu, iframePostEnabled);
// add file listing for current folder
target.append("<div class='o_table_wrapper'>");
listRenderer.render(fc, target, ubu, translator, iframePostEnabled);
if (fc.getCurrentContainerChildren().size() > 0) {
target.append("<div class='o_table_footer'>").append("<div class=\"o_table_checkall input-sm\">").append("<label class='checkbox-inline'><a href=\"#\" onclick=\"javascript:b_briefcase_toggleCheck('").append(formName).append("', true)\">").append("<input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\" />").append(translator.translate("checkall")).append("</a></label> <label class='checkbox-inline'><a href=\"#\" onclick=\"javascript:b_briefcase_toggleCheck('").append(formName).append("', false)\">").append("<input type=\"checkbox\" disabled=\"disabled\" />").append(translator.translate("uncheckall")).append("</a></label></div>").append("<div class='o_table_buttons'>");
if (canMail) {
target.append("<button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_MAIL).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("send"))).append("</span></button>");
}
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_DOWNLOAD_ZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("download"))).append("</span></button>");
if (canDelete) {
// delete
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_DEL).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("del"))).append("</span></button>");
}
if (canWrite) {
// move
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_MOVE).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("move"))).append("</span></button>");
// copy
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_COPY).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("copy"))).append("</span></button>");
// zip
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_ZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("zip"))).append("</span></button>");
// unzip
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_UNZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("unzip"))).append("</span></button>");
}
target.append("</div></div>");
}
target.append("</div></form>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class StaticFlexiCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
String cellAction = getAction();
if (StringHelper.containsNonWhitespace(cellAction)) {
FlexiTableElementImpl ftE = source.getFlexiTableElement();
String id = source.getFormDispatchId();
Form rootForm = ftE.getRootForm();
NameValuePair pair = new NameValuePair(cellAction, Integer.toString(row));
String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair);
target.append("<a href=\"javascript:").append(jsCode).append(";\"");
if (StringHelper.containsNonWhitespace(linkTitle)) {
target.append(" title=\"").append(StringEscapeUtils.escapeHtml(linkTitle)).append("\"");
}
if (StringHelper.containsNonWhitespace(linkCSS)) {
target.append(" class=\"").append(linkCSS).append("\"");
}
target.append(">");
if (StringHelper.containsNonWhitespace(iconLeftCSS)) {
target.append("<i class=\"o_icon ").append(iconLeftCSS).append("\"> </i>");
}
if (labelDelegate == null) {
target.append(getLabel());
} else {
labelDelegate.render(renderer, target, cellValue, row, source, ubu, translator);
}
if (StringHelper.containsNonWhitespace(iconRightCSS)) {
target.append(" <i class=\"o_icon ").append(iconRightCSS).append("\"> </i>");
}
target.append("</a>");
} else if (labelDelegate == null) {
target.append(getLabel());
} else {
labelDelegate.render(renderer, target, cellValue, row, source, ubu, translator);
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class TreeNodeFlexiCellRenderer method renderIndented.
private void renderIndented(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
FlexiTableElementImpl ftE = source.getFlexiTableElement();
FlexiTreeTableDataModel<?> treeTableModel = ftE.getTreeTableDataModel();
String id = source.getFormDispatchId();
Form rootForm = ftE.getRootForm();
// indentation
int indentation = treeTableModel.getIndentation(row);
boolean hasChildren = treeTableModel.hasChildren(row);
target.append("<div class='o_table_flexi_l").append(indentation).append(" o_table_flexi_leaf", !hasChildren).append("'>");
if (hasChildren) {
NameValuePair pair;
boolean open = treeTableModel.isOpen(row);
if (open) {
pair = new NameValuePair("tt-close", Integer.toString(row));
} else {
pair = new NameValuePair("tt-open", Integer.toString(row));
}
String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair);
target.append("<a href=\"javascript:").append(jsCode).append(";\"><i class='o_icon o_icon-fw ");
if (open) {
target.append("o_icon_close_tree");
} else {
target.append("o_icon_open_tree");
}
target.append("'> </i></a> ");
}
NameValuePair pair = new NameValuePair("tt-focus", Integer.toString(row));
String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, false, false, pair);
target.append("<a href=\"javascript:").append(jsCode).append(";\">");
labelDelegate.render(renderer, target, cellValue, row, source, ubu, translator);
target.append("</a></div>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class FlexiTableClassicRenderer method renderRow.
@Override
protected void renderRow(Renderer renderer, StringOutput target, FlexiTableComponent ftC, String rowIdPrefix, int row, URLBuilder ubu, Translator translator, RenderResult renderResult) {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
FlexiTableColumnModel columnsModel = ftE.getTableDataModel().getTableColumnModel();
int numOfCols = columnsModel.getColumnCount();
Form theForm = ftE.getRootForm();
// use alternating css class
int numOfColumns = 0;
target.append("<tr id='").append(rowIdPrefix).append(row).append("'");
if (ftE.getCssDelegate() != null) {
String cssClass = ftE.getCssDelegate().getRowCssClass(FlexiTableRendererType.classic, row);
if (StringHelper.containsNonWhitespace(cssClass)) {
target.append(" class='").append(cssClass).append("'");
}
}
target.append(">");
if (ftE.isMultiSelect()) {
target.append("<td>").append("<input type='checkbox' name='tb_ms' value='").append(rowIdPrefix).append(row).append("'").append(" onclick=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, false, false, false, new NameValuePair("chkbox", Integer.toString(row)))).append(";\"");
if (ftE.isMultiSelectedIndex(row)) {
target.append(" checked='checked'");
}
boolean selectable = ftE.getTableDataModel().isSelectable(row);
if (!selectable) {
target.append(" disabled='disabled'");
}
target.append("/></td>");
}
for (int j = 0; j < numOfCols; j++) {
FlexiColumnModel fcm = columnsModel.getColumnModel(j);
if (ftE.isColumnModelVisible(fcm)) {
renderCell(renderer, target, ftC, fcm, row, ubu, translator, renderResult);
numOfColumns++;
}
}
target.append("</tr>");
if (ftE.isDetailsExpended(row)) {
target.append("<tr id='").append(rowIdPrefix).append(row).append("_details' class='o_table_row_details'>");
VelocityContainer container = ftE.getDetailsRenderer();
Object rowObject = ftE.getTableDataModel().getObject(row);
container.contextPut("row", rowObject);
FlexiTableComponentDelegate cmpDelegate = ftE.getComponentDelegate();
if (cmpDelegate != null) {
Iterable<Component> cmps = cmpDelegate.getComponents(row, rowObject);
if (cmps != null) {
for (Component cmp : cmps) {
container.put(cmp.getComponentName(), cmp);
}
}
}
if (ftE.isMultiSelect()) {
target.append("<td></td>");
}
target.append("<td colspan='").append(numOfColumns).append("'>");
container.getHTMLRendererSingleton().render(renderer, target, container, ubu, translator, renderResult, null);
container.contextRemove("row");
target.append("</td></tr>");
}
}
Aggregations