| author | Olav Lenz | 2013-01-27 09:53:20 (EST) |
|---|---|---|
| committer | Olav Lenz | 2013-01-29 12:44:28 (EST) |
| commit | 0d04d442259c52b0a3bf9c2097f8639eaae75a17 (patch) (side-by-side diff) | |
| tree | 8cab44693eb65c78b6ca1c078bace6abe5ed1cdb | |
| parent | 6da034301b1f54351336c66fabf570c069a5bc66 (diff) | |
| download | org.eclipse.recommenders-0d04d442259c52b0a3bf9c2097f8639eaae75a17.zip org.eclipse.recommenders-0d04d442259c52b0a3bf9c2097f8639eaae75a17.tar.gz org.eclipse.recommenders-0d04d442259c52b0a3bf9c2097f8639eaae75a17.tar.bz2 | |
[l10n] externalize strings in plugin *.rcp.sandbox and *.rcp.subwordsrefs/changes/51/9951/4
Change-Id: If5cbdab3173983cee6967084e74369e6680d16e4
25 files changed, 244 insertions, 53 deletions
diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/META-INF/MANIFEST.MF b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/META-INF/MANIFEST.MF index f2c97aa..a21fada 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Code Recommenders: Subwords Variable Name Matcher (Incubation) +Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.recommenders.completion.rcp.sandbox;singleton:=true Bundle-Version: 1.0.3.qualifier -Bundle-Vendor: Eclipse Code Recommenders +Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.core.runtime, org.eclipse.jdt.core, org.eclipse.jdt.ui, diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/OSGI-INF/l10n/bundle.properties b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..5b43c5b --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,3 @@ +#Properties file for org.eclipse.recommenders.completion.rcp.sandbox +Bundle-Vendor = Eclipse Code Recommenders +Bundle-Name = Code Recommenders: Subwords Variable Name Matcher (Incubation)
\ No newline at end of file diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/build.properties b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/build.properties index e7c4e2f..bed5aea 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/build.properties +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/build.properties @@ -3,7 +3,8 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ about.html,\ - icons/ + icons/,\ + OSGI-INF/l10n/bundle.properties source.. = src/ src.includes = about.html,\ pom.xml diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/Messages.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/Messages.java new file mode 100644 index 0000000..b5a0b19 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/Messages.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2010, 2012 Darmstadt University of Technology. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Olav Lenz - initial API and implementation. + */ +package org.eclipse.recommenders.completion.rcp.sandbox.l10n; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.recommenders.completion.rcp.sandbox.l10n.messages"; //$NON-NLS-1$ + public static String HIPPIE_COMPLETION_PROPOSAL; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/messages.properties b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/messages.properties new file mode 100644 index 0000000..2d6e0d2 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/completion/rcp/sandbox/l10n/messages.properties @@ -0,0 +1 @@ +HIPPIE_COMPLETION_PROPOSAL=hippie (%d) diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/HippieCompletionSessionProcessor.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/HippieCompletionSessionProcessor.java index 78a407a..cdb5dea 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/HippieCompletionSessionProcessor.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/HippieCompletionSessionProcessor.java @@ -16,6 +16,7 @@ import org.eclipse.recommenders.completion.rcp.IProcessableProposal; import org.eclipse.recommenders.completion.rcp.IRecommendersCompletionContext; import org.eclipse.recommenders.completion.rcp.ProposalProcessorManager; import org.eclipse.recommenders.completion.rcp.SessionProcessor; +import org.eclipse.recommenders.completion.rcp.sandbox.l10n.Messages; import org.eclipse.recommenders.internal.completion.rcp.SimpleProposalProcessor; import com.google.common.collect.HashMultiset; @@ -40,7 +41,7 @@ public class HippieCompletionSessionProcessor extends SessionProcessor { if (c == null) return; final int count = keys.count(key(c)); if (count > 0) { - String label = String.format("hippie (%d)", count); + String label = String.format(Messages.HIPPIE_COMPLETION_PROPOSAL, count); ProposalProcessorManager mgr = proposal.getProposalProcessorManager(); int increment = Math.min(10 << 2, count); mgr.addProcessor(new SimpleProposalProcessor(increment, label)); diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/Subwords2SessionProcessor.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/Subwords2SessionProcessor.java index 02f4835..9930dee 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/Subwords2SessionProcessor.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/Subwords2SessionProcessor.java @@ -29,7 +29,7 @@ import org.eclipse.recommenders.internal.completion.rcp.SimpleProposalProcessor; public class Subwords2SessionProcessor extends SessionProcessor { - SimpleProposalProcessor processor = new SimpleProposalProcessor(5, "contains"); + SimpleProposalProcessor processor = new SimpleProposalProcessor(5, "contains"); //$NON-NLS-1$ private boolean skip = false; private String varName; diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypeProposalsProcessor.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypeProposalsProcessor.java index 395ed9e..16635ec 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypeProposalsProcessor.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypeProposalsProcessor.java @@ -57,8 +57,8 @@ import com.google.common.collect.Sets.SetView; public final class TypeProposalsProcessor extends SessionProcessor { - private static final SimpleProposalProcessor PKG = new SimpleProposalProcessor(1 << 6, "pkg"); - private static SimpleProposalProcessor EXACT = new SimpleProposalProcessor(1 << 25, "exact type"); + private static final SimpleProposalProcessor PKG = new SimpleProposalProcessor(1 << 6, "pkg"); //$NON-NLS-1$ + private static SimpleProposalProcessor EXACT = new SimpleProposalProcessor(1 << 25, "exact type"); //$NON-NLS-1$ static final Set<Class<?>> SUPPORTED_COMPLETION_NODES = new HashSet<Class<?>>() { { @@ -86,7 +86,7 @@ public final class TypeProposalsProcessor extends SessionProcessor { expectedType = context.getExpectedType().orNull(); expected = context.getExpectedTypeNames(); if (expectedType != null) { - String[] split1 = expectedType.getElementName().split("(?=\\p{Upper})"); + String[] split1 = expectedType.getElementName().split("(?=\\p{Upper})"); //$NON-NLS-1$ for (String s : split1) { if (s.length() > 3) { expectedSubwords.add(s); @@ -139,7 +139,7 @@ public final class TypeProposalsProcessor extends SessionProcessor { } }); // remove omnipresent package - pkgs.remove(VmPackageName.get("java/lang")); + pkgs.remove(VmPackageName.get("java/lang")); //$NON-NLS-1$ } @Override @@ -171,7 +171,7 @@ public final class TypeProposalsProcessor extends SessionProcessor { if (expected.isEmpty()) return; String sig = new String(variableProposal.getSignature()); sig = sig.replace('.', '/'); - sig = StringUtils.removeEnd(sig, ";"); + sig = StringUtils.removeEnd(sig, ";"); //$NON-NLS-1$ ITypeName type = VmTypeName.get(sig); if (expected.contains(type)) { proposal.getProposalProcessorManager().addProcessor(EXACT); @@ -184,7 +184,7 @@ public final class TypeProposalsProcessor extends SessionProcessor { String methodSig = new String(coreProposal.getSignature()); String returnType = Signature.getReturnType(methodSig); returnType = returnType.replace('.', '/'); - returnType = StringUtils.removeEnd(returnType, ";"); + returnType = StringUtils.removeEnd(returnType, ";"); //$NON-NLS-1$ ITypeName type = VmTypeName.get(returnType); if (expected.contains(type)) { ProposalProcessorManager mgr = proposal.getProposalProcessorManager(); @@ -199,7 +199,7 @@ public final class TypeProposalsProcessor extends SessionProcessor { private void handleTypeProposal(IProcessableProposal proposal, final CompletionProposal coreProposal) { String sig = new String(coreProposal.getSignature()); sig = sig.replace('.', '/'); - sig = StringUtils.removeEnd(sig, ";"); + sig = StringUtils.removeEnd(sig, ";"); //$NON-NLS-1$ ITypeName type = VmTypeName.get(sig); IPackageName pkg = type.getPackage(); if (pkgs.contains(pkg)) { @@ -209,18 +209,18 @@ public final class TypeProposalsProcessor extends SessionProcessor { } private void handleConstructorProposal(IProcessableProposal proposal, final CompletionProposal coreProposal) { - String name = removeEnd(valueOf(coreProposal.getDeclarationSignature()).replace('.', '/'), ";"); + String name = removeEnd(valueOf(coreProposal.getDeclarationSignature()).replace('.', '/'), ";"); //$NON-NLS-1$ VmTypeName recType = VmTypeName.get(name); ProposalProcessorManager mgr = proposal.getProposalProcessorManager(); if (pkgs.contains(recType.getPackage())) { mgr.addProcessor(PKG); } if (expectedType != null) { - Set<String> s2 = Sets.newHashSet(recType.getClassName().split("(?=\\p{Upper})")); + Set<String> s2 = Sets.newHashSet(recType.getClassName().split("(?=\\p{Upper})")); //$NON-NLS-1$ final SetView<String> intersection = Sets.intersection(s2, expectedSubwords); if (!intersection.isEmpty()) { - SimpleProposalProcessor p = new SimpleProposalProcessor(intersection.size(), "partial"); + SimpleProposalProcessor p = new SimpleProposalProcessor(intersection.size(), "partial"); //$NON-NLS-1$ mgr.addProcessor(p); } } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypoSessionProcessor.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypoSessionProcessor.java index 162b469..8c288d8 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypoSessionProcessor.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/TypoSessionProcessor.java @@ -133,8 +133,8 @@ public final class TypoSessionProcessor extends SessionProcessor { if (distance == 0) append = null; else - append = "typo!"; - System.out.printf("pref %s compl %s dist %d\n", prefix, completion, distance); + append = "typo!"; //$NON-NLS-1$ + System.out.printf("pref %s compl %s dist %d\n", prefix, completion, distance); //$NON-NLS-1$ return distance >= 0 ? true : false; } @@ -157,7 +157,7 @@ public final class TypoSessionProcessor extends SessionProcessor { private boolean isPotentialMatch(final String completion, String prefix) { String s = StringUtils.substring(completion, 0, prefix.length()).toLowerCase(); int distance = StringUtils.getLevenshteinDistance(s, prefix.toLowerCase(), MAX_DISTANCE); - System.out.printf("-create pref %s compl %s dist %d\n", prefix, completion, distance); + System.out.printf("-create pref %s compl %s dist %d\n", prefix, completion, distance); //$NON-NLS-1$ return distance > 0 ? true : false; } @@ -175,18 +175,18 @@ public final class TypoSessionProcessor extends SessionProcessor { } public static String getTokensBetweenLastWhitespaceAndFirstOpeningBracket(String completion) { - if (completion.contains("(")) { + if (completion.contains("(")) { //$NON-NLS-1$ completion = getMethodIdentifierFromProposalText(completion); } else { - completion = StringUtils.substringBefore(completion, " "); + completion = StringUtils.substringBefore(completion, " "); //$NON-NLS-1$ } return completion; } private static String getMethodIdentifierFromProposalText(String completion) { - completion = StringUtils.substringBefore(completion, "("); - if (completion.contains(" ")) { - completion = StringUtils.substringAfterLast(completion, " "); + completion = StringUtils.substringBefore(completion, "("); //$NON-NLS-1$ + if (completion.contains(" ")) { //$NON-NLS-1$ + completion = StringUtils.substringAfterLast(completion, " "); //$NON-NLS-1$ } return completion; } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/META-INF/MANIFEST.MF b/plugins/org.eclipse.recommenders.completion.rcp.subwords/META-INF/MANIFEST.MF index 590030a..b91875a 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/META-INF/MANIFEST.MF @@ -1,10 +1,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Code Recommenders: Subwords Completion +Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.recommenders.completion.rcp.subwords;singleton:=true Bundle-Version: 1.0.3.qualifier -Bundle-Vendor: Eclipse Code Recommenders -Export-Package: org.eclipse.recommenders.internal.completion.rcp.subwords, +Bundle-Vendor: %Bundle-Vendor +Export-Package: org.eclipse.recommenders.completion.rcp.subwords.l10n, + org.eclipse.recommenders.internal.completion.rcp.subwords, org.eclipse.recommenders.internal.completion.rcp.subwords.proposals Require-Bundle: org.eclipse.core.runtime, org.eclipse.jface.text, diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/OSGI-INF/l10n/bundle.properties b/plugins/org.eclipse.recommenders.completion.rcp.subwords/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..6b805f2 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,5 @@ +#Properties file for org.eclipse.recommenders.completion.rcp.subwords +Bundle-Name = Code Recommenders: Subwords Completion +Bundle-Vendor = Eclipse Code Recommenders +extension.name = Java Subwords Proposals (Recommenders) +page.name = Subwords
\ No newline at end of file diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/build.properties b/plugins/org.eclipse.recommenders.completion.rcp.subwords/build.properties index 481af63..5d05029 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/build.properties +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/build.properties @@ -3,7 +3,8 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ icons/,\ - about.html + about.html,\ + OSGI-INF/l10n/bundle.properties source.. = src/ src.includes = about.html,\ icons/,\ diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/plugin.xml b/plugins/org.eclipse.recommenders.completion.rcp.subwords/plugin.xml index 38dc65e..7549629 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/plugin.xml +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/plugin.xml @@ -12,7 +12,7 @@ </extension> <extension id="org.eclipse.recommenders.subwords.rcp.category" - name="Java Subwords Proposals (Recommenders)" + name="%extension.name" point="org.eclipse.jdt.ui.javaCompletionProposalComputer"> <proposalCategory icon="icons/elcl16/category.gif"></proposalCategory> @@ -23,7 +23,7 @@ category="org.eclipse.recommenders.rcp.category.preferences" class="org.eclipse.recommenders.internal.completion.rcp.subwords.PreferencePage" id="org.eclipse.recommenders.internal.completion.rcp.subwords.PreferencePage" - name="Subwords"> + name="%page.name"> </page> </extension> <extension diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Messages.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Messages.java new file mode 100644 index 0000000..b841465 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Messages.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010, 2012 Darmstadt University of Technology. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Olav Lenz - initial API and implementation. + */ +package org.eclipse.recommenders.completion.rcp.subwords.l10n; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.recommenders.completion.rcp.subwords.l10n.messages"; //$NON-NLS-1$ + public static String DIALOG_FAIL_TO_GUESS_METHOD_PARAMETERS; + public static String JOB_DISABLING; + public static String PREFPAGE_ENABLE_PROPOSALS; + public static String PREFPAGE_INTRO; + public static String PREFPAGE_SEE_LINK_TO_CONTENT_ASSIST; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Utilities.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Utilities.java new file mode 100644 index 0000000..0e73bb8 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/Utilities.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2010, 2012 Darmstadt University of Technology. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Olav Lenz - initial API and implementation. + */ +package org.eclipse.recommenders.completion.rcp.subwords.l10n; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; + +public class Utilities { + + public static final String PREFERENCE_PAGE_EXTENTIONPOINT_ID = "org.eclipse.ui.preferencePages"; //$NON-NLS-1$ + + public static String createLinkLabelToPreferencePage(String preferencePageID) { + String text = getNameOfPreferencePage(preferencePageID); + + String categoryID = getCategoryOfPreferencePage(preferencePageID); + while (categoryID != null) { + text = getNameOfPreferencePage(categoryID) + " > " + text; //$NON-NLS-1$ + categoryID = getCategoryOfPreferencePage(categoryID); + } + if (text == null){ + return ""; //$NON-NLS-1$ + }else{ + return text; + } + } + + private static String getNameOfPreferencePage(String preferencePageID) { + return getAttributeOfPreferencePage(preferencePageID, "name"); //$NON-NLS-1$ + } + + private static String getCategoryOfPreferencePage(String preferencePageID) { + return getAttributeOfPreferencePage(preferencePageID, "category"); //$NON-NLS-1$ + } + + private static String getAttributeOfPreferencePage(String preferencePageID, String attribute) { + if (preferencePageID != null) { + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor( + PREFERENCE_PAGE_EXTENTIONPOINT_ID); + + if (elements != null) { + for (IConfigurationElement e : elements) { + String configId = e.getAttribute("id"); //$NON-NLS-1$ + if (preferencePageID.equalsIgnoreCase(configId)) { + String value = e.getAttribute(attribute); + return value; + } + } + } + } + return null; + } + +} diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/messages.properties b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/messages.properties new file mode 100644 index 0000000..062f366 --- a/dev/null +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/completion/rcp/subwords/l10n/messages.properties @@ -0,0 +1,5 @@ +DIALOG_FAIL_TO_GUESS_METHOD_PARAMETERS=Failed to guess method parameters +JOB_DISABLING=Disabling %1$s +PREFPAGE_INTRO=Subwords is a new experimental content assist for Java. It uses 'fuzzy word matching' which allows you to specify just a subsequence of the proposal's text you want to insert.\n\n Note that Subwords essentially makes the same proposals as the standard Java content assist, and thus, will automatically disabled itself when either JDT or Mylyn completion is active to avoid duplicated proposals. The button below is a shortcut for enabling Subwords and disabling standard Java and Mylyn content assist (and reverse). +PREFPAGE_SEE_LINK_TO_CONTENT_ASSIST=See %1$s to configure content assist directly. +PREFPAGE_ENABLE_PROPOSALS=Enable Java Subwords Proposals. diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/DisableContentAssistCategoryJob.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/DisableContentAssistCategoryJob.java index 9ba3f37..1286446 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/DisableContentAssistCategoryJob.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/DisableContentAssistCategoryJob.java @@ -7,6 +7,7 @@ * * Contributors: * Marcel Bruch - initial API and implementation. + * Olav Lenz - externalize Strings. */ package org.eclipse.recommenders.internal.completion.rcp.subwords; @@ -16,6 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.ui.PreferenceConstants; +import org.eclipse.recommenders.completion.rcp.subwords.l10n.Messages; import org.eclipse.ui.progress.UIJob; import com.google.common.collect.Sets; @@ -35,7 +37,7 @@ public class DisableContentAssistCategoryJob extends UIJob { * the content assist category as specified in plugin.xml. */ public DisableContentAssistCategoryJob(String categoryId) { - super("Disabling " + categoryId); + super(String.format(Messages.JOB_DISABLING, categoryId)); this.categoryId = categoryId; setSystem(true); } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/PreferencePage.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/PreferencePage.java index ff74dc0..1921e24 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/PreferencePage.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/PreferencePage.java @@ -7,6 +7,7 @@ * * Contributors: * Marcel Bruch - initial API and implementation. + * Olav Lenz - externalize Strings. */ package org.eclipse.recommenders.internal.completion.rcp.subwords; @@ -16,6 +17,8 @@ import static org.eclipse.recommenders.internal.completion.rcp.subwords.Subwords import java.util.Set; +import org.eclipse.recommenders.completion.rcp.subwords.l10n.Utilities; +import org.eclipse.recommenders.completion.rcp.subwords.l10n.Messages; import org.eclipse.recommenders.utils.rcp.internal.ContentAssistEnablementBlock; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -30,12 +33,11 @@ import org.eclipse.ui.dialogs.PreferencesUtil; public class PreferencePage extends org.eclipse.jface.preference.PreferencePage implements IWorkbenchPreferencePage { + private static final String PREFPAGE_ID_CODE_ASSIST_ADVANCED = "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced"; //$NON-NLS-1$ private ContentAssistEnablementBlock enablement; public PreferencePage() { - setDescription("Subwords is a new experimental content assist for Java. It uses 'fuzzy word matching' which allows you to specify just a subsequence of the proposal's text you want to insert.\n\n" - + "Note that Subwords essentially makes the same proposals as the standard Java content assist, and thus, will automatically disabled itself when either JDT or Mylyn completion is active to avoid duplicated proposals. " - + "The button below is a shortcut for enabling Subwords and disabling standard Java and Mylyn content assist (and reverse)."); + setDescription(Messages.PREFPAGE_INTRO); } @Override @@ -44,16 +46,18 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage container.setLayout(new GridLayout()); final Link link = new Link(container, SWT.NONE | SWT.WRAP); - link.setText("See <a>'Java > Editor > Content Assist > Advanced'</a> to configure content assist directly."); + link.setText(String.format( + Messages.PREFPAGE_SEE_LINK_TO_CONTENT_ASSIST, + "<a>'" + Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_CODE_ASSIST_ADVANCED)+ "'</a>")); //$NON-NLS-1$ //$NON-NLS-2$ link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(getShell(), - "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null); + PREFPAGE_ID_CODE_ASSIST_ADVANCED, null, null); } }); - enablement = new ContentAssistEnablementBlock(container, "Enable Java Subwords Proposals.", + enablement = new ContentAssistEnablementBlock(container, Messages.PREFPAGE_ENABLE_PROPOSALS, SubwordsCompletionProposalComputer.CATEGORY_ID) { @Override diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsCompletionProposalComputer.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsCompletionProposalComputer.java index 78b4586..b24cd14 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsCompletionProposalComputer.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsCompletionProposalComputer.java @@ -38,7 +38,7 @@ import com.google.common.collect.Sets; public class SubwordsCompletionProposalComputer implements IJavaCompletionProposalComputer { private static final int TIMEOUT = 8000; - public static String CATEGORY_ID = "org.eclipse.recommenders.subwords.rcp.category"; + public static String CATEGORY_ID = "org.eclipse.recommenders.subwords.rcp.category"; //$NON-NLS-1$ private JavaContentAssistInvocationContext ctx; @Override @@ -76,10 +76,10 @@ public class SubwordsCompletionProposalComputer implements IJavaCompletionPropos private String getToken() { CompletionContext coreCtx = ctx.getCoreContext(); - if (coreCtx == null) return ""; + if (coreCtx == null) return ""; //$NON-NLS-1$ final char[] token = coreCtx.getToken(); if (token == null) { - return ""; + return ""; //$NON-NLS-1$ } return String.valueOf(token); } @@ -105,7 +105,7 @@ public class SubwordsCompletionProposalComputer implements IJavaCompletionPropos cu.codeComplete(offsetBeforeTokenBegin, requestor, monitor); } } catch (final Exception e) { - RecommendersUtilsPlugin.logWarning(e, "Code completion failed: %s", e.getMessage()); + RecommendersUtilsPlugin.logWarning(e, "Code completion failed: %s", e.getMessage()); //$NON-NLS-1$ } return requestor.getProposals(); } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsUtils.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsUtils.java index fafb50d..4e9eef9 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsUtils.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/SubwordsUtils.java @@ -20,8 +20,8 @@ import org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory; import org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerRegistry; public class SubwordsUtils { - static final String JDT_ALL_CATEGORY = "org.eclipse.jdt.ui.javaAllProposalCategory"; - static final String MYLYN_ALL_CATEGORY = "org.eclipse.mylyn.java.ui.javaAllProposalCategory"; + static final String JDT_ALL_CATEGORY = "org.eclipse.jdt.ui.javaAllProposalCategory"; //$NON-NLS-1$ + static final String MYLYN_ALL_CATEGORY = "org.eclipse.mylyn.java.ui.javaAllProposalCategory"; //$NON-NLS-1$ public static String getTokensBetweenLastWhitespaceAndFirstOpeningBracket(final CompletionProposal proposal) { boolean isPotentialMethodDecl = proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION; @@ -37,18 +37,18 @@ public class SubwordsUtils { } public static String getTokensBetweenLastWhitespaceAndFirstOpeningBracket(String completion) { - if (completion.contains("(")) { + if (completion.contains("(")) { //$NON-NLS-1$ completion = getMethodIdentifierFromProposalText(completion); } else { - completion = StringUtils.substringBefore(completion, " "); + completion = StringUtils.substringBefore(completion, " "); //$NON-NLS-1$ } return completion; } private static String getMethodIdentifierFromProposalText(String completion) { - completion = StringUtils.substringBefore(completion, "("); - if (completion.contains(" ")) { - completion = StringUtils.substringAfterLast(completion, " "); + completion = StringUtils.substringBefore(completion, "("); //$NON-NLS-1$ + if (completion.contains(" ")) { //$NON-NLS-1$ + completion = StringUtils.substringAfterLast(completion, " "); //$NON-NLS-1$ } return completion; } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/ProposalFactory.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/ProposalFactory.java index c0907ac..d5f2b01 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/ProposalFactory.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/ProposalFactory.java @@ -62,7 +62,7 @@ public class ProposalFactory { } else if (GetterSetterCompletionProposal.class == c) { } } catch (final Exception e) { - RecommendersUtilsPlugin.logError(e, "wrapping jdt proposal failed"); + RecommendersUtilsPlugin.logError(e, "wrapping jdt proposal failed"); //$NON-NLS-1$ } return jdtProposal; } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwFilledArgumentNamesMethodProposal.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwFilledArgumentNamesMethodProposal.java index 2020cd5..79ac18f 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwFilledArgumentNamesMethodProposal.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwFilledArgumentNamesMethodProposal.java @@ -26,6 +26,7 @@ import org.eclipse.jface.text.link.LinkedModeUI; import org.eclipse.jface.text.link.LinkedPosition; import org.eclipse.jface.text.link.LinkedPositionGroup; import org.eclipse.jface.viewers.StyledString; +import org.eclipse.recommenders.completion.rcp.subwords.l10n.Messages; import org.eclipse.recommenders.internal.completion.rcp.subwords.SubwordsProposalContext; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; @@ -191,7 +192,7 @@ public class SwFilledArgumentNamesMethodProposal extends JavaMethodCompletionPro private void openErrorDialog(final BadLocationException e) { final Shell shell = getTextViewer().getTextWidget().getShell(); - MessageDialog.openError(shell, "Failed to guess method parameters", e.getMessage()); + MessageDialog.openError(shell, Messages.DIALOG_FAIL_TO_GUESS_METHOD_PARAMETERS, e.getMessage()); } } diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwLazyGenericTypeProposal.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwLazyGenericTypeProposal.java index 4b57f19..ddc8718 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwLazyGenericTypeProposal.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwLazyGenericTypeProposal.java @@ -407,7 +407,7 @@ public final class SwLazyGenericTypeProposal extends LazyJavaTypeCompletionPropo final String[] bounds = parameter.getBounds(); final String elementName = parameter.getElementName(); final String displayName = computeTypeParameterDisplayName(parameter, bounds); - if (bounds.length == 1 && !"java.lang.Object".equals(bounds[0])) { + if (bounds.length == 1 && !"java.lang.Object".equals(bounds[0])) { //$NON-NLS-1$ return new TypeArgumentProposal(Signature.getSimpleName(bounds[0]), true, displayName); } else { return new TypeArgumentProposal(elementName, true, displayName); @@ -415,7 +415,7 @@ public final class SwLazyGenericTypeProposal extends LazyJavaTypeCompletionPropo } private String computeTypeParameterDisplayName(final ITypeParameter parameter, final String[] bounds) { - if (bounds.length == 0 || bounds.length == 1 && "java.lang.Object".equals(bounds[0])) { + if (bounds.length == 0 || bounds.length == 1 && "java.lang.Object".equals(bounds[0])) { //$NON-NLS-1$ return parameter.getElementName(); } final StringBuffer buf = new StringBuffer(parameter.getElementName()); @@ -848,7 +848,7 @@ public final class SwLazyGenericTypeProposal extends LazyJavaTypeCompletionPropo private void openErrorDialog(final BadLocationException e) { final Shell shell = getTextViewer().getTextWidget().getShell(); - MessageDialog.openError(shell, "Failed", e.getMessage()); + MessageDialog.openError(shell, "Failed", e.getMessage()); //$NON-NLS-1$ } /* diff --git a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwParameterGuessingProposal.java b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwParameterGuessingProposal.java index 75612c5..3b11142 100644 --- a/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwParameterGuessingProposal.java +++ b/plugins/org.eclipse.recommenders.completion.rcp.subwords/src/org/eclipse/recommenders/internal/completion/rcp/subwords/proposals/SwParameterGuessingProposal.java @@ -340,7 +340,7 @@ public class SwParameterGuessingProposal extends JavaMethodCompletionProposal { private void openErrorDialog(final Exception e) { final Shell shell = getTextViewer().getTextWidget().getShell(); - MessageDialog.openError(shell, "parameter guessing error", e.getMessage()); + MessageDialog.openError(shell, "parameter guessing error", e.getMessage()); //$NON-NLS-1$ } private void ensurePositionCategoryInstalled(final IDocument document, final LinkedModeModel model) { diff --git a/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/subwords/PrefPageLinkStringTest.java b/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/subwords/PrefPageLinkStringTest.java new file mode 100644 index 0000000..f8a5038 --- a/dev/null +++ b/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/subwords/PrefPageLinkStringTest.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010, 2012 Darmstadt University of Technology. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Olav Lenz - initial API and implementation. + */ +package org.eclipse.recommenders.tests.completion.rcp.subwords; + +import static junit.framework.Assert.assertEquals; + +import org.eclipse.recommenders.completion.rcp.subwords.l10n.Utilities; +import org.junit.Test; + +public class PrefPageLinkStringTest { + + private static final String PREFPAGE_ID_EMPTY = ""; + private static final String PREFPAGE_ID_NON_EXISTING = "non.existing"; + private static final String PREFPAGE_ID_JAVA_BASE = "org.eclipse.jdt.ui.preferences.JavaBasePreferencePage"; + private static final String PREFPAGE_ID_EDITORS = "org.eclipse.ui.preferencePages.Editors"; + private static final String PREFPAGE_ID_SPELLING = "org.eclipse.ui.editors.preferencePages.Spelling"; + + @Test + public void emptyLinkStringForEmptyPrefPageID() { + assertEquals("", Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_EMPTY)); + } + + @Test + public void emptyLinkStringForNonExistingPrefPageID() { + assertEquals("", Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_NON_EXISTING)); + } + + @Test + public void correctLinkStringForPrefPageWithoutTopCategory() { + assertEquals("Java", Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_JAVA_BASE)); + } + + @Test + public void correctLinkStringForPrefPageWithOneTopCategory() { + assertEquals("General > Editors", Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_EDITORS)); + } + + @Test + public void correctLinkStringForPrefPageWithMoreTopCategory() { + assertEquals("General > Editors > Text Editors > Spelling", + Utilities.createLinkLabelToPreferencePage(PREFPAGE_ID_SPELLING)); + } +} |

