All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wicketstuff.jquery.ui.widget.menu.AbstractMenuItem Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 org.wicketstuff.jquery.ui.widget.menu;

import java.util.Collections;
import java.util.List;

import org.apache.wicket.model.IModel;
import org.wicketstuff.jquery.ui.JQueryIcon;

/**
 * Base class for {@link Menu} item
 *
 * @author Sebastien Briquet - sebfz1
 * @since 1.4.2
 * @since 6.2.2
 */
public abstract class AbstractMenuItem implements IMenuItem
{
	private static final long serialVersionUID = 1L;

	private IModel title;
	private String icon;
	private boolean enabled = true;

	/**
	 * Constructor
	 * @param title {@link IModel} that represent the title of the menu-item
	 * @param icon the icon css class; {@code 'ui-icon-blank'} or {@link JQueryIcon#BLANK} may be used to display no icon.
	 */
	public AbstractMenuItem(IModel title, String icon)
	{
		this.title = title;
		this.icon = icon;
	}

	@Override
	public String getId()
	{
		return "menuitem-" + this.hashCode();
	}

	@Override
	public IModel getTitle()
	{
		return this.title;
	}

	/**
	 * Sets the menu-item title
	 * @param title the menu-item title
	 */
	public void setTitle(IModel title)
	{
		this.title = title;
	}

	@Override
	public String getIcon()
	{
		return this.icon;
	}

	/**
	 * Sets the icon css class being displayed in the {@link Menu} (ie: ui-my-icon)
	 * @param icon the icon css class
	 */
	public void setIcon(String icon)
	{
		this.icon = icon;
	}

	@Override
	public boolean isEnabled()
	{
		return this.enabled;
	}

	/**
	 * Sets whether the menu-item is enabled
	 * @param enabled true or false
	 */
	public void setEnabled(boolean enabled)
	{
		this.enabled = enabled;
	}

	@Override
	public List getItems()
	{
		return Collections.emptyList();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy