From 58eaea76bdbd84a17eaf7cc2afd77c62aeca2986 Mon Sep 17 00:00:00 2001 From: Adam Wisniewski Date: Mon, 24 Jul 2023 12:03:22 -0400 Subject: [PATCH] Convert messages to nls format Signed-off-by: Adam Wisniewski --- .../META-INF/MANIFEST.MF | 1 + .../tools/eclipse/CommandBuilder.java | 9 +- .../tools/eclipse/DebugModeHandler.java | 26 ++--- .../tools/eclipse/DevModeOperations.java | 74 +++++++------ .../io/openliberty/tools/eclipse/Project.java | 12 +-- .../tools/eclipse/WorkspaceProjectsModel.java | 4 +- .../eclipse/handlers/ExplorerMenuHandler.java | 11 +- .../tools/eclipse/messages/Messages.java | 100 ++++++++++++++++++ .../eclipse/messages/Messages.properties | 90 ++++++++++++++++ .../eclipse/ui/dashboard/DashboardView.java | 54 +++++----- .../tools/eclipse/ui/launch/JRETab.java | 9 +- .../LaunchConfigurationDelegateLauncher.java | 4 +- .../tools/eclipse/ui/launch/StartTab.java | 25 +++-- .../shortcuts/OpenGradleTestReportAction.java | 10 +- .../shortcuts/OpenMavenITestReportAction.java | 10 +- .../shortcuts/OpenMavenUTestReportAction.java | 10 +- .../ui/launch/shortcuts/RunTestsAction.java | 8 +- .../ui/launch/shortcuts/StartAction.java | 8 +- .../StartConfigurationDialogAction.java | 8 +- .../shortcuts/StartInContainerAction.java | 8 +- .../ui/launch/shortcuts/StopAction.java | 12 ++- 21 files changed, 376 insertions(+), 117 deletions(-) create mode 100644 bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java create mode 100644 bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties diff --git a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF index 0c828aed..fcfc5f0f 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF +++ b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF @@ -29,6 +29,7 @@ Import-Package: org.eclipse.core.commands, org.eclipse.jdt.launching, org.eclipse.jem.util.emf.workbench, org.eclipse.osgi.service.debug, + org.eclipse.osgi.util;version="1.1.0", org.eclipse.swt.custom, org.eclipse.tm.internal.terminal.provisional.api, org.eclipse.tm.terminal.connector.local.launcher, diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java index ce36321c..fe9e14fb 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java @@ -16,7 +16,10 @@ import java.nio.file.Path; import java.nio.file.Paths; +import org.eclipse.osgi.util.NLS; + import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -99,7 +102,11 @@ private String getCommand() throws CommandBuilder.CommandNotFoundException { Trace.getTracer().trace(Trace.TRACE_TOOLS, errorMsg); } - ErrorHandler.processPreferenceErrorMessage(errorMsg, true); + if (isMaven) { + ErrorHandler.processPreferenceErrorMessage(NLS.bind(Messages.maven_exec_not_found, null), true); + } else { + ErrorHandler.processPreferenceErrorMessage(NLS.bind(Messages.gradle_exec_not_found, null), true); + } throw new CommandNotFoundException(errorMsg); } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java index 9573cf60..76c9932d 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java @@ -45,6 +45,7 @@ import org.eclipse.debug.core.ILaunchManager; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; @@ -54,6 +55,7 @@ import io.openliberty.tools.eclipse.Project.BuildType; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; import io.openliberty.tools.eclipse.ui.launch.StartTab; @@ -387,7 +389,7 @@ private Path getServerEnvPath(Project project) throws Exception { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg); } - ErrorHandler.processErrorMessage(msg, false); + ErrorHandler.processErrorMessage(NLS.bind(Messages.multiple_server_env, projectName), false); throw new Exception(msg); } } @@ -501,14 +503,14 @@ private ILaunch createRemoteJavaAppDebugConfig(Project project, String host, Str remoteJavaAppConfigWCopy.setAttribute(StartTab.PROJECT_RUN_TIME, String.valueOf(System.currentTimeMillis())); // - // Fixed issue: https://github.com/OpenLiberty/liberty-tools-eclipse/issues/372 + // Fixed issue: https://github.com/OpenLiberty/liberty-tools-eclipse/issues/372 // by launching with the return value of remoteJavaAppConfigWCopy.doSave(), rather than the // object (the "working copy") itself. - // - // Debated calling launch() with the doSave() return value vs. the value of - // remoteJavaAppConfigWCopy.getOriginal(). Decided on the former which + // + // Debated calling launch() with the doSave() return value vs. the value of + // remoteJavaAppConfigWCopy.getOriginal(). Decided on the former which // seemed to be the more common usage pattern, though not entirely clear which is better. - // + // ILaunchConfiguration updatedConfig = remoteJavaAppConfigWCopy.doSave(); return updatedConfig.launch(ILaunchManager.DEBUG_MODE, monitor); } @@ -581,12 +583,12 @@ private Project getLibertyServerProject(Project project) throws Exception { if (project.isParentOfServerModule()) { List mmps = project.getChildLibertyServerProjects(); switch (mmps.size()) { - case 0: - throw new Exception("Unable to find a child project that contains the Liberty server configuration."); - case 1: - return mmps.get(0); - default: - throw new Exception("Multiple child projects containing Liberty server configuration were found."); + case 0: + throw new Exception("Unable to find a child project that contains the Liberty server configuration."); + case 1: + return mmps.get(0); + default: + throw new Exception("Multiple child projects containing Liberty server configuration were found."); } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java index 5fdfe300..b117b1d8 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java @@ -36,6 +36,7 @@ import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.ISelectionService; import org.eclipse.ui.IWorkbenchWindow; @@ -47,6 +48,7 @@ import io.openliberty.tools.eclipse.Project.BuildType; import io.openliberty.tools.eclipse.logging.Logger; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; import io.openliberty.tools.eclipse.ui.terminal.ProjectTab; import io.openliberty.tools.eclipse.ui.terminal.ProjectTab.State; @@ -160,7 +162,7 @@ public void start(IProject iProject, String parms, String javaHomePath, String m if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_no_project_found, null), true); return; } @@ -187,8 +189,7 @@ public void start(IProject iProject, String parms, String javaHomePath, String m Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + projectName + ". No-op. ProjectTabController: " + projectTabController); } - ErrorHandler.processErrorMessage("The start request was already issued on project " + projectName - + ". Use the stop action before you select the start action.", true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_already_issued, projectName), true); return; } } @@ -245,11 +246,10 @@ public void start(IProject iProject, String parms, String javaHomePath, String m } return; } catch (Exception e) { - String msg = "An error was detected during the start request on project " + projectName; if (Trace.isEnabled()) { - Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); + Trace.getTracer().trace(Trace.TRACE_TOOLS, "An error was detected during the start request on project " + projectName, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_general_error, projectName), e, true); return; } @@ -277,7 +277,7 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_no_project_found, null), true); return; } @@ -304,8 +304,7 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start in container request was already issued on project " + projectName + ". No-op. ProjectTabController: " + projectTabController); } - ErrorHandler.processErrorMessage("The start in container request was already issued on project " + projectName - + ". Use the stop action before you select the start action.", true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_already_issued, projectName), true); return; } } @@ -360,7 +359,7 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_general_error, projectName), e, true); return; } @@ -391,7 +390,7 @@ public void stop(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.stop_no_project_found, null), true); return; } @@ -399,8 +398,7 @@ public void stop(IProject inputProject) { // Check if the stop action has already been issued of if a start action was never issued before. if (projectTabController.getProjectConnector(projectName) == null) { - String msg = "Unable to process the stop request on project " + projectName - + " because either Liberty Tools did not previously issue a start request, or a stop request was already issued."; + String msg = NLS.bind(Messages.stop_already_issued, projectName); handleStopActionError(projectName, msg); return; @@ -412,7 +410,7 @@ public void stop(IProject inputProject) { // the terminal process to end. Note that objects associated with the previous start attempt will be cleaned up on // the next restart attempt. if (projectTabController.isProjectTabMarkedClosed(projectName)) { - String msg = "The terminal tab associated with project " + projectName + " is not active."; + String msg = NLS.bind(Messages.stop_terminal_not_active, projectName); handleStopActionError(projectName, msg); return; @@ -436,7 +434,7 @@ public void stop(IProject inputProject) { projectTabController.processTerminalTabCleanup(projectName); } catch (Exception e) { - String msg = "An error was detected when the stop request was processed on project " + projectName + "."; + String msg = NLS.bind(Messages.stop_general_error, projectName); handleStopActionError(projectName, msg); return; @@ -469,7 +467,7 @@ public void runTests(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_no_project_found, null), true); return; } @@ -482,7 +480,7 @@ public void runTests(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. ProjectTabController: " + projectTabController); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_no_prior_start, projectName), true); return; } @@ -498,7 +496,7 @@ public void runTests(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. ProjectTabController: " + projectTabController); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_terminal_not_active, projectName), true); return; } @@ -510,7 +508,7 @@ public void runTests(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_general_error, projectName), e, true); return; } @@ -541,7 +539,7 @@ public void openMavenIntegrationTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_int_test_report_no_project_found, null), true); return; } @@ -569,7 +567,8 @@ public void openMavenIntegrationTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. Path: " + path); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_int_test_report_none_found, new String[] { projectName, + DashboardView.APP_MENU_ACTION_RUN_TESTS, DashboardView.APP_MENU_ACTION_VIEW_MVN_IT_REPORT }), true); return; } @@ -582,7 +581,7 @@ public void openMavenIntegrationTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_int_test_report_general_error, projectName), e, true); return; } @@ -615,7 +614,7 @@ public void openMavenUnitTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_unit_test_report_no_project_found, null), true); } String projectName = iProject.getName(); @@ -642,7 +641,8 @@ public void openMavenUnitTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. Path: " + path); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_unit_test_report_none_found, new String[] { projectName, + DashboardView.APP_MENU_ACTION_RUN_TESTS, DashboardView.APP_MENU_ACTION_VIEW_MVN_UT_REPORT }), true); return; } @@ -654,7 +654,7 @@ public void openMavenUnitTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.mvn_unit_test_report_general_error, projectName), e, true); return; } @@ -685,7 +685,7 @@ public void openGradleTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op."); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.gradle_test_report_no_project_found, null), true); return; } @@ -713,7 +713,11 @@ public void openGradleTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. Path: " + path); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler + .processErrorMessage( + NLS.bind(Messages.gradle_test_report_none_found, new String[] { projectName, + DashboardView.APP_MENU_ACTION_RUN_TESTS, DashboardView.APP_MENU_ACTION_VIEW_GRADLE_TEST_REPORT }), + true); return; } @@ -725,7 +729,7 @@ public void openGradleTestReport(IProject inputProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.gradle_test_report_general_error, projectName)); return; } @@ -787,8 +791,8 @@ public void startDevMode(String cmd, String projectName, String projectPath, Str * @param baseMsg The base message to display. */ private void handleStopActionError(String projectName, String baseMsg) { - String msg = baseMsg - + "\n\nWould you like to issue the Liberty Maven or Gradle stop command for this project to stop a Liberty server that may still be running the project outside of the Liberty Tools session?"; + String stopPromptMsg = NLS.bind(Messages.issue_stop_prompt, null); + String msg = baseMsg + "\n\n" + stopPromptMsg; Integer response = ErrorHandler.processWarningMessage(msg, true, new String[] { "Yes", "No" }, 0); if (response != null && response == 0) { issueLPStopCommand(projectName); @@ -885,7 +889,7 @@ protected IStatus run(IProgressMonitor monitor) { } } } catch (Exception e) { - ErrorHandler.processErrorMessage("Exception issuing plugin stop command", e, false); + ErrorHandler.processErrorMessage(NLS.bind(Messages.plugin_stop_issue_error, null), e, false); } return Status.OK_STATUS; } @@ -916,7 +920,9 @@ public void run() { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg); } - ErrorHandler.rawErrorMessageDialog(msg); + ErrorHandler.rawErrorMessageDialog( + NLS.bind(Messages.plugin_stop_timeout, + new String[] { projectName, Integer.toString(STOP_TIMEOUT_SECONDS) })); } }); return; @@ -932,7 +938,7 @@ public void run() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - ErrorHandler.processErrorMessage("Stop failed with exitValue = " + rc, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.plugin_stop_failed, rc), true); } }); return; @@ -948,7 +954,7 @@ public void run() { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.plugin_stop_general_error, projectName), e, true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/Project.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/Project.java index 60752161..23f309c0 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/Project.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/Project.java @@ -25,8 +25,10 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.osgi.util.NLS; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.utils.ErrorHandler; /** @@ -210,7 +212,7 @@ public List filterJavaProjects(Set projects) { javaProjecs.add(child); } } catch (CoreException e) { - ErrorHandler.processWarningMessage("Unable to determine if project : " + child.getName() + " is a Java project.", e, false); + ErrorHandler.processWarningMessage(NLS.bind(Messages.determine_java_project_error, child.getName()), e, false); } } return javaProjecs; @@ -254,7 +256,7 @@ public Project getAssociatedJavaProject(Project project) throws Exception { } /** - * Classifies this project as a project able to run on a Linerty server. + * Classifies this project as a project able to run on a Liberty server. */ public void classifyAsServerModule() { try { @@ -267,8 +269,7 @@ public void classifyAsServerModule() { libertyServerModule = false; } } catch (Exception e) { - String msg = "Error querying and adding Liberty nature"; - ErrorHandler.processWarningMessage(msg, e, false); + ErrorHandler.processWarningMessage(NLS.bind(Messages.liberty_nature_add_error, null), e, false); } } @@ -291,8 +292,7 @@ public void classifyAsLibertyNature() { } } } catch (Exception e) { - String msg = "Error querying and adding Liberty nature"; - ErrorHandler.processWarningMessage(msg, e, false); + ErrorHandler.processWarningMessage(NLS.bind(Messages.liberty_nature_add_error, null), e, false); } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/WorkspaceProjectsModel.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/WorkspaceProjectsModel.java index 80873725..0d1dd1f5 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/WorkspaceProjectsModel.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/WorkspaceProjectsModel.java @@ -24,8 +24,10 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.osgi.util.NLS; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.utils.ErrorHandler; /** @@ -146,7 +148,7 @@ private void buildMultiProjectModel(List projectsToScan, boolean class if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " Workspace projects: " + projectsByLocation.values(), e); } - ErrorHandler.processWarningMessage(msg, e, false); + ErrorHandler.processWarningMessage(NLS.bind(Messages.project_analyze_error, null), e, false); } if (Trace.isEnabled()) { diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/handlers/ExplorerMenuHandler.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/handlers/ExplorerMenuHandler.java index 558ad0c1..49d50b0d 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/handlers/ExplorerMenuHandler.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/handlers/ExplorerMenuHandler.java @@ -20,11 +20,13 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.handlers.HandlerUtil; import io.openliberty.tools.eclipse.LibertyNature; import io.openliberty.tools.eclipse.Project; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -49,13 +51,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // Validate that a project was selected. if (currentSelection.isEmpty()) { - String msg = "Invalid project. Be sure to select a project first."; + String msg = "The project is not valid. Be sure to select a project first."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_HANDLERS, msg); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.project_not_valid, null), true); return null; } @@ -71,7 +73,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Trace.getTracer().trace(Trace.TRACE_HANDLERS, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.menu_command_retrieve_error, null), e, true); return null; } @@ -103,7 +105,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Trace.getTracer().trace(Trace.TRACE_HANDLERS, msg, e); } - ErrorHandler.processErrorMessage(msg, e); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.menu_command_process_error, new String[] { commandName, iProject.getName() }), e); } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java new file mode 100644 index 00000000..4b471bc2 --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package io.openliberty.tools.eclipse.messages; + +import org.eclipse.osgi.util.NLS; + +/** + * Translated messages. + */ +public class Messages extends NLS { + + /** DebugModeHandler */ + public static String multiple_server_env; + + /** DevModeOperations */ + public static String start_no_project_found; + public static String start_already_issued; + public static String start_general_error; + + public static String start_container_no_project_found; + public static String start_container_already_issued; + public static String start_container_general_error; + + public static String stop_no_project_found; + public static String stop_already_issued; + public static String stop_terminal_not_active; + public static String stop_general_error; + + public static String run_tests_no_project_found; + public static String run_tests_no_prior_start; + public static String run_tests_terminal_not_active; + public static String run_tests_general_error; + + public static String mvn_int_test_report_no_project_found; + public static String mvn_int_test_report_none_found; + public static String mvn_int_test_report_general_error; + + public static String mvn_unit_test_report_no_project_found; + public static String mvn_unit_test_report_none_found; + public static String mvn_unit_test_report_general_error; + + public static String gradle_test_report_no_project_found; + public static String gradle_test_report_none_found; + public static String gradle_test_report_general_error; + + public static String issue_stop_prompt; + public static String plugin_stop_issue_error; + public static String plugin_stop_timeout; + public static String plugin_stop_failed; + public static String plugin_stop_general_error; + + /** WorkspaceProjectsModel */ + public static String project_analyze_error; + + /** DashboardView */ + public static String project_not_gradle_or_maven; + public static String image_descriptions_error; + public static String action_general_error; + public static String dashboard_refresh_error; + + /** JRETab */ + public static String java_default_set_error; + public static String java_resolution_error; + + /** LaunchConfigurationDelegateLauncher */ + public static String launch_config_error; + + /** StartTab */ + public static String start_parm_retrieve_error; + public static String project_name_error; + public static String run_config_initialize_error; + + /** All *Action classes */ + public static String launch_shortcut_error; + + /** ExplorerMenuHandler */ + public static String project_not_valid; + public static String menu_command_retrieve_error; + public static String menu_command_process_error; + + /** CommandBuilder */ + public static String maven_exec_not_found; + public static String gradle_exec_not_found; + + /** Project */ + public static String determine_java_project_error; + public static String liberty_nature_add_error; + + static { + NLS.initializeMessages("io.openliberty.tools.eclipse.messages.Messages", Messages.class); + } +} \ No newline at end of file diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties new file mode 100644 index 00000000..c819a6ba --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties @@ -0,0 +1,90 @@ +############################################################################### +# Copyright (c) 2023 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 +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +# NLS_ENCODING=UNICODE +# NLS_MESSAGEFORMAT_VAR + +# DebugModeHandler +multiple_server_env=More than one server.env file was found for project {0}. Unable to determine which server.env file to use. + +# DevModeOperations +start_no_project_found=An error was detected when the start request was processed. The object that represents the selected project was not found. +start_already_issued=The start request was already issued on project {0}. Use the stop action before you select the start action. +start_general_error=An error was detected during the start request on project {0}. + +start_container_no_project_found=An error was detected when the start in container request was processed. The object that represents the selected project was not found. +start_container_already_issued=The start in container request was already issued on project {0}. Use the stop action before you select the start action. +start_container_general_error=An error was detected during the start in container request on project {0}. + +stop_no_project_found=An error was detected when the stop request was processed. The object that represents the selected project was not found. When using the Run Configuration launcher, be sure to select a project or project content first. +stop_already_issued=Unable to process the stop request on project {0} because either Liberty Tools did not previously issue a start request, or a stop request was already issued. +stop_terminal_not_active=The terminal tab associated with project {0} is not active. +stop_general_error=An error was detected when the stop request was processed on project {0}. + +run_tests_no_project_found=An error was detected when the run tests request was processed. The object that represents the selected project was not found. When you use the Run Configuration launcher, be sure to select a project or project content first. +run_tests_no_prior_start=No start request was issued first or the stop request was already issued on project {0}. Issue a start request before you issue the run tests request. +run_tests_terminal_not_active=The terminal tab that is running project {0} is not active due to an unexpected error or external action. Review the terminal output for more details. Once the circumstance that caused the terminal tab to be inactive is determined and resolved, issue a start request before you issue the run tests request. +run_tests_general_error=An error was detected when the run tests request was processed on project {0}. + +mvn_int_test_report_no_project_found=An error was detected when the view integration test report request was processed. The object that represents the selected project was not found. When you use the Run Configuration launcher, be sure to select a project or project content first. +mvn_int_test_report_none_found=No integration test results were found for project {0}. Select "{1}" before you select "{2}" on the menu. +mvn_int_test_report_general_error="An error was detected when the view integration test report request was processed on project {0}. + +mvn_unit_test_report_no_project_found=An error was detected when the view unit test report request was processed. The object representing the selected project could not be found. When using the Run Configuration launcher, be sure to select a project or project content first. +mvn_unit_test_report_none_found=No unit test results were found for project {0}. Select "{1}" before you select "{2}" on the menu. +mvn_unit_test_report_general_error=An error was detected when the view unit test report request was processed on project {0}. + +gradle_test_report_no_project_found=An error was detected when the view test report request was processed. The object representing the selected project could not be found. When using the Run Configuration launcher, be sure to select a project or project content first. +gradle_test_report_none_found=No test results were found for project {0}. Select "{1}" before you select "{2}" on the menu. +gradle_test_report_general_error=An error was detected when the view test report request was processed on project {0}. + +issue_stop_prompt=Would you like to issue the Liberty Maven or Gradle stop command for this project to stop a Liberty server that may still be running the project outside of the Liberty Tools session? +plugin_stop_issue_error=Exception issuing plugin stop command. +plugin_stop_timeout=The Liberty Maven or Gradle stop command issued for project {0} timed out after {1} seconds. +plugin_stop_failed=Stop failed with exitValue = {0} +plugin_stop_general_error=An error was detected while processing the Liberty Maven or Gradle stop command on project {0}. + +# WorkspaceProjectsModel +project_analyze_error=An error occurred when the projects in the workspace were analyzed. + +# DashboardView +project_not_gradle_or_maven=Project {0} is not a Gradle or Maven project. +image_descriptions_error=An error was detected while retrieving image descriptions. +action_general_error=An error was detected during the {0} action. +dashboard_refresh_error=An error was detected when the Liberty dashboard content was refreshed. + +# JRETab +java_default_set_error=Unable to set the default Java installation that was obtained from the build path of project {0} in configuration {1}. +java_resolution_error=Unable to resolve the Java installation path by using configuration {0}. Using the workspace Java installation. + +# LaunchConfigurationDelegateLauncher +launch_config_error=An error was detected when configuration was launched {0}. + +# StartTab +start_parm_retrieve_error=An error was detected when the default start parameters were retrieved. +project_name_error=Error getting project name. +run_config_initialize_error=An error was detected during Run Configuration initialization. + +# All *Action classes +launch_shortcut_error=An error was detected when the "{0}" launch shortcut was processed. + +# ExplorerMenuHandler +project_not_valid=The project is not valid. Be sure to select a project first. +menu_command_retrieve_error=Unable to retrieve menu command. +menu_command_process_error=Unable to process menu command {0} on project {1}. + +# CommandBuilder +maven_exec_not_found=Could not find Maven executable or wrapper. +gradle_exec_not_found=Could not find Gradle executable or wrapper. + +# Project +determine_java_project_error=Unable to determine if project {0} is a Java project. +liberty_nature_add_error=Error querying and adding Liberty nature. + diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java index 9f2fd618..7d92dfbf 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java @@ -26,6 +26,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; @@ -38,6 +39,7 @@ import io.openliberty.tools.eclipse.Project; import io.openliberty.tools.eclipse.WorkspaceProjectsModel; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.shortcuts.OpenGradleTestReportAction; import io.openliberty.tools.eclipse.ui.launch.shortcuts.OpenMavenITestReportAction; import io.openliberty.tools.eclipse.ui.launch.shortcuts.OpenMavenUTestReportAction; @@ -209,7 +211,7 @@ private void addActionsToContextMenu(IMenuManager mgr) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg); } - ErrorHandler.processErrorMessage(msg, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.project_not_gradle_or_maven, projectName), true); return; } } @@ -233,7 +235,7 @@ private void createActions() { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processWarningMessage(msg, e, true); + ErrorHandler.processWarningMessage(NLS.bind(Messages.image_descriptions_error, null), e, true); } // Activate the Liberty tools context. @@ -248,11 +250,11 @@ public void run() { try { StartAction.run(iProject, null, ILaunchManager.RUN_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_START + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_START + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_START), e, true); } } }; @@ -271,11 +273,12 @@ public void run() { try { StartConfigurationDialogAction.run(iProject, ILaunchManager.RUN_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_START_CONFIG + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_START_CONFIG + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_START_CONFIG), e, + true); } } }; @@ -292,12 +295,12 @@ public void run() { try { StartInContainerAction.run(iProject, null, ILaunchManager.RUN_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_START_IN_CONTAINER + String msg = "An error was detected during the " + APP_MENU_ACTION_START_IN_CONTAINER + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_START_IN_CONTAINER), e, true); } } }; @@ -314,12 +317,12 @@ public void run() { try { StartInContainerAction.run(iProject, null, ILaunchManager.DEBUG_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_DEBUG_IN_CONTAINER + String msg = "An error was detected during the " + APP_MENU_ACTION_DEBUG_IN_CONTAINER + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_DEBUG_IN_CONTAINER), e, true); } } }; @@ -336,11 +339,11 @@ public void run() { try { StartAction.run(iProject, null, ILaunchManager.DEBUG_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_DEBUG + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_DEBUG + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_DEBUG), e, true); } } }; @@ -358,11 +361,11 @@ public void run() { try { StartConfigurationDialogAction.run(iProject, ILaunchManager.DEBUG_MODE); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_DEBUG_CONFIG + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_DEBUG_CONFIG + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_DEBUG_CONFIG), e, true); } } }; @@ -379,11 +382,11 @@ public void run() { try { StopAction.run(iProject); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_STOP + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_STOP + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_STOP), e, true); } } }; @@ -400,11 +403,11 @@ public void run() { try { RunTestsAction.run(iProject); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_RUN_TESTS + " action."; + String msg = "An error was detected during the " + APP_MENU_ACTION_RUN_TESTS + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_RUN_TESTS), e, true); } } }; @@ -421,12 +424,12 @@ public void run() { try { OpenMavenITestReportAction.run(iProject); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_VIEW_MVN_IT_REPORT + String msg = "An error was detected during the " + APP_MENU_ACTION_VIEW_MVN_IT_REPORT + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_VIEW_MVN_IT_REPORT), e, true); } } }; @@ -443,12 +446,12 @@ public void run() { try { OpenMavenUTestReportAction.run(iProject); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_VIEW_MVN_UT_REPORT + String msg = "An error was detected during the " + APP_MENU_ACTION_VIEW_MVN_UT_REPORT + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_VIEW_MVN_UT_REPORT), e, true); } } }; @@ -465,12 +468,13 @@ public void run() { try { OpenGradleTestReportAction.run(iProject); } catch (Exception e) { - String msg = "An error was detected during the " + DashboardView.APP_MENU_ACTION_VIEW_GRADLE_TEST_REPORT + String msg = "An error was detected during the " + APP_MENU_ACTION_VIEW_GRADLE_TEST_REPORT + " action."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.action_general_error, APP_MENU_ACTION_VIEW_GRADLE_TEST_REPORT), e, + true); } } }; @@ -507,7 +511,7 @@ public void refreshDashboardView(WorkspaceProjectsModel projectModel, boolean re if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, reportError); + ErrorHandler.processErrorMessage(NLS.bind(Messages.dashboard_refresh_error, null), e, reportError); return; } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/JRETab.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/JRETab.java index 13615c58..2af7296c 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/JRETab.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/JRETab.java @@ -26,11 +26,13 @@ import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.osgi.util.NLS; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.Project; import io.openliberty.tools.eclipse.WorkspaceProjectsModel; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -78,9 +80,8 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { } } } catch (Exception e) { - ErrorHandler - .processWarningMessage("Unable to set the default Java installation that was obtained from the build path of project " - + activeProject.getName() + " in configuration " + configuration.getName(), e); + ErrorHandler.processWarningMessage( + NLS.bind(Messages.java_default_set_error, new String[] { activeProject.getName(), configuration.getName() }), e); } super.setDefaults(configuration); @@ -108,7 +109,7 @@ public static String resolveJavaHome(ILaunchConfiguration configuration) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processWarningMessage(msg, e); + ErrorHandler.processWarningMessage(NLS.bind(Messages.java_resolution_error, configuration.getName()), e); } if (keyValue != null) { diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java index c0056633..16fe644c 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java @@ -20,11 +20,13 @@ import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.LaunchConfigurationDelegate; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.shortcuts.StartAction; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -85,7 +87,7 @@ public void run() { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.launch_config_error, configuration.getName()), e, true); return; } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java index 26619ee7..7273a15b 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java @@ -19,6 +19,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.preference.PreferenceDialog; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -39,6 +40,7 @@ import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -169,7 +171,11 @@ public void initializeFrom(ILaunchConfiguration configuration) { setDirty(false); } catch (CoreException ce) { - traceError(ce, "An error was detected during Run Configuration initialization."); + String msg = "An error was detected during Run Configuration initialization."; + if (Trace.isEnabled()) { + Trace.getTracer().trace(Trace.TRACE_UI, msg, ce); + } + ErrorHandler.processErrorMessage(NLS.bind(Messages.run_config_initialize_error, null), ce, true); } if (Trace.isEnabled()) { @@ -177,13 +183,6 @@ public void initializeFrom(ILaunchConfiguration configuration) { } } - private void traceError(CoreException ce, String msg) { - ErrorHandler.processErrorMessage(msg, ce, true); - if (Trace.isEnabled()) { - Trace.getTracer().trace(Trace.TRACE_UI, msg, ce); - } - } - private boolean checkForIncorrectTerms() { boolean valid = true; String startParamStr = startParmText.getText(); @@ -219,8 +218,12 @@ public boolean isValid(ILaunchConfiguration config) { return false; } } - } catch (CoreException e) { - traceError(e, "Error getting project name"); + } catch (CoreException ce) { + String msg = "Error getting project name"; + if (Trace.isEnabled()) { + Trace.getTracer().trace(Trace.TRACE_UI, msg, ce); + } + ErrorHandler.processErrorMessage(NLS.bind(Messages.project_name_error, null), ce, true); return false; } return checkForIncorrectTerms(); @@ -418,7 +421,7 @@ private String getDefaultStartCommand(IProject iProject) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage(NLS.bind(Messages.start_parm_retrieve_error, null), e, true); } return parms; diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenGradleTestReportAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenGradleTestReportAction.java index 67016be5..120863ee 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenGradleTestReportAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenGradleTestReportAction.java @@ -15,10 +15,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +49,9 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_GRADLE_VIEW_TEST_REPORT), + e, true); return; } @@ -75,7 +79,9 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_GRADLE_VIEW_TEST_REPORT), + e, true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenITestReportAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenITestReportAction.java index b76bc230..909acc62 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenITestReportAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenITestReportAction.java @@ -15,10 +15,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +49,9 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_MVN_VIEW_IT_REPORT), e, + true); return; } @@ -75,7 +79,9 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_MVN_VIEW_IT_REPORT), e, + true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenUTestReportAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenUTestReportAction.java index b2b29c98..30c910de 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenUTestReportAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/OpenMavenUTestReportAction.java @@ -15,10 +15,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +49,9 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_MVN_VIEW_UT_REPORT), e, + true); return; } @@ -75,7 +79,9 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_MVN_VIEW_UT_REPORT), e, + true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/RunTestsAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/RunTestsAction.java index a46fad91..96fbcaf2 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/RunTestsAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/RunTestsAction.java @@ -15,10 +15,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +49,8 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_RUN_TESTS), e, true); return; } @@ -75,7 +78,8 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_RUN_TESTS), e, true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java index 386b26bd..5ac2541e 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java @@ -16,10 +16,12 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.JRETab; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; @@ -52,7 +54,8 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START), e, true); } if (Trace.isEnabled()) { @@ -79,7 +82,8 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START), e, true); } if (Trace.isEnabled()) { diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartConfigurationDialogAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartConfigurationDialogAction.java index ede1fcfc..0449c6ff 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartConfigurationDialogAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartConfigurationDialogAction.java @@ -19,12 +19,14 @@ import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; @@ -61,7 +63,8 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONFIG), e, true); return; } @@ -89,7 +92,8 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONFIG), e, true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java index 6ce3e13b..e860bc28 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java @@ -16,10 +16,12 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.JRETab; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; @@ -52,7 +54,8 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONTAINER), e, true); return; } @@ -80,7 +83,8 @@ public void launch(IEditorPart part, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONTAINER), e, true); return; } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StopAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StopAction.java index 57fd66b7..1aaf3c00 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StopAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StopAction.java @@ -15,10 +15,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; +import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +49,8 @@ public void launch(ISelection selection, String mode) { if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_STOP), e, true); return; } @@ -70,12 +73,13 @@ public void launch(IEditorPart part, String mode) { try { run(iProject); } catch (Exception e) { - String msg = "An error was detected while processing the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_STOP - + "\" launch shortcut."; + String msg = "An error was detected when the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_STOP + + "\" launch shortcut was processed."; if (Trace.isEnabled()) { Trace.getTracer().trace(Trace.TRACE_UI, msg, e); } - ErrorHandler.processErrorMessage(msg, e, true); + ErrorHandler.processErrorMessage( + NLS.bind(Messages.launch_shortcut_error, LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_STOP), e, true); return; }