下面列出了javax.swing.DefaultListSelectionModel#isSelectedIndex ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Makes sure the currently selected <code>TreePath</code>s are valid
* for the current selection mode.
* If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
* and a <code>RowMapper</code> exists, this will make sure all
* the rows are contiguous, that is, when sorted all the rows are
* in order with no gaps.
* If the selection isn't contiguous, the selection is
* reset to contain the first set, when sorted, of contiguous rows.
* <p>
* If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
* more than one TreePath is selected, the selection is reset to
* contain the first path currently selected.
*/
protected void insureRowContinuity() {
if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
selection != null && rowMapper != null) {
DefaultListSelectionModel lModel = listSelectionModel;
int min = lModel.getMinSelectionIndex();
if(min != -1) {
for(int counter = min,
maxCounter = lModel.getMaxSelectionIndex();
counter <= maxCounter; counter++) {
if(!lModel.isSelectedIndex(counter)) {
if(counter == min) {
clearSelection();
}
else {
TreePath[] newSel = new TreePath[counter - min];
int selectionIndex[] = rowMapper.getRowsForPaths(selection);
// find the actual selection pathes corresponded to the
// rows of the new selection
for (int i = 0; i < selectionIndex.length; i++) {
if (selectionIndex[i]<counter) {
newSel[selectionIndex[i]-min] = selection[i];
}
}
setSelectionPaths(newSel);
break;
}
}
}
}
}
else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
selection != null && selection.length > 1) {
setSelectionPath(selection[0]);
}
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*
* @param paths array of {@code TreePaths} to check
* @return whether the particular set of {@code TreePaths} can be added
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*
* @param paths array of {@code TreePaths} to check
* @return whether the particular set of {@code TreePaths} can be added
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}
/**
* Used to test if a particular set of <code>TreePath</code>s can
* be added. This will return true if <code>paths</code> is null (or
* empty), or this object has no RowMapper, or nothing is currently selected,
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
* adding the paths to the current selection still results in a
* contiguous set of <code>TreePath</code>s.
*/
protected boolean canPathsBeAdded(TreePath[] paths) {
if(paths == null || paths.length == 0 || rowMapper == null ||
selection == null || selectionMode ==
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
return true;
else {
BitSet bitSet = new BitSet();
DefaultListSelectionModel lModel = listSelectionModel;
int anIndex;
int counter;
int min = lModel.getMinSelectionIndex();
int max = lModel.getMaxSelectionIndex();
TreePath[] tempPath = new TreePath[1];
if(min != -1) {
for(counter = min; counter <= max; counter++) {
if(lModel.isSelectedIndex(counter))
bitSet.set(counter);
}
}
else {
tempPath[0] = paths[0];
min = max = rowMapper.getRowsForPaths(tempPath)[0];
}
for(counter = paths.length - 1; counter >= 0; counter--) {
if(paths[counter] != null) {
tempPath[0] = paths[counter];
int[] rows = rowMapper.getRowsForPaths(tempPath);
if (rows == null) {
return false;
}
anIndex = rows[0];
min = Math.min(anIndex, min);
max = Math.max(anIndex, max);
if(anIndex == -1)
return false;
bitSet.set(anIndex);
}
}
for(counter = min; counter <= max; counter++)
if(!bitSet.get(counter))
return false;
}
return true;
}