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


Java Table.getSelectionIndex方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.Table.getSelectionIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java Table.getSelectionIndex方法的具體用法?Java Table.getSelectionIndex怎麽用?Java Table.getSelectionIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.Table的用法示例。


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

示例1: deleteRow

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
private void deleteRow(){

		Table table = mappingTableViewer.getTable();
		setValueForCellEditor();
		int selectionIndex = table.getSelectionIndex();
		int[] indexs = table.getSelectionIndices();
		if (selectionIndex == -1) {
			WidgetUtility.errorMessage("Select Rows to delete");
		} else {
			table.remove(indexs);
			int itemsRemoved=0;
			for (int index : indexs) {
				mappingTableItemList.remove(index-itemsRemoved);
				if(index-itemsRemoved-1 != -1){
					table.setSelection(index-itemsRemoved-1);
				}else{
					table.setSelection(0);
				}
				itemsRemoved++;
			}
			mappingTableViewer.refresh();
		}
		refreshButtonStatus();
	
	}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:26,代碼來源:JoinMapDialog.java

示例2: deleteRow

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
private void deleteRow()
{
	Table table = mappingTableViewer.getTable();
	setValueForCellEditor();
	int selectionIndex = table.getSelectionIndex();
	int[] indexs = table.getSelectionIndices();
	if (selectionIndex == -1) {
		WidgetUtility.errorMessage("Select Rows to delete");
	} else {
		table.remove(indexs);
		int itemsRemoved=0;
		for (int index : indexs) {
			mappingTableItemList.remove(index-itemsRemoved);
			if(index-itemsRemoved-1 != -1){
				table.setSelection(index-itemsRemoved-1);
			}else{
				table.setSelection(0);
			}
			itemsRemoved++;
		}
		mappingTableViewer.refresh();
	}
	component.setLatestChangesInSchema(false);
	refreshButtonStatus();

}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:27,代碼來源:LookupMapDialog.java

示例3: selectionListenerAction

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
@Override
	public void selectionListenerAction(
			PropertyDialogButtonBar propertyDialogButtonBar,
			ListenerHelper helpers, Widget... widgets) {

		ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID);
		Table table =gridDetails.getTableViewer().getTable();
		int temp = table.getSelectionIndex();
		int[] indexs=table.getSelectionIndices();
		if (temp == -1) {
			WidgetUtility.errorMessage("Please Select row to delete");
		} else {
			table.remove(indexs);
			ArrayList tempList= new ArrayList();
			for (int index :indexs) { 
//				PropertyField test =(PropertyField) gridDetails.getGrids().get(index);
//				tempList.add(test);
			}
			 gridDetails.getGrids().removeAll(tempList); 
			
		}		
	}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:23,代碼來源:ELTTransformDeleteSelectionListener.java

示例4: deleteRow

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
private void deleteRow(TableViewer parameterTableViewer ){
	Table table = parameterTableViewer.getTable();
	int selectionIndex = table.getSelectionIndex();
	int[] indexs = table.getSelectionIndices();
	if (selectionIndex == -1) {
		WidgetUtility
				.errorMessage(ErrorMessages.SELECT_ROW_TO_DELETE);
	} else {
		table.remove(indexs);
		int itemsRemoved = 0;
		for (int index : indexs) {
			parameters.remove(index - itemsRemoved);
			itemsRemoved++;
		}
		parameterTableViewer.getTable().removeAll();
		parameterTableViewer.refresh();
	}
	
	if(indexs.length == 1 && parameters.size() > 0){//only one item is deleted
		if(parameters.size() == 1){//list contains only one element
			table.select(0);// select the first element
			parameterTableViewer.editElement(parameterTableViewer.getElementAt(0), 0);
		}
		else if(parameters.size() == indexs[0]){//deleted last item 
			table.select(parameters.size() - 1);//select the last element which now at the end of the list
			parameterTableViewer.editElement(parameterTableViewer.getElementAt(parameters.size() - 1), 0);
		}
		else if(parameters.size() > indexs[0]){//deleted element from middle of the list
			table.select( indexs[0] == 0 ? 0 : (indexs[0] - 1) );//select the element from at the previous location
			parameterTableViewer.editElement(parameterTableViewer.getElementAt(indexs[0] == 0 ? 0 : (indexs[0] - 1)), 0);
		}
	}
	else if(indexs.length >= 2){//multiple items are selected for deletion
		if(indexs[0] == 0){//delete from 0 to ...
			if(parameters.size() >= 1){//list contains only one element
				table.select(0);//select the remaining element
				parameterTableViewer.editElement(parameterTableViewer.getElementAt(0), 0);
			}
		}
		else{//delete started from element other than 0th element
			table.select((indexs[0])-1);//select element before the start of selection   
			parameterTableViewer.editElement(parameterTableViewer.getElementAt((indexs[0])-1), 0);
		}
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:46,代碼來源:MultiParameterFileDialog.java

示例5: setCursorOnDeleteRow

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
/**
 * Set the cursor on delete the row from table.
 * @param tableViewer
 * @param gridList
 */
public static void setCursorOnDeleteRow(TableViewer tableViewer, List<?> gridList){
	Table table = tableViewer.getTable();
	int[] indexes = table.getSelectionIndices();
	if (table.getSelectionIndex() == -1) {
		WidgetUtility.errorMessage(ERROR_MESSAGE);
	} else {
		table.remove(indexes);
		List listOfItemsToRemove= new ArrayList();
		for (int index : indexes) { 
			listOfItemsToRemove.add(gridList.get(index));
		}
		gridList.removeAll(listOfItemsToRemove);
		
	//highlight after deletion
	if(indexes.length == 1 && gridList.size() > 0){//only one item is deleted
		if(gridList.size() == 1){//list contains only one element
			table.select(0);// select the first element
			tableViewer.editElement(tableViewer.getElementAt(0), 0);
		}
		else if(gridList.size() == indexes[0]){//deleted last item 
			table.select(gridList.size() - 1);//select the last element which now at the end of the list
			tableViewer.editElement(tableViewer.getElementAt(gridList.size() - 1), 0);
		}
		else if(gridList.size() > indexes[0]){//deleted element from middle of the list
			table.select( indexes[0] == 0 ? 0 : (indexes[0] - 1) );//select the element from at the previous location
			tableViewer.editElement(tableViewer.getElementAt(indexes[0] == 0 ? 0 : (indexes[0] - 1)), 0);
		}
	}
	else if(indexes.length >= 2){//multiple items are selected for deletion
		if(indexes[0] == 0){//delete from 0 to ...
			if(gridList.size() >= 1){//list contains only one element
				table.select(0);//select the remaining element
				tableViewer.editElement(tableViewer.getElementAt(0), 0);
			}
		}
		else{//delete started from element other than 0th element
			table.select((indexes[0])-1);//select element before the start of selection   
			tableViewer.editElement(tableViewer.getElementAt((indexes[0])-1), 0);
		}
	}
  }
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:48,代碼來源:WidgetUtility.java

示例6: selectionListenerAction

import org.eclipse.swt.widgets.Table; //導入方法依賴的package包/類
@Override
public void selectionListenerAction(
		PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, Widget... widgets) {
	propertyDialogButtonBar.enableApplyButton(true);
	ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID);
	
	TableViewer tableViewer = gridDetails.getTableViewer();
	Table table = tableViewer.getTable();
	int[] indexes=table.getSelectionIndices();
	if (table.getSelectionIndex() == -1) {
		WidgetUtility.errorMessage("Please Select row to delete");
	} else {
		table.remove(indexes);
		List listOfItemsToRemove= new ArrayList();
		for (int index : indexes) { 
			listOfItemsToRemove.add(gridDetails.getGrids().get(index));
		}
		List<GridRow> gridsList = gridDetails.getGrids();
		gridsList.removeAll(listOfItemsToRemove);
		
		
		//highlight after deletion
		if(indexes.length == 1 && gridsList.size() > 0){//only one item is deleted
			if(gridsList.size() == 1){//list contains only one element
				table.select(0);// select the first element
				tableViewer.editElement(tableViewer.getElementAt(0), 0);
			}
			else if(gridsList.size() == indexes[0]){//deleted last item 
				table.select(gridsList.size() - 1);//select the last element which now at the end of the list
				tableViewer.editElement(tableViewer.getElementAt(gridsList.size() - 1), 0);
			}
			else if(gridsList.size() > indexes[0]){//deleted element from middle of the list
				table.select( indexes[0] == 0 ? 0 : (indexes[0] - 1) );//select the element from at the previous location
				tableViewer.editElement(tableViewer.getElementAt(indexes[0] == 0 ? 0 : (indexes[0] - 1)), 0);
			}
		}
		else if(indexes.length >= 2){//multiple items are selected for deletion
			if(indexes[0] == 0){//delete from 0 to ...
				if(gridsList.size() >= 1){//list contains only one element
					table.select(0);//select the remaining element
					tableViewer.editElement(tableViewer.getElementAt(0), 0);
				}
			}
			else{//delete started from element other than 0th element
				table.select((indexes[0])-1);//select element before the start of selection   
				tableViewer.editElement(tableViewer.getElementAt((indexes[0])-1), 0);
			}
		}
	}
	
	if (gridDetails.getGrids().size() >= 1) {
		((Button) widgets[1]).setEnabled(true);
	} else {
		((Button) widgets[1]).setEnabled(false);
	}
	
	if (gridDetails.getGrids().size() >= 2) {
		((Button) widgets[2]).setEnabled(true);
		((Button) widgets[3]).setEnabled(true);
	} else {
		((Button) widgets[2]).setEnabled(false);
		((Button) widgets[3]).setEnabled(false);
	}
	((Component)helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true);
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:67,代碼來源:ELTGridDeleteSelectionListener.java


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