/**
* Copyright (C) cedarsoft GmbH.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cedarsoft.wicket.yaml;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.resources.StyleSheetReference;
import org.apache.wicket.model.PropertyModel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Implementing classes should add the following components on their own:
* <ul>
* <li>The content of column 1: {@link #ID_COL1_CONTENT}
* <li>The content of column 2: {@link #ID_COL2_CONTENT}
* <li>The navigation: {@link #ID_NAVIGATION}
* <li>The footer: {@link #ID_FOOTER}
* </ul>
* <p/>
* Use the method {@link #addOrReplace(Component...)} )} because empty panels are added per default.
* <p/>
* To set the layout of the columns use the method {@link #setLayoutStyleSheet(YamlLayout)}
* <p/>
* <hr>
* It is recommended to add those <b>own</b> style sheets:
* <ul>
* <li>basemod.css (derived from basemod_draft.css)
* <li>content.css (derived from content_default.css)
* <li>layout.css (derived from one of the layout files in layout or created with the online builder)
* </ul>
*/
public abstract class YamlPage extends WebPage {
@NotNull
@NonNls
public static final String ID_PAGE_TITLE = "pageTitle";
/**
* The ID for the column 1
*/
@NotNull
@NonNls
public static final String ID_COL1_CONTENT = "col1Content";
/**
* The ID for the column 1
*/
@NotNull
@NonNls
public static final String ID_TOP_NAV = "topnav";
/**
* The ID for the feedback panel
*/
@NotNull
@NonNls
public static final String ID_FEEDBACK_PANEL = "feedbackPanel";
/**
* The ID for the column 2
*/
@NotNull
@NonNls
public static final String ID_COL2_CONTENT = "col2Content";
/**
* The id for the navigation element
*/
@NotNull
@NonNls
public static final String ID_NAVIGATION = "navigation";
/**
* The id for the footer element
*/
@NotNull
@NonNls
public static final String ID_FOOTER = "footer";
/**
* The id for the Header of column 3.
* This may be used for additional navigation elements
*/
@NotNull
@NonNls
public static final String ID_COLUMN_3_HEAD = "col3head";
/**
* The id for the layout style sheet
*/
@NotNull
@NonNls
public static final String ID_LAYOUT_STYLE_SHEET = "layoutStyleSheet";
protected YamlPage() {
this( null );
}
protected YamlPage( @Nullable PageParameters parameters ) {
super( parameters );
//Page Title
add( new Label( ID_PAGE_TITLE, new PropertyModel<YamlPage>( this, "pageTitle" ) ) );
//Default style sheets
add( new StyleSheetReference( "baseStyleSheet", new ResourceReference( YamlPage.class, "css/core/base.css" ) ) );
add( new StyleSheetReference( "wicketYamlStyleSheet", new ResourceReference( YamlPage.class, "css/core/wicketyaml.css" ) ) );
add( new StyleSheetReference( "ieHacksStyleSheet", new ResourceReference( YamlPage.class, "css/core/iehacks.css" ) ) );
//Add the empty panels for footer, navigation and content
add( new EmptyPanel( ID_NAVIGATION ) );
add( new EmptyPanel( ID_FOOTER ) );
add( new EmptyPanel( ID_COL1_CONTENT ) );
add( new EmptyPanel( ID_COL2_CONTENT ) );
add( new EmptyPanel( ID_LAYOUT_STYLE_SHEET ) );
add( new EmptyPanel( ID_TOP_NAV ) );
add( new EmptyPanel( ID_COLUMN_3_HEAD ) );
add( new YamlFeedbackPanel( ID_FEEDBACK_PANEL ) );
//set the default layout
setLayoutStyleSheet( YamlLayout.THREE_COL_DEFAULT );
}
/**
* Call this method to set the layout style
*
* @param yamlLayout the layout
*/
public final void setLayoutStyleSheet( @NotNull YamlLayout yamlLayout ) {
ResourceReference styleSheetReference = yamlLayout.getStyleSheetReference();
setLayoutStyleSheet( styleSheetReference );
}
/**
* Sets the layout style sheet
*
* @param styleSheetReference the style sheet reference for the layout
*/
public void setLayoutStyleSheet( @NotNull ResourceReference styleSheetReference ) {
addOrReplace( new StyleSheetReference( ID_LAYOUT_STYLE_SHEET, styleSheetReference ) );
}
/**
* Returns the page title
*
* @return the page title
*/
@NotNull
public abstract String getPageTitle();
}