01: package com.xoetrope.editor.eclipse;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.InputStream;
05:
06: import org.eclipse.core.resources.IStorage;
07: import org.eclipse.core.runtime.CoreException;
08: import org.eclipse.core.runtime.IPath;
09: import org.eclipse.core.runtime.PlatformObject;
10:
11: /**
12: * A class used as an input source for editors when there's no
13: * file available.
14: *
15: */
16: public class XStringStorage extends PlatformObject implements IStorage {
17: private String input;
18:
19: public XStringStorage(String s) {
20: input = s;
21: }
22:
23: public InputStream getContents() throws CoreException {
24: return new ByteArrayInputStream(input.getBytes());
25: }
26:
27: public IPath getFullPath() {
28: return null;
29: }
30:
31: public String getName() {
32: int len = Math.min(5, input.length());
33: return input.substring(0, len).concat("...");
34: }
35:
36: public boolean isReadOnly() {
37: return true;
38: }
39:
40: }
|