Search in sources :

Example 61 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class RepositorySearchController 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 urequest, Controller source, Event event) {
    if (source == tableCtr) {
        // process table actions
        if (event instanceof TableEvent) {
            TableEvent te = (TableEvent) event;
            int rowId = te.getRowId();
            if (te.getActionId().equals(RepositoryTableModel.TABLE_ACTION_INFOS)) {
                RepositoryEntry entry = (RepositoryEntry) tableCtr.getTableDataModel().getObject(rowId);
                int row = tableCtr.getIndexOfSortedObject(entry);
                doOpenInfos(urequest, entry, row);
            } else if (te.getActionId().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
                selectedEntry = (RepositoryEntry) tableCtr.getTableDataModel().getObject(rowId);
                fireEvent(urequest, new Event(RepositoryTableModel.TABLE_ACTION_SELECT_LINK));
                selectedEntries = null;
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            if (!mse.getSelection().isEmpty()) {
                selectedEntry = null;
                BitSet objectMarkers = mse.getSelection();
                selectedEntries = new ArrayList<>(objectMarkers.size());
                for (int i = objectMarkers.nextSetBit(0); i >= 0; i = objectMarkers.nextSetBit(i + 1)) {
                    RepositoryEntry entry = (RepositoryEntry) tableCtr.getTableDataModel().getObject(i);
                    selectedEntries.add(entry);
                }
                fireEvent(urequest, new Event(RepositoryTableModel.TABLE_ACTION_SELECT_ENTRIES));
            }
        } else if (TableController.EVENT_FILTER_SELECTED.equals(event)) {
            TypeFilter typeFilter = (TypeFilter) tableCtr.getActiveFilter();
            if (searchType == SearchType.byOwner) {
                doSearchByOwnerLimitTypeInternal(typeFilter.getOwner(), new String[] { typeFilter.getType() }, false);
            } else if (searchType == SearchType.myAsStudent) {
                doSearchMyCoursesStudent(urequest, typeFilter.getType(), false);
            } else if (searchType == SearchType.myAsTeacher) {
                doSearchMyCoursesTeacher(urequest, typeFilter.getType(), false);
            } else if (searchType == SearchType.searchForm) {
                if (enableSearchforAllInSearchForm != null) {
                    doSearchAllReferencables(urequest, typeFilter.getType(), false);
                } else {
                    doSearch(urequest, typeFilter.getType(), false);
                }
            }
        } else if (TableController.EVENT_NOFILTER_SELECTED.equals(event)) {
            if (searchType == SearchType.byOwner) {
                doSearchByOwnerLimitTypeInternal(getIdentity(), new String[] {}, false);
            } else if (searchType == SearchType.myAsStudent) {
                doSearchMyCoursesStudent(urequest);
            } else if (searchType == SearchType.myAsTeacher) {
                doSearchMyCoursesTeacher(urequest);
            } else if (searchType == SearchType.searchForm) {
                if (enableSearchforAllInSearchForm != null) {
                    doSearchAllReferencables(urequest, null, false);
                } else {
                    doSearch(urequest, null, false);
                }
            }
        }
    } else if (event instanceof EntryChangedEvent) {
        // remove deleted entry
        EntryChangedEvent ecv = (EntryChangedEvent) event;
        if (ecv.getChange() == Change.deleted) {
            List<RepositoryEntry> newEntries = new ArrayList<RepositoryEntry>();
            for (int i = 0; i < repoTableModel.getRowCount(); i++) {
                RepositoryEntry foo = repoTableModel.getObject(i);
                if (!foo.getKey().equals(ecv.getRepositoryEntryKey())) {
                    newEntries.add(foo);
                }
            }
            repoTableModel.setObjects(newEntries);
            tableCtr.modelChanged();
        } else if (ecv.getChange() == Change.added) {
            doSearchByOwner(urequest.getIdentity());
        }
    } else if (source == searchForm) {
        // process search form events
        if (event == Event.DONE_EVENT) {
            if (searchForm.hasId()) {
                doSearchById(searchForm.getId(), searchForm.getRestrictedTypes());
            } else if (enableSearchforAllInSearchForm != null) {
                doSearchAllReferencables(urequest, null, true);
            } else {
                doSearch(urequest, null, true);
            }
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(urequest, Event.CANCELLED_EVENT);
        }
    } else if (calloutCtrl == source) {
        removeAsListenerAndDispose(calloutCtrl);
        removeAsListenerAndDispose(infosCtrl);
        calloutCtrl = null;
        infosCtrl = null;
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) Event(org.olat.core.gui.control.Event) TableEvent(org.olat.core.gui.components.table.TableEvent) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 62 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class OrderDetailController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            OrderItemWrapper wrapper = (OrderItemWrapper) tableCtr.getTableDataModel().getObject(rowid);
            if (CMD_SELECT.equals(actionid)) {
                popupTransactionDetails(ureq, wrapper);
            }
        }
    } else if (source == detailsCtlr) {
        cmc.deactivate();
        removeAsListenerAndDispose(detailsCtlr);
        removeAsListenerAndDispose(cmc);
        detailsCtlr = null;
        cmc = null;
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 63 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class PropTableDataModel 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)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals("choose")) {
                int rowid = te.getRowId();
                foundProp = tdm.getObject(rowid);
                // Tell parentController that a subject has been found
                fireEvent(ureq, new PropFoundEvent(foundProp));
            } else // fxdiff FXOLAT-149
            if (actionid.equals("delete")) {
                int rowid = te.getRowId();
                foundProp = tdm.getObject(rowid);
                String fullName = CoreSpringFactory.getImpl(UserManager.class).getUserDisplayName(displayedIdentity);
                activateYesNoDialog(ureq, translate("propdelete.yesno.title"), translate("propdelete.yesno.text", new String[] { foundProp.getName(), fullName }), null);
            }
        }
    } else // fxdiff FXOLAT-149
    if (DialogBoxUIFactory.isYesEvent(event) && foundProp != null) {
        PropertyManager.getInstance().deleteProperty(foundProp);
        tdm.getObjects().remove(foundProp);
        tableCtr.modelChanged();
        foundProp = null;
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 64 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class UsrPropContextCfgTableController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source.equals(contextTableCtr)) {
        TableEvent tblEvent = (TableEvent) event;
        Entry<String, UserPropertyUsageContext> contextRow = contTblModel.getObject(tblEvent.getRowId());
        removeAsListenerAndDispose(editBox);
        removeAsListenerAndDispose(contextEditCtr);
        contextEditCtr = new UsrPropContextEditController(ureq, getWindowControl(), contextRow.getValue(), contextRow.getKey());
        editBox = new CloseableModalController(getWindowControl(), translate("close"), contextEditCtr.getInitialComponent(), true, translate("upc.context.edit") + " :: " + contextRow.getKey(), true);
        listenTo(editBox);
        editBox.activate();
    } else if (source.equals(contextEditCtr)) {
    // nothing to do
    } else if (source.equals(editBox)) {
        if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
            // edit-popup was closed, refresh our table
            refreshView();
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) UserPropertyUsageContext(org.olat.user.propertyhandlers.UserPropertyUsageContext) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 65 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class ViteroBookingsAdminController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event instanceof TableEvent) {
            TableEvent e = (TableEvent) event;
            int row = e.getRowId();
            ViteroBooking booking = (ViteroBooking) tableCtr.getTableDataModel().getObject(row);
            if ("delete".equals(e.getActionId())) {
                confirmDeleteVitero(ureq, booking);
            } else if ("infos".equals(e.getActionId())) {
                openInfoBox(ureq, booking);
            } else if ("resource".equals(e.getActionId())) {
                openResource(ureq, booking);
            }
        }
    } else if (source == dialogCtr) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            ViteroBooking booking = (ViteroBooking) dialogCtr.getUserObject();
            deleteBooking(booking);
        }
    } else if (source == cmc) {
        removeAsListenerAndDispose(infoController);
        removeAsListenerAndDispose(cmc);
    } else if (source == infoController) {
        cmc.deactivate();
        removeAsListenerAndDispose(infoController);
        removeAsListenerAndDispose(cmc);
        reloadModel();
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) TableEvent(org.olat.core.gui.components.table.TableEvent)

Aggregations

TableEvent (org.olat.core.gui.components.table.TableEvent)114 ArrayList (java.util.ArrayList)42 List (java.util.List)40 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)40 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 Identity (org.olat.core.id.Identity)16 BitSet (java.util.BitSet)12 WindowControl (org.olat.core.gui.control.WindowControl)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 UserRequest (org.olat.core.gui.UserRequest)10 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)10 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 BusinessGroup (org.olat.group.BusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 Subscriber (org.olat.core.commons.services.notifications.Subscriber)4