use of org.olat.portfolio.EPArtefactHandler in project OpenOLAT by OpenOLAT.
the class PortfolioFilterController method initOrUpdateTypeFlc.
/**
*/
private void initOrUpdateTypeFlc(int limit) {
typeFlc.setLabel("filter.view", null);
typeAllBtn = uifactory.addToggleButton("filter.all", null, typeFlc, null, null);
typeAllBtn.toggleOff();
List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
typeCmpList = new ArrayList<FormToggle>();
int i = 0;
List<String> allActiveTypeToggles = new ArrayList<String>();
for (EPArtefactHandler<?> handler : handlers) {
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + HANDLER_TITLE_SUFFIX;
FormToggle link = (FormToggle) typeFlc.getFormComponent(handlerClass);
if (link == null) {
Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
typeFlc.setTranslator(handlerTrans);
link = uifactory.addToggleButton(handlerClass, null, typeFlc, null, null);
link.setUserObject(handler.getType());
}
if (selectedTypeList.contains(handler.getType())) {
link.toggleOn();
allActiveTypeToggles.add(handler.getType());
} else {
link.toggleOff();
}
typeCmpList.add(link);
i++;
if (i > limit)
break;
}
typeFlc.contextPut("typeCmpList", typeCmpList);
typeEditBtn = uifactory.addToggleButton("filter.edit", null, typeFlc, null, null);
typeEditBtn.toggleOff();
if (!allActiveTypeToggles.containsAll(selectedTypeList))
typeEditBtn.toggleOn();
if (selectedTypeList.isEmpty())
typeAllBtn.toggleOn();
}
use of org.olat.portfolio.EPArtefactHandler in project OpenOLAT by OpenOLAT.
the class EPArtefactTypeSelectionController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("filter.type.intro");
String[] keys = new String[] { "onoff" };
String[] values = new String[] { translate("filter.type.enabled") };
List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
typeCmpList = new ArrayList<MultipleSelectionElement>();
for (EPArtefactHandler<?> handler : handlers) {
Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
this.flc.setTranslator(handlerTrans);
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
MultipleSelectionElement chkBox = uifactory.addCheckboxesHorizontal(handlerClass, formLayout, keys, values);
if (selectedTypeList != null && selectedTypeList.contains(handler.getType())) {
chkBox.select(keys[0], true);
}
chkBox.addActionListener(FormEvent.ONCHANGE);
chkBox.setUserObject(handler.getType());
typeCmpList.add(chkBox);
}
uifactory.addFormSubmitButton("filter.type.submit", formLayout);
}
use of org.olat.portfolio.EPArtefactHandler in project openolat by klemens.
the class PortfolioAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// module configuration
FormLayoutContainer moduleFlc = FormLayoutContainer.createDefaultFormLayout("flc_module", getTranslator());
formLayout.add(moduleFlc);
String[] enabledValues = new String[] { translate("enabled") };
String[] enabledPortfolioValues = new String[] { translate("enabled"), translate("portfolio.v1.module.enabled") };
portfoliosEnabled = uifactory.addCheckboxesVertical("portfolio.module.enabled", moduleFlc, enabledPortfolioKeys, enabledPortfolioValues, 1);
if (portfolioModule.isEnabled() || portfolioV2Module.isEnabled()) {
portfoliosEnabled.select(enabledPortfolioKeys[0], true);
}
if (portfolioModule.isEnabled()) {
portfoliosEnabled.select(enabledPortfolioKeys[1], true);
}
portfoliosEnabled.addActionListener(FormEvent.ONCHANGE);
createBinderEl = uifactory.addCheckboxesVertical("portfolio.user.create.binder", moduleFlc, BINDER_CREATE_KEYS, translateKeys(BINDER_CREATE_KEYS), 1);
createBinderEl.addActionListener(FormEvent.ONCHANGE);
String[] entryPointKeys = new String[] { PortfolioV2Module.ENTRY_POINT_TOC, PortfolioV2Module.ENTRY_POINT_ENTRIES };
String[] entryPointValues = new String[] { translate("binder.entry.point.toc"), translate("binder.entry.point.entries") };
entryPointEl = uifactory.addDropdownSingleselect("binder.entry.point", "binder.entry.point", moduleFlc, entryPointKeys, entryPointValues, null);
entryPointEl.addActionListener(FormEvent.ONCHANGE);
String entryPoint = portfolioV2Module.getBinderEntryPoint();
for (String entryPointKey : entryPointKeys) {
if (entryPointKey.equals(entryPoint)) {
entryPointEl.select(entryPointKey, true);
}
}
if (!entryPointEl.isOneSelected()) {
entryPointEl.select(entryPointKeys[0], true);
}
sectionVisibilityEl = uifactory.addCheckboxesVertical("section.enabled", moduleFlc, SECTION_VISIBILITY_KEYS, translateKeys(SECTION_VISIBILITY_KEYS), 1);
sectionVisibilityEl.addActionListener(FormEvent.ONCHANGE);
entryElementsVisibilityEl = uifactory.addCheckboxesVertical("entries.elements.enabled", moduleFlc, ENTRIES_ELEMENTS_KEYS, translateKeys(ENTRIES_ELEMENTS_KEYS), 1);
entryElementsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
commentsVisibilityEl = uifactory.addCheckboxesVertical("comments.enabled", moduleFlc, COMMENTS_KEYS, translateKeys(COMMENTS_KEYS), 1);
commentsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
entriesViewEl = uifactory.addDropdownSingleselect("entries.view", moduleFlc, ENTRIES_VIEW_KEYS, translateKeys(ENTRIES_VIEW_KEYS));
String selectedKey = ENTRIES_BOTH_ENABLED;
if (portfolioV2Module.isEntriesTableEnabled() && !portfolioV2Module.isEntriesListEnabled()) {
selectedKey = ENTRIES_TABLE_ENABLED;
} else if (!portfolioV2Module.isEntriesTableEnabled() && portfolioV2Module.isEntriesListEnabled()) {
selectedKey = ENTRIES_LIST_ENABLED;
}
entriesViewEl.select(selectedKey, true);
entriesViewEl.addActionListener(FormEvent.ONCHANGE);
// handlers configuration
FormLayoutContainer handlersFlc = FormLayoutContainer.createDefaultFormLayout("flc_handlers", getTranslator());
formLayout.add(handlersFlc);
List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
for (EPArtefactHandler<?> handler : handlers) {
Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
handlersFlc.setTranslator(handlerTrans);
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
MultipleSelectionElement handlerEnabled = uifactory.addCheckboxesHorizontal(handlerClass, handlersFlc, enabledKeys, enabledValues);
handlerEnabled.select(enabledKeys[0], handler.isEnabled());
handlerEnabled.setUserObject(handler);
handlerEnabled.addActionListener(FormEvent.ONCHANGE);
handlersEnabled.add(handlerEnabled);
}
// configure steps in artefact collection wizard
wizardFlc = FormLayoutContainer.createDefaultFormLayout("flc_wizard", getTranslator());
formLayout.add(wizardFlc);
copyrightStepCB = uifactory.addCheckboxesHorizontal("wizard.step.copyright", wizardFlc, enabledKeys, enabledValues);
copyrightStepCB.select(enabledKeys[0], portfolioModule.isCopyrightStepEnabled());
copyrightStepCB.addActionListener(FormEvent.ONCHANGE);
reflexionStepCB = uifactory.addCheckboxesHorizontal("wizard.step.reflexion", wizardFlc, enabledKeys, enabledValues);
reflexionStepCB.select(enabledKeys[0], portfolioModule.isReflexionStepEnabled());
reflexionStepCB.addActionListener(FormEvent.ONCHANGE);
wizardFlc.setVisible(portfoliosEnabled.isSelected(1));
updateV2UI();
}
use of org.olat.portfolio.EPArtefactHandler in project OpenOLAT by OpenOLAT.
the class EPStructureDetailsController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
if (formLayout.getFormComponent("struct.title") != null) {
formLayout.remove("struct.title");
}
titleEl = uifactory.addTextElement("struct.title", "struct.title", 512, editStructure.getTitle(), formLayout);
titleEl.setNotEmptyCheck("map.title.not.empty");
titleEl.setMandatory(true);
// choose representation mode (table or minimized artefact-view)
if (formLayout.getFormComponent("view.mode") != null) {
formLayout.remove("view.mode");
}
final String[] theKeys = new String[] { VIEWMODE_TABLE, VIEWMODE_MINI };
final String[] theValues = new String[] { translate("view.mode." + VIEWMODE_TABLE), translate("view.mode." + VIEWMODE_MINI) };
viewRadio = uifactory.addRadiosHorizontal("view.mode", formLayout, theKeys, theValues);
final String artRepMode = editStructure.getArtefactRepresentationMode();
if (artRepMode != null) {
viewRadio.select(artRepMode, true);
} else {
viewRadio.select(VIEWMODE_MINI, true);
}
if (formLayout.getFormComponent("struct.description") != null) {
formLayout.remove("struct.description");
}
descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("struct.description", "struct.description", editStructure.getDescription(), -1, -1, formLayout, getWindowControl());
descriptionEl.setMaxLength(2047);
descriptionEl.setNotLongerThanCheck(2047, "map.description.too.long");
// hint for no edit options
if (formLayout.getFormComponent("noEditInfo") != null) {
formLayout.remove("noEditInfo");
}
noEditInfo = uifactory.addStaticTextElement("noEditInfo", "no.edit.info.label", translate("no.edit.info"), formLayout);
noEditInfo.setVisible(false);
if (formLayout.getFormComponent("collect.restriction") != null) {
formLayout.remove("collect.restriction");
}
// show restrictions only for templates and on page/structure-level, as artefacts are not linkable on maps itself
if (editStructure instanceof EPStructureElement && rootStructure instanceof EPStructuredMapTemplate && editStructure.getRoot() != null) {
final FormLayoutContainer collectContainer = FormLayoutContainer.createCustomFormLayout("collect.restriction", getTranslator(), velocity_root + "/restrictions.html");
collectContainer.setRootForm(mainForm);
collectContainer.setLabel("collect.restriction", null);
formLayout.add(collectContainer);
final String[] restrictionKeys = new String[] { "", RestrictionsConstants.MAX, RestrictionsConstants.EQUAL, RestrictionsConstants.MIN };
final String[] restrictionValues = new String[restrictionKeys.length];
restrictionValues[0] = "";
for (int i = 1; i < restrictionKeys.length; i++) {
restrictionValues[i] = translate("restriction." + restrictionKeys[i]);
}
// allow only to use enabled handlers
final List<EPArtefactHandler<?>> handlers = portfolioModule.getArtefactHandlers();
final String[] artefactKeys = new String[handlers.size() + 1];
final String[] artefactValues = new String[artefactKeys.length];
artefactValues[0] = artefactKeys[0] = "";
for (int i = 0; i < handlers.size(); i++) {
final EPArtefactHandler<?> handler = handlers.get(i);
artefactKeys[i + 1] = handler.getType();
final String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
artefactValues[i + 1] = handler.getHandlerTranslator(getTranslator()).translate(handlerClass);
}
if (collectRestrictions.isEmpty()) {
collectRestrictions.add(new CollectRestriction());
}
restrictionElements = new ArrayList<SingleSelection>();
restrictToArtefactElements = new ArrayList<SingleSelection>();
amountElements = new ArrayList<TextElement>();
errorElements = new ArrayList<StaticTextElement>();
final List<String> counts = new ArrayList<String>();
for (final CollectRestriction restriction : collectRestrictions) {
final int count = restrictionElements.size();
final SingleSelection restrictionElement = uifactory.addDropdownSingleselect("collect.restriction.restriction." + count, "", collectContainer, restrictionKeys, restrictionValues, null);
restrictionElement.setDomReplacementWrapperRequired(false);
restrictionElement.setMandatory(true);
if (restriction != null && StringHelper.containsNonWhitespace(restriction.getRestriction())) {
restrictionElement.select(restriction.getRestriction(), true);
}
restrictionElement.setUserObject(restriction);
final SingleSelection restrictToArtefactElement = uifactory.addDropdownSingleselect("collect.restriction.artefacts." + count, "", collectContainer, artefactKeys, artefactValues, null);
restrictToArtefactElement.setDomReplacementWrapperRequired(false);
restrictToArtefactElement.setMandatory(true);
if (restriction != null && StringHelper.containsNonWhitespace(restriction.getArtefactType())) {
restrictToArtefactElement.select(restriction.getArtefactType(), true);
}
String amountStr = "";
if (restriction != null && restriction.getAmount() > 0) {
amountStr = Integer.toString(restriction.getAmount());
}
final TextElement amountElement = uifactory.addTextElement("collect.restriction.amount." + count, null, 2, amountStr, collectContainer);
amountElement.setDomReplacementWrapperRequired(false);
amountElement.setDisplaySize(3);
StaticTextElement errorElement = uifactory.addStaticTextElement("collect.restriction.error." + count, null, "", collectContainer);
errorElement.setVisible(false);
restrictionElements.add(restrictionElement);
restrictToArtefactElements.add(restrictToArtefactElement);
amountElements.add(amountElement);
errorElements.add(errorElement);
final FormLink addLink = uifactory.addFormLink("collect.restriction.add." + count, "collect.restriction.add", "collect.restriction.add", collectContainer, Link.BUTTON_SMALL);
addLink.setDomReplacementWrapperRequired(false);
addLink.setUserObject(restriction);
final FormLink delLink = uifactory.addFormLink("collect.restriction.del." + count, "collect.restriction.delete", "collect.restriction.delete", collectContainer, Link.BUTTON_SMALL);
delLink.setDomReplacementWrapperRequired(false);
delLink.setUserObject(restriction);
counts.add(Integer.toString(count));
}
collectContainer.contextPut("counts", counts);
}
if (formLayout.getFormComponent("save") != null) {
formLayout.remove("save");
}
uifactory.addFormSubmitButton("save", formLayout);
}
use of org.olat.portfolio.EPArtefactHandler in project OpenOLAT by OpenOLAT.
the class PortfolioAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// module configuration
FormLayoutContainer moduleFlc = FormLayoutContainer.createDefaultFormLayout("flc_module", getTranslator());
formLayout.add(moduleFlc);
String[] enabledValues = new String[] { translate("enabled") };
String[] enabledPortfolioValues = new String[] { translate("enabled"), translate("portfolio.v1.module.enabled") };
portfoliosEnabled = uifactory.addCheckboxesVertical("portfolio.module.enabled", moduleFlc, enabledPortfolioKeys, enabledPortfolioValues, 1);
if (portfolioModule.isEnabled() || portfolioV2Module.isEnabled()) {
portfoliosEnabled.select(enabledPortfolioKeys[0], true);
}
if (portfolioModule.isEnabled()) {
portfoliosEnabled.select(enabledPortfolioKeys[1], true);
}
portfoliosEnabled.addActionListener(FormEvent.ONCHANGE);
createBinderEl = uifactory.addCheckboxesVertical("portfolio.user.create.binder", moduleFlc, BINDER_CREATE_KEYS, translateKeys(BINDER_CREATE_KEYS), 1);
createBinderEl.addActionListener(FormEvent.ONCHANGE);
String[] entryPointKeys = new String[] { PortfolioV2Module.ENTRY_POINT_TOC, PortfolioV2Module.ENTRY_POINT_ENTRIES };
String[] entryPointValues = new String[] { translate("binder.entry.point.toc"), translate("binder.entry.point.entries") };
entryPointEl = uifactory.addDropdownSingleselect("binder.entry.point", "binder.entry.point", moduleFlc, entryPointKeys, entryPointValues, null);
entryPointEl.addActionListener(FormEvent.ONCHANGE);
String entryPoint = portfolioV2Module.getBinderEntryPoint();
for (String entryPointKey : entryPointKeys) {
if (entryPointKey.equals(entryPoint)) {
entryPointEl.select(entryPointKey, true);
}
}
if (!entryPointEl.isOneSelected()) {
entryPointEl.select(entryPointKeys[0], true);
}
sectionVisibilityEl = uifactory.addCheckboxesVertical("section.enabled", moduleFlc, SECTION_VISIBILITY_KEYS, translateKeys(SECTION_VISIBILITY_KEYS), 1);
sectionVisibilityEl.addActionListener(FormEvent.ONCHANGE);
entryElementsVisibilityEl = uifactory.addCheckboxesVertical("entries.elements.enabled", moduleFlc, ENTRIES_ELEMENTS_KEYS, translateKeys(ENTRIES_ELEMENTS_KEYS), 1);
entryElementsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
commentsVisibilityEl = uifactory.addCheckboxesVertical("comments.enabled", moduleFlc, COMMENTS_KEYS, translateKeys(COMMENTS_KEYS), 1);
commentsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
entriesViewEl = uifactory.addDropdownSingleselect("entries.view", moduleFlc, ENTRIES_VIEW_KEYS, translateKeys(ENTRIES_VIEW_KEYS));
String selectedKey = ENTRIES_BOTH_ENABLED;
if (portfolioV2Module.isEntriesTableEnabled() && !portfolioV2Module.isEntriesListEnabled()) {
selectedKey = ENTRIES_TABLE_ENABLED;
} else if (!portfolioV2Module.isEntriesTableEnabled() && portfolioV2Module.isEntriesListEnabled()) {
selectedKey = ENTRIES_LIST_ENABLED;
}
entriesViewEl.select(selectedKey, true);
entriesViewEl.addActionListener(FormEvent.ONCHANGE);
// handlers configuration
FormLayoutContainer handlersFlc = FormLayoutContainer.createDefaultFormLayout("flc_handlers", getTranslator());
formLayout.add(handlersFlc);
List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
for (EPArtefactHandler<?> handler : handlers) {
Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
handlersFlc.setTranslator(handlerTrans);
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
MultipleSelectionElement handlerEnabled = uifactory.addCheckboxesHorizontal(handlerClass, handlersFlc, enabledKeys, enabledValues);
handlerEnabled.select(enabledKeys[0], handler.isEnabled());
handlerEnabled.setUserObject(handler);
handlerEnabled.addActionListener(FormEvent.ONCHANGE);
handlersEnabled.add(handlerEnabled);
}
// configure steps in artefact collection wizard
wizardFlc = FormLayoutContainer.createDefaultFormLayout("flc_wizard", getTranslator());
formLayout.add(wizardFlc);
copyrightStepCB = uifactory.addCheckboxesHorizontal("wizard.step.copyright", wizardFlc, enabledKeys, enabledValues);
copyrightStepCB.select(enabledKeys[0], portfolioModule.isCopyrightStepEnabled());
copyrightStepCB.addActionListener(FormEvent.ONCHANGE);
reflexionStepCB = uifactory.addCheckboxesHorizontal("wizard.step.reflexion", wizardFlc, enabledKeys, enabledValues);
reflexionStepCB.select(enabledKeys[0], portfolioModule.isReflexionStepEnabled());
reflexionStepCB.addActionListener(FormEvent.ONCHANGE);
wizardFlc.setVisible(portfoliosEnabled.isSelected(1));
updateV2UI();
}
Aggregations