Remote Systems
v6.4.1

com.ibm.etools.systems.core.ui
Class Mnemonics

java.lang.Object
  extended bycom.ibm.etools.systems.core.ui.Mnemonics

public class Mnemonics
extends Object

A class for creating unique mnemonics per control per window.


Field Summary
static String copyright
           
static char MNEMONIC_CHAR
           
 
Constructor Summary
Mnemonics()
           
 
Method Summary
static String applyMnemonic(String label, char mnemonicChar)
          Given a label and mnemonic, this applies that mnemonic to the label.
 void clear()
          Clear the list for re-use
 int findUniqueMnemonic(String label)
          Find a uniqe mnemonic char in given string.
static char getMnemonic(String text)
          Helper method to return the mnemonic from a string.
 boolean isUniqueMnemonic(char currchar)
          Determine if given char is a unique mnemonic
 String removeAndFreeMnemonic(String text)
          Remove and free up mnemonic
 void removeMnemonic(Button button)
          If a button is removed from a dialog window, call this method to remove its mnemonic from the list for this dialog.
 Mnemonics setApplyMnemonicsToPrecedingLabels(boolean apply)
          Set whether to apply mnemonics to labels preceding text fields, combos and inheritable entry fields.
 void setMnemonic(Button button)
          Adds a mnemonic to an SWT Button such that the user can select it via Ctrl/Alt+mnemonic.
 void setMnemonics(Composite parent)
          Given a Composite, this method walks all the children recursively and and sets the mnemonics uniquely for each child control where a mnemonic makes sense (eg, buttons).
 void setMnemonicsAndArmListener(Menu menu, ArmListener listener)
          Given a menu, this method walks all the items and assigns each a unique memnonic.
 Mnemonics setOnPreferencePage(boolean page)
          Set if the mnemonics are for a preference page Preference pages already have a few buttons with mnemonics set by Eclipse We have to make sure we do not use the ones they use
 Mnemonics setOnWizardPage(boolean page)
          Set if the mnemonics are for a wizard page Wizard pages already have a few buttons with mnemonics set by Eclipse We have to make sure we do not use the ones they use
 String setUniqueMnemonic(String label)
          Given a string, this starts at the first character and iterates until it finds a character not previously used as a mnemonic on this page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

MNEMONIC_CHAR

public static final char MNEMONIC_CHAR
See Also:
Constant Field Values
Constructor Detail

Mnemonics

public Mnemonics()
Method Detail

clear

public void clear()
Clear the list for re-use


setUniqueMnemonic

public String setUniqueMnemonic(String label)
Given a string, this starts at the first character and iterates until it finds a character not previously used as a mnemonic on this page. Not normally called from other classes, but rather by the setMnemonic methods in this class.

Parameters:
label - String to which to generate and apply the mnemonic
Returns:
input String with '&' inserted in front of the unique character

applyMnemonic

public static String applyMnemonic(String label,
                                   char mnemonicChar)
Given a label and mnemonic, this applies that mnemonic to the label. Not normally called from other classes, but rather by the setUniqueMnemonic methods in this class.

Parameters:
label - String to which to apply the mnemonic
mnemonicChar - the character that is to be the mnemonic character
Returns:
input String with '&' inserted in front of the given character

isUniqueMnemonic

public boolean isUniqueMnemonic(char currchar)
Determine if given char is a unique mnemonic


findUniqueMnemonic

public int findUniqueMnemonic(String label)
Find a uniqe mnemonic char in given string. Note if one is found, it is added to the list of currently used mnemonics!

Returns:
index position of unique character in input string, or -1 if none found.

setMnemonic

public void setMnemonic(Button button)
Adds a mnemonic to an SWT Button such that the user can select it via Ctrl/Alt+mnemonic. Note a mnemonic unique to this window is chosen


removeMnemonic

public void removeMnemonic(Button button)
If a button is removed from a dialog window, call this method to remove its mnemonic from the list for this dialog. This frees it up for another button to use.


removeAndFreeMnemonic

public String removeAndFreeMnemonic(String text)
Remove and free up mnemonic


getMnemonic

public static char getMnemonic(String text)
Helper method to return the mnemonic from a string. Helpful when it is necessary to know the mnemonic assigned so it can be reassigned, such as is necessary for buttons which toggle their text.

Returns:
the mnemonic if assigned, else a blank character.

setMnemonics

public void setMnemonics(Composite parent)
Given a Composite, this method walks all the children recursively and and sets the mnemonics uniquely for each child control where a mnemonic makes sense (eg, buttons). The letter/digit chosen for the mnemonic is unique for this Composite, so you should call this on as high a level of a composite as possible per Window. Call this after populating your controls.


setMnemonicsAndArmListener

public void setMnemonicsAndArmListener(Menu menu,
                                       ArmListener listener)
Given a menu, this method walks all the items and assigns each a unique memnonic. Also handles casdading submenus.

Also, since while we are at it, this overloaded method also sets a given ArmListener to each menu item, perhaps for the purpose of displaying tooltip text. It makes sense to do this when doing mnemonics because both must be done for every menu item with text and must be done exactly once for each.

Call this after populating the menu.


setOnPreferencePage

public Mnemonics setOnPreferencePage(boolean page)
Set if the mnemonics are for a preference page Preference pages already have a few buttons with mnemonics set by Eclipse We have to make sure we do not use the ones they use


setOnWizardPage

public Mnemonics setOnWizardPage(boolean page)
Set if the mnemonics are for a wizard page Wizard pages already have a few buttons with mnemonics set by Eclipse We have to make sure we do not use the ones they use


setApplyMnemonicsToPrecedingLabels

public Mnemonics setApplyMnemonicsToPrecedingLabels(boolean apply)
Set whether to apply mnemonics to labels preceding text fields, combos and inheritable entry fields. This is for consistency with Eclipse. Only set to false if it does not work in your dialog, wizard, preference or property page, i.e. you have labels preceding these widgets that do not necessarily refer to them.

Parameters:
apply - true to apply mnemonic to preceding labels, false otherwise.
Returns:
this instance, for convenience

Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.