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
}
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"));
}
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();
}
}
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));
}
}
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();
}
Aggregations