Package org.olat.course.nodes.st

Source Code of org.olat.course.nodes.st.STPeekViewController

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) frentix GmbH<br>
* http://www.frentix.com<br>
* <p>
*/
package org.olat.course.nodes.st;

import java.util.ArrayList;
import java.util.List;

import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.htmlsite.OlatCmdEvent;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.course.nodes.CourseNode;
import org.olat.course.nodes.CourseNodeFactory;
import org.olat.course.nodes.STCourseNode;

/**
* <h3>Description:</h3> The structure node peek view controller displays the
* title, the description and the first level of child nodes
* <p>
* <h4>Events fired by this Controller</h4>
* <ul>
* <li>none</li>
* </ul>
* <p>
* Initial Date: 23.09.2009 <br>
*
* @author gnaegi, gnaegi@frentix.com, www.frentix.com
*/
public class STPeekViewController extends BasicController {
  private VelocityContainer genericPeekViewVC;
  /**
   * Constructor
   *
   * @param ureq
   * @param wControl
   * @param userCourseEnv
   * @param ne
   */
  public STPeekViewController(UserRequest ureq, WindowControl wControl, STCourseNode courseNode) {
    super(ureq, wControl);

    genericPeekViewVC = createVelocityContainer("stPeekView");
   
    List<CourseNode> childNodes = new ArrayList<CourseNode>();
    for (int i = 0; i < courseNode.getChildCount(); i++) {
      CourseNode child = (CourseNode) courseNode.getChildAt(i);
      childNodes.add(child);
      // Add link to jump to course node
      Link nodeLink = LinkFactory.createLink("nodeLink_" + child.getIdent(), genericPeekViewVC, this);
      nodeLink.setCustomDisplayText(child.getShortTitle());
      // Add css class for course node type
      String iconCSSClass = CourseNodeFactory.getInstance().getCourseNodeConfiguration(child.getType()).getIconCSSClass();
      nodeLink.setCustomEnabledLinkCSS("b_with_small_icon_left o_gotoNode " + iconCSSClass);
      nodeLink.setUserObject(child.getIdent());
    }
    // Add course node to get title etc
    genericPeekViewVC.contextPut("childNodes", childNodes);
    // Add css class for course node type
    CourseNodeFactory courseNodeFactory = CourseNodeFactory.getInstance();
    genericPeekViewVC.contextPut("courseNodeFactory", courseNodeFactory);
    //
    putInitialPanel(genericPeekViewVC);
  }

  /**
   * @see org.olat.core.gui.control.DefaultController#doDispose()
   */
  @Override
  protected void doDispose() {
  // nothing to dispose
  }

  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *      org.olat.core.gui.components.Component,
   *      org.olat.core.gui.control.Event)
   */
  @Override
  protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
      Link nodeLink = (Link) source;
      // get node ID and fire activation event
      String nodeId = (String) nodeLink.getUserObject();
      fireEvent(ureq, new OlatCmdEvent(OlatCmdEvent.GOTONODE_CMD, nodeId));     
    }
  }

}
TOP

Related Classes of org.olat.course.nodes.st.STPeekViewController

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.