Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to create a new Part Dynamically
How to create a new Part Dynamically [message #508136] Sat, 16 January 2010 13:32 Go to next message
Walter Mising name is currently offline Walter Mising name
Messages: 126
Registered: July 2009
Senior Member
Hi,

When a menu item is clicked, how to create a new Part programmatically.
I have the following in my xmi file

PartSashContainer
PartStack
Part - "WatchList"
Sash
PartStack
Part - "Chart"

During the run time when the user clicks "NewWatchList" ( DirectToolItem )
I would like to create and show a new Part along with "WatchList" Part. The
result similar to the following entry in xmi file.

PartSashContainer
PartStack
Part - "WatchList"
Part - "NewWatchList"
Sash
PartStack
Part - "Chart"

I am clue less on how to achieve this. FYI, I am using M3.

Best Regards,
Walter G. Prabhakar.

[Updated on: Mon, 18 January 2010 09:59]

Report message to a moderator

Re: How to new Part Dynamically [message #508351 is a reply to message #508136] Mon, 18 January 2010 14:12 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can add a PartDescriptor in M3, and then use the
EPartService#showView(*) to show it (similar to IWorkbenchPage#showView(*)).

Or you can find your PartStack and use
org.eclipse.e4.ui.model.application.MApplicationFactory to create the
appropriate new MPart, then add it as a child or your PartStack.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How to new Part Dynamically [message #508472 is a reply to message #508351] Tue, 19 January 2010 05:07 Go to previous messageGo to next message
Walter Mising name is currently offline Walter Mising name
Messages: 126
Registered: July 2009
Senior Member
How do I locate the PartStack ?
Re: How to new Part Dynamically [message #508528 is a reply to message #508472] Tue, 19 January 2010 10:30 Go to previous messageGo to next message
Jens Keller is currently offline Jens Keller
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
You can use the IEclipseContext for this:

MPartStack sampleStack = (MPartStack) context.get( "sampleStackID" );



Jens Keller
Re: How to new Part Dynamically [message #567699 is a reply to message #508136] Mon, 18 January 2010 14:12 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can add a PartDescriptor in M3, and then use the
EPartService#showView(*) to show it (similar to IWorkbenchPage#showView(*)).

Or you can find your PartStack and use
org.eclipse.e4.ui.model.application.MApplicationFactory to create the
appropriate new MPart, then add it as a child or your PartStack.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How to new Part Dynamically [message #567795 is a reply to message #508351] Tue, 19 January 2010 05:07 Go to previous messageGo to next message
Walter Mising name is currently offline Walter Mising name
Messages: 126
Registered: July 2009
Senior Member
How do I locate the PartStack ?
Re: How to new Part Dynamically [message #567826 is a reply to message #567795] Tue, 19 January 2010 10:30 Go to previous message
Jens Keller is currently offline Jens Keller
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
You can use the IEclipseContext for this:

MPartStack sampleStack = (MPartStack) context.get( "sampleStackID" );


Jens Keller
Previous Topic:Using the e4 dependency injection implementation outside e4
Next Topic:Showing menu in e4 application
Goto Forum:
  


Current Time: Thu Oct 23 13:05:57 GMT 2014

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

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