Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemy Suen2011-11-17 14:11:30 +0000
committerRemy Suen2011-11-17 14:11:30 +0000
commit40367ebc94e9431896b75c2d6780831975cb873b (patch)
treeb1fe63ec8b3970cf15526d6c9e9e878c08b7b543
parent7ed043e1cc641d1e64fd5aec7dda371f4505c33b (diff)
downloadeclipse.platform.ui-40367ebc94e9431896b75c2d6780831975cb873b.tar.gz
eclipse.platform.ui-40367ebc94e9431896b75c2d6780831975cb873b.tar.xz
eclipse.platform.ui-40367ebc94e9431896b75c2d6780831975cb873b.zip
Bug 340771 [Compatibility] Debug views are empty when first opened
As the part visibility events are only fired when the selection of an element container changes, the event may not be fired on startup because there have been no changes. This causes the debug views to show up with no content because they optimize themselves to not render anything if they are not currently visible. The fix is to fire these visibility events on workbench startup.
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java8
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java51
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java5
3 files changed, 63 insertions, 1 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
index cb69911bdfb..770ff05d492 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
@@ -705,6 +705,14 @@ public final class Workbench extends EventManager implements IWorkbench {
background.dispose();
registration[0].unregister(); // unregister ourself
WorkbenchPlugin.unsetSplashShell(display);
+
+ // fire part visibility events now that we're up
+ for (IWorkbenchWindow window : getWorkbenchWindows()) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ ((WorkbenchPage) page).fireInitialPartVisibilityEvents();
+ }
+ }
}
public void update() {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
index b9104c7e490..1d06211a40f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
@@ -187,10 +187,19 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
}
public void partVisible(MPart part) {
- firePartVisible(part);
+ // ignored, use the BRINGTOTOP event instead
}
}
+ private EventHandler bringToTopHandler = new EventHandler() {
+ public void handleEvent(Event event) {
+ Object element = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (element instanceof MPart) {
+ firePartVisible((MPart) element);
+ }
+ }
+ };
+
ArrayList<MPart> activationList = new ArrayList<MPart>();
/**
@@ -1435,6 +1444,7 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
legacyWindow.setActivePage(null);
partService.removePartListener(e4PartListener);
broker.unsubscribe(selectionHandler);
+ broker.unsubscribe(bringToTopHandler);
broker.unsubscribe(areaWidgetHandler);
broker.unsubscribe(referenceRemovalEventHandler);
@@ -2333,6 +2343,7 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
broker.subscribe(UIEvents.buildTopic(UIEvents.ElementContainer.TOPIC,
UIEvents.ElementContainer.SELECTEDELEMENT), selectionHandler);
+ broker.subscribe(UIEvents.UILifeCycle.BRINGTOTOP, bringToTopHandler);
broker.subscribe(UIEvents.buildTopic(UIEvents.UIElement.TOPIC, UIEvents.UIElement.WIDGET),
areaWidgetHandler);
broker.subscribe(
@@ -3882,6 +3893,44 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
return references;
}
+ void fireInitialPartVisibilityEvents() {
+ MPerspective selectedElement = getPerspectiveStack().getSelectedElement();
+ // technically shouldn't be null here
+ if (selectedElement != null) {
+ Collection<MPart> parts = modelService.findElements(selectedElement, null, MPart.class,
+ null);
+ List<MPart> visibleParts = new ArrayList<MPart>(parts.size());
+ for (MPart part : parts) {
+ if (isVisible(selectedElement, part)) {
+ visibleParts.add(part);
+ }
+ }
+
+ for (MPart part : visibleParts) {
+ firePartVisible(part);
+ }
+ }
+ }
+
+ private boolean isVisible(MPerspective perspective, MUIElement element) {
+ if (element == perspective) {
+ return true;
+ } else if (element.isVisible() && element.isToBeRendered()) {
+ MElementContainer<?> parent = element.getParent();
+ if (parent instanceof MPartStack) {
+ if (parent.getSelectedElement() == element) {
+ return isVisible(perspective, parent);
+ }
+ } else if (parent == null) {
+ MPlaceholder placeholder = element.getCurSharedRef();
+ return placeholder == null ? false : isVisible(perspective, placeholder);
+ } else {
+ return isVisible(perspective, parent);
+ }
+ }
+ return false;
+ }
+
private void firePartActivated(MPart part) {
Object client = part.getObject();
if (client instanceof CompatibilityPart) {
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 f493cf7cfb3..945df1daf56 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
@@ -511,6 +511,7 @@ public class WorkbenchWindow implements IWorkbenchWindow {
List<MPerspectiveStack> ps = modelService.findElements(model, null,
MPerspectiveStack.class, null);
MPerspective curPersp = null;
+ boolean newWindow = true;
if (ps.size() > 0) {
MPerspectiveStack stack = ps.get(0);
if (stack.getSelectedElement() != null) {
@@ -519,10 +520,14 @@ public class WorkbenchWindow implements IWorkbenchWindow {
.findPerspectiveWithId(curPersp.getElementId());
if (thePersp != null) {
perspective = thePersp;
+ newWindow = false;
}
}
}
page.setPerspective(perspective);
+ if (newWindow) {
+ page.fireInitialPartVisibilityEvents();
+ }
firePageActivated();
populateTopTrimContributions();

Back to the top