Skip to content

Commit a976a46

Browse files
committed
Merge branch 'nebulaCell'
2 parents 2a6115e + b39caf2 commit a976a46

6 files changed

Lines changed: 127 additions & 29 deletions

File tree

devenv/launches/RCPTT IDE AUT.launch

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
<setEntry value="org.apache.httpcomponents.core5.httpcore5-h2@default:default"/>
7070
<setEntry value="org.apache.httpcomponents.core5.httpcore5@default:default"/>
7171
<setEntry value="org.apache.lucene.core@default:default"/>
72-
<setEntry value="org.apache.poi.ooxml@default:default"/>
73-
<setEntry value="org.apache.poi@default:default"/>
72+
<setEntry value="org.apache.poi*5.5.1.v20251201-1000@default:default"/>
73+
<setEntry value="org.apache.poi.ooxml*5.5.1.v20251201-1000@default:default"/>
7474
<setEntry value="org.apache.xmlgraphics@default:default"/>
7575
<setEntry value="org.aspectj.runtime@default:default"/>
7676
<setEntry value="org.aspectj.weaver@1:true"/>
@@ -561,7 +561,6 @@
561561
<setEntry value="org.eclipse.rcptt.watson.core@default:default"/>
562562
<setEntry value="org.eclipse.rcptt.watson.jface@default:default"/>
563563
<setEntry value="org.eclipse.rcptt.watson.jobs@default:default"/>
564-
<setEntry value="org.eclipse.rcptt.watson.ui@default:default"/>
565564
<setEntry value="org.eclipse.rcptt@default:default"/>
566565
</setAttribute>
567566
<booleanAttribute key="show_selected_only" value="false"/>

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

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
import org.eclipse.nebula.widgets.grid.Grid;
1414
import org.eclipse.nebula.widgets.grid.GridColumn;
1515
import org.eclipse.nebula.widgets.grid.GridItem;
16-
import org.eclipse.swt.widgets.Widget;
17-
1816
import org.eclipse.rcptt.tesla.core.protocol.ElementKind;
1917
import org.eclipse.rcptt.tesla.core.protocol.GenericElementKind;
2018
import org.eclipse.rcptt.tesla.internal.ui.player.AbstractSWTUIPlayerExtension;
2119
import org.eclipse.rcptt.tesla.internal.ui.player.ChildrenCollectingSession;
2220
import org.eclipse.rcptt.tesla.internal.ui.player.IChildrenCollectingExtension;
21+
import org.eclipse.rcptt.tesla.internal.ui.player.ItemUIElement;
2322
import org.eclipse.rcptt.tesla.internal.ui.player.PlayerSelectionFilter;
2423
import org.eclipse.rcptt.tesla.internal.ui.player.PlayerWrapUtils;
2524
import org.eclipse.rcptt.tesla.internal.ui.player.SWTUIElement;
@@ -30,29 +29,64 @@
3029
import org.eclipse.rcptt.tesla.nebula.grid.parts.ItemCell;
3130
import org.eclipse.rcptt.tesla.nebula.grid.parts.RowHeader;
3231
import org.eclipse.rcptt.tesla.nebula.viewers.NebulaViewers;
32+
import org.eclipse.rcptt.util.swt.Bounds;
33+
import org.eclipse.rcptt.util.swt.Events;
34+
import org.eclipse.swt.widgets.Event;
35+
import org.eclipse.swt.widgets.Widget;
3336

3437
public class NebulaUIPlayerExtension extends AbstractSWTUIPlayerExtension {
3538

39+
@Override
3640
public SWTUIElement wrap(Object s, SWTUIPlayer p) {
3741
if (s instanceof Grid)
3842
return new NebulaUIElement((Widget) s, p);
3943
if (s instanceof GridPart)
4044
return new NebulaPartUIElement((GridPart) s, p);
4145
return null;
4246
}
47+
48+
private static final class GridCell extends ItemUIElement {
49+
50+
public GridCell(GridItem w, SWTUIPlayer p, int column) {
51+
super(w, p, column);
52+
}
53+
54+
@Override
55+
public GridItem unwrap() {
56+
return (GridItem) super.unwrap();
57+
}
58+
59+
@Override
60+
public String getText() {
61+
return unwrap().getText(getColumn());
62+
}
63+
}
4364

65+
@Override
4466
public SWTUIElement select(SWTUIPlayer p, PlayerSelectionFilter f) {
4567

4668
switch (f.kind.kind) {
4769
case ColumnHeader:
4870
return selectColumnHeader(p, f);
4971
case Item:
5072
Widget parentWidget = f.parent.unwrap();
51-
if (f.path != null && parentWidget instanceof Grid) {
52-
GridItem item = (GridItem) NebulaViewers.searchGridItem(
53-
(NebulaUIElement) f.parent, f.path);
54-
if (item != null)
55-
return p.wrap(item);
73+
if(parentWidget instanceof Grid grid) {
74+
if (f.path != null) {
75+
GridItem item = (GridItem) NebulaViewers.searchGridItem(
76+
(NebulaUIElement) f.parent, f.path);
77+
if (item != null) {
78+
return new GridCell(item, p, 0);
79+
}
80+
}
81+
if (f.indexes.length == 2) {
82+
int column = f.indexes[0];
83+
int row = f.indexes[1];
84+
var item = grid.getItem(row);
85+
if (item == null) {
86+
return null;
87+
}
88+
return new GridCell(item, p, column);
89+
}
5690
}
5791

5892
case Custom:
@@ -64,11 +98,32 @@ else if (f.kind.is(NebulaElementKinds.ITEM_CELL))
6498
return ItemCell.select(p, f);
6599
else if (f.kind.is(NebulaElementKinds.EMPTY_AREA))
66100
return EmptyArea.select(p, f);
101+
default:
102+
return null;
67103
}
104+
}
105+
106+
@Override
107+
public boolean canClick(SWTUIElement widget, boolean isDefault, boolean doubleClick, boolean arrow) {
108+
return widget instanceof GridCell;
109+
}
110+
111+
@Override
112+
public void click(SWTUIElement widget, boolean isDefault, boolean doubleClick, boolean arrow, int stateMask) {
113+
GridCell gridCell = (GridCell)widget;
114+
GridItem gridItem = gridCell.unwrap();
115+
Grid grid = gridItem.getParent();
116+
final Event[] event = Events.createClick(Bounds.centerAbs(gridItem.getBounds(gridCell.getColumn())));
117+
widget.getPlayer().exec("Performing click on a Nebula Grid cell", new Runnable() {
118+
@Override
119+
public void run() {
120+
widget.getPlayer().getEvents().sendAll(grid, event);
121+
}
122+
});
68123

69-
return null;
70124
}
71125

126+
@Override
72127
public GenericElementKind getKind(Object w) {
73128
if (w instanceof Grid)
74129
return new GenericElementKind(NebulaElementKinds.GRID);
@@ -116,5 +171,6 @@ public SWTUIElement getShell(SWTUIElement element) {
116171
}
117172
return null;
118173
}
174+
119175

120176
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import org.eclipse.rcptt.tesla.core.protocol.DoubleClick;
4646
import org.eclipse.rcptt.tesla.core.protocol.DragCommand;
4747
import org.eclipse.rcptt.tesla.core.protocol.ElementKind;
48+
import org.eclipse.rcptt.tesla.core.protocol.GetText;
49+
import org.eclipse.rcptt.tesla.core.protocol.GetTextResponse;
4850
import org.eclipse.rcptt.tesla.core.protocol.IElementProcessorMapper;
4951
import org.eclipse.rcptt.tesla.core.protocol.ProtocolPackage;
5052
import org.eclipse.rcptt.tesla.core.protocol.SelectCommand;
@@ -54,6 +56,7 @@
5456
import org.eclipse.rcptt.tesla.core.protocol.raw.Command;
5557
import org.eclipse.rcptt.tesla.core.protocol.raw.Element;
5658
import org.eclipse.rcptt.tesla.core.protocol.raw.Response;
59+
import org.eclipse.rcptt.tesla.core.protocol.raw.ResponseStatus;
5760
import org.eclipse.rcptt.tesla.core.ui.Color;
5861
import org.eclipse.rcptt.tesla.core.ui.Selection;
5962
import org.eclipse.rcptt.tesla.core.ui.UiFactory;
@@ -64,6 +67,8 @@
6467
import org.eclipse.rcptt.tesla.internal.core.AbstractTeslaClient;
6568
import org.eclipse.rcptt.tesla.internal.ui.SWTElementMapper;
6669
import org.eclipse.rcptt.tesla.internal.ui.player.ISWTModelMapperExtension;
70+
import org.eclipse.rcptt.tesla.internal.ui.player.ItemUIElement;
71+
import org.eclipse.rcptt.tesla.internal.ui.player.PlayerTextUtils;
6772
import org.eclipse.rcptt.tesla.internal.ui.player.PlayerWrapUtils;
6873
import org.eclipse.rcptt.tesla.internal.ui.player.SWTEvents;
6974
import org.eclipse.rcptt.tesla.internal.ui.player.SWTModelMapper;
@@ -140,7 +145,9 @@ public PreExecuteStatus preExecute(Command command, PreExecuteStatus previousSta
140145
SelectData data = ((SelectCommand) command).getData();
141146
SWTUIElement parent = getMapper().get(data.getParent());
142147

143-
GridScrollingHelper.scrollGridFor(data, parent);
148+
if (!GridScrollingHelper.scrollGridFor(data, parent)) {
149+
return new PreExecuteStatus(false);
150+
}
144151
}
145152
// for SetSelectionEx see SelectingParts.mouseActions
146153
else if (command instanceof SetSelectionRange) {
@@ -246,6 +253,19 @@ public void run() {
246253
}
247254
return null;
248255
}
256+
257+
258+
@Override
259+
protected Response handleGetText(GetText command) {
260+
final SWTUIElement element = getMapper().get(command.getElement());
261+
final GetTextResponse response = factory.createGetTextResponse();
262+
if (element.unwrap() instanceof GridItem) {
263+
response.setText(element.getText());
264+
} else {
265+
return super.handleGetText(command);
266+
}
267+
return response;
268+
}
249269

250270
@Override
251271
protected Response handleDoubleClick(DoubleClick command) {

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

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,34 @@ 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;
46+
if (data.getIndexes().size() == 2) {
47+
item = grid.getItem(data.getIndexes().get(1));
48+
} else {
49+
item = (GridItem) NebulaViewers.searchGridItem(
50+
(NebulaUIElement) parent, data.getPath());
51+
}
52+
if (!showItemIfHidden(item)) {
53+
return false;
54+
}
55+
if (data.getKind().contentEquals(NebulaElementKinds.ITEM_CELL)) {
56+
ItemCell cell = ItemCell.from(data, item, data.getIndex());
57+
return showColumnIfHidden(cell.column); // scroll horizontally to the column
58+
}
59+
} else if (parentWidget instanceof GridItem item) {
60+
if (!showItemIfHidden(item)) {
61+
return false;
62+
}
4763

4864
if (data.getKind().contentEquals(NebulaElementKinds.ITEM_CELL)) {
4965
ItemCell cell = ItemCell.from(data, item, data.getIndex());
50-
showColumnIfHidden(cell.column); // scroll horizontally to the column
66+
return showColumnIfHidden(cell.column); // scroll horizontally to the column
5167
}
5268
}
5369
else if (data.getKind().contentEquals(NebulaElementKinds.EMPTY_AREA)) {
@@ -57,33 +73,39 @@ else if (data.getKind().contentEquals(NebulaElementKinds.EMPTY_AREA)) {
5773
if (!area.top) {
5874
// scroll grid to bottom to see the empty area
5975
grid.setTopIndex(grid.getItemCount() - 1);
76+
return false;
6077
}
6178

6279
// scroll horizontally
63-
if (area.column != null)
64-
showColumnIfHidden(area.column); // to see the column
80+
if (area.column != null)
81+
return showColumnIfHidden(area.column); // to see the column
6582
else if (!area.left)
66-
grid.showColumn(NebulaViewers.getGridLastColumn(grid)); // to see an empty area on the right
83+
return showColumnIfHidden(NebulaViewers.getGridLastColumn(grid)); // to see an empty area on the right
6784
}
85+
return true;
6886
}
6987

7088
//
7189

72-
public static void showItemIfHidden(GridItem item) {
73-
if (NebulaViewers.getItemBounds(item) == null) {
90+
public static boolean showItemIfHidden(GridItem item) {
91+
if (NebulaViewers.getItemBounds(item) == null || !item.isVisible()) {
7492
Grid grid = item.getParent();
75-
76-
// scroll grid vertically to see the item
77-
grid.setTopIndex(grid.getIndexOfItem(item));
93+
grid.showItem(item);
94+
return false;
7895
}
96+
97+
return true;
7998
}
8099

81-
public static void showColumnIfHidden(GridColumn column) {
100+
public static boolean showColumnIfHidden(GridColumn column) {
82101
Grid grid = column.getParent();
83102
Rectangle bounds = NebulaViewers.getColumnHeaderBounds(column);
84103

85-
if (bounds == null || bounds.x > grid.getBounds().width)
104+
if (bounds == null || bounds.x > grid.getBounds().width) {
86105
grid.showColumn(column);
106+
return false;
107+
}
108+
return true;
87109
}
88110

89111
public static void showPartIfHidden(ItemPart part) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.rcptt.tesla.nebula.grid.parts.RowHeader;
3535
import org.eclipse.rcptt.tesla.ui.IViewerItem;
3636
import org.eclipse.rcptt.util.Predicate;
37+
import org.eclipse.rcptt.util.TableTreeItemPathUtil;
3738
import org.eclipse.swt.SWT;
3839
import org.eclipse.swt.graphics.Point;
3940
import org.eclipse.swt.graphics.Rectangle;
@@ -202,7 +203,7 @@ public static GridItem searchGridItem(NebulaUIElement parent, List<String> path)
202203
if (items == null) {
203204
return null;
204205
}
205-
current = new PathSelectorPart(part).findIn(items);
206+
current = new PathSelectorPart(TableTreeItemPathUtil.excludeColumnName(part)).findIn(items);
206207
if (current == null)
207208
return null;
208209
}

runtime/tesla/org.eclipse.rcptt.tesla.swt/src/org/eclipse/rcptt/tesla/internal/ui/processors/SWTUIProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,7 @@ protected Response handleGetText(final GetText command) {
26282628
final SWTUIElement element = getMapper().get(command.getElement());
26292629
final GetTextResponse response = factory.createGetTextResponse();
26302630
if (element != null) {
2631-
response.setText(PlayerTextUtils.getText(element));
2631+
response.setText(element.getText());
26322632
}
26332633
else {
26342634
response.setStatus(ResponseStatus.FAILED);

0 commit comments

Comments
 (0)