Lines 34-39
Link Here
|
34 |
import org.eclipse.ant.internal.ui.editor.actions.RunToLineAdapter; |
34 |
import org.eclipse.ant.internal.ui.editor.actions.RunToLineAdapter; |
35 |
import org.eclipse.ant.internal.ui.editor.actions.ToggleLineBreakpointAction; |
35 |
import org.eclipse.ant.internal.ui.editor.actions.ToggleLineBreakpointAction; |
36 |
import org.eclipse.ant.internal.ui.editor.outline.AntEditorContentOutlinePage; |
36 |
import org.eclipse.ant.internal.ui.editor.outline.AntEditorContentOutlinePage; |
|
|
37 |
import org.eclipse.ant.internal.ui.editor.templates.AntTemplatesPage; |
37 |
import org.eclipse.ant.internal.ui.editor.text.AntEditorDocumentProvider; |
38 |
import org.eclipse.ant.internal.ui.editor.text.AntEditorDocumentProvider; |
38 |
import org.eclipse.ant.internal.ui.editor.text.AntFoldingStructureProvider; |
39 |
import org.eclipse.ant.internal.ui.editor.text.AntFoldingStructureProvider; |
39 |
import org.eclipse.ant.internal.ui.editor.text.IReconcilingParticipant; |
40 |
import org.eclipse.ant.internal.ui.editor.text.IReconcilingParticipant; |
Lines 71-76
Link Here
|
71 |
import org.eclipse.jface.text.ISelectionValidator; |
72 |
import org.eclipse.jface.text.ISelectionValidator; |
72 |
import org.eclipse.jface.text.ISynchronizable; |
73 |
import org.eclipse.jface.text.ISynchronizable; |
73 |
import org.eclipse.jface.text.ITextInputListener; |
74 |
import org.eclipse.jface.text.ITextInputListener; |
|
|
75 |
import org.eclipse.jface.text.ITextOperationTarget; |
74 |
import org.eclipse.jface.text.ITextSelection; |
76 |
import org.eclipse.jface.text.ITextSelection; |
75 |
import org.eclipse.jface.text.ITextViewer; |
77 |
import org.eclipse.jface.text.ITextViewer; |
76 |
import org.eclipse.jface.text.Position; |
78 |
import org.eclipse.jface.text.Position; |
Lines 85-90
Link Here
|
85 |
import org.eclipse.jface.text.source.projection.IProjectionListener; |
87 |
import org.eclipse.jface.text.source.projection.IProjectionListener; |
86 |
import org.eclipse.jface.text.source.projection.ProjectionSupport; |
88 |
import org.eclipse.jface.text.source.projection.ProjectionSupport; |
87 |
import org.eclipse.jface.text.source.projection.ProjectionViewer; |
89 |
import org.eclipse.jface.text.source.projection.ProjectionViewer; |
|
|
90 |
import org.eclipse.jface.text.templates.Template; |
88 |
import org.eclipse.jface.util.PropertyChangeEvent; |
91 |
import org.eclipse.jface.util.PropertyChangeEvent; |
89 |
import org.eclipse.jface.viewers.IPostSelectionProvider; |
92 |
import org.eclipse.jface.viewers.IPostSelectionProvider; |
90 |
import org.eclipse.jface.viewers.ISelection; |
93 |
import org.eclipse.jface.viewers.ISelection; |
Lines 93-98
Link Here
|
93 |
import org.eclipse.jface.viewers.IStructuredSelection; |
96 |
import org.eclipse.jface.viewers.IStructuredSelection; |
94 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
97 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
95 |
import org.eclipse.swt.custom.StyledText; |
98 |
import org.eclipse.swt.custom.StyledText; |
|
|
99 |
import org.eclipse.swt.dnd.Clipboard; |
96 |
import org.eclipse.swt.events.ShellAdapter; |
100 |
import org.eclipse.swt.events.ShellAdapter; |
97 |
import org.eclipse.swt.events.ShellEvent; |
101 |
import org.eclipse.swt.events.ShellEvent; |
98 |
import org.eclipse.swt.graphics.Image; |
102 |
import org.eclipse.swt.graphics.Image; |
Lines 112-139
Link Here
|
112 |
import org.eclipse.ui.texteditor.ContentAssistAction; |
116 |
import org.eclipse.ui.texteditor.ContentAssistAction; |
113 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
117 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
114 |
import org.eclipse.ui.texteditor.IEditorStatusLine; |
118 |
import org.eclipse.ui.texteditor.IEditorStatusLine; |
|
|
119 |
import org.eclipse.ui.texteditor.ITextEditor; |
115 |
import org.eclipse.ui.texteditor.ITextEditorActionConstants; |
120 |
import org.eclipse.ui.texteditor.ITextEditorActionConstants; |
116 |
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; |
121 |
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; |
|
|
122 |
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; |
123 |
import org.eclipse.ui.texteditor.TextEditorAction; |
117 |
import org.eclipse.ui.texteditor.TextOperationAction; |
124 |
import org.eclipse.ui.texteditor.TextOperationAction; |
|
|
125 |
import org.eclipse.ui.texteditor.templates.TemplateTransfer; |
118 |
import org.eclipse.ui.views.contentoutline.ContentOutline; |
126 |
import org.eclipse.ui.views.contentoutline.ContentOutline; |
119 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
127 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
|
|
128 |
import org.eclipse.ui.views.templates.ITemplatesPage; |
120 |
|
129 |
|
121 |
/** |
130 |
/** |
122 |
* The actual editor implementation for Eclipse's Ant integration. |
131 |
* The actual editor implementation for Eclipse's Ant integration. |
123 |
*/ |
132 |
*/ |
124 |
public class AntEditor extends TextEditor implements IReconcilingParticipant, IProjectionListener { |
133 |
public class AntEditor extends TextEditor implements IReconcilingParticipant, |
|
|
134 |
IProjectionListener { |
135 |
|
136 |
class ClipboardPasteOperation extends TextEditorAction { |
137 |
private ITextOperationTarget fOperationTarget; |
138 |
private int fOperationCode = -1; |
139 |
|
140 |
protected ClipboardPasteOperation(ResourceBundle bundle, String prefix, |
141 |
ITextEditor editor, int style) { |
142 |
super(bundle, prefix, editor, style); |
143 |
} |
144 |
|
145 |
public void run() { |
146 |
ITextEditor editor = getTextEditor(); |
147 |
Clipboard clipboard = new Clipboard(getSite().getShell() |
148 |
.getDisplay()); |
149 |
Template[] templates = (Template[]) clipboard |
150 |
.getContents(TemplateTransfer.getInstance()); |
151 |
if (templates != null) { |
152 |
AntTemplatesPage page = (AntTemplatesPage) editor |
153 |
.getAdapter(ITemplatesPage.class); |
154 |
page.insertTemplate(templates[0]); |
155 |
} else |
156 |
fOperationTarget.doOperation(fOperationCode); |
157 |
} |
158 |
|
159 |
/* |
160 |
* (non-Javadoc) |
161 |
* |
162 |
* @see org.eclipse.ui.texteditor.IUpdate#update() |
163 |
*/ |
164 |
public void update() { |
165 |
super.update(); |
166 |
} |
167 |
|
168 |
} |
169 |
|
125 |
/** |
170 |
/** |
126 |
* Updates the Ant outline page selection and this editor's range indicator. |
171 |
* Updates the Ant outline page selection and this editor's range indicator. |
127 |
* |
172 |
* |
128 |
* @since 3.0 |
173 |
* @since 3.0 |
129 |
*/ |
174 |
*/ |
130 |
private class EditorSelectionChangedListener implements ISelectionChangedListener { |
175 |
private class EditorSelectionChangedListener implements |
131 |
|
176 |
ISelectionChangedListener { |
|
|
177 |
|
132 |
/** |
178 |
/** |
133 |
* Installs this selection changed listener with the given selection provider. If |
179 |
* Installs this selection changed listener with the given selection |
134 |
* the selection provider is a post selection provider, post selection changed |
180 |
* provider. If the selection provider is a post selection provider, |
135 |
* events are the preferred choice, otherwise normal selection changed events |
181 |
* post selection changed events are the preferred choice, otherwise |
136 |
* are requested. |
182 |
* normal selection changed events are requested. |
137 |
* |
183 |
* |
138 |
* @param selectionProvider |
184 |
* @param selectionProvider |
139 |
*/ |
185 |
*/ |
Lines 141-157
Link Here
|
141 |
if (selectionProvider == null || getAntModel() == null) { |
187 |
if (selectionProvider == null || getAntModel() == null) { |
142 |
return; |
188 |
return; |
143 |
} |
189 |
} |
144 |
|
190 |
|
145 |
if (selectionProvider instanceof IPostSelectionProvider) { |
191 |
if (selectionProvider instanceof IPostSelectionProvider) { |
146 |
IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; |
192 |
IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider; |
147 |
provider.addPostSelectionChangedListener(this); |
193 |
provider.addPostSelectionChangedListener(this); |
148 |
} else { |
194 |
} else { |
149 |
selectionProvider.addSelectionChangedListener(this); |
195 |
selectionProvider.addSelectionChangedListener(this); |
150 |
} |
196 |
} |
151 |
} |
197 |
} |
152 |
|
198 |
|
153 |
/** |
199 |
/** |
154 |
* Removes this selection changed listener from the given selection provider. |
200 |
* Removes this selection changed listener from the given selection |
|
|
201 |
* provider. |
155 |
* |
202 |
* |
156 |
* @param selectionProvider |
203 |
* @param selectionProvider |
157 |
*/ |
204 |
*/ |
Lines 159-201
Link Here
|
159 |
if (selectionProvider == null || getAntModel() == null) { |
206 |
if (selectionProvider == null || getAntModel() == null) { |
160 |
return; |
207 |
return; |
161 |
} |
208 |
} |
162 |
|
209 |
|
163 |
if (selectionProvider instanceof IPostSelectionProvider) { |
210 |
if (selectionProvider instanceof IPostSelectionProvider) { |
164 |
IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; |
211 |
IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider; |
165 |
provider.removePostSelectionChangedListener(this); |
212 |
provider.removePostSelectionChangedListener(this); |
166 |
} else { |
213 |
} else { |
167 |
selectionProvider.removeSelectionChangedListener(this); |
214 |
selectionProvider.removeSelectionChangedListener(this); |
168 |
} |
215 |
} |
169 |
} |
216 |
} |
170 |
|
217 |
|
171 |
/* |
218 |
/* |
172 |
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
219 |
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
173 |
*/ |
220 |
*/ |
174 |
public void selectionChanged(SelectionChangedEvent event) { |
221 |
public void selectionChanged(SelectionChangedEvent event) { |
175 |
AntModel model= getAntModel(); |
222 |
AntModel model = getAntModel(); |
176 |
ISelection selection= event.getSelection(); |
223 |
ISelection selection = event.getSelection(); |
177 |
AntElementNode node= null; |
224 |
AntElementNode node = null; |
178 |
if (selection instanceof ITextSelection) { |
225 |
if (selection instanceof ITextSelection) { |
179 |
ITextSelection textSelection= (ITextSelection)selection; |
226 |
ITextSelection textSelection = (ITextSelection) selection; |
180 |
int offset= textSelection.getOffset(); |
227 |
int offset = textSelection.getOffset(); |
181 |
node= model.getNode(offset, false); |
228 |
node = model.getNode(offset, false); |
182 |
updateOccurrenceAnnotations(textSelection, model); |
229 |
updateOccurrenceAnnotations(textSelection, model); |
183 |
} |
230 |
} |
184 |
|
231 |
|
185 |
if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) { |
232 |
if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean( |
|
|
233 |
IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) { |
186 |
synchronizeOutlinePage(node, true); |
234 |
synchronizeOutlinePage(node, true); |
187 |
} |
235 |
} |
188 |
setSelection(node, false); |
236 |
setSelection(node, false); |
189 |
} |
237 |
} |
190 |
} |
238 |
} |
191 |
|
239 |
|
192 |
class StatusLineSourceViewer extends ProjectionViewer{ |
240 |
class StatusLineSourceViewer extends ProjectionViewer { |
193 |
|
241 |
|
194 |
public StatusLineSourceViewer(Composite composite, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, int styles) { |
242 |
public StatusLineSourceViewer(Composite composite, |
195 |
super(composite, verticalRuler, overviewRuler, isOverviewRulerVisible(), styles); |
243 |
IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, |
|
|
244 |
int styles) { |
245 |
super(composite, verticalRuler, overviewRuler, |
246 |
isOverviewRulerVisible(), styles); |
196 |
} |
247 |
} |
197 |
|
248 |
|
198 |
/* (non-Javadoc) |
249 |
/* |
|
|
250 |
* (non-Javadoc) |
251 |
* |
199 |
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int) |
252 |
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int) |
200 |
*/ |
253 |
*/ |
201 |
public void doOperation(int operation) { |
254 |
public void doOperation(int operation) { |
Lines 204-372
Link Here
|
204 |
} |
257 |
} |
205 |
|
258 |
|
206 |
switch (operation) { |
259 |
switch (operation) { |
207 |
case CONTENTASSIST_PROPOSALS: |
260 |
case CONTENTASSIST_PROPOSALS: |
208 |
String msg= fContentAssistant.showPossibleCompletions(); |
261 |
String msg = fContentAssistant.showPossibleCompletions(); |
209 |
setStatusLineErrorMessage(msg); |
262 |
setStatusLineErrorMessage(msg); |
210 |
return; |
263 |
return; |
211 |
} |
264 |
} |
212 |
|
265 |
|
213 |
super.doOperation(operation); |
266 |
super.doOperation(operation); |
214 |
} |
267 |
} |
215 |
} |
268 |
} |
216 |
|
269 |
|
217 |
|
|
|
218 |
/** |
270 |
/** |
219 |
* Finds and marks occurrence annotations. |
271 |
* Finds and marks occurrence annotations. |
220 |
* |
272 |
* |
221 |
* @since 3.1 |
273 |
* @since 3.1 |
222 |
*/ |
274 |
*/ |
223 |
class OccurrencesFinderJob extends Job { |
275 |
class OccurrencesFinderJob extends Job { |
224 |
|
276 |
|
225 |
private IDocument fDocument; |
277 |
private IDocument fDocument; |
226 |
private ISelection fSelection; |
278 |
private ISelection fSelection; |
227 |
private ISelectionValidator fPostSelectionValidator; |
279 |
private ISelectionValidator fPostSelectionValidator; |
228 |
private boolean fCanceled= false; |
280 |
private boolean fCanceled = false; |
229 |
private IProgressMonitor fProgressMonitor; |
281 |
private IProgressMonitor fProgressMonitor; |
230 |
private List fPositions; |
282 |
private List fPositions; |
231 |
|
283 |
|
232 |
public OccurrencesFinderJob(IDocument document, List positions, ISelection selection) { |
284 |
public OccurrencesFinderJob(IDocument document, List positions, |
|
|
285 |
ISelection selection) { |
233 |
super("Occurrences Marker"); //$NON-NLS-1$ |
286 |
super("Occurrences Marker"); //$NON-NLS-1$ |
234 |
fDocument= document; |
287 |
fDocument = document; |
235 |
fSelection= selection; |
288 |
fSelection = selection; |
236 |
fPositions= positions; |
289 |
fPositions = positions; |
237 |
|
290 |
|
238 |
if (getSelectionProvider() instanceof ISelectionValidator) |
291 |
if (getSelectionProvider() instanceof ISelectionValidator) |
239 |
fPostSelectionValidator= (ISelectionValidator)getSelectionProvider(); |
292 |
fPostSelectionValidator = (ISelectionValidator) getSelectionProvider(); |
240 |
} |
293 |
} |
241 |
|
294 |
|
242 |
// cannot use cancel() because it is declared final |
295 |
// cannot use cancel() because it is declared final |
243 |
void doCancel() { |
296 |
void doCancel() { |
244 |
fCanceled= true; |
297 |
fCanceled = true; |
245 |
cancel(); |
298 |
cancel(); |
246 |
} |
299 |
} |
247 |
|
300 |
|
248 |
private boolean isCanceled() { |
301 |
private boolean isCanceled() { |
249 |
return fCanceled || fProgressMonitor.isCanceled() |
302 |
return fCanceled |
250 |
|| fPostSelectionValidator != null && !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection) |
303 |
|| fProgressMonitor.isCanceled() |
251 |
|| LinkedModeModel.hasInstalledModel(fDocument); |
304 |
|| fPostSelectionValidator != null |
|
|
305 |
&& !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection) |
306 |
|| LinkedModeModel.hasInstalledModel(fDocument); |
252 |
} |
307 |
} |
253 |
|
308 |
|
254 |
/* |
309 |
/* |
255 |
* @see Job#run(org.eclipse.core.runtime.IProgressMonitor) |
310 |
* @see Job#run(org.eclipse.core.runtime.IProgressMonitor) |
256 |
*/ |
311 |
*/ |
257 |
public IStatus run(IProgressMonitor progressMonitor) { |
312 |
public IStatus run(IProgressMonitor progressMonitor) { |
258 |
|
313 |
|
259 |
fProgressMonitor= progressMonitor; |
314 |
fProgressMonitor = progressMonitor; |
260 |
|
315 |
|
261 |
if (isCanceled()) |
316 |
if (isCanceled()) |
262 |
return Status.CANCEL_STATUS; |
317 |
return Status.CANCEL_STATUS; |
263 |
|
318 |
|
264 |
ITextViewer textViewer= getViewer(); |
319 |
ITextViewer textViewer = getViewer(); |
265 |
if (textViewer == null) |
320 |
if (textViewer == null) |
266 |
return Status.CANCEL_STATUS; |
321 |
return Status.CANCEL_STATUS; |
267 |
|
322 |
|
268 |
IDocument document= textViewer.getDocument(); |
323 |
IDocument document = textViewer.getDocument(); |
269 |
if (document == null) |
324 |
if (document == null) |
270 |
return Status.CANCEL_STATUS; |
325 |
return Status.CANCEL_STATUS; |
271 |
|
326 |
|
272 |
IDocumentProvider documentProvider= getDocumentProvider(); |
327 |
IDocumentProvider documentProvider = getDocumentProvider(); |
273 |
if (documentProvider == null) |
328 |
if (documentProvider == null) |
274 |
return Status.CANCEL_STATUS; |
329 |
return Status.CANCEL_STATUS; |
275 |
|
330 |
|
276 |
IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); |
331 |
IAnnotationModel annotationModel = documentProvider |
|
|
332 |
.getAnnotationModel(getEditorInput()); |
277 |
if (annotationModel == null) |
333 |
if (annotationModel == null) |
278 |
return Status.CANCEL_STATUS; |
334 |
return Status.CANCEL_STATUS; |
279 |
|
335 |
|
280 |
// Add occurrence annotations |
336 |
// Add occurrence annotations |
281 |
int length= fPositions.size(); |
337 |
int length = fPositions.size(); |
282 |
Map annotationMap= new HashMap(length); |
338 |
Map annotationMap = new HashMap(length); |
283 |
for (int i= 0; i < length; i++) { |
339 |
for (int i = 0; i < length; i++) { |
284 |
|
340 |
|
285 |
if (isCanceled()) |
341 |
if (isCanceled()) |
286 |
return Status.CANCEL_STATUS; |
342 |
return Status.CANCEL_STATUS; |
287 |
|
343 |
|
288 |
String message; |
344 |
String message; |
289 |
Position position= (Position) fPositions.get(i); |
345 |
Position position = (Position) fPositions.get(i); |
290 |
|
346 |
|
291 |
// Create & add annotation |
347 |
// Create & add annotation |
292 |
try { |
348 |
try { |
293 |
message= document.get(position.offset, position.length); |
349 |
message = document.get(position.offset, position.length); |
294 |
} catch (BadLocationException ex) { |
350 |
} catch (BadLocationException ex) { |
295 |
// Skip this match |
351 |
// Skip this match |
296 |
continue; |
352 |
continue; |
297 |
} |
353 |
} |
298 |
annotationMap.put( |
354 |
annotationMap.put(new Annotation( |
299 |
new Annotation("org.eclipse.jdt.ui.occurrences", false, message), //$NON-NLS-1$ |
355 |
"org.eclipse.jdt.ui.occurrences", false, message), //$NON-NLS-1$ |
300 |
position); |
356 |
position); |
301 |
} |
357 |
} |
302 |
|
358 |
|
303 |
if (isCanceled()) { |
359 |
if (isCanceled()) { |
304 |
return Status.CANCEL_STATUS; |
360 |
return Status.CANCEL_STATUS; |
305 |
} |
361 |
} |
306 |
|
362 |
|
307 |
Object lock= getLockObject(document); |
363 |
Object lock = getLockObject(document); |
308 |
if (lock == null) { |
364 |
if (lock == null) { |
309 |
updateAnnotations(annotationModel, annotationMap); |
365 |
updateAnnotations(annotationModel, annotationMap); |
310 |
} else { |
366 |
} else { |
311 |
synchronized (lock) { |
367 |
synchronized (lock) { |
312 |
updateAnnotations(annotationModel, annotationMap); |
368 |
updateAnnotations(annotationModel, annotationMap); |
313 |
} |
369 |
} |
314 |
} |
370 |
} |
315 |
|
371 |
|
316 |
return Status.OK_STATUS; |
372 |
return Status.OK_STATUS; |
317 |
} |
373 |
} |
318 |
|
374 |
|
319 |
private void updateAnnotations(IAnnotationModel annotationModel, Map annotationMap) { |
375 |
private void updateAnnotations(IAnnotationModel annotationModel, |
320 |
if (annotationModel instanceof IAnnotationModelExtension) { |
376 |
Map annotationMap) { |
321 |
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap); |
377 |
if (annotationModel instanceof IAnnotationModelExtension) { |
322 |
} else { |
378 |
((IAnnotationModelExtension) annotationModel) |
323 |
removeOccurrenceAnnotations(); |
379 |
.replaceAnnotations(fOccurrenceAnnotations, |
324 |
Iterator iter= annotationMap.entrySet().iterator(); |
380 |
annotationMap); |
325 |
while (iter.hasNext()) { |
381 |
} else { |
326 |
Map.Entry mapEntry= (Map.Entry)iter.next(); |
382 |
removeOccurrenceAnnotations(); |
327 |
annotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue()); |
383 |
Iterator iter = annotationMap.entrySet().iterator(); |
328 |
} |
384 |
while (iter.hasNext()) { |
329 |
} |
385 |
Map.Entry mapEntry = (Map.Entry) iter.next(); |
330 |
fOccurrenceAnnotations= (Annotation[])annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]); |
386 |
annotationModel.addAnnotation((Annotation) mapEntry |
331 |
} |
387 |
.getKey(), (Position) mapEntry.getValue()); |
332 |
} |
388 |
} |
333 |
|
389 |
} |
|
|
390 |
fOccurrenceAnnotations = (Annotation[]) annotationMap.keySet() |
391 |
.toArray(new Annotation[annotationMap.keySet().size()]); |
392 |
} |
393 |
} |
394 |
|
334 |
/** |
395 |
/** |
335 |
* Cancels the occurrences finder job upon document changes. |
396 |
* Cancels the occurrences finder job upon document changes. |
336 |
* |
397 |
* |
337 |
* @since 3.1 |
398 |
* @since 3.1 |
338 |
*/ |
399 |
*/ |
339 |
class OccurrencesFinderJobCanceler implements IDocumentListener, ITextInputListener { |
400 |
class OccurrencesFinderJobCanceler implements IDocumentListener, |
|
|
401 |
ITextInputListener { |
340 |
|
402 |
|
341 |
public void install() { |
403 |
public void install() { |
342 |
ISourceViewer sourceViewer= getSourceViewer(); |
404 |
ISourceViewer sourceViewer = getSourceViewer(); |
343 |
if (sourceViewer == null) |
405 |
if (sourceViewer == null) |
344 |
return; |
406 |
return; |
345 |
|
407 |
|
346 |
StyledText text= sourceViewer.getTextWidget(); |
408 |
StyledText text = sourceViewer.getTextWidget(); |
347 |
if (text == null || text.isDisposed()) |
409 |
if (text == null || text.isDisposed()) |
348 |
return; |
410 |
return; |
349 |
|
411 |
|
350 |
sourceViewer.addTextInputListener(this); |
412 |
sourceViewer.addTextInputListener(this); |
351 |
|
413 |
|
352 |
IDocument document= sourceViewer.getDocument(); |
414 |
IDocument document = sourceViewer.getDocument(); |
353 |
if (document != null) |
415 |
if (document != null) |
354 |
document.addDocumentListener(this); |
416 |
document.addDocumentListener(this); |
355 |
} |
417 |
} |
356 |
|
418 |
|
357 |
public void uninstall() { |
419 |
public void uninstall() { |
358 |
ISourceViewer sourceViewer= getSourceViewer(); |
420 |
ISourceViewer sourceViewer = getSourceViewer(); |
359 |
if (sourceViewer != null) |
421 |
if (sourceViewer != null) |
360 |
sourceViewer.removeTextInputListener(this); |
422 |
sourceViewer.removeTextInputListener(this); |
361 |
|
423 |
|
362 |
IDocumentProvider documentProvider= getDocumentProvider(); |
424 |
IDocumentProvider documentProvider = getDocumentProvider(); |
363 |
if (documentProvider != null) { |
425 |
if (documentProvider != null) { |
364 |
IDocument document= documentProvider.getDocument(getEditorInput()); |
426 |
IDocument document = documentProvider |
|
|
427 |
.getDocument(getEditorInput()); |
365 |
if (document != null) |
428 |
if (document != null) |
366 |
document.removeDocumentListener(this); |
429 |
document.removeDocumentListener(this); |
367 |
} |
430 |
} |
368 |
} |
431 |
} |
369 |
|
|
|
370 |
|
432 |
|
371 |
/* |
433 |
/* |
372 |
* @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) |
434 |
* @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) |
Lines 383-391
Link Here
|
383 |
} |
445 |
} |
384 |
|
446 |
|
385 |
/* |
447 |
/* |
386 |
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) |
448 |
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, |
|
|
449 |
* org.eclipse.jface.text.IDocument) |
387 |
*/ |
450 |
*/ |
388 |
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { |
451 |
public void inputDocumentAboutToBeChanged(IDocument oldInput, |
|
|
452 |
IDocument newInput) { |
389 |
if (oldInput == null) |
453 |
if (oldInput == null) |
390 |
return; |
454 |
return; |
391 |
|
455 |
|
Lines 393-399
Link Here
|
393 |
} |
457 |
} |
394 |
|
458 |
|
395 |
/* |
459 |
/* |
396 |
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) |
460 |
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, |
|
|
461 |
* org.eclipse.jface.text.IDocument) |
397 |
*/ |
462 |
*/ |
398 |
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { |
463 |
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { |
399 |
if (newInput == null) |
464 |
if (newInput == null) |
Lines 401-409
Link Here
|
401 |
newInput.addDocumentListener(this); |
466 |
newInput.addDocumentListener(this); |
402 |
} |
467 |
} |
403 |
} |
468 |
} |
404 |
|
469 |
|
405 |
/** |
470 |
/** |
406 |
* Internal activation listener. |
471 |
* Internal activation listener. |
|
|
472 |
* |
407 |
* @since 3.1 |
473 |
* @since 3.1 |
408 |
*/ |
474 |
*/ |
409 |
private class ActivationListener extends ShellAdapter { |
475 |
private class ActivationListener extends ShellAdapter { |
Lines 412-425
Link Here
|
412 |
*/ |
478 |
*/ |
413 |
public void shellActivated(ShellEvent e) { |
479 |
public void shellActivated(ShellEvent e) { |
414 |
if (fMarkOccurrenceAnnotations && isActivePart()) { |
480 |
if (fMarkOccurrenceAnnotations && isActivePart()) { |
415 |
ISelection selection= getSelectionProvider().getSelection(); |
481 |
ISelection selection = getSelectionProvider().getSelection(); |
416 |
if (selection instanceof ITextSelection) { |
482 |
if (selection instanceof ITextSelection) { |
417 |
fForcedMarkOccurrencesSelection= (ITextSelection) selection; |
483 |
fForcedMarkOccurrencesSelection = (ITextSelection) selection; |
418 |
updateOccurrenceAnnotations(fForcedMarkOccurrencesSelection, getAntModel()); |
484 |
updateOccurrenceAnnotations( |
|
|
485 |
fForcedMarkOccurrencesSelection, getAntModel()); |
419 |
} |
486 |
} |
420 |
} |
487 |
} |
421 |
} |
488 |
} |
422 |
|
489 |
|
423 |
/* |
490 |
/* |
424 |
* @see org.eclipse.swt.events.ShellAdapter#shellDeactivated(org.eclipse.swt.events.ShellEvent) |
491 |
* @see org.eclipse.swt.events.ShellAdapter#shellDeactivated(org.eclipse.swt.events.ShellEvent) |
425 |
*/ |
492 |
*/ |
Lines 432-451
Link Here
|
432 |
/** |
499 |
/** |
433 |
* Selection changed listener for the outline view. |
500 |
* Selection changed listener for the outline view. |
434 |
*/ |
501 |
*/ |
435 |
protected ISelectionChangedListener fSelectionChangedListener = new ISelectionChangedListener(){ |
502 |
protected ISelectionChangedListener fSelectionChangedListener = new ISelectionChangedListener() { |
436 |
public void selectionChanged(SelectionChangedEvent event) { |
503 |
public void selectionChanged(SelectionChangedEvent event) { |
437 |
fSelectionSetFromOutline= false; |
504 |
fSelectionSetFromOutline = false; |
438 |
doSelectionChanged(event); |
505 |
doSelectionChanged(event); |
439 |
fSelectionSetFromOutline= true; |
506 |
fSelectionSetFromOutline = true; |
440 |
} |
507 |
} |
441 |
}; |
508 |
}; |
442 |
|
509 |
|
443 |
private IAntModelListener fAntModelListener= new IAntModelListener() { |
510 |
private IAntModelListener fAntModelListener = new IAntModelListener() { |
444 |
/* (non-Javadoc) |
511 |
/* |
|
|
512 |
* (non-Javadoc) |
513 |
* |
445 |
* @see org.eclipse.ant.internal.ui.editor.outline.IDocumentModelListener#documentModelChanged(org.eclipse.ant.internal.ui.editor.outline.DocumentModelChangeEvent) |
514 |
* @see org.eclipse.ant.internal.ui.editor.outline.IDocumentModelListener#documentModelChanged(org.eclipse.ant.internal.ui.editor.outline.DocumentModelChangeEvent) |
446 |
*/ |
515 |
*/ |
447 |
public void antModelChanged(AntModelChangeEvent event) { |
516 |
public void antModelChanged(AntModelChangeEvent event) { |
448 |
AntModel model= getAntModel(); |
517 |
AntModel model = getAntModel(); |
449 |
if (event.getModel() == model) { |
518 |
if (event.getModel() == model) { |
450 |
if (event.isPreferenceChange()) { |
519 |
if (event.isPreferenceChange()) { |
451 |
updateEditorImage(model); |
520 |
updateEditorImage(model); |
Lines 456-470
Link Here
|
456 |
} |
525 |
} |
457 |
} |
526 |
} |
458 |
}; |
527 |
}; |
459 |
|
528 |
|
460 |
/** |
529 |
/** |
461 |
* The page that shows the outline. |
530 |
* The page that shows the outline. |
462 |
*/ |
531 |
*/ |
463 |
protected AntEditorContentOutlinePage fOutlinePage; |
532 |
protected AntEditorContentOutlinePage fOutlinePage; |
464 |
|
533 |
protected AntTemplatesPage fTemplatesPage; |
465 |
|
534 |
|
466 |
private boolean fInitialReconcile= true; |
535 |
private boolean fInitialReconcile = true; |
467 |
|
536 |
|
468 |
/** |
537 |
/** |
469 |
* The editor selection changed listener. |
538 |
* The editor selection changed listener. |
470 |
* |
539 |
* |
Lines 473-753
Link Here
|
473 |
private EditorSelectionChangedListener fEditorSelectionChangedListener; |
542 |
private EditorSelectionChangedListener fEditorSelectionChangedListener; |
474 |
|
543 |
|
475 |
private ProjectionSupport fProjectionSupport; |
544 |
private ProjectionSupport fProjectionSupport; |
476 |
|
545 |
|
477 |
private AntFoldingStructureProvider fFoldingStructureProvider; |
546 |
private AntFoldingStructureProvider fFoldingStructureProvider; |
478 |
|
|
|
479 |
private boolean fSelectionSetFromOutline= false; |
480 |
|
547 |
|
481 |
private FoldingActionGroup fFoldingGroup; |
548 |
private boolean fSelectionSetFromOutline = false; |
482 |
|
549 |
|
|
|
550 |
private FoldingActionGroup fFoldingGroup; |
551 |
|
483 |
/** |
552 |
/** |
484 |
* Holds the current occurrence annotations. |
553 |
* Holds the current occurrence annotations. |
|
|
554 |
* |
485 |
* @since 3.1 |
555 |
* @since 3.1 |
486 |
*/ |
556 |
*/ |
487 |
private Annotation[] fOccurrenceAnnotations= null; |
557 |
private Annotation[] fOccurrenceAnnotations = null; |
488 |
|
558 |
|
489 |
private OccurrencesFinderJob fOccurrencesFinderJob; |
559 |
private OccurrencesFinderJob fOccurrencesFinderJob; |
490 |
private OccurrencesFinderJobCanceler fOccurrencesFinderJobCanceler; |
560 |
private OccurrencesFinderJobCanceler fOccurrencesFinderJobCanceler; |
491 |
|
561 |
|
492 |
private ITextSelection fForcedMarkOccurrencesSelection; |
562 |
private ITextSelection fForcedMarkOccurrencesSelection; |
493 |
/** |
563 |
/** |
494 |
* The internal shell activation listener for updating occurrences. |
564 |
* The internal shell activation listener for updating occurrences. |
|
|
565 |
* |
495 |
* @since 3.1 |
566 |
* @since 3.1 |
496 |
*/ |
567 |
*/ |
497 |
private ActivationListener fActivationListener= new ActivationListener(); |
568 |
private ActivationListener fActivationListener = new ActivationListener(); |
498 |
|
569 |
|
499 |
private boolean fMarkOccurrenceAnnotations; |
570 |
private boolean fMarkOccurrenceAnnotations; |
500 |
private boolean fStickyOccurrenceAnnotations; |
571 |
private boolean fStickyOccurrenceAnnotations; |
501 |
|
572 |
|
502 |
private AntModel fAntModel; |
573 |
private AntModel fAntModel; |
503 |
|
574 |
|
504 |
public AntEditor() { |
575 |
public AntEditor() { |
505 |
super(); |
576 |
super(); |
506 |
setSourceViewerConfiguration(new AntEditorSourceViewerConfiguration(this)); |
577 |
setSourceViewerConfiguration(new AntEditorSourceViewerConfiguration( |
|
|
578 |
this)); |
507 |
setDocumentProvider(AntUIPlugin.getDefault().getDocumentProvider()); |
579 |
setDocumentProvider(AntUIPlugin.getDefault().getDocumentProvider()); |
508 |
AntModelCore.getDefault().addAntModelListener(fAntModelListener); |
580 |
AntModelCore.getDefault().addAntModelListener(fAntModelListener); |
509 |
|
581 |
|
510 |
if (isFoldingEnabled()) { |
582 |
if (isFoldingEnabled()) { |
511 |
fFoldingStructureProvider= new AntFoldingStructureProvider(this); |
583 |
fFoldingStructureProvider = new AntFoldingStructureProvider(this); |
512 |
} |
584 |
} |
513 |
} |
585 |
} |
|
|
586 |
|
587 |
/* |
588 |
* (non-Javadoc) |
589 |
* |
590 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() |
591 |
*/ |
592 |
protected void createActions() { |
593 |
super.createActions(); |
594 |
|
595 |
ResourceBundle bundle = ResourceBundle |
596 |
.getBundle("org.eclipse.ant.internal.ui.editor.AntEditorMessages"); //$NON-NLS-1$ |
597 |
IAction action = new ContentAssistAction(bundle, |
598 |
"ContentAssistProposal.", this); //$NON-NLS-1$ |
599 |
|
600 |
// This action definition is associated with the accelerator Ctrl+Space |
601 |
action |
602 |
.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); |
603 |
setAction("ContentAssistProposal", action); //$NON-NLS-1$ |
514 |
|
604 |
|
|
|
605 |
action = new TextOperationAction(bundle, |
606 |
"ContentFormat.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ |
607 |
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT); |
608 |
setAction("ContentFormat", action); //$NON-NLS-1$ |
515 |
|
609 |
|
516 |
/* (non-Javadoc) |
610 |
action = new OpenDeclarationAction(this); |
517 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() |
611 |
setAction("OpenDeclaration", action); //$NON-NLS-1$ |
518 |
*/ |
612 |
|
519 |
protected void createActions() { |
613 |
fFoldingGroup = new FoldingActionGroup(this, getViewer()); |
520 |
super.createActions(); |
614 |
|
521 |
|
615 |
action = new RenameInFileAction(this); |
522 |
ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.ant.internal.ui.editor.AntEditorMessages"); //$NON-NLS-1$ |
|
|
523 |
IAction action = new ContentAssistAction(bundle, "ContentAssistProposal.", this); //$NON-NLS-1$ |
524 |
|
525 |
// This action definition is associated with the accelerator Ctrl+Space |
526 |
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); |
527 |
setAction("ContentAssistProposal", action); //$NON-NLS-1$ |
528 |
|
529 |
action = new TextOperationAction(bundle, "ContentFormat.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ |
530 |
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT); |
531 |
setAction("ContentFormat", action); //$NON-NLS-1$ |
532 |
|
533 |
action = new OpenDeclarationAction(this); |
534 |
setAction("OpenDeclaration", action); //$NON-NLS-1$ |
535 |
|
536 |
fFoldingGroup= new FoldingActionGroup(this, getViewer()); |
537 |
|
538 |
action= new RenameInFileAction(this); |
539 |
action.setActionDefinitionId("org.eclipse.ant.ui.renameInFile"); //$NON-NLS-1$ |
616 |
action.setActionDefinitionId("org.eclipse.ant.ui.renameInFile"); //$NON-NLS-1$ |
540 |
setAction("renameInFile", action); //$NON-NLS-1$ |
617 |
setAction("renameInFile", action); //$NON-NLS-1$ |
541 |
} |
618 |
|
|
|
619 |
// Override the TextEditor paste operation to support templates |
620 |
action = new ClipboardPasteOperation(bundle, |
621 |
"Editor.Paste.", this, ITextOperationTarget.PASTE); //$NON-NLS-1$ |
622 |
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE); |
623 |
setAction(ITextEditorActionConstants.PASTE, action); |
624 |
} |
542 |
|
625 |
|
543 |
/* |
626 |
/* |
544 |
* (non-Javadoc) |
627 |
* (non-Javadoc) |
545 |
* @see org.eclipse.ui.editors.text.TextEditor#initializeEditor() |
628 |
* |
546 |
* Called from TextEditor.<init> |
629 |
* @see org.eclipse.ui.editors.text.TextEditor#initializeEditor() Called |
|
|
630 |
* from TextEditor.<init> |
547 |
*/ |
631 |
*/ |
548 |
protected void initializeEditor() { |
632 |
protected void initializeEditor() { |
549 |
super.initializeEditor(); |
633 |
super.initializeEditor(); |
550 |
setPreferenceStore(AntUIPlugin.getDefault().getCombinedPreferenceStore()); |
634 |
setPreferenceStore(AntUIPlugin.getDefault() |
|
|
635 |
.getCombinedPreferenceStore()); |
551 |
setCompatibilityMode(false); |
636 |
setCompatibilityMode(false); |
552 |
setHelpContextId(IAntUIHelpContextIds.ANT_EDITOR); |
637 |
setHelpContextId(IAntUIHelpContextIds.ANT_EDITOR); |
553 |
setRulerContextMenuId("org.eclipse.ant.internal.ui.editor.AntEditor.RulerContext"); //$NON-NLS-1$ |
638 |
setRulerContextMenuId("org.eclipse.ant.internal.ui.editor.AntEditor.RulerContext"); //$NON-NLS-1$ |
554 |
setEditorContextMenuId("org.eclipse.ant.internal.ui.editor.AntEditor"); //$NON-NLS-1$ |
639 |
setEditorContextMenuId("org.eclipse.ant.internal.ui.editor.AntEditor"); //$NON-NLS-1$ |
555 |
fMarkOccurrenceAnnotations= getPreferenceStore().getBoolean(AntEditorPreferenceConstants.EDITOR_MARK_OCCURRENCES); |
640 |
fMarkOccurrenceAnnotations = getPreferenceStore().getBoolean( |
556 |
fStickyOccurrenceAnnotations= getPreferenceStore().getBoolean(AntEditorPreferenceConstants.EDITOR_STICKY_OCCURRENCES); |
641 |
AntEditorPreferenceConstants.EDITOR_MARK_OCCURRENCES); |
557 |
} |
642 |
fStickyOccurrenceAnnotations = getPreferenceStore().getBoolean( |
558 |
|
643 |
AntEditorPreferenceConstants.EDITOR_STICKY_OCCURRENCES); |
559 |
/* (non-Javadoc) |
644 |
} |
|
|
645 |
|
646 |
/* |
647 |
* (non-Javadoc) |
648 |
* |
560 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
649 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
561 |
*/ |
650 |
*/ |
562 |
public Object getAdapter(Class key) { |
651 |
public Object getAdapter(Class key) { |
563 |
if (key.equals(IContentOutlinePage.class)) { |
652 |
if (key.equals(IContentOutlinePage.class)) { |
564 |
return getOutlinePage(); |
653 |
return getOutlinePage(); |
565 |
} |
654 |
} |
566 |
|
655 |
|
567 |
if (fProjectionSupport != null) { |
656 |
if (key.equals(ITemplatesPage.class)) { |
568 |
Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), key); |
657 |
return getTemplatesPage(); |
569 |
if (adapter != null) { |
658 |
} |
570 |
return adapter; |
|
|
571 |
} |
572 |
} |
573 |
|
659 |
|
574 |
if (key == IShowInTargetList.class) { |
660 |
if (fProjectionSupport != null) { |
|
|
661 |
Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), |
662 |
key); |
663 |
if (adapter != null) { |
664 |
return adapter; |
665 |
} |
666 |
} |
667 |
|
668 |
if (key == IShowInTargetList.class) { |
575 |
return new IShowInTargetList() { |
669 |
return new IShowInTargetList() { |
576 |
public String[] getShowInTargetIds() { |
670 |
public String[] getShowInTargetIds() { |
577 |
return new String[] { JavaUI.ID_PACKAGES, IPageLayout.ID_RES_NAV }; |
671 |
return new String[] { JavaUI.ID_PACKAGES, |
|
|
672 |
IPageLayout.ID_RES_NAV }; |
578 |
} |
673 |
} |
579 |
}; |
674 |
}; |
580 |
} |
675 |
} |
581 |
|
676 |
|
582 |
if (key == IToggleBreakpointsTarget.class) { |
677 |
if (key == IToggleBreakpointsTarget.class) { |
583 |
return new ToggleLineBreakpointAction(); |
678 |
return new ToggleLineBreakpointAction(); |
584 |
} |
679 |
} |
585 |
|
680 |
|
586 |
if (key == IRunToLineTarget.class) { |
681 |
if (key == IRunToLineTarget.class) { |
587 |
return new RunToLineAdapter(); |
682 |
return new RunToLineAdapter(); |
588 |
} |
683 |
} |
589 |
|
684 |
|
590 |
return super.getAdapter(key); |
685 |
return super.getAdapter(key); |
591 |
} |
686 |
} |
592 |
|
687 |
|
593 |
private AntEditorContentOutlinePage getOutlinePage() { |
688 |
private AntEditorContentOutlinePage getOutlinePage() { |
594 |
if (fOutlinePage == null) { |
689 |
if (fOutlinePage == null) { |
595 |
fOutlinePage= new AntEditorContentOutlinePage(AntModelCore.getDefault(), this); |
690 |
fOutlinePage = new AntEditorContentOutlinePage(AntModelCore |
596 |
fOutlinePage.addPostSelectionChangedListener(fSelectionChangedListener); |
691 |
.getDefault(), this); |
|
|
692 |
fOutlinePage |
693 |
.addPostSelectionChangedListener(fSelectionChangedListener); |
597 |
setOutlinePageInput(); |
694 |
setOutlinePageInput(); |
598 |
} |
695 |
} |
599 |
return fOutlinePage; |
696 |
return fOutlinePage; |
600 |
} |
697 |
} |
601 |
|
698 |
|
602 |
private void doSelectionChanged(SelectionChangedEvent selectionChangedEvent) { |
699 |
private AntTemplatesPage getTemplatesPage() { |
603 |
IStructuredSelection selection= (IStructuredSelection)selectionChangedEvent.getSelection(); |
700 |
if (fTemplatesPage == null) { |
|
|
701 |
fTemplatesPage = new AntTemplatesPage(this); |
702 |
} |
703 |
return fTemplatesPage; |
704 |
} |
705 |
|
706 |
protected void handleCursorPositionChanged() { |
707 |
super.handleCursorPositionChanged(); |
708 |
if (fTemplatesPage != null) |
709 |
fTemplatesPage.cursorPositionChanged(); |
710 |
} |
604 |
|
711 |
|
605 |
if (!isActivePart() && AntUIPlugin.getActivePage() != null) { |
712 |
private void doSelectionChanged(SelectionChangedEvent selectionChangedEvent) { |
|
|
713 |
IStructuredSelection selection = (IStructuredSelection) selectionChangedEvent |
714 |
.getSelection(); |
715 |
|
716 |
if (!isActivePart() && AntUIPlugin.getActivePage() != null) { |
606 |
AntUIPlugin.getActivePage().bringToTop(this); |
717 |
AntUIPlugin.getActivePage().bringToTop(this); |
607 |
} |
718 |
} |
608 |
|
719 |
|
609 |
AntElementNode selectedXmlElement = (AntElementNode)selection.getFirstElement(); |
720 |
AntElementNode selectedXmlElement = (AntElementNode) selection |
610 |
if(selectedXmlElement != null) { |
721 |
.getFirstElement(); |
|
|
722 |
if (selectedXmlElement != null) { |
611 |
setSelection(selectedXmlElement, !isActivePart()); |
723 |
setSelection(selectedXmlElement, !isActivePart()); |
612 |
} |
724 |
} |
613 |
} |
725 |
} |
|
|
726 |
|
727 |
private boolean isActivePart() { |
728 |
IWorkbenchPart part = getActivePart(); |
729 |
return part != null && part.equals(this); |
730 |
} |
731 |
|
732 |
public void setSelection(AntElementNode reference, boolean moveCursor) { |
733 |
if (fSelectionSetFromOutline) { |
734 |
// the work has all just been done via a selection setting in the |
735 |
// outline |
736 |
fSelectionSetFromOutline = false; |
737 |
return; |
738 |
} |
739 |
if (reference == null) { |
740 |
if (moveCursor) { |
741 |
resetHighlightRange(); |
742 |
markInNavigationHistory(); |
743 |
} |
744 |
return; |
745 |
} |
614 |
|
746 |
|
615 |
private boolean isActivePart() { |
|
|
616 |
IWorkbenchPart part= getActivePart(); |
617 |
return part != null && part.equals(this); |
618 |
} |
619 |
|
620 |
public void setSelection(AntElementNode reference, boolean moveCursor) { |
621 |
if (fSelectionSetFromOutline) { |
622 |
//the work has all just been done via a selection setting in the outline |
623 |
fSelectionSetFromOutline= false; |
624 |
return; |
625 |
} |
626 |
if (reference == null) { |
627 |
if (moveCursor) { |
628 |
resetHighlightRange(); |
629 |
markInNavigationHistory(); |
630 |
} |
631 |
return; |
632 |
} |
633 |
|
634 |
if (moveCursor) { |
747 |
if (moveCursor) { |
635 |
markInNavigationHistory(); |
748 |
markInNavigationHistory(); |
636 |
} |
749 |
} |
637 |
|
|
|
638 |
while (reference.getImportNode() != null) { |
639 |
reference= reference.getImportNode(); |
640 |
} |
641 |
if (reference.isExternal()) { |
642 |
return; |
643 |
} |
644 |
|
645 |
ISourceViewer sourceViewer= getSourceViewer(); |
646 |
if (sourceViewer == null) { |
647 |
return; |
648 |
} |
649 |
StyledText textWidget= sourceViewer.getTextWidget(); |
650 |
if (textWidget == null) { |
651 |
return; |
652 |
} |
653 |
|
654 |
try { |
655 |
int offset= reference.getOffset(); |
656 |
if (offset < 0) { |
657 |
return; |
658 |
} |
659 |
int length= reference.getSelectionLength(); |
660 |
int highLightLength= reference.getLength(); |
661 |
|
662 |
textWidget.setRedraw(false); |
663 |
|
664 |
if (highLightLength > 0) { |
665 |
setHighlightRange(offset, highLightLength, moveCursor); |
666 |
} |
667 |
|
668 |
if (!moveCursor) { |
669 |
return; |
670 |
} |
671 |
|
672 |
if (offset > -1 && length > 0) { |
673 |
sourceViewer.revealRange(offset, length); |
674 |
// Selected region begins one index after offset |
675 |
sourceViewer.setSelectedRange(offset, length); |
676 |
markInNavigationHistory(); |
677 |
} |
678 |
} catch (IllegalArgumentException x) { |
679 |
AntUIPlugin.log(x); |
680 |
} finally { |
681 |
textWidget.setRedraw(true); |
682 |
} |
683 |
} |
684 |
|
750 |
|
685 |
/* (non-Javadoc) |
751 |
while (reference.getImportNode() != null) { |
|
|
752 |
reference = reference.getImportNode(); |
753 |
} |
754 |
if (reference.isExternal()) { |
755 |
return; |
756 |
} |
757 |
|
758 |
ISourceViewer sourceViewer = getSourceViewer(); |
759 |
if (sourceViewer == null) { |
760 |
return; |
761 |
} |
762 |
StyledText textWidget = sourceViewer.getTextWidget(); |
763 |
if (textWidget == null) { |
764 |
return; |
765 |
} |
766 |
|
767 |
try { |
768 |
int offset = reference.getOffset(); |
769 |
if (offset < 0) { |
770 |
return; |
771 |
} |
772 |
int length = reference.getSelectionLength(); |
773 |
int highLightLength = reference.getLength(); |
774 |
|
775 |
textWidget.setRedraw(false); |
776 |
|
777 |
if (highLightLength > 0) { |
778 |
setHighlightRange(offset, highLightLength, moveCursor); |
779 |
} |
780 |
|
781 |
if (!moveCursor) { |
782 |
return; |
783 |
} |
784 |
|
785 |
if (offset > -1 && length > 0) { |
786 |
sourceViewer.revealRange(offset, length); |
787 |
// Selected region begins one index after offset |
788 |
sourceViewer.setSelectedRange(offset, length); |
789 |
markInNavigationHistory(); |
790 |
} |
791 |
} catch (IllegalArgumentException x) { |
792 |
AntUIPlugin.log(x); |
793 |
} finally { |
794 |
textWidget.setRedraw(true); |
795 |
} |
796 |
} |
797 |
|
798 |
/* |
799 |
* (non-Javadoc) |
800 |
* |
686 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#affectsTextPresentation(org.eclipse.jface.util.PropertyChangeEvent) |
801 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#affectsTextPresentation(org.eclipse.jface.util.PropertyChangeEvent) |
687 |
*/ |
802 |
*/ |
688 |
protected boolean affectsTextPresentation(PropertyChangeEvent event) { |
803 |
protected boolean affectsTextPresentation(PropertyChangeEvent event) { |
689 |
return ((AntEditorSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event); |
804 |
return ((AntEditorSourceViewerConfiguration) getSourceViewerConfiguration()) |
|
|
805 |
.affectsTextPresentation(event); |
690 |
} |
806 |
} |
691 |
|
807 |
|
692 |
/* (non-Javadoc) |
808 |
/* |
|
|
809 |
* (non-Javadoc) |
810 |
* |
693 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent) |
811 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent) |
694 |
*/ |
812 |
*/ |
695 |
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { |
813 |
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { |
696 |
String property= event.getProperty(); |
814 |
String property = event.getProperty(); |
697 |
|
815 |
|
698 |
if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) { |
816 |
if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH |
699 |
Object value= event.getNewValue(); |
817 |
.equals(property)) { |
700 |
StatusLineSourceViewer viewer= (StatusLineSourceViewer) getSourceViewer(); |
818 |
Object value = event.getNewValue(); |
701 |
int newValue= -1; |
819 |
StatusLineSourceViewer viewer = (StatusLineSourceViewer) getSourceViewer(); |
|
|
820 |
int newValue = -1; |
702 |
if (value instanceof Integer) { |
821 |
if (value instanceof Integer) { |
703 |
newValue=((Integer) value).intValue(); |
822 |
newValue = ((Integer) value).intValue(); |
704 |
} else if (value instanceof String) { |
823 |
} else if (value instanceof String) { |
705 |
newValue= Integer.parseInt((String) value); |
824 |
newValue = Integer.parseInt((String) value); |
706 |
} |
825 |
} |
707 |
if (newValue != -1) { |
826 |
if (newValue != -1) { |
708 |
viewer.getTextWidget().setTabs(newValue); |
827 |
viewer.getTextWidget().setTabs(newValue); |
709 |
} |
828 |
} |
710 |
return; |
829 |
return; |
711 |
} |
830 |
} |
712 |
|
831 |
|
713 |
if (AntEditorPreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) { |
832 |
if (AntEditorPreferenceConstants.EDITOR_MARK_OCCURRENCES |
714 |
boolean newBooleanValue= Boolean.valueOf(event.getNewValue().toString()).booleanValue(); |
833 |
.equals(property)) { |
|
|
834 |
boolean newBooleanValue = Boolean.valueOf( |
835 |
event.getNewValue().toString()).booleanValue(); |
715 |
if (newBooleanValue != fMarkOccurrenceAnnotations) { |
836 |
if (newBooleanValue != fMarkOccurrenceAnnotations) { |
716 |
fMarkOccurrenceAnnotations= newBooleanValue; |
837 |
fMarkOccurrenceAnnotations = newBooleanValue; |
717 |
if (fMarkOccurrenceAnnotations) { |
838 |
if (fMarkOccurrenceAnnotations) { |
718 |
installOccurrencesFinder(); |
839 |
installOccurrencesFinder(); |
719 |
} else { |
840 |
} else { |
720 |
uninstallOccurrencesFinder(); |
841 |
uninstallOccurrencesFinder(); |
721 |
} |
842 |
} |
722 |
} |
843 |
} |
723 |
return; |
844 |
return; |
724 |
} |
845 |
} |
725 |
if (AntEditorPreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) { |
846 |
if (AntEditorPreferenceConstants.EDITOR_STICKY_OCCURRENCES |
726 |
boolean newBooleanValue= Boolean.valueOf(event.getNewValue().toString()).booleanValue(); |
847 |
.equals(property)) { |
727 |
fStickyOccurrenceAnnotations= newBooleanValue; |
848 |
boolean newBooleanValue = Boolean.valueOf( |
|
|
849 |
event.getNewValue().toString()).booleanValue(); |
850 |
fStickyOccurrenceAnnotations = newBooleanValue; |
728 |
return; |
851 |
return; |
729 |
} |
852 |
} |
730 |
|
853 |
|
731 |
AntEditorSourceViewerConfiguration sourceViewerConfiguration= (AntEditorSourceViewerConfiguration)getSourceViewerConfiguration(); |
854 |
AntEditorSourceViewerConfiguration sourceViewerConfiguration = (AntEditorSourceViewerConfiguration) getSourceViewerConfiguration(); |
732 |
if (sourceViewerConfiguration != null) { |
855 |
if (sourceViewerConfiguration != null) { |
733 |
if (affectsTextPresentation(event)) { |
856 |
if (affectsTextPresentation(event)) { |
734 |
sourceViewerConfiguration.adaptToPreferenceChange(event); |
857 |
sourceViewerConfiguration.adaptToPreferenceChange(event); |
735 |
} |
858 |
} |
736 |
|
859 |
|
737 |
sourceViewerConfiguration.changeConfiguration(event); |
860 |
sourceViewerConfiguration.changeConfiguration(event); |
738 |
} |
861 |
} |
739 |
super.handlePreferenceStoreChanged(event); |
862 |
super.handlePreferenceStoreChanged(event); |
740 |
} |
863 |
} |
741 |
|
864 |
|
742 |
/* |
865 |
/* |
743 |
* @see org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput) |
866 |
* @see org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput) |
744 |
*/ |
867 |
*/ |
745 |
protected void doSetInput(IEditorInput input) throws CoreException { |
868 |
protected void doSetInput(IEditorInput input) throws CoreException { |
746 |
fAntModel= null; |
869 |
fAntModel = null; |
747 |
super.doSetInput(input); |
870 |
super.doSetInput(input); |
748 |
setOutlinePageInput(); |
871 |
setOutlinePageInput(); |
749 |
if (fFoldingStructureProvider != null) { |
872 |
if (fFoldingStructureProvider != null) { |
750 |
fFoldingStructureProvider.setDocument(getDocumentProvider().getDocument(input)); |
873 |
fFoldingStructureProvider.setDocument(getDocumentProvider() |
|
|
874 |
.getDocument(input)); |
751 |
} |
875 |
} |
752 |
} |
876 |
} |
753 |
|
877 |
|
Lines 756-896
Link Here
|
756 |
fOutlinePage.setPageInput(getAntModel()); |
880 |
fOutlinePage.setPageInput(getAntModel()); |
757 |
} |
881 |
} |
758 |
} |
882 |
} |
759 |
|
883 |
|
760 |
/** |
884 |
/** |
761 |
* Returns the Ant model for the current editor input of this editor. |
885 |
* Returns the Ant model for the current editor input of this editor. |
|
|
886 |
* |
762 |
* @return the Ant model for this editor or <code>null</code> |
887 |
* @return the Ant model for this editor or <code>null</code> |
763 |
*/ |
888 |
*/ |
764 |
public AntModel getAntModel() { |
889 |
public AntModel getAntModel() { |
765 |
if (fAntModel == null) { |
890 |
if (fAntModel == null) { |
766 |
IDocumentProvider provider= getDocumentProvider(); |
891 |
IDocumentProvider provider = getDocumentProvider(); |
767 |
if (provider instanceof AntEditorDocumentProvider) { |
892 |
if (provider instanceof AntEditorDocumentProvider) { |
768 |
AntEditorDocumentProvider documentProvider= (AntEditorDocumentProvider) provider; |
893 |
AntEditorDocumentProvider documentProvider = (AntEditorDocumentProvider) provider; |
769 |
fAntModel= documentProvider.getAntModel(getEditorInput()); |
894 |
fAntModel = documentProvider.getAntModel(getEditorInput()); |
770 |
} |
895 |
} |
771 |
} |
896 |
} |
772 |
return fAntModel; |
897 |
return fAntModel; |
773 |
} |
898 |
} |
774 |
|
899 |
|
775 |
/* (non-Javadoc) |
900 |
/* |
776 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int) |
901 |
* (non-Javadoc) |
777 |
*/ |
902 |
* |
778 |
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { |
903 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, |
779 |
fOverviewRuler= createOverviewRuler(getSharedColors()); |
904 |
* org.eclipse.jface.text.source.IVerticalRuler, int) |
780 |
ISourceViewer viewer= new StatusLineSourceViewer(parent, ruler, getOverviewRuler(), styles); |
905 |
*/ |
781 |
//ensure decoration support has been created and configured. |
906 |
protected ISourceViewer createSourceViewer(Composite parent, |
|
|
907 |
IVerticalRuler ruler, int styles) { |
908 |
fOverviewRuler = createOverviewRuler(getSharedColors()); |
909 |
ISourceViewer viewer = new StatusLineSourceViewer(parent, ruler, |
910 |
getOverviewRuler(), styles); |
911 |
// ensure decoration support has been created and configured. |
782 |
getSourceViewerDecorationSupport(viewer); |
912 |
getSourceViewerDecorationSupport(viewer); |
783 |
return viewer; |
913 |
return viewer; |
784 |
} |
914 |
} |
785 |
|
915 |
|
786 |
/** |
916 |
/** |
787 |
* Set the given message as error message to this editor's status line. |
917 |
* Set the given message as error message to this editor's status line. |
788 |
* @param msg message to be set |
918 |
* |
|
|
919 |
* @param msg |
920 |
* message to be set |
789 |
*/ |
921 |
*/ |
790 |
protected void setStatusLineErrorMessage(String msg) { |
922 |
protected void setStatusLineErrorMessage(String msg) { |
791 |
IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class); |
923 |
IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class); |
792 |
if (statusLine != null) |
924 |
if (statusLine != null) |
793 |
statusLine.setMessage(true, msg, null); |
925 |
statusLine.setMessage(true, msg, null); |
794 |
} |
926 |
} |
795 |
|
927 |
|
796 |
public void openReferenceElement() { |
928 |
public void openReferenceElement() { |
797 |
ISelection selection= getSelectionProvider().getSelection(); |
929 |
ISelection selection = getSelectionProvider().getSelection(); |
798 |
Object target= null; |
930 |
Object target = null; |
799 |
if (selection instanceof ITextSelection) { |
931 |
if (selection instanceof ITextSelection) { |
800 |
ITextSelection textSelection= (ITextSelection)selection; |
932 |
ITextSelection textSelection = (ITextSelection) selection; |
801 |
ISourceViewer viewer= getSourceViewer(); |
933 |
ISourceViewer viewer = getSourceViewer(); |
802 |
int textOffset= textSelection.getOffset(); |
934 |
int textOffset = textSelection.getOffset(); |
803 |
IRegion region= XMLTextHover.getRegion(viewer, textOffset); |
935 |
IRegion region = XMLTextHover.getRegion(viewer, textOffset); |
804 |
target= findTarget(region); |
936 |
target = findTarget(region); |
805 |
} |
937 |
} |
806 |
|
938 |
|
807 |
openTarget(target); |
939 |
openTarget(target); |
808 |
} |
940 |
} |
809 |
|
941 |
|
810 |
protected void openTarget(Object node) { |
942 |
protected void openTarget(Object node) { |
811 |
String errorMessage= null; |
943 |
String errorMessage = null; |
812 |
if (node instanceof AntElementNode) { |
944 |
if (node instanceof AntElementNode) { |
813 |
errorMessage= openNode((AntElementNode) node); |
945 |
errorMessage = openNode((AntElementNode) node); |
814 |
if (errorMessage == null) { |
946 |
if (errorMessage == null) { |
815 |
return; |
947 |
return; |
816 |
} |
948 |
} |
817 |
} else if (node instanceof String){ |
949 |
} else if (node instanceof String) { |
818 |
errorMessage= openInEditor((String) node, getAntModel().getEditedFile()); |
950 |
errorMessage = openInEditor((String) node, getAntModel() |
|
|
951 |
.getEditedFile()); |
819 |
if (errorMessage == null) { |
952 |
if (errorMessage == null) { |
820 |
return; |
953 |
return; |
821 |
} |
954 |
} |
822 |
} |
955 |
} |
823 |
if (errorMessage == null || errorMessage.length() == 0) { |
956 |
if (errorMessage == null || errorMessage.length() == 0) { |
824 |
errorMessage= AntEditorMessages.getString("AntEditor.3"); //$NON-NLS-1$ |
957 |
errorMessage = AntEditorMessages.getString("AntEditor.3"); //$NON-NLS-1$ |
825 |
} |
958 |
} |
826 |
setStatusLineErrorMessage(errorMessage); |
959 |
setStatusLineErrorMessage(errorMessage); |
827 |
getSite().getShell().getDisplay().beep(); |
960 |
getSite().getShell().getDisplay().beep(); |
828 |
} |
961 |
} |
829 |
|
962 |
|
830 |
/** |
963 |
/** |
831 |
* @param region The region to find the navigation target |
964 |
* @param region |
832 |
* @return the navigation target at the specified region |
965 |
* The region to find the navigation target |
833 |
*/ |
966 |
* @return the navigation target at the specified region |
834 |
public Object findTarget(IRegion region) { |
967 |
*/ |
835 |
ISourceViewer viewer = getSourceViewer(); |
968 |
public Object findTarget(IRegion region) { |
836 |
AntElementNode node= null; |
969 |
ISourceViewer viewer = getSourceViewer(); |
837 |
|
970 |
AntElementNode node = null; |
|
|
971 |
|
838 |
if (region != null) { |
972 |
if (region != null) { |
839 |
IDocument document= viewer.getDocument(); |
973 |
IDocument document = viewer.getDocument(); |
840 |
String text= null; |
974 |
String text = null; |
841 |
try { |
975 |
try { |
842 |
text= document.get(region.getOffset(), region.getLength()); |
976 |
text = document.get(region.getOffset(), region.getLength()); |
843 |
} catch (BadLocationException e) { |
977 |
} catch (BadLocationException e) { |
844 |
} |
978 |
} |
845 |
if (text != null && text.length() > 0) { |
979 |
if (text != null && text.length() > 0) { |
846 |
AntModel model= getAntModel(); |
980 |
AntModel model = getAntModel(); |
847 |
if (model == null) { |
981 |
if (model == null) { |
848 |
return null; |
982 |
return null; |
849 |
} |
983 |
} |
850 |
node= model.getReferenceNode(text); |
984 |
node = model.getReferenceNode(text); |
851 |
if (node == null) { |
985 |
if (node == null) { |
852 |
node= model.getTargetNode(text); |
986 |
node = model.getTargetNode(text); |
853 |
if (node == null) { |
987 |
if (node == null) { |
854 |
node= model.getPropertyNode(text); |
988 |
node = model.getPropertyNode(text); |
855 |
if (node == null) { |
989 |
if (node == null) { |
856 |
String path= model.getPath(text, region.getOffset()); |
990 |
String path = model.getPath(text, region |
|
|
991 |
.getOffset()); |
857 |
if (path != null) { |
992 |
if (path != null) { |
858 |
return path; |
993 |
return path; |
859 |
} |
994 |
} |
860 |
|
995 |
|
861 |
node= model.getDefininingTaskNode(text); |
996 |
node = model.getDefininingTaskNode(text); |
862 |
if (node == null) { |
997 |
if (node == null) { |
863 |
node= model.getMacroDefAttributeNode(text); |
998 |
node = model.getMacroDefAttributeNode(text); |
864 |
} |
999 |
} |
865 |
} |
1000 |
} |
866 |
} |
1001 |
} |
867 |
} |
1002 |
} |
868 |
} |
1003 |
} |
869 |
} |
1004 |
} |
870 |
return node; |
1005 |
return node; |
871 |
} |
1006 |
} |
872 |
|
|
|
873 |
|
1007 |
|
874 |
private String openNode(AntElementNode node) { |
1008 |
private String openNode(AntElementNode node) { |
875 |
String errorMessage= null; |
1009 |
String errorMessage = null; |
876 |
if (node.isExternal()) { |
1010 |
if (node.isExternal()) { |
877 |
String path= node.getFilePath(); |
1011 |
String path = node.getFilePath(); |
878 |
errorMessage= openInEditor(path, null); |
1012 |
errorMessage = openInEditor(path, null); |
879 |
} else { |
1013 |
} else { |
880 |
setSelection(node, true); |
1014 |
setSelection(node, true); |
881 |
} |
1015 |
} |
882 |
return errorMessage; |
1016 |
return errorMessage; |
883 |
} |
1017 |
} |
884 |
|
1018 |
|
885 |
private String openInEditor(String path, File buildFile) { |
1019 |
private String openInEditor(String path, File buildFile) { |
886 |
File buildFileParent= null; |
1020 |
File buildFileParent = null; |
887 |
if (buildFile != null) { |
1021 |
if (buildFile != null) { |
888 |
buildFileParent= buildFile.getParentFile(); |
1022 |
buildFileParent = buildFile.getParentFile(); |
889 |
} |
1023 |
} |
890 |
IFile file= AntUtil.getFileForLocation(path, buildFileParent); |
1024 |
IFile file = AntUtil.getFileForLocation(path, buildFileParent); |
891 |
if (file != null && file.exists()) { |
1025 |
if (file != null && file.exists()) { |
892 |
try { |
1026 |
try { |
893 |
IWorkbenchPage p= getEditorSite().getPage(); |
1027 |
IWorkbenchPage p = getEditorSite().getPage(); |
894 |
if (p != null) { |
1028 |
if (p != null) { |
895 |
IDE.openEditor(p, file, isActivePart()); |
1029 |
IDE.openEditor(p, file, isActivePart()); |
896 |
} |
1030 |
} |
Lines 899-974
Link Here
|
899 |
return e.getLocalizedMessage(); |
1033 |
return e.getLocalizedMessage(); |
900 |
} |
1034 |
} |
901 |
} |
1035 |
} |
902 |
File externalFile= new File(path); |
1036 |
File externalFile = new File(path); |
903 |
if (externalFile.exists()) { |
1037 |
if (externalFile.exists()) { |
904 |
new ExternalHyperlink(externalFile, -1).linkActivated(); |
1038 |
new ExternalHyperlink(externalFile, -1).linkActivated(); |
905 |
return null; |
1039 |
return null; |
906 |
} |
1040 |
} |
907 |
|
1041 |
|
908 |
return ""; //$NON-NLS-1$ |
1042 |
return ""; //$NON-NLS-1$ |
909 |
} |
1043 |
} |
910 |
|
1044 |
|
911 |
/* (non-Javadoc) |
1045 |
/* |
|
|
1046 |
* (non-Javadoc) |
1047 |
* |
912 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) |
1048 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) |
913 |
*/ |
1049 |
*/ |
914 |
public void editorContextMenuAboutToShow(IMenuManager menu) { |
1050 |
public void editorContextMenuAboutToShow(IMenuManager menu) { |
915 |
super.editorContextMenuAboutToShow(menu); |
1051 |
super.editorContextMenuAboutToShow(menu); |
916 |
|
1052 |
|
917 |
if (getAntModel() != null) { |
1053 |
if (getAntModel() != null) { |
918 |
IAction action= getAction("OpenDeclaration"); //$NON-NLS-1$ |
1054 |
IAction action = getAction("OpenDeclaration"); //$NON-NLS-1$ |
919 |
if (action != null) { |
1055 |
if (action != null) { |
920 |
String openGroup = "group.open"; //$NON-NLS-1$ |
1056 |
String openGroup = "group.open"; //$NON-NLS-1$ |
921 |
menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, new Separator(openGroup)); |
1057 |
menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, |
|
|
1058 |
new Separator(openGroup)); |
922 |
menu.appendToGroup(openGroup, action); |
1059 |
menu.appendToGroup(openGroup, action); |
923 |
} |
1060 |
} |
924 |
|
1061 |
|
925 |
action= getAction("renameInFile"); //$NON-NLS-1$ |
1062 |
action = getAction("renameInFile"); //$NON-NLS-1$ |
926 |
String editGroup = "group.edit"; //$NON-NLS-1$ |
1063 |
String editGroup = "group.edit"; //$NON-NLS-1$ |
927 |
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, new Separator(editGroup)); |
1064 |
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, |
|
|
1065 |
new Separator(editGroup)); |
928 |
menu.appendToGroup(editGroup, action); |
1066 |
menu.appendToGroup(editGroup, action); |
929 |
|
1067 |
|
930 |
action= getAction("ContentFormat"); //$NON-NLS-1$ |
1068 |
action = getAction("ContentFormat"); //$NON-NLS-1$ |
931 |
menu.appendToGroup(editGroup, action); |
1069 |
menu.appendToGroup(editGroup, action); |
932 |
} |
1070 |
} |
933 |
} |
1071 |
} |
934 |
|
1072 |
|
935 |
/* (non-Javadoc) |
1073 |
/* |
|
|
1074 |
* (non-Javadoc) |
1075 |
* |
936 |
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
1076 |
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
937 |
*/ |
1077 |
*/ |
938 |
public void createPartControl(Composite parent) { |
1078 |
public void createPartControl(Composite parent) { |
939 |
super.createPartControl(parent); |
1079 |
super.createPartControl(parent); |
940 |
|
1080 |
|
941 |
ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer(); |
1081 |
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); |
942 |
createFoldingSupport(projectionViewer); |
1082 |
createFoldingSupport(projectionViewer); |
943 |
if (isFoldingEnabled()) { |
1083 |
if (isFoldingEnabled()) { |
944 |
projectionViewer.doOperation(ProjectionViewer.TOGGLE); |
1084 |
projectionViewer.doOperation(ProjectionViewer.TOGGLE); |
945 |
} |
1085 |
} |
946 |
|
1086 |
|
947 |
if (fMarkOccurrenceAnnotations) { |
1087 |
if (fMarkOccurrenceAnnotations) { |
948 |
installOccurrencesFinder(); |
1088 |
installOccurrencesFinder(); |
949 |
} |
1089 |
} |
950 |
getEditorSite().getShell().addShellListener(fActivationListener); |
1090 |
getEditorSite().getShell().addShellListener(fActivationListener); |
951 |
|
1091 |
|
952 |
fEditorSelectionChangedListener= new EditorSelectionChangedListener(); |
1092 |
fEditorSelectionChangedListener = new EditorSelectionChangedListener(); |
953 |
fEditorSelectionChangedListener.install(getSelectionProvider()); |
1093 |
fEditorSelectionChangedListener.install(getSelectionProvider()); |
954 |
} |
1094 |
} |
955 |
|
1095 |
|
956 |
private void createFoldingSupport(ProjectionViewer projectionViewer) { |
1096 |
private void createFoldingSupport(ProjectionViewer projectionViewer) { |
957 |
fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); |
1097 |
fProjectionSupport = new ProjectionSupport(projectionViewer, |
958 |
fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { |
1098 |
getAnnotationAccess(), getSharedColors()); |
959 |
public IInformationControl createInformationControl(Shell shell) { |
1099 |
fProjectionSupport |
960 |
return new AntSourceViewerInformationControl(shell); |
1100 |
.setHoverControlCreator(new IInformationControlCreator() { |
961 |
} |
1101 |
public IInformationControl createInformationControl( |
962 |
}); |
1102 |
Shell shell) { |
963 |
fProjectionSupport.install(); |
1103 |
return new AntSourceViewerInformationControl(shell); |
964 |
((ProjectionViewer)getViewer()).addProjectionListener(this); |
1104 |
} |
965 |
|
1105 |
}); |
966 |
} |
1106 |
fProjectionSupport.install(); |
|
|
1107 |
((ProjectionViewer) getViewer()).addProjectionListener(this); |
967 |
|
1108 |
|
|
|
1109 |
} |
968 |
|
1110 |
|
969 |
private boolean isFoldingEnabled() { |
1111 |
private boolean isFoldingEnabled() { |
970 |
IPreferenceStore store= getPreferenceStore(); |
1112 |
IPreferenceStore store = getPreferenceStore(); |
971 |
return store.getBoolean(AntEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); |
1113 |
return store |
|
|
1114 |
.getBoolean(AntEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); |
972 |
} |
1115 |
} |
973 |
|
1116 |
|
974 |
/* |
1117 |
/* |
Lines 976-1090
Link Here
|
976 |
* @since 3.3 |
1119 |
* @since 3.3 |
977 |
*/ |
1120 |
*/ |
978 |
protected boolean isTabsToSpacesConversionEnabled() { |
1121 |
protected boolean isTabsToSpacesConversionEnabled() { |
979 |
return super.isTabsToSpacesConversionEnabled(); //provide package visibility |
1122 |
return super.isTabsToSpacesConversionEnabled(); // provide package |
|
|
1123 |
// visibility |
980 |
} |
1124 |
} |
981 |
|
1125 |
|
982 |
/* (non-Javadoc) |
1126 |
/* |
|
|
1127 |
* (non-Javadoc) |
1128 |
* |
983 |
* @see org.eclipse.ui.IWorkbenchPart#dispose() |
1129 |
* @see org.eclipse.ui.IWorkbenchPart#dispose() |
984 |
*/ |
1130 |
*/ |
985 |
public void dispose() { |
1131 |
public void dispose() { |
986 |
if (fEditorSelectionChangedListener != null) { |
1132 |
if (fEditorSelectionChangedListener != null) { |
987 |
fEditorSelectionChangedListener.uninstall(getSelectionProvider()); |
1133 |
fEditorSelectionChangedListener.uninstall(getSelectionProvider()); |
988 |
fEditorSelectionChangedListener= null; |
1134 |
fEditorSelectionChangedListener = null; |
989 |
} |
1135 |
} |
990 |
|
1136 |
|
991 |
((ProjectionViewer)getViewer()).removeProjectionListener(this); |
1137 |
((ProjectionViewer) getViewer()).removeProjectionListener(this); |
992 |
if (fProjectionSupport != null) { |
1138 |
if (fProjectionSupport != null) { |
993 |
fProjectionSupport.dispose(); |
1139 |
fProjectionSupport.dispose(); |
994 |
fProjectionSupport= null; |
1140 |
fProjectionSupport = null; |
995 |
} |
1141 |
} |
996 |
|
1142 |
|
997 |
uninstallOccurrencesFinder(); |
1143 |
uninstallOccurrencesFinder(); |
998 |
|
1144 |
|
999 |
if (fActivationListener != null) { |
1145 |
if (fActivationListener != null) { |
1000 |
Shell shell= getEditorSite().getShell(); |
1146 |
Shell shell = getEditorSite().getShell(); |
1001 |
if (shell != null && !shell.isDisposed()) { |
1147 |
if (shell != null && !shell.isDisposed()) { |
1002 |
shell.removeShellListener(fActivationListener); |
1148 |
shell.removeShellListener(fActivationListener); |
1003 |
} |
1149 |
} |
1004 |
fActivationListener= null; |
1150 |
fActivationListener = null; |
1005 |
} |
1151 |
} |
1006 |
|
1152 |
|
1007 |
AntModelCore.getDefault().removeAntModelListener(fAntModelListener); |
1153 |
AntModelCore.getDefault().removeAntModelListener(fAntModelListener); |
1008 |
fAntModel= null; |
1154 |
fAntModel = null; |
1009 |
super.dispose(); |
1155 |
super.dispose(); |
1010 |
} |
1156 |
} |
1011 |
|
1157 |
|
1012 |
/* (non-Javadoc) |
1158 |
/* |
|
|
1159 |
* (non-Javadoc) |
1160 |
* |
1013 |
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
1161 |
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
1014 |
*/ |
1162 |
*/ |
1015 |
public void doSave(IProgressMonitor monitor) { |
1163 |
public void doSave(IProgressMonitor monitor) { |
1016 |
super.doSave(monitor); |
1164 |
super.doSave(monitor); |
1017 |
AntModel model= getAntModel(); |
1165 |
AntModel model = getAntModel(); |
1018 |
model.updateMarkers(); |
1166 |
model.updateMarkers(); |
1019 |
updateEditorImage(model); |
1167 |
updateEditorImage(model); |
1020 |
} |
1168 |
} |
1021 |
|
1169 |
|
1022 |
private void updateEditorImage(AntModel model) { |
1170 |
private void updateEditorImage(AntModel model) { |
1023 |
Image titleImage= getTitleImage(); |
1171 |
Image titleImage = getTitleImage(); |
1024 |
if (titleImage == null) { |
1172 |
if (titleImage == null) { |
1025 |
return; |
1173 |
return; |
1026 |
} |
1174 |
} |
1027 |
AntProjectNode node= model.getProjectNode(); |
1175 |
AntProjectNode node = model.getProjectNode(); |
1028 |
if (node != null) { |
1176 |
if (node != null) { |
1029 |
postImageChange(node); |
1177 |
postImageChange(node); |
1030 |
} |
1178 |
} |
1031 |
} |
1179 |
} |
1032 |
|
1180 |
|
1033 |
private void updateForInitialReconcile() { |
1181 |
private void updateForInitialReconcile() { |
1034 |
IDocumentProvider provider= getDocumentProvider(); |
1182 |
IDocumentProvider provider = getDocumentProvider(); |
1035 |
if (provider == null) {//disposed |
1183 |
if (provider == null) {// disposed |
1036 |
return; |
1184 |
return; |
1037 |
} |
1185 |
} |
1038 |
if (getAntModel() == null) { |
1186 |
if (getAntModel() == null) { |
1039 |
return; |
1187 |
return; |
1040 |
} |
1188 |
} |
1041 |
IDocument doc= provider.getDocument(getEditorInput()); |
1189 |
IDocument doc = provider.getDocument(getEditorInput()); |
1042 |
if (doc == null) { |
1190 |
if (doc == null) { |
1043 |
return; //disposed |
1191 |
return; // disposed |
1044 |
} |
1192 |
} |
1045 |
Object lock= getLockObject(doc); |
1193 |
Object lock = getLockObject(doc); |
1046 |
//ensure to synchronize so that the AntModel is not nulled out underneath in the AntEditorDocumentProvider |
1194 |
// ensure to synchronize so that the AntModel is not nulled out |
1047 |
//when the editor/doc provider are disposed |
1195 |
// underneath in the AntEditorDocumentProvider |
1048 |
if (lock == null) { |
1196 |
// when the editor/doc provider are disposed |
1049 |
updateModelForInitialReconcile(); |
1197 |
if (lock == null) { |
1050 |
} else { |
1198 |
updateModelForInitialReconcile(); |
1051 |
synchronized (lock) { |
1199 |
} else { |
1052 |
updateModelForInitialReconcile(); |
1200 |
synchronized (lock) { |
1053 |
} |
1201 |
updateModelForInitialReconcile(); |
1054 |
} |
1202 |
} |
1055 |
} |
1203 |
} |
1056 |
|
1204 |
} |
1057 |
private void updateModelForInitialReconcile() { |
1205 |
|
1058 |
AntModel model= getAntModel(); |
1206 |
private void updateModelForInitialReconcile() { |
1059 |
if (model == null) { |
1207 |
AntModel model = getAntModel(); |
1060 |
return; |
1208 |
if (model == null) { |
1061 |
} |
1209 |
return; |
1062 |
|
1210 |
} |
1063 |
fInitialReconcile= false; |
1211 |
|
1064 |
updateEditorImage(model); |
1212 |
fInitialReconcile = false; |
1065 |
model.updateForInitialReconcile(); |
1213 |
updateEditorImage(model); |
1066 |
} |
1214 |
model.updateForInitialReconcile(); |
1067 |
|
1215 |
} |
1068 |
private Object getLockObject(IDocument doc) { |
1216 |
|
1069 |
Object lock= null; |
1217 |
private Object getLockObject(IDocument doc) { |
1070 |
if (doc instanceof ISynchronizable) { |
1218 |
Object lock = null; |
1071 |
lock= ((ISynchronizable) doc).getLockObject(); |
1219 |
if (doc instanceof ISynchronizable) { |
1072 |
} else { |
1220 |
lock = ((ISynchronizable) doc).getLockObject(); |
1073 |
lock= getAntModel(); |
1221 |
} else { |
1074 |
} |
1222 |
lock = getAntModel(); |
1075 |
return lock; |
1223 |
} |
1076 |
} |
1224 |
return lock; |
1077 |
|
1225 |
} |
|
|
1226 |
|
1078 |
private void postImageChange(final AntElementNode node) { |
1227 |
private void postImageChange(final AntElementNode node) { |
1079 |
Shell shell= getSite().getShell(); |
1228 |
Shell shell = getSite().getShell(); |
1080 |
if (shell != null && !shell.isDisposed()) { |
1229 |
if (shell != null && !shell.isDisposed()) { |
1081 |
shell.getDisplay().asyncExec(new Runnable() { |
1230 |
shell.getDisplay().asyncExec(new Runnable() { |
1082 |
public void run() { |
1231 |
public void run() { |
1083 |
if (getSite().getShell() == null || getSite().getShell().isDisposed()) { |
1232 |
if (getSite().getShell() == null |
|
|
1233 |
|| getSite().getShell().isDisposed()) { |
1084 |
return; |
1234 |
return; |
1085 |
} |
1235 |
} |
1086 |
Image titleImage= getTitleImage(); |
1236 |
Image titleImage = getTitleImage(); |
1087 |
Image newImage= node.getImage(); |
1237 |
Image newImage = node.getImage(); |
1088 |
if (titleImage != newImage) { |
1238 |
if (titleImage != newImage) { |
1089 |
setTitleImage(newImage); |
1239 |
setTitleImage(newImage); |
1090 |
} |
1240 |
} |
Lines 1097-1167
Link Here
|
1097 |
if (getSelectionProvider() == null) { |
1247 |
if (getSelectionProvider() == null) { |
1098 |
return; |
1248 |
return; |
1099 |
} |
1249 |
} |
1100 |
AntElementNode node= getNode(); |
1250 |
AntElementNode node = getNode(); |
1101 |
synchronizeOutlinePage(node, checkIfOutlinePageActive); |
1251 |
synchronizeOutlinePage(node, checkIfOutlinePageActive); |
1102 |
|
1252 |
|
1103 |
} |
1253 |
} |
1104 |
|
1254 |
|
1105 |
protected void synchronize(boolean checkIfOutlinePageActive) { |
1255 |
protected void synchronize(boolean checkIfOutlinePageActive) { |
1106 |
if (getSelectionProvider() == null) { |
1256 |
if (getSelectionProvider() == null) { |
1107 |
return; |
1257 |
return; |
1108 |
} |
1258 |
} |
1109 |
AntElementNode node= getNode(); |
1259 |
AntElementNode node = getNode(); |
1110 |
if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) { |
1260 |
if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean( |
|
|
1261 |
IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) { |
1111 |
synchronizeOutlinePage(node, checkIfOutlinePageActive); |
1262 |
synchronizeOutlinePage(node, checkIfOutlinePageActive); |
1112 |
} |
1263 |
} |
1113 |
setSelection(node, false); |
1264 |
setSelection(node, false); |
1114 |
|
1265 |
|
1115 |
} |
1266 |
} |
1116 |
|
1267 |
|
1117 |
private AntElementNode getNode() { |
1268 |
private AntElementNode getNode() { |
1118 |
AntModel model= getAntModel(); |
1269 |
AntModel model = getAntModel(); |
1119 |
if (model == null) { |
1270 |
if (model == null) { |
1120 |
return null; |
1271 |
return null; |
1121 |
} |
1272 |
} |
1122 |
AntElementNode node= null; |
1273 |
AntElementNode node = null; |
1123 |
ISelection selection= getSelectionProvider().getSelection(); |
1274 |
ISelection selection = getSelectionProvider().getSelection(); |
1124 |
if (selection instanceof ITextSelection) { |
1275 |
if (selection instanceof ITextSelection) { |
1125 |
ITextSelection textSelection= (ITextSelection)selection; |
1276 |
ITextSelection textSelection = (ITextSelection) selection; |
1126 |
int offset= textSelection.getOffset(); |
1277 |
int offset = textSelection.getOffset(); |
1127 |
node= model.getNode(offset, false); |
1278 |
node = model.getNode(offset, false); |
1128 |
} |
1279 |
} |
1129 |
return node; |
1280 |
return node; |
1130 |
} |
1281 |
} |
1131 |
|
1282 |
|
1132 |
protected void synchronizeOutlinePage(AntElementNode node, boolean checkIfOutlinePageActive) { |
1283 |
protected void synchronizeOutlinePage(AntElementNode node, |
1133 |
if (fOutlinePage != null && !(checkIfOutlinePageActive && isAntOutlinePageActive())) { |
1284 |
boolean checkIfOutlinePageActive) { |
1134 |
fOutlinePage.removePostSelectionChangedListener(fSelectionChangedListener); |
1285 |
if (fOutlinePage != null |
|
|
1286 |
&& !(checkIfOutlinePageActive && isAntOutlinePageActive())) { |
1287 |
fOutlinePage |
1288 |
.removePostSelectionChangedListener(fSelectionChangedListener); |
1135 |
fOutlinePage.select(node); |
1289 |
fOutlinePage.select(node); |
1136 |
fOutlinePage.addPostSelectionChangedListener(fSelectionChangedListener); |
1290 |
fOutlinePage |
|
|
1291 |
.addPostSelectionChangedListener(fSelectionChangedListener); |
1137 |
} |
1292 |
} |
1138 |
} |
1293 |
} |
1139 |
|
1294 |
|
1140 |
/* (non-Javadoc) |
1295 |
/* |
|
|
1296 |
* (non-Javadoc) |
1297 |
* |
1141 |
* @see org.eclipse.ant.internal.ui.editor.text.IReconcilingParticipant#reconciled() |
1298 |
* @see org.eclipse.ant.internal.ui.editor.text.IReconcilingParticipant#reconciled() |
1142 |
*/ |
1299 |
*/ |
1143 |
public void reconciled() { |
1300 |
public void reconciled() { |
1144 |
if (fInitialReconcile) { |
1301 |
if (fInitialReconcile) { |
1145 |
updateForInitialReconcile(); |
1302 |
updateForInitialReconcile(); |
1146 |
} |
1303 |
} |
1147 |
|
1304 |
|
1148 |
SourceViewerConfiguration config= getSourceViewerConfiguration(); |
1305 |
SourceViewerConfiguration config = getSourceViewerConfiguration(); |
1149 |
if (config == null) { |
1306 |
if (config == null) { |
1150 |
return; //editor has been disposed. |
1307 |
return; // editor has been disposed. |
1151 |
} |
1308 |
} |
1152 |
IAutoEditStrategy[] strategies= config.getAutoEditStrategies(getViewer(), null); |
1309 |
IAutoEditStrategy[] strategies = config.getAutoEditStrategies( |
|
|
1310 |
getViewer(), null); |
1153 |
for (int i = 0; i < strategies.length; i++) { |
1311 |
for (int i = 0; i < strategies.length; i++) { |
1154 |
IAutoEditStrategy strategy = strategies[i]; |
1312 |
IAutoEditStrategy strategy = strategies[i]; |
1155 |
if (strategy instanceof AntAutoEditStrategy) { |
1313 |
if (strategy instanceof AntAutoEditStrategy) { |
1156 |
((AntAutoEditStrategy)strategy).reconciled(); |
1314 |
((AntAutoEditStrategy) strategy).reconciled(); |
1157 |
} |
1315 |
} |
1158 |
} |
1316 |
} |
1159 |
|
1317 |
|
1160 |
Shell shell= getSite().getShell(); |
1318 |
Shell shell = getSite().getShell(); |
1161 |
if (shell != null && !shell.isDisposed()) { |
1319 |
if (shell != null && !shell.isDisposed()) { |
1162 |
shell.getDisplay().asyncExec(new Runnable() { |
1320 |
shell.getDisplay().asyncExec(new Runnable() { |
1163 |
public void run() { |
1321 |
public void run() { |
1164 |
if (getSite().getShell() == null || getSite().getShell().isDisposed()) { |
1322 |
if (getSite().getShell() == null |
|
|
1323 |
|| getSite().getShell().isDisposed()) { |
1165 |
return; |
1324 |
return; |
1166 |
} |
1325 |
} |
1167 |
synchronize(true); |
1326 |
synchronize(true); |
Lines 1169-1187
Link Here
|
1169 |
}); |
1328 |
}); |
1170 |
} |
1329 |
} |
1171 |
} |
1330 |
} |
1172 |
|
1331 |
|
1173 |
private boolean isAntOutlinePageActive() { |
1332 |
private boolean isAntOutlinePageActive() { |
1174 |
IWorkbenchPart part= getActivePart(); |
1333 |
IWorkbenchPart part = getActivePart(); |
1175 |
return part instanceof ContentOutline && ((ContentOutline)part).getCurrentPage() == fOutlinePage; |
1334 |
return part instanceof ContentOutline |
|
|
1335 |
&& ((ContentOutline) part).getCurrentPage() == fOutlinePage; |
1176 |
} |
1336 |
} |
1177 |
|
1337 |
|
1178 |
private IWorkbenchPart getActivePart() { |
1338 |
private IWorkbenchPart getActivePart() { |
1179 |
IWorkbenchWindow window= getSite().getWorkbenchWindow(); |
1339 |
IWorkbenchWindow window = getSite().getWorkbenchWindow(); |
1180 |
IPartService service= window.getPartService(); |
1340 |
IPartService service = window.getPartService(); |
1181 |
return service.getActivePart(); |
1341 |
return service.getActivePart(); |
1182 |
} |
1342 |
} |
1183 |
|
1343 |
|
1184 |
/* (non-Javadoc) |
1344 |
/* |
|
|
1345 |
* (non-Javadoc) |
1346 |
* |
1185 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetSelection(org.eclipse.jface.viewers.ISelection) |
1347 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetSelection(org.eclipse.jface.viewers.ISelection) |
1186 |
*/ |
1348 |
*/ |
1187 |
protected void doSetSelection(ISelection selection) { |
1349 |
protected void doSetSelection(ISelection selection) { |
Lines 1189-1259
Link Here
|
1189 |
synchronizeOutlinePage(true); |
1351 |
synchronizeOutlinePage(true); |
1190 |
} |
1352 |
} |
1191 |
|
1353 |
|
1192 |
/** |
1354 |
/** |
1193 |
* Returns the viewer associated with this editor |
1355 |
* Returns the viewer associated with this editor |
1194 |
* @return The viewer associated with this editor |
1356 |
* |
1195 |
*/ |
1357 |
* @return The viewer associated with this editor |
1196 |
public ISourceViewer getViewer() { |
1358 |
*/ |
1197 |
return getSourceViewer(); |
1359 |
public ISourceViewer getViewer() { |
1198 |
} |
1360 |
return getSourceViewer(); |
1199 |
|
1361 |
} |
1200 |
protected FoldingActionGroup getFoldingActionGroup() { |
1362 |
|
1201 |
return fFoldingGroup; |
1363 |
protected FoldingActionGroup getFoldingActionGroup() { |
1202 |
} |
1364 |
return fFoldingGroup; |
1203 |
|
1365 |
} |
1204 |
/* (non-Javadoc) |
1366 |
|
1205 |
* @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionEnabled() |
1367 |
/* |
1206 |
*/ |
1368 |
* (non-Javadoc) |
1207 |
public void projectionEnabled() { |
1369 |
* |
1208 |
fFoldingStructureProvider= new AntFoldingStructureProvider(this); |
1370 |
* @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionEnabled() |
1209 |
fFoldingStructureProvider.setDocument(getDocumentProvider().getDocument(getEditorInput())); |
1371 |
*/ |
|
|
1372 |
public void projectionEnabled() { |
1373 |
fFoldingStructureProvider = new AntFoldingStructureProvider(this); |
1374 |
fFoldingStructureProvider.setDocument(getDocumentProvider() |
1375 |
.getDocument(getEditorInput())); |
1210 |
fFoldingStructureProvider.updateFoldingRegions(getAntModel()); |
1376 |
fFoldingStructureProvider.updateFoldingRegions(getAntModel()); |
1211 |
} |
1377 |
} |
1212 |
|
1378 |
|
1213 |
/* (non-Javadoc) |
1379 |
/* |
1214 |
* @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionDisabled() |
1380 |
* (non-Javadoc) |
1215 |
*/ |
1381 |
* |
1216 |
public void projectionDisabled() { |
1382 |
* @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionDisabled() |
1217 |
fFoldingStructureProvider= null; |
1383 |
*/ |
1218 |
} |
1384 |
public void projectionDisabled() { |
1219 |
|
1385 |
fFoldingStructureProvider = null; |
1220 |
/* (non-Javadoc) |
1386 |
} |
|
|
1387 |
|
1388 |
/* |
1389 |
* (non-Javadoc) |
1390 |
* |
1221 |
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeKeyBindingScopes() |
1391 |
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeKeyBindingScopes() |
1222 |
*/ |
1392 |
*/ |
1223 |
protected void initializeKeyBindingScopes() { |
1393 |
protected void initializeKeyBindingScopes() { |
1224 |
setKeyBindingScopes(new String[] { "org.eclipse.ant.ui.AntEditorScope" }); //$NON-NLS-1$ |
1394 |
setKeyBindingScopes(new String[] { "org.eclipse.ant.ui.AntEditorScope" }); //$NON-NLS-1$ |
1225 |
} |
1395 |
} |
1226 |
|
1396 |
|
1227 |
protected IPreferenceStore getEditorPreferenceStore() { |
1397 |
protected IPreferenceStore getEditorPreferenceStore() { |
1228 |
return getPreferenceStore(); |
1398 |
return getPreferenceStore(); |
1229 |
} |
1399 |
} |
1230 |
|
1400 |
|
1231 |
/* (non-Javadoc) |
1401 |
/* |
|
|
1402 |
* (non-Javadoc) |
1403 |
* |
1232 |
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages() |
1404 |
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages() |
1233 |
* @since 3.1 |
1405 |
* @since 3.1 |
1234 |
*/ |
1406 |
*/ |
1235 |
protected String[] collectContextMenuPreferencePages() { |
1407 |
protected String[] collectContextMenuPreferencePages() { |
1236 |
String[] ids= super.collectContextMenuPreferencePages(); |
1408 |
String[] ids = super.collectContextMenuPreferencePages(); |
1237 |
String[] more= new String[ids.length + 6]; |
1409 |
String[] more = new String[ids.length + 6]; |
1238 |
more[0]= "org.eclipse.ant.ui.AntEditorPreferencePage"; //$NON-NLS-1$ |
1410 |
more[0] = "org.eclipse.ant.ui.AntEditorPreferencePage"; //$NON-NLS-1$ |
1239 |
more[1]= "org.eclipse.ant.ui.AntCodeFormatterPreferencePage"; //$NON-NLS-1$ |
1411 |
more[1] = "org.eclipse.ant.ui.AntCodeFormatterPreferencePage"; //$NON-NLS-1$ |
1240 |
more[2]= "org.eclipse.ant.ui.AntCodeAssistPreferencePage"; //$NON-NLS-1$ |
1412 |
more[2] = "org.eclipse.ant.ui.AntCodeAssistPreferencePage"; //$NON-NLS-1$ |
1241 |
more[3]= "org.eclipse.ant.ui.TemplatesPreferencePage"; //$NON-NLS-1$ |
1413 |
more[3] = "org.eclipse.ant.ui.TemplatesPreferencePage"; //$NON-NLS-1$ |
1242 |
more[4]= "org.eclipse.ant.ui.AntPreferencePage"; //$NON-NLS-1$ |
1414 |
more[4] = "org.eclipse.ant.ui.AntPreferencePage"; //$NON-NLS-1$ |
1243 |
more[5]= "org.eclipse.ant.ui.AntRuntimePreferencePage"; //$NON-NLS-1$ |
1415 |
more[5] = "org.eclipse.ant.ui.AntRuntimePreferencePage"; //$NON-NLS-1$ |
1244 |
System.arraycopy(ids, 0, more, 6, ids.length); |
1416 |
System.arraycopy(ids, 0, more, 6, ids.length); |
1245 |
return more; |
1417 |
return more; |
1246 |
} |
1418 |
} |
1247 |
|
1419 |
|
1248 |
/** |
1420 |
/** |
1249 |
* Updates the occurrences annotations based |
1421 |
* Updates the occurrences annotations based on the current selection. |
1250 |
* on the current selection. |
|
|
1251 |
* |
1422 |
* |
1252 |
* @param selection the text selection |
1423 |
* @param selection |
1253 |
* @param antModel the model for the buildfile |
1424 |
* the text selection |
|
|
1425 |
* @param antModel |
1426 |
* the model for the buildfile |
1254 |
* @since 3.1 |
1427 |
* @since 3.1 |
1255 |
*/ |
1428 |
*/ |
1256 |
protected void updateOccurrenceAnnotations(ITextSelection selection, AntModel antModel) { |
1429 |
protected void updateOccurrenceAnnotations(ITextSelection selection, |
|
|
1430 |
AntModel antModel) { |
1257 |
|
1431 |
|
1258 |
if (fOccurrencesFinderJob != null) |
1432 |
if (fOccurrencesFinderJob != null) |
1259 |
fOccurrencesFinderJob.cancel(); |
1433 |
fOccurrencesFinderJob.cancel(); |
Lines 1261-1367
Link Here
|
1261 |
if (!fMarkOccurrenceAnnotations) { |
1435 |
if (!fMarkOccurrenceAnnotations) { |
1262 |
return; |
1436 |
return; |
1263 |
} |
1437 |
} |
1264 |
|
1438 |
|
1265 |
if (selection == null || antModel == null) { |
1439 |
if (selection == null || antModel == null) { |
1266 |
return; |
1440 |
return; |
1267 |
} |
1441 |
} |
1268 |
|
1442 |
|
1269 |
IDocument document= getSourceViewer().getDocument(); |
1443 |
IDocument document = getSourceViewer().getDocument(); |
1270 |
if (document == null) { |
1444 |
if (document == null) { |
1271 |
return; |
1445 |
return; |
1272 |
} |
1446 |
} |
1273 |
|
1447 |
|
1274 |
List positions= null; |
1448 |
List positions = null; |
1275 |
|
1449 |
|
1276 |
OccurrencesFinder finder= new OccurrencesFinder(this, antModel, document, selection.getOffset()); |
1450 |
OccurrencesFinder finder = new OccurrencesFinder(this, antModel, |
1277 |
positions= finder.perform(); |
1451 |
document, selection.getOffset()); |
1278 |
|
1452 |
positions = finder.perform(); |
|
|
1453 |
|
1279 |
if (positions == null || positions.size() == 0) { |
1454 |
if (positions == null || positions.size() == 0) { |
1280 |
if (!fStickyOccurrenceAnnotations) { |
1455 |
if (!fStickyOccurrenceAnnotations) { |
1281 |
removeOccurrenceAnnotations(); |
1456 |
removeOccurrenceAnnotations(); |
1282 |
} |
1457 |
} |
1283 |
return; |
1458 |
return; |
1284 |
} |
1459 |
} |
1285 |
|
1460 |
|
1286 |
fOccurrencesFinderJob= new OccurrencesFinderJob(document, positions, selection); |
1461 |
fOccurrencesFinderJob = new OccurrencesFinderJob(document, positions, |
|
|
1462 |
selection); |
1287 |
fOccurrencesFinderJob.run(new NullProgressMonitor()); |
1463 |
fOccurrencesFinderJob.run(new NullProgressMonitor()); |
1288 |
} |
1464 |
} |
1289 |
|
1465 |
|
1290 |
private void removeOccurrenceAnnotations() { |
1466 |
private void removeOccurrenceAnnotations() { |
1291 |
IDocumentProvider documentProvider= getDocumentProvider(); |
1467 |
IDocumentProvider documentProvider = getDocumentProvider(); |
1292 |
if (documentProvider == null) { |
1468 |
if (documentProvider == null) { |
1293 |
return; |
1469 |
return; |
1294 |
} |
1470 |
} |
1295 |
|
1471 |
|
1296 |
IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); |
1472 |
IAnnotationModel annotationModel = documentProvider |
|
|
1473 |
.getAnnotationModel(getEditorInput()); |
1297 |
if (annotationModel == null || fOccurrenceAnnotations == null) { |
1474 |
if (annotationModel == null || fOccurrenceAnnotations == null) { |
1298 |
return; |
1475 |
return; |
1299 |
} |
1476 |
} |
1300 |
|
1477 |
|
1301 |
IDocument document= documentProvider.getDocument(getEditorInput()); |
1478 |
IDocument document = documentProvider.getDocument(getEditorInput()); |
1302 |
Object lock= getLockObject(document); |
1479 |
Object lock = getLockObject(document); |
1303 |
if (lock == null) { |
1480 |
if (lock == null) { |
1304 |
updateAnnotationModelForRemoves(annotationModel); |
1481 |
updateAnnotationModelForRemoves(annotationModel); |
1305 |
} else { |
1482 |
} else { |
1306 |
synchronized (lock) { |
1483 |
synchronized (lock) { |
1307 |
updateAnnotationModelForRemoves(annotationModel); |
1484 |
updateAnnotationModelForRemoves(annotationModel); |
1308 |
} |
1485 |
} |
1309 |
} |
1486 |
} |
1310 |
} |
1487 |
} |
1311 |
|
1488 |
|
1312 |
|
1489 |
private void updateAnnotationModelForRemoves( |
1313 |
private void updateAnnotationModelForRemoves(IAnnotationModel annotationModel) { |
1490 |
IAnnotationModel annotationModel) { |
1314 |
if (annotationModel instanceof IAnnotationModelExtension) { |
1491 |
if (annotationModel instanceof IAnnotationModelExtension) { |
1315 |
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); |
1492 |
((IAnnotationModelExtension) annotationModel).replaceAnnotations( |
1316 |
} else { |
1493 |
fOccurrenceAnnotations, null); |
1317 |
for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) { |
1494 |
} else { |
1318 |
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); |
1495 |
for (int i = 0, length = fOccurrenceAnnotations.length; i < length; i++) { |
1319 |
} |
1496 |
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); |
1320 |
} |
1497 |
} |
1321 |
fOccurrenceAnnotations= null; |
1498 |
} |
1322 |
} |
1499 |
fOccurrenceAnnotations = null; |
|
|
1500 |
} |
1323 |
|
1501 |
|
1324 |
protected void installOccurrencesFinder() { |
1502 |
protected void installOccurrencesFinder() { |
1325 |
fMarkOccurrenceAnnotations= true; |
1503 |
fMarkOccurrenceAnnotations = true; |
1326 |
|
1504 |
|
1327 |
if (getSelectionProvider() != null) { |
1505 |
if (getSelectionProvider() != null) { |
1328 |
ISelection selection= getSelectionProvider().getSelection(); |
1506 |
ISelection selection = getSelectionProvider().getSelection(); |
1329 |
if (selection instanceof ITextSelection) { |
1507 |
if (selection instanceof ITextSelection) { |
1330 |
fForcedMarkOccurrencesSelection= (ITextSelection) selection; |
1508 |
fForcedMarkOccurrencesSelection = (ITextSelection) selection; |
1331 |
updateOccurrenceAnnotations(fForcedMarkOccurrencesSelection, getAntModel()); |
1509 |
updateOccurrenceAnnotations(fForcedMarkOccurrencesSelection, |
|
|
1510 |
getAntModel()); |
1332 |
} |
1511 |
} |
1333 |
} |
1512 |
} |
1334 |
if (fOccurrencesFinderJobCanceler == null) { |
1513 |
if (fOccurrencesFinderJobCanceler == null) { |
1335 |
fOccurrencesFinderJobCanceler= new OccurrencesFinderJobCanceler(); |
1514 |
fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler(); |
1336 |
fOccurrencesFinderJobCanceler.install(); |
1515 |
fOccurrencesFinderJobCanceler.install(); |
1337 |
} |
1516 |
} |
1338 |
} |
1517 |
} |
1339 |
|
1518 |
|
1340 |
protected void uninstallOccurrencesFinder() { |
1519 |
protected void uninstallOccurrencesFinder() { |
1341 |
fMarkOccurrenceAnnotations= false; |
1520 |
fMarkOccurrenceAnnotations = false; |
1342 |
|
1521 |
|
1343 |
if (fOccurrencesFinderJob != null) { |
1522 |
if (fOccurrencesFinderJob != null) { |
1344 |
fOccurrencesFinderJob.cancel(); |
1523 |
fOccurrencesFinderJob.cancel(); |
1345 |
fOccurrencesFinderJob= null; |
1524 |
fOccurrencesFinderJob = null; |
1346 |
} |
1525 |
} |
1347 |
|
1526 |
|
1348 |
if (fOccurrencesFinderJobCanceler != null) { |
1527 |
if (fOccurrencesFinderJobCanceler != null) { |
1349 |
fOccurrencesFinderJobCanceler.uninstall(); |
1528 |
fOccurrencesFinderJobCanceler.uninstall(); |
1350 |
fOccurrencesFinderJobCanceler= null; |
1529 |
fOccurrencesFinderJobCanceler = null; |
1351 |
} |
1530 |
} |
1352 |
|
1531 |
|
1353 |
removeOccurrenceAnnotations(); |
1532 |
removeOccurrenceAnnotations(); |
1354 |
} |
1533 |
} |
1355 |
|
1534 |
|
1356 |
public boolean isMarkingOccurrences() { |
1535 |
public boolean isMarkingOccurrences() { |
1357 |
return fMarkOccurrenceAnnotations; |
1536 |
return fMarkOccurrenceAnnotations; |
1358 |
} |
1537 |
} |
1359 |
|
1538 |
|
1360 |
|
|
|
1361 |
/** |
1539 |
/** |
1362 |
* The editor has entered or exited linked mode. |
1540 |
* The editor has entered or exited linked mode. |
1363 |
* @param inLinkedMode whether an enter or exit has occurred |
1541 |
* |
1364 |
* @param effectsOccurrences whether to change the state of the occurrences finder |
1542 |
* @param inLinkedMode |
|
|
1543 |
* whether an enter or exit has occurred |
1544 |
* @param effectsOccurrences |
1545 |
* whether to change the state of the occurrences finder |
1365 |
*/ |
1546 |
*/ |
1366 |
public void setInLinkedMode(boolean inLinkedMode, boolean effectsOccurrences) { |
1547 |
public void setInLinkedMode(boolean inLinkedMode, boolean effectsOccurrences) { |
1367 |
if (inLinkedMode) { |
1548 |
if (inLinkedMode) { |