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