Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Moffatt2013-01-10 19:42:45 +0000
committerEric Moffatt2013-01-10 19:42:45 +0000
commit923c49b5ab2b7e78504051413500bd8ac83393d9 (patch)
treef77eaefc21393c551534ad5143a0d09affb941a4
parent9f5ddb53438dae8eddb2ccb169f54f4810737fe5 (diff)
downloadeclipse.platform.ui-923c49b5ab2b7e78504051413500bd8ac83393d9.tar.gz
eclipse.platform.ui-923c49b5ab2b7e78504051413500bd8ac83393d9.tar.xz
eclipse.platform.ui-923c49b5ab2b7e78504051413500bd8ac83393d9.zip
Fix for Bug 395194 - Non-restorable views appear on a restart
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java72
1 files changed, 37 insertions, 35 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
index 7c3ad5a3e28..e780a8c764d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
@@ -172,7 +172,6 @@ import org.eclipse.ui.services.IDisposable;
import org.eclipse.ui.services.IEvaluationService;
import org.eclipse.ui.services.IServiceScopes;
import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
@@ -1142,7 +1141,6 @@ public class WorkbenchWindow implements IWorkbenchWindow {
// Setup internal flags to indicate window is in
// progress of closing and no update should be done.
- closing = true;
updateDisabled = true;
try {
@@ -1164,6 +1162,7 @@ public class WorkbenchWindow implements IWorkbenchWindow {
windowClosed = workbench.close();
} else {
if (okToClose()) {
+ closing = true;
windowClosed = hardClose(remove);
}
}
@@ -1423,43 +1422,46 @@ public class WorkbenchWindow implements IWorkbenchWindow {
return PlatformUI.getWorkbench();
}
- private void hideNonRestorablePlaceholder(MPlaceholder placeholder) {
- MElementContainer<MUIElement> parent = placeholder.getParent();
- // if this placeholder is currently the selected element, its parent
- // needs to select something else
- if (parent.getSelectedElement() == placeholder) {
- // if nothing found just set it to null
- MUIElement candidate = null;
- // search for a valid candidate from the list of children
- for (MUIElement element : parent.getChildren()) {
- if (element.isVisible() && element.isToBeRendered() && element != placeholder) {
- candidate = element;
- break;
+ private void hideNonRestorableViews() {
+ List<MPart> sharedPartsToRemove = new ArrayList<MPart>();
+ List<MPlaceholder> phList = modelService
+ .findElements(model, null, MPlaceholder.class, null);
+ for (MPlaceholder ph : phList) {
+ if (!(ph.getRef() instanceof MPart))
+ continue;
+
+ String partId = ph.getElementId();
+
+ // If the id contains a ':' use the part before it as the
+ // descriptor id
+ int colonIndex = partId.indexOf(':');
+ String descId = colonIndex == -1 ? partId : partId.substring(0, colonIndex);
+ String secondaryId = colonIndex == -1 ? null : partId.substring(colonIndex + 1);
+ IViewDescriptor regEntry = ((Workbench) workbench).getViewRegistry().find(descId);
+ if (regEntry != null && !regEntry.isRestorable() && !("*".equals(secondaryId))) { //$NON-NLS-1$
+ MElementContainer<MUIElement> phParent = ph.getParent();
+ if (colonIndex != -1) {
+ // if it's a multi-instance part remove it (and its MPart)
+ if (!sharedPartsToRemove.contains(ph.getRef()))
+ sharedPartsToRemove.add((MPart) ph.getRef());
+ ph.getParent().getChildren().remove(ph);
+ } else if (ph.isToBeRendered()) {
+ // just hide it (so we remember where to open it again
+ ph.setToBeRendered(false);
}
- }
- parent.setSelectedElement(candidate);
- }
-
- // this tag is only applied to editors technically speaking, but better
- // safe than sorry
- MUIElement ref = placeholder.getRef();
- if (ref != null && ref.getTags().contains(EPartService.REMOVE_ON_HIDE_TAG)) {
- parent.getChildren().remove(placeholder);
+ // We need to do our own cleanup here...
+ int vc = modelService.countRenderableChildren(phParent);
+ if (vc == 0) {
+ phParent.setToBeRendered(false);
+ }
+ }
}
- placeholder.setToBeRendered(false);
- }
-
- private void hideNonRestorableViews() {
- List<MPlaceholder> placeholders = modelService.findElements(model, null,
- MPlaceholder.class, null);
- IViewRegistry registry = getWorkbench().getViewRegistry();
- for (MPlaceholder placeholder : placeholders) {
- IViewDescriptor descriptor = registry.find(placeholder.getElementId());
- if (descriptor != null && !descriptor.isRestorable()) {
- hideNonRestorablePlaceholder(placeholder);
- }
+ // Remove the actual shared Parts for any placeholder that was removed
+ List<MUIElement> seList = model.getSharedElements();
+ for (MPart partToRemove : sharedPartsToRemove) {
+ seList.remove(partToRemove);
}
}

Back to the top