use of org.eclipse.ui.editors.text.TextEditor in project eclipse.platform.text by eclipse.
the class EncodingChangeTests method testChangeEncodingViaFile.
@Test
public void testChangeEncodingViaFile() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
fFile.setCharset(NON_DEFAULT_ENCODING, null);
} catch (CoreException ex) {
fail();
}
try {
fEditor = IDE.openEditor(page, fFile);
if (fEditor instanceof TextEditor) {
TextEditor editor = (TextEditor) fEditor;
Accessor accessor = new Accessor(editor, StatusTextEditor.class);
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
assertNull(composite);
DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
assertEquals(NON_DEFAULT_ENCODING, encodingSupport.getEncoding());
} else
fail();
} catch (PartInitException e) {
fail();
}
}
use of org.eclipse.ui.editors.text.TextEditor in project eclipse.platform.text by eclipse.
the class EncodingChangeTests method testChangeEncodingViaEncodingSupport.
@Test
public void testChangeEncodingViaEncodingSupport() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
fEditor = IDE.openEditor(page, fFile);
if (fEditor instanceof TextEditor) {
TextEditor editor = (TextEditor) fEditor;
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
encodingSupport.setEncoding(NON_DEFAULT_ENCODING);
Accessor accessor = new Accessor(editor, StatusTextEditor.class);
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
assertNull(composite);
String actual = null;
try {
actual = fFile.getCharset(false);
} catch (CoreException e1) {
fail();
}
assertEquals(NON_DEFAULT_ENCODING, actual);
} else
fail();
} catch (PartInitException e) {
fail();
}
}
use of org.eclipse.ui.editors.text.TextEditor in project eclipse.platform.text by eclipse.
the class EncodingChangeTests method testAInvalidEncoding.
@Test
public void testAInvalidEncoding() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
fFile.setCharset("nonexistent", null);
} catch (CoreException e2) {
fail();
}
try {
fEditor = IDE.openEditor(page, fFile);
if (fEditor instanceof TextEditor) {
TextEditor editor = (TextEditor) fEditor;
Accessor accessor = new Accessor(editor, StatusTextEditor.class);
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
ITextFileBuffer fileBuffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
String expected = encodingSupport.getStatusMessage(fileBuffer.getStatus());
Composite composite = (Composite) accessor.get("fStatusControl");
ScrolledComposite scrolledComposite = (ScrolledComposite) composite.getChildren()[0];
StyledText statusText = (StyledText) ((Composite) scrolledComposite.getContent()).getChildren()[5];
String actual = statusText.getText();
assertEquals(expected, actual);
} else
fail();
} catch (PartInitException e) {
fail();
}
}
use of org.eclipse.ui.editors.text.TextEditor in project linuxtools by eclipse.
the class RepoFormEditor method createEditorPage.
/**
* Creates editor for the current .repo file.
*
* @throws PartInitException
*/
private void createEditorPage() throws PartInitException {
editor = new TextEditor();
int index = addPage(editor, getEditorInput());
setPageText(index, editor.getTitle());
}
use of org.eclipse.ui.editors.text.TextEditor in project eclipse.platform.text by eclipse.
the class StatusEditorTest method openNonExistentFile.
private IEditorPart openNonExistentFile(IWorkbenchPage page1, URI uri) throws Exception {
FileStoreEditorInput input = new FileStoreEditorInput(EFS.getStore(uri));
TextEditor editor = (TextEditor) page1.openEditor(input, EditorsUI.DEFAULT_TEXT_EDITOR_ID, true);
Method setMethod = AbstractTextEditor.class.getDeclaredMethod("setDocumentProvider", IDocumentProvider.class);
setMethod.setAccessible(true);
setMethod.invoke(editor, new ErrorDocumentProvider(editor.getDocumentProvider()));
editor.setInput(input);
processEvents();
return editor;
}
Aggregations