use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class FactoryControllerCreator method createController.
/**
* @see org.olat.core.gui.control.creator.ControllerCreator#createController(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl)
*/
public Controller createController(UserRequest lureq, WindowControl lwControl) {
Exception re = null;
try {
Object o = null;
Class<?> cclazz = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
try {
Constructor<?> con = cclazz.getConstructor(ARGCLASSES);
o = con.newInstance(new Object[] { lureq, lwControl });
} catch (NoSuchMethodException e) {
// constructor does not exist with arguments ARGCLASSES => try invoking
// method without instantiated class (o = null).
}
Method method = cclazz.getMethod(factoryMethod, ARGCLASSES);
Object result = method.invoke(o, new Object[] { lureq, lwControl });
Controller c = (Controller) result;
return c;
} catch (ClassNotFoundException e) {
re = e;
} catch (SecurityException e) {
re = e;
} catch (NoSuchMethodException e) {
re = e;
} catch (IllegalArgumentException e) {
re = e;
} catch (IllegalAccessException e) {
re = e;
} catch (InvocationTargetException e) {
re = e;
} catch (InstantiationException e) {
re = e;
} finally {
if (re != null) {
throw new AssertException("could not create controller via reflection. factoryName: " + factoryName + " method: " + factoryMethod, re);
}
}
return null;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class GenericMainController method getContentCtr.
private Controller getContentCtr(Object uobject, UserRequest ureq) {
Controller contentCtr1Tmp = null;
if (uobject instanceof ActionExtension) {
ActionExtension ae = (ActionExtension) uobject;
contentCtr1Tmp = createController(ae, ureq);
} else {
contentCtr1Tmp = handleOwnMenuTreeEvent(uobject, ureq);
}
if (contentCtr1Tmp == null) {
throw new AssertException("Node must either be an ActionExtension or implementation must handle this MenuTreeEvent: " + (uobject == null ? "NULL" : uobject.toString()));
}
return contentCtr1Tmp;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class TitledWrapperController method cloneController.
@Override
public Controller cloneController(UserRequest ureq, WindowControl wControl) {
if (contentController == null || contentController instanceof CloneableController) {
Controller wrappedAndCloned = ((CloneableController) contentController).cloneController(ureq, wControl);
TitledWrapperController clone = new TitledWrapperController(ureq, wControl, wrappedAndCloned, wrapperCss, titleInfo);
clone.setTitle((String) theVelocityContainer.getContext().get(TITLE_VAR));
clone.setSubTitle((String) theVelocityContainer.getContext().get(SUBTITLE_VAR));
clone.setContextTitle((String) theVelocityContainer.getContext().get(CONTEXT_TITLE_VAR));
clone.setIconCssClass((String) theVelocityContainer.getContext().get(ICON_CSS));
clone.setSeparatorEnabled((Boolean) theVelocityContainer.getContext().get(USE_SEPARATOR));
clone.setTitleSize((Integer) theVelocityContainer.getContext().get(TITLE_SIZE));
return clone;
}
return null;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class DevelopmentController method dumpTree.
private void dumpTree(StringOutput sb, Component current, int indent, Map<Controller, List<Component>> controllerInfos) {
// add infos,
Controller lController = org.olat.core.gui.dev.Util.getListeningControllerFor(current);
if (lController != null) {
List<Component> lcomps = controllerInfos.get(lController);
if (lcomps == null) {
// first entry
lcomps = new ArrayList<Component>();
controllerInfos.put(lController, lcomps);
}
lcomps.add(current);
}
int pxInd = indent * 25;
String pcid = Renderer.getComponentPrefix(current);
sb.append("<div id='dmt_").append(pcid).append("' ");
if (current.isVisible() && current.isDomReplaceable()) {
sb.append(" onMouseOver=\"jQuery(this).css('background-color','#f3feff');o_dbg_mark('").append(pcid).append("')\" onMouseOut=\"jQuery(this).css('background-color','');o_dbg_unmark('").append(pcid).append("')\"");
}
sb.append(" style=\"color:blue; padding-bottom:2px; font-size:10px\"><div style=\"margin-left:" + pxInd + "px\">");
String cname = current.getClass().getName();
cname = cname.substring(cname.lastIndexOf('.') + 1);
sb.append("<b>" + cname + "</b> (" + current.getComponentName() + " id " + current.getDispatchID() + ") ");
if (current == mainComp) {
// suppress detail and subtree for our controller here
sb.append(" --suppressing output, since developmentcontroller --</div></div>");
} else {
sb.append((current.isVisible() ? "" : "INVISIBLE ") + (current.isEnabled() ? "" : " NOT ENABLED ") + current.getExtendedDebugInfo() + ", " + current.getListenerInfo() + "<br />");
sb.append("</div></div>");
if (current instanceof Container) {
Container co = (Container) current;
for (Component child : co.getComponents()) {
dumpTree(sb, child, indent + 1, controllerInfos);
}
}
}
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class DevelopmentController method renderDebugInfo.
/**
* used by velocityrenderdecorator
* @param target
*/
private void renderDebugInfo(Component root, StringOutput target) {
target.append("<div>");
int cnt = cntTree(root);
int size = DefaultController.getControllerCount();
target.append("<strong>Component Tree:</strong> count: " + cnt + " | Controllers (global: active and not disposed): <strong>" + size + "</strong>");
target.append("</div><div>");
Map<Controller, List<Component>> controllerInfos = new HashMap<Controller, List<Component>>();
dumpTree(target, root, 0, controllerInfos);
target.append("</div>");
// now dump the controller info
for (Controller controller : controllerInfos.keySet()) {
try {
Component initComp = controller.getInitialComponent();
target.append("<div style=\"padding-bottom:2px; \"><strong>Controller " + controller.getClass().getName() + " :" + controller.hashCode());
appendDivCodeForComponent("<i>Initial Component:</i> ", target, initComp, 20);
List<Component> listenTo = controllerInfos.get(controller);
for (Component component : listenTo) {
appendDivCodeForComponent("", target, component, 20);
}
target.append("</strong></div><br />");
} catch (Exception e) {
// some components like window dont like being called for the initialcomponent
// -> ignore
}
}
}
Aggregations