Skip to content

Commit cee4945

Browse files
committed
Validate project start before launch
Signed-off-by: Adam Wisniewski <awisniew@us.ibm.com>
1 parent 874e01e commit cee4945

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.io.BufferedReader;
1616
import java.io.File;
17+
import java.io.IOException;
1718
import java.io.InputStreamReader;
1819
import java.net.URL;
1920
import java.nio.file.Path;
@@ -166,8 +167,10 @@ public static DevModeOperations getInstance() {
166167
* @param javaHomePath The configuration java installation home to be set in the process running dev mode.
167168
* @param launch The launch associated with this run.
168169
* @param mode The configuration mode.
170+
*
171+
* @throws IOException
169172
*/
170-
public void start(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) {
173+
public void start(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) throws IOException {
171174

172175
if (Trace.isEnabled()) {
173176
Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, new Object[] { iProject, parms, javaHomePath, mode });
@@ -182,20 +185,8 @@ public void start(IProject iProject, String parms, String javaHomePath, ILaunch
182185
return;
183186
}
184187

185-
// Check if the start action has already been issued.
186188
String projectName = iProject.getName();
187189

188-
// Check if we already have a start process running for this project
189-
if (processController.isProcessStarted(projectName)) {
190-
191-
if (Trace.isEnabled()) {
192-
Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + projectName
193-
+ ". No-op. ProcessController: " + processController);
194-
}
195-
ErrorHandler.processErrorMessage(NLS.bind(Messages.start_already_issued, projectName), true);
196-
return;
197-
}
198-
199190
Project project = null;
200191

201192
try {
@@ -303,20 +294,8 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat
303294
return;
304295
}
305296

306-
// Check if the start action has already been issued.
307297
String projectName = iProject.getName();
308298

309-
// Check if we already have a start process running for this project
310-
if (processController.isProcessStarted(projectName)) {
311-
312-
if (Trace.isEnabled()) {
313-
Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start in container request was already issued on project " + projectName
314-
+ ". No-op. ProcessController: " + processController);
315-
}
316-
ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_already_issued, projectName), true);
317-
return;
318-
}
319-
320299
Project project = null;
321300

322301
try {

bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ public boolean isValid(ILaunchConfiguration config) {
218218
return false;
219219
}
220220
}
221+
222+
// Check if project is already started
223+
if (devModeOps.isProjectStarted(configProjectName)) {
224+
if (Trace.isEnabled()) {
225+
Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + configProjectName);
226+
}
227+
228+
super.setErrorMessage(NLS.bind(Messages.start_already_issued, configProjectName));
229+
return false;
230+
}
221231
} catch (CoreException ce) {
222232
String msg = "Error getting project name";
223233
if (Trace.isEnabled()) {

bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ public static void run(IProject iProject, String mode) throws Exception {
104104
DevModeOperations devModeOps = DevModeOperations.getInstance();
105105
devModeOps.verifyProjectSupport(iProject);
106106

107+
// Check if project is already started
108+
String projectName = iProject.getName();
109+
if (devModeOps.isProjectStarted(projectName)) {
110+
111+
if (Trace.isEnabled()) {
112+
Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + projectName);
113+
}
114+
ErrorHandler.processErrorMessage(NLS.bind(Messages.start_already_issued, projectName), true);
115+
return;
116+
}
117+
107118
// Determine what configuration to use.
108119
LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance();
109120
ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.LOCAL);

bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ public static void run(IProject iProject, String mode) throws Exception {
107107
DevModeOperations devModeOps = DevModeOperations.getInstance();
108108
devModeOps.verifyProjectSupport(iProject);
109109

110+
// Check if project is already started
111+
String projectName = iProject.getName();
112+
if (devModeOps.isProjectStarted(projectName)) {
113+
114+
if (Trace.isEnabled()) {
115+
Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start in container request was already issued on project " + projectName);
116+
}
117+
ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_already_issued, projectName), true);
118+
return;
119+
}
120+
110121
// Determine what configuration to use.
111122
LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance();
112123
ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.CONTAINER);

0 commit comments

Comments
 (0)