net.i2p.desktopgui

## Class TrayManager

- java.lang.Object
- - net.i2p.desktopgui.TrayManager

- Direct Known Subclasses:
    ExternalTrayManager, InternalTrayManager

      abstract class TrayManager
      extends Object

  Abstract base class for managing system tray icons and menus for I2P. Handles tray icon lifecycle, notifications, and provides platform-specific menu creation for both AWT and Swing implementations.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected I2PAppContext` | `_appContext`
    `protected JMenuItem` | `_jnotificationItem1`
    `protected JMenuItem` | `_jnotificationItem2`
    `protected MenuItem` | `_notificationItem1`
    `protected MenuItem` | `_notificationItem2`
    `protected boolean` | `_showNotifications`
    `protected boolean` | `_useSwing`
    `protected static String` | `PROP_NOTIFICATIONS`
    `protected SystemTray` | `tray`
    `protected TrayIcon` | `trayIcon`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TrayManager(I2PAppContext ctx, boolean useSwing)` Instantiate tray manager.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `_t(String s)`
    `protected String` | `_t(String s, Object o)`
    `protected void` | `configureNotifications(boolean enable)` Does not save.
    `int` | `displayMessage(int priority, String title, String message, String path)` Send a notification to the user.
    `protected abstract PopupMenu` | `getMainMenu()` Build a popup menu, adding callbacks to the different items.
    `protected abstract JPopupMenu` | `getSwingMainMenu()` Build a popup menu, adding callbacks to the different items.
    `protected void` | `initializeJNotificationItems()` Initializes _jnotificationItem 1 and 2
    `protected void` | `initializeNotificationItems()` Initializes _notificationItem 1 and 2
    `void` | `languageChanged()`
    `void` | `startManager()` Add the tray icon to the system tray and start everything up.
    `void` | `stopManager()` Remove the tray icon from the system tray
    `protected abstract void` | `updateMenu()` Update the menu

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _appContext

          protected final I2PAppContext _appContext

    - #### _jnotificationItem1

          protected JMenuItem _jnotificationItem1

    - #### _jnotificationItem2

          protected JMenuItem _jnotificationItem2

    - #### _notificationItem1

          protected MenuItem _notificationItem1

    - #### _notificationItem2

          protected MenuItem _notificationItem2

    - #### _showNotifications

          protected volatile boolean _showNotifications

    - #### _useSwing

          protected final boolean _useSwing

    - #### PROP_NOTIFICATIONS

          protected static final String PROP_NOTIFICATIONS

      See Also:
        Constant Field Values

    - #### tray

          protected SystemTray tray

    - #### trayIcon

          protected TrayIcon trayIcon

  - ### Constructor Detail

    - #### TrayManager

          protected TrayManager(I2PAppContext ctx,
                                boolean useSwing)

      Instantiate tray manager.

  - ### Method Detail

    - #### _t

          protected String _t(String s)

    - #### _t

          protected String _t(String s,
                              Object o)

    - #### configureNotifications

          protected void configureNotifications(boolean enable)

      Does not save. See InternalTrayManager.

    - #### displayMessage

          public int displayMessage(int priority,
                                    String title,
                                    String message,
                                    String path)

      Send a notification to the user.
      Parameters:
        `title` - for the popup, translated
        `message` - translated
        `path` - unsupported
      Returns:
        0, or -1 on failure

    - #### getMainMenu

          protected abstract PopupMenu getMainMenu()

      Build a popup menu, adding callbacks to the different items.
      Returns:
        popup menu

    - #### getSwingMainMenu

          protected abstract JPopupMenu getSwingMainMenu()

      Build a popup menu, adding callbacks to the different items.
      Returns:
        popup menu

    - #### initializeJNotificationItems

          protected void initializeJNotificationItems()

      Initializes _jnotificationItem 1 and 2

    - #### initializeNotificationItems

          protected void initializeNotificationItems()

      Initializes _notificationItem 1 and 2

    - #### languageChanged

          public void languageChanged()

    - #### startManager

          public void startManager()
                            throws AWTException

      Add the tray icon to the system tray and start everything up.
      Throws:
        `AWTException`

    - #### stopManager

          public void stopManager()

      Remove the tray icon from the system tray

    - #### updateMenu

          protected abstract void updateMenu()

      Update the menu