X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.nattable%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fnattable%2FSelectedCellEditorMatcher.java;fp=bundles%2Forg.simantics.browsing.ui.nattable%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fnattable%2FSelectedCellEditorMatcher.java;h=4cf1e16beb9abc6b33b3dd03102252f62cd9bed2;hp=0000000000000000000000000000000000000000;hb=96bb7ef9cbe42d82eb58306d8f9b62392cc29ba8;hpb=ae5bb63c5c88f6569518fed2a24df86fbd0570ff 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 index 000000000..4cf1e16be --- /dev/null +++ b/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/SelectedCellEditorMatcher.java @@ -0,0 +1,39 @@ +package org.simantics.browsing.ui.nattable; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.layer.LabelStack; +import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; +import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher; +import org.eclipse.swt.events.MouseEvent; + +public class SelectedCellEditorMatcher extends CellEditorMouseEventMatcher{ + + public SelectedCellEditorMatcher( String regionLabel) { + super(regionLabel); + } + + ILayerCell previous; + int previousTime = 0; + @Override + public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) { + if (super.matches(natTable, event, regionLabels)) { + int px = natTable.getColumnPositionByX(event.x); + int py = natTable.getRowPositionByY(event.y); + ILayerCell cell = natTable.getCellByPosition(px,py); + int time = event.time; + if (previous != null && + cell.getColumnIndex() == previous.getColumnIndex() && + cell.getRowIndex() == previous.getRowIndex() && + time - previousTime > event.display.getDoubleClickTime()) + return true; + previous = cell; + previousTime = time; + } + return false; + } + + + + + +}