Difference between revisions of "MenuItemExtension"

From OpenKM Documentation
Jump to: navigation, search
(Created page with '== Constructors == MenuItemExtension(String imageURL, String text, Command cmd) MenuItemExtension(String imageURL, String text, MenuBar menuBar) MenuItemExtension(String text,…')
 
 
Line 1: Line 1:
 
== Constructors ==
 
== Constructors ==
MenuItemExtension(String imageURL, String text, Command cmd)
+
=== MenuItemExtension(String imageURL, String text, Command cmd) ===
MenuItemExtension(String imageURL, String text, MenuBar menuBar)
 
MenuItemExtension(String text, MenuBar menuBar)
 
 
 
== MenuItemExtension(String imageURL, String text, Command cmd) ==
 
 
Normal menuitem
 
Normal menuitem
  
 
+
=== MenuItemExtension(String imageURL, String text, MenuBar menuBar) ===
== MenuItemExtension(String imageURL, String text, MenuBar menuBar) ==
 
 
A menuitem that has a menu bar. Normally used to submenu entry.
 
A menuitem that has a menu bar. Normally used to submenu entry.
  
 +
=== MenuItemExtension(String text, MenuBar menuBar) ===
 +
Normally used to define the main menuItem. Menu root that has other menu options as child.
  
== MenuItemExtension(String text, MenuBar menuBar) ==
+
=== Example ===
Normally used to define the main menuItem. Menu root that has other menu options as childs.
 
 
 
 
 
== Example ==
 
 
<source lang="java">
 
<source lang="java">
 
public class MainMenuExample {
 
public class MainMenuExample {
 
 
private MenuItemExtension exampleMenu;
 
private MenuItemExtension exampleMenu;
 
private MenuBarExtension subMenuExample;
 
private MenuBarExtension subMenuExample;
Line 97: Line 89:
 
</source>
 
</source>
  
 
+
[[Category: Extension Guide]]
[[Category: OpenKM plugin extensions]]
 

Latest revision as of 13:28, 2 December 2010

Constructors

MenuItemExtension(String imageURL, String text, Command cmd)

Normal menuitem

MenuItemExtension(String imageURL, String text, MenuBar menuBar)

A menuitem that has a menu bar. Normally used to submenu entry.

MenuItemExtension(String text, MenuBar menuBar)

Normally used to define the main menuItem. Menu root that has other menu options as child.

Example

public class MainMenuExample {
	private MenuItemExtension exampleMenu;
	private MenuBarExtension subMenuExample;
	private MenuBarExtension subMenuExample2;
	private MenuItemExtension subMenuItem;
	private MenuItemExtension option1;
	private MenuItemExtension option2;
	private MenuItemExtension option3;
	private MenuItemExtension option4;
	
	/**
	 * MainMenuExample
	 */
	public MainMenuExample() {
		// All menu items
		option1 = new MenuItemExtension("img/box.png", "Option 1", option1Action);
		option2 = new MenuItemExtension("img/box.png", "Option 2", option2Action);
		option3 = new MenuItemExtension("img/box.png", "Option 3", option3Action);
		option4 = new MenuItemExtension("img/box.png", "Option 4", option4Action);
		
		// Secondary submenu
		subMenuExample2 = new MenuBarExtension();
		subMenuExample2.addItem(option3);
		subMenuExample2.addItem(option4);
		subMenuItem = new MenuItemExtension("img/box.png","Sub menu", subMenuExample2); // is a secondary submenu
		
		// Principal submenu
		subMenuExample = new MenuBarExtension();
		subMenuExample.addItem(option1);
		subMenuExample.addItem(option2);
		subMenuExample.addItem(subMenuItem);
		
		// Principal menuitem
		exampleMenu = new MenuItemExtension("New Menu", subMenuExample); // is not a secondary submenu
	}
	
	public MenuItemExtension getNewMenu() {
		return exampleMenu;
	}
	
	/**
	 * option1Action
	 */
	Command option1Action = new Command() {
		public void execute() {
			Window.alert("option1 action");
		}
	};
	
	/**
	 * option2Action
	 */
	Command option2Action = new Command() {
		public void execute() {
			Window.alert("option2 action");
		}
	};
	
	/**
	 * option3Action
	 */
	Command option3Action = new Command() {
		public void execute() {
			Window.alert("option3 action");
		}
	};	
	
	/**
	 * option4Action
	 */
	Command option4Action = new Command() {
		public void execute() {
			Window.alert("option4 action");
		}
	};	
}