Search in sources :

Example 46 with Event

use of org.olat.core.gui.control.Event in project OpenOLAT by OpenOLAT.

the class ValidatingVisitor method appendDispatchDebugInfos.

private void appendDispatchDebugInfos(Component target, StringBuilder debugMsg) {
    Controller c = target.getLatestDispatchedController();
    if (c != null) {
        WindowControl wCo = null;
        try {
            wCo = c.getWindowControlForDebug();
        } catch (Exception e) {
        // getWindowControl throw an Assertion if wControl = null
        }
        if (wCo != null) {
            String coInfo = "";
            WindowControlInfo wci = wCo.getWindowControlInfo();
            while (wci != null) {
                String cName = wci.getControllerClassName();
                coInfo = cName + ":" + coInfo;
                wci = wci.getParentWindowControlInfo();
            }
            BusinessControl bc = wCo.getBusinessControl();
            String businessPath = bc == null ? "n/a" : bc.getAsString();
            String compName = target.getComponentName();
            String msg = "wci:" + coInfo + "%%" + compName + "%%" + businessPath + "%%";
            // allowed for debugging, dispatching is already over
            Event ev = target.getAndClearLatestFiredEvent();
            if (ev != null) {
                msg += ev.getClass().getName() + ":" + ev.getCommand() + "%%";
            }
            String targetInfo = target.getExtendedDebugInfo();
            msg += targetInfo + "%%";
            debugMsg.append(msg).append(LOG_SEPARATOR);
        } else {
        // no windowcontrol -> ignore
        }
    }
// else: a component with -no- controller as listener, makes no sense in 99.99% of the cases; ignore in those rare cases
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) Event(org.olat.core.gui.control.Event) ChiefController(org.olat.core.gui.control.ChiefController) Controller(org.olat.core.gui.control.Controller) WindowControl(org.olat.core.gui.control.WindowControl) AssertException(org.olat.core.logging.AssertException) JSONException(org.json.JSONException) InvalidRequestParameterException(org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) IOException(java.io.IOException) WindowControlInfo(org.olat.core.gui.control.info.WindowControlInfo)

Example 47 with Event

use of org.olat.core.gui.control.Event in project OpenOLAT by OpenOLAT.

the class GlossaryTermAndSynonymController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String glossTerm = glossaryTermField.getValue().trim();
    if (StringHelper.containsNonWhitespace(glossTerm)) {
        if (!glossTerm.equals(glossaryItem.getGlossTerm()) && glossaryItem.getGlossFlexions().size() > 0) {
            showWarning("flexions.warn.after.changed.term");
        }
        glossaryItem.setGlossTerm(glossTerm);
    }
    // save all changes made in existing synonyms
    int oldSynonymCount = glossItemSynonyms.size();
    glossItemSynonyms = new ArrayList<String>();
    for (int i = 0; i < oldSynonymCount; i++) {
        String textElementValue = synonymTextElementList.get(i).getValue().trim();
        if (StringHelper.containsNonWhitespace(textElementValue)) {
            glossItemSynonyms.add(textElementValue);
        }
    }
    String newSynonym = newSynonymField.getValue().trim();
    if (StringHelper.containsNonWhitespace(newSynonym)) {
        glossItemSynonyms.add(newSynonym);
    }
    // remove duplicates and sort
    removeDuplicate(glossItemSynonyms);
    Collections.sort(glossItemSynonyms);
    // update synonym-list and re-initialize
    glossaryItem.setGlossSynonyms(glossItemSynonyms);
    createOrUpdateSynonymLayout(this.flc, glossItemSynonyms);
    Revision revision = new Revision();
    revision.setAuthor(new Author(getIdentity()));
    revision.setJavaDate(new Date());
    if (add) {
        revision.setRevisionflag("added");
    } else {
        revision.setRevisionflag("changed");
    }
    glossaryItem.getRevHistory().add(revision);
    if (!checkForDuplicatesInGlossary()) {
        showError("term.error.alreadyused", duplicateGlossItem.getGlossTerm());
        glossaryTermField.setErrorKey("term.error.alreadyused", new String[] { duplicateGlossItem.getGlossTerm() });
    } else
        fireEvent(ureq, new Event("termOK"));
}
Also used : FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) Event(org.olat.core.gui.control.Event) Date(java.util.Date)

Example 48 with Event

use of org.olat.core.gui.control.Event in project OpenOLAT by OpenOLAT.

the class PortletToolSortingControllerImpl method event.

public void event(UserRequest ureq, Controller source, Event event) {
    if (source == portletAutoSortingConfigurator) {
        if (event == Event.DONE_EVENT) {
            SortingCriteria newSortingCriteria = portletAutoSortingConfigurator.getSortingCriteria();
            this.sortingCriteria = newSortingCriteria;
            closeableModalController.deactivate();
            closeableModalController.dispose();
            fireEvent(ureq, new Event(COMMAND_AUTO_SORTING));
        }
    } else if (source == portletManualSortingConfigurator) {
        if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            this.sortedItems = portletManualSortingConfigurator.getSortedItems();
            closeableModalController.deactivate();
            closeableModalController.dispose();
            fireEvent(ureq, new Event(COMMAND_MANUAL_SORTING));
        }
    }
    if (event == Event.CANCELLED_EVENT) {
        closeableModalController.deactivate();
        closeableModalController.dispose();
    } else if (event == CloseableModalController.CLOSE_MODAL_EVENT) {
        closeableModalController.dispose();
    }
}
Also used : Event(org.olat.core.gui.control.Event)

Example 49 with Event

use of org.olat.core.gui.control.Event in project OpenOLAT by OpenOLAT.

the class ChooseNodeController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (multiSpsLink == source) {
        fireEvent(ureq, event);
    } else if (multiCheckListLink == source) {
        fireEvent(ureq, event);
    } else if (source instanceof Link) {
        doCreateNode(event.getCommand());
        String cmd = EditorMainController.TB_ACTION + event.getCommand();
        fireEvent(ureq, new Event(cmd));
    }
}
Also used : Event(org.olat.core.gui.control.Event) Link(org.olat.core.gui.components.link.Link)

Example 50 with Event

use of org.olat.core.gui.control.Event in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method doCopy.

private void doCopy(UserRequest ureq, TreePosition tp) {
    // user chose a position to insert the node to be copied
    int targetPos = tp.getChildpos();
    ItemNode selectedNode = (ItemNode) menuTree.getSelectedNode();
    // only items are moveable
    // use XStream instead of ObjectCloner
    // Item qtiItem =
    // (Item)xstream.fromXML(xstream.toXML(selectedNode.getUnderlyingQTIObject()));
    Item toClone = (Item) selectedNode.getUnderlyingQTIObject();
    Item qtiItem = (Item) XStreamHelper.xstreamClone(toClone);
    // copy flow label class too, olat-2791
    Question orgQuestion = toClone.getQuestion();
    if (orgQuestion instanceof ChoiceQuestion) {
        String flowLabelClass = ((ChoiceQuestion) orgQuestion).getFlowLabelClass();
        Question copyQuestion = qtiItem.getQuestion();
        if (copyQuestion instanceof ChoiceQuestion) {
            ((ChoiceQuestion) copyQuestion).setFlowLabelClass(flowLabelClass);
        } else {
            throw new AssertException("Could not copy flow-label-class, wrong type of copy question , must be 'ChoiceQuestion' but is " + copyQuestion);
        }
    }
    String editorIdentPrefix = "";
    if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_SCQ))
        editorIdentPrefix = ItemParser.ITEM_PREFIX_SCQ;
    else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_MCQ))
        editorIdentPrefix = ItemParser.ITEM_PREFIX_MCQ;
    else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_KPRIM))
        editorIdentPrefix = ItemParser.ITEM_PREFIX_KPRIM;
    else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_FIB))
        editorIdentPrefix = ItemParser.ITEM_PREFIX_FIB;
    else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_ESSAY))
        editorIdentPrefix = ItemParser.ITEM_PREFIX_ESSAY;
    // set new ident... this is all it needs for our engine to recognise it
    // as a new item.
    qtiItem.setIdent(editorIdentPrefix + CodeHelper.getForeverUniqueID());
    // insert into menutree (insert on GenericNode do a remove from parent)
    GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
    GenericQtiNode newNode = new ItemNode(qtiItem, qtiPackage);
    parentTargetNode.insert(newNode, targetPos);
    // insert into model
    parentTargetNode.insertQTIObjectAt(qtiItem, targetPos);
    // activate copied node
    menuTree.setSelectedNodeId(newNode.getIdent());
    event(ureq, menuTree, new Event(MenuTree.COMMAND_TREENODE_CLICKED));
    qtiPackage.serializeQTIDocument();
    parentTargetNode.childNodeChanges();
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) AssertException(org.olat.core.logging.AssertException) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) Event(org.olat.core.gui.control.Event) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)

Aggregations

Event (org.olat.core.gui.control.Event)68 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)14 WindowControl (org.olat.core.gui.control.WindowControl)12 ArrayList (java.util.ArrayList)10 UserRequest (org.olat.core.gui.UserRequest)10 Controller (org.olat.core.gui.control.Controller)10 Identity (org.olat.core.id.Identity)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 List (java.util.List)8 Link (org.olat.core.gui.components.link.Link)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)6 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)6 QItemViewEvent (org.olat.modules.qpool.ui.events.QItemViewEvent)6 Component (org.olat.core.gui.components.Component)5 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)5 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 PopEvent (org.olat.core.gui.components.stack.PopEvent)4 TableEvent (org.olat.core.gui.components.table.TableEvent)4 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)4