use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class JSPELContentAssistTest method getCompletionProposals.
/**
* use a viewer and document location to generate completion proposals for that location in the viewer
*
* @param filePath
* @param documentLocation
* @return
* @throws PartInitException
*/
private ICompletionProposal[] getCompletionProposals(String filePath, int documentLocation) throws PartInitException {
IFile file = getFile(filePath);
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
return getCompletionProposals(viewer, documentLocation);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class JSPELContentAssistTest method getCompletionProposals.
/**
* use a viewer and document location to generate completion proposals for that location in the viewer
*
* @param file
* @param documentLocation
* @return
* @throws PartInitException
*/
private ICompletionProposal[] getCompletionProposals(IFile file, int documentLocation) throws PartInitException {
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
return getCompletionProposals(viewer, documentLocation);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class JSPELContentAssistTest method getEditor.
/**
* Given a file returns a viewer for that file
*
* @param file
* @return
* @throws PartInitException
*/
private StructuredTextEditor getEditor(IFile file) throws PartInitException {
IEditorInput input = new FileEditorInput(file);
IEditorPart part = this.page.openEditor(input, STRUCTURED_EDITOR_TYPE, true);
assertTrue("Unable to open structured text editor", part instanceof StructuredTextEditor);
return (StructuredTextEditor) part;
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestContentFormatter method formatAndAssertSignificantEquals.
private void formatAndAssertSignificantEquals(String beforePath, boolean resetPreferences) throws UnsupportedEncodingException, IOException, CoreException {
StructuredTextEditor editor = (StructuredTextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(beforePath)), "org.eclipse.jst.jsp.core.jspsource.source", true);
try {
String before = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
editor.getTextViewer().doOperation(StructuredTextViewer.FORMAT_DOCUMENT);
String after = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
assertTrue(onlyWhiteSpaceDiffers(before, after));
} finally {
editor.close(false);
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class FindOccurrencesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
ITextEditor textEditor = null;
if (editorPart instanceof ITextEditor)
textEditor = (ITextEditor) editorPart;
else {
Object o = editorPart.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
boolean okay = false;
if (textEditor != null) {
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
if (document != null) {
ITextSelection textSelection = getTextSelection(textEditor);
FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
if (findOccurrenceProcessor != null) {
if (textEditor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
}
}
}
}
if (okay) {
// clear status message
PlatformStatusLineUtil.clearStatusLine();
} else {
// $NON-NLS-1$
String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0;
if (textEditor instanceof StructuredTextEditor) {
PlatformStatusLineUtil.displayTemporaryErrorMessage(((StructuredTextEditor) textEditor).getTextViewer(), errorMessage);
} else {
PlatformStatusLineUtil.displayErrorMessage(errorMessage);
PlatformStatusLineUtil.addOneTimeClearListener();
}
}
return null;
}
Aggregations