* Shows the view with the given id and secondary id.
*/
public IViewPart showView(String viewId, String secondaryId)
throws PartInitException {
ViewFactory factory = getViewFactory();
IViewReference ref = factory.createView(viewId, secondaryId);
IViewPart part = (IViewPart) ref.getPart(true);
if (part == null) {
throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_couldNotCreate, ref.getId()));
}
ViewSite site = (ViewSite) part.getSite();
ViewPane pane = (ViewPane) site.getPane();
IPreferenceStore store = WorkbenchPlugin.getDefault()
.getPreferenceStore();
int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
if (openViewMode == IPreferenceConstants.OVM_FAST &&
fastViewManager != null) {
fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, true);
setActiveFastView(ref);
} else if (openViewMode == IPreferenceConstants.OVM_FLOAT
&& presentation.canDetach()) {
presentation.addDetachedPart(pane);
} else {
if (useNewMinMax(this)) {
// Is this view going to show in the trim?
LayoutPart vPart = presentation.findPart(viewId, secondaryId);
// Determine if there is a trim stack that should get the view
String trimId = null;
// If we can locate the correct trim stack then do so
if (vPart != null) {
String id = null;
ILayoutContainer container = vPart.getContainer();
if (container instanceof ContainerPlaceholder)
id = ((ContainerPlaceholder)container).getID();
else if (container instanceof ViewStack)
id = ((ViewStack)container).getID();
// Is this place-holder in the trim?
if (id != null && fastViewManager.getFastViews(id).size() > 0) {
trimId = id;
}
}
// No explicit trim found; If we're maximized then we either have to find an
// arbitrary stack...
if (trimId == null && presentation.getMaximizedStack() != null) {
if (vPart == null) {
ViewStackTrimToolBar blTrimStack = fastViewManager.getBottomRightTrimStack();
if (blTrimStack != null) {
// OK, we've found a trim stack to add it to...
trimId = blTrimStack.getId();
// Since there was no placeholder we have to add one
LayoutPart blPart = presentation.findPart(trimId, null);
if (blPart instanceof ContainerPlaceholder) {
ContainerPlaceholder cph = (ContainerPlaceholder) blPart;
if (cph.getRealContainer() instanceof ViewStack) {
ViewStack vs = (ViewStack) cph.getRealContainer();
// Create a 'compound' id if this is a multi-instance part
String compoundId = ref.getId();
if (ref.getSecondaryId() != null)
compoundId = compoundId + ':' + ref.getSecondaryId();
// Add the new placeholder
vs.add(new PartPlaceholder(compoundId));
}
}