Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Treeviewer and Editing Objects (Newbie)
Treeviewer and Editing Objects (Newbie) [message #462717] Tue, 18 October 2005 03:55 Go to next message
J. Michael Dean, M.D. is currently offline J. Michael Dean, M.D.Friend
Messages: 218
Registered: July 2009
Senior Member
I have a TreeViewer that navigates an object hierarchy that is not file
based. I have context popup menus for the various objects (which are
different in type as we go down the hierarchy), and for each object type I
want to open an editor (probably FormToolkit derived). But I have NO CLUE
how to open an editor that is based on an Iselection object rather than on a
file type. Any suggestions would be greatly appreciated.
Re: Treeviewer and Editing Objects (Newbie) [message #462721 is a reply to message #462717] Tue, 18 October 2005 07:42 Go to previous messageGo to next message
Tim Shelley is currently offline Tim ShelleyFriend
Messages: 60
Registered: July 2009
Member
Hi,

You will need to implement org.eclipse.ui.IEditorInput for the objects in
your tree. I usually set my viewer to listen to double clicks and then call:

PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().openEditor(new myEditrInput(), "editor.id", true);

Regards,

Tim.

"J Michael Dean" <mdean77@comcast.net> wrote in message
news:BF79CE67.EE44%mdean77@comcast.net...
>I have a TreeViewer that navigates an object hierarchy that is not file
> based. I have context popup menus for the various objects (which are
> different in type as we go down the hierarchy), and for each object type I
> want to open an editor (probably FormToolkit derived). But I have NO CLUE
> how to open an editor that is based on an Iselection object rather than on
> a
> file type. Any suggestions would be greatly appreciated.
>
Re: Treeviewer and Editing Objects (Newbie) [message #462726 is a reply to message #462717] Tue, 18 October 2005 10:37 Go to previous message
James Leotta is currently offline James LeottaFriend
Messages: 202
Registered: July 2009
Senior Member
J Michael Dean wrote:
> I have a TreeViewer that navigates an object hierarchy that is not file
> based. I have context popup menus for the various objects (which are
> different in type as we go down the hierarchy), and for each object type I
> want to open an editor (probably FormToolkit derived). But I have NO CLUE
> how to open an editor that is based on an Iselection object rather than on a
> file type. Any suggestions would be greatly appreciated.
>

I used this code for the listener:

treeViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
IStructuredSelection selection = (IStructuredSelection)
treeViewer.getSelection();
getEditor(selection.getFirstElement());
}
});


And this code for opending the editor:


public void getEditor(Object obj){
String editorID = null;
IEditorPart editor = null;
IEditorInput input = null;
if (obj instanceof Agency){
input = new AgencyEditorInput((Agency) obj);
editorID = AgencyEditor.ID;
}
if (obj instanceof AMITables){
//input = new AgencyEditorInput((Agency) obj);
//editorID = AgencyEditor.ID;
}
if (obj instanceof Grant){
input = new GrantEditorInput((Grant) obj);
editorID = GrantEditor.ID;
}
if (obj instanceof Employee){
input = new StaffEditorInput((Employee) obj);
editorID = StaffEditor.ID;
}
if (obj instanceof County){

}
if (obj instanceof User){
input = new UserEditorInput((User) obj);
editorID = UserEditor.ID;
}
editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findEditor(input);
if (editor != null){

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().activate(editor);
return;
}
try{

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().openEditor(input,
editorID);
}catch(Exception e){
System.out.println(e);
}
}
Previous Topic:Isnt this supported
Next Topic:Widget disposed exception after Ok?
Goto Forum:
  


Current Time: Fri Apr 26 11:29:48 GMT 2024

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

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

Back to the top