Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.ui
Class Mnemonics

java.lang.Object
  extended by 
org.eclipse.rse.ui.Mnemonics

public class Mnemonics
extends Object

Instances of this class may be used to supply mnemonics to the text for controls. There are preferences which can be set by products to control how these mnemonics are generated and applied.

There are two types of mnemonics which can be added to a label: embedded mnemonics and appended mnemonics. An embedded mnemonic uses an existing letter in the label for the mnemonic. An appended mnemonic is added to the end of the label (but prior to any punctuation or accelerators) and is of the form (X).

The org.eclipse.rse.ui/MNEMONICS_POLICY preference establishes the desire to generated embedded mnemonics using letters that already exist in the text of the controls and/or to generate appended mnemonics if an embedded mnemonic cannot be found or is not desired. The policy is composed of bit flags. See EMBED_MNEMONICS and APPEND_MNEMONICS for the flag values. See POLICY_DEFAULT for the default policy value. A policy value of 0 will disable the generation of all mnemonics.

The org.eclipse.rse.ui/APPEND_MNEMONICS_PATTERN preference is used to further qualify the appending behavior by the current locale. If the current locale name matches this pattern then appending can be performed. See APPEND_MNEMONICS_PATTERN_DEFAULT for the default pattern.

Mnemonics on menus are allowed to have duplicates. Attempts are made to find the least used mnemonic when finding a duplicate.


Field Summary
static int APPEND_MNEMONICS
          An option bit mask - value 2.
static  String APPEND_MNEMONICS_PATTERN_DEFAULT
          Some products will to append mnemonics only for certain locales.
static  String APPEND_MNEMONICS_PATTERN_PREFERENCE
          The simple name of the preference that holds the pattern to be used for matching against the locale to determine if APPEND_MNEMONICS option applies.
static int EMBED_MNEMONICS
          An option bit mask - value 1.
static int POLICY_DEFAULT
          The default mnemonics policy.
static  String POLICY_PREFERENCE
          The simple name of the preference that determines the policy to be used when applying mnemonics to menus and composites.
 
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 of used mnemonic characters
 void clear ( String usedMnemonics)
          Resets the list of used mnemonic characters to those in the string.
static char getMnemonic ( String text)
          Helper method to return the mnemonic from a string.
 boolean isUniqueMnemonic (char ch)
          Determine if given char is a unique mnemonic.
static  String removeMnemonic ( String text)
          Helper method to strip the mnemonic from a string.
  Mnemonics setApplyMnemonicsToPrecedingLabels (boolean apply)
          Set whether to apply mnemonics to labels preceding text fields, combos and inheritable entry fields.
 boolean 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 setMnemonics ( Composite parent, Set ignoredControls)
          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 (for example, buttons).
 void setMnemonics ( Menu menu)
          Given a menu, this method walks all the items and assigns each a mnemonic.
  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)
          Sets a mnemonic in the given string and returns the result.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMBED_MNEMONICS

public static final int EMBED_MNEMONICS
An option bit mask - value 1. If on, specifies whether or not to insert mnemonic indications into the current text of a label. If off, all other options are ignored.

See Also:
Constant Field Values

APPEND_MNEMONICS

public static final int APPEND_MNEMONICS
An option bit mask - value 2. If on, specifies to generate mnemonics of the form (X) at the end of labels for those languages matching the locale pattern. If off, then only characters from the label will be used as mnemonics.

See Also:
Constant Field Values

APPEND_MNEMONICS_PATTERN_PREFERENCE

public static final 
String APPEND_MNEMONICS_PATTERN_PREFERENCE
The simple name of the preference that holds the pattern to be used for matching against the locale to determine if APPEND_MNEMONICS option applies.

See Also:
Constant Field Values

APPEND_MNEMONICS_PATTERN_DEFAULT

public static final 
String APPEND_MNEMONICS_PATTERN_DEFAULT
Some products will to append mnemonics only for certain locales. The following provides the default pattern for matching the locale. The default pattern matches Chinese, Japanese, and Korean.

See Also:
Constant Field Values

POLICY_PREFERENCE

public static final 
String POLICY_PREFERENCE
The simple name of the preference that determines the policy to be used when applying mnemonics to menus and composites.

See Also:
Constant Field Values

POLICY_DEFAULT

public static final int POLICY_DEFAULT
The default mnemonics policy. If no policy is specified in a call to generate mnemonics this policy will be used. Can be overridden by the org.eclipse.rse.ui/MNEMONICS_POLICY preference.

See Also:
Constant Field Values
Constructor Detail

Mnemonics

public Mnemonics()
Method Detail

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.

Parameters:
text - the label from which to extract the mnemonic
Returns:
the mnemonic if assigned, else a blank 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, or with "(c)" appended to the label at a proper position in case the character c is not part of the label.

removeMnemonic

public static 
String removeMnemonic(
String text)
Helper method to strip the mnemonic from a string. Useful if using Eclipse supplied labels.

Parameters:
text - the label from which to strip the mnemonic
Returns:
the label with the mnemonic stripped

clear

public void clear()
Clear the list of used mnemonic characters


clear

public void clear(
String usedMnemonics)
Resets the list of used mnemonic characters to those in the string.

Parameters:
usedMnemonics - A String listing the characters to mark used as mnemonics. Each character will be considered in a case insensitive manner.

setUniqueMnemonic

public 
String setUniqueMnemonic(
String label)
Sets a mnemonic in the given string and returns the result. Functions according to the default policy as specified in Sets the mnemonic according to the org.eclipse.rse.ui/MNEMONICS_POLICY preference. Not normally called from other classes, but rather by the setMnemonic methods in this class.

Parameters:
label - The string to which to apply the mnemonic
Returns:
the result string with the mnemonic embedded or appended

isUniqueMnemonic

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

Parameters:
ch - the character to test.
Returns:
true if the character has not yet been used.

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

setMnemonic

public boolean 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.

Parameters:
button - the button to equip with a mnemonic
Returns:
true if the button was actually changed

setMnemonics

public void setMnemonics(
Menu menu)
Given a menu, this method walks all the items and assigns each a mnemonic. Note that menu item mnemonics do not have to be unique. The mnemonics used on cascaded menus are independent of those of the parent. Handles cascading menus. Call this after populating the menu.

Parameters:
menu - the menu to examine

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.

Parameters:
parent - the parent control to examine.

setMnemonics

public void setMnemonics(
Composite parent,
                         
Set ignoredControls)
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 (for example, 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.

Parameters:
parent - the parent control to examine.
ignoredControls - the set of controls in which to not set mnemonics. If the controls are composites, their children are also not examined.

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


RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire