com.cooldatasoft.horizontal.dropdown.chrome.ChromeDropDownMenu Maven / Gradle / Ivy
package com.cooldatasoft.horizontal.dropdown.chrome;
import java.util.List;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.core.util.string.JavaScriptUtils;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cooldatasoft.common.MenuItem;
/**
*
* @author Fatih Mehmet UCAR - [email protected]
*
*/
public class ChromeDropDownMenu extends Panel implements IHeaderContributor {
private final static Logger LOGGER = LoggerFactory.getLogger(ChromeDropDownMenu.class);
private static final long serialVersionUID = 1L;
private final static ResourceReference DOWN_GIF = new PackageResourceReference(ChromeDropDownMenu.class, "images/down.gif");
private static final ResourceReference MENU_JS = new JavaScriptResourceReference(ChromeDropDownMenu.class, "js/chrome.js");
private final static CssResourceReference MENU_CSS_THEME1 = new CssResourceReference(ChromeDropDownMenu.class,
"css/chrome1.css");
private final static CssResourceReference MENU_CSS_THEME2 = new CssResourceReference(ChromeDropDownMenu.class,
"css/chrome2.css");
private final static CssResourceReference MENU_CSS_THEME3 = new CssResourceReference(ChromeDropDownMenu.class,
"css/chrome3.css");
private final static CssResourceReference MENU_CSS_THEME4 = new CssResourceReference(ChromeDropDownMenu.class,
"css/chrome4.css");
public enum CSS {
THEME1, THEME2, THEME3, THEME4
};
private int numberOfMenu;
private final ResourceReference menuCssResourceReference;
@Override
public void renderHead(IHeaderResponse response) {
StringBuffer buffer = new StringBuffer();
buffer.append("var downGifRelativeLocation=''; ");
response.getResponse().write(JavaScriptUtils.SCRIPT_OPEN_TAG);
response.getResponse().write(buffer.toString());
response.getResponse().write(JavaScriptUtils.SCRIPT_CLOSE_TAG);
response.render(JavaScriptHeaderItem.forReference(MENU_JS));
response.render(CssHeaderItem.forReference(menuCssResourceReference));
}
private void processResponse(MenuItem menuItem) {
switch (menuItem.getDestinationType()) {
case EXTERNAL_LINK:
break;
case WEB_PAGE_CLASS:
setResponsePage(menuItem.getResponsePageClass());
break;
case WEB_PAGE_INSTANCE:
setResponsePage(menuItem.getResponsePage());
break;
case AJAX_TARGET:
// DO Nothing as ajax will execute
break;
case NONE:
LOGGER.warn("MenuItem does not have a destination! ");
break;
default:
throw new RuntimeException("Destination type not valid!");
}
}
public ChromeDropDownMenu(String id, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy