]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/SelectedCellEditorMatcher.java
Merge "Testing SonarQube with Simantics Platform SDK"
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / SelectedCellEditorMatcher.java
1 package org.simantics.browsing.ui.nattable;\r
2 \r
3 import org.eclipse.nebula.widgets.nattable.NatTable;\r
4 import org.eclipse.nebula.widgets.nattable.layer.LabelStack;\r
5 import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;\r
6 import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;\r
7 import org.eclipse.swt.events.MouseEvent;\r
8 \r
9 public class SelectedCellEditorMatcher extends CellEditorMouseEventMatcher{\r
10 \r
11         public SelectedCellEditorMatcher( String regionLabel) {\r
12                 super(regionLabel);\r
13         }\r
14         \r
15         ILayerCell previous;\r
16         int previousTime = 0;\r
17         @Override\r
18         public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {\r
19                 if (super.matches(natTable, event, regionLabels)) {\r
20                         int px = natTable.getColumnPositionByX(event.x);\r
21                         int py = natTable.getRowPositionByY(event.y);\r
22                         ILayerCell cell = natTable.getCellByPosition(px,py);\r
23                         int time = event.time;\r
24                         if (previous != null &&\r
25                                 cell.getColumnIndex() == previous.getColumnIndex() &&\r
26                                 cell.getRowIndex() == previous.getRowIndex() &&\r
27                                 time - previousTime > event.display.getDoubleClickTime())\r
28                                 return true;\r
29                         previous = cell;\r
30                         previousTime = time;\r
31                 }\r
32                 return false;\r
33         }\r
34         \r
35         \r
36         \r
37         \r
38 \r
39 }\r