User Tools

Site Tools


show_part_in_specific_partstack

Show Part in specific PartStack

If a part is statically added to the application model the parent container containing the part is set because the part model element is placed directly under the part container in the hierarchy.

For adding a part dynamically the parent of the part is not set and by default refers to the part stack of the current view (afaik).

For setting the parent (part stack) of a dynamically created part the specific part needs to be retrieved from the application model. Then the new part needs to be added to the part stack.

// create a new Part based on a PartDescriptor
// in the application model
// assume the ID is used for the PartDescriptor
MPart part = partService.createPart(Constants.EDITOR_PART_ID);

// configure part
part.setLabel(input.getName());
part.setTooltip(input.getName());
part.setCloseable(true);
part.setContributionURI("bundleclass://miworkplace.spools/miworkplace.spools.editor.SpooledFileEditor");

// add part to partstack
MPartStack editorPartStack = (MPartStack) modelService.find("miworkplace.middle", application);
editorPartStack.getChildren().add(part);

// If multiple parts of this type are now allowed
// in the application model,
// then the provided part will be shown
// and returned
partService.showPart(part, PartState.ACTIVATE);

show_part_in_specific_partstack.txt · Last modified: 2013/12/18 10:47 by mihael