Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2016-12-20 09:58:05 +0000
committerLars Vogel2017-01-10 20:04:30 +0000
commit0c79082ca5bf92bd817be21c8dca28d0be23c70b (patch)
tree18bfc961cc6b5352ed6d1a09748985c502270441
parentce6c4aac56ea37281a40665d8230380864e7eb2b (diff)
downloadeclipse.platform.ui-0c79082ca5bf92bd817be21c8dca28d0be23c70b.tar.gz
eclipse.platform.ui-0c79082ca5bf92bd817be21c8dca28d0be23c70b.tar.xz
eclipse.platform.ui-0c79082ca5bf92bd817be21c8dca28d0be23c70b.zip
Bug 509405 - [PropertiesView] No update after selection change in
maximized view Properties view should update the PropertySheet to the current selection if the selection was changed during the property view was hidden and now is made visible again (for example due the zoom/unzoom of another view). Change-Id: I0a8b6eb1daf6ca51b9dc54e81d0cb7f483390448 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java40
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java69
2 files changed, 97 insertions, 12 deletions
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
index 8210591305e..d24bed2c41a 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
@@ -136,8 +136,15 @@ public class PropertySheet extends PageBookView
*/
private HashSet ignoredViews;
+ /** the view was hidden */
private boolean wasHidden;
+ /**
+ * the selection update which was made during the view was hidden need to be
+ * propagated to IPropertySheetPage
+ */
+ private boolean selectionUpdatePending;
+
private final SaveablesTracker saveablesTracker;
/**
@@ -363,6 +370,11 @@ public class PropertySheet extends PageBookView
@Override
protected void partVisible(IWorkbenchPart part) {
super.partVisible(part);
+ if (wasHidden && part == this) {
+ if (selectionUpdatePending) {
+ showSelectionAndDescription();
+ }
+ }
}
@Override
@@ -385,12 +397,8 @@ public class PropertySheet extends PageBookView
if (wasHidden && part == this) {
wasHidden = false;
super.partActivated(part);
- if (currentPart != null) {
- IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
- if (page != null) {
- page.selectionChanged(currentPart, currentSelection);
- }
- updateContentDescription();
+ if (selectionUpdatePending) {
+ showSelectionAndDescription();
}
return;
}
@@ -455,16 +463,12 @@ public class PropertySheet extends PageBookView
boolean visible = getSite() != null && getSite().getPage().isPartVisible(this);
if (!visible) {
+ selectionUpdatePending = true;
return;
}
// pass the selection to the page
- IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
- if (page != null) {
- page.selectionChanged(currentPart, currentSelection);
- }
-
- updateContentDescription();
+ showSelectionAndDescription();
}
private void updateContentDescription() {
@@ -477,6 +481,18 @@ public class PropertySheet extends PageBookView
firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY);
}
+ private void showSelectionAndDescription() {
+ selectionUpdatePending = false;
+ if (currentPart == null || currentSelection == null) {
+ return;
+ }
+ IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
+ if (page != null) {
+ page.selectionChanged(currentPart, currentSelection);
+ }
+ updateContentDescription();
+ }
+
/**
* Defines the dirty state indication behavior of the {@link PropertySheet}
* instance for the current tracked part if it is a {@link ISaveablePart}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java
index 4f8fd5c0999..e786ccd8e3f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.propertysheet;
+import static org.junit.Assert.assertArrayEquals;
+
import java.util.ArrayList;
import java.util.Random;
@@ -30,6 +32,8 @@ import org.eclipse.ui.views.properties.ColorPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetEntry;
+import org.eclipse.ui.views.properties.PropertySheetPage;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
/**
@@ -354,6 +358,64 @@ public class PropertySheetAuto extends UITestCase {
}
}
+ /**
+ * Supply selection events with a random car selection after properties view
+ * is hidden by maximizing source view. All of these selections should go to
+ * the properties view even if it is hidden. After properties view became
+ * visible again, it should show car selection from the (restored) original
+ * source view.
+ */
+ public void testInputIfHiddenByMaximizeBug509405() throws Throwable {
+ PropertySheetPerspectiveFactory3.applyPerspective(activePage);
+ IViewPart projectExplorer = activePage.showView(IPageLayout.ID_PROJECT_EXPLORER);
+ PropertySheet propView = (PropertySheet) createTestParts(activePage);
+ // project explorer hides property view, because it is in the same stack
+ createCars();
+ for (int i = 0; i < 10; i++) {
+ // bring project explorer view to front (hides property view from
+ // same stack)
+ assertViewsVisibility2(propView, projectExplorer);
+
+ // activate now selectionProviderView (to became site selection
+ // provider again)
+ activePage.activate(selectionProviderView);
+ processUiEvents();
+ activePage.toggleZoom(activePage.getReference(selectionProviderView));
+ processUiEvents();
+
+ // create the selection
+ int numberToSelect = random.nextInt(NUMBER_OF_CARS - 2);
+ ArrayList selection = new ArrayList(numberToSelect);
+ while (selection.size() < numberToSelect) {
+ int j = random.nextInt(NUMBER_OF_CARS);
+ if (!selection.contains(cars[j])) {
+ selection.add(cars[j]);
+ }
+ }
+ StructuredSelection structuredSelection = new StructuredSelection(selection);
+ // fire the selection
+ selectionProviderView.setSelection(structuredSelection);
+ processUiEvents();
+
+ // props view hidden, but still tracks the selection from original
+ // source part
+ assertEquals(structuredSelection, propView.getShowInContext().getSelection());
+
+ // unhide props view again
+ activePage.toggleZoom(activePage.getReference(selectionProviderView));
+ processUiEvents();
+ assertViewsVisibility2(propView, projectExplorer);
+
+ // props view visible again and shows the last selection from
+ // original source part
+ assertEquals(structuredSelection, propView.getShowInContext().getSelection());
+
+ PropertySheetPage currentPage = (PropertySheetPage) propView.getCurrentPage();
+ PropertySheetEntry propEntry = (PropertySheetEntry) currentPage.getControl().getData();
+ assertArrayEquals(structuredSelection.toArray(), propEntry.getValues());
+ }
+ }
+
/**
* Supply selection events with a random car selection after properties view
* is hidden by the another view in the same stack but the original
@@ -400,6 +462,10 @@ public class PropertySheetAuto extends UITestCase {
// props view visible again and shows the last selection from original source part
assertEquals(structuredSelection, propView.getShowInContext().getSelection());
+
+ PropertySheetPage currentPage = (PropertySheetPage) propView.getCurrentPage();
+ PropertySheetEntry propEntry = (PropertySheetEntry) currentPage.getControl().getData();
+ assertArrayEquals(structuredSelection.toArray(), propEntry.getValues());
}
}
@@ -472,6 +538,9 @@ public class PropertySheetAuto extends UITestCase {
// props view visible again and shows the last selection from
// original source part
assertEquals(structuredSelection, propView.getShowInContext().getSelection());
+ PropertySheetPage currentPage = (PropertySheetPage) propView.getCurrentPage();
+ PropertySheetEntry propEntry = (PropertySheetEntry) currentPage.getControl().getData();
+ assertArrayEquals(structuredSelection.toArray(), propEntry.getValues());
}
}

Back to the top