Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Open new Editor from Selected Figure
Open new Editor from Selected Figure [message #169552] Thu, 24 February 2005 12:11 Go to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Hey,

I have added a Figure (Composite) to my Editor that contains other figures
and whose purpose is to group figures together.
When I add these Figures to my Composite they reduce in size so that more
can be fit in.
If I then remove them from the the Composite they return to normal size for
easy editing
What I would like to do is be able to open another editor from the
Composite.
So for example say the Composite contains 3 figures. If I then double-click
on it I want to open a new Editor which then shows these three figures at
normal size for editing purposes.

Anybody done this already or have ideas on how this can be done ?

Thanks,
Alan.
Re: Open new Editor from Selected Figure [message #169866 is a reply to message #169552] Sun, 27 February 2005 22:58 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Your CompositeEditPart's performRequest() method will be invoked with
REQ_OPEN when the user double-clicks that part. You can launch another
Editor from there.

"Alan Morgan" <a.morgan@pilz.ie> wrote in message
news:cvkgbe$6kc$1@www.eclipse.org...
> Hey,
>
> I have added a Figure (Composite) to my Editor that contains other figures
> and whose purpose is to group figures together.
> When I add these Figures to my Composite they reduce in size so that more
> can be fit in.
> If I then remove them from the the Composite they return to normal size
for
> easy editing
> What I would like to do is be able to open another editor from the
> Composite.
> So for example say the Composite contains 3 figures. If I then
double-click
> on it I want to open a new Editor which then shows these three figures at
> normal size for editing purposes.
>
> Anybody done this already or have ideas on how this can be done ?
>
> Thanks,
> Alan.
>
>
Re: Open new Editor from Selected Figure [message #170010 is a reply to message #169866] Tue, 01 March 2005 11:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Thanks for that Pratik. That makes sense.

However I still have a further question if its not too much trouble.
How exactly do I launch another eidtor from there ?.
I have never launched an editor programmatically.

My plan was to call the Constructor and then call createPartControl which I
though would call configureGraphicalViewer() and
initializeGraphicalViewer().

I then got a NullPointerException during configureGraphicalViewer() as the
call to getSite() returned null.
At this point I'm a bit stuck.
Any help would be greatly appreciated.

Regards,
Alan.

"Pratik Shah" <ppshah@us.ibm.com> wrote in message
news:cvuk77$rei$6@www.eclipse.org...
> Your CompositeEditPart's performRequest() method will be invoked with
> REQ_OPEN when the user double-clicks that part. You can launch another
> Editor from there.
>
> "Alan Morgan" <a.morgan@pilz.ie> wrote in message
> news:cvkgbe$6kc$1@www.eclipse.org...
> > Hey,
> >
> > I have added a Figure (Composite) to my Editor that contains other
figures
> > and whose purpose is to group figures together.
> > When I add these Figures to my Composite they reduce in size so that
more
> > can be fit in.
> > If I then remove them from the the Composite they return to normal size
> for
> > easy editing
> > What I would like to do is be able to open another editor from the
> > Composite.
> > So for example say the Composite contains 3 figures. If I then
> double-click
> > on it I want to open a new Editor which then shows these three figures
at
> > normal size for editing purposes.
> >
> > Anybody done this already or have ideas on how this can be done ?
> >
> > Thanks,
> > Alan.
> >
> >
>
>
Re: Open new Editor from Selected Figure [message #170024 is a reply to message #170010] Tue, 01 March 2005 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Alan Morgan wrote:
> Thanks for that Pratik. That makes sense.
>
> However I still have a further question if its not too much trouble.
> How exactly do I launch another eidtor from there ?.
> I have never launched an editor programmatically.
>
> My plan was to call the Constructor and then call createPartControl which I
> though would call configureGraphicalViewer() and
> initializeGraphicalViewer().
>
> I then got a NullPointerException during configureGraphicalViewer() as the
> call to getSite() returned null.
> At this point I'm a bit stuck.
> Any help would be greatly appreciated.
>
> Regards,
> Alan.
>
>

if(RequestConstrants.REQ_OPEN.equals(request.getType())){

create a new IEditorInput and pass it into
IWorkbenchPage.openEditor(input,MyEditor.ID);

}


CL
Re: Open new Editor from Selected Figure [message #170040 is a reply to message #170024] Tue, 01 March 2005 12:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Thanks for the help CL.
I've added the check for REQ_OPEN in my performRequest method and I've
created a new IEditorInput.
But I'm stuck when it comes to the call to openEditor().
This method is not static and so I need a instance of IWorkbenchPage.
Maybe I'm missing something obvious but I can't see where I can get this.

Any thoughts ?

Thanks,
Alan.


"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:d01l9t$d36$1@www.eclipse.org...
> Alan Morgan wrote:
> > Thanks for that Pratik. That makes sense.
> >
> > However I still have a further question if its not too much trouble.
> > How exactly do I launch another eidtor from there ?.
> > I have never launched an editor programmatically.
> >
> > My plan was to call the Constructor and then call createPartControl
which I
> > though would call configureGraphicalViewer() and
> > initializeGraphicalViewer().
> >
> > I then got a NullPointerException during configureGraphicalViewer() as
the
> > call to getSite() returned null.
> > At this point I'm a bit stuck.
> > Any help would be greatly appreciated.
> >
> > Regards,
> > Alan.
> >
> >
>
> if(RequestConstrants.REQ_OPEN.equals(request.getType())){
>
> create a new IEditorInput and pass it into
> IWorkbenchPage.openEditor(input,MyEditor.ID);
>
> }
>
>
> CL
Re: Open new Editor from Selected Figure [message #170064 is a reply to message #170040] Tue, 01 March 2005 13:56 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
..getActivePage().openEditor(IEditorInput, Editor.ID);

Alan Morgan wrote:

> Thanks for the help CL.
> I've added the check for REQ_OPEN in my performRequest method and I've
> created a new IEditorInput.
> But I'm stuck when it comes to the call to openEditor().
> This method is not static and so I need a instance of IWorkbenchPage.
> Maybe I'm missing something obvious but I can't see where I can get this.
>
> Any thoughts ?
>[...]
Re: Open new Editor from Selected Figure [message #170079 is a reply to message #170064] Tue, 01 March 2005 14:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Fabian Wolf wrote:
> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> .getActivePage().openEditor(IEditorInput, Editor.ID);
>
> Alan Morgan wrote:
>
>
>>Thanks for the help CL.
>>I've added the check for REQ_OPEN in my performRequest method and I've
>>created a new IEditorInput.
>>But I'm stuck when it comes to the call to openEditor().
>>This method is not static and so I need a instance of IWorkbenchPage.
>>Maybe I'm missing something obvious but I can't see where I can get this.
>>
>>Any thoughts ?
>>[...]

be sure to check if getActivePage returns null. It shouldn't but i
think its possible. Maybe just an assert, but perhaps who needs an
assert on something that will throw an NPE right away.

CL
Re: Open new Editor from Selected Figure [message #170084 is a reply to message #170079] Tue, 01 March 2005 14:51 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
CL [dnoyeb] Gilbert wrote:

> Fabian Wolf wrote:
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
>> .getActivePage().openEditor(IEditorInput, Editor.ID);
>>
>> Alan Morgan wrote:
>>
>>
>>>Thanks for the help CL.
>>>I've added the check for REQ_OPEN in my performRequest method and I've
>>>created a new IEditorInput.
>>>But I'm stuck when it comes to the call to openEditor().
>>>This method is not static and so I need a instance of IWorkbenchPage.
>>>Maybe I'm missing something obvious but I can't see where I can get this.
>>>
>>>Any thoughts ?
>>>[...]
>
> be sure to check if getActivePage returns null. It shouldn't but i
> think its possible. Maybe just an assert, but perhaps who needs an
> assert on something that will throw an NPE right away.

Wasn't he trying to open the new editor from an existing one? If
getActivePage returns null there, you might be having more trouble than a
NPE ;)
Re: Open new Editor from Selected Figure [message #170091 is a reply to message #170064] Tue, 01 March 2005 15:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Thanks Fabian, that worked.

Now I've got one more (and hopefully last) question on this topic.
I was using an empty IEditorInput object up until now just to prove I could
launch another Editor using double-click.

What I want to be able to do is take the information contained within the
Composite figure that I am double-clicking on and pass this to the new
editor.
In other words the Composite I double click on contains e.g. three
figures,at a given size, location and possibly with connections bewteen each
other.
I want the new editor to display everything that was in this Composite
figure.
How do I go about doing this ?

Thanks,
Alan.



"Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
news:d01s9o$ho3$1@www.eclipse.org...
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> .getActivePage().openEditor(IEditorInput, Editor.ID);
>
> Alan Morgan wrote:
>
> > Thanks for the help CL.
> > I've added the check for REQ_OPEN in my performRequest method and I've
> > created a new IEditorInput.
> > But I'm stuck when it comes to the call to openEditor().
> > This method is not static and so I need a instance of IWorkbenchPage.
> > Maybe I'm missing something obvious but I can't see where I can get
this.
> >
> > Any thoughts ?
> >[...]
Re: Open new Editor from Selected Figure [message #170123 is a reply to message #170084] Tue, 01 March 2005 18:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Fabian Wolf wrote:
> CL [dnoyeb] Gilbert wrote:
>
>
>>Fabian Wolf wrote:
>>
>>>PlatformUI.getWorkbench().getActiveWorkbenchWindow()
>>>.getActivePage().openEditor(IEditorInput, Editor.ID);
>>>
>>>Alan Morgan wrote:
>>>
>>>
>>>
>>>>Thanks for the help CL.
>>>>I've added the check for REQ_OPEN in my performRequest method and I've
>>>>created a new IEditorInput.
>>>>But I'm stuck when it comes to the call to openEditor().
>>>>This method is not static and so I need a instance of IWorkbenchPage.
>>>>Maybe I'm missing something obvious but I can't see where I can get this.
>>>>
>>>>Any thoughts ?
>>>>[...]
>>
>>be sure to check if getActivePage returns null. It shouldn't but i
>>think its possible. Maybe just an assert, but perhaps who needs an
>>assert on something that will throw an NPE right away.
>
>
> Wasn't he trying to open the new editor from an existing one? If
> getActivePage returns null there, you might be having more trouble than a
> NPE ;)

I think thats a safe assumption. I kind of feel that way. But
technically he is opening his editor from an 'editpart' not an editor.
And you can assume if there is an edit part there must be an editor.
But I don't know what happens if an app is minimized, or if windows can
be hidden or anything. So i just checked for it. getActivePage just
says it may return null, but it does not say under what conditions there
can be no active page. And I have not had the energy to look.

CL
Re: Open new Editor from Selected Figure [message #170130 is a reply to message #170091] Tue, 01 March 2005 18:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Alan Morgan wrote:
> Thanks Fabian, that worked.
>
> Now I've got one more (and hopefully last) question on this topic.
> I was using an empty IEditorInput object up until now just to prove I could
> launch another Editor using double-click.
>
> What I want to be able to do is take the information contained within the
> Composite figure that I am double-clicking on and pass this to the new
> editor.
> In other words the Composite I double click on contains e.g. three
> figures,at a given size, location and possibly with connections bewteen each
> other.
> I want the new editor to display everything that was in this Composite
> figure.
> How do I go about doing this ?
>
> Thanks,
> Alan.
>
>
>

you should not be passing around or manipulating Composites or Figures.
You should be manipulating your models. The IEditorInput should
contain a light weight pointer to your model. It should not contain
the model itself. But to get you going quickly, you can just stuff the
model right into the IEditorInput based class you create.

In your editor, in the setEditorInput method or whatever its called, you
check with instanceof to see if its your type of IEditorInput and if so
you use it.

but again, a figure is just a way to show yoru model, but you should be
passing around and manipulating the model only.


CL
Re: Open new Editor from Selected Figure [message #170160 is a reply to message #170130] Wed, 02 March 2005 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

CL,

Thanks for the advice. I created an instance of IEditorInput and had it hold
an instance of my model.
In the setEditorInput method of my new Editor I take this model and load the
parts of it I need into the new editor.
Not sure if this is how I should be doing it but I guess it'll do for the
time being.
Not quite sure what you are referring to when you speak about IEditorInput
containing a light weight pointer to my model.

Anyway I now have a new editor which displays the contents of my Composite.
What I was hoping to do now was to have changes that I make reflected back
in the original editor.
So if I add and a new Figure in my new Editor this should appear in the
Composite figure in the original editor on save.
This means that I somehow need to be able to update the original Model from
my new Editor.
Not sure how to approach this...would I be better off using a Multipage
Editor here or can I manage this another way ?

Thanks again,
Alan.


"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:d02bql$46g$1@www.eclipse.org...
> Alan Morgan wrote:
> > Thanks Fabian, that worked.
> >
> > Now I've got one more (and hopefully last) question on this topic.
> > I was using an empty IEditorInput object up until now just to prove I
could
> > launch another Editor using double-click.
> >
> > What I want to be able to do is take the information contained within
the
> > Composite figure that I am double-clicking on and pass this to the new
> > editor.
> > In other words the Composite I double click on contains e.g. three
> > figures,at a given size, location and possibly with connections bewteen
each
> > other.
> > I want the new editor to display everything that was in this Composite
> > figure.
> > How do I go about doing this ?
> >
> > Thanks,
> > Alan.
> >
> >
> >
>
> you should not be passing around or manipulating Composites or Figures.
> You should be manipulating your models. The IEditorInput should
> contain a light weight pointer to your model. It should not contain
> the model itself. But to get you going quickly, you can just stuff the
> model right into the IEditorInput based class you create.
>
> In your editor, in the setEditorInput method or whatever its called, you
> check with instanceof to see if its your type of IEditorInput and if so
> you use it.
>
> but again, a figure is just a way to show yoru model, but you should be
> passing around and manipulating the model only.
>
>
> CL
Re: Open new Editor from Selected Figure [message #170168 is a reply to message #170160] Wed, 02 March 2005 11:18 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
Alan Morgan wrote:

> CL,
>
> Thanks for the advice. I created an instance of IEditorInput and had it
> hold an instance of my model.
> In the setEditorInput method of my new Editor I take this model and load
> the parts of it I need into the new editor.
> Not sure if this is how I should be doing it but I guess it'll do for the
> time being.
> Not quite sure what you are referring to when you speak about IEditorInput
> containing a light weight pointer to my model.

see below...

> Anyway I now have a new editor which displays the contents of my
> Composite. What I was hoping to do now was to have changes that I make
> reflected back in the original editor.
> So if I add and a new Figure in my new Editor this should appear in the
> Composite figure in the original editor on save.
> This means that I somehow need to be able to update the original Model
> from my new Editor.

This is were the suggested pointer comes into play. You modify the model
inside your new editor and what you're actually doing is modiyfing the one
and only existing model you passed as a pointer - I guess the word pointer
might be somewhat confusing...
Just don't instantiate a new model object, when you pass your old model it
should be passed by reference (since no primitive type) and should therefor
be used in both of your editors.

> Not sure how to approach this...would I be better off using a Multipage
> Editor here or can I manage this another way ?

Don't use it ;) Me and others were having far to many problems with it,...
see some pending bugs ("combine and compose nested workbench parts.").
....unless you plan on spending a lot of time working around them.

HTH

Fabian
Re: Open new Editor from Selected Figure [message #170184 is a reply to message #170168] Wed, 02 March 2005 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Fabian,

Thanks very much for that - once I started using the Model object that was
passed as is, it worked like a treat.
Now I understand what CL was trying to tell me.

Right I'll avoid the Multi Page Editor for the time being then.
Out of interest does this warning extend to FormEditors ?
Cause I was kinda thinking of doing something along the lines of the
plugin.xml multi-pager ?

Thanks again for all your help.
You too CL.

Alan.




"Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
news:d047ej$g00$1@www.eclipse.org...
> Alan Morgan wrote:
>
> > CL,
> >
> > Thanks for the advice. I created an instance of IEditorInput and had it
> > hold an instance of my model.
> > In the setEditorInput method of my new Editor I take this model and load
> > the parts of it I need into the new editor.
> > Not sure if this is how I should be doing it but I guess it'll do for
the
> > time being.
> > Not quite sure what you are referring to when you speak about
IEditorInput
> > containing a light weight pointer to my model.
>
> see below...
>
> > Anyway I now have a new editor which displays the contents of my
> > Composite. What I was hoping to do now was to have changes that I make
> > reflected back in the original editor.
> > So if I add and a new Figure in my new Editor this should appear in the
> > Composite figure in the original editor on save.
> > This means that I somehow need to be able to update the original Model
> > from my new Editor.
>
> This is were the suggested pointer comes into play. You modify the model
> inside your new editor and what you're actually doing is modiyfing the one
> and only existing model you passed as a pointer - I guess the word pointer
> might be somewhat confusing...
> Just don't instantiate a new model object, when you pass your old model it
> should be passed by reference (since no primitive type) and should
therefor
> be used in both of your editors.
>
> > Not sure how to approach this...would I be better off using a Multipage
> > Editor here or can I manage this another way ?
>
> Don't use it ;) Me and others were having far to many problems with it,...
> see some pending bugs ("combine and compose nested workbench parts.").
> ...unless you plan on spending a lot of time working around them.
>
> HTH
>
> Fabian
Re: Open new Editor from Selected Figure [message #170192 is a reply to message #170184] Wed, 02 March 2005 16:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Alan Morgan wrote:
> Fabian,
>
> Thanks very much for that - once I started using the Model object that was
> passed as is, it worked like a treat.
> Now I understand what CL was trying to tell me.
>
> Right I'll avoid the Multi Page Editor for the time being then.
> Out of interest does this warning extend to FormEditors ?
> Cause I was kinda thinking of doing something along the lines of the
> plugin.xml multi-pager ?
>
> Thanks again for all your help.
> You too CL.
>
> Alan.
>


Also that the IEditorparts are stored inside the eclipse architecture,
so they should be light weight. But its quite complicated to pass a
light weight IEditorInput for this purpose. As long as your IEditorInput
is not IPersistable I don't think it will matter.

Otherwise eclipse will try to keep your ieditor input so it can list
your file in the files menu to allow it to be opened from a shortcut
listed there.

CL
Re: Open new Editor from Selected Figure [message #170209 is a reply to message #170184] Wed, 02 March 2005 17:18 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
Alan Morgan wrote:

> Fabian,
>
> Thanks very much for that - once I started using the Model object that was
> passed as is, it worked like a treat.
> Now I understand what CL was trying to tell me.
>
> Right I'll avoid the Multi Page Editor for the time being then.
> Out of interest does this warning extend to FormEditors ?
> Cause I was kinda thinking of doing something along the lines of the
> plugin.xml multi-pager ?


Try it and tell us ;)
Well, to be honest, I think those problems arise as soon as you try to show
more than one editor inside another one. The platform wasn't designed to do
that,... but it's supposed to get fixed. Don't know when though.

If the other pages you try to show inside the FormEditor or
MultiPageEditorPart are not EditorParts,.. then there should be no real
problem.

Fabian
Re: Open new Editor from Selected Figure [message #170936 is a reply to message #170123] Tue, 08 March 2005 05:25 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
When the workbench is launched, the active page is null until after any open
editors have been created. I believe there's a bug open regarding this.

"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:d02bgh$1vp$1@www.eclipse.org...
> Fabian Wolf wrote:
> > CL [dnoyeb] Gilbert wrote:
> >
> >
> >>Fabian Wolf wrote:
> >>
> >>>PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> >>>.getActivePage().openEditor(IEditorInput, Editor.ID);
> >>>
> >>>Alan Morgan wrote:
> >>>
> >>>
> >>>
> >>>>Thanks for the help CL.
> >>>>I've added the check for REQ_OPEN in my performRequest method and I've
> >>>>created a new IEditorInput.
> >>>>But I'm stuck when it comes to the call to openEditor().
> >>>>This method is not static and so I need a instance of IWorkbenchPage.
> >>>>Maybe I'm missing something obvious but I can't see where I can get
this.
> >>>>
> >>>>Any thoughts ?
> >>>>[...]
> >>
> >>be sure to check if getActivePage returns null. It shouldn't but i
> >>think its possible. Maybe just an assert, but perhaps who needs an
> >>assert on something that will throw an NPE right away.
> >
> >
> > Wasn't he trying to open the new editor from an existing one? If
> > getActivePage returns null there, you might be having more trouble than
a
> > NPE ;)
>
> I think thats a safe assumption. I kind of feel that way. But
> technically he is opening his editor from an 'editpart' not an editor.
> And you can assume if there is an edit part there must be an editor.
> But I don't know what happens if an app is minimized, or if windows can
> be hidden or anything. So i just checked for it. getActivePage just
> says it may return null, but it does not say under what conditions there
> can be no active page. And I have not had the energy to look.
>
> CL
Previous Topic:Properties on EditPart instead of model
Next Topic:[Draw2d] Can we draw a dot line in draw2d
Goto Forum:
  


Current Time: Thu Apr 25 16:18:14 GMT 2024

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

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

Back to the top