use of org.olat.core.util.memento.Memento in project openolat by klemens.
the class QTIEditorMainController method init.
private void init(UserRequest ureq) {
main = createVelocityContainer("index");
JSAndCSSComponent jsAndCss;
// Add html header js
jsAndCss = new JSAndCSSComponent("qitjsandcss", new String[] { "js/openolat/qti.js" }, null);
main.put("qitjsandcss", jsAndCss);
mainPanel = new Panel("p_qti_editor");
mainPanel.setContent(main);
if (notEditable) {
// test not editable
VelocityContainer notEditableVc = createVelocityContainer("notEditable");
notEditableButton = LinkFactory.createButton("ok", notEditableVc, this);
Panel panel = new Panel("notEditable");
panel.setContent(notEditableVc);
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), null, panel, null);
putInitialPanel(columnLayoutCtr.getInitialComponent());
return;
}
stackedPanel = new TooledStackedPanel("qtiEditorStackedPanel", getTranslator(), this);
stackedPanel.setCssClass("o_edit_mode");
// initialize the history
if (qtiPackage.isResumed() && qtiPackage.hasSerializedChangelog()) {
// there were already changes made -> reload!
history = qtiPackage.loadChangelog();
} else {
// start with a fresh history. Editor is resumed but no changes were made
// so far.
history = new HashMap<String, Memento>();
}
// The menu tree model represents the structure of the qti document.
// All insert/move operations on the model are propagated to the structure
// by the node
menuTreeModel = new QTIEditorTreeModel(qtiPackage);
menuTree = new MenuTree("QTIDocumentTree");
menuTree.setTreeModel(menuTreeModel);
menuTree.setSelectedNodeId(menuTree.getTreeModel().getRootNode().getIdent());
// listen to the tree
menuTree.addListener(this);
// remember the qtidoc title when we started this editor, to correctly name
// the history report
startedWithTitle = menuTree.getSelectedNode().getAltText();
//
main.put("tabbedPane", menuTreeModel.getQtiRootNode().createEditTabbedPane(ureq, getWindowControl(), getTranslator(), this));
main.contextPut("qtititle", menuTreeModel.getQtiRootNode().getAltText());
main.contextPut("isRestrictedEdit", restrictedEdit ? Boolean.TRUE : Boolean.FALSE);
//
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), menuTree, mainPanel, "qtieditor" + qtiPackage.getRepresentingResourceable());
listenTo(columnLayoutCtr);
stackedPanel.pushController("Editor", columnLayoutCtr);
// qtiPackage must be loaded previousely
populateToolC();
// Add css background
if (restrictedEdit) {
addSectionLink.setEnabled(false);
addSCLink.setEnabled(false);
addMCLink.setEnabled(false);
addPoolLink.setEnabled(false);
addFIBLink.setEnabled(false);
if (!qtiPackage.getQTIDocument().isSurvey()) {
addKPrimLink.setEnabled(false);
}
addEssayLink.setEnabled(false);
columnLayoutCtr.addCssClassToMain("o_editor_qti_correct");
} else {
columnLayoutCtr.addCssClassToMain("o_editor_qti");
}
deleteLink.setEnabled(false);
moveLink.setEnabled(false);
copyLink.setEnabled(false);
putInitialPanel(stackedPanel);
if (restrictedEdit) {
// we would like to us a modal dialog here, but this does not work! we
// can't push to stack because the outher workflows pushes us after the
// controller to the stack. Thus, if we used a modal dialog here the
// dialog would never show up.
columnLayoutCtr.setCol3(new Panel("empty"));
columnLayoutCtr.hideCol1(true);
columnLayoutCtr.hideCol2(true);
String text = translate("qti.restricted.edit.warning") + "<br/><br/>" + createReferenceesMsg(ureq);
proceedRestricedEditDialog = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), null, text);
listenTo(proceedRestricedEditDialog);
proceedRestricedEditDialog.activate();
}
}
Aggregations