當前位置: 首頁>>代碼示例>>Java>>正文


Java RowSorter類代碼示例

本文整理匯總了Java中javax.swing.RowSorter的典型用法代碼示例。如果您正苦於以下問題:Java RowSorter類的具體用法?Java RowSorter怎麽用?Java RowSorter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RowSorter類屬於javax.swing包,在下文中一共展示了RowSorter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSortKeys

import javax.swing.RowSorter; //導入依賴的package包/類
public void setSortKeys(List newKeys) {
    if (newKeys == null) {
        setSortKeysImpl(newKeys);
        return;
    }
    
    RowSorter.SortKey oldKey = getSortKey();
    RowSorter.SortKey newKey = (RowSorter.SortKey)newKeys.get(0);
    
    if (oldKey == null || oldKey.getColumn() != newKey.getColumn()) {
        // Use defined initial SortOrder for a newly sorted column
        setSortColumn(newKey.getColumn());
    } else {
        setSortKeysImpl(newKeys);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:ProfilerRowSorter.java

示例2: getIcon

import javax.swing.RowSorter; //導入依賴的package包/類
/**
 * Overridden to return an icon suitable to a sorted column, or null if the
 * column is unsorted. The icon for the primary sorted column is fully
 * opaque, and the opacity is reduced by a factor of
 * <code>alpha</code> for each subsequent sort index.
 *
 * @param table the <code>JTable</code>.
 * @param column the column index.
 * @return the sort icon with appropriate opacity, or null if the column is
 * unsorted.
 */
@Override
public Icon getIcon(JTable table, int column) {
    float computedAlpha = 1.0F;
    for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
        if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
            switch (sortKey.getSortOrder()) {
                case ASCENDING:
                    return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
                case DESCENDING:
                    return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
                    
                default:
                    // Just to remove unmatched case warning
            }
        }
        computedAlpha *= alpha;
    }
    return null;
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:31,代碼來源:MultiColumnSortTableHeaderCellRenderer.java

示例3: getColumnSortOrder

import javax.swing.RowSorter; //導入依賴的package包/類
public static SortOrder getColumnSortOrder(JTable table, int column)
{
    SortOrder rv = null;

    if (table == null || table.getRowSorter() == null)
    {
        return rv;
    }

    java.util.List<? extends RowSorter.SortKey> sortKeys = table
            .getRowSorter().getSortKeys();

    if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table
            .convertColumnIndexToModel(column))
    {
        rv = sortKeys.get(0).getSortOrder();
    }

    return rv;
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:21,代碼來源:LuckTableCellHeaderRenderer.java

示例4: DetailsView

import javax.swing.RowSorter; //導入依賴的package包/類
/** Creates new form DetailsView 
     * @param rowSorter 
    */
    public DetailsView(List<Row> rows, int size, DataModel dataModel, Table table, int rowIndex, RowSorter<? extends TableModel> rowSorter, boolean showSpinner) {
        this.table = table;
    	this.rows = rows;
    	this.rowSorter = rowSorter;
        initComponents();
        if (rowSorter != null) {
        	rowIndex = rowSorter.convertRowIndexToView(rowIndex);
        }
        final SpinnerNumberModel model = new SpinnerNumberModel(rowIndex + 1, 1, size, -1);
        rowSpinner.setModel(model);
        rowSpinner.addChangeListener(new ChangeListener() {
			@Override
			public void stateChanged(ChangeEvent e) {
				setCurrentRow((Integer) model.getValue() - 1, true);
			}
		});
        if (!showSpinner) {
        	jLabel1.setVisible(false);
        	rowSpinner.setVisible(false);
//        	jScrollPane1.setBorder(null);
        	jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
			jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		}
        setCurrentRow(rowIndex, showSpinner);
    }
 
開發者ID:P15,項目名稱:jailer,代碼行數:29,代碼來源:DetailsView.java

示例5: setSourceModel

import javax.swing.RowSorter; //導入依賴的package包/類
public void setSourceModel(ListSelectionModel listSelectionModel,
		RowSorter<?> rowSorter) {
	if (this.sourceModel != null) {
		this.sourceModel.removeListSelectionListener(targetModelSync);
	}

	if (rowSorter == null) {
		targetModelSync.setIndexConverter(null);
		sourceModelSync.setIndexConverter(null);
	} else {
		targetModelSync
				.setIndexConverter(new ViewToModelRowSorterConverter(
						rowSorter));
		sourceModelSync
				.setIndexConverter(new ModelToViewRowSorterConverter(
						rowSorter));
	}
	this.sourceModel = listSelectionModel;
	if (this.sourceModel != null) {
		sourceModelSync.setTargetModel(sourceModel, targetModelSync);
		this.sourceModel.addListSelectionListener(targetModelSync);
	}
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:24,代碼來源:RowSorterAwareListSelectionModelUpdater.java

示例6: updateClusterTable

import javax.swing.RowSorter; //導入依賴的package包/類
private void updateClusterTable() {
	int index = annotationSetCombo.getSelectedIndex();
	AnnotationSet annotationSet = annotationSetCombo.getItemAt(index).getValue();
	ClusterTableModel clusterModel = new ClusterTableModel(annotationSet);
	
	int widths[] = getColumnWidths(clusterTable);
	clusterTable.setModel(clusterModel);
	setColumnWidths(clusterTable, widths);
	TableColumn collapsedColumn = clusterTable.getColumnModel().getColumn(ClusterTableModel.COLLAPSED_COLUMN_INDEX);
	collapsedColumn.setCellRenderer(new ClusterTableCollapsedCellRenderer(iconManager));
	
	
	// sort
	TableRowSorter<TableModel> sorter = new TableRowSorter<>(clusterTable.getModel());
	clusterTable.setRowSorter(sorter);
	List<SortKey> sortKeys = new ArrayList<>(2);
	sortKeys.add(new RowSorter.SortKey(ClusterTableModel.NODES_COLUMN_INDEX, SortOrder.DESCENDING));
	sortKeys.add(new RowSorter.SortKey(ClusterTableModel.CLUSTER_COLUMN_INDEX, SortOrder.ASCENDING));
	sorter.setSortKeys(sortKeys);
	sorter.sort();
}
 
開發者ID:BaderLab,項目名稱:AutoAnnotateApp,代碼行數:22,代碼來源:ClusterPanel.java

示例7: getIcon

import javax.swing.RowSorter; //導入依賴的package包/類
/**
 * Overridden to return an icon suitable to a sorted column, or null if the column is unsorted.
 * The icon for the primary sorted column is fully opaque, and the opacity is reduced by a
 * factor of <code>alpha</code> for each subsequent sort index.
 *
 * @param table the <code>JTable</code>.
 * @param column the column index.
 * @return the sort icon with appropriate opacity, or null if the column is unsorted.
 */
public Icon getIcon(JTable table, int column) {
  float computedAlpha = 1.0F;
  for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
    if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
      switch (sortKey.getSortOrder()) {
        case ASCENDING:
          return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
        case DESCENDING:
          return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
      }
    }
    computedAlpha *= alpha;
  }
  return null;
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:25,代碼來源:MultisortTableHeaderCellRenderer.java

示例8: setTeamProjectTable

import javax.swing.RowSorter; //導入依賴的package包/類
public void setTeamProjectTable(final ServerContextTableModel tableModel, final ListSelectionModel selectionModel) {
    teamProjectTable.setModel(tableModel);
    teamProjectTable.setSelectionModel(selectionModel);

    // Setup table sorter
    final RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
    teamProjectTable.setRowSorter(sorter);

    // Attach an index converter to fix the indexes if the user sorts the list
    tableModel.setSelectionConverter(new TableModelSelectionConverter() {
        @Override
        public int convertRowIndexToModel(int viewRowIndex) {
            if (viewRowIndex >= 0) {
                return teamProjectTable.convertRowIndexToModel(viewRowIndex);
            }

            return viewRowIndex;
        }
    });
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:21,代碼來源:ImportForm.java

示例9: setContextTable

import javax.swing.RowSorter; //導入依賴的package包/類
public void setContextTable(final ServerContextTableModel tableModel, final ListSelectionModel selectionModel) {
    contextTable.setModel(tableModel);
    contextTable.setSelectionModel(selectionModel);

    // Setup table sorter
    final RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
    contextTable.setRowSorter(sorter);

    // Attach an index converter to fix the indexes if the user sorts the list
    tableModel.setSelectionConverter(new TableModelSelectionConverter() {
        @Override
        public int convertRowIndexToModel(int viewRowIndex) {
            if (viewRowIndex >= 0) {
                return contextTable.convertRowIndexToModel(viewRowIndex);
            }
            return viewRowIndex;
        }
    });
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:20,代碼來源:TeamServicesSettingsForm.java

示例10: setWorkItemTable

import javax.swing.RowSorter; //導入依賴的package包/類
public void setWorkItemTable(final WorkItemsTableModel tableModel, final ListSelectionModel selectionModel) {
    workItemTable.setModel(tableModel);
    workItemTable.setSelectionModel(selectionModel);

    // Setup table sorter
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
    workItemTable.setRowSorter(sorter);

    // Attach an index converter to fix the indexes if the user sorts the list
    tableModel.setSelectionConverter(new TableModelSelectionConverter() {
        @Override
        public int convertRowIndexToModel(int viewRowIndex) {
            if (viewRowIndex >= 0) {
                return workItemTable.convertRowIndexToModel(viewRowIndex);
            }

            return viewRowIndex;
        }
    });
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:21,代碼來源:SelectWorkItemsForm.java

示例11: setRepositoryTable

import javax.swing.RowSorter; //導入依賴的package包/類
public void setRepositoryTable(final ServerContextTableModel tableModel, final ListSelectionModel selectionModel) {
    repositoryTable.setModel(tableModel);
    repositoryTable.setSelectionModel(selectionModel);

    // Setup table sorter
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
    repositoryTable.setRowSorter(sorter);

    // Attach an index converter to fix the indexes if the user sorts the list
    tableModel.setSelectionConverter(new TableModelSelectionConverter() {
        @Override
        public int convertRowIndexToModel(int viewRowIndex) {
            if (viewRowIndex >= 0) {
                return repositoryTable.convertRowIndexToModel(viewRowIndex);
            }

            return viewRowIndex;
        }
    });
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:21,代碼來源:CheckoutForm.java

示例12: getSortedColumn

import javax.swing.RowSorter; //導入依賴的package包/類
/**
 * Returns the primary sort column, or null if nothing sorted or no sortKey
 *   corresponds to a TableColumn currently contained in the TableColumnModel.
 * 
 * @return the currently interactively sorted TableColumn or null if there
 *         is not sorter active or if the sorted column index does not
 *         correspond to any column in the TableColumnModel.
 */
public TableColumn getSortedColumn() {
    // bloody hack: get primary SortKey and
    // check if there's a column with it available
    RowSorter<?> controller = getRowSorter();
    if (controller != null) {
        // PENDING JW: must use RowSorter?
        SortKey sortKey = SortUtils.getFirstSortingKey(controller
                .getSortKeys());
        if (sortKey != null) {
            int sorterColumn = sortKey.getColumn();
            List<TableColumn> columns = getColumns(true);
            for (Iterator<TableColumn> iter = columns.iterator(); iter
                    .hasNext();) {
                TableColumn column = iter.next();
                if (column.getModelIndex() == sorterColumn) {
                    return column;
                }
            }

        }
    }
    return null;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:32,代碼來源:JXTable.java

示例13: mouseClicked

import javax.swing.RowSorter; //導入依賴的package包/類
@Override
public void mouseClicked( MouseEvent e ) {
  JBroTableHeader header = getHeader();
  if ( !header.isEnabled() )
    return;
  Point point = e.getPoint();
  JBroTableColumn column = getColumnAtPoint( point );
  if ( column == null )
    return;
  if ( isLeaf( column ) && e.getClickCount() == 1 && SwingUtilities.isLeftMouseButton( e ) ) {
    JTable table = header.getTable();
    RowSorter sorter;
    if ( table != null && ( sorter = table.getRowSorter() ) != null ) {
      int columnIndex = column.getModelIndex();
      if ( columnIndex != -1 ) {
        sorter.toggleSortOrder( columnIndex );
        header.repaint();
      }
    }
  }
}
 
開發者ID:Qualtagh,項目名稱:JBroTable,代碼行數:22,代碼來源:JBroTableHeaderUI.java

示例14: toNumericKeys

import javax.swing.RowSorter; //導入依賴的package包/類
private RowSorter.SortKey[] toNumericKeys( SortKey... modelColumns ) {
  if ( modelColumns != null && modelColumns.length != 0 ) {
    JBroTable table = getTable();
    ModelData data = table.getData();
    RowSorter.SortKey keys[] = new RowSorter.SortKey[ modelColumns.length ];
    for ( int i = 0; i < modelColumns.length; i++ ) {
      SortKey modelColumn = modelColumns[ i ];
      int col = data.getIndexOfModelField( modelColumn.getColumn() );
      if ( col < 0 )
        throw new IllegalArgumentException( "Field \"" + modelColumn.getColumn() + "\" not found" );
      RowSorter.SortKey key = new RowSorter.SortKey( col, modelColumn.getSortOrder() );
      keys[ i ] = key;
    }
    return keys;
  }
  return null;
}
 
開發者ID:Qualtagh,項目名稱:JBroTable,代碼行數:18,代碼來源:JBroPredefinedRowSorter.java

示例15: toStringKeys

import javax.swing.RowSorter; //導入依賴的package包/類
private SortKey[] toStringKeys( RowSorter.SortKey... modelColumns ) {
  if ( modelColumns != null && modelColumns.length != 0 ) {
    JBroTable table = getTable();
    ModelData data = table.getData();
    ModelField fields[] = data.getFields();
    SortKey keys[] = new SortKey[ modelColumns.length ];
    for ( int i = 0; i < modelColumns.length; i++ ) {
      RowSorter.SortKey modelColumn = modelColumns[ i ];
      ModelField col = fields[ modelColumn.getColumn() ];
      SortKey key = new SortKey( col.getIdentifier(), modelColumn.getSortOrder() );
      keys[ i ] = key;
    }
    return keys;
  }
  return EMPTY_ARRAY;
}
 
開發者ID:Qualtagh,項目名稱:JBroTable,代碼行數:17,代碼來源:JBroPredefinedRowSorter.java


注:本文中的javax.swing.RowSorter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。