⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 legacyactiontools.java

📁 jfa2ce 源码帮助开发人员更好的理解运用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	}	/**	 * Maps standard keyboard modifier key names to the corresponding SWT	 * modifier bit. The following modifier key names are recognized (case is	 * ignored): <code>"CTRL"</code>, <code>"SHIFT"</code>,	 * <code>"ALT"</code>, and <code>"COMMAND"</code>. The given modifier	 * key name is converted to upper case before comparison.	 * 	 * @param token	 *            the modifier key name	 * @return the SWT modifier bit, or <code>0</code> if no match was found	 * @see SWT	 */	public static final int findModifier(String token) {		token = token.toUpperCase();		if (token.equals("CTRL")) { //$NON-NLS-1$			return SWT.CTRL;		}		if (token.equals("SHIFT")) { //$NON-NLS-1$			return SWT.SHIFT;		}		if (token.equals("ALT")) { //$NON-NLS-1$			return SWT.ALT;		}		if (token.equals("COMMAND")) { //$NON-NLS-1$			return SWT.COMMAND;		}		return 0;	}	/**	 * Returns a string representation of an SWT modifier bit (SWT.CTRL,	 * SWT.ALT, SWT.SHIFT, and SWT.COMMAND). Returns <code>null</code> if the	 * key code is not an SWT modifier bit.	 * 	 * @param keyCode	 *            the SWT modifier bit to be translated	 * @return the string representation of the SWT modifier bit, or	 *         <code>null</code> if the key code was not an SWT modifier bit	 * @see SWT	 */	public static final String findModifierString(final int keyCode) {		if (keyCode == SWT.CTRL) {			return JFaceResources.getString("Ctrl"); //$NON-NLS-1$		}		if (keyCode == SWT.ALT) {			return JFaceResources.getString("Alt"); //$NON-NLS-1$		}		if (keyCode == SWT.SHIFT) {			return JFaceResources.getString("Shift"); //$NON-NLS-1$		}		if (keyCode == SWT.COMMAND) {			return JFaceResources.getString("Command"); //$NON-NLS-1$				}		return null;	}	/**	 * Returns the string representation of the modifiers (Ctrl, Alt, Shift,	 * Command) of the key event.	 * 	 * @param keyCode	 *            The key code for which the modifier string is desired.	 * @return The string representation of the key code; never	 *         <code>null</code>.	 */	private static String getModifierString(int keyCode) {		String modString = ""; //$NON-NLS-1$		if ((keyCode & SWT.CTRL) != 0) {			modString = findModifierString(keyCode & SWT.CTRL);		}		if ((keyCode & SWT.ALT) != 0) {			if (modString.equals("")) { //$NON-NLS-1$				modString = findModifierString(keyCode & SWT.ALT);			} else {				modString = modString						+ "+" + findModifierString(keyCode & SWT.ALT); //$NON-NLS-1$			}		}		if ((keyCode & SWT.SHIFT) != 0) {			if (modString.equals("")) { //$NON-NLS-1$				modString = findModifierString(keyCode & SWT.SHIFT);			} else {				modString = modString						+ "+" + findModifierString(keyCode & SWT.SHIFT); //$NON-NLS-1$			}		}		if ((keyCode & SWT.COMMAND) != 0) {			if (modString.equals("")) { //$NON-NLS-1$				modString = findModifierString(keyCode & SWT.COMMAND);			} else {				modString = modString						+ "+" + findModifierString(keyCode & SWT.COMMAND); //$NON-NLS-1$			}		}		return modString;	}	/**	 * Initializes the internal key code table.	 */	private static final void initKeyCodes() {		keyCodes = new HashMap(40);		keyCodes.put("BACKSPACE", new Integer(8)); //$NON-NLS-1$		keyCodes.put("TAB", new Integer(9)); //$NON-NLS-1$		keyCodes.put("RETURN", new Integer(13)); //$NON-NLS-1$		keyCodes.put("ENTER", new Integer(13)); //$NON-NLS-1$		keyCodes.put("ESCAPE", new Integer(27)); //$NON-NLS-1$		keyCodes.put("ESC", new Integer(27)); //$NON-NLS-1$		keyCodes.put("DELETE", new Integer(127)); //$NON-NLS-1$		keyCodes.put("SPACE", new Integer(' ')); //$NON-NLS-1$		keyCodes.put("ARROW_UP", new Integer(SWT.ARROW_UP)); //$NON-NLS-1$		keyCodes.put("ARROW_DOWN", new Integer(SWT.ARROW_DOWN)); //$NON-NLS-1$		keyCodes.put("ARROW_LEFT", new Integer(SWT.ARROW_LEFT)); //$NON-NLS-1$		keyCodes.put("ARROW_RIGHT", new Integer(SWT.ARROW_RIGHT)); //$NON-NLS-1$		keyCodes.put("PAGE_UP", new Integer(SWT.PAGE_UP)); //$NON-NLS-1$		keyCodes.put("PAGE_DOWN", new Integer(SWT.PAGE_DOWN)); //$NON-NLS-1$		keyCodes.put("HOME", new Integer(SWT.HOME)); //$NON-NLS-1$		keyCodes.put("END", new Integer(SWT.END)); //$NON-NLS-1$		keyCodes.put("INSERT", new Integer(SWT.INSERT)); //$NON-NLS-1$		keyCodes.put("F1", new Integer(SWT.F1)); //$NON-NLS-1$		keyCodes.put("F2", new Integer(SWT.F2)); //$NON-NLS-1$		keyCodes.put("F3", new Integer(SWT.F3)); //$NON-NLS-1$		keyCodes.put("F4", new Integer(SWT.F4)); //$NON-NLS-1$		keyCodes.put("F5", new Integer(SWT.F5)); //$NON-NLS-1$		keyCodes.put("F6", new Integer(SWT.F6)); //$NON-NLS-1$		keyCodes.put("F7", new Integer(SWT.F7)); //$NON-NLS-1$		keyCodes.put("F8", new Integer(SWT.F8)); //$NON-NLS-1$		keyCodes.put("F9", new Integer(SWT.F9)); //$NON-NLS-1$		keyCodes.put("F10", new Integer(SWT.F10)); //$NON-NLS-1$		keyCodes.put("F11", new Integer(SWT.F11)); //$NON-NLS-1$		keyCodes.put("F12", new Integer(SWT.F12)); //$NON-NLS-1$	}	/**	 * Initializes the internal key string table.	 */	private static void initKeyStrings() {		keyStrings = new HashMap(40);		keyStrings.put(new Integer(8), JFaceResources.getString("Backspace")); //$NON-NLS-1$		keyStrings.put(new Integer(9), JFaceResources.getString("Tab")); //$NON-NLS-1$		keyStrings.put(new Integer(13), JFaceResources.getString("Return")); //$NON-NLS-1$		keyStrings.put(new Integer(13), JFaceResources.getString("Enter")); //$NON-NLS-1$		keyStrings.put(new Integer(27), JFaceResources.getString("Escape")); //$NON-NLS-1$		keyStrings.put(new Integer(27), JFaceResources.getString("Esc")); //$NON-NLS-1$		keyStrings.put(new Integer(127), JFaceResources.getString("Delete")); //$NON-NLS-1$		keyStrings.put(new Integer(' '), JFaceResources.getString("Space")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.ARROW_UP), JFaceResources				.getString("Arrow_Up")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.ARROW_DOWN), JFaceResources				.getString("Arrow_Down")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.ARROW_LEFT), JFaceResources				.getString("Arrow_Left")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.ARROW_RIGHT), JFaceResources				.getString("Arrow_Right")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.PAGE_UP), JFaceResources				.getString("Page_Up")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.PAGE_DOWN), JFaceResources				.getString("Page_Down")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.HOME), JFaceResources.getString("Home")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.END), JFaceResources.getString("End")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.INSERT), JFaceResources				.getString("Insert")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F1), JFaceResources.getString("F1")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F2), JFaceResources.getString("F2")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F3), JFaceResources.getString("F3")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F4), JFaceResources.getString("F4")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F5), JFaceResources.getString("F5")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F6), JFaceResources.getString("F6")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F7), JFaceResources.getString("F7")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F8), JFaceResources.getString("F8")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F9), JFaceResources.getString("F9")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F10), JFaceResources.getString("F10")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F11), JFaceResources.getString("F11")); //$NON-NLS-1$		keyStrings.put(new Integer(SWT.F12), JFaceResources.getString("F12")); //$NON-NLS-1$	}	/**	 * Initializes the localized internal key code table.	 */	private static void initLocalizedKeyCodes() {		localizedKeyCodes = new HashMap(40);		localizedKeyCodes.put(JFaceResources				.getString("Backspace").toUpperCase(), new Integer(8)); //$NON-NLS-1$		localizedKeyCodes.put(				JFaceResources.getString("Tab").toUpperCase(), new Integer(9)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Return").toUpperCase(), new Integer(13)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Enter").toUpperCase(), new Integer(13)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Escape").toUpperCase(), new Integer(27)); //$NON-NLS-1$		localizedKeyCodes.put(				JFaceResources.getString("Esc").toUpperCase(), new Integer(27)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Delete").toUpperCase(), new Integer(127)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Space").toUpperCase(), new Integer(' ')); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Arrow_Up").toUpperCase(), new Integer(SWT.ARROW_UP)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Arrow_Down").toUpperCase(), new Integer(SWT.ARROW_DOWN)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Arrow_Left").toUpperCase(), new Integer(SWT.ARROW_LEFT)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Arrow_Right").toUpperCase(), new Integer(SWT.ARROW_RIGHT)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Page_Up").toUpperCase(), new Integer(SWT.PAGE_UP)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Page_Down").toUpperCase(), new Integer(SWT.PAGE_DOWN)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Home").toUpperCase(), new Integer(SWT.HOME)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("End").toUpperCase(), new Integer(SWT.END)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("Insert").toUpperCase(), new Integer(SWT.INSERT)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F1").toUpperCase(), new Integer(SWT.F1)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F2").toUpperCase(), new Integer(SWT.F2)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F3").toUpperCase(), new Integer(SWT.F3)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F4").toUpperCase(), new Integer(SWT.F4)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F5").toUpperCase(), new Integer(SWT.F5)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F6").toUpperCase(), new Integer(SWT.F6)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F7").toUpperCase(), new Integer(SWT.F7)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F8").toUpperCase(), new Integer(SWT.F8)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F9").toUpperCase(), new Integer(SWT.F9)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F10").toUpperCase(), new Integer(SWT.F10)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F11").toUpperCase(), new Integer(SWT.F11)); //$NON-NLS-1$		localizedKeyCodes				.put(						JFaceResources.getString("F12").toUpperCase(), new Integer(SWT.F12)); //$NON-NLS-1$	}	/**	 * Initialize the list of localized modifiers	 */	private static void initLocalizedModifiers() {		localizedCtrl = JFaceResources.getString("Ctrl").toUpperCase(); //$NON-NLS-1$		localizedShift = JFaceResources.getString("Shift").toUpperCase(); //$NON-NLS-1$		localizedAlt = JFaceResources.getString("Alt").toUpperCase(); //$NON-NLS-1$		localizedCommand = JFaceResources.getString("Command").toUpperCase(); //$NON-NLS-1$		}	/**	 * Convenience method for removing any optional accelerator text from the	 * given string. The accelerator text appears at the end of the text, and is	 * separated from the main part by a single tab character <code>'\t'</code>.	 * 	 * @param text	 *            the text	 * @return the text sans accelerator	 */	public static final String removeAcceleratorText(final String text) {		int index = text.lastIndexOf('\t');		if (index == -1) {			index = text.lastIndexOf('@');		}		if (index >= 0) {			return text.substring(0, index);		}		return text;	}	/**	 * Convenience method for removing any mnemonics from the given string. For	 * example, <code>removeMnemonics("&Open")</code> will return	 * <code>"Open"</code>.	 * 	 * @param text	 *            the text	 * @return the text sans mnemonics	 */	public static final String removeMnemonics(final String text) {		int index = text.indexOf('&');		if (index == -1) {			return text;		}		int len = text.length();		StringBuffer sb = new StringBuffer(len);		int lastIndex = 0;		while (index != -1) {			// ignore & at the end			if (index == len - 1) {				break;			}			// handle the && case			if (text.charAt(index + 1) == '&') {				++index;			}			// DBCS languages use "(&X)" format			if (index > 0 && text.charAt(index - 1) == '('					&& text.length() >= index + 3					&& text.charAt(index + 2) == ')') {				sb.append(text.substring(lastIndex, index - 1));				index += 3;			} else {				sb.append(text.substring(lastIndex, index));				// skip the &				++index;			}			lastIndex = index;			index = text.indexOf('&', index);		}		if (lastIndex < len) {			sb.append(text.substring(lastIndex, len));		}		return sb.toString();	}	/**	 * This class cannot be instantiated.	 */	private LegacyActionTools() {		// Does nothing	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -