diff --git a/editor.lib/nbproject/project.properties b/editor.lib/nbproject/project.properties --- a/editor.lib/nbproject/project.properties +++ b/editor.lib/nbproject/project.properties @@ -39,7 +39,7 @@ javac.compilerargs=-Xlint:unchecked javac.source=1.5 -spec.version.base=1.30.0 +spec.version.base=1.31.0 is.autoload=true javadoc.arch=${basedir}/arch.xml diff --git a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java --- a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java +++ b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java @@ -96,6 +96,7 @@ private boolean hyperlinkEnabled; private int actionKeyMask; + private int altActionKeyMask; public static void ensureRegistered(JTextComponent component, String mimeType) { if (component.getClientProperty(KEY) == null) { @@ -106,6 +107,7 @@ private static synchronized Cursor getMouseCursor(HyperlinkType type) { switch (type) { case GO_TO_DECLARATION: + case GO_TO_ALT_DECLARATION: return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); default: throw new UnsupportedOperationException(); @@ -196,6 +198,7 @@ Preferences prefs = MimeLookup.getLookup(DocumentUtilities.getMimeType(component)).lookup(Preferences.class); this.actionKeyMask = prefs.getInt(SimpleValueNames.HYPERLINK_ACTIVATION_MODIFIERS, InputEvent.CTRL_DOWN_MASK); + this.altActionKeyMask = prefs.getInt(SimpleValueNames.ALT_HYPERLINK_ACTIVATION_MODIFIERS, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK); } public void mouseMoved(MouseEvent e) { @@ -221,7 +224,13 @@ } private HyperlinkType getHyperlinkType(InputEvent e) { - return ((e.getModifiers() | e.getModifiersEx()) & actionKeyMask) == actionKeyMask ? HyperlinkType.GO_TO_DECLARATION : null; + int modifiers = e.getModifiers() | e.getModifiersEx(); + if ((modifiers & altActionKeyMask) == altActionKeyMask) { + return HyperlinkType.GO_TO_ALT_DECLARATION; + } else if ((modifiers & actionKeyMask) == actionKeyMask) { + return HyperlinkType.GO_TO_DECLARATION; + } + return null; } private void performHyperlinking(int position, HyperlinkType type) { @@ -357,8 +366,9 @@ } public void keyReleased(KeyEvent e) { - if ((e.getModifiers() & actionKeyMask) == 0) + if (getHyperlinkType(e) == null) { unHyperlink(true); + } } public void keyPressed(KeyEvent e) { diff --git a/editor.lib/src/org/netbeans/lib/editor/hyperlink/spi/HyperlinkType.java b/editor.lib/src/org/netbeans/lib/editor/hyperlink/spi/HyperlinkType.java --- a/editor.lib/src/org/netbeans/lib/editor/hyperlink/spi/HyperlinkType.java +++ b/editor.lib/src/org/netbeans/lib/editor/hyperlink/spi/HyperlinkType.java @@ -40,17 +40,22 @@ */ package org.netbeans.lib.editor.hyperlink.spi; -/**A type of work for hyperlinks. Currently, there is only one hyperlink type - * (go to declaration), but more can be introduced in the future. +/**A type of work for hyperlinks. * * @since 1.18 * @author Jan Lahoda */ public enum HyperlinkType { - /** + /** + * go to declaration * @since 1.18 */ GO_TO_DECLARATION, - + + /** + * go to alternative declaration + * @since 1.31 + */ + GO_TO_ALT_DECLARATION, } diff --git a/editor.settings/manifest.mf b/editor.settings/manifest.mf --- a/editor.settings/manifest.mf +++ b/editor.settings/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.editor.settings/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/settings/Bundle.properties -OpenIDE-Module-Specification-Version: 1.23 +OpenIDE-Module-Specification-Version: 1.24 OpenIDE-Module-Needs: org.netbeans.api.editor.settings.implementation diff --git a/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java b/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java --- a/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java +++ b/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java @@ -373,6 +373,12 @@ */ public static final String HYPERLINK_ACTIVATION_MODIFIERS = "hyperlink-activation-modifiers"; //NOI18N + /** + * Modifiers for which the alternative hyperlinks should be enabled. + * @since 1.24 + */ + public static final String ALT_HYPERLINK_ACTIVATION_MODIFIERS = "alt-hyperlink-activation-modifiers"; //NOI18N + /** * Whether popup menu will be displayed on mouse right-click or not. * It's set to true by default.