Skip to main content



      Home
Home » Newcomers » Newcomers » open an editor on an instance for a class
open an editor on an instance for a class [message #221873] Tue, 17 July 2007 07:14 Go to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

Trying to open an editor on an instance for a class. I've looked at
http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_on_somet hing_that_is_not_a_file%3F

I can't see the connection. How does I got the editorclass to find
instance from the class I want to open it on? It's opening a new Editor,
but it's empty and I don't se how the editor can get access to the
instance.


/**
* CLASS 1
*/
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection)selection).getFirstElement());

IWorkbenchWindow window =
PLtformUI.getWorkbench().getActiveWorkbenchWindow();
String string = obj.toString();
IStorage storage = new StringStorage(string);
IStorageEditorInput input = new StringInput(storage);
IWorkbenchPage page = window.getActivePage();
if (page != null)
page.openEditor(input, "editor.Editor");


/*
* CLASS EDITOR ???
*/
protected void initializeGraphicalViewer(){
System.out.println(""); //ok here I'm
getGraphicalViewer().setContents( ???);
}
Re: open an editor on an instance for a class [message #222116 is a reply to message #221873] Wed, 18 July 2007 06:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

If i'm trying to get some value from the object in class 1. Thats working
good.

MyClass class = (MyClass) obj;
System.out.println(class.getValue()); // give me the right value.

But when I'. trying to get the value from the object I don't know what to
do.

The code

GraphicalViewer v = getGraphicalViewer();
System.out.println(v.getContents()) // give me null.

Anyone knows what the problem could be?
Re: open an editor on an instance for a class [message #222671 is a reply to message #221873] Thu, 19 July 2007 08:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

someone please?
Re: open an editor on an instance for a class [message #222676 is a reply to message #222671] Thu, 19 July 2007 08:20 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Karl,

I suspect no one really understands what you are trying to do. I'm
kind of assuming you want the editor to edit the actual object you've
selected; but all you've done is call toString on it and pass that along
which seems unlikely to be close to a desirable result. You could
implement your own derived type of IEditorInput that wraps the actual
object. Then in your editor's init method or when you call
getEditorInput, you can check for your special type of input and unwrap
it to get at your actual object. I'm not sure how save and all that
will work for you, but that's the only way I can imagine passing long
the actual object you have in the view to your editor.


karl wrote:
> someone please?
>
Previous Topic:How to group features hierarchically
Next Topic:Eclipse & Web Logic
Goto Forum:
  


Current Time: Wed Jul 23 05:02:07 EDT 2025

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

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

Back to the top