File: SourceListContextMenuProvider.java

package info (click to toggle)
mac-widgets 0.10.0%2Bsvn416-dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,968 kB
  • ctags: 2,003
  • sloc: java: 9,909; makefile: 13; sh: 12
file content (72 lines) | stat: -rw-r--r-- 3,366 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.explodingpixels.macwidgets;

import javax.swing.JPopupMenu;

/**
 * <p>
 * An interface to hook into the context-menu showing process. When installed on a
 * {@link SourceList}, this interface will be notified just prior to a context menu being shown.
 * </p>
 * <p>
 * Here's a sample implementation and installation of this interface:
 * </p>
 * <pre>
 * SourceListContextMenuProvider menuProvider = new SourceListContextMenuProvider() {
 *           public JPopupMenu createContextMenu() {
 *               // create and install your custom menu items for context-menu's on the SourceList.
 *               JPopupMenu menu = new JPopupMenu();
 *               popupMenu.add(new JMenuItem("Generic Menu for SourceList"));
 *               return popupMenu;
 *           }
 *           public JPopupMenu createContextMenu(JPopupMenu popupMenu, SourceListItem item) {
 *               // create and install your custom menu items for context-menu's on a SourceListItem.
 *               JPopupMenu menu = new JPopupMenu();
 *               popupMenu.add(new JMenuItem("Menu for " + item.getText()));
 *               return menu;
 *           }
 *           public JPopupMenu createContextMenu(SourceListCategory category) {
 *               // create and install your custom menu items for context-menu's on a SourceListCategory.
 *               JPopupMenu menu = new JPopupMenu();
 *               popupMenu.add(new JMenuItem("Menu for " + category.getText()));
 *               return menu;
 *           }
 *       };
 * mySourceList.setSourceListContextMenuProvider(menuProvider);
 * <pre>
 */
public interface SourceListContextMenuProvider {

    /**
     * Called when the user requests that a context-menu be shown on the {@link SourceList} itself.
     * This will only be called if the {@code SourceList} does not fill the entire view (doesn't
     * have scroll bars) and the user clicks below any item or category. If the returned menu is
     * null or if no menu items are added to the menu, then the menu will not be shown.
     *
     * @return the context menu for the associated {@code SourceList}. Can be null or have no menu
     *         items to indicate no menu should be shown.
     */
    JPopupMenu createContextMenu();

    /**
     * Called when the user requests that a context-menu be shown on a {@link SourceListItem}.
     * If the returned menu is null or if no menu items are added to the menu, then the menu will
     * not be shown.
     *
     * @param item the {@code SourceListItem} that the context-menu was requested for.
     * @return the context menu for the associated {@code SourceListItem}. Can be null or have no
     *         menu items to indicate no menu should be shown.
     */
    JPopupMenu createContextMenu(SourceListItem item);

    /**
     * Called when the user requests that a context-menu be shown on a {@link SourceListCategory}.
     * If the returned menu is null or no menu items are added to the menu, then the menu will not
     * be shown.
     *
     * @param category the {@code SourceListCategory} that the context-menu was requested for.
     * @return the context menu for the associated {@code SourceListCategory}.  Can be null or have
     *         no menu items to indicate no menu should be shown.
     */
    JPopupMenu createContextMenu(SourceListCategory category);

}