Search in sources :

Example 26 with TreeModel

use of org.olat.core.gui.components.tree.TreeModel in project openolat by klemens.

the class BusinessGroupMainRunController method event.

/**
 * @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
 */
@Override
public void event(Event event) {
    if (event instanceof OLATResourceableJustBeforeDeletedEvent) {
        OLATResourceableJustBeforeDeletedEvent delEvent = (OLATResourceableJustBeforeDeletedEvent) event;
        if (!delEvent.targetEquals(businessGroup)) {
            throw new AssertException("receiving a delete event for a olatres we never registered for!!!:" + delEvent.getDerivedOres());
        }
        dispose();
    } else if (event instanceof BusinessGroupModifiedEvent) {
        BusinessGroupModifiedEvent bgmfe = (BusinessGroupModifiedEvent) event;
        if (event.getCommand().equals(BusinessGroupModifiedEvent.CONFIGURATION_MODIFIED_EVENT)) {
            // reset business group property manager
            // update reference to update business group object
            businessGroup = businessGroupService.loadBusinessGroup(businessGroup);
            chatAvailable = isChatAvailable();
            main.contextPut("BuddyGroup", businessGroup);
            TreeModel trMdl = buildTreeModel();
            bgTree.setTreeModel(trMdl);
            if (bgEditCntrllr == null) {
                // change didn't origin by our own edit controller
                showInfo("grouprun.configurationchanged");
                bgTree.setSelectedNodeId(trMdl.getRootNode().getIdent());
                mainPanel.setContent(main);
            } else {
                // Activate edit menu item
                bgTree.setSelectedNodeId(ACTIVITY_MENUSELECT_ADMINISTRATION);
            }
        } else if (bgmfe.wasMyselfRemoved(getIdentity()) && !wildcard && !isGroupsAdmin) {
            // nothing more here!! The message will be created and displayed upon disposing
            // disposed message controller will be set
            dispose();
        }
    } else if (event instanceof AssessmentEvent) {
        if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STARTED)) {
            groupRunDisabled = true;
        } else if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STOPPED)) {
            groupRunDisabled = false;
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) AssertException(org.olat.core.logging.AssertException) AssessmentEvent(org.olat.course.nodes.iq.AssessmentEvent) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 27 with TreeModel

use of org.olat.core.gui.components.tree.TreeModel 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)

Example 28 with TreeModel

use of org.olat.core.gui.components.tree.TreeModel in project openolat by klemens.

the class DocumentPoolWebDAVMergeSource method loadMergedContainers.

@Override
protected List<VFSContainer> loadMergedContainers() {
    List<VFSContainer> containers = new ArrayList<>();
    String taxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
    if (StringHelper.isLong(taxonomyTreeKey)) {
        Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyTreeKey)));
        if (taxonomy != null) {
            String templatesDir = Util.createPackageTranslator(DocumentPoolMainController.class, identityEnv.getLocale()).translate("document.pool.templates");
            TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identityEnv.getIdentity(), null, identityEnv.getRoles().isOLATAdmin(), docPoolModule.isTemplatesDirectoryEnabled(), templatesDir, null);
            TreeModel model = builder.buildTreeModel();
            TreeNode rootNode = model.getRootNode();
            for (int i = 0; i < rootNode.getChildCount(); i++) {
                VFSContainer container = loadRecursiveMergedContainers(taxonomy, rootNode.getChildAt(i));
                if (container != null) {
                    containers.add(container);
                }
            }
        }
    }
    return containers;
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) DocumentPoolMainController(org.olat.modules.docpool.ui.DocumentPoolMainController) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)

Aggregations

TreeModel (org.olat.core.gui.components.tree.TreeModel)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)16 TreeNode (org.olat.core.gui.components.tree.TreeNode)14 ArrayList (java.util.ArrayList)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)8 HashMap (java.util.HashMap)6 List (java.util.List)6 Map (java.util.Map)6 Identity (org.olat.core.id.Identity)6 StringHelper (org.olat.core.util.StringHelper)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 Taxonomy (org.olat.modules.taxonomy.Taxonomy)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 TaxonomyTreeBuilder (org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)6 Date (java.util.Date)4 Locale (java.util.Locale)4 Collectors (java.util.stream.Collectors)4 Component (org.olat.core.gui.components.Component)4 AssertException (org.olat.core.logging.AssertException)4