Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Starting with a non empty Editor
Starting with a non empty Editor [message #199687] Tue, 18 October 2005 13:21 Go to next message
Eclipse UserFriend
Originally posted by: mirco.mirco-dunker.de

Hello,
I have a GEF-Tutorial that works fine and I can start with an empty editor
so I can compose diagrams. But I want to start a non empty editor. If I
create a new editor instance I want to have one of my model elements on
this editor. But it doesn't work. My idear was to change this:

public class MyGraphicalEditor extends GraphicalEditorWithPalette {
[...]
protected void setInput(IEditorInput input) {
super.setInput(input);
IFile file = (IFile) input.getAdapter(IResource.class);
try {
InputStream is = file.getContents();
if (is.available() == 0) {
rootElement = new RootElement();
//Adding the model element that should be shown
modelElement = new modelElement();
rootElement.addModelElement(modelElement);
} else {
ObjectInputStream ois = new ObjectInputStream(is);
rootElement = (RootElement) ois.readObject();
}
} catch (Exception e) {
[...]
}
}
[...]

When I start a new editor it contains only the root element. What have I
to do that my model element is shown?
Greeting Mirco
Re: Starting with a non empty Editor [message #199695 is a reply to message #199687] Tue, 18 October 2005 13:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

Well, how about this:

protected void initializeGraphicalViewer()
{
getGraphicalViewer.setContents(getDiagram());
}

in YourEditorCalss.java :)

getDiagram() return diagram with elements in it.

Good luck ;)

Greg

Mirco Dunker wrote:
> Hello,
> I have a GEF-Tutorial that works fine and I can start with an empty
> editor so I can compose diagrams. But I want to start a non empty
> editor. If I create a new editor instance I want to have one of my
> model elements on this editor. But it doesn't work. My idear was to
> change this:
>
> public class MyGraphicalEditor extends GraphicalEditorWithPalette {
> [...]
> protected void setInput(IEditorInput input) {
> super.setInput(input);
> IFile file = (IFile) input.getAdapter(IResource.class);
> try {
> InputStream is = file.getContents();
> if (is.available() == 0) {
> rootElement = new RootElement();
> //Adding the model element that should be shown
> modelElement = new modelElement();
> rootElement.addModelElement(modelElement);
> } else {
> ObjectInputStream ois = new ObjectInputStream(is);
> rootElement = (RootElement) ois.readObject();
> }
> } catch (Exception e) {
> [...]
> }
> }
> [...]
>
> When I start a new editor it contains only the root element. What have
> I to do that my model element is shown?
> Greeting Mirco
Re: Starting with a non empty Editor [message #199703 is a reply to message #199695] Tue, 18 October 2005 13:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mirco.mirco-dunker.de

Hi Greg,
thx for your answer. At the moment I try this

protected void initializeGraphicalViewer() {
getGraphicalViewer().setEditPartFactory(new MyEditPartFactory());
getGraphicalViewer().setContents(rootElement);
}

Is this not correct?
Greeting Mirco

> Well, how about this:
>
> protected void initializeGraphicalViewer()
> {
> getGraphicalViewer.setContents(getDiagram());
> }
>
> in YourEditorCalss.java :)
>
> getDiagram() return diagram with elements in it.
>
> Good luck ;)
>
> Greg
>
> Mirco Dunker wrote:
>> Hello,
>> I have a GEF-Tutorial that works fine and I can start with an empty
>> editor so I can compose diagrams. But I want to start a non empty
>> editor. If I create a new editor instance I want to have one of my
>> model elements on this editor. But it doesn't work. My idear was to
>> change this:
>> public class MyGraphicalEditor extends GraphicalEditorWithPalette {
>> [...]
>> protected void setInput(IEditorInput input) {
>> super.setInput(input);
>> IFile file = (IFile) input.getAdapter(IResource.class);
>> try {
>> InputStream is = file.getContents();
>> if (is.available() == 0) {
>> rootElement = new RootElement();
>> //Adding the model element that should be shown
>> modelElement = new modelElement();
>> rootElement.addModelElement(modelElement);
>> } else {
>> ObjectInputStream ois = new ObjectInputStream(is);
>> rootElement = (RootElement) ois.readObject();
>> }
>> } catch (Exception e) {
>> [...]
>> }
>> }
>> [...]
>> When I start a new editor it contains only the root element. What have
>> I to do that my model element is shown?
>> Greeting Mirco



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Starting with a non empty Editor [message #199710 is a reply to message #199703] Tue, 18 October 2005 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

Well, EditPartFactory should be set in:

protected void configureGraphicalViewer()
{...}

rest of it is ok :)

Greg


Mirco Dunker wrote:
> Hi Greg,
> thx for your answer. At the moment I try this
>
> protected void initializeGraphicalViewer() {
> getGraphicalViewer().setEditPartFactory(new MyEditPartFactory());
> getGraphicalViewer().setContents(rootElement);
> }
>
> Is this not correct?
> Greeting Mirco
>
>> Well, how about this:
>>
>> protected void initializeGraphicalViewer()
>> {
>> getGraphicalViewer.setContents(getDiagram());
>> }
>>
>> in YourEditorCalss.java :)
>>
>> getDiagram() return diagram with elements in it.
>>
>> Good luck ;)
>>
>> Greg
>>
>> Mirco Dunker wrote:
>>
>>> Hello,
>>> I have a GEF-Tutorial that works fine and I can start with an empty
>>> editor so I can compose diagrams. But I want to start a non empty
>>> editor. If I create a new editor instance I want to have one of my
>>> model elements on this editor. But it doesn't work. My idear was to
>>> change this:
>>> public class MyGraphicalEditor extends GraphicalEditorWithPalette {
>>> [...]
>>> protected void setInput(IEditorInput input) {
>>> super.setInput(input);
>>> IFile file = (IFile) input.getAdapter(IResource.class);
>>> try {
>>> InputStream is = file.getContents();
>>> if (is.available() == 0) {
>>> rootElement = new RootElement();
>>> //Adding the model element that should be shown
>>> modelElement = new modelElement();
>>> rootElement.addModelElement(modelElement);
>>> } else {
>>> ObjectInputStream ois = new ObjectInputStream(is);
>>> rootElement = (RootElement) ois.readObject();
>>> }
>>> } catch (Exception e) {
>>> [...]
>>> }
>>> }
>>> [...]
>>> When I start a new editor it contains only the root element. What
>>> have I to do that my model element is shown?
>>> Greeting Mirco
>
>
>
>
Re: Starting with a non empty Editor [message #199726 is a reply to message #199710] Tue, 18 October 2005 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: mirco.mirco-dunker.de

Thank you very much!
Greetings Mirco

> Well, EditPartFactory should be set in:
>
> protected void configureGraphicalViewer()
> {...}
>
> rest of it is ok :)
>
> Greg
>
>
> Mirco Dunker wrote:
>> Hi Greg,
>> thx for your answer. At the moment I try this
>> protected void initializeGraphicalViewer() {
>> getGraphicalViewer().setEditPartFactory(new
>> MyEditPartFactory());
>> getGraphicalViewer().setContents(rootElement);
>> }
>> Is this not correct?
>> Greeting Mirco
>>
>>> Well, how about this:
>>>
>>> protected void initializeGraphicalViewer()
>>> {
>>> getGraphicalViewer.setContents(getDiagram());
>>> }
>>>
>>> in YourEditorCalss.java :)
>>>
>>> getDiagram() return diagram with elements in it.
>>>
>>> Good luck ;)
>>>
>>> Greg
>>>
>>> Mirco Dunker wrote:
>>>
>>>> Hello,
>>>> I have a GEF-Tutorial that works fine and I can start with an empty
>>>> editor so I can compose diagrams. But I want to start a non empty
>>>> editor. If I create a new editor instance I want to have one of my
>>>> model elements on this editor. But it doesn't work. My idear was to
>>>> change this:
>>>> public class MyGraphicalEditor extends GraphicalEditorWithPalette {
>>>> [...]
>>>> protected void setInput(IEditorInput input) {
>>>> super.setInput(input);
>>>> IFile file = (IFile) input.getAdapter(IResource.class);
>>>> try {
>>>> InputStream is = file.getContents();
>>>> if (is.available() == 0) {
>>>> rootElement = new RootElement();
>>>> //Adding the model element that should be shown
>>>> modelElement = new modelElement();
>>>> rootElement.addModelElement(modelElement);
>>>> } else {
>>>> ObjectInputStream ois = new ObjectInputStream(is);
>>>> rootElement = (RootElement) ois.readObject();
>>>> }
>>>> } catch (Exception e) {
>>>> [...]
>>>> }
>>>> }
>>>> [...]
>>>> When I start a new editor it contains only the root element. What
>>>> have I to do that my model element is shown?
>>>> Greeting Mirco
>>
Previous Topic:Drag and Drop from Package Explorer to an Editor
Next Topic:Cannot create children for topmost model element
Goto Forum:
  


Current Time: Thu Sep 19 10:51:56 GMT 2024

Powered by FUDForum. Page generated in 0.04255 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top