Java Code Examples for javax.swing.DefaultListSelectionModel#getMaxSelectionIndex()

The following examples show how to use javax.swing.DefaultListSelectionModel#getMaxSelectionIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTreeSelectionModel.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 2
Source File: DefaultTreeSelectionModel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 3
Source File: DefaultTreeSelectionModel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 4
Source File: DefaultTreeSelectionModel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 5
Source File: DefaultTreeSelectionModel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 6
Source File: DefaultTreeSelectionModel.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 7
Source File: DefaultTreeSelectionModel.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 8
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 9
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 10
Source File: DefaultTreeSelectionModel.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 11
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 12
Source File: DefaultTreeSelectionModel.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: DefaultTreeSelectionModel.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: DefaultTreeSelectionModel.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: DefaultTreeSelectionModel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: DefaultTreeSelectionModel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: DefaultTreeSelectionModel.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: DefaultTreeSelectionModel.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: DefaultTreeSelectionModel.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}