Editor and multiple editor input [message #121782] |
Wed, 03 September 2003 05:39  |
Eclipse User |
|
|
|
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 #122493 is a reply to message #122179] |
Thu, 04 September 2003 03:03   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #125497 is a reply to message #123571] |
Tue, 09 September 2003 10:42   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.05333 seconds