Lines 22-27
Link Here
|
22 |
import org.eclipse.jface.window.ApplicationWindow; |
22 |
import org.eclipse.jface.window.ApplicationWindow; |
23 |
import org.eclipse.osgi.util.NLS; |
23 |
import org.eclipse.osgi.util.NLS; |
24 |
import org.eclipse.ui.ISaveablePart; |
24 |
import org.eclipse.ui.ISaveablePart; |
|
|
25 |
import org.eclipse.ui.ISaveablePart2; |
25 |
import org.eclipse.ui.IWorkbenchPart; |
26 |
import org.eclipse.ui.IWorkbenchPart; |
26 |
import org.eclipse.ui.IWorkbenchWindow; |
27 |
import org.eclipse.ui.IWorkbenchWindow; |
27 |
import org.eclipse.ui.PlatformUI; |
28 |
import org.eclipse.ui.PlatformUI; |
Lines 59-83
Link Here
|
59 |
// If confirmation is required .. |
60 |
// If confirmation is required .. |
60 |
if (confirm) { |
61 |
if (confirm) { |
61 |
int choice = AutomatedResponse; |
62 |
int choice = AutomatedResponse; |
62 |
if (choice == -1) { |
63 |
if (choice == -1) { |
63 |
String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, part.getTitle()); |
64 |
if (saveable instanceof ISaveablePart2) { |
64 |
// Show a dialog. |
65 |
choice = ((ISaveablePart2)saveable).promptToSaveOnClose(); |
65 |
String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; |
66 |
} |
66 |
MessageDialog d = new MessageDialog( |
67 |
if (choice == -1 || choice == ISaveablePart2.DEFAULT) { |
67 |
window.getShell(), WorkbenchMessages.Save_Resource, |
68 |
String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, part.getTitle()); |
68 |
null, message, MessageDialog.QUESTION, buttons, 0); |
69 |
// Show a dialog. |
69 |
choice = d.open(); |
70 |
String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; |
|
|
71 |
MessageDialog d = new MessageDialog( |
72 |
window.getShell(), WorkbenchMessages.Save_Resource, |
73 |
null, message, MessageDialog.QUESTION, buttons, 0); |
74 |
choice = d.open(); |
75 |
} |
70 |
} |
76 |
} |
71 |
|
77 |
|
72 |
// Branch on the user choice. |
78 |
// Branch on the user choice. |
73 |
// The choice id is based on the order of button labels above. |
79 |
// The choice id is based on the order of button labels above. |
74 |
switch (choice) { |
80 |
switch (choice) { |
75 |
case 0 : //yes |
81 |
case ISaveablePart2.YES : //yes |
76 |
break; |
82 |
break; |
77 |
case 1 : //no |
83 |
case ISaveablePart2.NO : //no |
78 |
return true; |
84 |
return true; |
79 |
default : |
85 |
default : |
80 |
case 2 : //cancel |
86 |
case ISaveablePart2.CANCEL : //cancel |
81 |
return false; |
87 |
return false; |
82 |
} |
88 |
} |
83 |
} |
89 |
} |