Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlara Ward2017-09-04 13:08:44 +0000
committerThomas Schindl2017-11-01 22:50:18 +0000
commitda427eaeb7c25a1a5f391c0d3fc043e91027b7d8 (patch)
treeeadb7f02dd2ec857e62cd131604cea970d5fe35b
parent79fbfd4935af02b44260067449ceed1a98408e55 (diff)
downloadeclipse.platform.ui-da427eaeb7c25a1a5f391c0d3fc043e91027b7d8.tar.gz
eclipse.platform.ui-da427eaeb7c25a1a5f391c0d3fc043e91027b7d8.tar.xz
eclipse.platform.ui-da427eaeb7c25a1a5f391c0d3fc043e91027b7d8.zip
Bug 268135 - Table with SWT.MULTI and TableViewerEditor problem
Allows users to choose between previous selection behavior (default), and displaying both the full selection and the currently selected cell, indicated with different colors. Contributed by marek.chodorowski@gmail.com Change-Id: I1df6aca0e41a6de97aab819fd7a50ad927638590 Signed-off-by: Klara Ward <klara.ward@oracle.com>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java33
1 files changed, 26 insertions, 7 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
index b43ee5f7c14..afce411ed81 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,6 +34,8 @@ import org.eclipse.swt.widgets.Listener;
*
*/
public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
+ private boolean removeNonFocusedSelectionInformation;
+
/**
* Create a new instance which can be passed to a
* {@link TreeViewerFocusCellManager}
@@ -42,7 +44,23 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
* the viewer
*/
public FocusCellOwnerDrawHighlighter(ColumnViewer viewer) {
+ this(viewer, true);
+ }
+
+ /**
+ * Create a new instance which can be passed to a
+ * {@link TreeViewerFocusCellManager}
+ *
+ * @param viewer
+ * the viewer
+ * @param removeNonFocusedSelectionInformation
+ * <code>true</code> if only the currently focused cell should be
+ * indicated as selected. <code>false</code> to indicate both the
+ * full selection and the currently focused cell.
+ */
+ public FocusCellOwnerDrawHighlighter(ColumnViewer viewer, boolean removeNonFocusedSelectionInformation) {
super(viewer);
+ this.removeNonFocusedSelectionInformation = removeNonFocusedSelectionInformation;
hookListener(viewer);
}
@@ -85,10 +103,8 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
private void removeSelectionInformation(Event event, ViewerCell cell) {
GC gc = event.gc;
- gc.setBackground(cell.getViewerRow().getBackground(
- cell.getColumnIndex()));
- gc.setForeground(cell.getViewerRow().getForeground(
- cell.getColumnIndex()));
+ gc.setBackground(cell.getViewerRow().getBackground(cell.getColumnIndex()));
+ gc.setForeground(cell.getViewerRow().getForeground(cell.getColumnIndex()));
gc.fillRectangle(cell.getBounds());
event.detail &= ~SWT.SELECTED;
}
@@ -107,7 +123,9 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
ViewerCell cell = row.getCell(event.index);
if (focusCell == null || !cell.equals(focusCell)) {
- removeSelectionInformation(event, cell);
+ if (removeNonFocusedSelectionInformation) {
+ removeSelectionInformation(event, cell);
+ }
} else {
markFocusedCell(event, cell);
}
@@ -125,7 +143,8 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
* @return the color or <code>null</code> to use the default
*/
protected Color getSelectedCellBackgroundColor(ViewerCell cell) {
- return null;
+ return removeNonFocusedSelectionInformation ? null
+ : cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
}
/**

Back to the top