de.cau.cs.kieler.core.kivi.menu
Class KiviMenuContributionService

java.lang.Object
  extended by de.cau.cs.kieler.core.kivi.menu.KiviMenuContributionService

public class KiviMenuContributionService
extends Object

A simple programmatic API to specify toolbar buttons to be used with the KIELER View Management.

Rating red

Nested Class Summary
static class KiviMenuContributionService.ButtonConfiguration
          A container class for configurations for buttons.
static class KiviMenuContributionService.LocationScheme
          A location scheme enumeration allowing to determine the locations of KIVi menu contributions.
 
Field Summary
static KiviMenuContributionService INSTANCE
          Singleton instance of this service.
 
Constructor Summary
KiviMenuContributionService()
           
 
Method Summary
 void addSeparator(String id, KiviMenuContributionService.LocationScheme locationSchemeExpression, Expression visibilityExpression, String... activeEditors)
          Add a separator button configuration.
 void addToolbarButton(ICombination responsibleCombination, String id, String label)
          Add the simplest button configuration possible.
 void addToolbarButton(ICombination responsibleCombination, String id, String tooltip, ImageDescriptor icon, String... activeEditors)
          Add a button configuration with only a few parameters.
 void addToolbarButton(ICombination responsibleCombination, String id, String label, String tooltip, ImageDescriptor icon, int style, KiviMenuContributionService.LocationScheme locationSchemeExpression, Expression visibilityExpression, KeySequence keySequence, String shortcutContext, String... activeEditors)
          Add a button configuration with all possible parameters.
 KiviMenuContributionService.ButtonConfiguration getButtonConfiguration(String id)
          Get a ButtonCnfiguration with the given ID.
 List<KiviMenuContributionService.ButtonConfiguration> getButtonConfigurations()
          Get the list of registered ButtonConfigurations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final KiviMenuContributionService INSTANCE
Singleton instance of this service.

Constructor Detail

KiviMenuContributionService

public KiviMenuContributionService()
Method Detail

addToolbarButton

public void addToolbarButton(ICombination responsibleCombination,
                             String id,
                             String label,
                             String tooltip,
                             ImageDescriptor icon,
                             int style,
                             KiviMenuContributionService.LocationScheme locationSchemeExpression,
                             Expression visibilityExpression,
                             KeySequence keySequence,
                             String shortcutContext,
                             String... activeEditors)
Add a button configuration with all possible parameters.

Parameters:
responsibleCombination - the KiVi Combination which is responsible for this button. the button will be made invisible if the combination gets deactivated
id - the ID that the button should get. Need to identify the button lateron with this ID
label - an optional label for the button. May be null. Either the label or the icon should be specified.
tooltip - a tooltip for the button, may be null
icon - the icon for the button, may be null. Either the label or the icon should be specified. An Image descriptor can be obtained by the plugin activator with the plugin ID and the relative path of the icon within that plugin.
style - a SWT style constant, either SWT.PUSH, SWT.RADIO or SWT.CHECK
locationSchemeExpression - a KiviMenuContributionService.LocationScheme enumeration value indicating the locations the button is to be attached to
visibilityExpression - an eclipse core Expression that gets registered as visibility expression, may be null
keySequence - a keySequence for binding a key combination to the command of this button, may be null
shortcutContext - the context in which the shortcut defined by the keySequence should be active, may be null and will default to org.eclipse.ui.contexts.window
activeEditors - Strings of editor IDs for which this button should be made visible only, parameter to avoid using the visibilityExpression, may be left

addSeparator

public void addSeparator(String id,
                         KiviMenuContributionService.LocationScheme locationSchemeExpression,
                         Expression visibilityExpression,
                         String... activeEditors)
Add a separator button configuration.

Parameters:
id - the ID that the separator should get. Need to identify the button lateron with this ID
locationSchemeExpression - a KiviMenuContributionService.LocationScheme enumeration value indicating the locations the button is to be attached to
visibilityExpression - an eclipse core Expression that gets registered as visibility expression, may be null
activeEditors - Strings of editor IDs for which this button should be made visible only, parameter to avoid using the visibilityExpression, may be left

addToolbarButton

public void addToolbarButton(ICombination responsibleCombination,
                             String id,
                             String tooltip,
                             ImageDescriptor icon,
                             String... activeEditors)
Add a button configuration with only a few parameters.

Parameters:
responsibleCombination - the KiVi Combination which is responsible for this button. the button will be made invisible if the combination gets deactivated
id - the ID that the button should get. Need to identify the button lateron with this ID
tooltip - a tooltip for the button, may be null
icon - the icon for the button, may be null. Either the label or the icon should be specified. An Image descriptor can be obtained by the plugin activator with the plugin ID and the relative path of the icon within that plugin.
activeEditors - Strings of editor IDs for which this button should be made visible only, parameter to avoid using the visibilityExpression, may be left

addToolbarButton

public void addToolbarButton(ICombination responsibleCombination,
                             String id,
                             String label)
Add the simplest button configuration possible. Usually used only for quick testing.

Parameters:
responsibleCombination - the KiVi Combination which is responsible for this button. the button will be made invisible if the combination gets deactivated
id - the ID that the button should get. Need to identify the button lateron with this ID
label - an optional label for the button. May be null. Either the label or the icon should be specified.

getButtonConfigurations

public List<KiviMenuContributionService.ButtonConfiguration> getButtonConfigurations()
Get the list of registered ButtonConfigurations.

Returns:
all registered ButtonConfigurations

getButtonConfiguration

public KiviMenuContributionService.ButtonConfiguration getButtonConfiguration(String id)
Get a ButtonCnfiguration with the given ID.

Parameters:
id - given ID
Returns:
null if there is no config registered for the given ID