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

The following are Jave code examples for showing how to use getItems() 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.
+ Save this method
Example 1
Project: eZooKeeper   File: ZnodeAclComposite.java   View Source Code Vote up 6 votes
public List<ACL> getZnodeAclFromTable() {

        Table table = getTable();
        TableItem[] items = table.getItems();

        Set<ACL> aclSet = new HashSet<ACL>(items.length);
        for (TableItem item : items) {

            int perms = getItemPerms(item);
            Id id = getItemId(item);

            ACL acl = new ACL(perms, id);
            aclSet.add(acl);
        }
        return new ArrayList<ACL>(aclSet);
    }
 
Example 2
Project: Hydrograph   File: FindViewDataDialog.java   View Source Code 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   View Source Code 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: Hydrograph   File: SchemaRowValidation.java   View Source Code Vote up 5 votes
/**
 * @param gridRow
 * @param item
 * @param table
 * @param componentType
 * 
 * This method highlight invalid data row with red color.
 * 
 */
public void highlightInvalidRowWithRedColor(GridRow gridRow,TableItem item,Table table,String componentType ){ 
	this.table=table;
	if(item==null){
		for(TableItem tableItem:table.getItems()){		
	     setRedColorOnTableRowBasedOnInvalidData((GridRow)tableItem.getData(), componentType, tableItem);	
		}
	}else{
		 setRedColorOnTableRowBasedOnInvalidData(gridRow, componentType, item);	
		 gridRow=null;
	}
}
 
Example 5
Project: Hydrograph   File: FindViewDataDialog.java   View Source Code 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 6
Project: Hydrograph   File: FindViewDataDialog.java   View Source Code 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 7
Project: Hydrograph   File: FindViewDataDialog.java   View Source Code 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));
}
 }
}
 
Example 8
Project: SWET   File: TableEditorEx.java   View Source Code Vote up 4 votes
private static void appendRowToTable(Table table, List<String> stepIds) {

		TableItem[] tableItems = table.getItems();
		int cnt = 0;
		for (String stepId : stepIds) {

			// get element data
			TableItem tableItem = tableItems[cnt];
			Map<String, String> elementData = testData.get(stepId);
			String selectorChoice = selectorFromSWD
					.get(elementData.get("ElementSelectedBy"));

			String selectorValue = elementData
					.get(elementData.get("ElementSelectedBy"));

			// Append row into the TableEditor
			tableItem.setText(new String[] { elementData.get("ElementStepNumber"),
					elementData.get("ElementCodeName"), String.format("Action %d", cnt),
					selectorChoice, selectorValue });
			// some columns need to be converted to selects

			TableEditor keywordChoiceEditor = new TableEditor(table);
			CCombo keywordChoiceCombo = new CCombo(table, SWT.NONE);
			keywordChoiceCombo.setText("Choose..");
			for (String keyword : keywordTable.keySet()) {
				keywordChoiceCombo.add(keyword);
			}
			// NOTE: none of options is initially selected
			keywordChoiceEditor.grabHorizontal = true;
			int keywordChoiceColumn = 2;
			keywordChoiceCombo.setData("column", keywordChoiceColumn);
			keywordChoiceCombo.setData("item", tableItem);
			keywordChoiceEditor.setEditor(keywordChoiceCombo, tableItem,
					keywordChoiceColumn);
			keywordChoiceCombo.addModifyListener(new keywordChoiceListener());

			TableEditor selectorChoiceEditor = new TableEditor(table);
			CCombo selectorChoiceCombo = new CCombo(table, SWT.NONE);
			for (String locator : selectorFromSWD.values()) {
				selectorChoiceCombo.add(locator);
			}
			int currentSelector = new ArrayList<String>(selectorFromSWD.values())
					.indexOf(selectorFromSWD.get(elementData.get("ElementSelectedBy")));

			selectorChoiceCombo.select(currentSelector);
			selectorChoiceEditor.grabHorizontal = true;
			int selectorChoiceColumn = 3;
			selectorChoiceCombo.setData("item", tableItem);
			selectorChoiceCombo.setData("column", selectorChoiceColumn);
			selectorChoiceEditor.setEditor(selectorChoiceCombo, tableItem,
					selectorChoiceColumn);
			selectorChoiceCombo.addModifyListener(new selectorChoiceListener());
			cnt = cnt + 1;
		}
		return;
	}