Registering own IDocumentProvider [message #335031] |
Tue, 17 March 2009 09:19  |
Eclipse User |
|
|
|
Hello!
Let me describe my problem.
1 .I have my own IStorageEditorInput, which provides editing some string
without openning IFile
public class SimpleEditorInput implements IStorageEditorInput {
private String inputString;
public SimpleEditorInput(String inputString) {
this.inputString = inputString;
}
public IStorage getStorage() throws CoreException {
return new IStorage() {
public InputStream getContents() throws CoreException {
return IOUtils.toInputStream(inputString);
}
public IPath getFullPath() {
return null;
}
public String getName() {
return SimpleEditorInput.this.getName();
}
public boolean isReadOnly() {
return false;
}
public Object getAdapter(Class adapter) {
return null;
}
};
}
public boolean exists() {
return true;
}
public ImageDescriptor getImageDescriptor() {
return ImageDescriptor.getMissingImageDescriptor();
}
public String getName() {
return "JSEditor";
}
public IPersistableElement getPersistable() {
return null;
}
public String getToolTipText() {
return "JSEditor Tool Tip Text";
}
public Object getAdapter(Class adapter) {
return null;
}
public void setInputString(String inputString) {
this.inputString = inputString;
}
}
2. Next, I'm opennig any Editor (for example:
window.getActivePage().openEditor(new
SimpleEditorInput(TEST_JS_1),"org.eclipse.ui.DefaultTextEditor ");
or
window.getActivePage().openEditor(new
SimpleEditorInput(TEST_JS_1),"org.eclipse.wst.jsdt.ui.CompilationUnitEditor ");
3. The problem is, that I'd like to process SAVE action. But default
provider for my EditorInput is StorageDocumentProvider, which
doSaveDocument method is empty:
protected void doSaveDocument(IProgressMonitor monitor, Object
element, IDocument document, boolean overwrite) throws CoreException {
}
So, I'm trying to register my own DocumentProvider:
public class StringStorageDocumentProvider extends StorageDocumentProvider
{
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object
element, IDocument document, boolean overwrite) throws CoreException {
... here do something ...
}
}
by placing in my plugin.xml this block:
<extension
point="org.eclipse.ui.editors.documentProviders">
<provider
class="test.jseditor.StringStorageDocumentProvider"
inputTypes="org.eclipse.ui.IStorageEditorInput"
id="test.jseditor.StringStorageDocumentProvider">
</provider>
</extension>
But this doesn't work!
Please, help me. What do I wrong?
|
|
|
Re: Registering own IDocumentProvider [message #335047 is a reply to message #335031] |
Thu, 19 March 2009 06:37  |
Eclipse User |
|
|
|
Andrew Arapov wrote:
> Hello!
> Let me describe my problem.
See my answer in eclipse.platform.rcp.
Dani
>
> 1 .I have my own IStorageEditorInput, which provides editing some
> string without openning IFile
> public class SimpleEditorInput implements IStorageEditorInput {
> private String inputString;
>
> public SimpleEditorInput(String inputString) {
> this.inputString = inputString;
> }
>
> public IStorage getStorage() throws CoreException {
> return new IStorage() {
>
> public InputStream getContents() throws CoreException {
> return IOUtils.toInputStream(inputString);
> }
>
> public IPath getFullPath() {
> return null;
> }
>
> public String getName() {
> return SimpleEditorInput.this.getName();
> }
>
> public boolean isReadOnly() {
> return false;
> }
>
> public Object getAdapter(Class adapter) {
> return null;
> }
> };
> }
>
> public boolean exists() {
> return true;
> }
>
> public ImageDescriptor getImageDescriptor() {
> return ImageDescriptor.getMissingImageDescriptor();
> }
>
> public String getName() {
> return "JSEditor";
> }
>
> public IPersistableElement getPersistable() {
> return null;
> }
>
> public String getToolTipText() {
> return "JSEditor Tool Tip Text";
> }
>
> public Object getAdapter(Class adapter) {
> return null;
> }
>
> public void setInputString(String inputString) {
> this.inputString = inputString;
> }
> }
>
> 2. Next, I'm opennig any Editor (for example:
> window.getActivePage().openEditor(new
> SimpleEditorInput(TEST_JS_1),"org.eclipse.ui.DefaultTextEditor ");
> or
> window.getActivePage().openEditor(new
> SimpleEditorInput(TEST_JS_1),"org.eclipse.wst.jsdt.ui.CompilationUnitEditor ");
>
>
> 3. The problem is, that I'd like to process SAVE action. But default
> provider for my EditorInput is StorageDocumentProvider, which
> doSaveDocument method is empty:
> protected void doSaveDocument(IProgressMonitor monitor, Object
> element, IDocument document, boolean overwrite) throws CoreException {
> }
>
> So, I'm trying to register my own DocumentProvider:
>
> public class StringStorageDocumentProvider extends
> StorageDocumentProvider {
> @Override
> protected void doSaveDocument(IProgressMonitor monitor, Object
> element, IDocument document, boolean overwrite) throws CoreException {
> ... here do something ...
> }
> }
>
> by placing in my plugin.xml this block:
> <extension
> point="org.eclipse.ui.editors.documentProviders">
> <provider
> class="test.jseditor.StringStorageDocumentProvider"
> inputTypes="org.eclipse.ui.IStorageEditorInput"
> id="test.jseditor.StringStorageDocumentProvider">
> </provider>
> </extension>
>
> But this doesn't work!
>
> Please, help me. What do I wrong?
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04205 seconds