Package ch.goodsolutions.demoextension

Source Code of ch.goodsolutions.demoextension.DemoExtension

/**
* 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) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/


package ch.goodsolutions.demoextension;

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

import org.olat.core.extensions.Extension;
import org.olat.core.extensions.ExtensionElement;
import org.olat.core.extensions.action.ActionExtension;
import org.olat.core.extensions.helpers.ExtensionElements;
import org.olat.core.extensions.helpers.StaticAndCssHelper;
import org.olat.core.extensions.sitescreator.SitesCreator;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.dtabs.DTabs;
import org.olat.core.gui.control.navigation.SiteDefinition;
import org.olat.core.gui.translator.PackageTranslator;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
import org.olat.home.HomeMainController;

import ch.goodsolutions.demoextension.controller.DemoController;

/**
* Description:<br>
* TODO: Felix Class Description for SiteExtension
* <P>
* Initial Date: 02.08.2005 <br>
*
* @author Felix Jost
*/
public class DemoExtension implements Extension {
  // package local to avoid synthetic access method
  static final String PACKAGE = Util.getPackageName(DemoExtension.class);
 
  private ExtensionElements elements = new ExtensionElements();

  public String mapPath; // to be accessed by controllers of a sub-package (only for pdf or such, not for images!)

  /**
   * [used by spring]
   */
  private DemoExtension() {

    // --- after logging in, you would like to see a new link in the menu on the left (beeing in the user's home screen) and a new site (top of screen)
    elements.putExtensionElement(HomeMainController.class.getName(), new ActionExtension() {
      public String getDescription(Locale loc) {
        Translator trans = new PackageTranslator(PACKAGE, loc);
        return trans.translate("homemaincontroller.description");
      }

      public String getActionText(Locale loc) {
        Translator trans = new PackageTranslator(PACKAGE, loc);
        return trans.translate("homemaincontroller.actiontext");
      }

      public Controller createController(UserRequest ureq, WindowControl wControl, Object arg) {
        Controller dsc = new DemoController(ureq, wControl, null);
        return dsc;
      }
    });

    // --- create a new site:
    SiteDefinition s1 = new DemoSiteDef();
    final List sitedefs = new ArrayList();
    sitedefs.add(s1);
    elements.putExtensionElement(DTabs.class.getName(), new SitesCreator() {
      public List createSiteDefinitions() {
        return sitedefs;
      }
    });

    // offer an extension so that all content in the "raw" subfolder of the
    // given class should be served (e.g. static pdf's and a stylesheet, but
    // static images should -not- be referenced by using an <img src=...> tag,
    // but rather use the background-image attribute of your css classes),
    StaticAndCssHelper sach = new StaticAndCssHelper(this.getClass(), "style.css");
    sach.initAndRegister(elements);
    mapPath = sach.getMapPath();

    //FIXME:fj:a allow multiple namedispatcher per extension!
    //elements.putExtensionElement(DispatcherAction.EXTENSIONPOINT_NAMEDDISPATCHER, new FullFunctionality());
    //elements.putExtensionElement(DispatcherAction.EXTENSIONPOINT_NAMEDDISPATCHER, new SmallFunctionality());
   
  }

  /**
   * @see org.olat.core.extensions.Extension#getExtensionFor(java.lang.Class)
   */
  public ExtensionElement getExtensionFor(String extensionPoint) {
    return elements.getExtensionElement(extensionPoint);
  }

}
TOP

Related Classes of ch.goodsolutions.demoextension.DemoExtension

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.