Back to index

moin  1.9.0~rc2
Public Member Functions | Private Attributes
CH.ifa.draw.util.CommandMenu Class Reference
Inheritance diagram for CH.ifa.draw.util.CommandMenu:
Inheritance graph
[legend]
Collaboration diagram for CH.ifa.draw.util.CommandMenu:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CommandMenu (String name)
synchronized void add (Command command)
 Adds a command to the menu.
synchronized void add (Command command, MenuShortcut shortcut)
 Adds a command with the given short cut to the menu.
synchronized void remove (Command command)
synchronized void remove (MenuItem item)
synchronized void enable (String name, boolean state)
 Changes the enabling/disabling state of a named menu item.
synchronized void checkEnabled ()
void actionPerformed (ActionEvent e)
 Executes the command.

Private Attributes

Vector fCommands

Detailed Description

Definition at line 21 of file CommandMenu.java.


Constructor & Destructor Documentation

CH.ifa.draw.util.CommandMenu.CommandMenu ( String  name) [inline]

Definition at line 26 of file CommandMenu.java.

                                    {
        super(name);
        fCommands = new Vector(10);
    }

Member Function Documentation

void CH.ifa.draw.util.CommandMenu.actionPerformed ( ActionEvent  e) [inline]

Executes the command.

Definition at line 92 of file CommandMenu.java.

                                               {
        int j = 0;
        Object source = e.getSource();
        for (int i = 0; i < getItemCount(); i++) {
            MenuItem item = getItem(i);
            // ignore separators
            // a separator has a hyphen as its label
            if (item.getLabel().equals("-"))
                continue;
            if (source == item) {
                Command cmd = (Command)fCommands.elementAt(j);
                cmd.execute();
                break;
            }
            j++;
        }
    }

Here is the call graph for this function:

synchronized void CH.ifa.draw.util.CommandMenu.add ( Command  command) [inline]

Adds a command to the menu.

The item's label is the command's name.

Definition at line 35 of file CommandMenu.java.

                                                  {
        MenuItem m = new MenuItem(command.name());
        m.addActionListener(this);
        add(m);
        fCommands.addElement(command);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void CH.ifa.draw.util.CommandMenu.add ( Command  command,
MenuShortcut  shortcut 
) [inline]

Adds a command with the given short cut to the menu.

The item's label is the command's name.

Definition at line 46 of file CommandMenu.java.

                                                                         {
        MenuItem m = new MenuItem(command.name(), shortcut);
        m.setName(command.name());
        m.addActionListener(this);
        add(m);
        fCommands.addElement(command);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void CH.ifa.draw.util.CommandMenu.checkEnabled ( ) [inline]

Definition at line 75 of file CommandMenu.java.

                                            {
        int j = 0;
        for (int i = 0; i < getItemCount(); i++) {
            MenuItem item = getItem(i);
            // ignore separators
            // a separator has a hyphen as its label
            if (item.getLabel().equals("-"))
                continue;
            Command cmd = (Command)fCommands.elementAt(j);
            item.setEnabled(cmd.isExecutable());
            j++;
        }
    }

Here is the call graph for this function:

synchronized void CH.ifa.draw.util.CommandMenu.enable ( String  name,
boolean  state 
) [inline]

Changes the enabling/disabling state of a named menu item.

Definition at line 65 of file CommandMenu.java.

                                                                {
        for (int i = 0; i < getItemCount(); i++) {
            MenuItem item = getItem(i);
            if (name.equals(item.getLabel())) {
                item.setEnabled(state);
                return;
            }
        }
    }
synchronized void CH.ifa.draw.util.CommandMenu.remove ( Command  command) [inline]

Definition at line 54 of file CommandMenu.java.

                                                     {
        System.out.println("not implemented");
    }

Here is the caller graph for this function:

synchronized void CH.ifa.draw.util.CommandMenu.remove ( MenuItem  item) [inline]

Definition at line 58 of file CommandMenu.java.

                                                   {
        System.out.println("not implemented");
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 24 of file CommandMenu.java.


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