Skip to content
Snippets Groups Projects
Commit e07e1056 authored by uhensler's avatar uhensler
Browse files

OO-4939: Refactoring admin area as preparation for removal of Office365 Editor

parent 463b854c
No related branches found
No related tags found
No related merge requests found
Showing
with 276 additions and 87 deletions
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.commons.services.doceditor;
import java.util.Locale;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
/**
*
* Initial date: 16 Sep 2020<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface DocEditorAdminSegment {
public String getLinkName(Locale locale);
public String getBusinessPathType();
public Controller createController(UserRequest ureq, WindowControl wControl);
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.commons.services.doceditor.collabora.ui;
import java.util.Locale;
import org.olat.core.commons.services.doceditor.DocEditorAdminSegment;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
import org.springframework.stereotype.Component;
/**
*
* Initial date: 17 Sep 2020<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
@Component
public class CollaboraAdminSegment implements DocEditorAdminSegment {
@Override
public String getLinkName(Locale locale) {
Translator translator = Util.createPackageTranslator(CollaboraAdminController.class, locale);
return translator.translate("editor.display.name");
}
@Override
public String getBusinessPathType() {
return "Collabora";
}
@Override
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new CollaboraAdminController(ureq, wControl);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.commons.services.doceditor.office365.ui;
import java.util.Locale;
import org.olat.core.commons.services.doceditor.DocEditorAdminSegment;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
import org.springframework.stereotype.Component;
/**
*
* Initial date: 17 Sep 2020<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
@Component
public class Office365AdminSegment implements DocEditorAdminSegment {
@Override
public String getLinkName(Locale locale) {
Translator translator = Util.createPackageTranslator(Office365AdminController.class, locale);
return translator.translate("editor.display.name");
}
@Override
public String getBusinessPathType() {
return "OfficeForTheWeb";
}
@Override
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new Office365AdminController(ureq, wControl);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.commons.services.doceditor.onlyoffice.ui;
import java.util.Locale;
import org.olat.core.commons.services.doceditor.DocEditorAdminSegment;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
import org.springframework.stereotype.Component;
/**
*
* Initial date: 17 Sep 2020<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
@Component
public class OnlyOfficeAdminSegment implements DocEditorAdminSegment {
@Override
public String getLinkName(Locale locale) {
Translator translator = Util.createPackageTranslator(OnlyOfficeAdminController.class, locale);
return translator.translate("editor.display.name");
}
@Override
public String getBusinessPathType() {
return "OnlyOffice";
}
@Override
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new OnlyOfficeAdminController(ureq, wControl);
}
}
......@@ -21,9 +21,7 @@ package org.olat.core.commons.services.doceditor.ui;
import java.util.List;
import org.olat.core.commons.services.doceditor.collabora.ui.CollaboraAdminController;
import org.olat.core.commons.services.doceditor.office365.ui.Office365AdminController;
import org.olat.core.commons.services.doceditor.onlyoffice.ui.OnlyOfficeAdminController;
import org.olat.core.commons.services.doceditor.DocEditorAdminSegment;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
......@@ -40,6 +38,7 @@ import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.util.resource.OresHelper;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
......@@ -47,41 +46,45 @@ import org.olat.core.util.resource.OresHelper;
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class AdminDocEditorController extends BasicController implements Activateable2 {
public class AdminDocEditorController extends BasicController implements Activateable2 {
private static final String COLLABORA_RES_TYPE = "Collabora";
private static final String ONLY_OFFICE_RES_TYPE = "OnlyOffice";
private static final String OFFICE365_RES_TYPE = "Office365";
private static final String DOCUMENTS_IN_USE_RES_TYPE = "OpenDocuments";
private VelocityContainer mainVC;
private final Link collaboraLink;
private final Link onlyOfficeLink;
private final Link office365Link;
private final Link documentsInUseLink;
private final SegmentViewComponent segmentView;
private Controller collaboraCtrl;
private Controller onlyOfficeCtrl;
private Controller office365Ctrl;
private Controller editorCtrl;
private DocumentsInUseListController documentsInUseCtrl;
private int counter = 0;
@Autowired
private List<DocEditorAdminSegment> adminSegments;
public AdminDocEditorController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
mainVC = createVelocityContainer("admin");
segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this);
collaboraLink = LinkFactory.createLink("admin.collabora", mainVC, this);
segmentView.addSegment(collaboraLink, true);
onlyOfficeLink = LinkFactory.createLink("admin.onlyoffice", mainVC, this);
segmentView.addSegment(onlyOfficeLink, false);
office365Link = LinkFactory.createLink("admin.office365", mainVC, this);
segmentView.addSegment(office365Link, false);
adminSegments.sort((s1, s2) -> s1.getLinkName(getLocale()).compareToIgnoreCase(s2.getLinkName(getLocale())));
for (DocEditorAdminSegment adminSegment : adminSegments) {
String name = "ed-" + (++counter);
Link link = LinkFactory.createLink(name, name, getTranslator(), mainVC, this, Link.NONTRANSLATED);
link.setCustomDisplayText(adminSegment.getLinkName(getLocale()));
link.setUserObject(adminSegment);
segmentView.addSegment(link, false);
}
documentsInUseLink = LinkFactory.createLink("admin.documents.in.use", mainVC, this);
segmentView.addSegment(documentsInUseLink, false);
doOpenCollabora(ureq);
Component firstLink = segmentView.getSegments().get(0);
segmentView.select(firstLink);
doOpenAdminSegment(ureq, adminSegments.get(0));
putInitialPanel(mainVC);
}
......@@ -90,19 +93,32 @@ public class AdminDocEditorController extends BasicController implements Activat
if(entries == null || entries.isEmpty()) return;
String type = entries.get(0).getOLATResourceable().getResourceableTypeName();
if(COLLABORA_RES_TYPE.equalsIgnoreCase(type)) {
doOpenCollabora(ureq);
segmentView.select(collaboraLink);
} else if(ONLY_OFFICE_RES_TYPE.equalsIgnoreCase(type)) {
doOpenOnlyOffice(ureq);
segmentView.select(onlyOfficeLink);
} else if(OFFICE365_RES_TYPE.equalsIgnoreCase(type)) {
doOpenOffice365(ureq);
segmentView.select(office365Link);
} else if(DOCUMENTS_IN_USE_RES_TYPE.equalsIgnoreCase(type)) {
if (DOCUMENTS_IN_USE_RES_TYPE.equalsIgnoreCase(type)) {
doOpenDocumentsInUse(ureq);
segmentView.select(documentsInUseLink);
} else {
DocEditorAdminSegment adminSegment = getAdminSegment(type);
if (adminSegment != null) {
doOpenAdminSegment(ureq, adminSegment);
}
}
}
private DocEditorAdminSegment getAdminSegment(String type) {
for (Component component : segmentView.getSegments()) {
if (component instanceof Link) {
Link link = (Link)component;
Object userObject = link.getUserObject();
if (userObject instanceof DocEditorAdminSegment) {
DocEditorAdminSegment adminSegment = (DocEditorAdminSegment)userObject;
if (adminSegment.getBusinessPathType().equalsIgnoreCase(type)) {
segmentView.select(component);
return adminSegment;
}
}
}
}
return null;
}
@Override
......@@ -112,50 +128,28 @@ public class AdminDocEditorController extends BasicController implements Activat
SegmentViewEvent sve = (SegmentViewEvent)event;
String segmentCName = sve.getComponentName();
Component clickedLink = mainVC.getComponent(segmentCName);
if (clickedLink == collaboraLink) {
doOpenCollabora(ureq);
} else if (clickedLink == onlyOfficeLink) {
doOpenOnlyOffice(ureq);
} else if (clickedLink == office365Link) {
doOpenOffice365(ureq);
} else if (clickedLink == documentsInUseLink) {
if (clickedLink == documentsInUseLink) {
doOpenDocumentsInUse(ureq);
} else if (clickedLink instanceof Link) {
Link link = (Link)clickedLink;
Object userObject = link.getUserObject();
if (userObject instanceof DocEditorAdminSegment) {
DocEditorAdminSegment adminSegment = (DocEditorAdminSegment)userObject;
doOpenAdminSegment(ureq, adminSegment);
}
}
}
}
}
private void doOpenCollabora(UserRequest ureq) {
if(collaboraCtrl == null) {
WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableType(COLLABORA_RES_TYPE), null);
collaboraCtrl = new CollaboraAdminController(ureq, swControl);
listenTo(collaboraCtrl);
} else {
addToHistory(ureq, collaboraCtrl);
}
mainVC.put("segmentCmp", collaboraCtrl.getInitialComponent());
}
private void doOpenOnlyOffice(UserRequest ureq) {
if(onlyOfficeCtrl == null) {
WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableType(ONLY_OFFICE_RES_TYPE), null);
onlyOfficeCtrl = new OnlyOfficeAdminController(ureq, swControl);
listenTo(onlyOfficeCtrl);
} else {
addToHistory(ureq, onlyOfficeCtrl);
}
mainVC.put("segmentCmp", onlyOfficeCtrl.getInitialComponent());
}
private void doOpenOffice365(UserRequest ureq) {
if(office365Ctrl == null) {
WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableType(OFFICE365_RES_TYPE), null);
office365Ctrl = new Office365AdminController(ureq, swControl);
listenTo(office365Ctrl);
} else {
addToHistory(ureq, office365Ctrl);
}
mainVC.put("segmentCmp", office365Ctrl.getInitialComponent());
private void doOpenAdminSegment(UserRequest ureq, DocEditorAdminSegment adminSegment) {
removeAsListenerAndDispose(editorCtrl);
editorCtrl = null;
WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableType(adminSegment.getBusinessPathType()), null);
editorCtrl = adminSegment.createController(ureq, swControl);
listenTo(editorCtrl);
mainVC.put("segmentCmp", editorCtrl.getInitialComponent());
}
private void doOpenDocumentsInUse(UserRequest ureq) {
......
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=Best\u00e4tigung Datentransfer
admin.documents.in.use=Ge\u00f6ffnete Dokumente
admin.menu.title.alt=Dokumenteneditoren
admin.menu.title=Dokumenteneditoren
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
admin.usage.roles.author=Autoren
admin.usage.roles.coach=Betreuer
admin.usage.roles.help=Wenn Sie diese Option einschalten, kann niemand ausser den explizit angegebenen Benutzerrollen den Editor verwenden. Nur Administratoren k\u00f6nnen den Editor immer verwenden.
......
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=Confirmation of data transfer
admin.documents.in.use=Open documents
admin.menu.title.alt=Document editors
......@@ -8,8 +7,6 @@ admin.usage.roles.author=Authors
admin.usage.roles.coach=Coaches
admin.usage.roles.help=If you enable this option, nobody but the explicitly specified user roles can use the editor. Only administrators can always use the editor.
admin.usage.roles.managers=Manager
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
create.doc.already.exists=$org.olat.core.commons.modules.bc\:cfile.already.exists
create.doc.button=Create document
create.doc.name.notvalid=$org.olat.core.commons.modules.bc\:cfile.name.notvalid
......
#Thu Apr 23 10:22:06 CEST 2020
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=Confirmer le transfert de donn\u00E9es
admin.documents.in.use=Documents ouverts
admin.menu.title=Editeurs de documents
admin.menu.title.alt=Editeurs de documents
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
admin.usage.roles=Restrictions d'usage \u00E0
admin.usage.roles.author=Auteurs
admin.usage.roles.coach=Coach
......
#Wed Aug 26 16:00:00 CEST 2020
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=Confermare il trasferimento dati
admin.documents.in.use=Aprire documenti
admin.menu.title=Editori di documenti
admin.menu.title.alt=Editore di documenti
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
admin.usage.roles=Restrizioni d'uso per
admin.usage.roles.author=Autori
admin.usage.roles.coach=Coach
......
#Tue May 26 15:13:50 CEST 2020
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=Confirma\u00E7\u00E3o de transfer\u00EAncia de dados
admin.documents.in.use=Documentos abertos
admin.menu.title=Editores de documento
admin.menu.title.alt=Editores de documentos
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
admin.usage.roles=Restringir o uso a
admin.usage.roles.author=Autores
admin.usage.roles.coach=Treinadores
......
#Fri Feb 28 09:46:20 CET 2020
admin.collabora=$org.olat.core.commons.services.doceditor.collabora.ui\:editor.display.name
admin.data.transfer.confirmation.enabled=\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043D\u043D\u044B\u0445
admin.menu.title=\u0420\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432
admin.menu.title.alt=\u0420\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432
admin.office365=$org.olat.core.commons.services.doceditor.office365.ui\:editor.display.name
admin.onlyoffice=$org.olat.core.commons.services.doceditor.onlyoffice.ui\:editor.display.name
admin.usage.roles=\u041E\u0433\u0440\u0430\u043D\u0438\u0447\u0438\u0442\u044C \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E
admin.usage.roles.author=\u0410\u0432\u0442\u043E\u0440\u044B
admin.usage.roles.coach=\u0422\u0440\u0435\u043D\u0435\u0440\u044B
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment