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

com.jk.application.api.AbstractMenu Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2002-2016 Jalal Kiswani.
 *
 * 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.jk.application.api;

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

import com.jk.locale.JKMessage;
import com.jk.security.JKPrivilige;
import com.jk.security.JKSecurityManager;

/**
 * The Class Menu.
 *
 * @author u087
 */
public abstract class AbstractMenu implements Menu {
	String name;

	String iconName;

	List items = new ArrayList();
	List groups = new ArrayList();
	Module parentModule;

	int priviligeId;

	private int index;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#add(com.jk.metadata.application.
	 * MenuItem)
	 */
	public boolean addAll(final List c) {
		return this.items.addAll(c);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#clear()
	 */
	@Override
	public void clear() {
		this.items.clear();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#get(int)
	 */
	@Override
	public MenuItem get(final int index) {
		return this.items.get(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getFullQualifiedPath()
	 */
	@Override
	public String getFullQualifiedPath() {
		final StringBuffer buf = new StringBuffer();
		buf.append(JKMessage.get(getParentModule().getModuleName(), true));
		buf.append("-->");
		buf.append(JKMessage.get(getName(), true));
		return buf.toString();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getGroups()
	 */
	@Override
	public List getGroups() {
		return this.groups;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getIconName()
	 */
	@Override
	public String getIconName() {
		return this.iconName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getItems()
	 */
	@Override
	public List getItems() {
		return this.items;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getName()
	 */
	@Override
	public String getName() {
		return this.name;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getParentModule()
	 */
	@Override
	public Module getParentModule() {
		return this.parentModule;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getPrivilige()
	 */
	@Override
	public JKPrivilige getPrivilige() {
		// final int privId = (getParentModule().getModuleName() +
		// getName()).hashCode();
		return JKSecurityManager.createPrivilige(JKMessage.get(getName(), true), getParentModule().getPrivilige());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#init()
	 */
	@Override
	public void init() {
		new Runnable() {

			@Override
			public void run() {
				for (int i = 0; i < AbstractMenu.this.items.size(); i++) {
					AbstractMenu.this.items.get(i).init();
				}
			}
		};
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#setIconName(java.lang.String)
	 */
	@Override
	public void setIconName(final String iconName) {
		this.iconName = iconName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#setName(java.lang.String)
	 */
	@Override
	public void setName(final String name) {
		this.name = name;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#setParentModule(com.jk.metadata.
	 * application.api.Module)
	 */
	@Override
	public void setParentModule(final Module parentModule) {
		this.parentModule = parentModule;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#size()
	 */
	@Override
	public int size() {
		return this.items.size();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getFullTitle()
	 */
	@Override
	public String getFullTitle() {
		return JKMessage.get(getParentModule().getModuleName(), true).concat(" > ").concat(JKMessage.get(getName(), true));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#setIndex(int)
	 */
	@Override
	public void setIndex(int index) {
		this.index = index;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.jk.metadata.application.Menu#getIndex()
	 */
	@Override
	public int getIndex() {
		return index;
	}

	@Override
	public boolean add(MenuItem o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void addGroup(Menu menu) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setItems(List items) {
		// TODO Auto-generated method stub

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy