diff --git a/chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/swt/ExtendedTableViewer.java b/chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/swt/ExtendedTableViewer.java index b11096d030..3b448083f1 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/swt/ExtendedTableViewer.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/swt/ExtendedTableViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2025 Lablicate GmbH. + * Copyright (c) 2015, 2026 Lablicate GmbH. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -318,14 +318,13 @@ public boolean isColumnSelected(Event event, String columnLabel) { } /** - * Checks if the cell of the given column was selected. - * ColumnIndex is 0 based. + * Returns the column index of the selected cell or -1 if + * none was selected. ColumnIndex is 0 based. * * @param event - * @param columnIndex - * @return boolean + * @return int */ - public boolean isColumnSelected(Event event, int columnIndex) { + public int getColumnIndex(Event event) { Table table = getTable(); Rectangle clientArea = table.getClientArea(); @@ -338,9 +337,7 @@ public boolean isColumnSelected(Event event, int columnIndex) { for(int i = 0; i < table.getColumnCount(); i++) { Rectangle rectangle = item.getBounds(i); if(rectangle.contains(point)) { - if(i == columnIndex) { - return true; - } + return i; } if(!visible && rectangle.intersects(clientArea)) { @@ -349,11 +346,29 @@ public boolean isColumnSelected(Event event, int columnIndex) { } if(!visible) { - return false; + return -1; } index++; } + return -1; + } + + /** + * Checks if the cell of the given column was selected. + * ColumnIndex is 0 based. + * + * @param event + * @param columnIndex + * @return boolean + */ + public boolean isColumnSelected(Event event, int columnIndex) { + + int index = getColumnIndex(event); + if(index >= 0 && index == columnIndex) { + return true; + } + return false; }