Examples of WindowControl


Examples of org.olat.core.gui.control.WindowControl

  }
 
 

  public WindowControl createBusinessWindowControl(BusinessControl businessControl, WindowControl origWControl) {
    WindowControl wc = new StackedBusinessWindowControl(origWControl, businessControl);
    return wc;
  }
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

                    // check for dirty child components in the component tree
                    Command co = handleDirties();
                   
                    //DUMP FOR EACH CLICK THE CURRENT JumpInPath -> for later usage and debugging.
                    //System.err.println("V^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^V");
                    WindowControl current = (WindowControl)wbackofficeImpl.getWindow().getAttribute("BUSPATH");
                    //System.err.println(current != null ? JumpInManager.getRestJumpInUri(current.getBusinessControl()) : "NONE");
                    //System.err.println("T^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^T");
                    wbackofficeImpl.fireCycleEvent(AFTER_INLINE_RENDERING);
                    if (co != null) { // see method handleDirties for the rare case of co == null even if there are dirty components;
                      wbackofficeImpl.sendCommandTo(co);
                    }
                  }
                }
              } else { // not inline
                if(!validForDispatching){
                  // not valid: fire oldtimestamp event
                  fireEvent(ureq, OLDTIMESTAMPCALL);
                }
                // not inline, new mediaresource
                // send it to the parent window (e.g. an excel download, but could also be a 302 redirect)
                // if the browser has e.g. pdf configured to be displayed inline, we want it to fill the whole area (self window), not the hidden iframe.
                // the same for 302.
                // -> send a command which offers a new location for the main window.
                // create a mapper which maps this mediaresource, and serves it once only
                MediaResourceMapper extMRM = new MediaResourceMapper();
                extMRM.setMediaResource(mmr);
                //FIXME:fj:b deregister old mapper, or reuse current one
                String res = MapperRegistry.getInstanceFor(ureq.getUserSession()).register(extMRM)+"/";
                // e.g. res = /olat/m/10001/
                Command rmrcom = CommandFactory.createParentRedirectForExternalResource(res);
                wbackofficeImpl.sendCommandTo(rmrcom);
              }
            } else { // not dispatched
              Tracing.logDebug("Found a valid timestamp but could not dispatch to component: ureq.compid:"+ureq.getComponentID()+" ureq.win-ts:"+ureq.getTimestampID()+" ureq.comp-ts:"+ureq.getComponentTimestamp() + " target.timestamp:" + target.getTimestamp() + " target=" + target, this.getClass());
              String reRenderUri = buildURIFor(this, timestampID, null);
              Command rmrcom = CommandFactory.createParentRedirectTo(reRenderUri);
              wbackofficeImpl.sendCommandTo(rmrcom);
            }
            MediaResource jsonmr = wbackofficeImpl.extractCommands(true);
            ServletUtil.serveResource(request, response, jsonmr);
          } catch (Throwable th) {
            // in any case, try to inform the user appropriately.
            // a) error while dispatching (e.g. db problem, npe, ...)
            // b) for inline: error while validating or json-rendering dirty components.
           
            // since an error has occured for a request which is targeted in the background iframe, we need to redirect to the error window.
            // create the error window
            try {
              Tracing.logDebug("Error in Window, rollback", getClass());
              DBFactory.getInstance().rollback();
           
              ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, th);
              Window errWindow = msgcc.getWindow();
              // register window
              Windows.getWindows(ureq).registerWindow(errWindow);
              // redirect to the error window
              String newWinUri = buildRenderOnlyURIFor(errWindow);
              Command rmrcom = CommandFactory.createParentRedirectTo(newWinUri);
              wbackofficeImpl.sendCommandTo(rmrcom);
              MediaResource jsonmr = wbackofficeImpl.extractCommands(true);
              ServletUtil.serveResource(request, response, jsonmr);
            } catch (Throwable anotherTh) {
              Tracing.logError("Exception while handling exception!!!!", anotherTh, this.getClass());
            }
          }
          return;
        }
      }
     
      // -------------------------
      // ----- standard mode -----
      // -------------------------
      if (renderOnly || timestampID == null) {
        inline = true;
        validate = true;
      } else if (validatingCausedRerendering && timestampID.equals("-1")) {
        // the first request after the 302 redirect cause by a component validation
        // -> just rerender, but clear the flag for further async media requests
        validatingCausedRerendering = false;
        inline = true;
        validate = false; // no need to revalidate right now
        checkNewWindow = false;
        dispatch = false;
      else {
        // [POST: !renderOnly && timestampID != null]
        // if we had a inline rendering at least once (latestTimestamp is
        // set), then check for an old timestamp
        //System.out.println("dispatch normal: compid:"+ureq.getComponentID()+" win-ts:"+ureq.getTimestampID()+" comp-ts:"+ureq.getComponentTimestamp());
        if (latestTimestamp != null && !timestampID.equals(latestTimestamp)) {
          // this is not a link from the latest rendering, but from a previous
          // one, since it has a wrong timestamp parameter -> check for
          // asynchronous media
          if (asyncMediaResponsible == null) { // no async resp.
            // assume it to be a link from an old window (using browser back or
            // "open in new
            // window/tab" in the browser).
            if ((componentID != null && componentID.equals("-1")) || (ureq.getParameter("o_winrndo") != null)) {
              // just rerender
            else {
              // not a valid timestamp -> most likely a browser back or forward event (or a copy/paste of a url) ->

              // fire event to listening chiefcontroller
              fireEvent(ureq, OLDTIMESTAMPCALL);
              /*
               *
               * REVIEW:PB: this will be the code allowing back forward navigation
               * ---->
              // look at the timestamps more thoroughly.
              if (!timestampID.equals("-1")) {
                int diff = findInHistory(ureq);
                // diff == 0 -> reload (->ignore, so it will cause a simple rerendering)
                // diff < 0  -> browser-back
                // diff > 0  -> browser-forward
                //System.out.println("!!!!(normal) back: diff "+diff);
                wbackofficeImpl.browserBackOrForward(ureq, diff);
              } // else a 302 redirect of the main window -> simply rerender
              if (ureq.getComponentID() != null) {
                //System.out.println("normal: compid:"+ureq.getComponentID()+" win-ts:"+ureq.getTimestampID()+" comp-ts:"+ureq.getComponentTimestamp());
              } else {
                //System.out.println("special url - no component part (e.g. 302 redirect because of new req. js / css) compid:"+ureq.getComponentID()+" win-ts:"+ureq.getTimestampID()+" comp-ts:"+ureq.getComponentTimestamp());
              }
              validate = true;
              <------------- */
            }
            // just rerender current window
            inline = true;
            // do not increment timestamp so that e.g. url in a iframe remain valid
            incTimestamp = false;
          } else {
            // some component will take care of it for the moment, so be it
            mr = asyncMediaResponsible.getAsyncMediaResource(ureq);
            if (mr == null) { // indicates inline rendering
              inline = true;
              checkNewWindow = true; // an inline rendered async link should be
              // able to produce a new window
              validate = true;
            } else { // serve the resource.
              // all flags remain at their default value
            }
          }
        } else {
          // latestTimestamp == null || timestampID.equals(latestTimestamp)
         
          dispatch = true;
          checkNewWindow = true;
          validate = true;       
        }
      }
      // end of simple flagging.
      long dstart = 0;
      if (isDebugLog) {
        dstart = System.currentTimeMillis();
        long syncIntroDiff = dstart - debug_start;
        debugMsg.append("sync_bdisp:").append(syncIntroDiff).append(LOG_SEPARATOR);
      }
     
      if (dispatch) {
        boolean didDispatch = doDispatchToComponent(ureq, debugMsg);
        if (isDebugLog) {
          long dstop = System.currentTimeMillis();
          long diff = dstop - dstart;
          debugMsg.append("disp_comp:").append(diff).append(LOG_SEPARATOR);
          //Tracing.logDebug("componentdispatchtime: " + (dstop - dstart), Window.class);
        }
        if (didDispatch) { // the component with the given id was found
          mr = ureq.getDispatchResult().getResultingMediaResource();
          if (mr == null) {
            inline = true;
          } else {
            inline = false;
          }
        } else {
          // component with id was not found -> probably asynchronous thread changed flow ->
          // just rerender
          inline = true;
          dispatch = false;
          checkNewWindow = false;
          validate = true;
        }

      }

      if (checkNewWindow) {
        Window resWindow = ureq.getDispatchResult().getResultingWindow();
        if (resWindow != null) {
          // register it first, if not done before
          Windows ws = Windows.getWindows(ureq);
          if (!ws.isRegistered(resWindow)) {
            resWindow.setUriPrefix(uriPrefix);
            ws.registerWindow(resWindow);
          }
          // render initial state of new window by redirecting (302) to the new
          // window id. needed for asyncronous data like images loaded
         
          // todo maybe better delegate window registry to the windowbackoffice?
          URLBuilder ubu = new URLBuilder(uriPrefix, resWindow.getInstanceId(), String.valueOf(resWindow.timestamp), resWindow.wbackofficeImpl);
          StringOutput sout = new StringOutput(30);
          ubu.buildURI(sout, null, null);
          mr = new RedirectMediaResource(sout.toString());
          ServletUtil.serveResource(request, response, mr);
          if (isDebugLog) {
            long diff = System.currentTimeMillis() - debug_start;
            debugMsg.append("rdirnw:").append(diff).append(LOG_SEPARATOR);
            Tracing.logDebug(debugMsg.toString(), Window.class);
          }
          return;
        }
      }

      if (inline) {
          // do inline rendering.
         
          Container top = getContentPane();
          // validate prior to rendering, but only if the timestamp was not null
          // /
          // the component just got dispatched
          if (validate) { // do not validate if a previous validate lead to a
            // redirect; validating makes no sense here
            //long t1 = System.currentTimeMillis();
            ValidatingVisitor vv = new ValidatingVisitor(gsettings, jsAndCssAdder);
            ComponentTraverser ct = new ComponentTraverser(vv, top, false);
            ct.visitAll(ureq);
            wbackofficeImpl.fireCycleEvent(Window.AFTER_VALIDATING);
            ValidationResult vr = vv.getValidationResult();
            String newModUri = vr.getNewModuleURI();

            vr.getJsAndCSSAdder().finishAndCheckChange(); // ignore the return value since we are just about rendering anyway
         
            if (newModUri != null) {
              // send 302 redirect without dispatching, but just rerender
              // inline.
              // set window id to cur id, timestamp to current timestamp,
              // component id to -1 -> indicates rerender
              String uri = buildURIForRedirect(newModUri);
              MediaResource mrr = new RedirectMediaResource(uri);
              // set this only for the first request (the .html request), but clear it afterwards for asyncmedia
              validatingCausedRerendering = true;
              ServletUtil.serveResource(request, response, mrr);
              if (isDebugLog) {
                long diff = System.currentTimeMillis() - debug_start;
                debugMsg.append("rdirva:").append(diff).append(LOG_SEPARATOR);
                Tracing.logDebug(debugMsg.toString(), Window.class);
              }
              return;
            }
          }

         
          wbackofficeImpl.fireCycleEvent(BEFORE_INLINE_RENDERING);
          String result;
          synchronized(render_mutex) { //o_clusterOK by:fj
            // render now
            if (incTimestamp) timestamp++;
            String newTimestamp = String.valueOf(timestamp);
            // add the businesscontrol path for bookmarking:
            // each url has a part in it (the so called business path), which, in case of an invalid url or invalidated
            // session, can be used as a bookmark. that is, urls from our framework are bookmarkable, but require some little
            // coding effort: setting an appropriate business path and launching for each controller.
            // note: the businesspath may also be used as a easy (but of course not perfect) back-button-solution:
            // if the timestamp of a request is outdated, simply jump to its bookmarked business control path.
            URLBuilder ubu = new URLBuilder(uriPrefix, getInstanceId(), newTimestamp, wbackofficeImpl);
            RenderResult 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(top, top.getTranslator(), ubu, renderResult, gsettings);
            long rstart = 0;
            if (isDebugLog) {
              rstart = System.currentTimeMillis();
            }
            result = fr.render(top).toString();
            if (isDebugLog) {
              long rstop = System.currentTimeMillis();
              long diff = rstop - rstart;
              debugMsg.append("render:").append(diff).append(LOG_SEPARATOR);
            }
            if (renderResult.getRenderException() != null) throw new OLATRuntimeException(Window.class, renderResult.getLogMsg(),
                renderResult.getRenderException());
   
            // after rendering we know if some component awaits further async
            // calls
            // like images, so get a handler
            AsyncMediaResponsible amr = renderResult.getAsyncMediaResponsible();
            setAsyncMediaResponsible(amr); // if amr == null -> we are not
            // excepting
            // any async calls in the near future...
            latestTimestamp = newTimestamp;
          }
          if (isDebugLog) {
            long diff = System.currentTimeMillis() - debug_start;
            debugMsg.append("inl_comp:").append(diff).append(LOG_SEPARATOR);
          }
         
          //DUMP FOR EACH CLICK THE CURRENT JumpInPath -> for later usage and debugging.
          //System.err.println("VV^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^VV");
          WindowControl current = (WindowControl)wbackofficeImpl.getWindow().getAttribute("BUSPATH");
          //System.err.println(current != null ? JumpInManager.getRestJumpInUri(current.getBusinessControl()) : "NONE");
          //System.err.println("TT^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TT");
          wbackofficeImpl.fireCycleEvent(AFTER_INLINE_RENDERING);
          ServletUtil.serveStringResource(request, response, result);
          if (isDebugLog) {
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

     
      // if loglevel is set accordingly, collect anonymous controller usage statistics.
      if (debugMsg != null) {
        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();
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

                boolean newFactory = false;
                if(launchController == null) {
                  try  {
                    String resourceUrl = "[" + resName + ":0][notifications]";
                    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
                    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
                    NewControllerFactory.getInstance().launch(ureq, bwControl);
                    newFactory = true;
                  } catch (Exception ex) {
                    //fail silently
                  }
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

  }
 
   
  private static WindowControl updateBusinessPath(UserRequest ureq, WindowControl wControl) {
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ureq.getIdentity());
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
    return bwControl;
  }
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

      String businessPath = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_BUSINESSPATH);
      if (businessPath != null) {
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(businessPath);
        ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute("AUTHCHIEFCONTROLLER");

        WindowControl wControl = cc.getWindowControl();
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, wControl);
        NewControllerFactory.getInstance().launch(ureq, bwControl)
        // render the window
        Window w = cc.getWindow();
        w.dispatchRequest(ureq, true); // renderOnly
        return;
      }
     
      // 1. check for direct launch urls, see org.olat.core.dispatcher.jumpin.JumpinConfig
      if (!ureq.isValidDispatchURI()) {
        JumpInReceptionist jh = JumpInManager.getInstance().getJumpInReceptionist(ureq);
        if (jh == null) {
          // found no JumpInManager => try with new 5.1 JumpIn-Resource URL
          String uri = ureq.getNonParsedUri();
          if (uri.startsWith(JumpInManager.CONST_EXTLINK)) {
            String resourceUrl = ureq.getParameter(JumpInManager.CONST_RESOURCE_URL);
            if (resourceUrl != null) {
              // attach the launcher data
              BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
              try {
                // get main window and dynamic tabs
                // brasato:: ChiefController cc = Windows.getWindows(usess).getWindowManager().getMainChiefController();
                ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute(AUTHCHIEFCONTROLLER);

                // brasato:: todo: cc = Windows.getWindows(usess).getRegisteredJumpChiefController();
                WindowControl wControl = cc.getWindowControl();
                WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, wControl);
                NewControllerFactory.getInstance().launch(ureq, bwControl)
                // render the window
                Window w = cc.getWindow();
                w.dispatchRequest(ureq, true); // renderOnly
                return;
              } catch (Exception ex) {
                // sendNotFound         
              }
            }
          }
          DispatcherAction.sendNotFound(request.getRequestURI(), response);
          return;
        }
       
        // handler found e.g. for repo/go or cata/go or alike
        OLATResourceable ores = jh.getOLATResourceable();     
        String title = jh.getTitle();

        // get main window and dynamic tabs
        // brasato:: ChiefController cc = Windows.getWindows(usess).getMainOlatChiefController();
        ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute(AUTHCHIEFCONTROLLER);

        if (cc == null) throw new AssertException("logged in, but no window/Chiefcontroller 'olatmain' found!");
        WindowControl wControl = cc.getWindowControl();

        // add to tabs
        DTabs dts = (DTabs)wControl.getWindowBackOffice().getWindow().getAttribute(D_TABS);
        synchronized (dts) { //o_clusterok per:fj user session
          DTab dt = dts.getDTab(ores);
          if (dt == null) {
            // no dynamic tab found, lets see if the ores implements the SiteInstance interface.
            boolean isSiteInstance;
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

      contentP.pushContent(bookmarkController.getInitialComponent());
    } else if (cmd.equals(ACTION_CALENDAR)) { // popup calendar
      ControllerCreator ctrlCreator = new ControllerCreator() {
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
          ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(courseRepositoryEntry);
          WindowControl llwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, lwControl);
          CourseCalendarController calendarController = new CourseCalendarController(lureq, llwControl, course);         
          // use a one-column main layout
          LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, llwControl, null, null, calendarController.getInitialComponent(), null);
          layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), uce.getCourseEnvironment()));
          layoutCtr.addDisposableChildController(calendarController); // dispose calendar on layout dispose
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

       
        // calculate the new businesscontext for the coursenode being called.
        //FIXME:pb:mannheim discussion should not be "this.ores" -> may be the "forum" should go in here.
        //
        ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(forum);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, getWindowControl());
       
        discussionContent.put("articleforum", ForumUIFactory.getStandardForumController(ureq, bwControl, forum, forumCallback).getInitialComponent());
      }
    } else if (source == wikiEditForm) {
      /*************************************************************************
 
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

  private void adjustBusinessControlPath(UserRequest ureq, Message m) {
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(m));
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Message.class,m.getKey());
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
   
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, getWindowControl());   
   
    //Simple way to "register" the new ContextEntry although only a VelocityPage was flipped.
    Controller dummy = new BasicController(ureq, bwControl) {
   
      @Override
View Full Code Here

Examples of org.olat.core.gui.control.WindowControl

        String uri = url.substring(pathIndex + 5, url.length() - 1);
        RedirectMediaResource rsrc = new RedirectMediaResource(uri);
        ureq.getDispatchResult().setResultingMediaResource(rsrc);
      } else {
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(url);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
      }
    } catch (Exception ex) {
      log.debug("Document not found");
      getWindowControl().setWarning(getTranslator().translate("error.resource.could.not.found"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.