use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class CmdMoveCopy method execute.
@Override
public Controller execute(FolderComponent fc, UserRequest ureq, WindowControl windowControl, Translator trans) {
this.folderComponent = fc;
this.translator = trans;
this.fileSelection = new FileSelection(ureq, fc.getCurrentContainerPath());
VelocityContainer main = new VelocityContainer("mc", VELOCITY_ROOT + "/movecopy.html", translator, this);
main.contextPut("fileselection", fileSelection);
// check if command is executed on a file list containing invalid filenames or paths
if (fileSelection.getInvalidFileNames().size() > 0) {
main.contextPut("invalidFileNames", fileSelection.getInvalidFileNames());
}
selTree = new MenuTree(null, "seltree", this);
FolderTreeModel ftm = new FolderTreeModel(ureq.getLocale(), fc.getRootContainer(), true, false, true, fc.getRootContainer().canWrite() == VFSConstants.YES, new EditableFilter());
selTree.setTreeModel(ftm);
selectButton = LinkFactory.createButton(move ? "move" : "copy", main, this);
cancelButton = LinkFactory.createButton("cancel", main, this);
main.put("seltree", selTree);
if (move) {
main.contextPut("move", Boolean.TRUE);
}
setInitialComponent(main);
return this;
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class NotificationSubscriptionAndNewsController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == tabbedPane) {
if (event instanceof TabbedPaneChangedEvent) {
TabbedPaneChangedEvent tabbedEvent = (TabbedPaneChangedEvent) event;
// user clicks the tab the first time
if (tabbedEvent.getNewComponent() == subscriptionPanel && subscriptionCtr == null) {
subscriptionCtr = new NotificationSubscriptionController(ureq, getWindowControl(), subscriberIdentity, false);
listenTo(subscriptionCtr);
subscriptionPanel.setContent(subscriptionCtr.getInitialComponent());
} else // user clicks the tab the first time
if (tabbedEvent.getNewComponent() == rssPanel && rssPanel.getContent() == null) {
VelocityContainer notificationsRssVC = createVelocityContainer("notificationsRSS");
String rssLink = PersonalRSSUtil.getPersonalRssLink(ureq);
notificationsRssVC.contextPut("rssLink", rssLink);
User user = subscriberIdentity.getUser();
String fullName = user.getProperty(UserConstants.FIRSTNAME, getLocale()) + " " + user.getProperty(UserConstants.LASTNAME, getLocale());
notificationsRssVC.contextPut("fullName", fullName);
rssPanel.setContent(notificationsRssVC);
}
// fxdiff BAKS-7 Resume function
tabbedPane.addToHistory(ureq, getWindowControl());
}
}
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class FlexiTableCustomRenderer method renderRow.
@Override
protected void renderRow(Renderer renderer, StringOutput sb, FlexiTableComponent ftC, String rowIdPrefix, int row, URLBuilder ubu, Translator translator, RenderResult renderResult) {
sb.append("<div class='");
if (ftC.getFlexiTableElement().getCssDelegate() != null) {
String cssClass = ftC.getFlexiTableElement().getCssDelegate().getRowCssClass(FlexiTableRendererType.custom, row);
if (cssClass == null) {
sb.append("o_table_row row");
} else {
sb.append(cssClass);
}
} else {
sb.append("o_table_row row");
}
sb.append("'>");
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
VelocityContainer container = ftE.getRowRenderer();
container.contextPut("f", new FormDecorator(ftE.getRootForm()));
FlexiTableDataModel<?> dataModel = ftE.getTableDataModel();
Object rowObject = ftE.getTableDataModel().getObject(row);
container.contextPut("row", rowObject);
container.contextPut("rowIndex", row);
FlexiTableColumnModel columnsModel = ftE.getTableDataModel().getTableColumnModel();
int numOfCols = columnsModel.getColumnCount();
// link to the table element the form elements in the data model
for (int j = 0; j < numOfCols; j++) {
FlexiColumnModel fcm = columnsModel.getColumnModel(j);
int columnIndex = fcm.getColumnIndex();
Object cellValue = columnIndex >= 0 ? dataModel.getValueAt(row, columnIndex) : null;
if (cellValue instanceof FormItem) {
FormItem formItem = (FormItem) cellValue;
formItem.setTranslator(translator);
if (ftE.getRootForm() != formItem.getRootForm()) {
formItem.setRootForm(ftE.getRootForm());
}
ftE.addFormItem(formItem);
container.put(formItem.getComponent().getComponentName(), formItem.getComponent());
}
}
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);
}
}
}
container.getHTMLRendererSingleton().render(renderer, sb, container, ubu, translator, renderResult, null);
container.contextRemove("row");
container.contextRemove("f");
sb.append("</div>");
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
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>");
}
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class ComponentUtil method createTitledComponent.
/**
* convenience method to easily add a title to a component
* @param titleKey the key for the title
* @param args the arguments for the translator, when you need to pass arguments to the translation. may be null
* @param trans the translator to translate the given key
* @param content the component which is to appear after the title
* @return a component which first renders the title with h1 tags, and then the content
*/
public static Component createTitledComponent(String titleKey, String[] args, Translator trans, Component content) {
VelocityContainer vc = new VelocityContainer("titlewrapper", VELOCITY_ROOT + "/title.html", trans, null);
vc.contextPut("title", trans.translate(titleKey, args));
vc.put("content", content);
return vc;
}
Aggregations