at.spardat.xma.appshell.IMenuItem Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* s IT Solutions AT Spardat GmbH - initial API and implementation
*******************************************************************************/
/*
* @(#) $Id: IMenuItem.java 8548 2011-09-28 11:41:26Z laslovd $
*
*
*
*
*/
package at.spardat.xma.appshell;
import java.util.List;
import org.eclipse.swt.graphics.Image;
/**
* Interface for {@link MenuItem}.
*
* @author s2877
* @since 1.4.0
*/
public interface IMenuItem {
/**
* Get the list of all MenuItems of the submenu of this MenuItem.
* @return the list of all MenuItems of the submenu.
*/
List getItems();
/**
* Determine if the given item is contained in the submenu of this menu.
* @param item the MenuItem to search for in the submenu.
* @return true if the given item is contained in the list of subitems.
*/
public boolean containsItem(IMenuItem item);
/**
* Determine if the given item is contained in the submenu of this menu.
* @param item the MenuItem to search for in the submenu.
* @param recurisvely true if the item should be searched deeply
* @return true if the given item is contained in the list of subitems.
*/
public boolean containsItem(IMenuItem item, boolean recurisvely);
/**
* Remove all MenuItems from the list of subitems.
* The items are unregisterd from the AppShell and
* are no longer visible.
*/
public void clearItems();
/**
* Get the visual representation of the MenuItem.
* e.g.: a {@link at.spardat.xma.mdl.tree.ITreeWMClient} or org.eclipse.swt.widget.MenuItem.
* @return the GUI-Object corresponding to this MenuItem.
*/
public Object getAttached();
/**
* Set the visual representation of the MenuItem
* e.g.: a {@link at.spardat.xma.mdl.tree.ITreeWMClient} or org.eclipse.swt.widget.MenuItem.
* @param attached the GUI-Object corresponding to this MenuItem.
*/
public void setAttached(Object attached);
/**
* Get the visual representation of the parent MenuItem
* @return the GUI-Object corresponding to the parent of this MenuItem.
*/
public Object getParentAttached();
/**
* Get the MenuItem containing this MenuItem in its submenu.
* @return the parent MenuItem.
*/
public IMenuItem getParent();
/**
* Get the name of the MenuItem. The name must be unique within the
* client side application.
* @return the name of the MenuItem
*/
public String getName();
/**
* Get the index of the MenuItem in the list of
* subitems in its parent.
* @return the index of this.
*/
public int getIndex();
/**
* Get the index of the given MenuItem in the submenu of this.
* @param item to determine the index of
* @return the index of the given item in the submenu
*/
public int getIndexOf(IMenuItem item);
/**
* Add the given MenuItem to the list of subitems.
* The new item is registered at the AppShell and
* becomes visible.
* Note: A MenuItem used at a MenuAppShell (i.e. at an SWT menu) must be of the style CASCADE to have children.
* @param item to add.
*/
public void addItem(MenuItem item);
/**
* Add the given MenuItem to the list of subitems at the given index.
* The new item is registered at the AppShell and becomes visible.
* Note: A MenuItem used at a MenuAppShell (i.e. at an SWT menu) must be of the style CASCADE to have children.
* @param index where to add the new item.
* @param item to add.
*/
public void addItem(int index, MenuItem item);
/**
* Remove the given MenuItem from the list of subitems.
* This item is unregisterd from the AppShell and
* is no longer visible.
* @param item to remove
*/
public void removeItem(MenuItem item);
/**
* Get the Task than will be called whenever this MenuItem is selected.
* @return the Task of this item.
*/
public ITask getTask();
/**
* Set the task to run when the MenuItem is selected
* @param task the task of this item.
*/
public void setTask(ITask task);
/**
* Select the MenuItem. This runs its contained Task.
*/
public void select();
/**
* @return Returns the image which is shown at this item. Can be null.
*/
public Image getImage();
/**
* Sets the image to show at this item.
*/
public void setImage(Image image);
// TODO: comment me
public int getAccelerator ();
// TODO: comment me
public void setAccelerator ( int accelerator );
/**
*
* If no style was set then SWT.NONE is returned.
* @return Returns the style set at this item.
*/
public int getStyle();
/**
* Enables this menu item if the argument is true
,
* and disables it otherwise. A disabled menu item is
* not selectable from the user interface and
* draws with an inactive or "grayed" look.
* Disabling a menu item makes all its children not selectable, too.
* @since 2.2.0
*/
public void setEnabled(boolean enabled);
/**
* Returns true
if this menu item is enabled and false
* otherwise. A disabled menu item is not selectable from the user interface
* and draws with an inactive or "grayed" look. A menu item is disabled, if
* it is either directly disabled or any of its parents is disabled.
* @since 2.2.0
*/
public boolean isEnabled();
/**
* Returns false
if this menu item is directly disabled by calling
* setEnabled(false)
on its instance. It does not take the enabled
* state of its parent into account.
* @since 2.2.0
*/
public boolean isLocalEnabled();
}