diff options
author | Christian Georgi | 2015-03-21 11:47:23 +0000 |
---|---|---|
committer | Dani Megert | 2015-04-21 07:37:37 +0000 |
commit | 71251d2fc945eb663a3eaa6e898a98f4e9d6793d (patch) | |
tree | 4dc170637926b035ab6962c0b943819bdfeb316b | |
parent | cf6a78a0aca4711d9e133f8bd74280479b5ba99c (diff) | |
download | eclipse.jdt.ui-71251d2fc945eb663a3eaa6e898a98f4e9d6793d.tar.gz eclipse.jdt.ui-71251d2fc945eb663a3eaa6e898a98f4e9d6793d.tar.xz eclipse.jdt.ui-71251d2fc945eb663a3eaa6e898a98f4e9d6793d.zip |
Bug 462770: Properly format completion modifier key
Instead of hard-wiring 'Ctrl' use the OS symbol. This one is different
on MacOS at least.
Also use a constant for SWT.CTRL in both completion code and preference
page.
Change-Id: I25290a0396c369dca1e13bf2968479cc5eaaf0a9
Signed-off-by: Christian Georgi <christian.georgi@sap.com>
3 files changed, 19 insertions, 6 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java index 5395a70598..125995fafc 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,11 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Christian Georgi<christian.georgi@sap.com> - Bug 462770: Use OS symbol for 'Ctrl' *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.util.Map; +import org.eclipse.osgi.util.NLS; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -29,6 +32,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.bindings.keys.SWTKeySupport; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.jface.preference.IPreferenceStore; @@ -42,6 +46,7 @@ import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; import org.eclipse.jdt.internal.ui.text.java.ProposalSorterHandle; import org.eclipse.jdt.internal.ui.text.java.ProposalSorterRegistry; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; @@ -376,7 +381,8 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock { fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener); Label label= new Label(completionComposite, SWT.NONE); - label.setText(PreferencesMessages.JavaEditorPreferencePage_completionToggleHint); + String modifier= SWTKeySupport.getKeyFormatterForPlatform().format(AbstractJavaCompletionProposal.MODIFIER_TOGGLE_COMPLETION_MODE); + label.setText(NLS.bind(PreferencesMessages.JavaEditorPreferencePage_completionToggleHint, modifier)); GridData gd= new GridData(); gd.horizontalIndent= LayoutUtil.getIndent(); gd.horizontalSpan= 2; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties index 04c9237b58..9de665c8b2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2014 IBM Corporation and others. +# Copyright (c) 2000, 2015 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -13,6 +13,7 @@ # Guven Demir <guven.internet+eclipse@gmail.com> - [package explorer] Alternative package name shortening: abbreviation - https://bugs.eclipse.org/bugs/show_bug.cgi?id=299514 # Thomas Reinhardt <thomas@reinhardt.com> - [build path] user library dialog should allow to select JAR from workspace - http://bugs.eclipse.org/300542 # Stephan Herrmann <stephan@cs.tu-berlin.de> - [compiler][null] inheritance of null annotations as an option - https://bugs.eclipse.org/388281 +# Christian Georgi<christian.georgi@sap.com> - Use OS symbol for 'Ctrl' - https://bugs.eclipse.org/462770 ############################################################################### BuildPathsPropertyPage_error_message=An error occurred while setting the build path. @@ -145,7 +146,7 @@ JavaEditorPreferencePage_automaticallyAddImportInsteadOfQualifiedName=Add import JavaEditorPreferencePage_suggestStaticImports=&Use <a>static imports</a> (only 1.5 or higher) JavaEditorPreferencePage_completionInserts=Completion inser&ts JavaEditorPreferencePage_completionOverwrites=Completion over&writes -JavaEditorPreferencePage_completionToggleHint=Press 'Ctrl' to toggle while content assist is active +JavaEditorPreferencePage_completionToggleHint=Press ''{0}'' to toggle while content assist is active JavaEditorPreferencePage_fillArgumentsOnMethodCompletion=&Fill method arguments and show guessed arguments JavaEditorPreferencePage_fillParameterNamesOnMethodCompletion=I&nsert parameter names JavaEditorPreferencePage_fillBestGuessedArgumentsOnMethodCompletion=Insert best &guessed arguments diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java index 5549462f15..973e66cdec 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2014 IBM Corporation and others. + * Copyright (c) 2005, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Christian Georgi<christian.georgi@sap.com> - Bug 462770: Use OS symbol for 'Ctrl' *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; @@ -108,6 +109,11 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP /** + * The key modifier that toggles whether to insert or overwrite + */ + public static final int MODIFIER_TOGGLE_COMPLETION_MODE= SWT.CTRL; + + /** * A class to simplify tracking a reference position in a document. */ static final class ReferenceTracker { @@ -490,7 +496,7 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP // don't eat if not in preferences, XOR with Ctrl // but: if there is a selection, replace it! Point selection= viewer.getSelectedRange(); - fToggleEating= (stateMask & SWT.CTRL) != 0; + fToggleEating= (stateMask & MODIFIER_TOGGLE_COMPLETION_MODE) != 0; int newLength= selection.x + selection.y - getReplacementOffset(); if ((insertCompletion() ^ fToggleEating) && newLength >= 0) setReplacementLength(newLength); |