Java Code Examples for javax.swing.plaf.basic.BasicDirectoryModel

The following examples show how to use javax.swing.plaf.basic.BasicDirectoryModel. These examples are extracted from open source projects. 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 Project: darklaf   Source File: DarkFilePaneUIBridge.java    License: MIT License 6 votes vote down vote up
protected int getNextMatch(final int startIndex, final int finishIndex) {
    BasicDirectoryModel model = getModel();
    JFileChooser fileChooser = getFileChooser();
    DetailsTableRowSorter rowSorter = getRowSorter();

    String prefix = typedString.toString().toLowerCase();

    // Search element
    for (int index = startIndex; index <= finishIndex; index++) {
        File file = (File) model.getElementAt(rowSorter.convertRowIndexToModel(index));

        String fileName = fileChooser.getName(file).toLowerCase();

        if (fileName.startsWith(prefix)) {
            return index;
        }
    }

    return -1;
}
 
Example 2
Source Project: darklaf   Source File: DarkFileChooserUIBridge.java    License: MIT License 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return DarkFileChooserUIBridge.this.getModel();
}
 
Example 3
Source Project: darklaf   Source File: DarkFilePaneUIBridge.java    License: MIT License 4 votes vote down vote up
/**
 * Moves the keyboard focus to the first element whose prefix matches
 * the sequence of alphanumeric keys pressed by the user with delay
 * less than value of <code>timeFactor</code>. Subsequent same key
 * presses move the keyboard focus to the next object that starts with
 * the same letter until another key is pressed, then it is treated
 * as the prefix with appropriate number of the same letters followed
 * by first typed another letter.
 */
public void keyTyped(final KeyEvent e) {
    BasicDirectoryModel model = getModel();
    int rowCount = model.getSize();

    if (detailsTable == null || rowCount == 0 ||
        e.isAltDown() || e.isControlDown() || e.isMetaDown()) {
        return;
    }

    InputMap inputMap = detailsTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke key = KeyStroke.getKeyStrokeForEvent(e);

    if (inputMap != null && inputMap.get(key) != null) {
        return;
    }

    int startIndex = detailsTable.getSelectionModel().getLeadSelectionIndex();

    if (startIndex < 0) {
        startIndex = 0;
    }

    if (startIndex >= rowCount) {
        startIndex = rowCount - 1;
    }

    char c = e.getKeyChar();

    long time = e.getWhen();

    if (time - lastTime < timeFactor) {
        if (typedString.length() == 1 && typedString.charAt(0) == c) {
            // Subsequent same key presses move the keyboard focus to the next
            // object that starts with the same letter.
            startIndex++;
        } else {
            typedString.append(c);
        }
    } else {
        startIndex++;

        typedString.setLength(0);
        typedString.append(c);
    }

    lastTime = time;

    if (startIndex >= rowCount) {
        startIndex = 0;
    }

    // Find next file
    int index = getNextMatch(startIndex, rowCount - 1);

    if (index < 0 && startIndex > 0) { // wrap
        index = getNextMatch(0, startIndex - 1);
    }

    if (index >= 0) {
        detailsTable.getSelectionModel().setSelectionInterval(index, index);

        Rectangle cellRect = detailsTable.getCellRect(index,
                                                      detailsTable.convertColumnIndexToView(COLUMN_FILENAME),
                                                      false);
        detailsTable.scrollRectToVisible(cellRect);
    }
}
 
Example 4
Source Project: darklaf   Source File: DarkFilePaneUIBridge.java    License: MIT License 4 votes vote down vote up
protected BasicDirectoryModel getModel() {
    return fileChooserUIAccessor.getModel();
}
 
Example 5
Source Project: jdk1.8-source-analysis   Source File: GTKFileChooserUI.java    License: Apache License 2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 6
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 7
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 8
Source Project: jdk8u60   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 9
Source Project: JDKSourceCode1.8   Source File: GTKFileChooserUI.java    License: MIT License 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 10
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 11
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 12
Source Project: Bytecoder   Source File: GTKFileChooserUI.java    License: Apache License 2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 13
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 14
Source Project: jdk8u-jdk   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 15
Source Project: hottub   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 16
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 17
Source Project: openjdk-8   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 18
Source Project: jdk8u_jdk   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 19
Source Project: jdk8u-jdk   Source File: GTKFileChooserUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 20
public BasicDirectoryModel getModel() {
    return model;
}
 
Example 21
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 4 votes vote down vote up
@Override public BasicDirectoryModel getModel() {
  return model2;
}
 
Example 22
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 4 votes vote down vote up
@Override public BasicDirectoryModel getModel() {
  return model2;
}
 
Example 23
Source Project: darklaf   Source File: DarkFilePaneUIBridge.java    License: MIT License votes vote down vote up
BasicDirectoryModel getModel();