|
Lines 12-17
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.util.ResourceBundle; |
13 |
import java.util.ResourceBundle; |
| 14 |
|
14 |
|
|
|
15 |
import org.osgi.framework.Bundle; |
| 16 |
|
| 15 |
import org.eclipse.swt.custom.StyledText; |
17 |
import org.eclipse.swt.custom.StyledText; |
| 16 |
import org.eclipse.swt.custom.VerifyKeyListener; |
18 |
import org.eclipse.swt.custom.VerifyKeyListener; |
| 17 |
import org.eclipse.swt.events.FocusEvent; |
19 |
import org.eclipse.swt.events.FocusEvent; |
|
Lines 22-27
Link Here
|
| 22 |
import org.eclipse.swt.graphics.Point; |
24 |
import org.eclipse.swt.graphics.Point; |
| 23 |
import org.eclipse.swt.widgets.Event; |
25 |
import org.eclipse.swt.widgets.Event; |
| 24 |
|
26 |
|
|
|
27 |
import org.eclipse.core.commands.ExecutionEvent; |
| 28 |
import org.eclipse.core.commands.ExecutionException; |
| 29 |
import org.eclipse.core.commands.IExecutionListener; |
| 30 |
import org.eclipse.core.commands.NotHandledException; |
| 31 |
|
| 32 |
import org.eclipse.core.runtime.ILog; |
| 33 |
import org.eclipse.core.runtime.IStatus; |
| 34 |
import org.eclipse.core.runtime.Platform; |
| 35 |
import org.eclipse.core.runtime.Status; |
| 36 |
|
| 25 |
import org.eclipse.jface.text.Assert; |
37 |
import org.eclipse.jface.text.Assert; |
| 26 |
import org.eclipse.jface.text.BadLocationException; |
38 |
import org.eclipse.jface.text.BadLocationException; |
| 27 |
import org.eclipse.jface.text.DocumentEvent; |
39 |
import org.eclipse.jface.text.DocumentEvent; |
|
Lines 35-40
Link Here
|
| 35 |
import org.eclipse.jface.text.TextSelection; |
47 |
import org.eclipse.jface.text.TextSelection; |
| 36 |
import org.eclipse.jface.text.source.ISourceViewer; |
48 |
import org.eclipse.jface.text.source.ISourceViewer; |
| 37 |
|
49 |
|
|
|
50 |
import org.eclipse.ui.PlatformUI; |
| 51 |
import org.eclipse.ui.commands.ICommandService; |
| 52 |
import org.eclipse.ui.components.ComponentException; |
| 53 |
import org.eclipse.ui.internal.texteditor.TextEditorPlugin; |
| 54 |
|
| 38 |
/** |
55 |
/** |
| 39 |
* Action for moving selected lines in an editor. |
56 |
* Action for moving selected lines in an editor. |
| 40 |
* @since 3.0 |
57 |
* @since 3.0 |
|
Lines 51-57
Link Here
|
| 51 |
* <li>the underlying document gets changed due to anything but this action</li> |
68 |
* <li>the underlying document gets changed due to anything but this action</li> |
| 52 |
* </ul> |
69 |
* </ul> |
| 53 |
*/ |
70 |
*/ |
| 54 |
private class ExitStrategy implements VerifyKeyListener, MouseListener, FocusListener, IDocumentListener { |
71 |
private class ExitStrategy implements VerifyKeyListener, MouseListener, FocusListener, IDocumentListener, IExecutionListener { |
| 55 |
|
72 |
|
| 56 |
/** |
73 |
/** |
| 57 |
* The widget this instance is registered with for <code>VerifyKey</code>-, <code>Mouse</code>- |
74 |
* The widget this instance is registered with for <code>VerifyKey</code>-, <code>Mouse</code>- |
|
Lines 92-97
Link Here
|
| 92 |
fDocumentEventSource= viewer.getDocument(); |
109 |
fDocumentEventSource= viewer.getDocument(); |
| 93 |
if (fDocumentEventSource != null) |
110 |
if (fDocumentEventSource != null) |
| 94 |
fDocumentEventSource.addDocumentListener(this); |
111 |
fDocumentEventSource.addDocumentListener(this); |
|
|
112 |
|
| 113 |
try { |
| 114 |
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class); |
| 115 |
commandService.addExecutionListener(this); |
| 116 |
} catch (ComponentException ex) { |
| 117 |
Status status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, ex.getLocalizedMessage(), ex); //$NON-NLS-1$ |
| 118 |
Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); |
| 119 |
ILog log= Platform.getLog(bundle); |
| 120 |
log.log(status); |
| 121 |
} |
| 95 |
} |
122 |
} |
| 96 |
|
123 |
|
| 97 |
/** |
124 |
/** |
|
Lines 108-113
Link Here
|
| 108 |
fDocumentEventSource.removeDocumentListener(this); |
135 |
fDocumentEventSource.removeDocumentListener(this); |
| 109 |
fDocumentEventSource= null; |
136 |
fDocumentEventSource= null; |
| 110 |
} |
137 |
} |
|
|
138 |
|
| 139 |
try { |
| 140 |
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class); |
| 141 |
commandService.removeExecutionListener(this); |
| 142 |
} catch (ComponentException ex) { |
| 143 |
Status status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, ex.getLocalizedMessage(), ex); //$NON-NLS-1$ |
| 144 |
Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); |
| 145 |
ILog log= Platform.getLog(bundle); |
| 146 |
log.log(status); |
| 147 |
} |
| 148 |
|
| 111 |
fIsInstalled= false; |
149 |
fIsInstalled= false; |
| 112 |
} |
150 |
} |
| 113 |
|
151 |
|
|
Lines 139-144
Link Here
|
| 139 |
} |
177 |
} |
| 140 |
|
178 |
|
| 141 |
public void documentChanged(DocumentEvent event) {} |
179 |
public void documentChanged(DocumentEvent event) {} |
|
|
180 |
|
| 181 |
public void notHandled(String commandId, NotHandledException exception) { |
| 182 |
} |
| 183 |
|
| 184 |
public void postExecuteFailure(String commandId, ExecutionException exception) { |
| 185 |
} |
| 186 |
|
| 187 |
public void postExecuteSuccess(String commandId, Object returnValue) { |
| 188 |
} |
| 189 |
|
| 190 |
public void preExecute(String commandId, ExecutionEvent event) { |
| 191 |
if (!fCopy && !(ITextEditorActionDefinitionIds.MOVE_LINES_UP.equals(commandId) || ITextEditorActionDefinitionIds.MOVE_LINES_DOWN.equals(commandId)) |
| 192 |
|| fCopy && !(ITextEditorActionDefinitionIds.COPY_LINES_UP.equals(commandId) || ITextEditorActionDefinitionIds.COPY_LINES_DOWN.equals(commandId))) |
| 193 |
endCompoundEdit(); |
| 194 |
} |
| 142 |
} |
195 |
} |
| 143 |
|
196 |
|
| 144 |
/* keys */ |
197 |
/* keys */ |