TextEditor that does not operate on file [message #276561] |
Thu, 25 November 2004 09:03  |
Eclipse User |
|
|
|
Originally posted by: iwan.global.co.za
Hello,
I need to have the usual text editor, but it should basically edit a
relatively small String (which is part of a model object), and NOT be
associated to a file.
The editor will be on a page of a MultiPageEditor, and I need to be able
to instantiate it myself.
What is a good way of doing this/where can I find good documentation?
I've played with the TextEditor in jface, but I had all kind of problems
instantiating it and putting it in a MultiPageEditor page.
Thanks
-i
|
|
|
|
Re: TextEditor that does not operate on file [message #276644 is a reply to message #276592] |
Fri, 26 November 2004 10:07  |
Eclipse User |
|
|
|
It is quite straight forward to use the MultiPageEditor. The MultiPageEditor
example offers a starting point and the MultiPageEditor API also tells you
what to do.
Essentially you need to implement (override) the createPages() method, in
which you add all the pages to the editor using
addPage(IEditorPart, IEditorInput)
For your particular problem this means you create an IEditorPart (or extend
one of the abstract editor classes) and add it to your MPE using that
method.
e.g.
protected void addPages() {
javaEditor = new JavaEditor();
IEditorInput javaInput = new JavaEditorInput(javaCode);
int index = addPage(javaEditor, javaInput);
setPageText(index, "Java: "+javaCode.getClassName());
}
this would create a new JavaEditor and add it to the MPE with the given
JavaEditorInput (your input as described bye anonymous)
the title of the editors tab in the MPE is then set to "Java: " followed by
the classname. Here you can put anything you want...
regards
Thomas
"anonymous" <asd@asd.com> wrote in message
news:co6go0$sef$1@www.eclipse.org...
> The object which you wish to edit should implement IStorageEditorInput
> interface (like EditorInputTest in the code below).
> then you need to get handle to the workbench page and call openEditor.
> The first arguement is the IStorageEditorInput object and the second is
> the id of the editor through which you wish to handle the editing.
> the code given below was declared inside SelectionChanged () method of the
> class implement ISelectionListener.
> I havcent tried multipageeditor input, so I dont have idea about that.
> //create the Editor Object
> IWorkbench wb = PlatformUI.getWorkbench();
> IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
> IWorkbenchPage page = win.getActivePage();
>
> InputStream inputstream=new StringBufferInputStream(node.getStrName());
> // TODO get the handle to our actual data of the object and pass it to the
> editor as input
> EditorInputTest input=new EditorInputTest(node.getStrName(),inputstream);
> try {
> if (page != null)
> page.openEditor(input, "ResourceExplorer.TestEditor");
> } catch (PartInitException e1) {
> // TODO Auto-generated catch block
> e1.printStackTrace();
> throw new RuntimeException(e1);
> }
>
> Iwan Vosloo wrote:
>
>> Hello,
>
>> I need to have the usual text editor, but it should basically edit a
>> relatively small String (which is part of a model object), and NOT be
>> associated to a file.
>
>> The editor will be on a page of a MultiPageEditor, and I need to be able
>> to instantiate it myself.
>
>> What is a good way of doing this/where can I find good documentation?
>> I've played with the TextEditor in jface, but I had all kind of problems
>> instantiating it and putting it in a MultiPageEditor page.
>
>> Thanks
>> -i
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03476 seconds