From a8138c9ba283b91daf464fb1441ff4ad7f845ad2 Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Tue, 24 May 2011 14:43:46 +0000 Subject: [PATCH] Bug 331788 - NLS: Severities for Code Analysis Problem Preferences not externalized for translation --- .../build.properties | 3 +- .../org/eclipse/cdt/codan/core/Messages.java | 15 +++++++++- .../cdt/codan/core/Messages.properties | 6 +++- .../cdt/codan/core/model/CodanSeverity.java | 28 ++++++++++++++++--- .../ui/preferences/ProblemsTreeEditor.java | 2 +- .../ui/widgets/ParametersComposite.java | 9 +++--- 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/codan/org.eclipse.cdt.codan.core/build.properties b/codan/org.eclipse.cdt.codan.core/build.properties index b599b4a135a..393cd297460 100644 --- a/codan/org.eclipse.cdt.codan.core/build.properties +++ b/codan/org.eclipse.cdt.codan.core/build.properties @@ -15,5 +15,6 @@ bin.includes = META-INF/,\ plugin.xml,\ schema/,\ OSGI-INF/l10n/bundle.properties,\ - about.html + about.html,\ + OSGI-INF/ src.includes = schema/ diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java index 1c70c89d409..2e46b4f5dc6 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009,2010 Alena Laskavaia + * Copyright (c) 2009, 2011 Alena Laskavaia 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: * Alena Laskavaia - initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.codan.core; @@ -24,6 +25,18 @@ public class Messages extends NLS { public static String CodanApplication_Usage; public static String CodanApplication_verbose_option; public static String CodanBuilder_Code_Analysis_On; + /** + * @since 2.0 + */ + public static String CodanSeverity_Error; + /** + * @since 2.0 + */ + public static String CodanSeverity_Info; + /** + * @since 2.0 + */ + public static String CodanSeverity_Warning; public static String FileScopeProblemPreference_Label; static { diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.properties b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.properties index d27aa294057..cc76a9dd941 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.properties +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2010 Alena Laskavaia and others. +# Copyright (c) 2010, 2011 Alena Laskavaia 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: # Alena Laskavaia - initial API and implementation +# IBM Corporation ############################################################################### CodanApplication_Error_ProjectDoesNotExists=Error: project {0} does not exist CodanApplication_LogRunProject=Running code analysis on project @@ -16,4 +17,7 @@ CodanApplication_Options=Options: CodanApplication_all_option= -all - run on all projects in workspace CodanApplication_verbose_option= -verbose - print verbose build information CodanBuilder_Code_Analysis_On=Code analysis on +CodanSeverity_Error=Error +CodanSeverity_Info=Info +CodanSeverity_Warning=Warning FileScopeProblemPreference_Label=Exclusion and Inclusion diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java index c75d9985cae..d92db707347 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Alena Laskavaia + * Copyright (c) 2009, 2011 Alena Laskavaia 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,16 +7,18 @@ * * Contributors: * Alena Laskavaia - initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.codan.core.model; +import org.eclipse.cdt.codan.core.Messages; import org.eclipse.core.resources.IMarker; /** - * + * * Represents Severity of the codan problem. It is directly mapped to markers * severity. - * + * */ public enum CodanSeverity { /** @@ -52,7 +54,7 @@ public enum CodanSeverity { String[] svalues = new String[values.length]; for (int i = 0; i < values.length; i++) { CodanSeverity sev = values[i]; - svalues[i] = sev.toString(); + svalues[i] = sev.toTranslatableString(); } return svalues; } @@ -71,4 +73,22 @@ public enum CodanSeverity { return Error; return null; } + + /** + * @return translated string value of this CodanSeverity + * @since 2.0 + */ + public String toTranslatableString() { + switch (this) { + case Info: + return Messages.CodanSeverity_Info; + + case Warning: + return Messages.CodanSeverity_Warning; + + case Error: + default: + return Messages.CodanSeverity_Error; + } + } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java index 164ca8ea8bb..a69563587ba 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java @@ -273,7 +273,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { public String getText(Object element) { if (element instanceof IProblem) { IProblem p = (IProblem) element; - return p.getSeverity().toString(); + return p.getSeverity().toTranslatableString(); } return null; } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java index 4d22d3c1a1b..f585dbbd1b6 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Alena Laskavaia + * Copyright (c) 2009, 2011 Alena Laskavaia 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: * Alena Laskavaia - initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.codan.internal.ui.widgets; @@ -70,9 +71,9 @@ public class ParametersComposite extends Composite { noDefaultAndApplyButton(); ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; addField(new BooleanFieldEditor(PREF_ENABLED, CodanUIMessages.ParametersComposite_IsEnabled, getFieldEditorParent())); - String[][] entries = { { CodanSeverity.Error.toString(), CodanSeverity.Error.toString() }, // - { CodanSeverity.Warning.toString(), CodanSeverity.Warning.toString() }, // - { CodanSeverity.Info.toString(), CodanSeverity.Info.toString() }, // + String[][] entries = { { CodanSeverity.Error.toTranslatableString(), CodanSeverity.Error.toString() }, // + { CodanSeverity.Warning.toTranslatableString(), CodanSeverity.Warning.toString() }, // + { CodanSeverity.Info.toTranslatableString(), CodanSeverity.Info.toString() }, // { NO_CHANGE, NO_CHANGE }, // }; addField(new ComboFieldEditor(PREF_SEVERITY, CodanUIMessages.ParametersComposite_Severity, entries, getFieldEditorParent()));