ch.uzh.ifi.attempto.preditor
Class MenuCreator

java.lang.Object
  extended by ch.uzh.ifi.attempto.preditor.MenuCreator
Direct Known Subclasses:
ExampleMenuCreator, SimpleMenuCreator

public abstract class MenuCreator
extends java.lang.Object

This abstract class is used for the predictive editor to create menus on the basis of categories of the grammar.

Author:
Tobias Kuhn

Constructor Summary
MenuCreator()
          Initializes a new menu creator object.
 
Method Summary
 void addMenuEntry(java.lang.String menuBlockName, TextElement textElement)
          Adds a new menu entry containing the text element to the menu block.
 void addMenuItem(java.lang.String menuBlockName, MenuItem menuItem)
          Adds the menu item to the given menu block.
protected abstract  void addMenuItems(Restriction restriction)
          An implementation of this abstract method should add menu items that comply with the given restriction.
 void addVariableEntries(java.lang.String menuBlockName, int num, java.lang.String categoryName)
          Adds menu entries that stand for variables in the form of "X", "Y", "Z", "X1", "Y1", and so on.
abstract  void initMenuCreation()
          This abstract method is called when the predictive editor is refreshed (before the first call of addMenuItems).
 void prepareMenuBlock(java.lang.String menuBlockName)
          Prepares a new menu block (if there is no such menu block already with the same name).
 void prepareMenuBlock(java.lang.String menuBlockName, boolean doSort)
          Prepares a new menu block (if there is no such menu block already with the same name).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuCreator

public MenuCreator()
Initializes a new menu creator object.

Method Detail

addMenuItems

protected abstract void addMenuItems(Restriction restriction)
An implementation of this abstract method should add menu items that comply with the given restriction. This should be done by calling addMenuItem and/or addMenuEntry.

Parameters:
restriction - The restriction for the menu items.

initMenuCreation

public abstract void initMenuCreation()
This abstract method is called when the predictive editor is refreshed (before the first call of addMenuItems). This is a good place for calling prepareMenuBlock.


prepareMenuBlock

public void prepareMenuBlock(java.lang.String menuBlockName)
Prepares a new menu block (if there is no such menu block already with the same name). The menu blocks are shown in the predictive editor in the same order as they have been prepared.

Parameters:
menuBlockName - The name of the menu block.

prepareMenuBlock

public void prepareMenuBlock(java.lang.String menuBlockName,
                             boolean doSort)
Prepares a new menu block (if there is no such menu block already with the same name). The second parameter defines whether the items of the menu block should be sorted. The menu blocks are shown in the predictive editor in the same order as they have been prepared.

Parameters:
menuBlockName - The name of the menu block.
doSort - true if the items should be sorted.

addMenuItem

public void addMenuItem(java.lang.String menuBlockName,
                        MenuItem menuItem)
Adds the menu item to the given menu block. If no menu block of this name has been prepared at this point then the preparation is done first.

Parameters:
menuBlockName - The name of the menu block.
menuItem - The menu item to be added to the menu block.

addMenuEntry

public void addMenuEntry(java.lang.String menuBlockName,
                         TextElement textElement)
Adds a new menu entry containing the text element to the menu block. If no menu block of this name has been prepared at this point then the preparation is done first.

Parameters:
menuBlockName - The name of the menu block.
textElement - The text element of the menu entry that is created and then added to the menu block.

addVariableEntries

public void addVariableEntries(java.lang.String menuBlockName,
                               int num,
                               java.lang.String categoryName)
Adds menu entries that stand for variables in the form of "X", "Y", "Z", "X1", "Y1", and so on.

Parameters:
menuBlockName - The name of the menu block into which the entries should be added.
num - The number upto which the variables should be enumerated.
categoryName - The category name of the entries.


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)