Java Code Examples for org.eclipse.swt.widgets.Table.getColumnCount()

The following are Jave code examples for showing how to use getColumnCount() of the org.eclipse.swt.widgets.Table class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: gw4e.project   File: TableHelper.java   Source Code and License Vote up 6 votes
public static void handleEvent(Event event) {

		Table table = (Table) event.widget;
		int columnCount = table.getColumnCount();
		if (columnCount == 0)
			return;
		Rectangle area = table.getClientArea();
		int totalAreaWdith = area.width;
		int lineWidth = table.getGridLineWidth();
		int totalGridLineWidth = (columnCount - 1) * lineWidth;
		int totalColumnWidth = 0;
		for (TableColumn column : table.getColumns()) {
			totalColumnWidth = totalColumnWidth + column.getWidth();
		}
		int diff = totalAreaWdith - (totalColumnWidth + totalGridLineWidth);

		TableColumn lastCol = table.getColumns()[columnCount - 1];

		lastCol.setWidth(diff + lastCol.getWidth());

	}
 
Example 2
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 6 votes
private void selectAllInTable(TableViewer debugDataViewer, TableCursor tableCursor){
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	int recordCount = 0;
	
	for(int rowIndex = 0; rowIndex < tableItems.length; rowIndex++){
		TableItem tableItem = tableItems[rowIndex];
		for(int colIndex = 1; colIndex <= table.getColumnCount(); colIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(colIndex), findText.getText())){
				label.setVisible(false);
				tableItem.setBackground(colIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				recordCount++;
			}
		}
		findColIndex=1;
	}
	
	findRowIndex = 0;
	findColIndex = 0;
	
	if(recordCount > 0){
		label.setVisible(true);
		label.setText("Match count - " + recordCount);
	}else{ label.setVisible(false); }
	
}
 
Example 3
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 6 votes
private boolean isExistInTable(TableViewer tableViewer, String text){
  boolean isDataExist = false;
  Table table = tableViewer.getTable();
  TableItem[] tableItems = table.getItems();
  for(int i=0;i<tableItems.length;i++){
	TableItem tableItem = tableItems[i];
	for(int j=1;j <= table.getColumnCount()-1;j++){
		if(StringUtils.containsIgnoreCase(tableItem.getText(j), text)){
			label.setVisible(false);
			isDataExist = true;
			return isDataExist;
		}else{
			label.setVisible(true);
			label.setText(labelText);
			isDataExist =  false;
		}
		
	}
  }
return isDataExist;
 }
 
Example 4
Project: convertigo-eclipse   File: EngineLogView.java   Source Code and License Vote up 5 votes
private void createColumns() {
	Table table = tableViewer.getTable();

	while (table.getColumnCount() > 0) {
		table.getColumns()[0].dispose();
	}

	for (ColumnInfo columnInfo : columnInfos) {
		createTableViewerColumn(columnInfo);
	}

	// Set the column saved order
	table.setColumnOrder(columnOrder);
}
 
Example 5
Project: gw4e.project   File: CustomListWithButtons.java   Source Code and License Vote up 5 votes
/**
 * Refresh the Table Viewer
 */
private void refresh() {
	listViewer.refresh();
	Table table = listViewer.getTable();
	for (int i = 0, n = table.getColumnCount(); i < n; i++) {
		table.getColumn(i).pack();
	}
}
 
Example 6
Project: Hydrograph   File: JoinMapDialog.java   Source Code and License Vote up 5 votes
private void setTableLayoutToMappingTable(Table table) {
	TableColumnLayout layout = new TableColumnLayout();
	mappingTableViewer.getControl().getParent().setLayout(layout);

	for (int columnIndex = 0, n = table.getColumnCount(); columnIndex < n; columnIndex++) {
		table.getColumn(columnIndex).pack();
	}

	for (int i = 0; i < mappingTableViewer.getTable().getColumnCount(); i++) {
		layout.setColumnData(mappingTableViewer.getTable().getColumn(i),
				new ColumnWeightData(1));
	}
}
 
Example 7
Project: Hydrograph   File: LookupMapDialog.java   Source Code and License Vote up 5 votes
private void setTableLayoutToMappingTable(Table table) {
	TableColumnLayout layout = new TableColumnLayout();
	mappingTableViewer.getControl().getParent().setLayout(layout);

	for (int columnIndex = 0, n = table.getColumnCount(); columnIndex < n; columnIndex++) {
		table.getColumn(columnIndex).pack();
	}

	for (int i = 0; i < mappingTableViewer.getTable().getColumnCount(); i++) {
		layout.setColumnData(mappingTableViewer.getTable().getColumn(i),
				new ColumnWeightData(1));
	}
}
 
Example 8
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 5 votes
private void forwardTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex++;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	if(findColIndex == prevColSelection && findRowIndex == prevRowSelection){
		findColIndex++;
	}
	if(findRowIndex < 0){
		findRowIndex = 0;
	}
	for(;findRowIndex<tableItems.length;){
		TableItem tableItem = tableItems[findRowIndex];
		for(;findColIndex <= table.getColumnCount();findColIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				return;
			}
		}
		findRowIndex++;
		findColIndex=1;
		if(findRowIndex >= tableItems.length){ findRowIndex = 0;}
	}
}
 
Example 9
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 5 votes
private void reverseTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex -= 1;
	}
	if(findRowIndex < 0){
		findRowIndex = debugDataViewer.getTable().getItems().length - 1;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	for(; findRowIndex >=0; findRowIndex--){
		TableItem tableItem = tableItems[findRowIndex];
		for( ; findColIndex > 0 ;findColIndex--){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex,Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				if(findColIndex<=0){debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex-1);}else{
					debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				}
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				prevRowSelection = findRowIndex;
				return ;
			}
			
		}
		if(findColIndex <= 0){ findColIndex = table.getColumnCount();}
		if(findRowIndex == 0){ findRowIndex = tableItems.length; }
	}
}
 
Example 10
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 5 votes
private void clearTableItemBgColor(TableViewer debugDataViewer){
 if(debugDataViewer == null){
  return;
 }
 Table table = debugDataViewer.getTable();
 TableItem[] tableItems = table.getItems();
 for(int i=0;i<tableItems.length;i++){
TableItem tableItem = tableItems[i];
for(int j=1;j <= table.getColumnCount()-1;j++){
	tableItem.getText(j);
	tableItem.setBackground(j, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
 }
}