use of org.olat.admin.user.tools.UserToolExtension in project OpenOLAT by OpenOLAT.
the class UserToolsAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("usertools");
setFormDescription("usertools.description");
int numOfTools = userTools.size();
String[] toolKeys = new String[numOfTools];
String[] toolValues = new String[numOfTools];
for (int i = 0; i < numOfTools; i++) {
UserToolExtension userTool = userTools.get(i);
toolKeys[i] = userTool.getUniqueExtensionID();
toolValues[i] = userTool.getLabel(getLocale());
}
availableEl = uifactory.addCheckboxesVertical("available.tools", "available.tools", formLayout, toolKeys, toolValues, 1);
availableEl.addActionListener(FormEvent.ONCHANGE);
Set<String> availableTools = userToolsModule.getAvailableUserToolSet();
if (availableTools.isEmpty()) {
for (String toolKey : toolKeys) {
availableEl.select(toolKey, true);
}
} else {
for (String toolKey : toolKeys) {
if (availableTools.contains(toolKey)) {
availableEl.select(toolKey, true);
}
}
}
List<String> presetToolKeyList = new ArrayList<>(numOfTools);
List<String> presetToolValueList = new ArrayList<>(numOfTools);
for (int i = 0; i < numOfTools; i++) {
UserToolExtension userTool = userTools.get(i);
if (!userTool.isShortCutOnly()) {
presetToolKeyList.add(userTool.getUniqueExtensionID());
presetToolValueList.add(userTool.getLabel(getLocale()));
}
}
String[] presetToolKeys = presetToolKeyList.toArray(new String[presetToolKeyList.size()]);
String[] presetToolValues = presetToolValueList.toArray(new String[presetToolValueList.size()]);
presetEl = uifactory.addCheckboxesVertical("preset.tools", "preset.tools", formLayout, presetToolKeys, presetToolValues, 1);
presetEl.addActionListener(FormEvent.ONCHANGE);
if (userToolsModule.isUserToolsDisabled()) {
presetEl.setEnabled(false);
} else {
Set<String> tools = userToolsModule.getDefaultPresetOfUserToolSet();
if (tools.size() > 0) {
for (String toolKey : presetToolKeys) {
if (tools.contains(toolKey)) {
presetEl.select(toolKey, true);
}
}
}
}
}
use of org.olat.admin.user.tools.UserToolExtension in project openolat by klemens.
the class OlatTopNavController method loadPersonalTools.
private void loadPersonalTools(UserRequest ureq) {
List<Tool> toolSetLinksName = new ArrayList<Tool>();
Preferences prefs = ureq.getUserSession().getGuiPreferences();
String selectedTools = userToolsModule.getUserTools(prefs);
if (!StringHelper.containsNonWhitespace(selectedTools)) {
selectedTools = userToolsModule.getDefaultPresetOfUserTools();
}
Set<String> selectedToolSet = new HashSet<>();
if (StringHelper.containsNonWhitespace(selectedTools)) {
String[] selectedToolArr = selectedTools.split(",");
for (String selectedTool : selectedToolArr) {
selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
}
}
List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
for (UserToolExtension toolExtension : toolExtensions) {
// check for sites
if (toolExtension.isShortCutOnly() || selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
if (tool != null) {
Component cmp = tool.getMenuComponent(ureq, topNavVC);
String cssId = toolExtension.getShortCutCssId();
String cssClass = toolExtension.getShortCutCssClass();
toolSetLinksName.add(new Tool(cssId, cssClass, cmp.getComponentName()));
disposableTools.add(tool);
}
}
}
topNavVC.contextPut("toolSet", toolSetLinksName);
}
use of org.olat.admin.user.tools.UserToolExtension in project openolat by klemens.
the class UserToolsMenuController method loadPersonalTools.
private void loadPersonalTools(UserRequest ureq) {
List<String> linksName = new ArrayList<>();
List<String> configLinksName = new ArrayList<>();
List<String> searchLinksName = new ArrayList<>();
List<String> systemLinksName = new ArrayList<>();
Preferences prefs = ureq.getUserSession().getGuiPreferences();
String selectedTools = userToolsModule.getUserTools(prefs);
if (!StringHelper.containsNonWhitespace(selectedTools)) {
selectedTools = userToolsModule.getDefaultPresetOfUserTools();
}
Set<String> selectedToolSet = new HashSet<>();
if (StringHelper.containsNonWhitespace(selectedTools)) {
String[] selectedToolArr = selectedTools.split(",");
for (String selectedTool : selectedToolArr) {
selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
}
}
List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
for (UserToolExtension toolExtension : toolExtensions) {
// check for sites
UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
if (tool != null) {
UserToolCategory category = toolExtension.getUserToolCategory();
boolean shortCutOnly = toolExtension.isShortCutOnly();
if (!shortCutOnly && !selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
Component link = tool.getMenuComponent(ureq, menuVC);
String linkName = link.getComponentName();
switch(category) {
case search:
searchLinksName.add(linkName);
break;
case personal:
linksName.add(linkName);
break;
case config:
configLinksName.add(linkName);
break;
case system:
systemLinksName.add(linkName);
break;
}
disposableTools.add(tool);
}
}
}
menuVC.contextPut("personalTools", linksName);
menuVC.contextPut("configs", configLinksName);
menuVC.contextPut("systems", systemLinksName);
menuVC.contextPut("searchs", searchLinksName);
menuVC.contextPut("locked", Boolean.FALSE);
}
use of org.olat.admin.user.tools.UserToolExtension in project OpenOLAT by OpenOLAT.
the class ToolsPrefsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("usertools.title");
setFormDescription("usertools.descr");
setFormContextHelp("Configuration#_tools");
String[] toolKeys;
String[] toolValues;
if (enabled) {
int numOfTools = userTools.size();
toolKeys = new String[numOfTools];
toolValues = new String[numOfTools];
for (int i = 0; i < numOfTools; i++) {
UserToolExtension userTool = userTools.get(i);
toolKeys[i] = userTool.getUniqueExtensionID();
toolValues[i] = userTool.getLabel(getLocale());
}
} else {
toolKeys = new String[0];
toolValues = new String[0];
}
presetEl = uifactory.addCheckboxesVertical("usertools.set", "usertools.set", formLayout, toolKeys, toolValues, 1);
presetEl.addActionListener(FormEvent.ONCHANGE);
presetEl.setEnabled(enabled);
initPresetElementUserData();
// Create submit and cancel buttons
FormLayoutContainer buttonLayoutWrappper = FormLayoutContainer.createButtonLayout("buttonLayoutWrappper", getTranslator());
formLayout.add(buttonLayoutWrappper);
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayoutInner", getTranslator());
buttonLayoutWrappper.add(buttonLayout);
uifactory.addFormSubmitButton("save", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
use of org.olat.admin.user.tools.UserToolExtension in project OpenOLAT by OpenOLAT.
the class UserToolsMenuController method loadPersonalTools.
private void loadPersonalTools(UserRequest ureq) {
List<String> linksName = new ArrayList<>();
List<String> configLinksName = new ArrayList<>();
List<String> searchLinksName = new ArrayList<>();
List<String> systemLinksName = new ArrayList<>();
Preferences prefs = ureq.getUserSession().getGuiPreferences();
String selectedTools = userToolsModule.getUserTools(prefs);
if (!StringHelper.containsNonWhitespace(selectedTools)) {
selectedTools = userToolsModule.getDefaultPresetOfUserTools();
}
Set<String> selectedToolSet = new HashSet<>();
if (StringHelper.containsNonWhitespace(selectedTools)) {
String[] selectedToolArr = selectedTools.split(",");
for (String selectedTool : selectedToolArr) {
selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
}
}
List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
for (UserToolExtension toolExtension : toolExtensions) {
// check for sites
UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
if (tool != null) {
UserToolCategory category = toolExtension.getUserToolCategory();
boolean shortCutOnly = toolExtension.isShortCutOnly();
if (!shortCutOnly && !selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
Component link = tool.getMenuComponent(ureq, menuVC);
String linkName = link.getComponentName();
switch(category) {
case search:
searchLinksName.add(linkName);
break;
case personal:
linksName.add(linkName);
break;
case config:
configLinksName.add(linkName);
break;
case system:
systemLinksName.add(linkName);
break;
}
disposableTools.add(tool);
}
}
}
menuVC.contextPut("personalTools", linksName);
menuVC.contextPut("configs", configLinksName);
menuVC.contextPut("systems", systemLinksName);
menuVC.contextPut("searchs", searchLinksName);
menuVC.contextPut("locked", Boolean.FALSE);
}
Aggregations