1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

[cleanup] Fix Javadoc

This commit is contained in:
Martin Oberhuber 2008-04-09 20:18:53 +00:00
parent e8275c719b
commit 080b1790a5

View file

@ -1,15 +1,15 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [187860] review for adding foreign lang support * Martin Oberhuber (Wind River) - [187860] review for adding foreign lang support
********************************************************************************/ ********************************************************************************/
@ -48,7 +48,7 @@ import com.ibm.icu.lang.UCharacter.UnicodeBlock;
import com.ibm.icu.util.ULocale; import com.ibm.icu.util.ULocale;
/** /**
* Instances of this class may be used to supply mnemonics to the * Instances of this class may be used to supply mnemonics to the
* text for controls. * text for controls.
* There are preferences which can be set by products to control how * There are preferences which can be set by products to control how
* these mnemonics are generated and applied. * these mnemonics are generated and applied.
@ -59,7 +59,7 @@ import com.ibm.icu.util.ULocale;
* is added to the end of the label (but prior to any punctuation or accelerators) * is added to the end of the label (but prior to any punctuation or accelerators)
* and is of the form (X). * and is of the form (X).
* <p> * <p>
* The org.eclipse.rse.ui/MNEMONICS_POLICY preference establishes the * The org.eclipse.rse.ui/MNEMONICS_POLICY preference establishes the
* desire to generated embedded mnemonics using letters that already * desire to generated embedded mnemonics using letters that already
* exist in the text of the controls and/or to generate appended mnemonics * exist in the text of the controls and/or to generate appended mnemonics
* if an embedded mnemonic cannot be found or is not desired. * if an embedded mnemonic cannot be found or is not desired.
@ -68,8 +68,8 @@ import com.ibm.icu.util.ULocale;
* See {@link #POLICY_DEFAULT} for the default policy value. * See {@link #POLICY_DEFAULT} for the default policy value.
* A policy value of 0 will disable the generation of all mnemonics. * A policy value of 0 will disable the generation of all mnemonics.
* <p> * <p>
* The org.eclipse.rse.ui/APPEND_MNEMONICS_PATTERN preference is used to * The org.eclipse.rse.ui/APPEND_MNEMONICS_PATTERN preference is used to
* further qualify the appending behavior by the current locale. If the * further qualify the appending behavior by the current locale. If the
* current locale name matches this pattern then appending can be performed. * current locale name matches this pattern then appending can be performed.
* See {@link #APPEND_MNEMONICS_PATTERN_DEFAULT} for the default pattern. * See {@link #APPEND_MNEMONICS_PATTERN_DEFAULT} for the default pattern.
* <p> * <p>
@ -77,15 +77,15 @@ import com.ibm.icu.util.ULocale;
* least used mnemonic when finding a duplicate. * least used mnemonic when finding a duplicate.
*/ */
public class Mnemonics { public class Mnemonics {
/** /**
* An option bit mask - value 1. * An option bit mask - value 1.
* If on, specifies whether or not to insert mnemonic indications into * If on, specifies whether or not to insert mnemonic indications into
* the current text of a label. * the current text of a label.
* If off, all other options are ignored. * If off, all other options are ignored.
*/ */
public static final int EMBED_MNEMONICS = 1; public static final int EMBED_MNEMONICS = 1;
/** /**
* An option bit mask - value 2. * An option bit mask - value 2.
* If on, specifies to generate mnemonics of the form (X) at the end of labels for * If on, specifies to generate mnemonics of the form (X) at the end of labels for
@ -93,10 +93,10 @@ public class Mnemonics {
* If off, then only characters from the label will be used as mnemonics. * If off, then only characters from the label will be used as mnemonics.
*/ */
public static final int APPEND_MNEMONICS = 2; public static final int APPEND_MNEMONICS = 2;
/** /**
* The simple name of the preference that holds the pattern to be used for matching * 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. * against the locale to determine if APPEND_MNEMONICS option applies.
*/ */
public static final String APPEND_MNEMONICS_PATTERN_PREFERENCE = "APPEND_MNEMONICS_PATTERN"; //$NON-NLS-1$ public static final String APPEND_MNEMONICS_PATTERN_PREFERENCE = "APPEND_MNEMONICS_PATTERN"; //$NON-NLS-1$
@ -106,7 +106,7 @@ public class Mnemonics {
* The default pattern matches Chinese, Japanese, and Korean. * The default pattern matches Chinese, Japanese, and Korean.
*/ */
public static final String APPEND_MNEMONICS_PATTERN_DEFAULT = "zh.*|ja.*|ko.*"; //$NON-NLS-1$ public static final String APPEND_MNEMONICS_PATTERN_DEFAULT = "zh.*|ja.*|ko.*"; //$NON-NLS-1$
/** /**
* The simple name of the preference that determines the policy to be used when applying mnemonics to menus and composites. * The simple name of the preference that determines the policy to be used when applying mnemonics to menus and composites.
*/ */
@ -114,11 +114,11 @@ public class Mnemonics {
/** /**
* The default mnemonics policy. If no policy is specified in a call to generate * 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 * mnemonics this policy will be used. Can be overridden by the
* org.eclipse.rse.ui/MNEMONICS_POLICY preference. * org.eclipse.rse.ui/MNEMONICS_POLICY preference.
*/ */
public static final int POLICY_DEFAULT = EMBED_MNEMONICS | APPEND_MNEMONICS; public static final int POLICY_DEFAULT = EMBED_MNEMONICS | APPEND_MNEMONICS;
private static final char MNEMONIC_CHAR = '&'; private static final char MNEMONIC_CHAR = '&';
/* /*
@ -126,14 +126,14 @@ public class Mnemonics {
*/ */
private static final String LC_GREEK = "el"; //$NON-NLS-1$ private static final String LC_GREEK = "el"; //$NON-NLS-1$
private static final String LC_RUSSIAN = "ru"; //$NON-NLS-1$ private static final String LC_RUSSIAN = "ru"; //$NON-NLS-1$
/* /*
* Known valid mnemonic candidates * Known valid mnemonic candidates
*/ */
private static final String GREEK_MNEMONICS = "\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039a\u039b\u039c\u039d\u039e\u039f\u03a0\u03a1\u03a3\u03a4\u03a5\u03a6\u03a7\u03a8\u03a9"; //$NON-NLS-1$ private static final String GREEK_MNEMONICS = "\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039a\u039b\u039c\u039d\u039e\u039f\u03a0\u03a1\u03a3\u03a4\u03a5\u03a6\u03a7\u03a8\u03a9"; //$NON-NLS-1$
private static final String RUSSIAN_MNEMONICS = "\u0410\u0411\u0412\u0413\u0414\u0145\u0401\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f"; //$NON-NLS-1$ private static final String RUSSIAN_MNEMONICS = "\u0410\u0411\u0412\u0413\u0414\u0145\u0401\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f"; //$NON-NLS-1$
private static final String LATIN_MNEMONICS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$ private static final String LATIN_MNEMONICS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
private final static Pattern TRANSPARENT_ENDING_PATTERN = Pattern.compile("(\\s|\\.\\.\\.|>|<|:|\uff0e\uff0e\uff0e|\uff1e|\uff1c|\uff1a|\\t.*)+$"); //$NON-NLS-1$ private final static Pattern TRANSPARENT_ENDING_PATTERN = Pattern.compile("(\\s|\\.\\.\\.|>|<|:|\uff0e\uff0e\uff0e|\uff1e|\uff1c|\uff1a|\\t.*)+$"); //$NON-NLS-1$
private boolean applyMnemonicsToPrecedingLabels = true; private boolean applyMnemonicsToPrecedingLabels = true;
@ -195,7 +195,7 @@ public class Mnemonics {
} }
return text; return text;
} }
/** /**
* Finds the point at which to insert a mnemonic of the form (&X). * Finds the point at which to insert a mnemonic of the form (&X).
* Checks for transparent endings. * Checks for transparent endings.
@ -214,16 +214,19 @@ public class Mnemonics {
public void clear() { public void clear() {
usedCharacters.clear(); usedCharacters.clear();
} }
/** /**
* Resets the list of used mnemonic characters to those in the string. * Resets the list of used mnemonic characters to those in the string.
* @param usedMnemonics *
* @param usedMnemonics A String listing the characters to mark used as
* mnemonics. Each character will be considered in a case
* insensitive manner.
*/ */
public void clear(String usedMnemonics) { public void clear(String usedMnemonics) {
clear(); clear();
makeUsed(usedMnemonics); makeUsed(usedMnemonics);
} }
/** /**
* Sets a mnemonic in the given string and returns the result. * Sets a mnemonic in the given string and returns the result.
* Functions according to the default policy as specified in * Functions according to the default policy as specified in
@ -241,7 +244,7 @@ public class Mnemonics {
String result = setUniqueMnemonic(label, flags, localePattern, false); String result = setUniqueMnemonic(label, flags, localePattern, false);
return result; return result;
} }
/** /**
* Given a string, this starts at the first character and iterates until * Given a string, this starts at the first character and iterates until
* it finds a character not already used as a mnemonic. * it finds a character not already used as a mnemonic.
@ -261,7 +264,7 @@ public class Mnemonics {
if (flags == 0 || label == null || label.trim().length() == 0 || label.equals("?")) { //$NON-NLS-1$ if (flags == 0 || label == null || label.trim().length() == 0 || label.equals("?")) { //$NON-NLS-1$
return label; return label;
} }
StringBuffer buffer = new StringBuffer(label); StringBuffer buffer = new StringBuffer(label);
char mn = getMnemonic(label); char mn = getMnemonic(label);
if (mn == ' ' && ((flags & EMBED_MNEMONICS) > 0)) { // no mnemonic exists, try embedding if (mn == ' ' && ((flags & EMBED_MNEMONICS) > 0)) { // no mnemonic exists, try embedding
int p = findUniqueMnemonic(label); int p = findUniqueMnemonic(label);
@ -287,7 +290,7 @@ public class Mnemonics {
} }
} }
if (mn == ' ' && ((flags & APPEND_MNEMONICS) > 0)) { // no mnemonic exists, try appending a mnemonic if (mn == ' ' && ((flags & APPEND_MNEMONICS) > 0)) { // no mnemonic exists, try appending a mnemonic
String localeName = ULocale.getDefault().getName(); String localeName = ULocale.getDefault().getName();
if (localeName.matches(localePattern)) { if (localeName.matches(localePattern)) {
String candidates = getCandidates(); String candidates = getCandidates();
int p = findUniqueMnemonic(candidates); int p = findUniqueMnemonic(candidates);
@ -311,27 +314,27 @@ public class Mnemonics {
public boolean isUniqueMnemonic(char ch) { public boolean isUniqueMnemonic(char ch) {
return timesUsed(ch) == 0; return timesUsed(ch) == 0;
} }
private Preferences getPreferences() { private Preferences getPreferences() {
return RSEUIPlugin.getDefault().getPluginPreferences(); return RSEUIPlugin.getDefault().getPluginPreferences();
} }
private String getLocalePattern() { private String getLocalePattern() {
return getPreferences().getString(APPEND_MNEMONICS_PATTERN_PREFERENCE); return getPreferences().getString(APPEND_MNEMONICS_PATTERN_PREFERENCE);
} }
private int getPolicy() { private int getPolicy() {
return getPreferences().getInt(POLICY_PREFERENCE); return getPreferences().getInt(POLICY_PREFERENCE);
} }
private boolean isEmbedding() { private boolean isEmbedding() {
return (getPolicy() & EMBED_MNEMONICS) > 0; return (getPolicy() & EMBED_MNEMONICS) > 0;
} }
private boolean isAppending() { private boolean isAppending() {
return (getPolicy() & APPEND_MNEMONICS) > 0; return (getPolicy() & APPEND_MNEMONICS) > 0;
} }
/** /**
* @return a string of acceptable mnemonic candidates for the language * @return a string of acceptable mnemonic candidates for the language
* of the current locale. * of the current locale.
@ -366,13 +369,13 @@ public class Mnemonics {
} }
return uniqueIndex; return uniqueIndex;
} }
private boolean isAcceptable(char ch) { private boolean isAcceptable(char ch) {
UnicodeBlock block = UnicodeBlock.of(ch); UnicodeBlock block = UnicodeBlock.of(ch);
boolean result = (isAcceptable(block) && UCharacter.isLetter(ch)); // the character is a letter boolean result = (isAcceptable(block) && UCharacter.isLetter(ch)); // the character is a letter
return result; return result;
} }
private boolean isAcceptable(UnicodeBlock block) { private boolean isAcceptable(UnicodeBlock block) {
if (block == UnicodeBlock.BASIC_LATIN) return true; if (block == UnicodeBlock.BASIC_LATIN) return true;
if (block == UnicodeBlock.LATIN_1_SUPPLEMENT) return true; if (block == UnicodeBlock.LATIN_1_SUPPLEMENT) return true;
@ -386,7 +389,7 @@ public class Mnemonics {
if (block == UnicodeBlock.ARABIC) return true; if (block == UnicodeBlock.ARABIC) return true;
return false; return false;
} }
/** /**
* Returns the number of times a given character is used as a mnemonic in this * Returns the number of times a given character is used as a mnemonic in this
* context. * context.
@ -402,7 +405,7 @@ public class Mnemonics {
} }
return result; return result;
} }
private void makeUsed(char ch) { private void makeUsed(char ch) {
// TODO if we are guaranteed java 1.5 we can use Character.valueOf(ch) // TODO if we are guaranteed java 1.5 we can use Character.valueOf(ch)
if (ch != ' ') { if (ch != ' ') {
@ -410,7 +413,7 @@ public class Mnemonics {
makeUsed(new Character(Character.toUpperCase(ch))); makeUsed(new Character(Character.toUpperCase(ch)));
} }
} }
private void makeUsed(Character ch) { private void makeUsed(Character ch) {
Integer count = (Integer) usedCharacters.get(ch); Integer count = (Integer) usedCharacters.get(ch);
if (count == null) { if (count == null) {
@ -418,13 +421,13 @@ public class Mnemonics {
} }
usedCharacters.put(ch, count); usedCharacters.put(ch, count);
} }
private void makeUsed(String s) { private void makeUsed(String s) {
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
makeUsed(s.charAt(i)); makeUsed(s.charAt(i));
} }
} }
/** /**
* Returns a string with the mnemonics for a given array of strings. * Returns a string with the mnemonics for a given array of strings.
* @param strings the array of strings. * @param strings the array of strings.
@ -524,7 +527,7 @@ public class Mnemonics {
processMenuItems(appendingItems, APPEND_MNEMONICS, localePattern); processMenuItems(appendingItems, APPEND_MNEMONICS, localePattern);
} }
} }
private void processMenuItems(Collection collection, int flags, String localePattern) { private void processMenuItems(Collection collection, int flags, String localePattern) {
for (Iterator z = collection.iterator(); z.hasNext();) { for (Iterator z = collection.iterator(); z.hasNext();) {
MenuItem menuItem = (MenuItem) z.next(); MenuItem menuItem = (MenuItem) z.next();
@ -539,13 +542,13 @@ public class Mnemonics {
} }
} }
} }
/** /**
* Given a Composite, this method walks all the children recursively and * Given a Composite, this method walks all the children recursively and
* and sets the mnemonics uniquely for each child control where a * and sets the mnemonics uniquely for each child control where a
* mnemonic makes sense (eg, buttons). * mnemonic makes sense (eg, buttons).
* The letter/digit chosen for the mnemonic is unique for this Composite, * 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 * so you should call this on as high a level of a composite as possible
* per window. * per window.
* Call this after populating your controls. * Call this after populating your controls.
* @param parent the parent control to examine. * @param parent the parent control to examine.
@ -553,17 +556,17 @@ public class Mnemonics {
public void setMnemonics(Composite parent) { public void setMnemonics(Composite parent) {
setMnemonics(parent, new HashSet()); setMnemonics(parent, new HashSet());
} }
/** /**
* Given a Composite, this method walks all the children recursively and * Given a Composite, this method walks all the children recursively and
* and sets the mnemonics uniquely for each child control where a * and sets the mnemonics uniquely for each child control where a
* mnemonic makes sense (for example, buttons). * mnemonic makes sense (for example, buttons).
* The letter/digit chosen for the mnemonic is unique for this Composite, * 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 * so you should call this on as high a level of a composite as possible
* per window. * per window.
* Call this after populating your controls. * Call this after populating your controls.
* @param parent the parent control to examine. * @param parent the parent control to examine.
* @param ignoredControls the set of controls in which to not set mnemonics. * @param ignoredControls the set of controls in which to not set mnemonics.
* If the controls are composites, their children are also not examined. * If the controls are composites, their children are also not examined.
*/ */
public void setMnemonics(Composite parent, Set ignoredControls) { public void setMnemonics(Composite parent, Set ignoredControls) {
@ -573,7 +576,7 @@ public class Mnemonics {
parent.layout(true); parent.layout(true);
} }
} }
private boolean setCompositeMnemonics(Composite parent, Set ignoredControls) { private boolean setCompositeMnemonics(Composite parent, Set ignoredControls) {
Control children[] = parent.getChildren(); Control children[] = parent.getChildren();
Control currentChild = null; Control currentChild = null;
@ -608,7 +611,7 @@ public class Mnemonics {
} }
return mustLayout; return mustLayout;
} }
private void gatherCompositeMnemonics(Composite parent) { private void gatherCompositeMnemonics(Composite parent) {
Control children[] = parent.getChildren(); Control children[] = parent.getChildren();
Control currentChild = null; Control currentChild = null;
@ -632,8 +635,8 @@ public class Mnemonics {
} }
} }
} }
/** /**
* Set if the mnemonics are for a preference page * Set if the mnemonics are for a preference page
* Preference pages already have a few buttons with mnemonics set by Eclipse * 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 * We have to make sure we do not use the ones they use
@ -647,7 +650,7 @@ public class Mnemonics {
return this; return this;
} }
/** /**
* Set if the mnemonics are for a wizard page * Set if the mnemonics are for a wizard page
* Wizard pages already have a few buttons with mnemonics set by Eclipse * 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 * We have to make sure we do not use the ones they use