org.eclipse.swt.widgets.TableColumn.addSelectionListener()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中org.eclipse.swt.widgets.TableColumn.addSelectionListener()方法的一些代码示例,展示了TableColumn.addSelectionListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableColumn.addSelectionListener()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.TableColumn
类名称:TableColumn
方法名:addSelectionListener

TableColumn.addSelectionListener介绍

[英]Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the column header is selected. widgetDefaultSelected is not called.
[中]通过发送SelectionListener界面中定义的消息之一,将侦听器添加到侦听器集合中,当用户选择控件时,将通知这些侦听器。
选择列标题时调用widgetSelected。未调用widgetDefaultSelected

代码示例

代码示例来源:origin: caoxinyu/RedisClient

tblclmnName.setWidth(150);
tblclmnName.setText(i18nFile.getText(I18nFile.NAME));
tblclmnName.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
tblclmnType.setWidth(150);
tblclmnType.setText(i18nFile.getText(I18nFile.TYPE));
tblclmnType.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
tblclmnSize.setWidth(100);
tblclmnSize.setText(i18nFile.getText(I18nFile.SIZE));
tblclmnSize.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: inspectIT/inspectIT

/**
 * Adds a column to this comparator so it can be used to sort by.
 *
 * @param column
 *            The {@link TableColumn} implementation. comparatorProvider The id of the
 *            {@link TableColumn} (user-defined).
 * @param comparator
 *            Comparator that will be used for the given column.
 */
public final void addColumn(final TableColumn column, final ResultComparator<T> comparator) {
  column.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      toggleSortColumn(comparator);
      Table table = column.getParent();
      table.setSortColumn(column);
      table.setSortDirection(getSortState().getSwtDirection());
    }
  });
}

代码示例来源:origin: org.eclipse/org.eclipse.datatools.enablement.oda.xml.ui

/**
 * Add listener to a column
 * @param column
 * @param n
 */
private void addColumnSortListener( TableColumn column, final int index )
{
  column.addSelectionListener( new SelectionListener( ) {
    private boolean asc = false;
    public void widgetSelected( SelectionEvent e )
    {
      sort( index, asc );
      asc = !asc;
    }
    public void widgetDefaultSelected( SelectionEvent e )
    {
    }
  } );
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

/**
 * Constructor
 * 
 * @param cviewer
 * @param column
 */
public ColumnSorter(ColumnViewer cviewer, TableColumn column) {
  this.cviewer = cviewer;
  this.column = column;
  this.columnidx = getColumnIndex();
  this.column.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      if (ColumnSorter.this.cviewer.getComparator() != ColumnSorter.this) {
        setDirection(SWT.DOWN);
      } else {
        int tdirection = ColumnSorter.this.column.getParent().getSortDirection();
        if (tdirection == SWT.NONE) {
          setDirection(SWT.DOWN);
        } else {
          setDirection(tdirection == SWT.UP ? SWT.DOWN : SWT.UP);
        }
      }
    }
  });
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

protected void addTableListeners (EventAdapter adapter, Table ta) {
  ta.addSelectionListener(adapter);
  TableColumn[] cols = ta.getColumns();
  for(int i=0;i<cols.length;i++) {
    cols[i].addSelectionListener(adapter);
  }
}

代码示例来源:origin: inspectIT/inspectIT

/**
 * @param tableViewer
 *            {@link TableViewer}.
 * @param tableInputController
 *            {@link TableInputController}.
 * @param repositoryDefinition
 *            {@link RepositoryDefinition}. Needed for
 *            {@link rocks.inspectit.ui.rcp.editor.search.factory.SearchFactory}.
 */
public TableViewerSearchHelper(TableViewer tableViewer, TableInputController tableInputController, RepositoryDefinition repositoryDefinition) {
  super(repositoryDefinition);
  this.tableViewer = tableViewer;
  this.tableInputController = tableInputController;
  for (TableColumn tableColumn : tableViewer.getTable().getColumns()) {
    tableColumn.addSelectionListener(getColumnSortingListener());
  }
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java16

/**
 * Creates and installs a TableComparatorChooser.
 *
 * @deprecated replaced with {@link #install}, which is functionally
 * identical but uses a more fitting name to convey the action that is
 * performed.
 */
@Deprecated
public TableComparatorChooser(DefaultEventTableViewer<E> eventTableViewer, SortedList<E> sortedList, boolean multipleColumnSort) {
  super(sortedList, eventTableViewer.getTableFormat());
  // save the SWT-specific state
  this.table = eventTableViewer.getTable();
  // listen for events on the specified table
  for(int c = 0; c < table.getColumnCount(); c++) {
    table.getColumn(c).addSelectionListener(columnListener);
  }
  // sort using the specified approach
  sortingStrategy = new MouseOnlySortingStrategy(multipleColumnSort);
}

代码示例来源:origin: org.apache.uima/uimaj-ep-pear-packager

@Override
protected void createTableColumns() {
 // 1st column with image/checkboxes - NOTE: The SWT.CENTER has no effect!!
 TableColumn column = new TableColumn(table, SWT.LEFT, 0);
 column.setText("Property Name");
 column.setWidth(200);
 // Add listener to column so tableRows are sorted by description when clicked
 column.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
   tableViewer.setSorter(new VarValSorter(VarValSorter.VAR_NAME));
  }
 });
 // 2nd column with tableRow Description
 column = new TableColumn(table, SWT.LEFT, 1);
 column.setText("Property Value");
 column.setWidth(250);
 // Add listener to column so tableRows are sorted by description when clicked
 column.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
   tableViewer.setSorter(new VarValSorter(VarValSorter.VAR_VALUE));
  }
 });
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * Creates and installs a TableComparatorChooser.
 *
 * @deprecated replaced with {@link #install}, which is functionally
 * identical but uses a more fitting name to convey the action that is
 * performed.
 */
public TableComparatorChooser(DefaultEventTableViewer<E> eventTableViewer, SortedList<E> sortedList, boolean multipleColumnSort) {
  super(sortedList, eventTableViewer.getTableFormat());
  // save the SWT-specific state
  this.table = eventTableViewer.getTable();
  // listen for events on the specified table
  for(int c = 0; c < table.getColumnCount(); c++) {
    table.getColumn(c).addSelectionListener(columnListener);
  }
  // sort using the specified approach
  sortingStrategy = new MouseOnlySortingStrategy(multipleColumnSort);
}

代码示例来源:origin: com.haulmont.thirdparty/glazedlists

/**
 * Creates and installs a TableComparatorChooser.
 *
 * @deprecated replaced with {@link #install}, which is functionally
 * identical but uses a more fitting name to convey the action that is
 * performed.
 */
public TableComparatorChooser(EventTableViewer<E> eventTableViewer, SortedList<E> sortedList, boolean multipleColumnSort) {
  super(sortedList, eventTableViewer.getTableFormat());
  // save the SWT-specific state
  this.table = eventTableViewer.getTable();
  // listen for events on the specified table
  for(int c = 0; c < table.getColumnCount(); c++) {
    table.getColumn(c).addSelectionListener(columnListener);
  }
  // sort using the specified approach
  sortingStrategy = new MouseOnlySortingStrategy(multipleColumnSort);
}

代码示例来源:origin: org.eclipse/org.eclipse.team.ui

col.setResizable(true);
col.setText(TeamUIMessages.GenericHistoryTableProvider_Revision); 
col.addSelectionListener(headerListener);
layout.addColumnData(new ColumnWeightData(20, true));
col.setResizable(true);
col.setText(TeamUIMessages.GenericHistoryTableProvider_RevisionTime); 
col.addSelectionListener(headerListener);
layout.addColumnData(new ColumnWeightData(20, true));
col.setResizable(true);
col.setText(TeamUIMessages.GenericHistoryTableProvider_Author); 
col.addSelectionListener(headerListener);
layout.addColumnData(new ColumnWeightData(20, true));
col.setResizable(true);
col.setText(TeamUIMessages.GenericHistoryTableProvider_Comment); 
col.addSelectionListener(headerListener);
layout.addColumnData(new ColumnWeightData(50, true));

代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui

/**
 * Creates the columns for the history table.
 */
private void createColumns(Table table, TableLayout layout, TableViewer viewer) {
  SelectionListener headerListener = getColumnListener(viewer);
  // revision
  TableColumn col = new TableColumn(table, SWT.NONE);
  col.setResizable(true);
  col.setText(TeamUIMessages.GenericHistoryTableProvider_Revision);
  col.addSelectionListener(headerListener);
  layout.addColumnData(new ColumnWeightData(20, true));
  // creation date
  col = new TableColumn(table, SWT.NONE);
  col.setResizable(true);
  col.setText(TeamUIMessages.GenericHistoryTableProvider_RevisionTime);
  col.addSelectionListener(headerListener);
  layout.addColumnData(new ColumnWeightData(20, true));
  // author
  col = new TableColumn(table, SWT.NONE);
  col.setResizable(true);
  col.setText(TeamUIMessages.GenericHistoryTableProvider_Author);
  col.addSelectionListener(headerListener);
  layout.addColumnData(new ColumnWeightData(20, true));
  //comment
  col = new TableColumn(table, SWT.NONE);
  col.setResizable(true);
  col.setText(TeamUIMessages.GenericHistoryTableProvider_Comment);
  col.addSelectionListener(headerListener);
  layout.addColumnData(new ColumnWeightData(50, true));
}

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

public void createTableColumnInternal(Language language) {
 TableColumn c = new TableColumn(m_table, SWT.LEAD);
 c.setData(LANGUAGE_COLUMN_ID, language);
 if (!language.isLocal()) {
  c.setToolTipText("this language is only in the parent defined!\nCreate a new language for " + language.getLocale().toString() + " to make it locally available.");
  c.setImage(NlsCore.getImage(INlsIcons.WARNING));
 }
 c.setText(language.getDispalyName());
 c.setMoveable(true);
 c.addSelectionListener(new P_SortSelectionAdapter(m_table.indexOf(c)));
 c.setWidth(200);
}

代码示例来源:origin: openaudible/openaudible

column.addSelectionListener(getColumnListener());

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

@SuppressWarnings("squid:S881")
private void createColumns(Table table) {
 // cleare old columns
 TableColumn[] cols = m_table.getColumns();
 for (TableColumn col : cols) {
  col.dispose();
 }
 // utility columns
 TableColumn colRefs = new TableColumn(table, SWT.LEAD);
 colRefs.setResizable(false);
 colRefs.setMoveable(false);
 colRefs.setWidth(45);
 colRefs.setText("*");
 colRefs.setToolTipText("* if the references are not sync!");
 colRefs.addSelectionListener(new P_SortSelectionAdapter(0));
 int i = NlsTable.INDEX_COLUMN_KEYS;
 // nls java column
 TableColumn jColumn = new TableColumn(table, SWT.LEAD);
 jColumn.setText(Language.LANGUAGE_KEY.getDispalyName());
 jColumn.setData(LANGUAGE_COLUMN_ID, Language.LANGUAGE_KEY);
 jColumn.setMoveable(false);
 jColumn.setWidth(200);
 jColumn.addSelectionListener(new P_SortSelectionAdapter(i++));
 if (m_tableModel.getProjects() != null) {
  for (Language language : m_tableModel.getProjects().getAllLanguages()) {
   createTableColumnInternal(language);
  }
  m_filterComp.columnsChanged();
 }
}

代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies

private void createColumns(final TableViewer tableViewer) {
 final String[] titles = { "Class" };
 final int[] bounds = { 120, 100, 200 };
 for (int i = 0; i < titles.length; i++) {
  final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
  tableViewer.setSorter(new TableViewerSorter(titles));
  viewerColumn.setLabelProvider(new TableCellLabelProvider());
  final TableColumn column = viewerColumn.getColumn();
  column.addSelectionListener(new ColumnSelectionListener(column, tableViewer));
  column.setText(titles[i]);
  column.setWidth(bounds[i]);
  column.setResizable(true);
  column.setMoveable(false);
 }
 final Table table = tableViewer.getTable();
 table.setHeaderVisible(true);
 table.setLinesVisible(true);
 ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);
}

代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies

private void createColumns(final TableViewer tableViewer) {
 final String[] titles = { "Relation", "Type", "Name" };
 final int[] bounds = { 120, 100, 200 };
 for (int i = 0; i < titles.length; i++) {
  final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
  tableViewer.setSorter(new TableViewerSorter(titles));
  viewerColumn.setLabelProvider(new TableCellLabelProvider());
  final TableColumn column = viewerColumn.getColumn();
  column.addSelectionListener(new ColumnSelectionListener(column, tableViewer));
  column.setText(titles[i]);
  column.setWidth(bounds[i]);
  column.setResizable(true);
  column.setMoveable(false);
 }
 final Table table = tableViewer.getTable();
 table.setHeaderVisible(true);
 table.setLinesVisible(true);
 ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);
 // Object[] projectsToSelect = openProjects.toArray();
 // IViewPart view = window.getActivePage().showView( "org.eclipse.jdt.ui.PackageExplorer" );
 // view.getSite().getSelectionProvider().setSelection( new StructuredSelection( projectsToSelect ) );
}

代码示例来源:origin: org.eclipse.equinox.p2/ui

tc.setWidth(convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH));
tc.addSelectionListener(new SelectionListener() {
  public void widgetDefaultSelected(SelectionEvent e) {
    columnSelected((TableColumn) e.widget);

代码示例来源:origin: openaudible/openaudible

public void changeTableLayout(int i) {
  table.setVisible(false);
  table.removeAll();
  TableColumn tc[] = table.getColumns();
  for (TableColumn aTc : tc) {
    aTc.dispose();
  }
  numColumns = i;
  
  for (int x = 0; x < numColumns; x++) {
    TableColumn column = new TableColumn(table, SWT.LEFT);
    String n = getColumnName(x);
    Image r = getColumnImage(x);
    column.setImage(r);
    column.setText(n);
    column.setWidth(getColumnWidth(x));
  }
  setColumWidths();
  // populateData(); // TODO: See about removing this.
  ColumnListener columnListener = getColumnListener();
  for (int c = 0; c < table.getColumnCount(); c++) {
    table.getColumn(c).addSelectionListener(columnListener);
  }
  table.setVisible(true);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

column.setWidth(150);
final int columnIndex = i;
column.addSelectionListener(widgetSelectedAdapter(e -> sort(columnIndex)));

相关文章