Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ch.uzh.ifi.attempto.preditor
Class MenuCreator

    java.lang.Object
      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.
`void` | `addReferenceEntries(java.lang.String menuBlockName, java.lang.String category)` This method looks for referenceable text elements earlier in the token list, given the category of the next token.
`void` | `addVariableEntries(java.lang.String menuBlockName, int num, java.lang.String category)` This method adds text elements that contain variables (in the form of "X", "Y", "Z", "X1", "Y1", "Z1", "X2", and so on) to the menu block.
`java.util.List<TextElement>` | `getAccessibleTextElements(java.lang.String nextToken)` This method returns all text elements that are accessible for the given next token.
`abstract void` | `initMenuCreation()` This abstract method is called when the predictive editor is refreshed (before the first call of `processCategory`).
`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).
`abstract void` | `processCategory(Terminal category)` An implementation of this abstract method should process the category by calling `addMenuItem` and/or `addMenuEntry`.

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

### processCategory

    public abstract void processCategory(Terminal category)

  An implementation of this abstract method should process the category by calling `addMenuItem` and/or `addMenuEntry`.

  Parameters:
    `category` - The category of the grammar to be processed.

### initMenuCreation

    public abstract void initMenuCreation()

  This abstract method is called when the predictive editor is refreshed (before the first call of `processCategory`). 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.

### addReferenceEntries

    public void addReferenceEntries(java.lang.String menuBlockName,
                                    java.lang.String category)

  This method looks for referenceable text elements earlier in the token list, given the category of the next token. For each of those text elements, a new reference text element is created and added to the menu block.

  Parameters:
    `menuBlockName` - The name of the menu block.
    `category` - The category name for which the previous tokens should be checked for referenceability.
  See Also:
    `getAccessibleTextElements(String)`, `RefableTextElement`, `RefTextElement`

### addVariableEntries

    public void addVariableEntries(java.lang.String menuBlockName,
                                   int num,
                                   java.lang.String category)

  This method adds text elements that contain variables (in the form of "X", "Y", "Z", "X1", "Y1", "Z1", "X2", and so on) to the menu block.

  Parameters:
    `menuBlockName` - The name of the menu block.
    `num` - Variables are created up to this number.
    `category` - The category name of the variable tokens.
  See Also:
    `VarTextElement`

### getAccessibleTextElements

    public java.util.List<TextElement> getAccessibleTextElements(java.lang.String nextToken)

  This method returns all text elements that are accessible for the given next token.

  Parameters:
    `nextToken` - The next token.
  Returns:
    A list of all accessible text elements.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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