本文整理匯總了Java中org.eclipse.swt.widgets.TreeColumn.addSelectionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeColumn.addSelectionListener方法的具體用法?Java TreeColumn.addSelectionListener怎麽用?Java TreeColumn.addSelectionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.TreeColumn
的用法示例。
在下文中一共展示了TreeColumn.addSelectionListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTreeViewerColumn
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
private TreeViewerColumn createTreeViewerColumn(String title, int width, int alignment, boolean resizable, boolean moveable, final boolean isNumber) {
final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
final TreeColumn column = viewerColumn.getColumn();
column.setText(title);
column.setAlignment(alignment);
column.setMoveable(moveable);
columnLayout.setColumnData(column, new ColumnPixelData(width, resizable));
column.setData("isNumber", isNumber);
column.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeLabelSorter sorter = (TreeLabelSorter) viewer.getComparator();
TreeColumn selectedColumn = (TreeColumn) e.widget;
sorter.setColumn(selectedColumn);
}
});
return viewerColumn;
}
示例2: initTreeSorter
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
/**
* Init tree sorter
*/
private void initTreeSorter(){
if(this.viewer.getTree().getColumnCount() == 0){
Activator.logError("Can't init TreeSorter. Tree has no columns.");
return;
}
RepoViewSorter repoViewSorter = new RepoViewSorter();
viewer.setSorter(repoViewSorter);
viewer.getTree().setSortColumn(viewer.getTree().getColumn(0));
viewer.getTree().setSortDirection(SWT.UP);
viewer.refresh();
TreeColumn[] cols = viewer.getTree().getColumns();
for(final TreeColumn item : cols){
item.addSelectionListener(this.selListener);
}
}
示例3: configSorters
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
private void configSorters(Tree tree) {
int index = 0;
for (TreeColumn column : tree.getColumns()) {
final int colIndex = index++;
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateSortColumn((TreeColumn) event.widget, colIndex);
}
});
}
}
示例4: createColumns
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
/**
* Creates the columns for the history table.
*/
private void createColumns(Tree tree, TableLayout layout) {
SelectionListener headerListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int column = viewer.getTree().indexOf((TreeColumn) e.widget);
HistoryComparator oldSorter = (HistoryComparator) viewer.getComparator();
TreeColumn treeColumn = ((TreeColumn)e.widget);
if (oldSorter != null && column == oldSorter.getColumnNumber()) {
oldSorter.setReversed(!oldSorter.isReversed());
viewer.getTree().setSortColumn(treeColumn);
viewer.getTree().setSortDirection(oldSorter.isReversed() ? SWT.DOWN : SWT.UP);
viewer.refresh();
} else {
viewer.getTree().setSortColumn(treeColumn);
viewer.getTree().setSortDirection(SWT.UP);
viewer.setComparator(new HistoryComparator(column));
}
}
};
// file name
TreeColumn nameCol = new TreeColumn(tree, SWT.NONE);
nameCol.setResizable(true);
nameCol.setText(HistoryMessages.GenericHistoryTableProvider_FileName);
nameCol.addSelectionListener(headerListener);
// creation date
TreeColumn dateCol = new TreeColumn(tree, SWT.NONE);
dateCol.setResizable(true);
dateCol.setText(TeamUIMessages.GenericHistoryTableProvider_RevisionTime);
dateCol.addSelectionListener(headerListener);
layout.addColumnData(new ColumnWeightData(15, true));
layout.addColumnData(new ColumnWeightData(10, true));
}
示例5: createFilterControls
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
/**
* 創建包含過濾文本的 TreeViewer
* @param parent
* 頂層容器 ;
*/
private void createFilterControls(Composite parent) {
fFilteredTree = new FilteredTree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION, new PatternFilter(), true);
GridData gridData;
final GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
fFilteredTree.setLayout(layout);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
fFilteredTree.setLayoutData(gridData);
final TreeViewer viewer = fFilteredTree.getViewer();
// 確保 filtered tree 有顯示 ITEMS_TO_SHOW 的高度
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
final Object layoutData = tree.getLayoutData();
if (layoutData instanceof GridData) {
gridData = (GridData) layoutData;
gridData.heightHint = parent.getSize().y; // 適應大小
}
LanguageCodeComparator comparator = new LanguageCodeComparator();
final TreeColumn codeColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_CODE_COLUMN);
codeColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.codeColumn"));
tree.setSortColumn(codeColumn);
tree.setSortColumn(codeColumn);
tree.setSortDirection(SWT.UP);
codeColumn.addSelectionListener(new ResortColumn(comparator, codeColumn, viewer, LANGUAGE_CODE_COLUMN));
final TreeColumn nameColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_NAME_COLUMN);
nameColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.nameColumn"));
nameColumn.addSelectionListener(new ResortColumn(comparator, nameColumn, viewer, LANGUAGE_NAME_COLUMN));
final TreeColumn bidiColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_BIDI_COLUMN);
bidiColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.bidiColumn"));
bidiColumn.addSelectionListener(new ResortColumn(comparator, bidiColumn, viewer, LANGUAGE_BIDI_COLUMN));
viewer.setContentProvider(new LanguageCodeContentProvider());
viewer.setLabelProvider(new LanguageCodeLabelProvider());
viewer.setComparator(comparator);
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
verifyCurrentSelected(EDIT);
}
});
fFilteredTree.getPatternFilter().setIncludeLeadingWildcard(true);
final TreeColumn[] columns = viewer.getTree().getColumns();
columns[LANGUAGE_CODE_COLUMN].setWidth(100);
columns[LANGUAGE_NAME_COLUMN].setWidth(240);
columns[LANGUAGE_BIDI_COLUMN].setWidth(100);
}
示例6: createColumns
import org.eclipse.swt.widgets.TreeColumn; //導入方法依賴的package包/類
private void createColumns() {
GC gc = new GC(getTree().getParent());
List<Integer> widths = new ArrayList<Integer>();
for (final IGenericTableColumn c : table.getColumns()) {
TreeViewerColumn viewerColumn = new TreeViewerColumn(this, SWT.NONE);
viewerColumn.setLabelProvider(new GenericLabelProvider(c
.getDataProvider()));
if (c.getEditable()) {
viewerColumn.setEditingSupport(c.getEditingSupport(this));
}
TreeColumn column = viewerColumn.getColumn();
if (c.getSortable() && comparator != null) {
column.addSelectionListener(getSelectionAdapter(column, c));
}
column.setText(c.getLabel());
column.setAlignment(c.getAlignMent());
int width;
if (c.getWidth() != -1) {
width = c.getWidth();
}
else if (c.getTextExtent() != null
&& c.getLabel().length() < c.getTextExtent().length()) {
width = gc.textExtent(c.getTextExtent()).x + 2;
}
else {
width = gc.textExtent(c.getLabel()).x + 2;
}
widths.add(width);
column.setWidth(width);
column.setResizable(c.getResizable());
}
gc.dispose();
// /* All columns have their prefered width set now calculate percentages */
// TreeColumnLayout layout = new TreeColumnLayout();
// for (int i = 0; i < widths.size(); i++) {
// layout.setColumnData(getTree().getColumns()[i], new ColumnWeightData(
// widths.get(i), widths.get(i), true));
// }
// getTree().getParent().setLayout(layout);
}