Skip to content

Commit

Permalink
Convert messages to nls format
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Wisniewski <[email protected]>
  • Loading branch information
Adam Wisniewski authored and Adam Wisniewski committed Jul 25, 2023
1 parent c3b0407 commit 58eaea7
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -581,12 +583,12 @@ private Project getLibertyServerProject(Project project) throws Exception {
if (project.isParentOfServerModule()) {
List<Project> 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.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -391,16 +390,15 @@ 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;
}

String projectName = iProject.getName();

// 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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit 58eaea7

Please sign in to comment.