Java Code Examples for org.jdesktop.swingx.table.TableColumnModelExt

The following examples show how to use org.jdesktop.swingx.table.TableColumnModelExt. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dsworkbench   Source File: PropertyHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static void storeTableProperties(JXTable pTable, Configuration pConfig, String pPrefix) {
  List<TableColumn> cols = ((TableColumnModelExt) pTable.getColumnModel()).getColumns(true);

  for (TableColumn c : cols) {
    TableColumnExt col = (TableColumnExt) c;
    String title = col.getTitle();
    pConfig.setProperty(pPrefix + ".table.col." + title + ".width", col.getWidth());
    pConfig.setProperty(pPrefix + ".table.col." + title + ".visible", col.isVisible());
  }
  int sortedCol = pTable.getSortedColumnIndex();
  if (sortedCol < 0) {
    return;
  }
  pConfig.setProperty(pPrefix + ".table.sort.col", sortedCol);
  int sortOrder = 0;
  switch (pTable.getSortOrder(sortedCol)) {
    case ASCENDING:
      sortOrder = 1;
      break;
    case DESCENDING:
      sortOrder = -1;
      break;
    default:
      sortOrder = 0;
  }
  pConfig.setProperty(pPrefix + ".table.sort.order", sortOrder);
  pConfig.setProperty(pPrefix + ".table.horizontal.scroll", pTable.isHorizontalScrollEnabled());
}
 
Example 2
Source Project: chipster   Source File: ImportPreviewTable.java    License: MIT License 5 votes vote down vote up
/**
 * Updates table header. Gets the header value from table if cell header row 
 * is selected. Otherwise the header value is just column numbers.
 *
 */
private void updateTableHeader(){
	TableColumnModelExt model = new DefaultTableColumnModelExt();
	Object[] columnTitles = conversionModel.getColumnTitles();
	
	for(int column = 0; column < columnTitles.length; column++){
		
		if(column >= this.getColumnCount()){
			/*
			 * The TitleRowChangeEvent is fired after data chopping is done. 
			 * This means that this method may be called before the table is updated. 
			 * In this case, if the column count is changed, ArrayIndexOutOfBounds exception 
			 * may occure.
			 *  
			 * So, let's break the loop and wait that this method is called by updateTable 
			 * method a bit later.
			 */
			break;
		}
		TableColumn newColumn = this.getColumnModel().getColumn(column);
		
		if(column >= 1){ 
			
			//Now text to the upper left corner cell
			if(newColumn.getHeaderRenderer() instanceof PanelTableHeaderRenderer){
				//For custom header of second step
				((PanelTableHeaderRenderer)newColumn.getHeaderRenderer()).
				setTitleText(columnTitles[column].toString());
			} else {
				//For step 1				
				newColumn.setHeaderValue(columnTitles[column]);
			}
		}
		
		model.addColumn(newColumn);
	} 
	this.setColumnModel(model);
	
	logger.debug("Table header updated");
}
 
Example 3
Source Project: cuba   Source File: DesktopAbstractTable.java    License: Apache License 2.0 4 votes vote down vote up
protected List<TableColumn> getAllColumns() {
    return ((TableColumnModelExt) impl.getColumnModel()).getColumns(true);
}