Tesseract  3.02
com.google.scrollview.ui.SVPopupMenu Class Reference

Inherits ActionListener.

List of all members.

Public Member Functions

void add (String parent, String name, int id)
void add (String parent, String name, int id, String value, String desc)
void actionPerformed (ActionEvent e)
void show (Component Invoker, int x, int y)

Package Functions

 SVPopupMenu (SVWindow sv)

Detailed Description

The SVPopupMenu class provides the functionality to add a popup menu to ScrollView. Each popup menu item gets associated with a (client-defined) command-id, which SVPopupMenu will return upon clicking it.

Author:
wanke@google.com

Definition at line 34 of file SVPopupMenu.java.


Constructor & Destructor Documentation

com.google.scrollview.ui.SVPopupMenu.SVPopupMenu ( SVWindow  sv) [inline, package]

Create a new SVPopupMenu and associate it with a ScrollView window.

Parameters:
svThe window our popup menu belongs to.

Definition at line 47 of file SVPopupMenu.java.

                           {
    root = new JPopupMenu();
    svWindow = sv;
    items = new HashMap<String, SVAbstractMenuItem>();
  }

Member Function Documentation

void com.google.scrollview.ui.SVPopupMenu.actionPerformed ( ActionEvent  e) [inline]

A click on one of the items in our menubar has occured. Forward it to the item itself to let it decide what happens.

Definition at line 129 of file SVPopupMenu.java.

                                             {

    // Get the corresponding menuitem
    SVAbstractMenuItem svm = items.get(e.getActionCommand());

   svm.performAction(svWindow, SVEventType.SVET_POPUP);
  }
void com.google.scrollview.ui.SVPopupMenu.add ( String  parent,
String  name,
int  id 
) [inline]

Add a new entry to the menubar. For these items, the server will poll the client to ask what to do.

Parameters:
parentThe menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level)
nameThe caption of the new entry.
idThe Id of the new entry. If it is -1, the entry will be treated as a menu.

Definition at line 64 of file SVPopupMenu.java.

                                                      {
    // A duplicate entry - we just throw it away, since its already in.
    if (items.get(name) != null) { return; }
    // A new submenu at the top-level
    if (parent.equals("")) {
      JMenu jli = new JMenu(name);
      SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
      items.put(name, mli);
      root.add(jli);
    }
    // A new sub-submenu
    else if (id == -1) {
      SVAbstractMenuItem jmi = items.get(parent);
      JMenu jli = new JMenu(name);
      SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
      items.put(name, mli);
      jmi.add(jli);
    }
    // A new child entry. Add to appropriate parent.
    else {
      SVAbstractMenuItem jmi = items.get(parent);
      if (jmi == null) {
        System.out.println("ERROR: Unknown parent " + parent);
        System.exit(1);
      }
      SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
      mli.mi.addActionListener(this);
      items.put(name, mli);
      jmi.add(mli);
    }
  }
void com.google.scrollview.ui.SVPopupMenu.add ( String  parent,
String  name,
int  id,
String  value,
String  desc 
) [inline]

Add a new entry to the menubar. In this case, we also know its value and possibly even have a description. For these items, the server will not poll the client to ask what to do, but just show an input dialog and send a message with the new value.

Parameters:
parentThe menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level)
nameThe caption of the new entry.
idThe Id of the new entry. If it is -1, the entry will be treated as a menu.
valueThe value of the new entry.
descThe description of the new entry.

Definition at line 111 of file SVPopupMenu.java.

                                                                                 {
    SVAbstractMenuItem jmi = items.get(parent);
    SVMenuItem mli = new SVMenuItem(id, name, value, desc);
    mli.mi.addActionListener(this);
    items.put(name, mli);
    if (jmi == null) { // add to root
      root.add(mli.mi);
    } else { // add to parent
      jmi.add(mli);
    }
  }
void com.google.scrollview.ui.SVPopupMenu.show ( Component  Invoker,
int  x,
int  y 
) [inline]

Gets called by the SVEventHandler of the window to actually show the content of the popup menu.

Definition at line 141 of file SVPopupMenu.java.

                                                    {
    root.show(Invoker, x, y);
  }

The documentation for this class was generated from the following file: