Class FeatureInstaller

java.lang.Object
com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller

public class FeatureInstaller extends Object
Adds a plug-in to the JUMP Workbench as a menu item.
  • Method Details

    • getInstance

      public static FeatureInstaller getInstance(WorkbenchContext context)
    • createLayersSelectedCheck

      public MultiEnableCheck createLayersSelectedCheck()
      Deprecated.
      Use the EnableCheckFactory methods instead
    • createOneLayerSelectedCheck

      public MultiEnableCheck createOneLayerSelectedCheck()
      Deprecated.
      Use the EnableCheckFactory methods instead
    • createVectorsExistCheck

      public MultiEnableCheck createVectorsExistCheck()
      Deprecated.
      Use the EnableCheckFactory methods instead
    • createFenceExistsCheck

      public MultiEnableCheck createFenceExistsCheck()
      Deprecated.
      Use the EnableCheckFactory methods instead
    • addMenuSeparator

      public void addMenuSeparator(String menu)
    • addMenuSeparator

      public void addMenuSeparator(String[] menuPath)
    • addMenuSeparator

      public void addMenuSeparator(JMenu menu)
    • addLayerViewMenuItem

      public void addLayerViewMenuItem(PlugIn executable, String menuName, String menuItemName)
      Deprecated.
    • addLayerNameViewMenuItem

      public void addLayerNameViewMenuItem(PlugIn executable, String menuName, String menuItemName)
      Deprecated.
    • addLayerViewMenuItem

      public void addLayerViewMenuItem(PlugIn executable, String[] menuPath, String menuItemName)
      Deprecated.
      Add a menu item to the main menu that is enabled only if the active internal frame is a LayerViewPanelProxy.
    • addLayerNameViewMenuItem

      public void addLayerNameViewMenuItem(PlugIn executable, String[] menuPath, String menuItemName)
      Deprecated.
      Add a menu item to the main menu that is enabled only if the active internal frame is a LayerViewPanelProxy and a LayerNamePanelProxy.
    • addMainMenuItem

      public void addMainMenuItem(PlugIn executable, String menuName, String menuItemName, Icon icon, EnableCheck enableCheck)
      Deprecated.
    • addMainMenu

      public JMenu addMainMenu(String[] menuPath, String menuName)
      Create and add a sub menu entry. index invalid input: '<' 0 adds it to the end.
      Parameters:
      menuPath - path of the Menu
      menuName - name of the Menu
      featureInstaller - the FeatureInstaller
      Returns:
      a JMenu
    • addMainMenuPlugin

      public JMenuItem addMainMenuPlugin(PlugIn executable, String[] menuPath)
    • addMainMenuPlugin

      public JMenuItem addMainMenuPlugin(PlugIn executable, String[] menuPath, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Convenience method without position parameter.
      See Also:
    • addMainMenuPlugin

      public JMenuItem addMainMenuPlugin(PlugIn executable, String[] menuPath, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck, int pos)
      Replacement for the retired methods above and below. Lot's of existing plugins depend on these methods. Rationale was to have the methods return the menuitem to the plugin for further manipulation invalid input: '&' attaching listeners etc. Unfortunately the return type is not part of the java method footprint, so we couldn't just change the return type but had to modify the name as well. Also the position parameter was added as it was needed anyway.
      Parameters:
      executable - the executable plugin
      menuPath - string array of sub menu entries to place the entry in
      menuItemName - name of the menu item
      checkBox - whether to create a JCheckBoxMenuItem or a JMenuItem
      icon - an Icon or null
      enableCheck - conditions to make the plugin available to the user
      pos - defines the position of the menu item in the menu
      See Also:
    • addMenuPlugin

      public JMenuItem addMenuPlugin(String menuKey, PlugIn plugin)
      a generic addMenu utility method, used in PluginManager all detailed settings are fetched from workbench properties and the plugin object.
      Parameters:
      menuKey - the key of the Menu to add this PlugIn to
      plugin - a PlugIn
      Returns:
      a new JMenuItem
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin)
      Deprecated.
      use addMainMenuPlugin() instead
      Add a Plugin as a JMenuItem with enableCheck conditions.
      Parameters:
      menuPath - path from the main menu to the menu item
      plugin - the plugin associated to this menu item
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin, int pos)
      Deprecated.
      use addMainMenuPlugin() instead
      Add a Plugin as a JMenuItem with enableCheck conditions.
      Parameters:
      menuPath - path from the main menu to the menu item
      plugin - the plugin associated to this menu item
      pos - defines the position of the menu item in the menu -1 adds menuItem at the end except for FILE menu where -1 adds menuItem before the separator preceding exit menu item
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin, EnableCheck enableCheck)
      Deprecated.
      use addMainMenuPlugin() instead
      Add a Plugin as a JMenuItem with enableCheck conditions.
      Parameters:
      menuPath - path from the main menu to the menu item
      plugin - the plugin associated to this menu item
      enableCheck - conditions making the plugin enabled
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin, EnableCheck enableCheck, int pos)
      Deprecated.
      use addMainMenuPlugin() instead
      Add a Plugin as a JMenuItem with enableCheck
      Parameters:
      menuPath - path from the main menu to the menu item
      plugin - the plugin associated to this menu item
      enableCheck - conditions making the plugin enabled
      pos - defines the position of the menu item in the menu -1 adds menuItem at the end except for FILE menu where -1 adds menuItem before the separator preceding exit menu item
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin, JMenuItem menuItem, int pos)
      Deprecated.
      use addMainMenuPlugin() instead
      Add a Plugin as a JMenuItem or a subclass of JMenuItem to the main menu
      Parameters:
      menuPath - path from the main menu to the menu item
      plugin - the plugin associated to this menu item
      menuItem - the menu item (JMenuItem, JCheckBoxMenuItem, JMenu, JRadioButtonMenuItem)
      pos - defines the position of the menu item in the menu -1 adds menuItem at the end except for FILE menu where -1 adds menuItem before the separator preceding exit menu item
    • addMainMenuItem

      public JMenuItem addMainMenuItem(String[] menuPath, AbstractUiPlugIn plugin, JMenuItem menuItem, EnableCheck enableCheck, int pos)
      Deprecated.
      use addMainMenuPlugin() instead
      New generic addMainMenuItem method using AbstractUiPlugIn.
      Parameters:
      menuPath - the menu path made of the menu and submenu names
      plugin - the plugin to execute with this item
      menuItem - the JMenuItem (or JCheckBoxMenuItem or JRadioButtonMenuItem) to the parent menu
      enableCheck - conditions making the plugin enabled
      pos - defines the position of the menu item in the menu -1 adds menuItem at the end except for FILE menu where -1 adds menuItem before the separator preceding exit menu item
    • addMainMenuItem

      public void addMainMenuItem(PlugIn executable, String[] menuPath, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Deprecated.
      Parameters:
      menuPath - separate items with slashes; items will be created if they do not already exist
      menuItemName - name of the menu item
      checkBox - whether to create a JCheckBoxMenuItem or a JMenuItem
      icon - an Icon or null
      enableCheck - conditions to make the plugin available to the user
      See Also:
    • addMainMenuItem

      public JMenuItem addMainMenuItem(PlugIn plugin, String[] menuPath, JMenuItem menuItem, EnableCheck enableCheck)
      Deprecated.
      use addMainMenuPlugin() instead
      New generic addMainMenuItem method. Adds menuItem at the end of the menu except for FILE menu where menuItem is added before the separator preceding exit menu item
      Parameters:
      plugin - the plugin to execute with this item
      menuPath - the menu path made of the menu and submenu names
      menuItem - the JMenuItem (or JCheckBoxMenuItem or JRadioButtonMenuItem) to the parent menu
      enableCheck - conditions making the plugin enabled
    • addMainMenuItem

      public JMenuItem addMainMenuItem(PlugIn plugin, String[] menuPath, JMenuItem menuItem, EnableCheck enableCheck, int pos)
      Deprecated.
      use addMainMenuPlugin() instead
      New generic addMainMenuItem method.
      Parameters:
      plugin - the plugin to execute with this item
      menuPath - the menu path made of the menu and submenu names
      menuItem - the JMenuItem (or JCheckBoxMenuItem or JRadioButtonMenuItem) to the parent menu
      enableCheck - conditions making the plugin enabled
      pos - defines the position of menuItem in the menu -1 adds menuItem at the end of the menu except for FILE menu where -1 adds menuItem before the separator preceding exit menuItem
    • addMenuItemShownListener

      public void addMenuItemShownListener(JMenuItem menuItem, MenuItemShownListener menuItemShownListener)
    • addPopupMenuPlugin

      public JMenuItem addPopupMenuPlugin(JPopupMenu popupMenu, PlugIn executable)
      Ultimate convenience method for attaching a plugin to a popupmenu.
      Parameters:
      popupMenu - a JPopupMenu
      executable - a PlugIn
      Returns:
      a JMenuItem to add in a PopupMenu
    • addPopupMenuPlugin

      public JMenuItem addPopupMenuPlugin(JPopupMenu popupMenu, PlugIn executable, String[] menuPath)
      Convenience method for entries with menupath
      Returns:
      menu item
    • addPopupMenuPlugin

      public JMenuItem addPopupMenuPlugin(JPopupMenu popupMenu, PlugIn executable, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Convenience method for entries without menupath
      Parameters:
      checkBox - true for item to be checkable
      enableCheck - , icon null to leave unspecified
      Returns:
      menu item
    • addPopupMenuPlugin

      public JMenuItem addPopupMenuPlugin(JPopupMenu popupMenu, PlugIn executable, String[] menuPath, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Analogue to addMainMenuPlugin(). Adds a plugin to a popup menu.
      Parameters:
      popupMenu - the PopupMenu to add the PlugIn to
      executable - the executable PlugIn
      menuPath - menu path of the PlugIn
      menuItemName - name of the menu item
      checkBox - true if this plugin must be marked with a CheckBox
      icon - icon for this PlugIn
      enableCheck - EnableCheck to (de/)activate the PlugIn
      Returns:
      a new JMenuItem
    • addPopupMenuItem

      public void addPopupMenuItem(JPopupMenu popupMenu, PlugIn executable, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Deprecated.
      use addPopupMenuPlugin instead
    • addPopupMenuItem

      public void addPopupMenuItem(JPopupMenu popupMenu, PlugIn executable, String[] menuPath, String menuItemName, boolean checkBox, Icon icon, EnableCheck enableCheck)
      Deprecated.
      use addPopupMenuPlugin instead
    • isSeparatingEnabled

      public boolean isSeparatingEnabled()
    • setSeparatingEnabled

      public void setSeparatingEnabled(boolean onoff)
    • updateSeparatorsInAllMenus

      public void updateSeparatorsInAllMenus()
    • fetchKeyForMenu

      public String fetchKeyForMenu(Object menu)
    • fetchMenuForKey

      public FeatureInstaller.Menu fetchMenuForKey(String key)
    • addPopupMenuSeparator

      public void addPopupMenuSeparator(JPopupMenu popupMenu, String[] menuPath)
    • popupMenu

      public static JMenu popupMenu(JPopupMenu popupMenu, String childName)
      Returns:
      the menu with the given name, or null if no such menu exists
    • wrapMenu

      public static FeatureInstaller.Menu wrapMenu(JPopupMenu popupMenu)
    • wrapMenu

      public static FeatureInstaller.Menu wrapMenu(JMenu menu)
    • wrapMenu

      public static FeatureInstaller.Menu wrapMenu(JMenuBar menu)
    • createMenusIfNecessary

      public FeatureInstaller.Menu createMenusIfNecessary(FeatureInstaller.Menu parent, String[] menuPath)
    • createMenusIfNecessary

      public FeatureInstaller.Menu createMenusIfNecessary(FeatureInstaller.Menu parent, String[] menuPath, Object[] menuPathPositions)
      Returns:
      the leaf
    • childMenuItem

      public static JMenuItem childMenuItem(String childName, FeatureInstaller.Menu menu)
      Find the first occurrence of a menu item with the given name and return it.
      Parameters:
      childName - name of the child MenuItem
      menu - Menu to add the child MenuItem to
      Returns:
      a new JMenuItem
    • childMenuItem

      public static JMenuItem childMenuItem(String itemName, FeatureInstaller.Menu menu, String[] menuPath)
      find the first occuring JMenuItem by childName in given Menu within given menuPath hierarchy, might return null if nothing was found
      Parameters:
      itemName -
      menu -
      menuPath -
      Returns:
    • registerShortcuts

      public boolean registerShortcuts(PlugIn plugin)
      Utility method to register global shortcuts. Should be preferred to the more direct approach using WorkbenchFrame.addKeyboardShortcut() .
      Parameters:
      plugin - a PlugIn
      Returns:
      true if shortcuts have been added for the PlugIn
    • fetchShortcutEnabledPlugins

      public static PlugIn[] fetchShortcutEnabledPlugins(PlugIn plugin)
      Convenience method to collect all plugins of a probably multi shortcut enabled plugin. Used to register multiple shortcut enabled plugins in one go.
      Parameters:
      plugin - a PlugIn
      Returns:
      plugins array
    • installMnemonic

      public static JMenuItem installMnemonic(JMenuItem menuItem, MenuElement parent)