if (window == null) {
logDebug("Found no window for jumpin => take WindowBackOffice", null);
window = wControl.getWindowBackOffice().getWindow();
}
DTabs dts = (DTabs) window.getAttribute("DTabs");
DTab dt = dts.getDTab(ores);
if (dt != null) {
// tab already open => close it
dts.removeDTab(dt);// disposes also dt and controllers
}
String firstType = mainCe.getOLATResourceable().getResourceableTypeName();
// String firstTypeId = ClassToId.getInstance().lookup() BusinessGroup
ContextEntryControllerCreator typeHandler = contextEntryControllerCreators.get(firstType);
if (typeHandler == null) throw new AssertException("Unable to get a handler for the type: " + firstType);
String siteClassName = typeHandler.getSiteClassName(mainCe);
// open in existing site
if (siteClassName != null) {
// use special activation key to trigger the activate method
String viewIdentifyer = null;
if (bc.hasContextEntry()) {
ContextEntry subContext = bc.popLauncherContextEntry();
if (subContext != null) {
OLATResourceable subResource = subContext.getOLATResourceable();
if (subResource != null) {
viewIdentifyer = subResource.getResourceableTypeName();
if (subResource.getResourceableId() != null) {
// add resource instance id if available. The ':' is a common
// separator in the activatable interface
viewIdentifyer = viewIdentifyer + ":" + subResource.getResourceableId();
}
}
}
} else if (!ceConsumed) {
//the olatresourceable is not in a dynamic tab but in a fix one
if(ores != null) {
viewIdentifyer = ores.getResourceableTypeName();
if (ores.getResourceableId() != null) {
// add resource instance id if available. The ':' is a common
// separator in the activatable interface
viewIdentifyer = viewIdentifyer + ":" + ores.getResourceableId();
}
}
}
dts.activateStatic(ureq, siteClassName, viewIdentifyer);
} else {
// or create new tab
String tabName = typeHandler.getTabName(mainCe);
// create and add Tab
dt = dts.createDTab(ores, tabName);
if (dt == null) {
// tabs are full: TODO
// user error message is generated in BaseFullWebappController, nothing
// to do here
} else {
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dt.getWindowControl());
Controller launchC = typeHandler.createController(mainCe, ureq, bwControl);
dt.setController(launchC);
dts.addDTab(dt);
}
dts.activate(ureq, dt, null); // null: do not activate to a certain view
}
}