本文整理汇总了Java中org.eclipse.ui.texteditor.IDocumentProvider.connect方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider.connect方法的具体用法?Java IDocumentProvider.connect怎么用?Java IDocumentProvider.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.texteditor.IDocumentProvider
的用法示例。
在下文中一共展示了IDocumentProvider.connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: getDocument
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private IDocument getDocument(IDocumentProvider provider, IEditorInput input) {
if (input == null)
return null;
IDocument result= null;
try {
provider.connect(input);
result= provider.getDocument(input);
} catch (CoreException e) {
} finally {
provider.disconnect(input);
}
return result;
}
示例4: doSetInput
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
protected void doSetInput(final IEditorInput input) throws CoreException {
if (input == null) {
close(isSaveOnCloseNeeded());
} else {
final IEditorInput oldInput = getEditorInput();
if (oldInput != null)
getDocumentProvider().disconnect(oldInput);
super.setInput(input);
updateDocumentProvider(input);
final IDocumentProvider provider = getDocumentProvider();
provider.connect(input);
initializeTitle(input);
if (fSourceViewer != null) {
initializeSourceViewer(input);
}
}
}
示例5: doSetInput
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
protected void doSetInput(IEditorInput input) throws CoreException {
if (input == null) {
close(isSaveOnCloseNeeded());
} else {
IEditorInput oldInput = getEditorInput();
if (oldInput != null)
getDocumentProvider().disconnect(oldInput);
super.setInput(input);
updateDocumentProvider(input);
IDocumentProvider provider = getDocumentProvider();
provider.connect(input);
initializeTitle(input);
if (fSourceViewer != null) {
initializeSourceViewer(input);
}
}
}
示例6: addMarkers
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void addMarkers(Set<String> deletedKeys) throws Exception {
targetFile.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
if (deletedKeys == null || deletedKeys.isEmpty()) {
//do nothing
return;
}
IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(targetFile);
IDocument targetFileDocument = provider.getDocument(targetFile);
FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(targetFileDocument);
for (String deletedkey: deletedKeys) {
IRegion region = adapter.find(0, deletedkey, true, false, false, false);
IMarker marker = targetFile.createMarker(IMarker.PROBLEM);
int lineNumber = targetFileDocument.getLineOfOffset(region.getOffset());
if (marker.exists()) {
marker.setAttribute(IMarker.MESSAGE, "Property might not be used within mule configs.");
marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber + 1);
marker.setAttribute(IMarker.CHAR_START, region.getOffset());
marker.setAttribute(IMarker.CHAR_END, region.getOffset() + region.getLength());
}
}
provider.disconnect(targetFile);
}