Example usage for javax.swing.event ListSelectionEvent getValueIsAdjusting

List of usage examples for javax.swing.event ListSelectionEvent getValueIsAdjusting

Introduction

In this page you can find the example usage for javax.swing.event ListSelectionEvent getValueIsAdjusting.

Prototype

public boolean getValueIsAdjusting() 

Source Link

Document

Returns whether or not this is one in a series of multiple events, where changes are still being made.

Usage

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

/**
 * //from   w w  w  .j  a v  a  2 s  .c  o  m
 */
private void hookFieldsTblSelectionListener() {
    if (fieldsTblSL == null) {
        fieldsTblSL = new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    checkForChanges();

                    int inx = fieldsTbl.getSelectedRow();
                    if (inx > -1) {
                        currentField = fields.get(inx);

                        fieldTypeCbx.setSelectedIndex(currentField.getType().ordinal());
                        isIncChk.setSelected(currentField.isIncrementer());
                        fieldTxt.setText(currentField.getValue());
                        sizeSpinner.setValue(Math.max(1, currentField.getSize()));
                        enabledEditorUI(true);

                    } else {
                        fieldTypeCbx.setSelectedIndex(-1);
                        enabledEditorUI(false);
                    }
                    fieldHasChanged = false;
                    updateEnabledState();
                }
            }
        };
    }

    fieldsTbl.getSelectionModel().addListSelectionListener(fieldsTblSL);
}

From source file:net.sf.firemox.DeckBuilder.java

public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        if (e.getSource() == leftList.getSelectionModel()) {
            if (leftList.getSelectedIndex() == -1 || allListModel.isEmpty()) {
                // No selection, disable fire button.
                addButton.setEnabled(false);
            } else {
                // Selection, enable the fire button.
                addButton.setEnabled(true);

                // Update the views
                final MCardCompare selectedCard = (MCardCompare) leftList.getSelectedValue();
                cardNameTxt.setText(selectedCard.getName());
                setCard(selectedCard);//from  w  w w.  j  a va 2s.c o m
            }
        } else if (e.getSource() == rightList.getSelectionModel()) {
            if (rightList.getSelectedRow() == -1) {
                // No selection, disable fire button.
                removeButton.setEnabled(false);
            } else {
                // Selection, enable the fire button.
                removeButton.setEnabled(true);

                // Update the views
                setCard(rightListModel.getCards().getElementAt(rightList.getSelectedRow()));
            }
        }
    }
}

From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java

/**
 * Called when the table selection changes
 * @param evt the event/*  w  w w . ja v a  2 s  . c o m*/
 */
@Override
public void valueChanged(ListSelectionEvent evt) {
    // Check if we are in a quiescent state
    if (quiescent) {
        return;
    }

    if (!evt.getValueIsAdjusting()) {
        selectedWp = routeDetailTable.getSelectedRow();
        updateButtonEnabledState();
    }
}

From source file:contactsdirectory.frontend.MainJFrame.java

private void jListContactValueChanged(javax.swing.event.ListSelectionEvent evt)//GEN-FIRST:event_jListContactValueChanged
{//GEN-HEADEREND:event_jListContactValueChanged
    if (!evt.getValueIsAdjusting()) {
        updateContactDetail();//from  w  w w  .  j  a  v a2  s  .  c o  m
    }
}

From source file:com.diversityarrays.kdxplore.trials.TrialOverviewPanel.java

public TrialOverviewPanel(String title, OfflineData offdata, TrialExplorerManager manager,
        FileListTransferHandler flth, MessagePrinter mp, final Closure<List<Trial>> onTrialSelected) {
    super(new BorderLayout());

    offlineData = offdata;//ww w .  j  a  v a2s.co m
    KdxploreDatabase kdxdb = offlineData.getKdxploreDatabase();
    if (kdxdb != null) {
        kdxdb.addEntityChangeListener(trialChangeListener);
        kdxdb.addEntityChangeListener(traitChangeListener);
    }

    this.messagePrinter = mp;

    TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(trialsTable, true);
    trialsTable.setTransferHandler(new ChainingTransferHandler(flth, tth));
    trialsTable.setAutoCreateRowSorter(true);

    trialsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                List<Trial> selectedTrials = getSelectedTrials();
                if (selectedTrials.size() == 1) {
                    trialTraitsTableModel.setSelectedTrial(selectedTrials.get(0));
                } else {
                    trialTraitsTableModel.setSelectedTrial(null);
                }
                onTrialSelected.execute(selectedTrials);
            }
        }
    });
    trialsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
                fireEditCommand(e);
            }
        }
    });

    GuiUtil.setVisibleRowCount(trialsTable, MAX_INITIAL_VISIBLE_TRIAL_ROWS);

    offlineData.addOfflineDataChangeListener(offlineDataChangeListener);

    trialTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateRefreshAction();
        }
    });
    trialTraitsTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateAddTraitAction();
            updateRemoveTraitAction();
            updateScoringOrderAction();
        }
    });
    trialTraitsTable.addMouseListener(new MouseAdapter() {

        List<Trait> selectedTraits;
        JPopupMenu popupMenu;
        Action showTraitsAction = new AbstractAction("Select in Trait Explorer") {
            @Override
            public void actionPerformed(ActionEvent e) {
                manager.showTraitsInTraitExplorer(selectedTraits);
            }
        };

        @Override
        public void mouseClicked(MouseEvent e) {

            if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) {
                // Start editing the Trait
                e.consume();
                int vrow = trialTraitsTable.rowAtPoint(e.getPoint());
                if (vrow >= 0) {
                    int mrow = trialTraitsTable.convertRowIndexToModel(vrow);
                    if (mrow >= 0) {
                        Trait trait = trialTraitsTableModel.getTraitAt(mrow);
                        if (trait != null) {
                            traitExplorer.startEditing(trait);
                            ;
                        }
                    }
                }
            } else if (SwingUtilities.isRightMouseButton(e) && 1 == e.getClickCount()) {
                // Select the traits in the traitExplorer
                e.consume();
                List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialTraitsTable);
                if (!modelRows.isEmpty()) {
                    selectedTraits = modelRows.stream().map(trialTraitsTableModel::getTraitAt)
                            .collect(Collectors.toList());

                    if (popupMenu == null) {
                        popupMenu = new JPopupMenu();
                        popupMenu.add(showTraitsAction);
                    }
                    Point pt = e.getPoint();
                    popupMenu.show(trialTraitsTable, pt.x, pt.y);
                }
            }
        }
    });
    trialTraitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateRemoveTraitAction();
            }
        }
    });
    updateAddTraitAction();
    updateRemoveTraitAction();
    updateScoringOrderAction();
    updateRefreshAction();

    KDClientUtils.initAction(ImageId.REFRESH_24, refreshTrialTraitsAction, "Refresh");
    KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitAction, "Remove selected Traits");
    KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addTraitAction, "Add Traits to Trial");
    KDClientUtils.initAction(ImageId.TRAIT_ORDER_24, setScoringOrderAction, "Define Trait Scoring Order");

    Box buttons = Box.createHorizontalBox();

    buttons.add(new JButton(setScoringOrderAction));
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(addTraitAction));
    buttons.add(new JButton(removeTraitAction));
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(refreshTrialTraitsButton);

    JPanel traitsPanel = new JPanel(new BorderLayout());
    traitsPanel.add(GuiUtil.createLabelSeparator("Uses Traits", buttons), BorderLayout.NORTH);
    traitsPanel.add(new PromptScrollPane(trialTraitsTable,
            "If the (single) selected Trial has Traits they will appear here"), BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(trialsTable), traitsPanel);
    splitPane.setResizeWeight(0.5);

    add(splitPane, BorderLayout.CENTER);
}

From source file:gdsc.smlm.ij.plugins.SpotAnalysis.java

public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        int index = onFramesList.getSelectedIndex();
        //int index = e.getFirstIndex();
        if (index >= 0 && index < listModel.size()) {
            //Utils.log("index = %d, %b", index, e.getValueIsAdjusting());
            Spot spot = (Spot) listModel.get(index);
            rawImp.setSlice(spot.frame);
        }//from  w w w.  j ava2  s  .  c o  m
    }
}

From source file:client.ui.FilePane.java

private void noteSelectedChanged(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        int rowIndex = noteTable.getSelectedRow();
        if (rowIndex != -1)
            rowIndex = noteTable.convertRowIndexToModel(rowIndex);
        if (rowIndex == -1) {
            deleteNoteButton.setEnabled(false);
        } else {/*w  w w .ja v  a2s  . com*/
            String userID = m_Business.getUser().getUserID();
            if (!noteTableModel.getValueAt(rowIndex).getCreator().equals(userID))
                deleteNoteButton.setEnabled(false);
            else
                deleteNoteButton.setEnabled(true);
        }
    }
}

From source file:client.ui.FilePane.java

private void fileSelectedChanged(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        String userID = m_Business.getUser().getUserID();
        int rowIndex = fileInfoTable.getSelectedRow();
        if (rowIndex != -1)
            rowIndex = fileInfoTable.convertRowIndexToModel(rowIndex);
        if (this.currentID.equals(userID)) { //?
            if (rowIndex == -1) { //
                deleteFileButton.setEnabled(false);
                renameFileButton.setEnabled(false);
                authorizationButton.setEnabled(false);
                downloadFileButton.setEnabled(false);
                deleteNoteButton.setEnabled(false);
                addNoteButton.setEnabled(false);
                deleteNoteButton.setEnabled(false);
            } else {
                deleteFileButton.setEnabled(true);
                renameFileButton.setEnabled(true);
                authorizationButton.setEnabled(true);
                downloadFileButton.setEnabled(true);
                addNoteButton.setEnabled(true);
            }/*from  w w  w .  j a v  a2  s .  c om*/
        } else { //?
            if (rowIndex == -1) { //
                downloadFileButton.setEnabled(false);
                addNoteButton.setEnabled(false);
                deleteNoteButton.setEnabled(false);
            } else {
                downloadFileButton.setEnabled(true);
                addNoteButton.setEnabled(true);
            }
        }
    }
}

From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java

/**
 * DOCUMENT ME!/*from   w  ww .  j  a v a  2 s  . c o  m*/
 *
 * @param  evt  DOCUMENT ME!
 */
private void lstFotosValueChanged(final ListSelectionEvent evt) { //GEN-FIRST:event_lstFotosValueChanged
    if (!evt.getValueIsAdjusting() && listListenerEnabled) {
        loadFoto();
    }
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

/**
 * An action for when a row is selected in the table.
 *///w w w. j  a v  a 2  s  .  co  m
private void EventListSelected(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        int row = eventTable.getSelectedModelIndex();

        if (row >= 0) {
            setEventAttributes(events.get(row).getAttributes(), false);
        }
    }
}