Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » open an object with an editor
open an object with an editor [message #318253] Tue, 24 July 2007 02:55 Go to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

If I got an object suppose with two int values. Is it poosible to open it with an editor? I have only found examples where it's files that opens with editors.


ISelection sel = viewer.getSeclection();
Object obj = ((IStructuredSelection)selection).getFirstElement();
...
openEditorOnObject(obj) //??? this don't exist

Someone have any ide?
Re: open an object with an editor [message #318267 is a reply to message #318253] Tue, 24 July 2007 06:57 Go to previous messageGo to next message
Eclipse UserFriend
karl wrote:
> If I got an object suppose with two int values. Is it poosible to open it with an editor? I have only found examples where it's files that opens with editors.

The framework would need to know what editor to open it with / what kind
of input the editor should be taking in. If I passed in an ArrayList to
the Eclipes Platform, how would it know how to display this? The Eclipse
Platform is great but it's not psychic.

Regards,
Rem
Re: open an object with an editor [message #318276 is a reply to message #318253] Tue, 24 July 2007 09:29 Go to previous messageGo to next message
Eclipse UserFriend
Karl, you would need to create an IEditorInput that could tell your
editor how to open on the selected value.

Then you just use IWorkbenchPage#openEditor(*). It takes the editor ID
and the IEditorInput.

Later,
PW
Re: open an object with an editor [message #318297 is a reply to message #318276] Wed, 25 July 2007 02:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Thanks a lot. I made a class that implements IEditorInput and that works fine.

Another thing now is that if I open the same object two times it's open an new editor instead of setting focus on the editor that already exists.
Re: open an object with an editor [message #318320 is a reply to message #318297] Wed, 25 July 2007 14:12 Go to previous messageGo to next message
Eclipse UserFriend
karl wrote:
> Thanks a lot. I made a class that implements IEditorInput and that works fine.
>
> Another thing now is that if I open the same object two times it's open an new editor instead of setting focus on the editor that already exists.

Does your editor input override equals(*) and hashCode()?

PW
Re: open an object with an editor [message #318343 is a reply to message #318320] Thu, 26 July 2007 02:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Yes my editor input is override equals(*) and hashCode. I let eclipse generate the code:

@Override
public int hashCode(){
final int prime = 31;
int result = 1;
result = prime * result + ((viewer == null) ? 0: viewer.hasCode());
return result;
}

@Override
public boolean equals(Object obj){
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final MyClass other = (MyClass) obj;
if(viewer == null){
if(other.viewer != null)
return false;
else if (viewer.equals(other.viewer))
return false;
return true;
}
}
return false;
return true;
}


// in configureGraphivalViewer()
viewer = getGraphicalViewer();
Re: open an object with an editor [message #318469 is a reply to message #318343] Mon, 30 July 2007 12:11 Go to previous messageGo to next message
Eclipse UserFriend
karl wrote:
> Yes my editor input is override equals(*) and hashCode. I let eclipse generate the code:

And do both of these methods generate the same values for the 2 "equal"
editor inputs? I'm just wondering what viewer is doing there?


Later,
PW
Re: open an object with an editor [message #318737 is a reply to message #318469] Fri, 03 August 2007 07:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

nope they don't generate the same value. what should I use instead of viewer?
Re: open an object with an editor [message #318816 is a reply to message #318737] Tue, 07 August 2007 09:28 Go to previous message
Eclipse UserFriend
karl wrote:
> nope they don't generate the same value. what should I use instead of viewer?

just use whatever it takes for the 2 IEditorInputs to be equal ...
editor inputs are abstract representations of an editor input ... like
java.io.File or an string path or a string key.

For example if your IEditorInput was just a string key, you would check
that those members are equal.

Later,
PW
Previous Topic:Re: How to wrap an editorContribution in an actionSet?
Next Topic:installing platform and plugins in a simlinked directory
Goto Forum:
  


Current Time: Fri Sep 19 04:24:25 EDT 2025

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

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

Back to the top