Lines 13-18
Link Here
|
13 |
* Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 |
13 |
* Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 |
14 |
* Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043 |
14 |
* Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043 |
15 |
* Tom Eicher (Avaloq Evolution AG) - block selection mode |
15 |
* Tom Eicher (Avaloq Evolution AG) - block selection mode |
|
|
16 |
* Renato Silva - out-of-sync extension point (http://bugs.eclipse.org/bugs/show_bug.cgi?id=261716) |
17 |
* |
16 |
*******************************************************************************/ |
18 |
*******************************************************************************/ |
17 |
package org.eclipse.ui.texteditor; |
19 |
package org.eclipse.ui.texteditor; |
18 |
|
20 |
|
Lines 104-112
Link Here
|
104 |
import org.eclipse.jface.viewers.ISelection; |
106 |
import org.eclipse.jface.viewers.ISelection; |
105 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
107 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
106 |
import org.eclipse.jface.viewers.ISelectionProvider; |
108 |
import org.eclipse.jface.viewers.ISelectionProvider; |
|
|
109 |
import org.eclipse.jface.viewers.LabelProvider; |
107 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
110 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
108 |
import org.eclipse.jface.viewers.StructuredSelection; |
111 |
import org.eclipse.jface.viewers.StructuredSelection; |
109 |
import org.eclipse.jface.window.IShellProvider; |
112 |
import org.eclipse.jface.window.IShellProvider; |
|
|
113 |
import org.eclipse.jface.window.Window; |
110 |
|
114 |
|
111 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
115 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
112 |
import org.eclipse.jface.text.BadLocationException; |
116 |
import org.eclipse.jface.text.BadLocationException; |
Lines 198-203
Link Here
|
198 |
import org.eclipse.ui.actions.ActionFactory; |
202 |
import org.eclipse.ui.actions.ActionFactory; |
199 |
import org.eclipse.ui.actions.CommandNotMappedException; |
203 |
import org.eclipse.ui.actions.CommandNotMappedException; |
200 |
import org.eclipse.ui.actions.ContributedAction; |
204 |
import org.eclipse.ui.actions.ContributedAction; |
|
|
205 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
201 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
206 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
202 |
import org.eclipse.ui.dnd.IDragAndDropService; |
207 |
import org.eclipse.ui.dnd.IDragAndDropService; |
203 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
208 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
Lines 4943-4954
Link Here
|
4943 |
} |
4948 |
} |
4944 |
|
4949 |
|
4945 |
if (isNotSynchronizedException(exception) && fErrorCorrectionOnSave == 1 && !isSynchronized) { |
4950 |
if (isNotSynchronizedException(exception) && fErrorCorrectionOnSave == 1 && !isSynchronized) { |
4946 |
String title= EditorMessages.Editor_error_save_outofsync_title; |
4951 |
|
4947 |
String msg= NLSUtility.format(EditorMessages.Editor_error_save_outofsync_message, getEditorInput().getToolTipText()); |
4952 |
OutOfSyncHandler handler = selectOutOfSycHandler(OutOfSyncHandler.getContributors()); |
4948 |
|
4953 |
if (handler != null) |
4949 |
if (MessageDialog.openQuestion(getSite().getShell(), title, msg)) |
4954 |
handler.handle(progressMonitor); |
4950 |
performSave(true, progressMonitor); |
4955 |
else |
4951 |
else { |
|
|
4952 |
/* |
4956 |
/* |
4953 |
* 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits |
4957 |
* 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits |
4954 |
* Set progress monitor to canceled in order to report back |
4958 |
* Set progress monitor to canceled in order to report back |
Lines 4956-4962
Link Here
|
4956 |
*/ |
4960 |
*/ |
4957 |
if (progressMonitor != null) |
4961 |
if (progressMonitor != null) |
4958 |
progressMonitor.setCanceled(true); |
4962 |
progressMonitor.setCanceled(true); |
4959 |
} |
4963 |
|
4960 |
} else { |
4964 |
} else { |
4961 |
String title= EditorMessages.Editor_error_save_title; |
4965 |
String title= EditorMessages.Editor_error_save_title; |
4962 |
String msg= EditorMessages.Editor_error_save_message; |
4966 |
String msg= EditorMessages.Editor_error_save_message; |
Lines 4974-4979
Link Here
|
4974 |
-- fErrorCorrectionOnSave; |
4978 |
-- fErrorCorrectionOnSave; |
4975 |
} |
4979 |
} |
4976 |
} |
4980 |
} |
|
|
4981 |
|
4982 |
/** |
4983 |
* Represents the out-of-sync handler option together with the associated handler. |
4984 |
*/ |
4985 |
private class OutOfSyncHandlerOption { |
4986 |
|
4987 |
private OutOfSyncHandler handler; |
4988 |
|
4989 |
public OutOfSyncHandlerOption(OutOfSyncHandler handler) { |
4990 |
this.handler = handler; |
4991 |
} |
4992 |
|
4993 |
public OutOfSyncHandler getHandler() { |
4994 |
return handler; |
4995 |
} |
4996 |
|
4997 |
public String toString() { |
4998 |
return (handler != null)? handler.getAnswer() : null; |
4999 |
} |
5000 |
|
5001 |
} |
5002 |
|
5003 |
/** |
5004 |
* Presents a dialog for asking what to do on out-of-sync saving errors. |
5005 |
* @param handlers the available handlers |
5006 |
* @return the selected handler |
5007 |
*/ |
5008 |
protected OutOfSyncHandler selectOutOfSycHandler(OutOfSyncHandler[] handlers) { |
5009 |
|
5010 |
OutOfSyncHandlerOption[] answers = new OutOfSyncHandlerOption[handlers.length + 1]; |
5011 |
|
5012 |
answers[handlers.length] = new OutOfSyncHandlerOption(new OutOfSyncHandler(){ |
5013 |
public String getAnswer() { |
5014 |
return EditorMessages.Editor_error_save_outofsync_overwrite; |
5015 |
} |
5016 |
public boolean handle(IProgressMonitor progressMonitor) { |
5017 |
performSave(true, progressMonitor); |
5018 |
return true; |
5019 |
} |
5020 |
}); |
5021 |
|
5022 |
for (int i= 0; i < handlers.length; i++) |
5023 |
answers[i] = new OutOfSyncHandlerOption(handlers[i]); |
5024 |
|
5025 |
// TODO Option icons and better font size |
5026 |
// Use another kind of dialog? For example, with radio buttons for each option |
5027 |
|
5028 |
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getSite().getShell(), new LabelProvider()); |
5029 |
dialog.setElements(answers); |
5030 |
dialog.setHelpAvailable(false); |
5031 |
dialog.setAllowDuplicates(true); |
5032 |
dialog.setMultipleSelection(false); |
5033 |
dialog.setSize(60, 10); |
5034 |
dialog.setTitle(EditorMessages.Editor_error_save_outofsync_title); |
5035 |
dialog.setMessage(NLSUtility.format(EditorMessages.Editor_error_save_outofsync_message, getEditorInput().getToolTipText())); |
5036 |
dialog.setEmptySelectionMessage(EditorMessages.Editor_error_save_outofsync_no_action_selected); |
5037 |
|
5038 |
if (dialog.open() == Window.OK) { |
5039 |
Object[] answer = dialog.getResult(); |
5040 |
if (answer != null) |
5041 |
return ((OutOfSyncHandlerOption)answer[0]).getHandler(); |
5042 |
} |
5043 |
return null; |
5044 |
} |
4977 |
|
5045 |
|
4978 |
/** |
5046 |
/** |
4979 |
* Presents an error dialog to the user when a problem |
5047 |
* Presents an error dialog to the user when a problem |