use of org.eclipse.ui.texteditor.ITextEditor in project eclipse.platform.text by eclipse.
the class LineAnnotationManagerTest method testLineBasedQuery.
@Test
public void testLineBasedQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fLineQuery);
AbstractTextSearchResult result = (AbstractTextSearchResult) fLineQuery.getSearchResult();
Object[] files = result.getElements();
try {
for (int i = 0; i < files.length; i++) {
IFile file = (IFile) files[0];
ITextEditor editor = (ITextEditor) SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
annotationModel.getAnnotationIterator();
ArrayList<Position> positions = new ArrayList<>();
for (Iterator<Annotation> iter = annotationModel.getAnnotationIterator(); iter.hasNext(); ) {
Annotation annotation = iter.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
positions.add(annotationModel.getPosition(annotation));
}
}
Match[] matches = result.getMatches(file);
for (int j = 0; j < matches.length; j++) {
Position position = computeDocumentPositionFromLineMatch(document, matches[j]);
assertTrue("position not found at: " + j, positions.remove(position));
}
assertEquals(0, positions.size());
}
} finally {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
use of org.eclipse.ui.texteditor.ITextEditor in project eclipse.platform.text by eclipse.
the class JavaActionContributor method doSetActiveEditor.
private void doSetActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
ITextEditor editor = null;
if (part instanceof ITextEditor)
editor = (ITextEditor) part;
fContentAssistProposal.setAction(getAction(editor, ITextEditorActionConstants.CONTENT_ASSIST));
fContentAssistTip.setAction(getAction(editor, ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION));
fTogglePresentation.setEditor(editor);
fTogglePresentation.update();
}
use of org.eclipse.ui.texteditor.ITextEditor in project eclipse.platform.text by eclipse.
the class PresentationAction method run.
@Override
public void run() {
ITextEditor editor = getTextEditor();
editor.resetHighlightRange();
boolean show = editor.showsHighlightRangeOnly();
setChecked(!show);
editor.showHighlightRangeOnly(!show);
}
use of org.eclipse.ui.texteditor.ITextEditor in project eclipse.platform.text by eclipse.
the class ProjectHyperlinkDetector method detectHyperlinks.
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
ITextEditor textEditor = getAdapter(ITextEditor.class);
IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
String fileLocation = TextProcessor.process(IDEResourceInfoUtils.getLocationText(resource));
ShowInSystemExplorerHyperlink showInSystemExplorerHyperlink = new ShowInSystemExplorerHyperlink(fileLocation, region);
URLHyperlink fileUrlHyperlink = new URLHyperlink(region, fileLocation);
URLHyperlink projectFileHelpLink = new URLHyperlink(region, "https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html");
return new IHyperlink[] { showInSystemExplorerHyperlink, fileUrlHyperlink, projectFileHelpLink };
}
use of org.eclipse.ui.texteditor.ITextEditor in project eclipse.platform.text by eclipse.
the class LineNumberColumn method getQuickDiffPreference.
/**
* Returns whether quick diff info should be visible upon opening an editor
* according to the preference store settings.
*
* @return <code>true</code> if the line numbers should be visible
*/
private boolean getQuickDiffPreference() {
if (fForwarder != null)
return fForwarder.isQuickDiffEnabled();
IPreferenceStore store = getPreferenceStore();
boolean setting = store != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false;
if (!setting)
return false;
boolean modifiable;
ITextEditor editor = getEditor();
if (editor instanceof ITextEditorExtension2) {
ITextEditorExtension2 ext = (ITextEditorExtension2) editor;
modifiable = ext.isEditorInputModifiable();
} else if (editor instanceof ITextEditorExtension) {
ITextEditorExtension ext = (ITextEditorExtension) editor;
modifiable = ext.isEditorInputReadOnly();
} else if (editor != null) {
modifiable = editor.isEditable();
} else {
modifiable = true;
}
return modifiable;
}
Aggregations