本文整理汇总了Java中org.eclipse.ui.texteditor.IDocumentProvider类的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider类的具体用法?Java IDocumentProvider怎么用?Java IDocumentProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDocumentProvider类属于org.eclipse.ui.texteditor包,在下文中一共展示了IDocumentProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveTo
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
public void moveTo(String handlerName) {
IEditorPart editor = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.getActiveEditor();
if (editor instanceof JscriptTransactionEditor) {
JscriptTransactionEditor myEditor = (JscriptTransactionEditor) editor;
MyJScriptEditor jsEditor = myEditor.getEditor();
IDocumentProvider provider = jsEditor.getDocumentProvider();
IDocument document = provider.getDocument(editor.getEditorInput());
String content = document.get();
int index = content.indexOf(handlerName);
jsEditor.selectAndReveal(index, handlerName.length());
}
}
示例2: saveOpenTmpSqlEditor
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
/**
* Saves the content as a temp-file, opens it using SQL-editor
* and ensures that UTF-8 is used for everything.
*/
public static void saveOpenTmpSqlEditor(String content, String filenamePrefix) throws IOException, CoreException {
Log.log(Log.LOG_INFO, "Creating file " + filenamePrefix); //$NON-NLS-1$
Path path = Files.createTempFile(filenamePrefix + '_', ".sql"); //$NON-NLS-1$
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(path.toFile());
IEditorInput input = new FileStoreEditorInput(externalFile);
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, EDITOR.SQL);
if (part instanceof ITextEditor) {
IDocumentProvider prov = ((ITextEditor) part).getDocumentProvider();
if (prov instanceof TextFileDocumentProvider) {
((TextFileDocumentProvider) prov).setEncoding(input, ApgdiffConsts.UTF_8);
prov.resetDocument(input);
}
}
}
示例3: attach
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
/**
* Attaches a coverage annotation model for the given editor if the editor can
* be annotated. Does nothing if the model is already attached.
*
* @param editor
* Editor to attach a annotation model to
*/
public static void attach(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
// there may be text editors without document providers (SF #1725100)
if (provider == null)
return;
IAnnotationModel model = provider.getAnnotationModel(editor
.getEditorInput());
if (!(model instanceof IAnnotationModelExtension))
return;
IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
IDocument document = provider.getDocument(editor.getEditorInput());
CoverageAnnotationModel coveragemodel = (CoverageAnnotationModel) modelex
.getAnnotationModel(KEY);
if (coveragemodel == null) {
coveragemodel = new CoverageAnnotationModel(editor, document);
modelex.addAnnotationModel(KEY, coveragemodel);
}
}
示例4: initializeSourceViewer
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
private void initializeSourceViewer(final IEditorInput input) {
final IDocumentProvider documentProvider = getDocumentProvider();
final IAnnotationModel model = documentProvider.getAnnotationModel(input);
final IDocument document = documentProvider.getDocument(input);
if (document != null) {
fSourceViewer.setDocument(document, model);
fSourceViewer.setEditable(isEditable());
fSourceViewer.showAnnotations(model != null);
}
if (fElementStateListener instanceof IElementStateListenerExtension) {
boolean isStateValidated = false;
if (documentProvider instanceof IDocumentProviderExtension)
isStateValidated = ((IDocumentProviderExtension) documentProvider).isStateValidated(input);
final IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
extension.elementStateValidationChanged(input, isStateValidated);
}
}
示例5: disposeDocumentProvider
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
/**
* Disposes of the connection with the document provider. Subclasses may
* extend.
*
* @since 3.0
*/
protected void disposeDocumentProvider() {
final IDocumentProvider provider = getDocumentProvider();
if (provider != null) {
final IEditorInput input = getEditorInput();
if (input != null)
provider.disconnect(input);
if (fElementStateListener != null) {
provider.removeElementStateListener(fElementStateListener);
fElementStateListener = null;
}
}
fImplicitDocumentProvider = null;
}
示例6: updateState
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
protected void updateState(final IEditorInput input) {
final IDocumentProvider provider = getDocumentProvider();
if (provider instanceof IDocumentProviderExtension) {
final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
try {
extension.updateStateCache(input);
if (fSourceViewer != null)
fSourceViewer.setEditable(isEditable());
} catch (final CoreException e) {
ERDiagramActivator.log(e);
}
}
}
示例7: initializeSourceViewer
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
private void initializeSourceViewer(IEditorInput input) {
IDocumentProvider documentProvider = getDocumentProvider();
IAnnotationModel model = documentProvider.getAnnotationModel(input);
IDocument document = documentProvider.getDocument(input);
if (document != null) {
fSourceViewer.setDocument(document, model);
fSourceViewer.setEditable(isEditable());
fSourceViewer.showAnnotations(model != null);
}
if (fElementStateListener instanceof IElementStateListenerExtension) {
boolean isStateValidated = false;
if (documentProvider instanceof IDocumentProviderExtension)
isStateValidated = ((IDocumentProviderExtension) documentProvider)
.isStateValidated(input);
IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
extension.elementStateValidationChanged(input, isStateValidated);
}
}
示例8: disposeDocumentProvider
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
/**
* Disposes of the connection with the document provider. Subclasses may
* extend.
*
* @since 3.0
*/
protected void disposeDocumentProvider() {
IDocumentProvider provider = getDocumentProvider();
if (provider != null) {
IEditorInput input = getEditorInput();
if (input != null)
provider.disconnect(input);
if (fElementStateListener != null) {
provider.removeElementStateListener(fElementStateListener);
fElementStateListener = null;
}
}
fImplicitDocumentProvider = null;
}
示例9: updateState
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
protected void updateState(IEditorInput input) {
IDocumentProvider provider = getDocumentProvider();
if (provider instanceof IDocumentProviderExtension) {
IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
try {
extension.updateStateCache(input);
if (fSourceViewer != null)
fSourceViewer.setEditable(isEditable());
} catch (CoreException e) {
ERDiagramActivator.log(e);
}
}
}
示例10: setDocumentProvider
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
/**
* Register the element state listener to react on the changes to the state (saved, dirty:=not saved)
*/
protected void setDocumentProvider(IEditorInput input)
{
super.setDocumentProvider(input);
IDocumentProvider provider = getDocumentProvider();
if (provider != null)
{
provider.addElementStateListener(new ElementStateAdapter() {
public void elementDirtyStateChanged(Object element, boolean isDirty)
{
if (isDirty)
{
contextService.deactivateContext(contextActivation);
} else
{
contextActivation = contextService.activateContext("toolbox.contexts.cleaneditor");
}
}
});
}
}
示例11: getPosition
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
public static Position getPosition(IFile file, TextSpan textSpan) throws BadLocationException {
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
ITextFileBuffer buffer = bufferManager.getTextFileBuffer(file.getLocation(), LocationKind.IFILE);
if (buffer != null) {
return getPosition(buffer.getDocument(), textSpan);
}
IDocumentProvider provider = new TextFileDocumentProvider();
try {
provider.connect(file);
IDocument document = provider.getDocument(file);
if (document != null) {
return getPosition(document, textSpan);
}
} catch (CoreException e) {
} finally {
provider.disconnect(file);
}
return null;
}
示例12: removeOccurrenceAnnotations
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
private void removeOccurrenceAnnotations() {
// fMarkOccurrenceModificationStamp=
// IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
// fMarkOccurrenceTargetRegion= null;
IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider == null)
return;
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null || fOccurrenceAnnotations == null)
return;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
} else {
for (int i = 0, length = fOccurrenceAnnotations.length; i < length; i++)
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
}
fOccurrenceAnnotations = null;
}
}
示例13: installTabsToSpacesConverter
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
@Override
protected void installTabsToSpacesConverter() {
ISourceViewer sourceViewer = getSourceViewer();
SourceViewerConfiguration config = getSourceViewerConfiguration();
if (config != null && sourceViewer instanceof ITextViewerExtension7) {
int tabWidth = config.getTabWidth(sourceViewer);
TabsToSpacesConverter tabToSpacesConverter = new TabsToSpacesConverter();
tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
IDocumentProvider provider = getDocumentProvider();
if (provider instanceof ICompilationUnitDocumentProvider) {
ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider;
tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
} else
tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
((ITextViewerExtension7) sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
updateIndentPrefixes();
}
}
示例14: getGWTProblemsInEditor
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
private List<GWTJavaProblem> getGWTProblemsInEditor(CompilationUnitEditor editor)
throws Exception {
List<GWTJavaProblem> problems = new ArrayList<GWTJavaProblem>();
Field annotationProblemField = CompilationUnitDocumentProvider.ProblemAnnotation.class.getDeclaredField("fProblem");
annotationProblemField.setAccessible(true);
IEditorInput editorInput = editor.getEditorInput();
IDocumentProvider documentProvider = editor.getDocumentProvider();
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editorInput);
Iterator<?> iter = annotationModel.getAnnotationIterator();
while (iter.hasNext()) {
Object annotation = iter.next();
if (annotation instanceof CompilationUnitDocumentProvider.ProblemAnnotation) {
CompilationUnitDocumentProvider.ProblemAnnotation problemAnnotation = (ProblemAnnotation) annotation;
if (problemAnnotation.getMarkerType().equals(GWTJavaProblem.MARKER_ID)) {
GWTJavaProblem problem = (GWTJavaProblem) annotationProblemField.get(problemAnnotation);
problems.add(problem);
}
}
}
return problems;
}
示例15: model2xml
import org.eclipse.ui.texteditor.IDocumentProvider; //导入依赖的package包/类
protected String model2xml() {
try {
if (model != null) {
String xml = doModel2xml();
IDocumentProvider dp = xmlEditor.getDocumentProvider();
IDocument doc = dp.getDocument(xmlEditor.getEditorInput());
if (xml != null && !Arrays.equals(doc.get().getBytes(), xml.getBytes()))
doc.set(xml);
xmlFresh = true;
return xml;
}
} catch (final Exception e) {
UIUtils.showError(e);
}
return null;
}