Package org.olat.repository.controllers

Source Code of org.olat.repository.controllers.ChooseStepsController

/*
****************************************************************************
*                     Technische Universitaet Chemnitz
*                     Lehrstuhl Technische Informatik
****************************************************************************
*
* Author:        Marcel Karras (toka@freebits.de)
*
* Projekt:       olat-5_2_3
* Original File: ChooseStepsController.java
* Erstellt am:   22.04.2008
* Version:       $Id: ChooseStepsController.java,v 1.3 2009-11-19 12:01:36 bja Exp $
*
****************************************************************************
*/
package org.olat.repository.controllers;

import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.form.Form;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.DefaultController;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.PackageTranslator;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
import org.olat.repository.ChooseStepsForm;
import org.olat.repository.RepositoryEntry;


/**
* Choose steps to be taken after having created a course with an initial description. TODO move
* this class to another package
*
* @author Marcel Karras (toka@freebits.de)
* @see org.olat.repository.controllers.RepositoryMainController
*/
public class ChooseStepsController extends DefaultController {

  /**
   * Step to start the wizard has been chosen.
   */
  public static Event START_COURSE_WIZARD = new Event(ChooseStepsForm.KEY_START_WIZARD);
  /**
   * Step to start the ESEM wizard.
   */
  public static final Event START_WIZARD_ESEM = new Event(ChooseStepsForm.KEY_START_WIZARD_ESEM);
  /**
   * Step to open the details view has been chosen.
   */
  public static Event DETAILS_VIEW = new Event(ChooseStepsForm.KEY_DETAILS_VIEW);
  /**
   * Step to start the raw course editor has been chosen.
   */
  public static Event COURSE_EDIT = new Event(ChooseStepsForm.KEY_COURSE_EDIT);

  // package name
  private static final String PACKAGE = Util.getPackageName(ChooseStepsController.class);
  // velocity root directory
  private static final String VELOCITY_ROOT = Util
      .getPackageVelocityRoot(ChooseStepsController.class);
  // translator object
  private Translator translator;
  // description velocity container
  private VelocityContainer descVC;
  // course elements chooser
  private ChooseStepsForm chooser;
  // keep track of the current course repository entry
  private final RepositoryEntry addedEntry;

  /**
   * Event fired when the close icon is pressed.
   */
  public static final Event EVENT_CLOSEICON = new Event("ci");

  public ChooseStepsController(final UserRequest ureq, final WindowControl control,  final RepositoryEntry addedEntry, String modus) {
    super(control);
    this.addedEntry = addedEntry;
    // translator for this class
    translator = new PackageTranslator(PACKAGE, ureq.getLocale());

    descVC = new VelocityContainer("vcDesc", VELOCITY_ROOT + "/csc_main.html", translator, this);
    descVC.contextPut("disabledforwardreason", translator.translate("disabledforwardreason"));
    // chooser form
    chooser = new ChooseStepsForm("chooser", translator, modus);
    chooser.addListener(this);
    descVC.put("chooser", chooser);
    descVC.contextPut("closeIcon", Boolean.TRUE);

    setInitialComponent(descVC);
  }

  public ChooseStepsController(final UserRequest ureq, final WindowControl control,
      final RepositoryEntry addedEntry) {
    super(control);
    this.addedEntry = addedEntry;
    // translator for this class
    translator = new PackageTranslator(PACKAGE, ureq.getLocale());

    descVC = new VelocityContainer("vcDesc", VELOCITY_ROOT + "/csc_main.html", translator, this);
    descVC.contextPut("disabledforwardreason", translator.translate("disabledforwardreason"));
    // chooser form
    chooser = new ChooseStepsForm("chooser", translator);
    chooser.addListener(this);
    descVC.put("chooser", chooser);
    descVC.contextPut("closeIcon", Boolean.TRUE);

    setInitialComponent(descVC);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  protected void doDispose() {
    // nothing to dispose here

  }

  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == this.chooser) { // process details form events
      if (event == Form.EVNT_FORM_CANCELLED) {
        fireEvent(ureq, Event.CANCELLED_EVENT);
        return;
      } else if (event == Form.EVNT_VALIDATION_OK) {
        final String step = chooser.getSelection();
        if (step == ChooseStepsForm.KEY_START_WIZARD)
          fireEvent(ureq, START_COURSE_WIZARD);
        else if (step == ChooseStepsForm.KEY_COURSE_EDIT)
          fireEvent(ureq, COURSE_EDIT);
        else if (step == ChooseStepsForm.KEY_DETAILS_VIEW)
          fireEvent(ureq, DETAILS_VIEW);
        else if (step == ChooseStepsForm.KEY_START_WIZARD_ESEM)
          fireEvent(ureq, START_WIZARD_ESEM);
        return;
      }
    }
  }

  /**
   * Get the currently active course entry.
   */
  public final RepositoryEntry getCourseRepositoryEntry() {
    return this.addedEntry;
  }

}
TOP

Related Classes of org.olat.repository.controllers.ChooseStepsController

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.