Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Editor and multiple editor input
Editor and multiple editor input [message #121782] Wed, 03 September 2003 05:39 Go to next message
Eclipse UserFriend
Originally posted by: didier.besset.ch.sogeti.biz

The editor I am working on is editing a group of files as one unit. One of
the files for the set is the "main" file and is set to the editor input
when an editor is openeed an any of the other files.

The problem occurs when one opens a file for that set other than the
"main" file, a new editor is opened because the algorithm determining what
is the editor input (IEditorInput) is within the editor itself.

Questions: Is there a way to tell Eclipse that the editor input is a set
of files (but better than a folder since the files can be located
anywhere)? Alternatively, is there a way to notify within the method
init(IEditorSite,IEditorInput) that no new instance must be created and
control should be passed to another instance of the same editor?

Cheers,

Didier
Re: Editor and multiple editor input [message #122179 is a reply to message #121782] Wed, 03 September 2003 11:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

When the workbench page is asked to open an editor on an IEditorInput, it
check first if there is already an open editor for this input. The workbench
page uses "equals()" method to determine if the new input matches an
existing editor input. The code is something like this:

openEditor(IEditorInput input, ...) {
...
Iterator editors = getOpenEditors();
while (editors.hasNext()) {
IEditorPart editor = (IEditorPart) editors.next();
if (input.equals(editor.getInput())
...

Simon :-)

PS By the way, are you saying that in your init method, you ignore the
IEditorInput you were passed and instead create your own on this "main
file"? That is not part of the init method contract.


"Didier Besset" <didier.besset@ch.sogeti.biz> wrote in message
news:bj4ctd$na$1@eclipse.org...
> The editor I am working on is editing a group of files as one unit. One of
> the files for the set is the "main" file and is set to the editor input
> when an editor is openeed an any of the other files.
>
> The problem occurs when one opens a file for that set other than the
> "main" file, a new editor is opened because the algorithm determining what
> is the editor input (IEditorInput) is within the editor itself.
>
> Questions: Is there a way to tell Eclipse that the editor input is a set
> of files (but better than a folder since the files can be located
> anywhere)? Alternatively, is there a way to notify within the method
> init(IEditorSite,IEditorInput) that no new instance must be created and
> control should be passed to another instance of the same editor?
>
> Cheers,
>
> Didier
>
Re: Editor and multiple editor input [message #122493 is a reply to message #122179] Thu, 04 September 2003 03:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: didier.besset.ch.sogeti.biz

Thanks for the reply!

Actually, I do use the "IEditorInput [I]were passed", but I then change it
with the following two lines of code:
setInput( new FileEditorInput( model.getResourceFile()));
firePropertyChange( PROP_INPUT);
(the "model" has been constructed from the IEditorInput passed and has
determined what is the "main" file to edit.

Following your suggestions, I made a class to wrap FileEditorInput and
added a suitable equals method. However, this method is called after the
window is opened, so that I still end up with two editor windows.

Any more suggestions?

Cheers,

Didier


Simon Arsenault wrote:

> When the workbench page is asked to open an editor on an IEditorInput, it
> check first if there is already an open editor for this input. The workbench
> page uses "equals()" method to determine if the new input matches an
> existing editor input. The code is something like this:

> openEditor(IEditorInput input, ...) {
> ...
> Iterator editors = getOpenEditors();
> while (editors.hasNext()) {
> IEditorPart editor = (IEditorPart) editors.next();
> if (input.equals(editor.getInput())
> ...

> Simon :-)

> PS By the way, are you saying that in your init method, you ignore the
> IEditorInput you were passed and instead create your own on this "main
> file"? That is not part of the init method contract.


> "Didier Besset" <didier.besset@ch.sogeti.biz> wrote in message
> news:bj4ctd$na$1@eclipse.org...
> > The editor I am working on is editing a group of files as one unit. One of
> > the files for the set is the "main" file and is set to the editor input
> > when an editor is openeed an any of the other files.
> >
> > The problem occurs when one opens a file for that set other than the
> > "main" file, a new editor is opened because the algorithm determining what
> > is the editor input (IEditorInput) is within the editor itself.
> >
> > Questions: Is there a way to tell Eclipse that the editor input is a set
> > of files (but better than a folder since the files can be located
> > anywhere)? Alternatively, is there a way to notify within the method
> > init(IEditorSite,IEditorInput) that no new instance must be created and
> > control should be passed to another instance of the same editor?
> >
> > Cheers,
> >
> > Didier
> >
Re: Editor and multiple editor input [message #122713 is a reply to message #122493] Thu, 04 September 2003 11:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

A new editor is open only is none of the existing editor inputs do not
"equals()" the new input. There must be something else going on.

Simon :-)

"Didier Besset" <didier.besset@ch.sogeti.biz> wrote in message
news:bj6o4t$b32$1@eclipse.org...
> Thanks for the reply!
>
> Actually, I do use the "IEditorInput [I]were passed", but I then change it
> with the following two lines of code:
> setInput( new FileEditorInput( model.getResourceFile()));
> firePropertyChange( PROP_INPUT);
> (the "model" has been constructed from the IEditorInput passed and has
> determined what is the "main" file to edit.
>
> Following your suggestions, I made a class to wrap FileEditorInput and
> added a suitable equals method. However, this method is called after the
> window is opened, so that I still end up with two editor windows.
>
> Any more suggestions?
>
> Cheers,
>
> Didier
>
>
> Simon Arsenault wrote:
>
> > When the workbench page is asked to open an editor on an IEditorInput,
it
> > check first if there is already an open editor for this input. The
workbench
> > page uses "equals()" method to determine if the new input matches an
> > existing editor input. The code is something like this:
>
> > openEditor(IEditorInput input, ...) {
> > ...
> > Iterator editors = getOpenEditors();
> > while (editors.hasNext()) {
> > IEditorPart editor = (IEditorPart) editors.next();
> > if (input.equals(editor.getInput())
> > ...
>
> > Simon :-)
>
> > PS By the way, are you saying that in your init method, you ignore the
> > IEditorInput you were passed and instead create your own on this "main
> > file"? That is not part of the init method contract.
>
>
> > "Didier Besset" <didier.besset@ch.sogeti.biz> wrote in message
> > news:bj4ctd$na$1@eclipse.org...
> > > The editor I am working on is editing a group of files as one unit.
One of
> > > the files for the set is the "main" file and is set to the editor
input
> > > when an editor is openeed an any of the other files.
> > >
> > > The problem occurs when one opens a file for that set other than the
> > > "main" file, a new editor is opened because the algorithm determining
what
> > > is the editor input (IEditorInput) is within the editor itself.
> > >
> > > Questions: Is there a way to tell Eclipse that the editor input is a
set
> > > of files (but better than a folder since the files can be located
> > > anywhere)? Alternatively, is there a way to notify within the method
> > > init(IEditorSite,IEditorInput) that no new instance must be created
and
> > > control should be passed to another instance of the same editor?
> > >
> > > Cheers,
> > >
> > > Didier
> > >
>
>
Re: Editor and multiple editor input [message #123010 is a reply to message #122179] Fri, 05 September 2003 09:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: glongman.intelligentworks.nospam.com

Since this topic is close to a question I've had for a while...

Is there an implementation of MultiEditor out there one can look at?

And

Is there any way to intercept the openEditor() call and tweak the input?

I ask as I would be pleased as punch if my plugin could intercept the call,
examine its state and the input itself, then insome cases turn the input
into a MultiEditor input.

We have a similar case of related files and a MultiEditor (if I understand
it right) would be an excellent tool to use.

Geoff

"Simon Arsenault" <simon@ibm.oti.lab> wrote in message
news:bj50ks$nts$1@eclipse.org...
> When the workbench page is asked to open an editor on an IEditorInput, it
> check first if there is already an open editor for this input. The
workbench
> page uses "equals()" method to determine if the new input matches an
> existing editor input. The code is something like this:
>
> openEditor(IEditorInput input, ...) {
> ...
> Iterator editors = getOpenEditors();
> while (editors.hasNext()) {
> IEditorPart editor = (IEditorPart) editors.next();
> if (input.equals(editor.getInput())
> ...
>
> Simon :-)
Re: Editor and multiple editor input [message #123087 is a reply to message #123010] Fri, 05 September 2003 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

No and No

Simon :-)

"G Longman" <glongman@intelligentworks.nospam.com> wrote in message
news:bja4me$h66$1@eclipse.org...
> Since this topic is close to a question I've had for a while...
>
> Is there an implementation of MultiEditor out there one can look at?
>
> And
>
> Is there any way to intercept the openEditor() call and tweak the input?
>
> I ask as I would be pleased as punch if my plugin could intercept the
call,
> examine its state and the input itself, then insome cases turn the input
> into a MultiEditor input.
>
> We have a similar case of related files and a MultiEditor (if I understand
> it right) would be an excellent tool to use.
>
> Geoff
>
> "Simon Arsenault" <simon@ibm.oti.lab> wrote in message
> news:bj50ks$nts$1@eclipse.org...
> > When the workbench page is asked to open an editor on an IEditorInput,
it
> > check first if there is already an open editor for this input. The
> workbench
> > page uses "equals()" method to determine if the new input matches an
> > existing editor input. The code is something like this:
> >
> > openEditor(IEditorInput input, ...) {
> > ...
> > Iterator editors = getOpenEditors();
> > while (editors.hasNext()) {
> > IEditorPart editor = (IEditorPart) editors.next();
> > if (input.equals(editor.getInput())
> > ...
> >
> > Simon :-)
>
>
>
Re: Editor and multiple editor input [message #123335 is a reply to message #123087] Fri, 05 September 2003 15:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: glongman.intelligentworks.nospam.com

> No and No
>
> Simon :-)
>

Why not? and I'll add a feature request!

Geoff
Re: Editor and multiple editor input [message #123348 is a reply to message #123335] Fri, 05 September 2003 15:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

I do not know why. Open a feature request...

Simon :-)

"G Longman" <glongman@intelligentworks.nospam.com> wrote in message
news:bjan6n$4m9$1@eclipse.org...
>
> > No and No
> >
> > Simon :-)
> >
>
> Why not? and I'll add a feature request!
>
> Geoff
>
>
Re: Editor and multiple editor input [message #123558 is a reply to message #123335] Sat, 06 September 2003 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

You might search for an existing one. I think this is a perennial request.

Bob

"G Longman" <glongman@intelligentworks.nospam.com> wrote in message
news:bjan6n$4m9$1@eclipse.org...
>
> > No and No
> >
> > Simon :-)
> >
>
> Why not? and I'll add a feature request!
>
> Geoff
>
>
Re: Editor and multiple editor input [message #123571 is a reply to message #122713] Sat, 06 September 2003 05:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: didier.besset.ch.sogeti.biz

Sorry to insist, but have you tried this?

The code checking for equals get called indeed and it returns true.
Nevertheless the editor is opened again. So I am at a loss here. Actually,
if I can believe the print outs I peppered my code with orthe debugger, it
appears that the new editor is opened ***before*** the check for equality
between two IEditorInput is performed. There must be something to be done
before that...

Would you have a code example I can borrow and try out?

Has anyone have this problem before?

Cheers,

Didier

Simon Arsenault wrote:

> A new editor is open only is none of the existing editor inputs do not
> "equals()" the new input. There must be something else going on.

> Simon :-)
Re: Editor and multiple editor input [message #123613 is a reply to message #123558] Sat, 06 September 2003 16:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: glongman.intelligentworks.nospam.com

I did (search for MultiEditor in bug comments), and found 19 bugs related.
Of the 19, two are mine, one refers to MultiEditorPage (not the same thing)
and four more are only peripherally related. The remainder are reported by
ibm/oti people who obviously are "in the know".

One is interesting as it refers to a "Sample MultiEditor page". Where is
this sample?!?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=14408


Geoff


"Bob Foster" <bob@objfac.com> wrote in message
news:bjc766$5qr$1@eclipse.org...
> You might search for an existing one. I think this is a perennial request.
>
> Bob
>
> "G Longman" <glongman@intelligentworks.nospam.com> wrote in message
> news:bjan6n$4m9$1@eclipse.org...
> >
> > > No and No
> > >
> > > Simon :-)
> > >
> >
> > Why not? and I'll add a feature request!
> >
> > Geoff
> >
> >
>
>
Re: Editor and multiple editor input [message #125497 is a reply to message #123571] Tue, 09 September 2003 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

The code works - otherwise, you would see this problem with the java editor,
pde editor, etc

I suggest you step thru the code using the debugger to understand what is
going wrong. At very least, but a breakpoint in the equals() method to see
if the inputs being compared are yours. Also a breakpoint in your init
method of you editor to see on the stack who is calling it (i.e is it coming
from the openEditor() method), and what is the input being passed in (is it
yours)

Simon :-)

"Didier Besset" <didier.besset@ch.sogeti.biz> wrote in message
news:bjc8bl$6hr$1@eclipse.org...
> Sorry to insist, but have you tried this?
>
> The code checking for equals get called indeed and it returns true.
> Nevertheless the editor is opened again. So I am at a loss here. Actually,
> if I can believe the print outs I peppered my code with orthe debugger, it
> appears that the new editor is opened ***before*** the check for equality
> between two IEditorInput is performed. There must be something to be done
> before that...
>
> Would you have a code example I can borrow and try out?
>
> Has anyone have this problem before?
>
> Cheers,
>
> Didier
>
> Simon Arsenault wrote:
>
> > A new editor is open only is none of the existing editor inputs do not
> > "equals()" the new input. There must be something else going on.
>
> > Simon :-)
>
>
>
Re: Editor and multiple editor input [message #125575 is a reply to message #125497] Tue, 09 September 2003 11:02 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.NOSPAM.us.ibm.com

I don't know if this has anything to do with it but I think the
comparison using the equals may be backwards for your request.

Looking through the code EditorManager.findEditor(IEditorInput input),
which is used when seeing if an editor for "input" is already open. In
there the comparison is
input.equals(editorpart.getEditorInput())

From your description, the customized editor input is on the EditorPart
side of the equation. So in this compare it won't use your equals, but
instead uses the equals from the incoming IEditorInput, which is just a
standard IFileEditorInput.

Rich
Previous Topic:Opening a perspective (programmatically)
Next Topic:ResourceListSelectionDialog
Goto Forum:
  


Current Time: Tue Jul 22 19:47:25 EDT 2025

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

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

Back to the top