Skip to content

Commit bb8c79f

Browse files
Marechkapykm05YashPatel974
authored andcommitted
Add a way to cancel if workspace is in use
Added #3rd Cancel button, close window button behaves as Cancel button, hence cancels launch. Fixes #2628 Co-authored-by: Aaron Pang <[email protected]> Co-authored-by: Yash Patel <[email protected]>
1 parent cae93a3 commit bb8c79f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ public class IDEApplication implements IApplication, IExecutableExtension {
122122
*/
123123
private static final int RETRY_LOAD = 0;
124124

125+
/**
126+
* Return value when the user wants to cancel launch since workspace already
127+
* occupied
128+
*/
129+
private static final int CANCEL_LAUNCH = 2;
130+
private static final int CANCEL_LAUNCH_DEFAULT = -1;
131+
125132
/**
126133
* A special return code that will be recognized by the PDE launcher and used to
127134
* show an error dialog if the workspace is locked.
@@ -374,8 +381,9 @@ protected Object checkInstanceLocation(Shell shell, Map applicationArguments) {
374381

375382
MessageDialog dialog = new MessageDialog(null, IDEWorkbenchMessages.IDEApplication_workspaceInUseTitle,
376383
null, NLS.bind(IDEWorkbenchMessages.IDEApplication_workspaceInUseMessage, workspaceUrl.getFile()),
377-
MessageDialog.ERROR, 1, IDEWorkbenchMessages.IDEApplication_workspaceInUse_Retry,
378-
IDEWorkbenchMessages.IDEApplication_workspaceInUse_Choose) {
384+
MessageDialog.ERROR, 2, IDEWorkbenchMessages.IDEApplication_workspaceInUse_Retry,
385+
IDEWorkbenchMessages.IDEApplication_workspaceInUse_Choose,
386+
IDEWorkbenchMessages.IDEApplication_workspaceInUse_Cancel) {
379387
@Override
380388
protected Control createCustomArea(Composite parent) {
381389
if (lockInfo == null || lockInfo.isBlank()) {
@@ -393,6 +401,11 @@ protected Control createCustomArea(Composite parent) {
393401
};
394402
// the return value influences the next loop's iteration
395403
returnValue = dialog.open();
404+
405+
if (returnValue == CANCEL_LAUNCH || returnValue == CANCEL_LAUNCH_DEFAULT) {
406+
return EXIT_OK;
407+
}
408+
396409
// Remember the locked workspace as recent workspace
397410
launchData.writePersistedData();
398411
}

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java

+1
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ public class IDEWorkbenchMessages extends NLS {
10431043
public static String IDEApplication_workspaceInUseMessage;
10441044
public static String IDEApplication_workspaceInUse_Choose;
10451045
public static String IDEApplication_workspaceInUse_Retry;
1046+
public static String IDEApplication_workspaceInUse_Cancel;
10461047
public static String IDEApplication_workspaceEmptyTitle;
10471048
public static String IDEApplication_workspaceEmptyMessage;
10481049
public static String IDEApplication_workspaceInvalidTitle;

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ IDEApplication_workspaceInUseTitle=Workspace Unavailable
10671067
IDEApplication_workspaceInUseMessage=Please choose another workspace as ''{0}'' is currently in use.
10681068
IDEApplication_workspaceInUse_Choose=&Choose
10691069
IDEApplication_workspaceInUse_Retry=&Retry
1070+
IDEApplication_workspaceInUse_Cancel=&Cancel
10701071
IDEApplication_workspaceEmptyTitle=Workspace Required
10711072
IDEApplication_workspaceEmptyMessage=Workspace field must not be empty; enter a path to continue.
10721073
IDEApplication_workspaceInvalidTitle=Invalid Workspace

0 commit comments

Comments
 (0)