Package com.cedarsoft.wicket.yaml.test

Source Code of com.cedarsoft.wicket.yaml.test.TestYamlPage

package com.cedarsoft.wicket.yaml.test;

import com.cedarsoft.wicket.BlindTextLabel;
import com.cedarsoft.wicket.navigation.LinkProvider;
import com.cedarsoft.wicket.navigation.NavigationLinkProvider;
import com.cedarsoft.wicket.yaml.SubColumn;
import com.cedarsoft.wicket.yaml.SubTemplate;
import com.cedarsoft.wicket.yaml.YamlFooter;
import com.cedarsoft.wicket.yaml.YamlLayout;
import com.cedarsoft.wicket.yaml.YamlNavigation;
import com.cedarsoft.wicket.yaml.YamlNavigationLinksView;
import com.cedarsoft.wicket.yaml.YamlPage;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.resources.StyleSheetReference;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

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

/**
*
*/
public class TestYamlPage extends YamlPage {
  public static final String THE_TITLE = "theTitle";

  public TestYamlPage() {
    //Add my custom style sheets
    add( new StyleSheetReference( "basemodStyleSheet", new ResourceReference( TestYamlPage.class, "css/basemod.css" ) ) );
    add( new StyleSheetReference( "contentStyleSheet", new ResourceReference( TestYamlPage.class, "css/content.css" ) ) );

    //Add the navigation
    addOrReplace( new YamlNavigation( ID_NAVIGATION, new YamlNavigationLinksView( new ListDataProvider( getLinkProviders() ) ), new ResourceReference( TestYamlPage.class, "css/navigation.css" ) ) );
    //Add the footer
    addOrReplace( new YamlFooter( ID_FOOTER ) );

    addOrReplace( new BlindTextLabel( ID_COL1_CONTENT ) );
    addOrReplace( new BlindTextLabel( ID_COL2_CONTENT ) );

    addOrReplace( new Label( ID_TOP_NAV, "the Text" ) );

    setLayoutStyleSheet( YamlLayout.TWO_COL_NAV_RIGHT );

    //Borders
    SubTemplate template = new SubTemplate( "subTemplate" );
    template.add( new SubColumn( "column0", SubColumn.ColumnClasses.C_50_LEFT ) );
    template.add( new SubColumn( "column1", SubColumn.ColumnClasses.C_50_RIGHT ) );
    add( template );
  }

  @NotNull
  private static List<LinkProvider> getLinkProviders() {
    List<LinkProvider> providers = new ArrayList<LinkProvider>();
    providers.add( new NavigationLinkProvider() {
      @NotNull
      public WebMarkupContainer createLink( @NotNull @NonNls String id ) {
        return new ExternalLink( id, "http://www.heise.de" );
      }

      @NotNull
      public WebComponent createLabel( @NotNull @NonNls String id ) {
        return new Label( id, "heise" );
      }

      public boolean isActive() {
        return false;
      }
    } );
    providers.add( new NavigationLinkProvider() {
      @NotNull
      public WebMarkupContainer createLink( @NotNull @NonNls String id ) {
        return ( WebMarkupContainer ) new ExternalLink( id, "http://www.chip.de" ).setEnabled( false );
      }

      @NotNull
      public WebComponent createLabel( @NotNull @NonNls String id ) {
        return new Label( id, "chip" );
      }

      public boolean isActive() {
        return true;
      }
    } );
    providers.add( new NavigationLinkProvider() {
      @NotNull
      public WebMarkupContainer createLink( @NotNull @NonNls String id ) {
        return ( WebMarkupContainer ) new ExternalLink( id, "http://www.spiegel.de" ).setEnabled( true );
      }

      @NotNull
      public WebComponent createLabel( @NotNull @NonNls String id ) {
        return new Label( id, "spiegel" );
      }

      public boolean isActive() {
        return false;
      }
    } );
    return providers;
  }

  @Override
  @NotNull
  public String getPageTitle() {
    return THE_TITLE;
  }
}
TOP

Related Classes of com.cedarsoft.wicket.yaml.test.TestYamlPage

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.