From 776c05d1f928ca53f156863ec7e5b4accd3fe7fe Mon Sep 17 00:00:00 2001 From: Brian Remedios Date: Sun, 28 Feb 2010 21:35:12 +0000 Subject: [PATCH] Now using native column sort indicators. Go Team Canada! git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7076 51baf565-9d33-0410-a72c-fc3788e3496d --- .../eclipse/ui/views/TableColumnSorter.java | 50 +++---------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/TableColumnSorter.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/TableColumnSorter.java index f2975f54e1..f42a676a2b 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/TableColumnSorter.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/TableColumnSorter.java @@ -36,75 +36,37 @@ package net.sourceforge.pmd.eclipse.ui.views; -import net.sourceforge.pmd.eclipse.ui.PMDUiConstants; -import net.sourceforge.pmd.eclipse.plugin.PMDPlugin; - import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TreeColumn; /** * Displays an Arrow-Image in a TableColumn, that shows in which Direction the Column is sorted * - * @author SebastianRaffel ( 22.05.2005 ), Philippe Herlin - * + * @author SebastianRaffel ( 22.05.2005 ), Philippe Herlin, Brian Remedios */ public class TableColumnSorter extends ViewerSorter { /** - * Constructor - * * @param column, the column to sort * @param order, the Direction to sort by, -1 (desc) or 1 (asc) */ public TableColumnSorter(TreeColumn column, int order) { super(); - // we delete all other Images - // and set the current one - final TreeColumn[] columns = column.getParent().getColumns(); - for (int i = 0; i < columns.length; i++) { - columns[i].setImage(null); - } - - column.setImage(getImage(order)); + column.getParent().setSortColumn(column); + column.getParent().setSortDirection(order == 1 ? SWT.UP : SWT.DOWN); } /** - * Constructor - * * @param column, the column to sort * @param order, the Direction to sort by, -1 (desc) or 1 (asc) */ public TableColumnSorter(TableColumn column, int order) { super(); - // we delete all other Images - // and set the current one - final TableColumn[] columns = column.getParent().getColumns(); - for (int i = 0; i < columns.length; i++) { - columns[i].setImage(null); - } - - column.setImage(getImage(order)); - } - - /** - * Retreive an image for the corresponding sort order. - * - * @param order - * @return - */ - private Image getImage(int order) { - Image image = null; - - if (order == 1) { - image = PMDPlugin.getDefault().getImage("arrow_up", PMDUiConstants.ICON_LABEL_ARRUP); - } else if (order == -1) { - image = PMDPlugin.getDefault().getImage("arrow_dn", PMDUiConstants.ICON_LABEL_ARRDN); - } - - return image; + column.getParent().setSortColumn(column); + column.getParent().setSortDirection(order == 1 ? SWT.UP : SWT.DOWN); } }