本文整理汇总了Java中org.eclipse.compare.IStreamContentAccessor类的典型用法代码示例。如果您正苦于以下问题:Java IStreamContentAccessor类的具体用法?Java IStreamContentAccessor怎么用?Java IStreamContentAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStreamContentAccessor类属于org.eclipse.compare包,在下文中一共展示了IStreamContentAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAsDocument
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
protected Object updateAsDocument(Object object) {
if (object instanceof IResourceProvider && supportsSharedDocuments(object)) {
return object;
}
if (object instanceof IStreamContentAccessor) {
try {
StreamContentAccessorDelegate streamContentAccessorDelegate = new StreamContentAccessorDelegate(
(IStreamContentAccessor) object, createResourceProvider(object));
documentProvider.connect(streamContentAccessorDelegate);
inputObjectStreamContentAccessorMap.put(object, streamContentAccessorDelegate);
return documentProvider.getDocument(streamContentAccessorDelegate);
} catch (CoreException coreException) {
throw new WrappedException(coreException);
}
}
return object;
}
示例2: loadResource
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
protected void loadResource(Object element, Resource resource) {
if (resource == null) {
return;
}
if (element instanceof IStreamContentAccessor) {
IStreamContentAccessor streamContentAccessor = (IStreamContentAccessor) element;
InputStream inputStream = null;
try {
inputStream = streamContentAccessor.getContents();
if (inputStream != null) {
resource.load(inputStream,
Collections.singletonMap(XtextResource.OPTION_ENCODING, getEncoding(element)));
}
} catch (Exception exception) {
throw new WrappedException(exception);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
示例3: readString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
public static String readString(IStreamContentAccessor sa) throws CoreException {
InputStream is= sa.getContents();
if (is != null) {
String encoding= null;
if (sa instanceof IEncodedStreamContentAccessor) {
try {
encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
} catch (Exception e) {
}
}
if (encoding == null)
encoding= ResourcesPlugin.getEncoding();
return readString(is, encoding);
}
return null;
}
示例4: readString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
public static String readString(IStreamContentAccessor sa) throws CoreException {
InputStream is = sa.getContents();
if (is != null) {
String encoding = null;
if (sa instanceof IEncodedStreamContentAccessor) {
try {
encoding = ((IEncodedStreamContentAccessor) sa).getCharset();
} catch (Exception e) {
}
}
if (encoding == null) {
encoding = ResourcesPlugin.getEncoding();
}
return readString(is, encoding);
}
return null;
}
示例5: readString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
public static String readString(IStreamContentAccessor sa) throws CoreException {
InputStream is= sa.getContents();
String encoding= null;
if (sa instanceof IEncodedStreamContentAccessor)
encoding= ((IEncodedStreamContentAccessor)sa).getCharset();
if (encoding == null)
encoding= ResourcesPlugin.getEncoding();
return Utilities.readString(is, encoding);
}
示例6: StreamContentAccessorDelegate
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
public StreamContentAccessorDelegate(IStreamContentAccessor streamContentAccessor,
IResourceProvider resourceProvider) {
super();
Assert.isNotNull(streamContentAccessor, "parameter 'streamContentAccessor' must not be null");
Assert.isNotNull(resourceProvider, "parameter 'resourceProvider' must not be null");
this.streamContentAccessor = streamContentAccessor;
this.resourceProvider = resourceProvider;
}
示例7: createDocument
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
@Override
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = null;
if (element instanceof IStreamContentAccessor) {
document = createEmptyDocument();
setupDocument(element, document);
}
return document;
}
示例8: getString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
protected String getString(Object input) {
if (input instanceof IStreamContentAccessor) {
IStreamContentAccessor streamContentAccessor = (IStreamContentAccessor) input;
try {
return readString(streamContentAccessor);
} catch (CoreException ex) {
throw new WrappedException(ex);
}
}
return ""; //$NON-NLS-1$
}
示例9: readString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
protected String readString(IStreamContentAccessor streamContentAccessor) throws CoreException {
InputStream inputStream = streamContentAccessor.getContents();
if (inputStream != null) {
String encoding = getEncoding(streamContentAccessor);
return readString(inputStream, encoding);
}
return null;
}
示例10: loadOnePlan
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
private EPlan loadOnePlan(ITypedElement resourceOrFileElement) throws IOException, CoreException {
if (resourceOrFileElement instanceof IResourceProvider) {
return EPlanUtils.loadOnePlan(((IResourceProvider) resourceOrFileElement).getResource());
}
else if (resourceOrFileElement instanceof IStreamContentAccessor) { // e.g. a FileRevisionTypedElement
return EPlanUtils.loadOnePlan(((IStreamContentAccessor) resourceOrFileElement).getContents());
}
else {
throw new IOException("Don't know how to load a plan from a " + resourceOrFileElement.getClass().getName() + ".");
}
}
示例11: setInput
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
@Override
public void setInput(Object input) {
if (input instanceof IStreamContentAccessor) {
Document document= new Document(getString(input));
JavaCompareUtilities.setupPropertiesFileDocument(document);
fSourceViewer.setDocument(document);
}
fInput= input;
}
示例12: getString
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
/**
* A helper method to retrieve the contents of the given object
* if it implements the IStreamContentAccessor interface.
*/
private static String getString(Object input) {
if (input instanceof IStreamContentAccessor) {
IStreamContentAccessor sca= (IStreamContentAccessor) input;
try {
return JavaCompareUtilities.readString(sca);
} catch (CoreException ex) {
JavaPlugin.log(ex);
}
}
return ""; //$NON-NLS-1$
}
示例13: getStructure
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
/**
* @param input implement the IStreamContentAccessor interface
* @return a tree of JavaNodes for the given input.
* In case of error null is returned.
*/
@Override
public IStructureComparator getStructure(final Object input) {
String contents= null;
char[] buffer= null;
IDocument doc= CompareUI.getDocument(input);
if (doc == null) {
if (input instanceof IStreamContentAccessor) {
IStreamContentAccessor sca= (IStreamContentAccessor) input;
try {
contents= JavaCompareUtilities.readString(sca);
} catch (CoreException ex) {
// return null indicates the error.
return null;
}
}
if (contents != null) {
int n= contents.length();
buffer= new char[n];
contents.getChars(0, n, buffer, 0);
doc= new Document(contents);
setupDocument(doc);
}
}
return createStructureComparator(input, buffer, doc, null, null);
}
示例14: getContents
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
public String getContents(Object node, boolean ignoreWhitespace) {
if (node instanceof IStreamContentAccessor) {
IStreamContentAccessor sca= (IStreamContentAccessor) node;
try {
return JavaCompareUtilities.readString(sca);
} catch (CoreException ex) {
JavaPlugin.log(ex);
}
}
return null;
}
示例15: setInput
import org.eclipse.compare.IStreamContentAccessor; //导入依赖的package包/类
@Override
public void setInput(Object input) {
if (input instanceof IStreamContentAccessor) {
Document document= new Document(getString(input));
JavaCompareUtilities.setupDocument(document);
fSourceViewer.setDocument(document);
}
fInput= input;
}