]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/SelectedCellEditorMatcher.java
Sync git svn branch with SVN repository r33144.
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / SelectedCellEditorMatcher.java
diff --git a/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/SelectedCellEditorMatcher.java b/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/SelectedCellEditorMatcher.java
new file mode 100644 (file)
index 0000000..4cf1e16
--- /dev/null
@@ -0,0 +1,39 @@
+package org.simantics.browsing.ui.nattable;\r
+\r
+import org.eclipse.nebula.widgets.nattable.NatTable;\r
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;\r
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;\r
+import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;\r
+import org.eclipse.swt.events.MouseEvent;\r
+\r
+public class SelectedCellEditorMatcher extends CellEditorMouseEventMatcher{\r
+\r
+       public SelectedCellEditorMatcher( String regionLabel) {\r
+               super(regionLabel);\r
+       }\r
+       \r
+       ILayerCell previous;\r
+       int previousTime = 0;\r
+       @Override\r
+       public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {\r
+               if (super.matches(natTable, event, regionLabels)) {\r
+                       int px = natTable.getColumnPositionByX(event.x);\r
+                       int py = natTable.getRowPositionByY(event.y);\r
+                       ILayerCell cell = natTable.getCellByPosition(px,py);\r
+                       int time = event.time;\r
+                       if (previous != null &&\r
+                               cell.getColumnIndex() == previous.getColumnIndex() &&\r
+                               cell.getRowIndex() == previous.getRowIndex() &&\r
+                               time - previousTime > event.display.getDoubleClickTime())\r
+                               return true;\r
+                       previous = cell;\r
+                       previousTime = time;\r
+               }\r
+               return false;\r
+       }\r
+       \r
+       \r
+       \r
+       \r
+\r
+}\r