use of org.olat.core.gui.control.generic.dtabs.DTab in project openolat by klemens.
the class NewControllerFactory method launch.
/**
* Launch a controller in a tab or site in the given window from a user
* request url
*
* @param ureq
* @param wControl
*/
public boolean launch(UserRequest ureq, WindowControl wControl) {
BusinessControl bc = wControl.getBusinessControl();
ContextEntry mainCe = bc.popLauncherContextEntry();
if (mainCe == null) {
// nothing to launch
return false;
}
OLATResourceable ores = mainCe.getOLATResourceable();
// Check for RepositoryEntry resource
RepositoryEntry re = null;
if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(RepositoryEntry.class))) {
if (ores instanceof RepositoryEntry) {
re = (RepositoryEntry) ores;
ores = re.getOlatResource();
} else {
// It is a repository-entry => get OLATResourceable from RepositoryEntry
RepositoryManager repom = RepositoryManager.getInstance();
re = repom.lookupRepositoryEntry(ores.getResourceableId());
if (re != null) {
ores = re.getOlatResource();
mainCe.upgradeOLATResourceable(re);
}
}
}
// was brasato:: DTabs dts = wControl.getDTabs();
UserSession usess = ureq.getUserSession();
Window window = Windows.getWindows(usess).getWindow(ureq);
if (window == null) {
log.debug("Found no window for jumpin => take WindowBackOffice", null);
window = wControl.getWindowBackOffice().getWindow();
}
DTabs dts = window.getDTabs();
String firstType = mainCe.getOLATResourceable().getResourceableTypeName();
// String firstTypeId = ClassToId.getInstance().lookup() BusinessGroup
ContextEntryControllerCreator typeHandler = getContextEntryControllerCreator(firstType);
if (typeHandler == null) {
log.warn("Cannot found an handler for context entry: " + mainCe, null);
// simply return and don't throw a red screen
return false;
}
if (!typeHandler.validateContextEntryAndShowError(mainCe, ureq, wControl)) {
// simply return and don't throw a red screen
return false;
}
List<ContextEntry> entries = new ArrayList<ContextEntry>(5);
while (bc.hasContextEntry()) {
entries.add(bc.popLauncherContextEntry());
}
List<ContextEntry> ces = new ArrayList<ContextEntry>(entries.size() + 1);
ces.add(mainCe);
if (entries.size() > 0) {
ces.addAll(entries);
}
TabContext context = typeHandler.getTabContext(ureq, ores, mainCe, entries);
String siteClassName = typeHandler.getSiteClassName(ces, ureq);
// open in existing site
boolean launched = false;
boolean assessmentMode = usess.isInAssessmentModeProcess();
if (siteClassName != null) {
if (!assessmentMode) {
dts.activateStatic(ureq, siteClassName, context.getContext());
launched = true;
}
} else if (!assessmentMode || usess.matchLockResource(ores)) {
// get current tab or create new tab
DTab dt = dts.getDTab(ores);
if (dt == null) {
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dts.getWindowControl());
usess.addToHistory(ureq, bc);
Controller launchC = typeHandler.createController(ces, ureq, bwControl);
if (launchC != null) {
dt = dts.createDTab(context.getTabResource(), re, launchC, context.getName());
if (dt == null) {
launched = false;
} else if (dts.addDTab(ureq, dt)) {
dts.activate(ureq, dt, context.getContext());
launched = true;
}
}
} else {
dts.activate(ureq, dt, context.getContext());
launched = true;
}
}
return launched;
}
use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.
the class DisposedCourseRestartController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == restartLink) {
OLATResourceable ores = OLATResourceManager.getInstance().findResourceable(courseRepositoryEntry.getOlatResource().getResourceableId(), courseRepositoryEntry.getOlatResource().getResourceableTypeName());
if (ores == null) {
// course was deleted!
MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.deleted.title"), translate("course.deleted.text"));
panel.setContent(msgController.getInitialComponent());
} else {
OLATResourceable reOres = OresHelper.clone(courseRepositoryEntry);
DTabs dtabs = getWindowControl().getWindowBackOffice().getWindow().getDTabs();
if (dtabs != null) {
DTab dt = dtabs.getDTab(reOres);
if (dt != null) {
dtabs.removeDTab(ureq, dt);
}
}
List<ContextEntry> entries = null;
List<HistoryPoint> stacks = ureq.getUserSession().getHistoryStack();
for (int i = stacks.size(); i-- > 0; ) {
HistoryPoint point = stacks.get(i);
if (point != null && point.getEntries() != null && point.getEntries().size() > 0) {
ContextEntry entry = point.getEntries().get(0);
if (reOres.equals(entry.getOLATResourceable())) {
entries = point.getEntries();
break;
}
}
}
WindowControl bwControl;
if (entries == null) {
bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(getWindowControl(), reOres);
} else {
BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(entries);
bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
}
NewControllerFactory.getInstance().launch(ureq, bwControl);
dispose();
}
}
}
use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method doDispose.
@Override
protected void doDispose() {
// deregister for chief global sticky messages events
GlobalStickyMessage.deregisterForGlobalStickyMessage(this);
if (dtabs != null) {
for (DTab tab : dtabs) {
tab.dispose();
}
for (BornSiteInstance bornSite : siteToBornSite.values()) {
bornSite.dispose();
}
dtabs = null;
dtabsControllers = null;
sites = null;
siteToBornSite = null;
siteToBusinessPath = null;
dtabToBusinessPath = null;
}
// clear the DTabs Service
WindowBackOffice wbackOffice = getWindowControl().getWindowBackOffice();
wbackOffice.getWindow().setDTabs(null);
wbackOffice.removeCycleListener(this);
if (jsServerC != null) {
jsServerC.dispose();
jsServerC = null;
}
if (debugC != null) {
debugC.dispose();
debugC = null;
}
if (inlineTranslationC != null) {
inlineTranslationC.dispose();
inlineTranslationC = null;
}
if (developmentC != null) {
developmentC.dispose();
developmentC = null;
}
// deregister for assessment mode
CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(this, AssessmentModeNotificationEvent.ASSESSMENT_MODE_NOTIFICATION);
}
use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method addDTab.
@Override
public boolean addDTab(UserRequest ureq, DTab dt) {
if (isDisposed()) {
return false;
}
DTab old = getDTab(dt.getOLATResourceable());
if (old != null) {
return true;
}
// add to tabs list
synchronized (dtabs) {
// make dtabs and dtabsControllers access synchronized
dtabs.add(dt);
dtabsLinkNames.add(dtabCreateCounter);
Link link = LinkFactory.createCustomLink("a" + dtabCreateCounter, "a" + dtabCreateCounter, "", Link.NONTRANSLATED, navTabsVc, this);
link.setCustomDisplayText(StringHelper.escapeHtml(dt.getNavElement().getTitle()));
link.setIconLeftCSS("o_icon o_icon-fw " + dt.getNavElement().getIconCSSClass());
link.setTitle(dt.getTitle());
link.setUserObject(dt);
// Set accessibility access key using the 's' key. You can loop through all opened tabs by
// pressing s repetitively (works only in IE/FF which is normally used by blind people)
link.setAccessKey("s");
// add close links
Link calink = LinkFactory.createCustomLink("c" + dtabCreateCounter, "c" + dtabCreateCounter, "", Link.NONTRANSLATED, navTabsVc, this);
calink.setCustomEnabledLinkCSS("o_navbar_tab_close");
calink.setIconLeftCSS("o_icon o_icon_close_tab");
calink.setTitle(translate("close"));
calink.setUserObject(dt);
Controller dtabCtr = dt.getController();
dtabCtr.addControllerListener(this);
updateBusinessPath(ureq, dt);
// add to tabs controller lookup table for later event dispatching
dtabsControllers.add(dtabCtr);
// increase DTab added counter.
dtabCreateCounter++;
}
return true;
}
use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method lockGUI.
private void lockGUI() {
if (topnavCtr != null) {
topnavCtr.lock();
}
if (footerCtr != null) {
footerCtr.lock();
}
if (userToolsMenuCtrl != null) {
userToolsMenuCtrl.lock();
}
if (dtabsControllers != null) {
for (int i = dtabsControllers.size(); i-- > 0; ) {
DTab tab = dtabs.get(i);
if (lockResource == null || !lockResource.getResourceableId().equals(tab.getOLATResourceable().getResourceableId())) {
removeDTab(null, tab);
} else if (lockResource != null && lockResource.getResourceableId().equals(tab.getOLATResourceable().getResourceableId()) && lockStatus != LockStatus.locked) {
removeDTab(null, tab);
}
}
}
navSitesVc.contextPut("visible", Boolean.FALSE);
navSitesVc.setDirty(true);
navTabsVc.setDirty(true);
main.setContent(new Panel("empty-mode"));
}
Aggregations