All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
com.google.scrollview.ui.SVPopupMenu Class Reference
Inheritance diagram for com.google.scrollview.ui.SVPopupMenu:

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)
 

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.nosp@m.@goo.nosp@m.gle.c.nosp@m.om

Definition at line 34 of file SVPopupMenu.java.

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.

129  {
130 
131  // Get the corresponding menuitem
132  SVAbstractMenuItem svm = items.get(e.getActionCommand());
133 
134  svm.performAction(svWindow, SVEventType.SVET_POPUP);
135  }
SVEventType
Definition: scrollview.h:45
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.

64  {
65  // A duplicate entry - we just throw it away, since its already in.
66  if (items.get(name) != null) { return; }
67  // A new submenu at the top-level
68  if (parent.equals("")) {
69  JMenu jli = new JMenu(name);
70  SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
71  items.put(name, mli);
72  root.add(jli);
73  }
74  // A new sub-submenu
75  else if (id == -1) {
76  SVAbstractMenuItem jmi = items.get(parent);
77  JMenu jli = new JMenu(name);
78  SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
79  items.put(name, mli);
80  jmi.add(jli);
81  }
82  // A new child entry. Add to appropriate parent.
83  else {
84  SVAbstractMenuItem jmi = items.get(parent);
85  if (jmi == null) {
86  System.out.println("ERROR: Unknown parent " + parent);
87  System.exit(1);
88  }
89  SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
90  mli.mi.addActionListener(this);
91  items.put(name, mli);
92  jmi.add(mli);
93  }
94  }
name_table name
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.

111  {
112  SVAbstractMenuItem jmi = items.get(parent);
113  SVMenuItem mli = new SVMenuItem(id, name, value, desc);
114  mli.mi.addActionListener(this);
115  items.put(name, mli);
116  if (jmi == null) { // add to root
117  root.add(mli.mi);
118  } else { // add to parent
119  jmi.add(mli);
120  }
121  }
name_table name
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.

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

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