本文整理汇总了Java中org.eclipse.ui.texteditor.IDocumentProvider.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider.getDocument方法的具体用法?Java IDocumentProvider.getDocument怎么用?Java IDocumentProvider.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.texteditor.IDocumentProvider
的用法示例。
在下文中一共展示了IDocumentProvider.getDocument方法的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: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: xml2model
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* Xml2model.
*
* @throws JRException
* the jR exception
*/
private void xml2model() throws Exception {
InputStream in = null;
try {
IDocumentProvider dp = xmlEditor.getDocumentProvider();
IDocument doc = dp.getDocument(xmlEditor.getEditorInput());
in = new ByteArrayInputStream(doc.get().getBytes("UTF-8"));
JasperDesign jd = new JRXmlLoader(jrContext, JasperReportsConfiguration.getJRXMLDigester()).loadXML(in);
jrContext.setJasperDesign(jd);
JaspersoftStudioPlugin.getExtensionManager().onLoad(jd, this);
setModel(ReportFactory.createReport(jrContext));
} finally {
FileUtils.closeStream(in);
}
}
示例8: validate
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
IDocument document = null;
// get document
try {
final IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(resource);
document = provider.getDocument(resource);
provider.disconnect(resource);
} catch (CoreException e) {
e.printStackTrace();
}
ValidationResult result = new ValidationResult();
if (document != null) {
// validate definitions names
List<ElementRegion> definitionNameRegions = tilesXmlParser
.getDefinitionNameRegions(document);
validateRegions(resource, document, result, definitionNameRegions,
DUP_DEFINITION_MESSAGE_TEXT, IMarker.SEVERITY_WARNING);
}
return result;
}
示例9: getScript
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public String getScript( )
{
IDocumentProvider provider = getDocumentProvider( );
String script = ""; //$NON-NLS-1$
if ( provider != null )
{
IDocument document = provider.getDocument( getEditorInput( ) );
if ( document != null )
{
script = document.get( );
}
}
return script;
}
示例10: gotoLine
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void gotoLine(ITextEditor editor, int line) {
IDocumentProvider provider = editor.getDocumentProvider();
IDocument document = provider.getDocument(editor.getEditorInput());
try {
int start = document.getLineOffset(line);
editor.selectAndReveal(start, 0);
IWorkbenchPage page = editor.getSite().getPage();
page.activate(editor);
} catch (BadLocationException x) {
// ignore
}
}
示例11: execute
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
IFileEditorInput input = (IFileEditorInput) part.getEditorInput();
IFile file = input.getFile();
if (part instanceof ITextEditor) {
final ITextEditor editor = (ITextEditor) part;
IVerticalRulerInfo ruleInfo = editor.getAdapter(IVerticalRulerInfo.class);
IDocumentProvider provider = editor.getDocumentProvider();
IDocument document = provider.getDocument(editor.getEditorInput());
int lineNumber = ruleInfo.getLineOfLastMouseButtonActivity();
String className = file.getName().substring(0, file.getName().lastIndexOf('.'));
HashMap<VFUnit, VFMethod> resultantUnit = getSelectedUnit(className, document, lineNumber);
List<VFNode> unit = new ArrayList<>();
if (resultantUnit.size() > 0) {
if (event.getCommand().getId().equals("JavaHandler.NavigateToJimple")) {
NavigationHandler handler = new NavigationHandler();
handler.highlightJimpleSource(new ArrayList<>(resultantUnit.keySet()));
} else {
for (VFUnit vfUnit : resultantUnit.keySet()) {
unit.add(new VFNode(vfUnit, 0));
}
try {
ServiceUtil.getService(DataModel.class).filterGraph(unit, true, true, null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
// call graph highlighting code here
} else {
logger.error("Editor not a Text Editor");
}
return null;
}
示例12: gotoLine
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static void gotoLine(ITextEditor textEditor, int line) throws BadLocationException {
IDocumentProvider provider = textEditor.getDocumentProvider();
IDocument document = provider.getDocument(textEditor.getEditorInput());
int start = document.getLineOffset(line);
textEditor.selectAndReveal(start, 0);
IWorkbenchPage page = textEditor.getSite().getPage();
page.activate(textEditor);
}
示例13: getOffsetOfFirstNonWhitespaceCharAtLine
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static int getOffsetOfFirstNonWhitespaceCharAtLine(ITextEditor textEditor, int lineNumber)
throws BadLocationException {
IDocumentProvider provider = textEditor.getDocumentProvider();
IDocument document = provider.getDocument(textEditor.getEditorInput());
IRegion region = document.getLineInformation(lineNumber);
int offset = region.getOffset();
int lastOffset = offset + region.getLength() - 1;
while ((offset <= lastOffset) && (document.getChar(offset) <= ' ')) {
offset++;
}
return offset;
}
示例14: getLineContent
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static String getLineContent(ITextEditor textEditor, int lineNumber) {
try {
IDocumentProvider provider = textEditor.getDocumentProvider();
IDocument document = provider.getDocument(textEditor.getEditorInput());
IRegion region = document.getLineInformation(lineNumber);
return document.get(region.getOffset(), region.getLength());
} catch (BadLocationException e) {
return null;
}
}
示例15: gotoLine
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static void gotoLine(ITextEditor textEditor, int line)
throws BadLocationException {
IDocumentProvider provider = textEditor.getDocumentProvider();
IDocument document = provider.getDocument(textEditor.getEditorInput());
int start = document.getLineOffset(line);
textEditor.selectAndReveal(start, 0);
IWorkbenchPage page = textEditor.getSite().getPage();
page.activate(textEditor);
}