use of org.olat.core.gui.components.panel.Panel in project openolat by klemens.
the class EPMultipleArtefactSmallReadOnlyPreviewController method init.
private void init(UserRequest ureq) {
if (artefactCtrls != null)
disposeArtefactControllers();
if (optionLinkCtrls != null)
disposeOptionLinkControllers();
optionLinkCtrls = new ArrayList<Controller>();
artefactCtrls = new ArrayList<Controller>();
List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
int i = 1;
for (AbstractArtefact artefact : artefacts) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Controller artCtrl;
// check for special art-display:
boolean special = artHandler.isProvidingSpecialMapViewController();
if (special) {
artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
if (artCtrl != null) {
// add the optionsLink to the artefact
EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
listenTo(optionsLinkCtrl);
optionLinkCtrls.add(optionsLinkCtrl);
}
} else {
artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
}
if (artCtrl != null) {
artefactCtrls.add(artCtrl);
Component artefactCtrlComponent = artCtrl.getInitialComponent();
listenTo(artCtrl);
Panel namedPanel = new Panel("artCtrl" + i);
namedPanel.setContent(artefactCtrlComponent);
if (special) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
artefactCtrlCompLine = new ArrayList<Panel>();
} else {
if (artefactCtrlCompLine.size() == 3) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLine = new ArrayList<Panel>();
}
artefactCtrlCompLine.add(namedPanel);
}
vC.put("artCtrl" + i, namedPanel);
if (special) {
// need a flag in a lopp for the velociy template
vC.put("specialartCtrl" + i, artefactCtrlComponent);
}
i++;
}
}
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
use of org.olat.core.gui.components.panel.Panel in project openolat by klemens.
the class ValidatingVisitor method handleDirties.
/**
* to be called by Window.java or the AjaxController only!
* this method is synchronized on the Window instance
*
* @return a updateUI-Command or null if there are no dirty components (normally not the case for sync (user-click) request, but often the case
* for pull request, since nothing has changed yet on the screen.
*/
public Command handleDirties() throws CannotReplaceDOMFragmentException {
// more accurately, the synchronized is needed when other classes than window call this method.
synchronized (this) {
Command com = null;
boolean isDebugLog = log.isDebug();
StringBuilder debugMsg = null;
long start = 0;
if (isDebugLog) {
log.debug("Perf-Test: Window.handleDirties started...");
start = System.currentTimeMillis();
}
final List<Component> dirties = new ArrayList<Component>();
ComponentVisitor dirtyV = new ComponentVisitor() {
public boolean visit(Component comp, UserRequest ureq) {
boolean visitChildren = false;
if (comp == null) {
log.warn("Ooops, a component is null");
} else if (!comp.isVisible()) {
// a component just made -visible- still needs to be collected (detected by checking dirty flag)
if (comp.isDirty()) {
dirties.add(comp);
// clear manually here since this component will not be rendered
comp.setDirty(false);
}
} else if (comp.isDirty()) {
dirties.add(comp);
} else {
// visible and not dirty -> visit children
visitChildren = true;
}
return visitChildren;
}
};
ComponentTraverser ct = new ComponentTraverser(dirtyV, getContentPane(), false);
ct.visitAll(null);
int dCnt = dirties.size();
if (isDebugLog) {
long durationVisitAll = System.currentTimeMillis() - start;
log.debug("Perf-Test: Window.handleDirties after ct.visitAll durationVisitAll=" + durationVisitAll);
log.debug("Perf-Test: Window.handleDirties dirties.size()=" + dirties.size());
}
if (dCnt > 0) {
// collect the redraw dirties command
try {
JSONObject root = new JSONObject();
root.put("cc", dirties.size());
root.put("wts", timestamp);
JSONArray ja = new JSONArray();
root.put("cps", ja);
GlobalSettings gsettings = wbackofficeImpl.getGlobalSettings();
synchronized (render_mutex) {
// o_clusterOK by:fj
// we let all dirty components render themselves.
// not offered (since not usability-useful) is the include of new js-libraries and css-libraries here, since this may invoke a screen reload
// which disturbes the user and lets him/her loose the focus and the cursor.
AsyncMediaResponsible amr = null;
long rstart = 0;
if (isDebugLog) {
rstart = System.currentTimeMillis();
debugMsg = new StringBuilder("update:").append(String.valueOf(dCnt)).append(";");
}
for (int i = 0; i < dCnt; i++) {
Component toRender = dirties.get(i);
if (isDebugLog) {
log.debug("Perf-Test: Window.handleDirties toRender.getComponentName()=" + toRender.getComponentName());
log.debug("Perf-Test: Window.handleDirties toRender=" + toRender);
}
boolean wasDomR = toRender.isDomReplaceable();
if (!wasDomR) {
throw new CannotReplaceDOMFragmentException("cannot replace as dom fragment:" + toRender.getComponentName() + " (" + toRender.getClass().getName() + ")," + toRender.getExtendedDebugInfo());
}
Panel wrapper = new Panel("renderpanel");
// to omit <div> around the render helper panel
wrapper.setDomReplaceable(false);
RenderResult renderResult = null;
StringOutput jsol = null;
StringOutput hdr = null;
StringOutput result = null;
try {
toRender.setDomReplaceable(false);
wrapper.setContent(toRender);
String newTimestamp = String.valueOf(timestamp);
URLBuilder ubu = new URLBuilder(uriPrefix, getInstanceId(), newTimestamp);
renderResult = new RenderResult();
// if we have an around-component-interception
// set the handler for this render cycle
InterceptHandler interceptHandler = wbackofficeImpl.getInterceptHandler();
if (interceptHandler != null) {
InterceptHandlerInstance dhri = interceptHandler.createInterceptHandlerInstance();
renderResult.setInterceptHandlerRenderInstance(dhri);
}
Renderer fr = Renderer.getInstance(wrapper, null, ubu, renderResult, gsettings);
jsol = StringOutputPool.allocStringBuilder(2048);
fr.renderBodyOnLoadJSFunctionCall(jsol, toRender);
hdr = StringOutputPool.allocStringBuilder(2048);
fr.renderHeaderIncludes(hdr, toRender);
long pstart = 0;
if (isDebugLog) {
pstart = System.currentTimeMillis();
}
result = StringOutputPool.allocStringBuilder(100000);
fr.render(toRender, result, null);
if (isDebugLog) {
long pstop = System.currentTimeMillis();
debugMsg.append(toRender.getComponentName()).append(":").append((pstop - pstart));
if (i < dCnt - 1)
debugMsg.append(",");
}
} catch (Exception e) {
throw new OLATRuntimeException("Unexpected error ", e);
} finally {
toRender.setDomReplaceable(true);
}
if (renderResult.getRenderException() != null) {
throw new OLATRuntimeException(Window.class, renderResult.getLogMsg(), renderResult.getRenderException());
}
AsyncMediaResponsible curAmr = renderResult.getAsyncMediaResponsible();
if (curAmr != null) {
if (amr != null) {
throw new AssertException("can set amr only once in a screen!");
} else {
amr = curAmr;
}
}
JSONObject jo = new JSONObject();
String cid = toRender.getDispatchID();
if (Settings.isDebuging()) {
// for debugging only
jo.put("cname", toRender.getComponentName());
jo.put("clisteners", toRender.getListenerInfo());
jo.put("hfragsize", result.length());
}
jo.put("cid", cid);
jo.put("cw", toRender.isDomReplacementWrapperRequired());
jo.put("cidvis", toRender.isVisible());
jo.put("hfrag", StringOutputPool.freePop(result));
jo.put("jsol", StringOutputPool.freePop(jsol));
jo.put("hdr", StringOutputPool.freePop(hdr));
ja.put(jo);
}
// to null otherwise it possible that e.g. pdf served as following click within a CP component
if (amr != null) {
setAsyncMediaResponsible(amr);
}
if (isDebugLog) {
long rstop = System.currentTimeMillis();
debugMsg.append(";inl_part_render:").append((rstop - rstart));
log.debug(debugMsg.toString());
}
}
com = CommandFactory.createDirtyComponentsCommand();
com.setSubJSON(root);
if (isDebugLog) {
long durationHandleDirties = System.currentTimeMillis() - start;
log.debug("Perf-Test:" + durationHandleDirties);
}
return com;
} catch (JSONException e) {
throw new AssertException("wrong data put into json object", e);
}
}
if (isDebugLog) {
long durationHandleDirties = System.currentTimeMillis() - start;
log.debug("Perf-Test: Window.handleDirties finished 2 durationHandleDirties=" + durationHandleDirties);
}
return com;
}
}
use of org.olat.core.gui.components.panel.Panel in project openolat by klemens.
the class GuiStackNiceImpl method pushModalDialog.
/**
* @param title the title of the modal dialog, can be null
* @param content the component to push as modal dialog
*/
@Override
public void pushModalDialog(Component content) {
wbo.sendCommandTo(new ScrollTopCommand());
// wrap the component into a modal foreground dialog with alpha-blended-background
final Panel guiMsgPlace = new Panel("guimsgplace_for_modaldialog");
VelocityContainer inset = new VelocityContainer("inset", VELOCITY_ROOT + "/modalDialog.html", null, null) {
@Override
public void validate(UserRequest ureq, ValidationResult vr) {
super.validate(ureq, vr);
// just before rendering, we need to tell the windowbackoffice that we are a favorite for accepting gui-messages.
// the windowbackoffice doesn't know about guimessages, it is only a container that keeps them for one render cycle
List<ZIndexWrapper> zindexed = wbo.getGuiMessages();
zindexed.add(new ZIndexWrapper(guiMsgPlace, 10));
}
};
inset.put("cont", content);
inset.put("guimsgplace", guiMsgPlace);
int zindex = 900 + (modalLayers * 100) + 5;
inset.contextPut("zindexoverlay", zindex + 1);
inset.contextPut("zindexshim", zindex);
inset.contextPut("zindexarea", zindex + 5);
inset.contextPut("zindexextwindows", zindex + 50);
modalPanel.pushContent(inset);
// the links in the panel cannot be clicked because of the alpha-blended background over it, but if user chooses own css style ->
// FIXME:fj:b panel.setEnabled(false) causes effects if there is an image component in the panel -> the component is not dispatched
// and thus renders inline and wastes the timestamp.
// Needed:solution (a) a flag (a bit of the mode indicator of the urlbuilder can be used) to indicate that a request always needs to be delivered even
// if the component or a parent is not enabled.
// alternative solution(b): wrap the imagecomponent into a controller and use a mapper
// alternative solution(c): introduce a flag to the component to say "dispatch always", even if a parent component is not enabled
//
// - solution a would be easy, but would allow for forced dispatching by manipulating the url's flag.
// for e.g. a Link button ("make me admin") that is disabled this is a security breach.
// - solution b needs some wrapping, the advantage (for images) would be that they are cached by the browser if requested more than once
// within a controller
// - solution c is a safe and easy way to allow dispatching (only in case a mediaresource is returned as a result of the dispatching) even
// if parent elements are not enabled
// proposal: fix for 5.1.0 with solution c; for 5.0.1 the uncommenting of the line below is okay.
// if (modalLayers == 0) panel.setEnabled(false);
modalLayers++;
}
use of org.olat.core.gui.components.panel.Panel in project openolat by klemens.
the class GTACoachController method setGrading.
private void setGrading(UserRequest ureq, Task assignedTask) {
mainVC.put("grading", new Panel("empty"));
if (assessedGroup != null) {
groupGradingCtrl = new GTACoachedGroupGradingController(ureq, getWindowControl(), coachCourseEnv, courseEnv, gtaNode, assessedGroup, taskList, assignedTask);
listenTo(groupGradingCtrl);
mainVC.put("grading", groupGradingCtrl.getInitialComponent());
} else if (assessedIdentity != null) {
OLATResource courseOres = courseEntry.getOlatResource();
participantGradingCtrl = new GTACoachedParticipantGradingController(ureq, getWindowControl(), courseOres, gtaNode, assignedTask, coachCourseEnv, assessedIdentity);
listenTo(participantGradingCtrl);
mainVC.put("grading", participantGradingCtrl.getInitialComponent());
}
}
use of org.olat.core.gui.components.panel.Panel in project openolat by klemens.
the class QTI12StatisticsToolController method doSelectNode.
private void doSelectNode(UserRequest ureq, TreeNode selectedNode) {
removeAsListenerAndDispose(currentCtrl);
WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(selectedNode.getIdent(), 0l), null);
currentCtrl = result.getController(ureq, swControl, stackPanel, selectedNode);
if (currentCtrl != null) {
listenTo(currentCtrl);
layoutCtr.setCol3(currentCtrl.getInitialComponent());
} else {
layoutCtr.setCol3(new Panel("empty"));
}
}
Aggregations