Search in sources :

Example 51 with ListSelectionModel

use of javax.swing.ListSelectionModel in project TauP by crotwell.

the class PhaseDialog method addPhaseActionPerformed.

// GEN-LAST:event_phaseListKeyTyped
private void addPhaseActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_addPhaseActionPerformed
    // Add your handling code here:
    phaseListModel.addElement(evt.getActionCommand());
    ListSelectionModel sel = phaseList.getSelectionModel();
    sel.addSelectionInterval(phaseListModel.getSize() - 1, phaseListModel.getSize() - 1);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            phaseList.ensureIndexIsVisible(phaseListModel.getSize() - 1);
        }
    });
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel)

Example 52 with ListSelectionModel

use of javax.swing.ListSelectionModel in project TauP by crotwell.

the class PhaseDialog method setPhases.

public void setPhases(String[] phases) {
    phaseListModel.removeAllElements();
    for (int i = 0; i < phases.length; i++) {
        phaseListModel.addElement(phases[i]);
    }
    ListSelectionModel sel = phaseList.getSelectionModel();
    sel.addSelectionInterval(0, phaseListModel.getSize() - 1);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel)

Example 53 with ListSelectionModel

use of javax.swing.ListSelectionModel in project com.revolsys.open by revolsys.

the class MergedRecordsTableModel method valueChanged.

@Override
public void valueChanged(final ListSelectionEvent event) {
    final RecordRowTable table = getTable();
    final ListSelectionModel selectionModel = table.getSelectionModel();
    final int rowCount = super.getRowCount();
    final boolean mergedSelected = selectionModel.isSelectedIndex(rowCount);
    for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
        final Record record = getRecord(rowIndex);
        if (record != null) {
            if (mergedSelected || selectionModel.isSelectedIndex(rowIndex)) {
                this.layer.addHighlightedRecords((LayerRecord) record);
            } else {
                this.layer.unHighlightRecords((LayerRecord) record);
            }
        }
    }
    this.layer.zoomToHighlighted();
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable)

Example 54 with ListSelectionModel

use of javax.swing.ListSelectionModel in project com.revolsys.open by revolsys.

the class RecordLayerTableModel method setTable.

@Override
public void setTable(final BaseJTable table) {
    super.setTable(table);
    final ListSelectionModel selectionModel = getSelectionModel();
    table.setSelectionModel(selectionModel);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel)

Example 55 with ListSelectionModel

use of javax.swing.ListSelectionModel in project com.revolsys.open by revolsys.

the class RecordLayerTableModel method setTableRecordsMode.

public void setTableRecordsMode(final TableRecordsMode tableRecordsMode) {
    Invoke.later(() -> {
        final TableRecordsMode oldMode = this.tableRecordsMode;
        final RecordLayerTable table = getTable();
        if (table != null && tableRecordsMode != null && tableRecordsMode != oldMode) {
            if (oldMode != null) {
                oldMode.deactivate();
            }
            final String oldGeometryFilterMode = getGeometryFilterMode();
            this.tableRecordsMode = MODE_EMPTY;
            fireTableDataChanged();
            table.setSortable(false);
            table.setSelectionModel(null);
            table.setRowFilter(null);
            tableRecordsMode.activate();
            final ListSelectionModel selectionModel = tableRecordsMode.getSelectionModel();
            table.setSelectionModel(selectionModel);
            final boolean sortable = tableRecordsMode.isSortable();
            table.setSortable(sortable);
            final RowFilter<RecordRowTableModel, Integer> rowFilter = getRowFilter();
            table.setRowFilter(rowFilter);
            final boolean filterByBoundingBoxSupported = tableRecordsMode.isFilterByBoundingBoxSupported();
            if (!filterByBoundingBoxSupported) {
                this.filterByBoundingBox = false;
            }
            this.tableRecordsMode = tableRecordsMode;
            refresh();
            firePropertyChange("tableRecordsMode", oldMode, this.tableRecordsMode);
            firePropertyChange("geometryFilterMode", oldGeometryFilterMode, getGeometryFilterMode());
            firePropertyChange("filterByBoundingBox", !this.filterByBoundingBox, this.filterByBoundingBox);
            firePropertyChange("filterByBoundingBoxSupported", !filterByBoundingBoxSupported, filterByBoundingBoxSupported);
        }
    });
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable)

Aggregations

ListSelectionModel (javax.swing.ListSelectionModel)80 BorderLayout (java.awt.BorderLayout)20 Dimension (java.awt.Dimension)20 JButton (javax.swing.JButton)20 JPanel (javax.swing.JPanel)19 ListSelectionEvent (javax.swing.event.ListSelectionEvent)19 ListSelectionListener (javax.swing.event.ListSelectionListener)19 ActionEvent (java.awt.event.ActionEvent)18 JTable (javax.swing.JTable)18 ActionListener (java.awt.event.ActionListener)17 Point (java.awt.Point)16 JScrollPane (javax.swing.JScrollPane)15 MouseEvent (java.awt.event.MouseEvent)14 MouseAdapter (java.awt.event.MouseAdapter)13 DefaultListSelectionModel (javax.swing.DefaultListSelectionModel)13 TableColumn (javax.swing.table.TableColumn)13 Insets (java.awt.Insets)12 TableModel (javax.swing.table.TableModel)11 TableRowSorter (javax.swing.table.TableRowSorter)10 FlowLayout (java.awt.FlowLayout)9