use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class BookmarksPortletRunController 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)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == showAllLink) {
// activate homes tab in top navigation and active bookmarks menu item
String resourceUrl = "[MyCoursesSite:0][Favorits:0]";
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
NewControllerFactory.getInstance().launch(ureq, bwControl);
}
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
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.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class NewControllerFactory method launch.
/**
* Launch a controller in a tab or a site with the business path
* @param businessPath
* @param ureq
* @param origControl
*/
public boolean launch(String businessPath, UserRequest ureq, WindowControl origControl) {
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(businessPath);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, origControl);
return launch(ureq, bwControl);
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class ResumeController method formOK.
@Override
protected void formOK(UserRequest ureq) {
savePreferences(ureq, "auto");
fireEvent(ureq, Event.DONE_EVENT);
HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(cloneCes);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
try {
// make the resume secure. If something fail, don't generate a red screen
NewControllerFactory.getInstance().launch(ureq, bwControl);
} catch (Exception e) {
logError("Error while resumging", e);
}
}
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class ValidatingVisitor method appendDispatchDebugInfos.
private void appendDispatchDebugInfos(Component target, StringBuilder debugMsg) {
Controller c = target.getLatestDispatchedController();
if (c != null) {
WindowControl wCo = null;
try {
wCo = c.getWindowControlForDebug();
} catch (Exception e) {
// getWindowControl throw an Assertion if wControl = null
}
if (wCo != null) {
String coInfo = "";
WindowControlInfo wci = wCo.getWindowControlInfo();
while (wci != null) {
String cName = wci.getControllerClassName();
coInfo = cName + ":" + coInfo;
wci = wci.getParentWindowControlInfo();
}
BusinessControl bc = wCo.getBusinessControl();
String businessPath = bc == null ? "n/a" : bc.getAsString();
String compName = target.getComponentName();
String msg = "wci:" + coInfo + "%%" + compName + "%%" + businessPath + "%%";
// allowed for debugging, dispatching is already over
Event ev = target.getAndClearLatestFiredEvent();
if (ev != null) {
msg += ev.getClass().getName() + ":" + ev.getCommand() + "%%";
}
String targetInfo = target.getExtendedDebugInfo();
msg += targetInfo + "%%";
debugMsg.append(msg).append(LOG_SEPARATOR);
} else {
// no windowcontrol -> ignore
}
}
// else: a component with -no- controller as listener, makes no sense in 99.99% of the cases; ignore in those rare cases
}
Aggregations