Search in sources :

Example 1 with VelocityContainer

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;
}
Also used : FileSelection(org.olat.core.commons.modules.bc.FileSelection) MenuTree(org.olat.core.gui.components.tree.MenuTree) FolderTreeModel(org.olat.core.gui.control.generic.folder.FolderTreeModel) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 2 with VelocityContainer

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());
        }
    }
}
Also used : User(org.olat.core.id.User) TabbedPaneChangedEvent(org.olat.core.gui.components.tabbedpane.TabbedPaneChangedEvent) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 3 with VelocityContainer

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>");
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) FormDecorator(org.olat.core.gui.components.form.flexible.impl.FormDecorator) Component(org.olat.core.gui.components.Component)

Example 4 with VelocityContainer

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>");
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) Component(org.olat.core.gui.components.Component)

Example 5 with VelocityContainer

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;
}
Also used : VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)162 Component (org.olat.core.gui.components.Component)22 ArrayList (java.util.ArrayList)16 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)14 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)14 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)14 Link (org.olat.core.gui.components.link.Link)12 Panel (org.olat.core.gui.components.panel.Panel)12 UserRequest (org.olat.core.gui.UserRequest)10 JSAndCSSComponent (org.olat.core.gui.components.htmlheader.jscss.JSAndCSSComponent)10 List (java.util.List)8 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)8 WindowControl (org.olat.core.gui.control.WindowControl)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 Translator (org.olat.core.gui.translator.Translator)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 HashMap (java.util.HashMap)6 Collectors (java.util.stream.Collectors)6 Mapper (org.olat.core.dispatcher.mapper.Mapper)6 BarSeries (org.olat.core.gui.components.chart.BarSeries)6