Search in sources :

Example 1 with RepositoryTableModel

use of org.olat.repository.ui.RepositoryTableModel in project OpenOLAT by OpenOLAT.

the class BGConfigResourcesStepController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    addResource = uifactory.addFormLink("cmd.addresource", formLayout, Link.BUTTON);
    Translator resourceTrans = Util.createPackageTranslator(RepositoryTableModel.class, getLocale(), getTranslator());
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("config.resources.noresources"));
    resourcesCtr = new TableController(tableConfig, ureq, getWindowControl(), resourceTrans);
    listenTo(resourcesCtr);
    repoTableModel = new RepositoryTableModel(getLocale());
    repoTableModel.addColumnDescriptors(resourcesCtr, false, false, true, true);
    resourcesCtr.setTableDataModel(repoTableModel);
    ((FormLayoutContainer) formLayout).put("resources", resourcesCtr.getInitialComponent());
}
Also used : RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) Translator(org.olat.core.gui.translator.Translator) TableController(org.olat.core.gui.components.table.TableController) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 2 with RepositoryTableModel

use of org.olat.repository.ui.RepositoryTableModel in project OpenOLAT by OpenOLAT.

the class BusinessGroupMainRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == bgEditCntrllr) {
        // changes from the admin controller
        if (event == Event.CHANGED_EVENT) {
            businessGroup = bgEditCntrllr.getBusinessGroup();
            chatAvailable = isChatAvailable();
            TreeModel trMdl = buildTreeModel();
            bgTree.setTreeModel(trMdl);
            bgTree.setSelectedNode(nodeAdmin);
        } else if (event == Event.CANCELLED_EVENT) {
            // could not get lock on business group, back to inital screen
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == resourcesCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            RepositoryTableModel repoTableModel = (RepositoryTableModel) resourcesCtr.getTableDataModel();
            if (RepositoryTableModel.TABLE_ACTION_SELECT_LINK.equals(actionid)) {
                RepositoryEntry currentRepoEntry = repoTableModel.getObject(rowid);
                OLATResource ores = currentRepoEntry.getOlatResource();
                if (ores == null)
                    throw new AssertException("repoEntry had no olatresource, repoKey = " + currentRepoEntry.getKey());
                addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.genRepoEntry));
                String businessPath = "[RepositoryEntry:" + currentRepoEntry.getKey() + "]";
                NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            }
        }
    } else if (source == sendToChooserForm) {
        if (event == Event.DONE_EVENT) {
            removeAsListenerAndDispose(collabToolCtr);
            collabToolCtr = createContactFormController(ureq);
            listenTo(collabToolCtr);
            mainPanel.setContent(collabToolCtr.getInitialComponent());
        } else if (event == Event.CANCELLED_EVENT) {
            // back to group overview
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == collabToolCtr) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.BACK_EVENT || event == Event.FAILED_EVENT) {
            // In all cases (success or failure) we
            // go back to the group overview page.
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == accessController) {
        if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
            removeAsListenerAndDispose(accessController);
            accessController = null;
            // check if on waiting list
            List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupMembership(Collections.singletonList(businessGroup.getKey()), getIdentity());
            if (isOnWaitinglist(memberships)) {
                Component cmp = getOnWaitingListMessage(ureq, businessGroup);
                mainPanel.setContent(cmp);
            } else {
                mainPanel.setContent(main);
                bgTree.setTreeModel(buildTreeModel());
                needActivation = false;
            }
        } else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
            String msg = ((AccessEvent) event).getMessage();
            if (StringHelper.containsNonWhitespace(msg)) {
                getWindowControl().setError(msg);
            } else {
                showError("error.accesscontrol");
            }
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) AssertException(org.olat.core.logging.AssertException) TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component)

Example 3 with RepositoryTableModel

use of org.olat.repository.ui.RepositoryTableModel in project openolat by klemens.

the class BusinessGroupMainRunController method doShowResources.

private void doShowResources(UserRequest ureq) {
    // always refresh data model, maybe it has changed
    RepositoryTableModel repoTableModel = new RepositoryTableModel(getLocale());
    List<RepositoryEntry> repoTableModelEntries = businessGroupService.findRepositoryEntries(Collections.singletonList(businessGroup), 0, -1);
    repoTableModel.setObjects(repoTableModelEntries);
    // init table controller only once
    if (resourcesCtr == null) {
        TableGuiConfiguration tableConfig = new TableGuiConfiguration();
        tableConfig.setTableEmptyMessage(translate("resources.noresources"));
        // removeAsListenerAndDispose(resourcesCtr);
        resourcesCtr = new TableController(tableConfig, ureq, getWindowControl(), resourceTrans);
        listenTo(resourcesCtr);
        resourcesVC = createVelocityContainer("resources");
        repoTableModel.addColumnDescriptors(resourcesCtr, true, false, false, false);
        resourcesVC.put("resources", resourcesCtr.getInitialComponent());
    }
    // add table model to table
    resourcesCtr.setTableDataModel(repoTableModel);
    mainPanel.setContent(resourcesVC);
    addToHistory(ureq, ORES_TOOLRESOURCES, null);
}
Also used : RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) TableController(org.olat.core.gui.components.table.TableController) RepositoryEntry(org.olat.repository.RepositoryEntry) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 4 with RepositoryTableModel

use of org.olat.repository.ui.RepositoryTableModel in project OpenOLAT by OpenOLAT.

the class BusinessGroupMainRunController method doShowResources.

private void doShowResources(UserRequest ureq) {
    // always refresh data model, maybe it has changed
    RepositoryTableModel repoTableModel = new RepositoryTableModel(getLocale());
    List<RepositoryEntry> repoTableModelEntries = businessGroupService.findRepositoryEntries(Collections.singletonList(businessGroup), 0, -1);
    repoTableModel.setObjects(repoTableModelEntries);
    // init table controller only once
    if (resourcesCtr == null) {
        TableGuiConfiguration tableConfig = new TableGuiConfiguration();
        tableConfig.setTableEmptyMessage(translate("resources.noresources"));
        // removeAsListenerAndDispose(resourcesCtr);
        resourcesCtr = new TableController(tableConfig, ureq, getWindowControl(), resourceTrans);
        listenTo(resourcesCtr);
        resourcesVC = createVelocityContainer("resources");
        repoTableModel.addColumnDescriptors(resourcesCtr, true, false, false, false);
        resourcesVC.put("resources", resourcesCtr.getInitialComponent());
    }
    // add table model to table
    resourcesCtr.setTableDataModel(repoTableModel);
    mainPanel.setContent(resourcesVC);
    addToHistory(ureq, ORES_TOOLRESOURCES, null);
}
Also used : RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) TableController(org.olat.core.gui.components.table.TableController) RepositoryEntry(org.olat.repository.RepositoryEntry) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 5 with RepositoryTableModel

use of org.olat.repository.ui.RepositoryTableModel in project openolat by klemens.

the class BusinessGroupMainRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == bgEditCntrllr) {
        // changes from the admin controller
        if (event == Event.CHANGED_EVENT) {
            businessGroup = bgEditCntrllr.getBusinessGroup();
            chatAvailable = isChatAvailable();
            TreeModel trMdl = buildTreeModel();
            bgTree.setTreeModel(trMdl);
            bgTree.setSelectedNode(nodeAdmin);
        } else if (event == Event.CANCELLED_EVENT) {
            // could not get lock on business group, back to inital screen
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == resourcesCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            RepositoryTableModel repoTableModel = (RepositoryTableModel) resourcesCtr.getTableDataModel();
            if (RepositoryTableModel.TABLE_ACTION_SELECT_LINK.equals(actionid)) {
                RepositoryEntry currentRepoEntry = repoTableModel.getObject(rowid);
                OLATResource ores = currentRepoEntry.getOlatResource();
                if (ores == null)
                    throw new AssertException("repoEntry had no olatresource, repoKey = " + currentRepoEntry.getKey());
                addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.genRepoEntry));
                String businessPath = "[RepositoryEntry:" + currentRepoEntry.getKey() + "]";
                NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            }
        }
    } else if (source == sendToChooserForm) {
        if (event == Event.DONE_EVENT) {
            removeAsListenerAndDispose(collabToolCtr);
            collabToolCtr = createContactFormController(ureq);
            listenTo(collabToolCtr);
            mainPanel.setContent(collabToolCtr.getInitialComponent());
        } else if (event == Event.CANCELLED_EVENT) {
            // back to group overview
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == collabToolCtr) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.BACK_EVENT || event == Event.FAILED_EVENT) {
            // In all cases (success or failure) we
            // go back to the group overview page.
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == accessController) {
        if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
            removeAsListenerAndDispose(accessController);
            accessController = null;
            // check if on waiting list
            List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupMembership(Collections.singletonList(businessGroup.getKey()), getIdentity());
            if (isOnWaitinglist(memberships)) {
                Component cmp = getOnWaitingListMessage(ureq, businessGroup);
                mainPanel.setContent(cmp);
            } else {
                mainPanel.setContent(main);
                bgTree.setTreeModel(buildTreeModel());
                needActivation = false;
            }
        } else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
            String msg = ((AccessEvent) event).getMessage();
            if (StringHelper.containsNonWhitespace(msg)) {
                getWindowControl().setError(msg);
            } else {
                showError("error.accesscontrol");
            }
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) AssertException(org.olat.core.logging.AssertException) TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component)

Aggregations

RepositoryTableModel (org.olat.repository.ui.RepositoryTableModel)6 TableController (org.olat.core.gui.components.table.TableController)4 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 Component (org.olat.core.gui.components.Component)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2 TreeModel (org.olat.core.gui.components.tree.TreeModel)2 Translator (org.olat.core.gui.translator.Translator)2 AssertException (org.olat.core.logging.AssertException)2 BusinessGroupMembership (org.olat.group.BusinessGroupMembership)2 OLATResource (org.olat.resource.OLATResource)2