Example usage for javax.swing.tree TreeSelectionModel addSelectionPath

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

Introduction

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

Prototype

void addSelectionPath(TreePath path);

Source Link

Document

Adds path to 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./*from w  ww .  jav a 2  s.  c o  m*/
 */
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());
    }
}