Search in sources :

Example 1 with PoolItemsSource

use of org.olat.modules.qpool.ui.datasource.PoolItemsSource in project OpenOLAT by OpenOLAT.

the class ItemListMySharesController method initButtons.

@Override
protected void initButtons(UserRequest ureq, FormItemContainer formLayout) {
    getItemsTable().setMultiSelect(true);
    selectLink = uifactory.addFormLink("select-to-import", "select", null, formLayout, Link.BUTTON);
    Roles roles = ureq.getUserSession().getRoles();
    if (qpoolModule.isPoolsEnabled()) {
        myPools = qpoolService.getPools(getIdentity(), roles);
    } else {
        myPools = Collections.emptyList();
    }
    if (qpoolModule.isSharesEnabled()) {
        myGroups = qpoolService.getResourcesWithSharedItems(getIdentity());
    } else {
        myGroups = Collections.emptyList();
    }
    String[] myShareKeys;
    String[] myShareValues;
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareKeys = new String[1];
        myShareValues = new String[1];
        myShareKeys[0] = "";
        myShareValues[0] = "";
    } else {
        int numOfShares = myPools.size() + myGroups.size();
        myShareKeys = new String[numOfShares];
        myShareValues = new String[numOfShares];
        int pos = 0;
        for (Pool myPool : myPools) {
            myShareKeys[pos] = "pool" + myPool.getKey().toString();
            myShareValues[pos++] = myPool.getName();
        }
        for (BusinessGroup group : myGroups) {
            myShareKeys[pos] = "grou" + group.getKey().toString();
            myShareValues[pos++] = group.getName();
        }
    }
    myShareEl = uifactory.addDropdownSingleselect("source.selector", "my.list", formLayout, myShareKeys, myShareValues, null);
    myShareEl.setDomReplacementWrapperRequired(false);
    myShareEl.getLabelC().setDomReplaceable(false);
    myShareEl.addActionListener(FormEvent.ONCHANGE);
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareEl.setEnabled(false);
    } else {
        myShareEl.select(myShareKeys[0], true);
        if (myPools.size() > 0) {
            Pool firstPool = myPools.get(0);
            PoolItemsSource source = new PoolItemsSource(getIdentity(), roles, firstPool);
            source.getDefaultParams().setFormat(restrictToFormat);
            updateSource(source);
        } else if (myGroups.size() > 0) {
            BusinessGroup firstGroup = myGroups.get(0);
            SharedItemsSource source = new SharedItemsSource(firstGroup, getIdentity(), roles, false);
            source.setRestrictToFormat(restrictToFormat);
            updateSource(source);
        }
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) SharedItemsSource(org.olat.modules.qpool.ui.datasource.SharedItemsSource) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) Pool(org.olat.modules.qpool.Pool)

Example 2 with PoolItemsSource

use of org.olat.modules.qpool.ui.datasource.PoolItemsSource in project OpenOLAT by OpenOLAT.

the class PoolTreeNode method getController.

@Override
public Controller getController(UserRequest ureq, WindowControl wControl) {
    if (questionsCtrl == null) {
        PoolItemsSource source = new PoolItemsSource(ureq.getIdentity(), ureq.getUserSession().getRoles(), pool);
        source.setRemoveEnabled(isRemoveEnabled(ureq, pool));
        WindowControl swControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, pool, null, wControl, true);
        questionsCtrl = new QuestionsController(ureq, swControl, stackPanel, source, securityCallback, TABLE_PREFERENCE_PREFIX + pool.getKey(), false);
    } else {
        questionsCtrl.updateSource();
    }
    return questionsCtrl;
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) WindowControl(org.olat.core.gui.control.WindowControl) QuestionsController(org.olat.modules.qpool.ui.QuestionsController)

Example 3 with PoolItemsSource

use of org.olat.modules.qpool.ui.datasource.PoolItemsSource in project openolat by klemens.

the class PoolTreeNode method getController.

@Override
public Controller getController(UserRequest ureq, WindowControl wControl) {
    if (questionsCtrl == null) {
        PoolItemsSource source = new PoolItemsSource(ureq.getIdentity(), ureq.getUserSession().getRoles(), pool);
        source.setRemoveEnabled(isRemoveEnabled(ureq, pool));
        WindowControl swControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, pool, null, wControl, true);
        questionsCtrl = new QuestionsController(ureq, swControl, stackPanel, source, securityCallback, TABLE_PREFERENCE_PREFIX + pool.getKey(), false);
    } else {
        questionsCtrl.updateSource();
    }
    return questionsCtrl;
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) WindowControl(org.olat.core.gui.control.WindowControl) QuestionsController(org.olat.modules.qpool.ui.QuestionsController)

Example 4 with PoolItemsSource

use of org.olat.modules.qpool.ui.datasource.PoolItemsSource in project OpenOLAT by OpenOLAT.

the class ItemListMySharesController method doSelectPool.

private void doSelectPool(UserRequest ureq, Long poolKey) {
    Pool myPool = null;
    for (Pool pool : myPools) {
        if (poolKey.equals(pool.getKey())) {
            myPool = pool;
        }
    }
    if (myPool == null) {
        updateSource(new EmptyItemsSource());
    } else {
        PoolItemsSource source = new PoolItemsSource(getIdentity(), ureq.getUserSession().getRoles(), myPool);
        source.getDefaultParams().setFormat(restrictToFormat);
        updateSource(source);
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) EmptyItemsSource(org.olat.modules.qpool.ui.datasource.EmptyItemsSource) Pool(org.olat.modules.qpool.Pool)

Example 5 with PoolItemsSource

use of org.olat.modules.qpool.ui.datasource.PoolItemsSource in project openolat by klemens.

the class ItemListMySharesController method initButtons.

@Override
protected void initButtons(UserRequest ureq, FormItemContainer formLayout) {
    getItemsTable().setMultiSelect(true);
    selectLink = uifactory.addFormLink("select-to-import", "select", null, formLayout, Link.BUTTON);
    Roles roles = ureq.getUserSession().getRoles();
    if (qpoolModule.isPoolsEnabled()) {
        myPools = qpoolService.getPools(getIdentity(), roles);
    } else {
        myPools = Collections.emptyList();
    }
    if (qpoolModule.isSharesEnabled()) {
        myGroups = qpoolService.getResourcesWithSharedItems(getIdentity());
    } else {
        myGroups = Collections.emptyList();
    }
    String[] myShareKeys;
    String[] myShareValues;
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareKeys = new String[1];
        myShareValues = new String[1];
        myShareKeys[0] = "";
        myShareValues[0] = "";
    } else {
        int numOfShares = myPools.size() + myGroups.size();
        myShareKeys = new String[numOfShares];
        myShareValues = new String[numOfShares];
        int pos = 0;
        for (Pool myPool : myPools) {
            myShareKeys[pos] = "pool" + myPool.getKey().toString();
            myShareValues[pos++] = myPool.getName();
        }
        for (BusinessGroup group : myGroups) {
            myShareKeys[pos] = "grou" + group.getKey().toString();
            myShareValues[pos++] = group.getName();
        }
    }
    myShareEl = uifactory.addDropdownSingleselect("source.selector", "my.list", formLayout, myShareKeys, myShareValues, null);
    myShareEl.setDomReplacementWrapperRequired(false);
    myShareEl.getLabelC().setDomReplaceable(false);
    myShareEl.addActionListener(FormEvent.ONCHANGE);
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareEl.setEnabled(false);
    } else {
        myShareEl.select(myShareKeys[0], true);
        if (myPools.size() > 0) {
            Pool firstPool = myPools.get(0);
            PoolItemsSource source = new PoolItemsSource(getIdentity(), roles, firstPool);
            source.getDefaultParams().setFormat(restrictToFormat);
            updateSource(source);
        } else if (myGroups.size() > 0) {
            BusinessGroup firstGroup = myGroups.get(0);
            SharedItemsSource source = new SharedItemsSource(firstGroup, getIdentity(), roles, false);
            source.setRestrictToFormat(restrictToFormat);
            updateSource(source);
        }
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) SharedItemsSource(org.olat.modules.qpool.ui.datasource.SharedItemsSource) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) Pool(org.olat.modules.qpool.Pool)

Aggregations

PoolItemsSource (org.olat.modules.qpool.ui.datasource.PoolItemsSource)6 Pool (org.olat.modules.qpool.Pool)4 WindowControl (org.olat.core.gui.control.WindowControl)2 Roles (org.olat.core.id.Roles)2 BusinessGroup (org.olat.group.BusinessGroup)2 QuestionsController (org.olat.modules.qpool.ui.QuestionsController)2 EmptyItemsSource (org.olat.modules.qpool.ui.datasource.EmptyItemsSource)2 SharedItemsSource (org.olat.modules.qpool.ui.datasource.SharedItemsSource)2