Example usage for javax.swing.tree TreeSelectionModel isPathSelected

List of usage examples for javax.swing.tree TreeSelectionModel isPathSelected

Introduction

In this page you can find the example usage for javax.swing.tree TreeSelectionModel isPathSelected.

Prototype

boolean isPathSelected(TreePath path);

Source Link

Document

Returns true if the path, path, is in the current selection.

Usage

From source file:com.mirth.connect.client.ui.DashboardPanel.java

/**
 * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the
 * rows if no row was selected.//ww w  .jav a 2s.  c  om
 */
private void checkSelectionAndPopupMenu(MouseEvent event) {
    TreePath path = dashboardTable.getPathForLocation(event.getX(), event.getY());

    /*
     * On mouse events we don't need to update the dashboard panel plugins. They will already
     * have been updated because of the ListSelectionEvent, and multiple mouse events will enter
     * here (as many as three, one pressed and two released) so we would basically be doing four
     * times the work.
     */
    if (path == null) {
        deselectRows(false);
    } else {
        updatePopupMenu(false);
    }

    if (event.isPopupTrigger()) {
        TreeSelectionModel selectionModel = dashboardTable.getTreeSelectionModel();

        if (!selectionModel.isPathSelected(path)) {
            deselectRows(false);
            selectionModel.addSelectionPath(path);
        }

        parent.dashboardPopupMenu.show(event.getComponent(), event.getX(), event.getY());
    }
}