use of org.olat.core.gui.control.navigation.SiteInstance in project OpenOLAT by OpenOLAT.
the class GuestBFWCParts method getSiteInstances.
/**
* @see org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts#getSiteInstances(org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl)
*/
@Override
public List<SiteInstance> getSiteInstances(UserRequest ureq, WindowControl wControl) {
SiteDefinitions sitedefs = CoreSpringFactory.getImpl(SiteDefinitions.class);
List<SiteInstance> sites = new ArrayList<SiteInstance>();
for (SiteDefinition sitedef : sitedefs.getSiteDefList()) {
SiteInstance site = sitedef.createSite(ureq, wControl);
if (site != null) {
// site == null means that site is not visible to the current user
sites.add(site);
}
}
return sites;
}
use of org.olat.core.gui.control.navigation.SiteInstance in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method initializeDefaultSite.
/**
* @param ureq
* @return The current business path if a site is initialized or null
*/
private String initializeDefaultSite(UserRequest ureq) {
String businessPath = null;
if (sites != null && sites.size() > 0 && curSite == null && curDTab == null && contentCtrl == null && lockResource == null) {
SiteInstance s = sites.get(0);
// activate site only if no content was set -> allow content before activation of default site.
activateSite(s, ureq, null, false);
businessPath = updateBusinessPath(ureq, s);
}
return businessPath;
}
use of org.olat.core.gui.control.navigation.SiteInstance in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source instanceof Link) {
Link link = (Link) source;
String mC = link.getCommand().substring(0, 1);
if (mC.equals("t")) {
// activate normal tab
SiteInstance s = (SiteInstance) link.getUserObject();
// fix the state of the last tab/site
updateBusinessPath(ureq);
HistoryPoint point = null;
if (siteToBusinessPath.containsKey(s)) {
point = siteToBusinessPath.get(s);
}
activateSite(s, ureq, null, true);
if (point != null) {
BusinessControlFactory.getInstance().addToHistory(ureq, point);
}
updateBusinessPath(ureq, s);
} else if (mC.equals("a")) {
// activate dyntab
DTab dt = (DTab) link.getUserObject();
// fix the state of the last tab/site
updateBusinessPath(ureq);
HistoryPoint point = null;
if (dtabToBusinessPath.containsKey(dt)) {
point = dtabToBusinessPath.get(dt);
}
doActivateDTab(dt);
if (dt.getController() instanceof Activateable2) {
((Activateable2) dt.getController()).activate(ureq, null, new ReloadEvent());
}
if (point != null) {
BusinessControlFactory.getInstance().addToHistory(ureq, point);
}
} else if (mC.equals("c")) {
// close dyntab
DTab dt = (DTab) link.getUserObject();
requestCloseTab(ureq, dt);
}
} else if (source == getWindowControl().getWindowBackOffice().getWindow()) {
if (event == Window.OLDTIMESTAMPCALL) {
getLogger().info("RELOAD");
HistoryPoint point = ureq.getUserSession().popLastHistoryEntry();
if (point != null) {
back(ureq, point);
}
}
}
}
use of org.olat.core.gui.control.navigation.SiteInstance in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method back.
protected void back(UserRequest ureq, HistoryPoint cstate) {
List<ContextEntry> entries = cstate.getEntries();
if (entries.isEmpty())
return;
entries = new ArrayList<ContextEntry>(entries);
ContextEntry state = entries.remove(0);
// no red screen for this
if (state == null)
return;
OLATResourceable ores = state.getOLATResourceable();
if (ores != null && "HomeSite".equals(ores.getResourceableTypeName())) {
activateSite(userTools, ureq, entries, false);
} else {
DTab dt = getDTab(ores);
if (dt != null) {
doActivateDTab(dt);
if (dt.getController() instanceof Activateable2) {
((Activateable2) dt.getController()).activate(ureq, entries, null);
}
updateBusinessPath(ureq, dt);
} else {
StateEntry s = state.getTransientState();
if (s instanceof StateSite && ((StateSite) s).getSite() != null && sites != null) {
SiteInstance site = ((StateSite) s).getSite();
for (SiteInstance savedSite : sites) {
if (savedSite != null && site.getClass().equals(savedSite.getClass())) {
activateSite(savedSite, ureq, entries, false);
}
}
}
}
}
}
use of org.olat.core.gui.control.navigation.SiteInstance in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method initialize.
private void initialize(UserRequest ureq) {
mainVc = createVelocityContainer("fullwebapplayout");
mainVc.contextPut("screenMode", screenMode);
LayoutModule layoutModule = CoreSpringFactory.getImpl(LayoutModule.class);
LandingPagesModule landingPagesModule = CoreSpringFactory.getImpl(LandingPagesModule.class);
LogoInformations logoInfos = new LogoInformations(ureq, layoutModule, landingPagesModule);
mainVc.contextPut("logoInfos", logoInfos);
// use separate container for navigation to prevent full page refresh in ajax mode on site change
// nav is not a controller part because it is a fundamental part of the BaseFullWebAppConroller.
navSitesVc = createVelocityContainer("nav_sites");
navSitesVc.setDomReplacementWrapperRequired(false);
navSitesVc.contextPut("visible", Boolean.TRUE);
mainVc.put("sitesComponent", navSitesVc);
navTabsVc = createVelocityContainer("nav_tabs");
navTabsVc.setDomReplacementWrapperRequired(false);
mainVc.put("tabsComponent", navTabsVc);
// GUI messages
guimsgVc = createVelocityContainer("guimsg");
guimsgVc.contextPut("guiMessage", guiMessage);
guimsgHolder = new Panel("guimsgholder");
guimsgHolder.setContent(guimsgPanel);
currentMsgHolder = guimsgHolder;
mainVc.put("guimessage", guimsgHolder);
// CSS panel
cssHolder = new Panel("customCss");
mainVc.put("customCssHolder", cssHolder);
// sticky maintenance message
stickyMessageCmp = new StickyMessageComponent("stickymsg", screenMode);
mainVc.put("stickymsg", stickyMessageCmp);
updateStickyMessage();
dtabs = new ArrayList<>();
dtabsLinkNames = new ArrayList<>();
dtabsControllers = new ArrayList<>();
// -- sites -- by definition the first site is activated at the beginning
userTools = new HomeSite(null);
sites = baseFullWebappControllerParts.getSiteInstances(ureq, getWindowControl());
if (sites != null && sites.size() == 0) {
sites = null;
}
List<String> siteLinks = new ArrayList<>();
// either sites is null or contains at least one SiteInstance.
if (sites != null) {
// create the links for the sites
for (Iterator<SiteInstance> iterator = sites.iterator(); iterator.hasNext(); ) {
SiteInstance si = iterator.next();
NavElement navEl = si.getNavElement();
if (navEl != null) {
String linkName = "t" + CodeHelper.getRAMUniqueID();
siteLinks.add(linkName);
Link link = LinkFactory.createCustomLink(linkName, "t", "", Link.NONTRANSLATED, navSitesVc, this);
link.setCustomDisplayText(navEl.getTitle());
link.setTitle(navEl.getDescription());
link.setUserObject(si);
Character accessKey = navEl.getAccessKey();
if (accessKey != null && StringHelper.containsNonWhitespace(accessKey.toString())) {
link.setAccessKey(accessKey.toString());
}
}
}
}
navSitesVc.contextPut("sites", siteLinks);
navSitesVc.contextPut("tabhelper", this);
navTabsVc.contextPut("dtabs", dtabs);
navTabsVc.contextPut("dtabsLinkNames", dtabsLinkNames);
navTabsVc.contextPut("tabhelper", this);
// header, optional (e.g. for logo, advertising )
Controller headerCtr = baseFullWebappControllerParts.createHeaderController(ureq, getWindowControl());
if (headerCtr != null) {
// cleanup on dispose
listenTo(headerCtr);
Component headerCmp = headerCtr.getInitialComponent();
mainVc.put("headerComponent", headerCmp);
}
// topnav, optional (e.g. for imprint, logout)
topnavCtr = baseFullWebappControllerParts.createTopNavController(ureq, getWindowControl());
if (topnavCtr != null) {
// cleanup on dispose
listenTo(topnavCtr);
mainVc.put("topnavComponent", topnavCtr.getInitialComponent());
userToolsMenuCtrl = new UserToolsMenuController(ureq, getWindowControl());
listenTo(userToolsMenuCtrl);
mainVc.put("menuComponent", userToolsMenuCtrl.getInitialComponent());
}
// panel for modal overlays, placed right after the olat-header-div
modalPanel = new Panel("ccmodalpanel");
mainVc.put("modalpanel", modalPanel);
// main, mandatory (e.g. a LayoutMain3ColsController)
main = new Panel("mainContent");
mainVc.put("main", main);
// footer, optional (e.g. for copyright, powered by)
footerCtr = baseFullWebappControllerParts.createFooterController(ureq, getWindowControl());
if (footerCtr != null) {
// cleanup on dispose
listenTo(footerCtr);
Component footerCmp = footerCtr.getInitialComponent();
mainVc.put("footerComponent", footerCmp);
}
contentCtrl = baseFullWebappControllerParts.getContentController(ureq, getWindowControl());
if (contentCtrl != null) {
listenTo(contentCtrl);
GuiStack gs = getWindowControl().getWindowBackOffice().createGuiStack(contentCtrl.getInitialComponent());
setGuiStack(gs);
main.setContent(contentCtrl.getInitialComponent());
} else {
main.setContent(TextFactory.createTextComponentFromString("empty", "", null, false, null));
// set a guistack for the after login interceptor
GuiStack gs = getWindowControl().getWindowBackOffice().createGuiStack(new Panel("dummy"));
setGuiStack(gs);
}
setWindowSettings(getWindowControl().getWindowBackOffice().getWindowSettings());
}
Aggregations