Skip to content

Commit fb880d1

Browse files
committed
Preselect reveal
1 parent 56801d4 commit fb880d1

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

modules/nebula/plugins/org.eclipse.rcptt.tesla.nebula.impl/src/org/eclipse/rcptt/tesla/nebula/NebulaUIPlayerExtension.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public SWTUIElement select(SWTUIPlayer p, PlayerSelectionFilter f) {
8282
}
8383
return new GridCell(item, p, column);
8484
}
85-
8685
}
8786

8887
case Custom:

modules/nebula/plugins/org.eclipse.rcptt.tesla.nebula.impl/src/org/eclipse/rcptt/tesla/nebula/NebulaUIProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public PreExecuteStatus preExecute(Command command, PreExecuteStatus previousSta
141141
SelectData data = ((SelectCommand) command).getData();
142142
SWTUIElement parent = getMapper().get(data.getParent());
143143

144-
GridScrollingHelper.scrollGridFor(data, parent);
144+
if (!GridScrollingHelper.scrollGridFor(data, parent)) {
145+
return new PreExecuteStatus(false);
146+
}
145147
}
146148
// for SetSelectionEx see SelectingParts.mouseActions
147149
else if (command instanceof SetSelectionRange) {

modules/nebula/plugins/org.eclipse.rcptt.tesla.nebula.impl/src/org/eclipse/rcptt/tesla/nebula/grid/GridScrollingHelper.java

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,29 @@ public static void scrollGridFor(NebulaUIElement grid, List<String> path) {
3636
showItemIfHidden(item);
3737
}
3838

39-
public static void scrollGridFor(SelectData data, SWTUIElement parent) {
39+
public static boolean scrollGridFor(SelectData data, SWTUIElement parent) {
4040
Widget parentWidget = unwrapWidget(parent);
4141

4242
// TODO implement it for whole item selection case (e.g. select "Item #3")
4343

44-
if (parentWidget instanceof GridItem) {
45-
GridItem item = (GridItem) unwrapWidget(parent);
46-
showItemIfHidden(item);
44+
if (parentWidget instanceof Grid grid) {
45+
GridItem item = (GridItem) NebulaViewers.searchGridItem(
46+
(NebulaUIElement) parent, data.getPath());
47+
if (!showItemIfHidden(item)) {
48+
return false;
49+
}
50+
if (data.getKind().contentEquals(NebulaElementKinds.ITEM_CELL)) {
51+
ItemCell cell = ItemCell.from(data, item, data.getIndex());
52+
return showColumnIfHidden(cell.column); // scroll horizontally to the column
53+
}
54+
} else if (parentWidget instanceof GridItem item) {
55+
if (!showItemIfHidden(item)) {
56+
return false;
57+
}
4758

4859
if (data.getKind().contentEquals(NebulaElementKinds.ITEM_CELL)) {
4960
ItemCell cell = ItemCell.from(data, item, data.getIndex());
50-
showColumnIfHidden(cell.column); // scroll horizontally to the column
61+
return showColumnIfHidden(cell.column); // scroll horizontally to the column
5162
}
5263
}
5364
else if (data.getKind().contentEquals(NebulaElementKinds.EMPTY_AREA)) {
@@ -57,33 +68,39 @@ else if (data.getKind().contentEquals(NebulaElementKinds.EMPTY_AREA)) {
5768
if (!area.top) {
5869
// scroll grid to bottom to see the empty area
5970
grid.setTopIndex(grid.getItemCount() - 1);
71+
return false;
6072
}
6173

6274
// scroll horizontally
63-
if (area.column != null)
64-
showColumnIfHidden(area.column); // to see the column
75+
if (area.column != null)
76+
return showColumnIfHidden(area.column); // to see the column
6577
else if (!area.left)
66-
grid.showColumn(NebulaViewers.getGridLastColumn(grid)); // to see an empty area on the right
78+
return showColumnIfHidden(NebulaViewers.getGridLastColumn(grid)); // to see an empty area on the right
6779
}
80+
return true;
6881
}
6982

7083
//
7184

72-
public static void showItemIfHidden(GridItem item) {
73-
if (NebulaViewers.getItemBounds(item) == null) {
85+
public static boolean showItemIfHidden(GridItem item) {
86+
if (NebulaViewers.getItemBounds(item) == null || !item.isVisible()) {
7487
Grid grid = item.getParent();
75-
76-
// scroll grid vertically to see the item
77-
grid.setTopIndex(grid.getIndexOfItem(item));
88+
grid.showItem(item);
89+
return false;
7890
}
91+
92+
return true;
7993
}
8094

81-
public static void showColumnIfHidden(GridColumn column) {
95+
public static boolean showColumnIfHidden(GridColumn column) {
8296
Grid grid = column.getParent();
8397
Rectangle bounds = NebulaViewers.getColumnHeaderBounds(column);
8498

85-
if (bounds == null || bounds.x > grid.getBounds().width)
99+
if (bounds == null || bounds.x > grid.getBounds().width) {
86100
grid.showColumn(column);
101+
return false;
102+
}
103+
return true;
87104
}
88105

89106
public static void showPartIfHidden(ItemPart part) {

0 commit comments

Comments
 (0)