Skip to content

Commit a217bfc

Browse files
committed
Simplify duplicated workspace-lock error handling in IDEApplication
The "already set" branch of checkInstanceLocation repeated hideSplash and the generic "cannot be set" error dialog across a nested if/else. Collapse to a single splash hide and one error path; behavior is unchanged.
1 parent bc410d9 commit a217bfc

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

  • bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -277,27 +277,23 @@ protected Object checkInstanceLocation(Shell shell, Map applicationArguments) {
277277
// 1. directory is already in use
278278
// 2. directory could not be created
279279
File workspaceDirectory = new File(instanceLoc.getURL().getFile());
280-
if (workspaceDirectory.exists()) {
281-
if (isDevLaunchMode(applicationArguments)) {
282-
return EXIT_WORKSPACE_LOCKED;
283-
}
280+
boolean workspaceDirectoryExists = workspaceDirectory.exists();
284281

285-
// check if there is a lock info then append it to error message.
286-
String lockInfo = WorkspaceLock.getWorkspaceLockDetails(instanceLoc.getURL());
287-
if (lockInfo != null) {
288-
hideSplash(shell);
289-
WorkspaceLock.showWorkspaceLockedDialog(shell, workspaceDirectory.getAbsolutePath(),
290-
lockInfo);
291-
} else {
292-
hideSplash(shell);
293-
MessageDialog.openError(shell,
294-
IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
295-
IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
296-
}
282+
// In dev (PDE) launch mode let the launcher report the locked workspace.
283+
if (workspaceDirectoryExists && isDevLaunchMode(applicationArguments)) {
284+
return EXIT_WORKSPACE_LOCKED;
285+
}
286+
287+
// If the directory exists and carries lock info, show it; otherwise
288+
// report that the workspace location could not be set.
289+
String lockInfo = workspaceDirectoryExists
290+
? WorkspaceLock.getWorkspaceLockDetails(instanceLoc.getURL())
291+
: null;
292+
hideSplash(shell);
293+
if (lockInfo != null) {
294+
WorkspaceLock.showWorkspaceLockedDialog(shell, workspaceDirectory.getAbsolutePath(), lockInfo);
297295
} else {
298-
hideSplash(shell);
299-
MessageDialog.openError(
300-
shell,
296+
MessageDialog.openError(shell,
301297
IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
302298
IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
303299
}

0 commit comments

Comments
 (0)