From 3e03b7117f3c8ff764b4b47349da8490a5e2f711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Fri, 19 Dec 2025 10:15:44 +0200 Subject: [PATCH] Remove long deprecated and unused keybinding API Deprecated for long time and creates way too many new deprecation warnings because of https://eclipse.dev/eclipse/markdown/?f=news/4.38/jdt.md#changes-concerning-deprecation-warnings . --- .../.settings/.api_filters | 88 ++++ .../internal/keys/AbstractKeyFormatter.java | 135 ----- .../keys/AbstractModifierKeyComparator.java | 34 -- .../keys/AlphabeticModifierKeyComparator.java | 32 -- .../ui/internal/keys/CompactKeyFormatter.java | 100 ---- .../ui/internal/keys/EmacsKeyFormatter.java | 81 --- .../ui/internal/keys/FormalKeyFormatter.java | 59 --- .../ui/internal/keys/MacKeyFormatter.java | 101 ---- .../ui/internal/keys/NativeKeyFormatter.java | 137 ----- .../keys/NativeModifierKeyComparator.java | 174 ------- .../org/eclipse/ui/keys/CharacterKey.java | 180 ------- .../org/eclipse/ui/keys/IKeyFormatter.java | 64 --- .../eclipseui/org/eclipse/ui/keys/Key.java | 105 ---- .../eclipse/ui/keys/KeyFormatterFactory.java | 98 ---- .../org/eclipse/ui/keys/KeySequence.java | 365 ------------- .../org/eclipse/ui/keys/KeyStroke.java | 351 ------------- .../org/eclipse/ui/keys/ModifierKey.java | 122 ----- .../org/eclipse/ui/keys/NaturalKey.java | 47 -- .../org/eclipse/ui/keys/ParseException.java | 49 -- .../org/eclipse/ui/keys/SWTKeySupport.java | 451 ---------------- .../org/eclipse/ui/keys/SpecialKey.java | 486 ------------------ bundles/org.eclipse.ui/.settings/.api_filters | 91 ++++ .../eclipse/ui/tests/keys/Bug42035Test.java | 187 ------- .../eclipse/ui/tests/keys/Bug43800Test.java | 50 -- .../eclipse/ui/tests/keys/KeysTestSuite.java | 2 - .../MultiPageKeyBindingTest.java | 8 +- 26 files changed, 181 insertions(+), 3416 deletions(-) delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractModifierKeyComparator.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AlphabeticModifierKeyComparator.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/CompactKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/EmacsKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/FormalKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/MacKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeModifierKeyComparator.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/CharacterKey.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/IKeyFormatter.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/Key.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyFormatterFactory.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeySequence.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyStroke.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ModifierKey.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/NaturalKey.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ParseException.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SWTKeySupport.java delete mode 100644 bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SpecialKey.java create mode 100644 bundles/org.eclipse.ui/.settings/.api_filters delete mode 100644 tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java delete mode 100644 tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java diff --git a/bundles/org.eclipse.ui.workbench/.settings/.api_filters b/bundles/org.eclipse.ui.workbench/.settings/.api_filters index 4614ab0685bf..041e6f356c52 100644 --- a/bundles/org.eclipse.ui.workbench/.settings/.api_filters +++ b/bundles/org.eclipse.ui.workbench/.settings/.api_filters @@ -1,5 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractKeyFormatter.java deleted file mode 100644 index 3d8b7171ba5e..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractKeyFormatter.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import java.util.Iterator; -import java.util.ResourceBundle; -import java.util.SortedSet; -import java.util.TreeSet; -import org.eclipse.ui.internal.util.Util; -import org.eclipse.ui.keys.IKeyFormatter; -import org.eclipse.ui.keys.Key; -import org.eclipse.ui.keys.KeySequence; -import org.eclipse.ui.keys.KeyStroke; -import org.eclipse.ui.keys.ModifierKey; -import org.eclipse.ui.keys.NaturalKey; - -/** - * An abstract implementation of a key formatter that provides a lot of common - * key formatting functionality. It is recommended that those people - * implementing their own key formatters subclass from here, rather than - * implementing KeyFormatter directly. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -public abstract class AbstractKeyFormatter implements IKeyFormatter { - - /** - * The key for the delimiter between keys. This is used in the - * internationalization bundles. - */ - protected static final String KEY_DELIMITER_KEY = "KEY_DELIMITER"; //$NON-NLS-1$ - - /** - * The key for the delimiter between key strokes. This is used in the - * internationalization bundles. - */ - protected static final String KEY_STROKE_DELIMITER_KEY = "KEY_STROKE_DELIMITER"; //$NON-NLS-1$ - - /** - * The bundle in which to look up the internationalized text for all of the - * individual keys in the system. This is the platform-agnostic version of the - * internationalized strings. Some platforms (namely Carbon) provide special - * Unicode characters and glyphs for some keys. - */ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(AbstractKeyFormatter.class.getName()); - - @Override - public String format(Key key) { - String name = key.toString(); - return Util.translateString(RESOURCE_BUNDLE, name, name, false, false); - } - - @Override - public String format(KeySequence keySequence) { - StringBuilder stringBuffer = new StringBuilder(); - - Iterator keyStrokeItr = keySequence.getKeyStrokes().iterator(); - while (keyStrokeItr.hasNext()) { - stringBuffer.append(format(keyStrokeItr.next())); - - if (keyStrokeItr.hasNext()) { - stringBuffer.append(getKeyStrokeDelimiter()); - } - } - - return stringBuffer.toString(); - } - - @Override - public String format(KeyStroke keyStroke) { - String keyDelimiter = getKeyDelimiter(); - - // Format the modifier keys, in sorted order. - SortedSet modifierKeys = new TreeSet<>(getModifierKeyComparator()); - modifierKeys.addAll(keyStroke.getModifierKeys()); - StringBuilder stringBuffer = new StringBuilder(); - Iterator modifierKeyItr = modifierKeys.iterator(); - while (modifierKeyItr.hasNext()) { - stringBuffer.append(format(modifierKeyItr.next())); - stringBuffer.append(keyDelimiter); - } - - // Format the natural key, if any. - NaturalKey naturalKey = keyStroke.getNaturalKey(); - if (naturalKey != null) { - stringBuffer.append(format(naturalKey)); - } - - return stringBuffer.toString(); - - } - - /** - * An accessor for the delimiter you wish to use between keys. This is used by - * the default format implementations to determine the key delimiter. - * - * @return The delimiter to use between keys; should not be null. - */ - protected abstract String getKeyDelimiter(); - - /** - * An accessor for the delimiter you wish to use between key strokes. This used - * by the default format implementations to determine the key stroke delimiter. - * - * @return The delimiter to use between key strokes; should not be - * null. - */ - protected abstract String getKeyStrokeDelimiter(); - - /** - * An accessor for the comparator to use for sorting modifier keys. This is used - * by the default format implementations to sort the modifier keys before - * formatting them into a string. - * - * @return The comparator to use to sort modifier keys; must not be - * null. - */ - protected abstract Comparator getModifierKeyComparator(); - -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractModifierKeyComparator.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractModifierKeyComparator.java deleted file mode 100644 index 622db818fb5b..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AbstractModifierKeyComparator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import org.eclipse.ui.keys.ModifierKey; - -@SuppressWarnings("removal") -abstract class AbstractModifierKeyComparator implements Comparator { - - @Override - public int compare(ModifierKey modifierKeyLeft, ModifierKey modifierKeyRight) { - int modifierKeyLeftRank = rank(modifierKeyLeft); - int modifierKeyRightRank = rank(modifierKeyRight); - - if (modifierKeyLeftRank != modifierKeyRightRank) { - return modifierKeyLeftRank - modifierKeyRightRank; - } - return modifierKeyLeft.compareTo(modifierKeyRight); - } - - protected abstract int rank(ModifierKey modifierKey); -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AlphabeticModifierKeyComparator.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AlphabeticModifierKeyComparator.java deleted file mode 100644 index 9ea44abe7ddc..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/AlphabeticModifierKeyComparator.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import org.eclipse.ui.keys.ModifierKey; - -/** - * Compares modifier keys lexicographically by the name of the key. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -public class AlphabeticModifierKeyComparator implements Comparator { - - @Override - public int compare(ModifierKey modifierKeyLeft, ModifierKey modifierKeyRight) { - return modifierKeyLeft.toString().compareTo(modifierKeyRight.toString()); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/CompactKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/CompactKeyFormatter.java deleted file mode 100644 index 8eb3e7b9ff20..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/CompactKeyFormatter.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import org.eclipse.ui.keys.KeySequence; -import org.eclipse.ui.keys.KeyStroke; -import org.eclipse.ui.keys.ModifierKey; -import org.eclipse.ui.keys.NaturalKey; - -/** - * A key formatter providing a special compact format for displaying key - * bindings. - * - * @since 3.0 - */ -public class CompactKeyFormatter extends NativeKeyFormatter { - - @SuppressWarnings("removal") - @Override - public String format(KeySequence keySequence) { - StringBuilder stringBuffer = new StringBuilder(); - - List keyStrokes = keySequence.getKeyStrokes(); - KeyStroke[] keyStrokeArray = keyStrokes.toArray(new KeyStroke[keyStrokes.size()]); - Set previousModifierKeys = Collections.emptySet(); - List naturalKeys = new ArrayList<>(); - for (int i = 0; i < keyStrokeArray.length; i++) { - KeyStroke keyStroke = keyStrokeArray[i]; - Set currentModifierKeys = keyStroke.getModifierKeys(); - - if (!previousModifierKeys.equals(currentModifierKeys)) { - // End the old sequence fragment. - if (i > 0) { - stringBuffer.append(formatKeyStrokes(previousModifierKeys, naturalKeys)); - stringBuffer.append(getKeyStrokeDelimiter()); - } - - // Start a new one. - previousModifierKeys = currentModifierKeys; - naturalKeys.clear(); - - } - - naturalKeys.add(keyStroke.getNaturalKey()); - } - - stringBuffer.append(formatKeyStrokes(previousModifierKeys, naturalKeys)); - - return stringBuffer.toString(); - } - - @SuppressWarnings("removal") - public String formatKeyStrokes(Set modifierKeys, List naturalKeys) { - StringBuilder stringBuffer = new StringBuilder(); - String keyDelimiter = getKeyDelimiter(); - - // Format the modifier keys, in sorted order. - SortedSet sortedModifierKeys = new TreeSet<>(getModifierKeyComparator()); - sortedModifierKeys.addAll(modifierKeys); - Iterator sortedModifierKeyItr = sortedModifierKeys.iterator(); - while (sortedModifierKeyItr.hasNext()) { - stringBuffer.append(format(sortedModifierKeyItr.next())); - stringBuffer.append(keyDelimiter); - } - - // Format the natural key, if any. - Iterator naturalKeyItr = naturalKeys.iterator(); - while (naturalKeyItr.hasNext()) { - Object naturalKey = naturalKeyItr.next(); - if (naturalKey instanceof NaturalKey) { - stringBuffer.append(format((NaturalKey) naturalKey)); - if (naturalKeyItr.hasNext()) { - stringBuffer.append(keyDelimiter); - } - } - } - - return stringBuffer.toString(); - - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/EmacsKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/EmacsKeyFormatter.java deleted file mode 100644 index 8370cf0ff631..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/EmacsKeyFormatter.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import java.util.ResourceBundle; -import org.eclipse.jface.bindings.keys.KeySequence; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.ui.internal.util.Util; -import org.eclipse.ui.keys.Key; -import org.eclipse.ui.keys.ModifierKey; - -/** - * A key formatter providing the Emacs-style accelerators using single letters - * to represent the modifier keys. - * - * @since 3.0 - */ -public class EmacsKeyFormatter extends AbstractKeyFormatter { - - /** - * A comparator that guarantees that modifier keys will be sorted the same - * across different platforms. - */ - private static final Comparator EMACS_MODIFIER_KEY_COMPARATOR = new AlphabeticModifierKeyComparator(); - - /** - * The resource bundle used by format() to translate formal string - * representations by locale. - */ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(EmacsKeyFormatter.class.getName()); - - /** - * Formats an individual key into a human readable format. This converts the key - * into a format similar to Xemacs. - * - * @param key The key to format; must not be null. - * @return The key formatted as a string; should not be null. - */ - @SuppressWarnings("removal") - @Override - public String format(Key key) { - if (key instanceof ModifierKey) { - String formattedName = Util.translateString(RESOURCE_BUNDLE, key.toString(), null, false, false); - if (formattedName != null) { - return formattedName; - } - } - - return super.format(key).toLowerCase(); - } - - @Override - protected String getKeyDelimiter() { - return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY, KeyStroke.KEY_DELIMITER, false, false); - } - - @Override - protected String getKeyStrokeDelimiter() { - return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY, KeySequence.KEY_STROKE_DELIMITER, false, - false); - } - - @Override - protected Comparator getModifierKeyComparator() { - return EMACS_MODIFIER_KEY_COMPARATOR; - } - -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/FormalKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/FormalKeyFormatter.java deleted file mode 100644 index e8f6c615cad8..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/FormalKeyFormatter.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import org.eclipse.jface.bindings.keys.KeySequence; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.ui.keys.Key; - -/** - * Formats the keys in the internal key sequence grammar. This is used for - * persistence, and is not really intended for display to the user. - * - * @since 3.0 - */ -public class FormalKeyFormatter extends AbstractKeyFormatter { - - /** - * A comparator that guarantees that modifier keys will be sorted the same - * across different platforms. - */ - private static final Comparator FORMAL_MODIFIER_KEY_COMPARATOR = new AlphabeticModifierKeyComparator(); - - @SuppressWarnings("removal") - @Override - public String format(Key key) { - return key.toString(); - } - - - @Override - protected String getKeyDelimiter() { - return KeyStroke.KEY_DELIMITER; - } - - - @Override - protected String getKeyStrokeDelimiter() { - return KeySequence.KEY_STROKE_DELIMITER; - } - - @Override - protected Comparator getModifierKeyComparator() { - return FORMAL_MODIFIER_KEY_COMPARATOR; - } - -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/MacKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/MacKeyFormatter.java deleted file mode 100644 index 18afa262d724..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/MacKeyFormatter.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.ResourceBundle; -import org.eclipse.jface.bindings.keys.KeySequence; -import org.eclipse.ui.internal.util.Util; -import org.eclipse.ui.keys.CharacterKey; -import org.eclipse.ui.keys.Key; -import org.eclipse.ui.keys.ModifierKey; -import org.eclipse.ui.keys.SpecialKey; - -@SuppressWarnings("removal") -public final class MacKeyFormatter extends AbstractKeyFormatter { - - private static final class MacModifierKeyComparator extends AbstractModifierKeyComparator { - - @Override - protected int rank(ModifierKey modifierKey) { - if (ModifierKey.SHIFT.equals(modifierKey)) { - return 0; - } - - if (ModifierKey.CTRL.equals(modifierKey)) { - return 1; - } - - if (ModifierKey.ALT.equals(modifierKey)) { - return 2; - } - - if (ModifierKey.COMMAND.equals(modifierKey)) { - return 3; - } - - return Integer.MAX_VALUE; - } - } - - private static final HashMap KEY_LOOKUP = new HashMap(); - - private static final Comparator MODIFIER_KEY_COMPARATOR = new MacModifierKeyComparator(); - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(MacKeyFormatter.class.getName()); - - static { - KEY_LOOKUP.put(CharacterKey.BS.toString(), "\u232B"); //$NON-NLS-1$ - KEY_LOOKUP.put(CharacterKey.CR.toString(), "\u21A9"); //$NON-NLS-1$ - KEY_LOOKUP.put(CharacterKey.DEL.toString(), "\u2326"); //$NON-NLS-1$ - KEY_LOOKUP.put(CharacterKey.SPACE.toString(), "\u2423"); //$NON-NLS-1$ - KEY_LOOKUP.put(ModifierKey.ALT.toString(), "\u2325"); //$NON-NLS-1$ - KEY_LOOKUP.put(ModifierKey.COMMAND.toString(), "\u2318"); //$NON-NLS-1$ - KEY_LOOKUP.put(ModifierKey.CTRL.toString(), "\u2303"); //$NON-NLS-1$ - KEY_LOOKUP.put(ModifierKey.SHIFT.toString(), "\u21E7"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.ARROW_DOWN.toString(), "\u2193"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.ARROW_LEFT.toString(), "\u2190"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.ARROW_RIGHT.toString(), "\u2192"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.ARROW_UP.toString(), "\u2191"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.END.toString(), "\u2198"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.NUMPAD_ENTER.toString(), "\u2324"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.HOME.toString(), "\u2196"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.PAGE_DOWN.toString(), "\u21DF"); //$NON-NLS-1$ - KEY_LOOKUP.put(SpecialKey.PAGE_UP.toString(), "\u21DE"); //$NON-NLS-1$ - } - - @Override - public String format(Key key) { - String string = (String) KEY_LOOKUP.get(key.toString()); - return string != null ? string : super.format(key); - } - - @Override - protected String getKeyDelimiter() { - return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY, Util.ZERO_LENGTH_STRING, false, false); - } - - @Override - protected String getKeyStrokeDelimiter() { - return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY, KeySequence.KEY_STROKE_DELIMITER, false, - false); - } - - @Override - protected Comparator getModifierKeyComparator() { - return MODIFIER_KEY_COMPARATOR; - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeKeyFormatter.java deleted file mode 100644 index 1a44d01e7bd3..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeKeyFormatter.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.ResourceBundle; -import org.eclipse.jface.bindings.keys.KeySequence; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.ui.internal.util.Util; -import org.eclipse.ui.keys.CharacterKey; -import org.eclipse.ui.keys.Key; -import org.eclipse.ui.keys.ModifierKey; -import org.eclipse.ui.keys.SpecialKey; - -/** - * Formats the key sequences and key strokes into the native human-readable - * format. This is typically what you would see on the menus for the given - * platform and locale. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -public class NativeKeyFormatter extends AbstractKeyFormatter { - - /** - * The key into the internationalization resource bundle for the delimiter to - * use between keys (on the Carbon platform). - */ - private static final String CARBON_KEY_DELIMITER_KEY = "CARBON_KEY_DELIMITER"; //$NON-NLS-1$ - - /** - * A look-up table for the string representations of various carbon keys. - */ - private static final HashMap CARBON_KEY_LOOK_UP = new HashMap<>(); - - /** - * A comparator to sort modifier keys in the order that they would be displayed - * to a user. This comparator is platform-specific. - */ - private static final Comparator MODIFIER_KEY_COMPARATOR = new NativeModifierKeyComparator(); - - /** - * The resource bundle used by format() to translate formal string - * representations by locale. - */ - private static final ResourceBundle RESOURCE_BUNDLE; - - /** - * The key into the internationalization resource bundle for the delimiter to - * use between key strokes (on the Win32 platform). - */ - private static final String WIN32_KEY_STROKE_DELIMITER_KEY = "WIN32_KEY_STROKE_DELIMITER"; //$NON-NLS-1$ - - static { - RESOURCE_BUNDLE = ResourceBundle.getBundle(NativeKeyFormatter.class.getName()); - - CARBON_KEY_LOOK_UP.put(CharacterKey.BS.toString(), "\u232B"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(CharacterKey.CR.toString(), "\u21A9"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(CharacterKey.DEL.toString(), "\u2326"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(CharacterKey.SPACE.toString(), "\u2423"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(ModifierKey.ALT.toString(), "\u2325"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(ModifierKey.COMMAND.toString(), "\u2318"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(ModifierKey.CTRL.toString(), "\u2303"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(ModifierKey.SHIFT.toString(), "\u21E7"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.ARROW_DOWN.toString(), "\u2193"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.ARROW_LEFT.toString(), "\u2190"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.ARROW_RIGHT.toString(), "\u2192"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.ARROW_UP.toString(), "\u2191"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.END.toString(), "\u2198"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.NUMPAD_ENTER.toString(), "\u2324"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.HOME.toString(), "\u2196"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.PAGE_DOWN.toString(), "\u21DF"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.put(SpecialKey.PAGE_UP.toString(), "\u21DE"); //$NON-NLS-1$ - } - - /** - * Formats an individual key into a human readable format. This uses an - * internationalization resource bundle to look up the key. This does the - * platform-specific formatting for Carbon. - * - * @param key The key to format; must not be null. - * @return The key formatted as a string; should not be null. - */ - @Override - public String format(Key key) { - String name = key.toString(); - - // TODO consider platform-specific resource bundles - if (org.eclipse.jface.util.Util.isMac()) { - String formattedName = CARBON_KEY_LOOK_UP.get(name); - if (formattedName != null) { - return formattedName; - } - } - - return super.format(key); - } - - @Override - protected String getKeyDelimiter() { - // We must do the look up every time, as our locale might change. - if (org.eclipse.jface.util.Util.isMac()) { - return Util.translateString(RESOURCE_BUNDLE, CARBON_KEY_DELIMITER_KEY, Util.ZERO_LENGTH_STRING, false, - false); - } - return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY, KeyStroke.KEY_DELIMITER, false, false); - } - - @Override - protected String getKeyStrokeDelimiter() { - // We must do the look up every time, as our locale might change. - if (org.eclipse.jface.util.Util.isWindows()) { - return Util.translateString(RESOURCE_BUNDLE, WIN32_KEY_STROKE_DELIMITER_KEY, - KeySequence.KEY_STROKE_DELIMITER, false, false); - } - return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY, KeySequence.KEY_STROKE_DELIMITER, false, - false); - } - - @Override - protected Comparator getModifierKeyComparator() { - return MODIFIER_KEY_COMPARATOR; - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeModifierKeyComparator.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeModifierKeyComparator.java deleted file mode 100644 index eaadd40681e6..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/keys/NativeModifierKeyComparator.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.internal.keys; - -import java.util.Comparator; -import org.eclipse.jface.util.Util; -import org.eclipse.ui.keys.ModifierKey; - -/** - * A comparator that sorts the modifier keys based on the native environment. - * Currently, this is only the windowing toolkit, but in the future it might - * expand to include the window manager. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -class NativeModifierKeyComparator implements Comparator { - - /** - * The sort order value to use when the modifier key is not recognized. - */ - private static final int UNKNOWN_KEY = Integer.MAX_VALUE; - - @Override - public int compare(ModifierKey left, ModifierKey right) { - ModifierKey modifierKeyLeft = left; - ModifierKey modifierKeyRight = right; - int modifierKeyLeftRank = rank(modifierKeyLeft); - int modifierKeyRightRank = rank(modifierKeyRight); - - if (modifierKeyLeftRank != modifierKeyRightRank) { - return modifierKeyLeftRank - modifierKeyRightRank; - } - return modifierKeyLeft.compareTo(modifierKeyRight); - } - - /** - * Calculates a rank for a given modifier key. - * - * @param modifierKey The modifier key to rank; may be null. - * @return The rank of this modifier key. This is a non-negative number where a - * lower number suggests a higher rank. - */ - private int rank(ModifierKey modifierKey) { - - if (Util.isWindows()) { - return rankWindows(modifierKey); - } - - if (Util.isGtk()) { - // TODO Do a look-up on window manager. - return rankGNOME(modifierKey); - } - - if (Util.isMac()) { - return rankMacOSX(modifierKey); - } - - return UNKNOWN_KEY; - } - - /** - * Provides a ranking for the modifier key based on the modifier key ordering - * used in the GNOME window manager. - * - * @param modifierKey The modifier key to rank; may be null. - * @return The rank of this modifier key. This is a non-negative number where a - * lower number suggests a higher rank. - */ - private final int rankGNOME(ModifierKey modifierKey) { - if (ModifierKey.SHIFT.equals(modifierKey)) { - return 0; - } - - if (ModifierKey.CTRL.equals(modifierKey)) { - return 1; - } - - if (ModifierKey.ALT.equals(modifierKey)) { - return 2; - } - - return UNKNOWN_KEY; - - } - - /** - * Provides a ranking for the modifier key based on the modifier key ordering - * used in the KDE window manager. - * - * @param modifierKey The modifier key to rank; may be null. - * @return The rank of this modifier key. This is a non-negative number where a - * lower number suggests a higher rank. - */ -// private final int rankKDE(ModifierKey modifierKey) { -// if (ModifierKey.ALT.equals(modifierKey)) { -// return 0; -// } -// -// if (ModifierKey.CTRL.equals(modifierKey)) { -// return 1; -// } -// -// if (ModifierKey.SHIFT.equals(modifierKey)) { -// return 2; -// } -// -// return UNKNOWN_KEY; -// } - - /** - * Provides a ranking for the modifier key based on the modifier key ordering - * used in the MacOS X operating system. - * - * @param modifierKey The modifier key to rank; may be null. - * @return The rank of this modifier key. This is a non-negative number where a - * lower number suggests a higher rank. - */ - private final int rankMacOSX(ModifierKey modifierKey) { - if (ModifierKey.SHIFT.equals(modifierKey)) { - return 0; - } - - if (ModifierKey.CTRL.equals(modifierKey)) { - return 1; - } - - if (ModifierKey.ALT.equals(modifierKey)) { - return 2; - } - - if (ModifierKey.COMMAND.equals(modifierKey)) { - return 3; - } - - return UNKNOWN_KEY; - } - - /** - * Provides a ranking for the modifier key based on the modifier key ordering - * used in the Windows operating system. - * - * @param modifierKey The modifier key to rank; may be null. - * @return The rank of this modifier key. This is a non-negative number where a - * lower number suggests a higher rank. - */ - private final int rankWindows(ModifierKey modifierKey) { - if (ModifierKey.CTRL.equals(modifierKey)) { - return 0; - } - - if (ModifierKey.ALT.equals(modifierKey)) { - return 1; - } - - if (ModifierKey.SHIFT.equals(modifierKey)) { - return 2; - } - - return UNKNOWN_KEY; - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/CharacterKey.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/CharacterKey.java deleted file mode 100644 index cb72cc26a0ff..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/CharacterKey.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.SortedMap; -import java.util.TreeMap; -import org.eclipse.jface.bindings.keys.IKeyLookup; -import org.eclipse.jface.bindings.keys.KeyLookupFactory; - -/** - *

- * Instances of CharacterKey represent keys on the keyboard which - * represent unicode characters. - *

- *

- * CharacterKey objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and - * org.eclipse.jface.bindings.keys.KeyLookupFactory - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class CharacterKey extends NaturalKey { - - /** - * An internal map used to lookup instances of CharacterKey given - * the formal string representation of a character key. - */ - @Deprecated - static SortedMap characterKeysByName = new TreeMap(); - - /** - * The single static instance of CharacterKey which represents the - * backspace key (U+0008). - */ - @Deprecated - public static final CharacterKey BS; - - /** - * The single static instance of CharacterKey which represents the - * carriage return (U+000D) key - */ - @Deprecated - public static final CharacterKey CR; - - /** - * The single static instance of CharacterKey which represents the - * delete (U+007F) key. - */ - @Deprecated - public static final CharacterKey DEL; - - /** - * The single static instance of CharacterKey which represents the - * escape (U+001B) key. - */ - @Deprecated - public static final CharacterKey ESC; - - /** - * The single static instance of CharacterKey which represents the - * form feed (U+000C) key. - */ - @Deprecated - public static final CharacterKey FF; - - /** - * The single static instance of CharacterKey which represents the - * line feed (U+000A) key. - */ - @Deprecated - public static final CharacterKey LF; - - /** - * The single static instance of CharacterKey which represents the - * null (U+0000) key. - */ - @Deprecated - public static final CharacterKey NUL; - - /** - * The single static instance of CharacterKey which represents the - * space (U+0020) key. - */ - @Deprecated - public static final CharacterKey SPACE; - - /** - * The single static instance of CharacterKey which represents the - * tab (U+0009) key. - */ - @Deprecated - public static final CharacterKey TAB; - - /** - * The single static instance of CharacterKey which represents the - * vertical tab (U+000B) key. - */ - @Deprecated - public static final CharacterKey VT; - - /** - * Creates an instance of CharacterKey given a unicode character. - * This method determines the correct name for the key based on character. - * Typically, this name is a string of one-character in length equal to the - * character that this instance represents. - * - * @param character the character that the resultant CharacterKey - * instance is to represent. - * @return an instance of CharacterKey representing the character. - */ - @Deprecated - public static CharacterKey getInstance(final char character) { - return new CharacterKey(character); - } - - static { - final IKeyLookup lookup = KeyLookupFactory.getDefault(); - BS = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.BS_NAME)); - CR = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.CR_NAME)); - DEL = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.DEL_NAME)); - ESC = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.ESC_NAME)); - FF = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.FF_NAME)); - LF = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.LF_NAME)); - NUL = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.NUL_NAME)); - SPACE = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.SPACE_NAME)); - TAB = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.TAB_NAME)); - VT = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.VT_NAME)); - - characterKeysByName.put(IKeyLookup.BS_NAME, CharacterKey.BS); - characterKeysByName.put(IKeyLookup.BACKSPACE_NAME, CharacterKey.BS); - characterKeysByName.put(IKeyLookup.CR_NAME, CharacterKey.CR); - characterKeysByName.put(IKeyLookup.ENTER_NAME, CharacterKey.CR); - characterKeysByName.put(IKeyLookup.RETURN_NAME, CharacterKey.CR); - characterKeysByName.put(IKeyLookup.DEL_NAME, CharacterKey.DEL); - characterKeysByName.put(IKeyLookup.DELETE_NAME, CharacterKey.DEL); - characterKeysByName.put(IKeyLookup.ESC_NAME, CharacterKey.ESC); - characterKeysByName.put(IKeyLookup.ESCAPE_NAME, CharacterKey.ESC); - characterKeysByName.put(IKeyLookup.FF_NAME, CharacterKey.FF); - characterKeysByName.put(IKeyLookup.LF_NAME, CharacterKey.LF); - characterKeysByName.put(IKeyLookup.NUL_NAME, CharacterKey.NUL); - characterKeysByName.put(IKeyLookup.SPACE_NAME, CharacterKey.SPACE); - characterKeysByName.put(IKeyLookup.TAB_NAME, CharacterKey.TAB); - characterKeysByName.put(IKeyLookup.VT_NAME, CharacterKey.VT); - } - - /** - * Constructs an instance of CharacterKey given a unicode character - * and a name. - * - * @param key The key to be wrapped. - */ - private CharacterKey(final int key) { - super(key); - } - - /** - * Gets the character that this object represents. - * - * @return the character that this object represents. - */ - @Deprecated - public char getCharacter() { - return (char) key; - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/IKeyFormatter.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/IKeyFormatter.java deleted file mode 100644 index e205f5d5b174..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/IKeyFormatter.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -/** - * Any formatter capable of taking key sequence or a key stroke and converting - * it into a string. These formatters are used to produce the strings that the - * user sees in the keys preference page and the menus, as well as the strings - * that are used for persistent storage. - * - * @deprecated Please use org.eclipse.jface.bindings.keys.IKeyFormatter - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public interface IKeyFormatter { - - /** - * Formats an individual key into a human readable format. This uses an - * internationalization resource bundle to look up the key. This does not do any - * platform-specific formatting (e.g., Carbon's command character). - * - * @param key The key to format; must not be null. - * @return The key formatted as a string; should not be null. - */ - @Deprecated - String format(Key key); - - /** - * Format the given key sequence into a string. The manner of the conversion is - * dependent on the formatter. It is required that unequal key seqeunces return - * unequal strings. - * - * @param keySequence The key sequence to convert; must not be - * null. - * @return A string representation of the key sequence; must not be - * null. - */ - @Deprecated - String format(KeySequence keySequence); - - /** - * Format the given key strokes into a string. The manner of the conversion is - * dependent on the formatter. It is required that unequal key strokes return - * unequal strings. - * - * @param keyStroke The key stroke to convert; must not be null. - * @return A string representation of the key stroke; must not be - * null - */ - @Deprecated - String format(KeyStroke keyStroke); -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/Key.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/Key.java deleted file mode 100644 index e6978693b7bb..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/Key.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.Objects; -import org.eclipse.jface.bindings.keys.IKeyLookup; -import org.eclipse.jface.bindings.keys.KeyLookupFactory; -import org.eclipse.ui.internal.util.Util; - -/** - *

- * Key is the abstract base class for all objects representing keys - * on the keyboard. - *

- *

- * All Key objects have a formal string representation, called the - * 'name' of the key, available via the toString() method. - *

- *

- * All Key objects, via the format() method, provide a - * version of their formal string representation translated by platform and - * locale, suitable for display to a user. - *

- *

- * Key objects are immutable. Clients are not permitted to extend - * this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and - * org.eclipse.jface.bindings.keys.KeyLookupFactory - * @since 3.0 - * @noextend This class is not intended to be subclassed by clients. - */ -@Deprecated(forRemoval = true, since = "2024-03") -public abstract class Key implements Comparable { - - /** - * The key from which this key was constructed. This value is defined by - * KeyLookupFactory.getDefault(). - */ - @Deprecated - protected final int key; - - /** - * Constructs an instance of Key given its formal string - * representation. - * - * @param key the integer representation of this key, as defined by - * KeyLookupFactory.getDefault(). - */ - @Deprecated - Key(final int key) { - this.key = key; - } - - /** - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Deprecated - @Override - public final int compareTo(final Object object) { - return Util.compare(key, ((Key) object).key); - } - - @Deprecated - @Override - public final boolean equals(final Object object) { - if (!(object instanceof Key)) { - return false; - } - - return key == ((Key) object).key; - } - - @Deprecated - @Override - public final int hashCode() { - return Objects.hashCode(key); - } - - /** - * Returns the formal string representation for this key. - * - * @return The formal string representation for this key. Guaranteed not to be - * null. - */ - @Deprecated - @Override - public final String toString() { - final IKeyLookup lookup = KeyLookupFactory.getDefault(); - return lookup.formalNameLookup(key); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyFormatterFactory.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyFormatterFactory.java deleted file mode 100644 index 0c4348bd40d7..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyFormatterFactory.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import org.eclipse.ui.internal.keys.CompactKeyFormatter; -import org.eclipse.ui.internal.keys.EmacsKeyFormatter; -import org.eclipse.ui.internal.keys.FormalKeyFormatter; - -/** - * A cache for formatters. It keeps a few instances of pre-defined instances of - * IKeyFormatter available for use. It also allows the default - * formatter to be changed. - * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyFormatterFactory - * @since 3.0 - * @see org.eclipse.ui.keys.IKeyFormatter - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class KeyFormatterFactory { - private static final IKeyFormatter COMPACT_KEY_FORMATTER = new CompactKeyFormatter(); - - private static final IKeyFormatter FORMAL_KEY_FORMATTER = new FormalKeyFormatter(); - - private static final IKeyFormatter EMACS_KEY_FORMATTER = new EmacsKeyFormatter(); - - private static IKeyFormatter defaultKeyFormatter = FORMAL_KEY_FORMATTER; - - /** - * Provides an instance of CompactKeyFormatter. - * - * @return The compact formatter; never null. - */ - @Deprecated - public static IKeyFormatter getCompactKeyFormatter() { - return COMPACT_KEY_FORMATTER; - } - - /** - * An accessor for the current default key formatter. - * - * @return The default formatter; never null. - */ - @Deprecated - public static IKeyFormatter getDefault() { - return defaultKeyFormatter; - } - - /** - * Provides an instance of EmacsKeyFormatter. - * - * @return The Xemacs formatter; never null. - */ - @Deprecated - public static IKeyFormatter getEmacsKeyFormatter() { - return EMACS_KEY_FORMATTER; - } - - /** - * Provides an instance of FormalKeyFormatter. - * - * @return The formal formatter; never null. - */ - @Deprecated - public static IKeyFormatter getFormalKeyFormatter() { - return FORMAL_KEY_FORMATTER; - } - - /** - * Sets the default key formatter. - * - * @param defaultKeyFormatter the default key formatter. Must not be - * null. - */ - @Deprecated - public static void setDefault(IKeyFormatter defaultKeyFormatter) { - if (defaultKeyFormatter == null) { - throw new NullPointerException(); - } - - KeyFormatterFactory.defaultKeyFormatter = defaultKeyFormatter; - } - - private KeyFormatterFactory() { - // Not to be constructred. - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeySequence.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeySequence.java deleted file mode 100644 index 8251ea58930e..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeySequence.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; -import org.eclipse.ui.internal.util.Util; - -/** - *

- * A KeySequence is defined as a list of zero or more - * KeyStrokes, with the stipulation that all KeyStroke - * objects must be complete, save for the last one, whose completeness is - * optional. A KeySequence is said to be complete if all of its - * KeyStroke objects are complete. - *

- *

- * All KeySequence objects have a formal string representation - * available via the toString() method. There are a number of - * methods to get instances of KeySequence objects, including one - * which can parse this formal string representation. - *

- *

- * All KeySequence objects, via the format() method, - * provide a version of their formal string representation translated by - * platform and locale, suitable for display to a user. - *

- *

- * KeySequence objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeySequence - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class KeySequence implements Comparable { - - /** - * The delimiter between multiple key strokes in a single key sequence -- - * expressed in the formal key stroke grammar. This is not to be displayed to - * the user. It is only intended as an internal representation. - */ - @Deprecated - public static final String KEY_STROKE_DELIMITER = "\u0020"; //$NON-NLS-1$ - - /** - * An empty key sequence instance for use by everyone. - */ - private static final KeySequence EMPTY_KEY_SEQUENCE = new KeySequence(Collections.EMPTY_LIST); - - /** - * An internal constant used only in this object's hash code algorithm. - */ - private static final int HASH_FACTOR = 89; - - /** - * An internal constant used only in this object's hash code algorithm. - */ - private static final int HASH_INITIAL = KeySequence.class.getName().hashCode(); - - /** - * The set of delimiters for KeyStroke objects allowed during - * parsing of the formal string representation. - */ - @Deprecated - public static final String KEY_STROKE_DELIMITERS = KEY_STROKE_DELIMITER + "\b\r\u007F\u001B\f\n\0\t\u000B"; //$NON-NLS-1$ - - /** - * Gets an instance of KeySequence. - * - * @return a key sequence. This key sequence will have no key strokes. - * Guaranteed not to be null. - */ - @Deprecated - public static KeySequence getInstance() { - return EMPTY_KEY_SEQUENCE; - } - - /** - * Gets an instance of KeySequence given a key sequence and a key - * stroke. - * - * @param keySequence a key sequence. Must not be null. - * @param keyStroke a key stroke. Must not be null. - * @return a key sequence that is equal to the given key sequence with the given - * key stroke appended to the end. Guaranteed not to be - * null. - */ - @Deprecated - public static KeySequence getInstance(KeySequence keySequence, KeyStroke keyStroke) { - if (keySequence == null || keyStroke == null) { - throw new NullPointerException(); - } - - List keyStrokes = new ArrayList<>(keySequence.getKeyStrokes()); - keyStrokes.add(keyStroke); - return new KeySequence(keyStrokes); - } - - /** - * Gets an instance of KeySequence given a single key stroke. - * - * @param keyStroke a single key stroke. Must not be null. - * @return a key sequence. Guaranteed not to be null. - */ - @Deprecated - public static KeySequence getInstance(KeyStroke keyStroke) { - return new KeySequence(Collections.singletonList(keyStroke)); - } - - /** - * Gets an instance of KeySequence given an array of key strokes. - * - * @param keyStrokes the array of key strokes. This array may be empty, but it - * must not be null. This array must not contain - * null elements. - * @return a key sequence. Guaranteed not to be null. - */ - @Deprecated - public static KeySequence getInstance(KeyStroke[] keyStrokes) { - return new KeySequence(Arrays.asList(keyStrokes)); - } - - /** - * Gets an instance of KeySequence given a list of key strokes. - * - * @param keyStrokes the list of key strokes. This list may be empty, but it - * must not be null. If this list is not empty, - * it must only contain instances of KeyStroke. - * @return a key sequence. Guaranteed not to be null. - */ - @Deprecated - public static KeySequence getInstance(List keyStrokes) { - return new KeySequence(keyStrokes); - } - - /** - * Gets an instance of KeySequence given a new-style key sequence. - * - * @param newKeySequence The new-style key sequence to convert into a legacy key - * sequence; must not be null. - * @return a key sequence; never null. - */ - @Deprecated - public static KeySequence getInstance(final org.eclipse.jface.bindings.keys.KeySequence newKeySequence) { - final org.eclipse.jface.bindings.keys.KeyStroke[] newKeyStrokes = newKeySequence.getKeyStrokes(); - final int newKeyStrokesCount = newKeyStrokes.length; - final List legacyKeyStrokes = new ArrayList<>(newKeyStrokesCount); - - for (int i = 0; i < newKeyStrokesCount; i++) { - final org.eclipse.jface.bindings.keys.KeyStroke newKeyStroke = newKeyStrokes[i]; - legacyKeyStrokes.add(SWTKeySupport - .convertAcceleratorToKeyStroke(newKeyStroke.getModifierKeys() | newKeyStroke.getNaturalKey())); - } - - return new KeySequence(legacyKeyStrokes); - } - - /** - * Gets an instance of KeySequence by parsing a given a formal - * string representation. - * - * @param string the formal string representation to parse. - * @return a key sequence. Guaranteed not to be null. - * @throws ParseException if the given formal string representation could not be - * parsed to a valid key sequence. - */ - @Deprecated - public static KeySequence getInstance(String string) throws ParseException { - if (string == null) { - throw new NullPointerException(); - } - - List keyStrokes = new ArrayList<>(); - StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_STROKE_DELIMITERS); - - while (stringTokenizer.hasMoreTokens()) { - keyStrokes.add(KeyStroke.getInstance(stringTokenizer.nextToken())); - } - - try { - return new KeySequence(keyStrokes); - } catch (Throwable t) { - throw new ParseException("Could not construct key sequence with these key strokes: " //$NON-NLS-1$ - + keyStrokes); - } - } - - /** - * The cached hash code for this object. Because KeySequence - * objects are immutable, their hash codes need only to be computed once. After - * the first call to hashCode(), the computed value is cached here - * for all subsequent calls. - */ - private transient int hashCode; - - /** - * A flag to determine if the hashCode field has already been - * computed. - */ - private transient boolean hashCodeComputed; - - /** - * The list of key strokes for this key sequence. - */ - private final List keyStrokes; - - /** - * Constructs an instance of KeySequence given a list of key - * strokes. - * - * @param keyStrokes the list of key strokes. This list may be empty, but it - * must not be null. If this list is not empty, - * it must only contain instances of KeyStroke. - */ - private KeySequence(List keyStrokes) { - this.keyStrokes = Util.safeCopy(keyStrokes, KeyStroke.class); - - for (int i = 0; i < this.keyStrokes.size() - 1; i++) { - KeyStroke keyStroke = this.keyStrokes.get(i); - - if (!keyStroke.isComplete()) { - throw new IllegalArgumentException(); - } - } - } - - @Deprecated - @Override - public int compareTo(Object object) { - KeySequence castedObject = (KeySequence) object; - return Util.compare(keyStrokes, castedObject.keyStrokes); - } - - /** - * Returns whether or not this key sequence ends with the given key sequence. - * - * @param keySequence a key sequence. Must not be null. - * @param equals whether or not an identical key sequence should be - * considered as a possible match. - * @return true, iff the given key sequence ends with this key - * sequence. - */ - @Deprecated - public boolean endsWith(KeySequence keySequence, boolean equals) { - if (keySequence == null) { - throw new NullPointerException(); - } - - return Util.endsWith(keyStrokes, keySequence.keyStrokes, equals); - } - - @Deprecated - @Override - public boolean equals(Object object) { - if (!(object instanceof KeySequence)) { - return false; - } - - return keyStrokes.equals(((KeySequence) object).keyStrokes); - } - - /** - * Formats this key sequence into the current default look. - * - * @return A string representation for this key sequence using the default look; - * never null. - */ - @Deprecated - public String format() { - return KeyFormatterFactory.getDefault().format(this); - } - - /** - * Returns the list of key strokes for this key sequence. - * - * @return the list of key strokes keys. This list may be empty, but is - * guaranteed not to be null. If this list is not empty, it - * is guaranteed to only contain instances of KeyStroke. - */ - @Deprecated - public List getKeyStrokes() { - return keyStrokes; - } - - @Deprecated - @Override - public int hashCode() { - if (!hashCodeComputed) { - hashCode = HASH_INITIAL; - hashCode = hashCode * HASH_FACTOR + keyStrokes.hashCode(); - hashCodeComputed = true; - } - - return hashCode; - } - - /** - * Returns whether or not this key sequence is complete. Key sequences are - * complete iff all of their key strokes are complete. - * - * @return true, iff the key sequence is complete. - */ - @Deprecated - public boolean isComplete() { - return keyStrokes.isEmpty() || keyStrokes.get(keyStrokes.size() - 1).isComplete(); - } - - /** - * Returns whether or not this key sequence is empty. Key sequences are complete - * iff they have no key strokes. - * - * @return true, iff the key sequence is empty. - */ - @Deprecated - public boolean isEmpty() { - return keyStrokes.isEmpty(); - } - - /** - * Returns whether or not this key sequence starts with the given key sequence. - * - * @param keySequence a key sequence. Must not be null. - * @param equals whether or not an identical key sequence should be - * considered as a possible match. - * @return true, iff the given key sequence starts with this key - * sequence. - */ - @Deprecated - public boolean startsWith(KeySequence keySequence, boolean equals) { - if (keySequence == null) { - throw new NullPointerException(); - } - - return Util.startsWith(keyStrokes, keySequence.keyStrokes, equals); - } - - /** - * Returns the formal string representation for this key sequence. - * - * @return The formal string representation for this key sequence. Guaranteed - * not to be null. - */ - @Deprecated - @Override - public String toString() { - return KeyFormatterFactory.getFormalKeyFormatter().format(this); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyStroke.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyStroke.java deleted file mode 100644 index 9d05da663894..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/KeyStroke.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Locale; -import java.util.Objects; -import java.util.Set; -import java.util.SortedSet; -import java.util.StringTokenizer; -import java.util.TreeSet; -import org.eclipse.ui.internal.util.Util; - -/** - *

- * A KeyStroke is defined as an optional set of modifier keys - * followed optionally by a natural key. A KeyStroke is said to be - * complete if it contains a natural key. A natural key is any Unicode character - * (e.g., "backspace", etc.), any character belonging to a natural language - * (e.g., "A", "1", "[", etc.), or any special control character specific to - * computers (e.g., "F10", "PageUp", etc.). - *

- *

- * All KeyStroke objects have a formal string representation - * available via the toString() method. There are a number of - * methods to get instances of KeyStroke objects, including one - * which can parse this formal string representation. - *

- *

- * All KeyStroke objects, via the format() method, - * provide a version of their formal string representation translated by - * platform and locale, suitable for display to a user. - *

- *

- * KeyStroke objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke - * @since 3.0 - * @see org.eclipse.ui.keys.ModifierKey - * @see org.eclipse.ui.keys.NaturalKey - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class KeyStroke implements Comparable { - - /** - * The delimiter between multiple keys in a single key strokes -- expressed in - * the formal key stroke grammar. This is not to be displayed to the user. It is - * only intended as an internal representation. - */ - @Deprecated - public static final String KEY_DELIMITER = "\u002B"; //$NON-NLS-1$ - - /** - * An internal constant used only in this object's hash code algorithm. - */ - private static final int HASH_FACTOR = 89; - - /** - * An internal constant used only in this object's hash code algorithm. - */ - private static final int HASH_INITIAL = KeyStroke.class.getName().hashCode(); - - /** - * The set of delimiters for Key objects allowed during parsing of - * the formal string representation. - */ - @Deprecated - public static final String KEY_DELIMITERS = KEY_DELIMITER; - - /** - * Gets an instance of KeyStroke given a single modifier key and a - * natural key. - * - * @param modifierKey a modifier key. Must not be null. - * @param naturalKey the natural key. May be null. - * @return a key stroke. Guaranteed not to be null. - */ - @Deprecated - public static KeyStroke getInstance(ModifierKey modifierKey, NaturalKey naturalKey) { - if (modifierKey == null) { - throw new NullPointerException(); - } - - return new KeyStroke(new TreeSet<>(Collections.singletonList(modifierKey)), naturalKey); - } - - /** - * Gets an instance of KeyStroke given an array of modifier keys - * and a natural key. - * - * @param modifierKeys the array of modifier keys. This array may be empty, but - * it must not be null. If this array is not - * empty, it must not contain null elements. - * @param naturalKey the natural key. May be null. - * @return a key stroke. Guaranteed not to be null. - */ - @Deprecated - public static KeyStroke getInstance(ModifierKey[] modifierKeys, NaturalKey naturalKey) { - Util.assertInstance(modifierKeys, ModifierKey.class); - return new KeyStroke(new TreeSet<>(Arrays.asList(modifierKeys)), naturalKey); - } - - /** - * Gets an instance of KeyStroke given a natural key. - * - * @param naturalKey the natural key. May be null. - * @return a key stroke. This key stroke will have no modifier keys. Guaranteed - * not to be null. - */ - @Deprecated - public static KeyStroke getInstance(NaturalKey naturalKey) { - return new KeyStroke(Collections.unmodifiableSortedSet(new TreeSet<>()), naturalKey); - } - - /** - * Gets an instance of KeyStroke given a set of modifier keys and a - * natural key. - * - * @param modifierKeys the set of modifier keys. This set may be empty, but it - * must not be null. If this set is not empty, - * it must only contain instances of - * ModifierKey. - * @param naturalKey the natural key. May be null. - * @return a key stroke. Guaranteed not to be null. - */ - @Deprecated - public static KeyStroke getInstance(SortedSet modifierKeys, NaturalKey naturalKey) { - return new KeyStroke(modifierKeys, naturalKey); - } - - /** - * Gets an instance of KeyStroke by parsing a given a formal string - * representation. - * - * @param string the formal string representation to parse. - * @return a key stroke. Guaranteed not to be null. - * @throws ParseException if the given formal string representation could not be - * parsed to a valid key stroke. - */ - @Deprecated - public static KeyStroke getInstance(String string) throws ParseException { - if (string == null) { - throw new NullPointerException(); - } - - SortedSet modifierKeys = new TreeSet<>(); - NaturalKey naturalKey = null; - StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true); - int i = 0; - - while (stringTokenizer.hasMoreTokens()) { - String token = stringTokenizer.nextToken(); - - if (i % 2 == 0) { - if (stringTokenizer.hasMoreTokens()) { - token = token.toUpperCase(Locale.ENGLISH); - ModifierKey modifierKey = ModifierKey.modifierKeysByName.get(token); - - if (modifierKey == null || !modifierKeys.add(modifierKey)) { - throw new ParseException( - "Cannot create key stroke with duplicate or non-existent modifier key: " //$NON-NLS-1$ - + token); - } - } else if (token.length() == 1) { - naturalKey = CharacterKey.getInstance(token.charAt(0)); - break; - } else { - token = token.toUpperCase(Locale.ENGLISH); - naturalKey = (NaturalKey) CharacterKey.characterKeysByName.get(token); - - if (naturalKey == null) { - naturalKey = SpecialKey.specialKeysByName.get(token); - } - - if (naturalKey == null) { - throw new ParseException("Cannot create key stroke with invalid natural key: " //$NON-NLS-1$ - + token); - } - } - } - - i++; - } - - try { - return new KeyStroke(modifierKeys, naturalKey); - } catch (Throwable t) { - throw new ParseException("Cannot create key stroke with " //$NON-NLS-1$ - + modifierKeys + " and " + naturalKey); //$NON-NLS-1$ - } - } - - /** - * The cached hash code for this object. Because KeyStroke objects - * are immutable, their hash codes need only to be computed once. After the - * first call to hashCode(), the computed value is cached here for - * all subsequent calls. - */ - private transient int hashCode; - - /** - * A flag to determine if the hashCode field has already been - * computed. - */ - private transient boolean hashCodeComputed; - - /** - * The set of modifier keys for this key stroke. - */ - private final SortedSet modifierKeys; - - /** - * The set of modifier keys for this key stroke in the form of an array. Used - * internally by int compareTo(Object). - */ - private transient ModifierKey[] modifierKeysAsArray; - - /** - * The natural key for this key stroke. - */ - private final NaturalKey naturalKey; - - /** - * Constructs an instance of KeyStroke given a set of modifier keys - * and a natural key. - * - * @param modifierKeys the set of modifier keys. This set may be empty, but it - * must not be null. If this set is not empty, - * it must only contain instances of - * ModifierKey. - * @param naturalKey the natural key. May be null. - */ - private KeyStroke(SortedSet modifierKeys, NaturalKey naturalKey) { - this.modifierKeys = Util.safeCopy(modifierKeys, ModifierKey.class); - this.naturalKey = naturalKey; - this.modifierKeysAsArray = this.modifierKeys.toArray(new ModifierKey[this.modifierKeys.size()]); - } - - /** - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Deprecated - @Override - public int compareTo(Object object) { - KeyStroke castedObject = (KeyStroke) object; - int compareTo = Util.compare(modifierKeysAsArray, castedObject.modifierKeysAsArray); - - if (compareTo == 0) { - compareTo = Util.compare(naturalKey, castedObject.naturalKey); - } - - return compareTo; - } - - @Deprecated - @Override - public boolean equals(Object object) { - if (!(object instanceof KeyStroke castedObject)) { - return false; - } - - if (!modifierKeys.equals(castedObject.modifierKeys)) { - return false; - } - return Objects.equals(naturalKey, castedObject.naturalKey); - } - - /** - * Formats this key stroke into the current default look. - * - * @return A string representation for this key stroke using the default look; - * never null. - */ - @Deprecated - public String format() { - return KeyFormatterFactory.getDefault().format(this); - } - - /** - * Returns the set of modifier keys for this key stroke. - * - * @return the set of modifier keys. This set may be empty, but is guaranteed - * not to be null. If this set is not empty, it is - * guaranteed to only contain instances of ModifierKey. - */ - @Deprecated - public Set getModifierKeys() { - return Collections.unmodifiableSet(modifierKeys); - } - - /** - * Returns the natural key for this key stroke. - * - * @return the natural key. May be null. - */ - @Deprecated - public NaturalKey getNaturalKey() { - return naturalKey; - } - - @Deprecated - @Override - public int hashCode() { - if (!hashCodeComputed) { - hashCode = HASH_INITIAL; - hashCode = hashCode * HASH_FACTOR + modifierKeys.hashCode(); - hashCode = hashCode * HASH_FACTOR + Objects.hashCode(naturalKey); - hashCodeComputed = true; - } - - return hashCode; - } - - /** - * Returns whether or not this key stroke is complete. Key strokes are complete - * iff they have a natural key which is not null. - * - * @return true, iff the key stroke is complete. - */ - @Deprecated - public boolean isComplete() { - return naturalKey != null; - } - - /** - * Returns the formal string representation for this key stroke. - * - * @return The formal string representation for this key stroke. Guaranteed not - * to be null. - */ - @Deprecated - @Override - public String toString() { - return KeyFormatterFactory.getFormalKeyFormatter().format(this); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ModifierKey.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ModifierKey.java deleted file mode 100644 index e16759829384..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ModifierKey.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.SortedMap; -import java.util.TreeMap; -import org.eclipse.jface.bindings.keys.IKeyLookup; -import org.eclipse.jface.bindings.keys.KeyLookupFactory; -import org.eclipse.jface.util.Util; - -/** - *

- * Instances of ModifierKey represent the four keys on the keyboard - * recognized by convention as 'modifier keys', those keys typically pressed in - * combination with themselves and/or a {@link org.eclipse.ui.keys.NaturalKey}. - *

- *

- * ModifierKey objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and - * org.eclipse.jface.bindings.keys.KeyLookupFactory - * @since 3.0 - * @see org.eclipse.ui.keys.NaturalKey - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class ModifierKey extends Key { - - /** - * An internal map used to lookup instances of ModifierKey given - * the formal string representation of a modifier key. - */ - @Deprecated - static SortedMap modifierKeysByName = new TreeMap<>(); - - /** - * The single static instance of ModifierKey which represents the - * 'Alt' key. - */ - @Deprecated - public static final ModifierKey ALT; - - /** - * The single static instance of ModifierKey which represents the - * 'Command' key. - */ - @Deprecated - public static final ModifierKey COMMAND; - - /** - * The single static instance of ModifierKey which represents the - * 'Ctrl' key. - */ - @Deprecated - public static final ModifierKey CTRL; - - /** - * The name of the 'M1' key. - */ - private static final String M1_NAME = "M1"; //$NON-NLS-1$ - - /** - * The name of the 'M2' key. - */ - private static final String M2_NAME = "M2"; //$NON-NLS-1$ - - /** - * The name of the 'M3' key. - */ - private static final String M3_NAME = "M3"; //$NON-NLS-1$ - - /** - * The name of the 'M4' key. - */ - private static final String M4_NAME = "M4"; //$NON-NLS-1$ - - /** - * The single static instance of ModifierKey which represents the - * 'Shift' key. - */ - @Deprecated - public static final ModifierKey SHIFT; - - static { - final IKeyLookup lookup = KeyLookupFactory.getDefault(); - ALT = new ModifierKey(lookup.getAlt()); - COMMAND = new ModifierKey(lookup.getCommand()); - CTRL = new ModifierKey(lookup.getCtrl()); - SHIFT = new ModifierKey(lookup.getShift()); - - modifierKeysByName.put(ModifierKey.ALT.toString(), ModifierKey.ALT); - modifierKeysByName.put(ModifierKey.COMMAND.toString(), ModifierKey.COMMAND); - modifierKeysByName.put(ModifierKey.CTRL.toString(), ModifierKey.CTRL); - modifierKeysByName.put(ModifierKey.SHIFT.toString(), ModifierKey.SHIFT); - modifierKeysByName.put(M1_NAME, Util.isMac() ? ModifierKey.COMMAND : ModifierKey.CTRL); - modifierKeysByName.put(M2_NAME, ModifierKey.SHIFT); - modifierKeysByName.put(M3_NAME, ModifierKey.ALT); - modifierKeysByName.put(M4_NAME, Util.isMac() ? ModifierKey.CTRL : ModifierKey.COMMAND); - } - - /** - * Constructs an instance of ModifierKey given a name. - * - * @param key The key which this key wraps. - */ - private ModifierKey(final int key) { - super(key); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/NaturalKey.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/NaturalKey.java deleted file mode 100644 index 7be5c906fdb3..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/NaturalKey.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -/** - *

- * Instances of NaturalKey represent all keys on the keyboard not - * known by convention as 'modifier keys'. These can either be keys that belong - * to a natural language of some kind(e.g., "A", "1"), any Unicode character - * (e.g., "backspace"), or they can be special controls keys used by computers - * (e.g., "F10", "PageUp"). - *

- *

- * NaturalKey objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and - * org.eclipse.jface.bindings.keys.KeyLookupFactory - * @since 3.0 - * @noextend This class is not intended to be subclassed by clients. - */ -@Deprecated(forRemoval = true, since = "2024-03") -public abstract class NaturalKey extends Key { - - /** - * Constructs an instance of NaturalKey given a name. - * - * @param key The key to be wrapped. - */ - @Deprecated - NaturalKey(final int key) { - super(key); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ParseException.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ParseException.java deleted file mode 100644 index 646062b1bb16..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/ParseException.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -/** - *

- * An exception indicating problems while parsing formal string representations - * of either KeyStroke or KeySequence objects. - *

- *

- * ParseException objects are immutable. Clients are not permitted - * to extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.ParseException - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class ParseException extends Exception { - - /** - * Generated serial version UID for this class. - * - * @since 3.1 - */ - private static final long serialVersionUID = 3257009864814376241L; - - /** - * Constructs a ParseException with the specified detail message. - * - * @param s the detail message. - */ - @Deprecated - public ParseException(final String s) { - super(s); - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SWTKeySupport.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SWTKeySupport.java deleted file mode 100644 index 05cd887a6c54..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SWTKeySupport.java +++ /dev/null @@ -1,451 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.Iterator; -import java.util.SortedSet; -import java.util.TreeSet; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.internal.keys.NativeKeyFormatter; - -/** - * A utility class for converting SWT events into key strokes. - * - * @deprecated Please use {@link org.eclipse.jface.bindings.keys.SWTKeySupport} - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class SWTKeySupport { - - /** - * Given an SWT accelerator value, provide the corresponding key stroke. - * - * @param accelerator The accelerator to convert; should be a valid SWT - * accelerator value. - * @return The equivalent key stroke; never null. - */ - @Deprecated - public static KeyStroke convertAcceleratorToKeyStroke(int accelerator) { - final SortedSet modifierKeys = new TreeSet<>(); - NaturalKey naturalKey; - - if ((accelerator & SWT.ALT) != 0) { - modifierKeys.add(ModifierKey.ALT); - } - - if ((accelerator & SWT.COMMAND) != 0) { - modifierKeys.add(ModifierKey.COMMAND); - } - - if ((accelerator & SWT.CTRL) != 0) { - modifierKeys.add(ModifierKey.CTRL); - } - - if ((accelerator & SWT.SHIFT) != 0) { - modifierKeys.add(ModifierKey.SHIFT); - } - - if (((accelerator & SWT.KEY_MASK) == 0) && (accelerator != 0)) { - // There were only accelerators - naturalKey = null; - } else { - // There were other keys. - accelerator &= SWT.KEY_MASK; - - switch (accelerator) { - case SWT.ARROW_DOWN: - naturalKey = SpecialKey.ARROW_DOWN; - break; - case SWT.ARROW_LEFT: - naturalKey = SpecialKey.ARROW_LEFT; - break; - case SWT.ARROW_RIGHT: - naturalKey = SpecialKey.ARROW_RIGHT; - break; - case SWT.ARROW_UP: - naturalKey = SpecialKey.ARROW_UP; - break; - case SWT.BREAK: - naturalKey = SpecialKey.BREAK; - break; - case SWT.CAPS_LOCK: - naturalKey = SpecialKey.CAPS_LOCK; - break; - case SWT.END: - naturalKey = SpecialKey.END; - break; - case SWT.F1: - naturalKey = SpecialKey.F1; - break; - case SWT.F10: - naturalKey = SpecialKey.F10; - break; - case SWT.F11: - naturalKey = SpecialKey.F11; - break; - case SWT.F12: - naturalKey = SpecialKey.F12; - break; - case SWT.F2: - naturalKey = SpecialKey.F2; - break; - case SWT.F3: - naturalKey = SpecialKey.F3; - break; - case SWT.F4: - naturalKey = SpecialKey.F4; - break; - case SWT.F5: - naturalKey = SpecialKey.F5; - break; - case SWT.F6: - naturalKey = SpecialKey.F6; - break; - case SWT.F7: - naturalKey = SpecialKey.F7; - break; - case SWT.F8: - naturalKey = SpecialKey.F8; - break; - case SWT.F9: - naturalKey = SpecialKey.F9; - break; - case SWT.HOME: - naturalKey = SpecialKey.HOME; - break; - case SWT.INSERT: - naturalKey = SpecialKey.INSERT; - break; - case SWT.KEYPAD_0: - naturalKey = SpecialKey.NUMPAD_0; - break; - case SWT.KEYPAD_1: - naturalKey = SpecialKey.NUMPAD_1; - break; - case SWT.KEYPAD_2: - naturalKey = SpecialKey.NUMPAD_2; - break; - case SWT.KEYPAD_3: - naturalKey = SpecialKey.NUMPAD_3; - break; - case SWT.KEYPAD_4: - naturalKey = SpecialKey.NUMPAD_4; - break; - case SWT.KEYPAD_5: - naturalKey = SpecialKey.NUMPAD_5; - break; - case SWT.KEYPAD_6: - naturalKey = SpecialKey.NUMPAD_6; - break; - case SWT.KEYPAD_7: - naturalKey = SpecialKey.NUMPAD_7; - break; - case SWT.KEYPAD_8: - naturalKey = SpecialKey.NUMPAD_8; - break; - case SWT.KEYPAD_9: - naturalKey = SpecialKey.NUMPAD_9; - break; - case SWT.KEYPAD_ADD: - naturalKey = SpecialKey.NUMPAD_ADD; - break; - case SWT.KEYPAD_CR: - naturalKey = SpecialKey.NUMPAD_ENTER; - break; - case SWT.KEYPAD_DECIMAL: - naturalKey = SpecialKey.NUMPAD_DECIMAL; - break; - case SWT.KEYPAD_DIVIDE: - naturalKey = SpecialKey.NUMPAD_DIVIDE; - break; - case SWT.KEYPAD_EQUAL: - naturalKey = SpecialKey.NUMPAD_EQUAL; - break; - case SWT.KEYPAD_MULTIPLY: - naturalKey = SpecialKey.NUMPAD_MULTIPLY; - break; - case SWT.KEYPAD_SUBTRACT: - naturalKey = SpecialKey.NUMPAD_SUBTRACT; - break; - case SWT.NUM_LOCK: - naturalKey = SpecialKey.NUM_LOCK; - break; - case SWT.PAGE_DOWN: - naturalKey = SpecialKey.PAGE_DOWN; - break; - case SWT.PAGE_UP: - naturalKey = SpecialKey.PAGE_UP; - break; - case SWT.PAUSE: - naturalKey = SpecialKey.PAUSE; - break; - case SWT.PRINT_SCREEN: - naturalKey = SpecialKey.PRINT_SCREEN; - break; - case SWT.SCROLL_LOCK: - naturalKey = SpecialKey.SCROLL_LOCK; - break; - default: - naturalKey = CharacterKey.getInstance((char) (accelerator & 0xFFFF)); - } - } - - return KeyStroke.getInstance(modifierKeys, naturalKey); - } - - /** - *

- * Converts the given event into an SWT accelerator value -- considering the - * modified character with the shift modifier. This is the third accelerator - * value that should be checked. - *

- *

- * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as - * "Ctrl+Shift+%". - *

- * - * @param event The event to be converted; must not be null. - * @return The combination of the state mask and the unmodified character. - */ - @Deprecated - public static int convertEventToModifiedAccelerator(Event event) { - int modifiers = event.stateMask & SWT.MODIFIER_MASK; - char character = topKey(event); - return modifiers + toUpperCase(character); - } - - /** - *

- * Converts the given event into an SWT accelerator value -- considering the - * unmodified character with all modifier keys. This is the first accelerator - * value that should be checked. However, all alphabetic characters are - * considered as their uppercase equivalents. - *

- *

- * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as - * "Ctrl+Shift+5". - *

- * - * @param event The event to be converted; must not be null. - * @return The combination of the state mask and the unmodified character. - */ - @Deprecated - public static int convertEventToUnmodifiedAccelerator(Event event) { - return convertEventToUnmodifiedAccelerator(event.stateMask, event.keyCode); - } - - /** - *

- * Converts the given state mask and key code into an SWT accelerator value -- - * considering the unmodified character with all modifier keys. All alphabetic - * characters are considered as their uppercase equivalents. - *

- *

- * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as - * "Ctrl+Shift+5". - *

- * - * @param stateMask The integer mask of modifiers keys depressed when this was - * pressed. - * @param keyCode The key that was pressed, before being modified. - * @return The combination of the state mask and the unmodified character. - */ - private static int convertEventToUnmodifiedAccelerator(int stateMask, int keyCode) { - int modifiers = stateMask & SWT.MODIFIER_MASK; - int character = keyCode; - return modifiers + toUpperCase(character); - } - - /** - *

- * Converts the given event into an SWT accelerator value -- considering the - * unmodified character with all modifier keys. This is the first accelerator - * value that should be checked. However, all alphabetic characters are - * considered as their uppercase equivalents. - *

- *

- * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as - * "Ctrl+%". - *

- * - * @param event The event to be converted; must not be null. - * @return The combination of the state mask and the unmodified character. - */ - @Deprecated - public static int convertEventToUnmodifiedAccelerator(KeyEvent event) { - return convertEventToUnmodifiedAccelerator(event.stateMask, event.keyCode); - } - - /** - * Converts the given event into an SWT accelerator value -- considering the - * modified character without the shift modifier. This is the second accelerator - * value that should be checked. Key strokes with alphabetic natural keys are - * run through convertEventToUnmodifiedAccelerator - * - * @param event The event to be converted; must not be null. - * @return The combination of the state mask without shift, and the modified - * character. - */ - @Deprecated - public static int convertEventToUnshiftedModifiedAccelerator(Event event) { - // Disregard alphabetic key strokes. - if (Character.isLetter((char) event.keyCode)) { - return convertEventToUnmodifiedAccelerator(event); - } - - int modifiers = event.stateMask & (SWT.MODIFIER_MASK ^ SWT.SHIFT); - char character = topKey(event); - return modifiers + toUpperCase(character); - } - - /** - * Given a key stroke, this method provides the equivalent SWT accelerator - * value. The functional inverse of convertAcceleratorToKeyStroke. - * - * @param keyStroke The key stroke to convert; must not be null. - * @return The SWT accelerator value - */ - @Deprecated - public static int convertKeyStrokeToAccelerator(final KeyStroke keyStroke) { - int accelerator = 0; - final Iterator iterator = keyStroke.getModifierKeys().iterator(); - - while (iterator.hasNext()) { - final ModifierKey modifierKey = iterator.next(); - - if (modifierKey == ModifierKey.ALT) { - accelerator |= SWT.ALT; - } else if (modifierKey == ModifierKey.COMMAND) { - accelerator |= SWT.COMMAND; - } else if (modifierKey == ModifierKey.CTRL) { - accelerator |= SWT.CTRL; - } else if (modifierKey == ModifierKey.SHIFT) { - accelerator |= SWT.SHIFT; - } - } - - final NaturalKey naturalKey = keyStroke.getNaturalKey(); - - if (naturalKey instanceof CharacterKey) { - accelerator |= ((CharacterKey) naturalKey).getCharacter(); - } else if (naturalKey instanceof final SpecialKey specialKey) { - if (specialKey == SpecialKey.ARROW_DOWN) { - accelerator |= SWT.ARROW_DOWN; - } else if (specialKey == SpecialKey.ARROW_LEFT) { - accelerator |= SWT.ARROW_LEFT; - } else if (specialKey == SpecialKey.ARROW_RIGHT) { - accelerator |= SWT.ARROW_RIGHT; - } else if (specialKey == SpecialKey.ARROW_UP) { - accelerator |= SWT.ARROW_UP; - } else if (specialKey == SpecialKey.END) { - accelerator |= SWT.END; - } else if (specialKey == SpecialKey.F1) { - accelerator |= SWT.F1; - } else if (specialKey == SpecialKey.F10) { - accelerator |= SWT.F10; - } else if (specialKey == SpecialKey.F11) { - accelerator |= SWT.F11; - } else if (specialKey == SpecialKey.F12) { - accelerator |= SWT.F12; - } else if (specialKey == SpecialKey.F2) { - accelerator |= SWT.F2; - } else if (specialKey == SpecialKey.F3) { - accelerator |= SWT.F3; - } else if (specialKey == SpecialKey.F4) { - accelerator |= SWT.F4; - } else if (specialKey == SpecialKey.F5) { - accelerator |= SWT.F5; - } else if (specialKey == SpecialKey.F6) { - accelerator |= SWT.F6; - } else if (specialKey == SpecialKey.F7) { - accelerator |= SWT.F7; - } else if (specialKey == SpecialKey.F8) { - accelerator |= SWT.F8; - } else if (specialKey == SpecialKey.F9) { - accelerator |= SWT.F9; - } else if (specialKey == SpecialKey.HOME) { - accelerator |= SWT.HOME; - } else if (specialKey == SpecialKey.INSERT) { - accelerator |= SWT.INSERT; - } else if (specialKey == SpecialKey.PAGE_DOWN) { - accelerator |= SWT.PAGE_DOWN; - } else if (specialKey == SpecialKey.PAGE_UP) { - accelerator |= SWT.PAGE_UP; - } - } - - return accelerator; - } - - private static final IKeyFormatter NATIVE_FORMATTER = new NativeKeyFormatter(); - - /** - * Provides an instance of IKeyFormatter appropriate for the - * current instance. - * - * @return an instance of IKeyFormatter appropriate for the current - * instance; never null. - */ - @Deprecated - public static IKeyFormatter getKeyFormatterForPlatform() { - return NATIVE_FORMATTER; - } - - /** - * Makes sure that a fully-modified character is converted to the normal form. - * This means that "Ctrl+" key strokes must reverse the modification caused by - * control-escaping. Also, all lower case letters are converted to uppercase. - * - * @param event The event from which the fully-modified character should be - * pulled. - * @return The modified character, uppercase and without control-escaping. - */ - private static char topKey(Event event) { - char character = event.character; - boolean ctrlDown = (event.stateMask & SWT.CTRL) != 0; - - if (ctrlDown && event.character != event.keyCode && event.character < 0x20) { - character += 0x40; - } - - return character; - } - - /** - * Makes the given character uppercase if it is a letter. - * - * @param keyCode The character to convert. - * @return The uppercase equivalent, if any; otherwise, the character itself. - */ - private static int toUpperCase(int keyCode) { - // Will this key code be truncated? - if (keyCode > 0xFFFF) { - return keyCode; - } - - // Downcast in safety. Only make characters uppercase. - char character = (char) keyCode; - return Character.isLetter(character) ? Character.toUpperCase(character) : keyCode; - } - - /** - * This class should never be instantiated. - */ - private SWTKeySupport() { - // This class should never be instantiated. - } -} diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SpecialKey.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SpecialKey.java deleted file mode 100644 index 8a8ac127cd2d..000000000000 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/keys/SpecialKey.java +++ /dev/null @@ -1,486 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.keys; - -import java.util.SortedMap; -import java.util.TreeMap; -import org.eclipse.jface.bindings.keys.IKeyLookup; -import org.eclipse.jface.bindings.keys.KeyLookupFactory; - -/** - *

- * Instances of SpecialKey represent the keys on keyboard - * recognized as neither modifier keys nor character keys. These are special - * control keys specific to computers (e.g., "left arrow", "page down", "F10", - * etc.). They do not include keys representing letters, numbers or punctuation - * from a natural language, nor do they include any key that can be represented - * by a Unicode character (e.g., "backspace"). - *

- *

- * SpecialKey objects are immutable. Clients are not permitted to - * extend this class. - *

- * - * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and - * org.eclipse.jface.bindings.keys.KeyLookupFactory - * @since 3.0 - */ -@Deprecated(forRemoval = true, since = "2024-03") -public final class SpecialKey extends NaturalKey { - - /** - * An internal map used to lookup instances of SpecialKey given the - * formal string representation of a special key. - */ - @Deprecated - static SortedMap specialKeysByName = new TreeMap<>(); - - /** - * The single static instance of SpecialKey which represents the - * 'Arrow Down' key. - */ - @Deprecated - public static final SpecialKey ARROW_DOWN; - - /** - * The single static instance of SpecialKey which represents the - * 'Arrow Left' key. - */ - @Deprecated - public static final SpecialKey ARROW_LEFT; - - /** - * The single static instance of SpecialKey which represents the - * 'Arrow Right' key. - */ - @Deprecated - public static final SpecialKey ARROW_RIGHT; - - /** - * The single static instance of SpecialKey which represents the - * 'Arrow Up' key. - */ - @Deprecated - public static final SpecialKey ARROW_UP; - - /** - * The single static instance of SpecialKey which represents the - * 'Break' key. - */ - @Deprecated - public static final SpecialKey BREAK; - - /** - * The single static instance of SpecialKey which represents the - * 'Caps Lock' key. - */ - @Deprecated - public static final SpecialKey CAPS_LOCK; - - /** - * The single static instance of SpecialKey which represents the - * 'End' key. - */ - @Deprecated - public static final SpecialKey END; - - /** - * The single static instance of SpecialKey which represents the - * 'F1' key. - */ - @Deprecated - public static final SpecialKey F1; - - /** - * The single static instance of SpecialKey which represents the - * 'F10' key. - */ - @Deprecated - public static final SpecialKey F10; - - /** - * The single static instance of SpecialKey which represents the - * 'F11' key. - */ - @Deprecated - public static final SpecialKey F11; - - /** - * The single static instance of SpecialKey which represents the - * 'F12' key. - */ - @Deprecated - public static final SpecialKey F12; - - /** - * The single static instance of SpecialKey which represents the - * 'F13' key. - */ - @Deprecated - public static final SpecialKey F13; - - /** - * The single static instance of SpecialKey which represents the - * 'F14' key. - */ - @Deprecated - public static final SpecialKey F14; - - /** - * The single static instance of SpecialKey which represents the - * 'F15' key. - */ - @Deprecated - public static final SpecialKey F15; - - /** - * The single static instance of SpecialKey which represents the - * 'F2' key. - */ - @Deprecated - public static final SpecialKey F2; - - /** - * The single static instance of SpecialKey which represents the - * 'F3' key. - */ - @Deprecated - public static final SpecialKey F3; - - /** - * The single static instance of SpecialKey which represents the - * 'F4' key. - */ - @Deprecated - public static final SpecialKey F4; - - /** - * The single static instance of SpecialKey which represents the - * 'F5' key. - */ - @Deprecated - public static final SpecialKey F5; - - /** - * The single static instance of SpecialKey which represents the - * 'F6' key. - */ - @Deprecated - public static final SpecialKey F6; - - /** - * The single static instance of SpecialKey which represents the - * 'F7' key. - */ - @Deprecated - public static final SpecialKey F7; - - /** - * The single static instance of SpecialKey which represents the - * 'F8' key. - */ - @Deprecated - public static final SpecialKey F8; - - /** - * The single static instance of SpecialKey which represents the - * 'F9' key. - */ - @Deprecated - public static final SpecialKey F9; - - /** - * The single static instance of SpecialKey which represents the - * 'Home' key. - */ - @Deprecated - public static final SpecialKey HOME; - - /** - * The single static instance of SpecialKey which represents the - * 'Insert' key. - */ - @Deprecated - public static final SpecialKey INSERT; - - /** - * The single static instance of SpecialKey which represents the - * 'NumLock' key. - */ - @Deprecated - public static final SpecialKey NUM_LOCK; - - /** - * The single static instance of SpecialKey which represents the - * '0' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_0; - - /** - * The single static instance of SpecialKey which represents the - * '1' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_1; - - /** - * The single static instance of SpecialKey which represents the - * '2' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_2; - - /** - * The single static instance of SpecialKey which represents the - * '3' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_3; - - /** - * The single static instance of SpecialKey which represents the - * '4' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_4; - - /** - * The single static instance of SpecialKey which represents the - * '5' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_5; - - /** - * The single static instance of SpecialKey which represents the - * '6' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_6; - - /** - * The single static instance of SpecialKey which represents the - * '7' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_7; - - /** - * The single static instance of SpecialKey which represents the - * '8' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_8; - - /** - * The single static instance of SpecialKey which represents the - * '9' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_9; - - /** - * The single static instance of SpecialKey which represents the - * 'Add' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_ADD; - - /** - * The single static instance of SpecialKey which represents the - * 'Decimal' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_DECIMAL; - - /** - * The single static instance of SpecialKey which represents the - * 'Divide' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_DIVIDE; - - /** - * The single static instance of SpecialKey which represents the - * 'Enter' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_ENTER; - - /** - * The single static instance of SpecialKey which represents the - * '=' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_EQUAL; - - /** - * The single static instance of SpecialKey which represents the - * 'Multiply' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_MULTIPLY; - - /** - * The single static instance of SpecialKey which represents the - * 'Subtract' key on the numpad. - */ - @Deprecated - public static final SpecialKey NUMPAD_SUBTRACT; - - /** - * The single static instance of SpecialKey which represents the - * 'Page Down' key. - */ - @Deprecated - public static final SpecialKey PAGE_DOWN; - - /** - * The single static instance of SpecialKey which represents the - * 'Page Up' key. - */ - @Deprecated - public static final SpecialKey PAGE_UP; - - /** - * The single static instance of SpecialKey which represents the - * 'Pause' key. - */ - @Deprecated - public static final SpecialKey PAUSE; - - /** - * The single static instance of SpecialKey which represents the - * 'Print Screen' key. - */ - @Deprecated - public static final SpecialKey PRINT_SCREEN; - - /** - * The single static instance of SpecialKey which represents the - * 'Scroll Lock' key. - */ - @Deprecated - public static final SpecialKey SCROLL_LOCK; - - static { - final IKeyLookup lookup = KeyLookupFactory.getDefault(); - ARROW_DOWN = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.ARROW_DOWN_NAME)); - ARROW_LEFT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.ARROW_LEFT_NAME)); - ARROW_RIGHT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.ARROW_RIGHT_NAME)); - ARROW_UP = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.ARROW_UP_NAME)); - BREAK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.BREAK_NAME)); - CAPS_LOCK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.CAPS_LOCK_NAME)); - END = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.END_NAME)); - F1 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F1_NAME)); - F2 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F2_NAME)); - F3 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F3_NAME)); - F4 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F4_NAME)); - F5 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F5_NAME)); - F6 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F6_NAME)); - F7 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F7_NAME)); - F8 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F8_NAME)); - F9 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F9_NAME)); - F10 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F10_NAME)); - F11 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F11_NAME)); - F12 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F12_NAME)); - F13 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F13_NAME)); - F14 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F14_NAME)); - F15 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F15_NAME)); - HOME = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.HOME_NAME)); - INSERT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.INSERT_NAME)); - NUM_LOCK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUM_LOCK_NAME)); - NUMPAD_0 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_0_NAME)); - NUMPAD_1 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_1_NAME)); - NUMPAD_2 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_2_NAME)); - NUMPAD_3 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_3_NAME)); - NUMPAD_4 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_4_NAME)); - NUMPAD_5 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_5_NAME)); - NUMPAD_6 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_6_NAME)); - NUMPAD_7 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_7_NAME)); - NUMPAD_8 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_8_NAME)); - NUMPAD_9 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_9_NAME)); - NUMPAD_ADD = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_ADD_NAME)); - NUMPAD_DECIMAL = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_DECIMAL_NAME)); - NUMPAD_DIVIDE = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_DIVIDE_NAME)); - NUMPAD_ENTER = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_ENTER_NAME)); - NUMPAD_EQUAL = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_EQUAL_NAME)); - NUMPAD_MULTIPLY = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_MULTIPLY_NAME)); - NUMPAD_SUBTRACT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.NUMPAD_SUBTRACT_NAME)); - PAGE_DOWN = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PAGE_DOWN_NAME)); - PAGE_UP = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PAGE_UP_NAME)); - PAUSE = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PAUSE_NAME)); - PRINT_SCREEN = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PRINT_SCREEN_NAME)); - SCROLL_LOCK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.SCROLL_LOCK_NAME)); - - specialKeysByName.put(SpecialKey.ARROW_DOWN.toString(), SpecialKey.ARROW_DOWN); - specialKeysByName.put(SpecialKey.ARROW_LEFT.toString(), SpecialKey.ARROW_LEFT); - specialKeysByName.put(SpecialKey.ARROW_RIGHT.toString(), SpecialKey.ARROW_RIGHT); - specialKeysByName.put(SpecialKey.ARROW_UP.toString(), SpecialKey.ARROW_UP); - specialKeysByName.put(SpecialKey.BREAK.toString(), SpecialKey.BREAK); - specialKeysByName.put(SpecialKey.CAPS_LOCK.toString(), SpecialKey.CAPS_LOCK); - specialKeysByName.put(SpecialKey.END.toString(), SpecialKey.END); - specialKeysByName.put(SpecialKey.F1.toString(), SpecialKey.F1); - specialKeysByName.put(SpecialKey.F10.toString(), SpecialKey.F10); - specialKeysByName.put(SpecialKey.F11.toString(), SpecialKey.F11); - specialKeysByName.put(SpecialKey.F12.toString(), SpecialKey.F12); - specialKeysByName.put(SpecialKey.F13.toString(), SpecialKey.F13); - specialKeysByName.put(SpecialKey.F14.toString(), SpecialKey.F14); - specialKeysByName.put(SpecialKey.F15.toString(), SpecialKey.F15); - specialKeysByName.put(SpecialKey.F2.toString(), SpecialKey.F2); - specialKeysByName.put(SpecialKey.F3.toString(), SpecialKey.F3); - specialKeysByName.put(SpecialKey.F4.toString(), SpecialKey.F4); - specialKeysByName.put(SpecialKey.F5.toString(), SpecialKey.F5); - specialKeysByName.put(SpecialKey.F6.toString(), SpecialKey.F6); - specialKeysByName.put(SpecialKey.F7.toString(), SpecialKey.F7); - specialKeysByName.put(SpecialKey.F8.toString(), SpecialKey.F8); - specialKeysByName.put(SpecialKey.F9.toString(), SpecialKey.F9); - specialKeysByName.put(SpecialKey.NUM_LOCK.toString(), SpecialKey.NUM_LOCK); - specialKeysByName.put(SpecialKey.NUMPAD_0.toString(), SpecialKey.NUMPAD_0); - specialKeysByName.put(SpecialKey.NUMPAD_1.toString(), SpecialKey.NUMPAD_1); - specialKeysByName.put(SpecialKey.NUMPAD_2.toString(), SpecialKey.NUMPAD_2); - specialKeysByName.put(SpecialKey.NUMPAD_3.toString(), SpecialKey.NUMPAD_3); - specialKeysByName.put(SpecialKey.NUMPAD_4.toString(), SpecialKey.NUMPAD_4); - specialKeysByName.put(SpecialKey.NUMPAD_5.toString(), SpecialKey.NUMPAD_5); - specialKeysByName.put(SpecialKey.NUMPAD_6.toString(), SpecialKey.NUMPAD_6); - specialKeysByName.put(SpecialKey.NUMPAD_7.toString(), SpecialKey.NUMPAD_7); - specialKeysByName.put(SpecialKey.NUMPAD_8.toString(), SpecialKey.NUMPAD_8); - specialKeysByName.put(SpecialKey.NUMPAD_9.toString(), SpecialKey.NUMPAD_9); - specialKeysByName.put(SpecialKey.NUMPAD_ADD.toString(), SpecialKey.NUMPAD_ADD); - specialKeysByName.put(SpecialKey.NUMPAD_DECIMAL.toString(), SpecialKey.NUMPAD_DECIMAL); - specialKeysByName.put(SpecialKey.NUMPAD_DIVIDE.toString(), SpecialKey.NUMPAD_DIVIDE); - specialKeysByName.put(SpecialKey.NUMPAD_ENTER.toString(), SpecialKey.NUMPAD_ENTER); - specialKeysByName.put(SpecialKey.NUMPAD_EQUAL.toString(), SpecialKey.NUMPAD_EQUAL); - specialKeysByName.put(SpecialKey.NUMPAD_MULTIPLY.toString(), SpecialKey.NUMPAD_MULTIPLY); - specialKeysByName.put(SpecialKey.NUMPAD_SUBTRACT.toString(), SpecialKey.NUMPAD_SUBTRACT); - specialKeysByName.put(SpecialKey.HOME.toString(), SpecialKey.HOME); - specialKeysByName.put(SpecialKey.INSERT.toString(), SpecialKey.INSERT); - specialKeysByName.put(SpecialKey.PAGE_DOWN.toString(), SpecialKey.PAGE_DOWN); - specialKeysByName.put(SpecialKey.PAGE_UP.toString(), SpecialKey.PAGE_UP); - specialKeysByName.put(SpecialKey.PAUSE.toString(), SpecialKey.PAUSE); - specialKeysByName.put(SpecialKey.PRINT_SCREEN.toString(), SpecialKey.PRINT_SCREEN); - specialKeysByName.put(SpecialKey.SCROLL_LOCK.toString(), SpecialKey.SCROLL_LOCK); - } - - /** - * Constructs an instance of SpecialKey given a name. - * - * @param key The key to be wrapped. - */ - private SpecialKey(final int key) { - super(key); - } -} diff --git a/bundles/org.eclipse.ui/.settings/.api_filters b/bundles/org.eclipse.ui/.settings/.api_filters new file mode 100644 index 000000000000..2249f74bc61f --- /dev/null +++ b/bundles/org.eclipse.ui/.settings/.api_filters @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java deleted file mode 100644 index bb6972935d3e..000000000000 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.tests.keys; - -import static org.junit.Assert.assertEquals; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.keys.KeyStroke; -import org.eclipse.ui.keys.ParseException; -import org.eclipse.ui.keys.SWTKeySupport; -import org.junit.Test; - -/** - * Test for Bug 42035. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -public class Bug42035Test { - - /** - * Tests the given key event to see if generates the three key strokes - * represented by the strings. - * - * @param keyEvent - * The key event to generate key strokes from; must not be - * null - * @param firstMatch - * The text format of the first match; must not be null. - * @param secondMatch - * The text format of the second match; must not be null. - * @param thirdMatch - * The text format of the third match; must not be null. - * @throws ParseException - * If anyone of the text formats provided cannot be parsed. - */ - private static void testKeyEvent(Event keyEvent, String firstMatch, - String secondMatch, String thirdMatch) throws ParseException { - KeyStroke desiredKeyStroke = null; - KeyStroke actualKeyStroke = null; - - // Test the first-level match. - desiredKeyStroke = KeyStroke.getInstance(firstMatch); - actualKeyStroke = SWTKeySupport - .convertAcceleratorToKeyStroke(SWTKeySupport - .convertEventToUnmodifiedAccelerator(keyEvent)); - assertEquals( - "Unmodified character with all modifiers doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$ - - // Test the second-level match. - desiredKeyStroke = KeyStroke.getInstance(secondMatch); - actualKeyStroke = SWTKeySupport - .convertAcceleratorToKeyStroke(SWTKeySupport - .convertEventToUnshiftedModifiedAccelerator(keyEvent)); - assertEquals( - "Modified character with no shift doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$ - - // Test the third-level match. - desiredKeyStroke = KeyStroke.getInstance(thirdMatch); - actualKeyStroke = SWTKeySupport - .convertAcceleratorToKeyStroke(SWTKeySupport - .convertEventToModifiedAccelerator(keyEvent)); - assertEquals( - "Modified character with all modifiers doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$ - } - - /** - * Tests that "Ctrl+" generates "Ctrl+", "Ctrl+" and "Ctrl+". - * - * @throws ParseException - * If "CTRL+" cannot be processed. - */ - @Test - public void testCtrl() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = 0x40000; - keyEvent.character = 0x00; - keyEvent.stateMask = SWT.NONE; - - KeyStroke desiredKeyStroke = KeyStroke.getInstance("CTRL+"); //$NON-NLS-1$ - KeyStroke actualKeyStroke = SWTKeySupport - .convertAcceleratorToKeyStroke(SWTKeySupport - .convertEventToUnmodifiedAccelerator(keyEvent)); - assertEquals( - "Unmodified character with all modifiers doesn't match", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$ - } - - /** - * Tests that "Ctrl+Enter" generates "Ctrl+Enter", "Ctrl+Enter" and - * "Ctrl+Enter". - * - * @throws ParseException - * If "CTRL+ENTER" cannot be processed. - */ - @Test - public void testCtrlEnter() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = 0x0D; - keyEvent.character = 0x0D; - keyEvent.stateMask = SWT.CTRL; - - testKeyEvent(keyEvent, "CTRL+CR", "CTRL+CR", "CTRL+CR"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Tests that "Ctrl+J" generates "Ctrl+M", "Ctrl+M" and "Ctrl+M". - * - * @throws ParseException - * If "CTRL+M" cannot be processed. - */ - @Test - public void testCtrlM() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = 0x6D; - keyEvent.character = 0x0D; - keyEvent.stateMask = SWT.CTRL; - - testKeyEvent(keyEvent, "CTRL+M", "CTRL+M", "CTRL+M"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Tests that "Ctrl+Shift+2" generates "Ctrl+Shift+2", "Ctrl+@" and - * "Ctrl+Shift+@". This simulates a U.S. keyboard layout. - * - * @throws ParseException - * If "CTRL+SHIFT+2", "CTRL+@" or "CTRL+SHIFT+@" cannot be - * processed. - */ - @Test - public void testCtrlShift2() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = '2'; - keyEvent.character = 0x00; - keyEvent.stateMask = SWT.CTRL | SWT.SHIFT; - - testKeyEvent(keyEvent, "CTRL+SHIFT+2", "CTRL+@", "CTRL+SHIFT+@"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Tests that "Ctrl+Shift+7" generates "Ctrl+Shift+7", "Ctrl+/" and - * "Ctrl+Shift+/". This simulates a Swiss-German keyboard layout. - * - * @throws ParseException - * If "CTRL+SHIFT+7", "CTRL+/" or "CTRL+SHIFT+/" cannot be - * processed. - */ - @Test - public void testCtrlShift7_SwissGerman() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = '7'; - keyEvent.character = '/'; - keyEvent.stateMask = SWT.CTRL | SWT.SHIFT; - - testKeyEvent(keyEvent, "CTRL+SHIFT+7", "CTRL+/", "CTRL+SHIFT+/"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Tests that "Ctrl+Shift+7" generates "Ctrl+Shift+7", "Ctrl+&" and - * "Ctrl+Shift+&". This simulates a US keyboard layout. - * - * @throws ParseException - * If "CTRL+SHIFT+7", "CTRL+&" or "CTRL+SHIFT+&" cannot be - * processed. - */ - @Test - public void testCtrlShift7_US() throws ParseException { - Event keyEvent = new Event(); - keyEvent.keyCode = '7'; - keyEvent.character = '&'; - keyEvent.stateMask = SWT.CTRL | SWT.SHIFT; - - testKeyEvent(keyEvent, "CTRL+SHIFT+7", "CTRL+&", "CTRL+SHIFT+&"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } -} diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java deleted file mode 100644 index 619b9cdae7f3..000000000000 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.tests.keys; - -import static org.junit.Assert.assertEquals; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.keys.SWTKeySupport; -import org.junit.Test; - -/** - * Test for Bug 43800. - * - * @since 3.0 - */ -@SuppressWarnings("removal") -public class Bug43800Test { - - /** - * Tests that key pressed with key codes greater than 16 bits are correctly - * converted into accelerator values. - */ - @Test - public void testTruncatingCast() { - /* - * Make an event representing a key stroke with a key code greater than 16 bits. - */ - Event event = new Event(); - event.keyCode = SWT.ARROW_LEFT; - event.character = 0x00; - event.stateMask = 0x00; - - // Convert the event, and test the resulting accelerator value. - int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); - assertEquals("Arrow_Left key truncated.", SWT.ARROW_LEFT, accelerator); //$NON-NLS-1$ - } -} diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java index a86030271b95..56a2bbb10eb7 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java @@ -28,14 +28,12 @@ Bug36537Test.class, Bug40023Test.class, Bug42024Test.class, - Bug42035Test.class, Bug42627Test.class, Bug43168Test.class, Bug43321Test.class, Bug43538Test.class, Bug43597Test.class, Bug43610Test.class, - Bug43800Test.class, KeysCsvTest.class, Bug44460Test.class, Bug53489Test.class, diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java index 7a54f177e3aa..89a4e969e961 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -27,7 +27,6 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.keys.ParseException; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; import org.junit.Ignore; @@ -41,7 +40,6 @@ * * @since 3.0 */ -@SuppressWarnings("removal") @Ignore("Focus issues, see Commit c28efd634f53c9de7bb31b756ffc755b8faf0ffe") public class MultiPageKeyBindingTest { @@ -54,11 +52,9 @@ public class MultiPageKeyBindingTest { * * @throws CoreException * If the project or file cannot be created. - * @throws ParseException - * The expected key sequence cannot be parsed. */ @Test - public void testSwitch() throws CoreException, ParseException { + public void testSwitch() throws CoreException { final String extension = "multi"; //$NON-NLS-1$ final String fileName = "A." + extension; //$NON-NLS-1$