Example usage for javax.swing.tree TreeSelectionModel clearSelection

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

Introduction

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

Prototype

void clearSelection();

Source Link

Document

Empties the current selection.

Usage

From source file:org.openmicroscopy.shoola.agents.measurement.view.ObjectManager.java

/**
 * Selects the collection of figures./*from   w w  w .  j  a  va 2 s .  c  o m*/
 * 
 * @param l The collection of objects to select.
 * @param clear Pass <code>true</code> to clear the selection
 *            <code>false</code> otherwise.
 */
void setSelectedFigures(List<ROIShape> l, boolean clear) {
    Iterator<ROIShape> i = l.iterator();
    TreeSelectionModel tsm = objectsTable.getTreeSelectionModel();
    ROIFigure figure = null;
    ROIShape shape;
    if (clear)
        tsm.clearSelection();
    objectsTable.removeTreeSelectionListener(treeSelectionListener);

    try {
        while (i.hasNext()) {
            shape = i.next();
            figure = shape.getFigure();
            objectsTable.selectROIShape(figure.getROIShape());
        }
        objectsTable.repaint();
        if (figure != null)
            objectsTable.scrollToROIShape(figure.getROIShape());
    } catch (Exception e) {
        MeasurementAgent.getRegistry().getLogger().info(this, "Figure selection " + e);
    }

    objectsTable.addTreeSelectionListener(treeSelectionListener);
}