MCompositePart creation with EPartService.createPart()? [message #1759076] |
Wed, 05 April 2017 18:53  |
Eclipse User |
|
|
|
Hmmm ... I don't see help to create an MCompositePart with EPartService, using a partDescriptor.
Looks like modelService.cloneElement might be used to create a deep copy of an existing MCompositePart nested description in the model. Is that the solution?
|
|
|
|
|
Re: MCompositePart creation with EPartService.createPart()? [message #1759888 is a reply to message #1759141] |
Wed, 19 April 2017 02:53   |
Eclipse User |
|
|
|
I experimented some more with the snippet cloning.
A single call to the snippet cloning handler below was able to replicate a copy of the whole window.main model, placed under the Snippets ... menus, parts, perspectives, sash and stack containers ... everything. Pretty amazing capability.
I couldn't find a document of what to give as the element ID for the node shown as 'Windows and Dialogs' in the editor, so I passed in a the window.main id as a sibling command parameter, and looked up the parent.
I was also left with a question about replication of the ID strings of the application model elements. Apparently the application model doesn't require these to be unique. At least, I didn't do anything explicit to change the IDs after cloning multiple times. Is that right?
public class CloneSnippetHandler {
@Execute
public void cloneSnippet(@Named("snippetID") String snippetID,@Named("siblingID") String siblingID, EModelService modelService, MApplication application) {
MUIElement el = modelService.findSnippet(application,snippetID);
MUIElement sibling = modelService.find(siblingID, application);
MUIElement cloned = modelService.cloneSnippet(application, snippetID, null);
MElementContainer<MUIElement> cont = sibling.getParent();
cont.getChildren().add(cloned);
}
}
|
|
|
|
Re: MCompositePart creation with EPartService.createPart()? [message #1759920 is a reply to message #1759908] |
Wed, 19 April 2017 19:39  |
Eclipse User |
|
|
|
Christoph Keimel wrote on Wed, 19 April 2017 15:51The "Windows and Dialogs" node shows the children of the application itself, so you can simplify your code by adding the cloned window directly to the application:
application.getChildren().add(cloned);
Yeah, thanks, but the handler can be reused for other snippet clone commands if I can consistently pass in a container ID.
I see that my application's ID is <project_name>.application, using application.getElementId().
String appId = application.getElementId();
|
|
|
Powered by
FUDForum. Page generated in 0.04185 seconds