final PartDefinition part,
final PanelDefinition panel,
final Menus menus,
final UIPart uiPart,
final String contextId ) {
WorkbenchPartPresenter partPresenter = mapPartDefinitionToPresenter.get( part );
if ( partPresenter == null ) {
partPresenter = getBeanFactory().newWorkbenchPart( menus, uiPart.getTitle(), uiPart.getTitleDecoration(), part );
partPresenter.setWrappedWidget( uiPart.getWidget() );
partPresenter.setContextId( contextId );
mapPartDefinitionToPresenter.put( part, partPresenter );
}
if ( part.isMinimized() ) {
statusBar.addMinimizedPlace( part.getPlace() );
} else {
final WorkbenchPanelPresenter panelPresenter = getWorkbenchPanelPresenter( panel );
if ( panelPresenter == null ) {
throw new IllegalArgumentException( "Unable to add Part to Panel. Panel has not been created." );
}
panelPresenter.addPart( partPresenter.getPartView(), contextId );
}
//The model for a Perspective is already fully populated. Don't go adding duplicates.
if ( !panel.getParts().contains( part ) ) {
panel.addPart( part );