uicellsorter.java

来自「Eclipse RCP下编写的工作管理软件代码」· Java 代码 · 共 48 行

JAVA
48
字号
/*
 * Created on 2003-4-11
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package net.sf.pim.view;

import java.util.Arrays;

import net.sf.pim.UiCore;
import net.sf.pim.model.psp.WorkComparator;
import net.sf.util.persistence.IEntry;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

/**
 * @author lzhang
 *         <p/>
 *         To change the template for this generated type comment go to
 *         Window>Preferences>Java>Code Generation>Code and Comments
 */
public class UiCellSorter implements Listener {
    UiCore uc;

    public UiCellSorter(UiCore parent) {
        uc = parent;
    }

    public void handleEvent(Event e) {
        if (uc.isMulti()) {
            IEntry[] list = uc.getData().getWorks();
            Table table = uc.getTv().getTable();
            TableColumn tc=(TableColumn) e.widget;
            boolean asc = true;
            asc =table.getSortDirection() == SWT.DOWN ? true:false;
            Arrays.sort(list, new WorkComparator((String) tc.getData(),asc));
            uc.getTv().setInput(list);
			table.setSortColumn(tc);
			table.setSortDirection(asc ? SWT.TOP : SWT.DOWN);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?