use of org.eclipse.ui.texteditor.IDocumentProvider in project linuxtools by eclipse.
the class CParserTest method tearDown.
@After
public void tearDown() throws Exception {
// content to the empty string).
if (cppSourceEditorPart != null) {
AbstractTextEditor castEditor = (AbstractTextEditor) cppSourceEditorPart;
IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
changelogContentDoc.set("");
cppSourceEditorPart.doSave(null);
// Also close open editor in order for default content to work.
// I.e. avoid spill over from previous test runs
closeEditor(cppSourceEditorPart);
}
// dispose
project.getTestProject().delete(true, true, null);
}
use of org.eclipse.ui.texteditor.IDocumentProvider in project linuxtools by eclipse.
the class EditorHelper method getContent.
/**
* Return the content of the given IEditorPart as String.
* @param editorPart
* @return Content of editorPart.
*/
public static String getContent(IEditorPart editorPart) {
AbstractTextEditor castEditor = (AbstractTextEditor) editorPart;
IDocumentProvider provider = castEditor.getDocumentProvider();
IDocument document = provider.getDocument(castEditor.getEditorInput());
return document.get();
}
use of org.eclipse.ui.texteditor.IDocumentProvider in project dbeaver by serge-rider.
the class SQLEditorNested method refreshPart.
@Override
public void refreshPart(Object source, boolean force) {
// Check if we are in saving process
// If so then no refresh needed (source text was updated during save)
IEditorSite editorSite = getEditorSite();
if (editorSite instanceof MultiPageEditorSite && ((MultiPageEditorSite) editorSite).getMultiPageEditor() instanceof EntityEditor && ((EntityEditor) ((MultiPageEditorSite) editorSite).getMultiPageEditor()).isSaveInProgress()) {
return;
}
final IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider instanceof SQLEditorNested.ObjectDocumentProvider) {
((SQLEditorNested.ObjectDocumentProvider) documentProvider).sourceText = null;
}
if (force) {
try {
super.init(editorSite, getEditorInput());
//setFocus();
} catch (PartInitException e) {
log.error(e);
}
}
}
use of org.eclipse.ui.texteditor.IDocumentProvider in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method openXtextEditor.
private void openXtextEditor(RepositoryNode repositoryNode, IProject fsProject, boolean readonly) {
try {
if (ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
IFile linkedFile = null;
IOpenJobScriptActionService openJobScriptActionService = (IOpenJobScriptActionService) GlobalServiceRegister.getDefault().getService(IOpenJobScriptActionService.class);
if (openJobScriptActionService != null) {
linkedFile = openJobScriptActionService.createWorkspaceLink(fsProject, repositoryNode.getObject().getProperty().getItem());
} else {
linkedFile = createWorkspaceLink(fsProject, fsProject.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.JOB_SCRIPT)).getFolder(repositoryNode.getParent().getRepositoryPath()).getFile(repositoryNode.getObject().getProperty().getLabel()).getLocation(), repositoryNode.getObject().getProperty().getVersion());
}
IWorkbenchPage page = getActivePage();
IEditorPart editor = IDE.openEditor(page, linkedFile);
if (readonly) {
IDocumentProvider provider = ((AbstractDecoratedTextEditor) editor).getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
} else {
JobScriptItem jobScriptItem = (JobScriptItem) repositoryNode.getObject().getProperty().getItem();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(jobScriptItem.eResource().getURI().path()).removeFirstSegments(1).removeFileExtension());
IFile linkedFile = createWorkspaceLink(fsProject, file.getLocation(), "");
IWorkbenchPage page = getActivePage();
IEditorPart editor = IDE.openEditor(page, linkedFile);
if (readonly) {
IDocumentProvider provider = ((AbstractDecoratedTextEditor) editor).getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (SecurityException e) {
ExceptionHandler.process(e);
} catch (NoSuchMethodException e) {
ExceptionHandler.process(e);
} catch (IllegalArgumentException e) {
ExceptionHandler.process(e);
} catch (IllegalAccessException e) {
ExceptionHandler.process(e);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.ui.texteditor.IDocumentProvider in project tdi-studio-se by Talend.
the class OpenDeclarationAction method highlightMethod.
/**
* Highlights the method on editor.
*
* @param editorInput The editor input
* @param editorPart The editor part
* @throws CoreException
*/
private void highlightMethod(IEditorInput editorInput, IEditorPart editorPart) throws CoreException {
if (!(editorPart instanceof ITextEditor) || methodName == null || parameters == null) {
return;
}
ITextEditor textEditor = (ITextEditor) editorPart;
IDocumentProvider provider = textEditor.getDocumentProvider();
provider.connect(editorInput);
int offset = 0;
int length = 0;
ISourceRange range = getMethodNameRange(editorInput);
if (range != null) {
offset = range.getOffset();
length = range.getLength();
}
textEditor.selectAndReveal(offset, length);
provider.disconnect(editorInput);
}
Aggregations