Starting with a non empty Editor [message #199687] |
Tue, 18 October 2005 13:21 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04255 seconds