本文整理汇总了Java中javafx.scene.control.TableView.TableViewSelectionModel.clearSelection方法的典型用法代码示例。如果您正苦于以下问题:Java TableViewSelectionModel.clearSelection方法的具体用法?Java TableViewSelectionModel.clearSelection怎么用?Java TableViewSelectionModel.clearSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableView.TableViewSelectionModel
的用法示例。
在下文中一共展示了TableViewSelectionModel.clearSelection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectCells
import javafx.scene.control.TableView.TableViewSelectionModel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") public void selectCells(TableView<?> tableView, String value) {
@SuppressWarnings("rawtypes")
TableViewSelectionModel selectionModel = tableView.getSelectionModel();
selectionModel.clearSelection();
JSONObject cells = new JSONObject(value);
JSONArray object = (JSONArray) cells.get("cells");
for (int i = 0; i < object.length(); i++) {
JSONArray jsonArray = object.getJSONArray(i);
int rowIndex = Integer.parseInt(jsonArray.getString(0));
int columnIndex = getColumnIndex(jsonArray.getString(1));
@SuppressWarnings("rawtypes")
TableColumn column = tableView.getColumns().get(columnIndex);
if (getVisibleCellAt(tableView, rowIndex, columnIndex) == null) {
tableView.scrollTo(rowIndex);
tableView.scrollToColumn(column);
}
selectionModel.select(rowIndex, column);
}
}
示例2: tableSelectCell
import javafx.scene.control.TableView.TableViewSelectionModel; //导入方法依赖的package包/类
private void tableSelectCell() {
int starRowtIndex = startRowIndexProperty.get();
int endRowIndex = endRowIndexProperty.get();
int starColtIndex = startColIndexProperty.get();
int endColIndex = endColIndexProperty.get();
TableViewSelectionModel<Map<String, Object>> selectionModel = tbResult.getSelectionModel();
selectionModel.clearSelection();
if (starColtIndex == 0) {
selectionModel.selectRange(starRowtIndex, tbResult.getColumns().get(0), endRowIndex,
tbResult.getColumns().get(tbResult.getColumns().size() - 1));
} else {
selectionModel.selectRange(starRowtIndex, tbResult.getColumns().get(starColtIndex), endRowIndex,
tbResult.getColumns().get(endColIndex));
}
}
示例3: marathon_select
import javafx.scene.control.TableView.TableViewSelectionModel; //导入方法依赖的package包/类
@Override public boolean marathon_select(String value) {
TableView<?> tableView = (TableView<?>) node;
TableViewSelectionModel<?> selectionModel = tableView.getSelectionModel();
if ("".equals(value)) {
selectionModel.clearSelection();
return true;
} else if (value.equals("all")) {
int rowSize = tableView.getItems().size();
for (int i = 0; i < rowSize; i++) {
selectionModel.select(i);
}
return true;
} else if (selectionModel.isCellSelectionEnabled()) {
selectCells(tableView, value);
return true;
} else {
int[] selectedRows = getSelectedRows(value);
selectionModel.clearSelection();
for (int rowIndex : selectedRows) {
if (getVisibleCellAt(tableView, rowIndex, tableView.getColumns().size() - 1) == null) {
tableView.scrollTo(rowIndex);
}
selectionModel.select(rowIndex);
}
return true;
}
}
示例4: generateRowMovementButtonHandlers
import javafx.scene.control.TableView.TableViewSelectionModel; //导入方法依赖的package包/类
/**
* @param movementDirection - enum to specify if the row movement is up or down
* @return an EventHandler for the row movement buttons
*/
private EventHandler<ActionEvent> generateRowMovementButtonHandlers(RowMovementDirection movementDirection)
{
int moveToPosition = movementDirection == RowMovementDirection.UP ? -1 : 1;
return event ->
{
ObservableList<PacketTypeToMatch> items = table.getItems();
TableViewSelectionModel<PacketTypeToMatch> selectionModel = table.getSelectionModel();
List<Integer> modifiableIndices = new ArrayList<>(selectionModel.getSelectedIndices());
int[] reSelectRows = new int[modifiableIndices.size()];
int i = 0;
if (movementDirection == RowMovementDirection.DOWN) //if we are moving down, we should start from the last index and go backwards
Collections.reverse(modifiableIndices);
for (Integer selectedIndex : modifiableIndices)
{
if (selectedIndex == (movementDirection == RowMovementDirection.UP ? 0 : items.size() - 1)) //if it's the first or last row (depending on movement direction), don't do anything
{
reSelectRows[i++] = selectedIndex;
continue;
}
PacketTypeToMatch itemToReplace = items.set(selectedIndex + moveToPosition, items.get(selectedIndex));
items.set(selectedIndex, itemToReplace);
reSelectRows[i++] = selectedIndex + moveToPosition;
}
selectionModel.clearSelection();
selectionModel.selectIndices(reSelectRows[0], reSelectRows);
table.refresh();
};
}
示例5: synchronizeTableToSelectionModel
import javafx.scene.control.TableView.TableViewSelectionModel; //导入方法依赖的package包/类
private void synchronizeTableToSelectionModel(final PathObjectHierarchy hierarchy, final TableView<PathObject> table) {
if (synchronizingModelToTable || hierarchy == null)
return;
boolean ownsChanges = !synchronizingTableToModel;
try {
synchronizingTableToModel = true;
PathObjectSelectionModel model = hierarchy.getSelectionModel();
TableViewSelectionModel<PathObject> tableModel = table.getSelectionModel();
if (model == null || model.noSelection()) {
tableModel.clearSelection();
return;
}
if (model.singleSelection()) {
int ind = table.getItems().indexOf(model.getSelectedObject());
if (ind >= 0) {
tableModel.clearAndSelect(ind);
table.scrollTo(ind);
}
else
tableModel.clearSelection();
return;
}
// Loop through all possible selections, and select them if they should be selected (and not if they shouldn't)
// For performance reasons, we need to do this using arrays - otherwise way too many events may be fired
int n = table.getItems().size();
PathObject mainSelectedObject = model.getSelectedObject();
int mainObjectInd = -1;
int[] indsToSelect = new int[table.getItems().size()];
int count = 0;
for (int i = 0; i < n; i++) {
PathObject temp = table.getItems().get(i);
if (temp == mainSelectedObject)
mainObjectInd = i;
if (model.isSelected(temp)) {
indsToSelect[count] = i;
count++;
}
}
tableModel.clearSelection();
if (count > 0)
tableModel.selectIndices(indsToSelect[0], Arrays.copyOfRange(indsToSelect, 1, count));
// for (int i = 0; i < n; i++) {
// PathObject temp = table.getItems().get(i);
// if (temp == mainSelectedObject)
// mainObjectInd = i;
// if (model.isSelected(temp)) {
// // Only select if necessary, or if this is the main selected object
// if (!tableModel.isSelected(i))
// tableModel.select(i);
// }
// else
// tableModel.clearSelection(i);
// }
// Ensure that the main object is focussed & its node expanded
if (mainObjectInd >= 0 && model.singleSelection()) {
tableModel.select(mainObjectInd);
table.scrollTo(mainObjectInd);
}
} finally {
if (ownsChanges)
synchronizingTableToModel = false;
}
}