Package org.olat.core.gui.control

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


    guimsgVc.contextPut("guiMessage", guiMessage);
    guimsgPanel = new OncePanel("guimsgPanel");

    mainVc.put("guimessage", guimsgPanel)
   
    final WindowControl origWCo = wControl; //no need to use: super.getWindowControl();
   
    myWControl = new WindowControl() {
      private WindowControlInfo wci;

      {
        wci = new WindowControlInfoImpl(SimpleBaseController.this, origWCo.getWindowControlInfo());
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#pushToMainArea(org.olat.core.gui.components.Component)
       */
      public void pushToMainArea(Component newMainArea) {
        currentGuiStack.pushContent(newMainArea);
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#pushAsModalDialog(java.lang.String,
       *      org.olat.core.gui.components.Component)
       */
      public void pushAsModalDialog(Component newModalDialog) {
        currentGuiStack.pushModalDialog(newModalDialog);
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#pop()
       */
      public void pop() {
        // reactivate latest dialog from stack, dumping current one
        currentGuiStack.popContent();
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#setInfo(java.lang.String)
       */
      public void setInfo(String info) {
        guiMessage.setInfo(info);
        guimsgPanel.setContent(guimsgVc);
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#setError(java.lang.String)
       */
      public void setError(String error) {
        guiMessage.setError(error);
        guimsgPanel.setContent(guimsgVc);
      }

      /**
       * @see org.olat.core.gui.control.WindowControl#setWarning(java.lang.String)
       */
      public void setWarning(String warning) {
        guiMessage.setWarn(warning);
        guimsgPanel.setContent(guimsgVc);
      }

      public WindowControlInfo getWindowControlInfo() {
        return wci;
      }

      public void makeFlat() {
        throw new AssertException("should never be called!");
      }

      public BusinessControl getBusinessControl() {
        return origWCo.getBusinessControl();
      }

      public WindowBackOffice getWindowBackOffice() {
        return origWCo.getWindowBackOffice();
      }

    };
    overrideWindowControl(myWControl);

View Full Code Here


    mainvc.put("olatContentPanel", contentPanel);
    mainvc.contextPut("o_winid", Long.valueOf(w.getDispatchID()));
    Version v = (Version) CoreSpringFactory.getBean("org.olat.core.Version");
    mainvc.contextPut("buildversion", v.getVersion());
   
    WindowControl wControl = new WindowControl() {
      private WindowControlInfo wci;

      {
        wci = new WindowControlInfoImpl(BaseChiefController.this, null);
      }
View Full Code Here

  public ChiefController createChiefController(UserRequest ureq) {
   
    BaseChiefController bcc = new BaseChiefController(ureq);
    SimpleBaseController sbasec = new SimpleBaseController(ureq, bcc.getWindowControl());
   
    WindowControl bwControl = sbasec.getWindowControl();
   
    // check if there is a bookmark part in the url
    String bookmark = ureq.getParameter("o_bkm"); // e.g. [demo*5]
    if (bookmark != null) {
      // attach the launcher data
View Full Code Here

   * be extracted
   * @return a new UserActivityLoggerImpl purpose built for use by the EventBus during fireEvent
   */
  public static UserActivityLoggerImpl newLoggerForEventBus(Controller controller) {
    IUserActivityLogger logger = controller.getUserActivityLogger();
    WindowControl wControl = controller.getWindowControlForDebug();
    UserActivityLoggerImpl newLogger = new UserActivityLoggerImpl(logger, wControl, false);
    newLogger.frameworkSetBusinessPathFromWindowControl(controller.getWindowControlForDebug());
    return newLogger;
    // don't set runtimeParent !
  }
View Full Code Here

      bc = new StackedBusinessControl(contextEntry, origBC);
    } else {
      // pass through
      bc = origBC;
    }
    WindowControl wc = new StackedBusinessWindowControl(windowWControl, bc);
    return wc;
  }
View Full Code Here

   * @return
   */
  public WindowControl createBusinessWindowControl(final ContextEntry contextEntry, WindowControl origWControl) {
    BusinessControl origBC = origWControl.getBusinessControl();
    BusinessControl bc = new StackedBusinessControl(contextEntry, origBC);
    WindowControl wc = new StackedBusinessWindowControl(origWControl, bc);
    return wc;
  }
View Full Code Here

  }
 
 

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

                    // 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

     
      // 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

                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

TOP

Related Classes of org.olat.core.gui.control.WindowControl

Copyright © 2018 www.massapicom. 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.