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:com.cch.aj.entryrecorder.frame.SearchJFrame.java

@Override
public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting() && tblSearch.getSelectedRow() != -1) {
        TableModel model = tblSearch.getModel();
        int checkId = (int) model.getValueAt(tblSearch.getSelectedRow(), 0);
        MainJFrame mf = AppContext.getApplicationContext().getBean("MainJFrame", MainJFrame.class);
        mf.init(checkId);//ww  w .ja  va  2  s  .com
        mf.setVisible(true);
    }
}

From source file:com.emental.mindraider.ui.outline.OutlineSorterJPanel.java

@Override
public void valueChanged(ListSelectionEvent event) {
    if (event.getValueIsAdjusting()) {
        int selectedRow = table.getSelectedRow();
        if (selectedRow >= 0) {
            // map the row to the model (column sorters may change it)
            selectedRow = table.convertRowIndexToModel(selectedRow);

            if (outlineSorterJPanel.activeConcepts != null
                    && outlineSorterJPanel.activeConcepts.length > selectedRow) {
                OutlineJPanel.getInstance().loadConcept(MindRaider.profile.getActiveOutlineUri().toString(),
                        (String) outlineSorterJPanel.getValueAt(selectedRow, OutlineSorterJPanel.COLUMN_URI));
                OutlineJPanel.getInstance().refresh();
            }/*from w ww .  j  ava 2s.  co m*/
            return;
        }
    }
}

From source file:SiteFrame.java

public SiteFrame(String name, SiteManager sm) {
    super("Site: " + name, true, true, true);
    parent = sm;/*from www .j a  v  a  2 s .  co m*/
    setBounds(50, 50, 250, 100);

    nameList = new JList(pages);
    nameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    nameList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent lse) {
            // We know this is the list, so pop up the page.
            if (!lse.getValueIsAdjusting()) {
                parent.addPageFrame((String) nameList.getSelectedValue());
            }
        }
    });
    Container contentPane = getContentPane();
    contentPane.add(nameList, BorderLayout.CENTER);
}

From source file:com.github.alexfalappa.nbspringboot.navigator.RequestMappingNavigatorPanel.java

/**
 * public no arg constructor needed for system to instantiate provider well
 *//*from w ww.  j  a v  a 2  s.c  om*/
public RequestMappingNavigatorPanel() {
    table = new ETable();
    mappedElementsModel = new MappedElementsModel();
    mappedElementGatheringTaskFactory = new ElementScanningTaskFactory(table, mappedElementsModel);
    table.setModel(mappedElementsModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setColumnSorted(0, true, 1);
    table.setDefaultRenderer(RequestMethod.class, new RequestMethodCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent event) {
            final int selectedRow = ((ListSelectionModel) event.getSource()).getMinSelectionIndex();
            if (event.getValueIsAdjusting() || selectedRow < 0) {
                return;
            }
            final MappedElement mappedElement = mappedElementsModel
                    .getElementAt(table.convertRowIndexToModel(selectedRow));
            ElementOpen.open(mappedElement.getFileObject(), mappedElement.getHandle());
            try {
                final DataObject dataObject = DataObject.find(mappedElement.getFileObject());
                final EditorCookie editorCookie = dataObject.getLookup().lookup(EditorCookie.class);
                if (editorCookie != null) {
                    editorCookie.openDocument();
                    JEditorPane[] p = editorCookie.getOpenedPanes();
                    if (p.length > 0) {
                        p[0].requestFocus();
                    }
                }
            } catch (IOException e) {
            }
        }
    });
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JScrollPane(table), BorderLayout.CENTER);
    this.component = panel;
    this.contextListener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
        }
    };
}

From source file:Main.java

public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

        if (list.getSelectedIndex() == -1) {
            // No selection: disable delete, up, and down buttons.
            deleteButton.setEnabled(false);
            upButton.setEnabled(false);//w ww.j a v  a 2 s.com
            downButton.setEnabled(false);
            nameField.setText("");

        } else if (list.getSelectedIndices().length > 1) {
            // Multiple selection: disable up and down buttons.
            deleteButton.setEnabled(true);
            upButton.setEnabled(false);
            downButton.setEnabled(false);

        } else {
            // Single selection: permit all operations.
            deleteButton.setEnabled(true);
            upButton.setEnabled(true);
            downButton.setEnabled(true);
            nameField.setText(list.getSelectedValue().toString());
        }
    }
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.SimilarCasesFrame.java

/**
 * Constructor./*from   ww w. j a  v a 2  s .  c  o  m*/
 */
SimilarCasesFrame(final Instances ds, final int dateIdx, final StationsDataProvider gcp, String attrname,
        final int gapsize, final int position, final double x, final double y, final int year,
        final String season, final boolean isDuringRising) throws Exception {
    LogoHelper.setLogo(this);
    this.setTitle("KnowledgeDB: Suggested configurations / similar cases");

    this.inputCaseTablePanel = new JXPanel();
    this.inputCaseTablePanel.setBorder(new TitledBorder("Present case"));
    this.inputCaseChartPanel = new JXPanel();
    this.inputCaseChartPanel.setBorder(new TitledBorder("Profile of the present case"));
    this.outputCasesTablePanel = new JXPanel();
    this.outputCasesTablePanel.setBorder(new TitledBorder("Suggested cases"));
    this.outputCasesChartPanel = new JXPanel();
    this.outputCasesChartPanel.setBorder(new TitledBorder("Profile of the selected suggested case"));

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
    getContentPane().add(inputCaseTablePanel);
    getContentPane().add(inputCaseChartPanel);
    getContentPane().add(outputCasesTablePanel);
    getContentPane().add(outputCasesChartPanel);

    final Instances res = GapFillingKnowledgeDB.findSimilarCases(attrname, x, y, year, season, gapsize,
            position, isDuringRising, gcp.findDownstreamStation(attrname) != null,
            gcp.findUpstreamStation(attrname) != null,
            GapsUtil.measureHighMiddleLowInterval(ds, ds.attribute(attrname).index(), position - 1));

    final Instances inputCase = new Instances(res);
    while (inputCase.numInstances() > 1)
        inputCase.remove(1);
    final JXTable inputCaseTable = buidJXTable(inputCase);
    final JScrollPane inputScrollPane = new JScrollPane(inputCaseTable);
    //System.out.println(inputScrollPane.getPreferredSize());
    inputScrollPane.setPreferredSize(
            new Dimension(COMPONENT_WIDTH, (int) (50 + inputScrollPane.getPreferredSize().getHeight())));
    this.inputCaseTablePanel.add(inputScrollPane);

    final ChartPanel inputcp = GapsUIUtil.buildGapChartPanel(ds, dateIdx, ds.attribute(attrname), gapsize,
            position);
    inputcp.getChart().removeLegend();
    inputcp.setPreferredSize(CHART_DIMENSION);
    this.inputCaseChartPanel.add(inputcp);

    final Instances outputCases = new Instances(res);
    outputCases.remove(0);
    final JXTable outputCasesTable = buidJXTable(outputCases);
    final JScrollPane outputScrollPane = new JScrollPane(outputCasesTable);
    outputScrollPane.setPreferredSize(
            new Dimension(COMPONENT_WIDTH, (int) (50 + outputScrollPane.getPreferredSize().getHeight())));
    this.outputCasesTablePanel.add(outputScrollPane);

    outputCasesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    outputCasesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final int modelRow = outputCasesTable.getSelectedRow();

                final String attrname = outputCasesTable.getModel().getValueAt(modelRow, 1).toString();
                final int gapsize = (int) Double
                        .valueOf(outputCasesTable.getModel().getValueAt(modelRow, 4).toString()).doubleValue();
                final int position = (int) Double
                        .valueOf(outputCasesTable.getModel().getValueAt(modelRow, 5).toString()).doubleValue();

                try {
                    final ChartPanel cp = GapsUIUtil.buildGapChartPanel(ds, dateIdx, ds.attribute(attrname),
                            gapsize, position);
                    cp.getChart().removeLegend();
                    cp.setPreferredSize(CHART_DIMENSION);
                    outputCasesChartPanel.removeAll();
                    outputCasesChartPanel.add(cp);
                    getContentPane().repaint();
                    pack();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    outputCasesTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(final MouseEvent e) {
            final InstanceTableModel instanceTableModel = (InstanceTableModel) outputCasesTable.getModel();
            final int row = outputCasesTable.rowAtPoint(e.getPoint());
            final int modelRow = outputCasesTable.convertRowIndexToModel(row);

            final String attrname = instanceTableModel.getValueAt(modelRow, 1).toString();
            final int gapsize = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 4).toString())
                    .doubleValue();
            final int position = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 5).toString())
                    .doubleValue();

            if (e.isPopupTrigger()) {
                final JPopupMenu jPopupMenu = new JPopupMenu("feur");

                final JMenuItem mi = new JMenuItem("Use this configuration");
                mi.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        System.out.println("not implemented!");
                    }
                });
                jPopupMenu.add(mi);
                jPopupMenu.show(outputCasesTable, e.getX(), e.getY());
            } else {
                // nothing?
            }
        }
    });

    setPreferredSize(new Dimension(FRAME_WIDTH, 900));

    pack();
    setVisible(true);

    /* select the first row */
    outputCasesTable.setRowSelectionInterval(0, 0);
}

From source file:Main.java

public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

        if (list.getSelectedIndex() == -1) {
            //No selection: disable delete, up, and down buttons.
            deleteButton.setEnabled(false);
            upButton.setEnabled(false);//from  www  .  jav a 2  s  .  co m
            downButton.setEnabled(false);
            nameField.setText("");

        } else if (list.getSelectedIndices().length > 1) {
            //Multiple selection: disable up and down buttons.
            deleteButton.setEnabled(true);
            upButton.setEnabled(false);
            downButton.setEnabled(false);

        } else {
            //Single selection: permit all operations.
            deleteButton.setEnabled(true);
            upButton.setEnabled(true);
            downButton.setEnabled(true);
            nameField.setText(list.getSelectedValue().toString());
        }
    }
}

From source file:TopLevelTransferHandlerDemo.java

public TopLevelTransferHandlerDemo() {
    super("TopLevelTransferHandlerDemo");
    setJMenuBar(createDummyMenuBar());/* w w  w .  j  av a 2s. c o m*/
    getContentPane().add(createDummyToolBar(), BorderLayout.NORTH);

    JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, list, dp);
    sp.setDividerLocation(120);
    getContentPane().add(sp);
    //new Doc("sample.txt");
    //new Doc("sample.txt");
    //new Doc("sample.txt");

    list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            Doc val = (Doc) list.getSelectedValue();
            if (val != null) {
                val.select();
            }
        }
    });

    final TransferHandler th = list.getTransferHandler();

    nullItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (nullItem.isSelected()) {
                list.setTransferHandler(null);
            } else {
                list.setTransferHandler(th);
            }
        }
    });
    thItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (thItem.isSelected()) {
                setTransferHandler(handler);
            } else {
                setTransferHandler(null);
            }
        }
    });
    dp.setTransferHandler(handler);
}

From source file:gui.TwopointPWDPanel.java

public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting())
        return;/*from   ww w. ja  va2  s .  com*/

    if (e.getSource() == markerTable.getSelectionModel()) {
        processMarkerTableClick(e);
    } else {
        processPhaseTableClick(e);
    }
}

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

@Override
public void valueChanged(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        int selectedRow = taskTable.getSelectedRow();
        boolean showRun = evt.getFirstIndex() > -1;
        boolean showCancel = false;

        if (showRun) {
            for (int row = 0; row < taskTable.getRowCount(); row++) {
                if (((DatabaseTask) taskTable.getValueAt(row, 1)).getStatus() == Status.RUNNING) {
                    showRun = false;//from www. j a  v  a2  s.  c  o m
                    if (row == selectedRow) {
                        showCancel = true;
                    }
                }
            }
        }

        setVisibleTasks(2, 2, showRun);
        setVisibleTasks(3, 3, showCancel);

        Map<String, String> affectedChannels = new HashMap<String, String>();
        if (selectedRow > -1) {
            affectedChannels = ((DatabaseTask) taskTable.getValueAt(selectedRow, 1)).getAffectedChannels();
        }

        Object[][] data = new Object[affectedChannels.size()][2];
        int i = 0;

        for (String channelId : affectedChannels.keySet()) {
            data[i][0] = affectedChannels.get(channelId);
            data[i][1] = channelId;
            i++;
        }

        ((RefreshTableModel) channelsTable.getModel()).refreshDataVector(data);
    }
}