Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package de.tototec.utils.jface.viewer;
import static de.tototec.utils.jface.viewer.Util.map;
import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.core.internal.commands.util.Util;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This is a utility class that enables sortable column for {@link TableViewer}s
* and {@link TreeViewer}s.
*
*
* Features:
*
*
*
Automatically sort column based on it's label provider
*
Automatically toggle between ascending and descending when clicking on
* the column header
*
Support for alternative column sorters (if the label provider isn't
* enough)
*
Support for fallback sorter, which is used initially and also when the
* user clicks multiple times on the column
* header. If a fallback sorter is present, the click on the column header
* cycles between ascending, descending and
* fallback sorter.
*
Only sort selected columns.
*
*
*/
public class ColumnSorter extends ViewerComparator {
public static final int ASC = 1;
public static final int NONE = 0;
public static final int DESC = -1;
private final Logger log = LoggerFactory.getLogger(ColumnSorter.class);
private final ColumnViewer viewer;
private int direction = 0;
private TableColumn tableColumn = null;
private TreeColumn treeColumn = null;
private int columnIndex = 0;
private Map