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:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidBatchScaleImporter.java

private void initRowSelection() {
    table.getColumnModel().setColumnSelectionAllowed(false);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override/*from   ww  w .ja  v a  2 s .com*/
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            int selectedRow = table.getSelectedRow();
            if (table.getSelectedRowCount() == 1) {
                updateImage(controller.getImage(selectedRow));
            } else {
                updateImage(null);
            }
        }
    });
}

From source file:de.tor.tribes.ui.views.DSWorkbenchChurchFrame.java

@Override
public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
        int selectionCount = jChurchTable.getSelectedRowCount();
        if (selectionCount != 0) {
            showInfo(selectionCount + ((selectionCount == 1) ? " Kirche gewhlt" : " Kirchen gewhlt"));
        }/*from w w w .  j  ava 2 s  . c  o m*/
    }
}

From source file:org.nekorp.workflow.desktop.view.NavegadorServiciosView.java

@Override
public void iniciaVista() {
    initComponents();/*from w w w  . j  a v a  2 s  . c om*/
    bindingManager.registerBind(servicioLoadedListMetadata, "serviciosNuevos", modeloServicioNuevoList);
    bindingManager.registerBind(servicioLoadedListMetadata, "servicios", modeloServicioList);
    this.bindingManager.registerBind(servicioMetaData, "servicioActual", new ReadOnlyBinding() {
        @Override
        public void notifyUpdate(Object origen, String property, Object value) {
            internalUpdateOnProcess = true;
            ServicioLoaded servicio = (ServicioLoaded) value;
            listaServicioCargado.clearSelection();
            listaServicioNuevo.clearSelection();
            if (servicio != null) {
                if (servicio.isNuevo()) {
                    listaServicioNuevo.setSelectedIndex(modeloServicioNuevoList.indexof(servicio));
                } else {
                    listaServicioCargado.setSelectedIndex(modeloServicioList.indexof(servicio));
                }
            }
            internalUpdateOnProcess = false;
        }
    });
    this.listaServicioNuevo.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (listaServicioNuevo.getSelectedIndex() < modeloServicioNuevoList.getSize()
                    && listaServicioNuevo.getSelectedIndex() > -1) {
                if (!internalUpdateOnProcess && !e.getValueIsAdjusting()
                        && !listaServicioNuevo.isSelectionEmpty()) {
                    aplication.cambiarServicio(
                            modeloServicioNuevoList.getElementAt(listaServicioNuevo.getSelectedIndex()));
                }
            }
        }
    });

    this.listaServicioCargado.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (listaServicioCargado.getSelectedIndex() < modeloServicioList.getSize()
                    && listaServicioCargado.getSelectedIndex() > -1) {
                if (!internalUpdateOnProcess && !e.getValueIsAdjusting()
                        && !listaServicioCargado.isSelectionEmpty()) {
                    aplication.cambiarServicio(
                            modeloServicioList.getElementAt(listaServicioCargado.getSelectedIndex()));
                }
            }
        }
    });
}

From source file:de.tor.tribes.ui.views.DSWorkbenchWatchtowerFrame.java

@Override
public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
        int selectionCount = jWatchtowerTable.getSelectedRowCount();
        if (selectionCount != 0) {
            showInfo(selectionCount + ((selectionCount == 1) ? " Wachturm gewhlt" : " Wachtrme gewhlt"));
        }//from   ww w .  j  av a2s.c o  m
    }
}

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

public void refresh(final Instances dataSet, final int dateIdx) {
    final Instances gapsDescriptionsDataset = GapsUtil.buildGapsDescription(gcp, dataSet, dateIdx);

    final JXTable gapsDescriptionsTable = new JXTable();
    final InstanceTableModel gapsDescriptionsTableModel = new InstanceTableModel(false);
    gapsDescriptionsTableModel.setDataset(gapsDescriptionsDataset);
    gapsDescriptionsTable.setModel(gapsDescriptionsTableModel);
    gapsDescriptionsTable.setEditable(true);
    gapsDescriptionsTable.setShowHorizontalLines(false);
    gapsDescriptionsTable.setShowVerticalLines(false);
    gapsDescriptionsTable.setVisibleRowCount(5);
    gapsDescriptionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    gapsDescriptionsTable.setSortable(false);
    gapsDescriptionsTable.packAll();//from   ww w  .jav a  2s.  co  m

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

                final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString();
                final Attribute attr = dataSet.attribute(attrname);
                final int gapsize = (int) Double
                        .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString()).doubleValue();
                final int position = (int) Double
                        .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString()).doubleValue();

                try {
                    final ChartPanel cp = GapsUIUtil.buildGapChartPanel(dataSet, dateIdx, attr, gapsize,
                            position);

                    visualOverviewPanel.removeAll();
                    visualOverviewPanel.add(cp, BorderLayout.CENTER);

                    geomapPanel.removeAll();
                    geomapPanel.add(gcp.getMapPanel(Arrays.asList(attrname), new ArrayList<String>(), false));

                    jxp.updateUI();
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
            }
        }
    });

    gapsDescriptionsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(final MouseEvent e) {
            final InstanceTableModel instanceTableModel = (InstanceTableModel) gapsDescriptionsTable.getModel();
            final int row = gapsDescriptionsTable.rowAtPoint(e.getPoint());
            //final int row=gapsDescriptionsTable.getSelectedRow();
            final int modelRow = gapsDescriptionsTable.convertRowIndexToModel(row);
            //final int modelRow=(int)Double.valueOf(instanceTableModel.getValueAt(row,0).toString()).doubleValue();
            //System.out.println(row+" "+modelRow);

            final String attrname = instanceTableModel.getValueAt(modelRow, 1).toString();
            final Attribute attr = dataSet.attribute(attrname);
            final int gapsize = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 5).toString())
                    .doubleValue();
            final int position = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 6).toString())
                    .doubleValue();

            if (!e.isPopupTrigger()) {
                // nothing?
            } else {
                final JPopupMenu jPopupMenu = new JPopupMenu("feur");

                final JMenuItem interactiveFillMenuItem = new JMenuItem("Fill this gap (interactively)");
                interactiveFillMenuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final GapFillingFrame jxf = new GapFillingFrame(atv, dataSet, attr, dateIdx,
                                GapsUtil.getCountOfValuesBeforeAndAfter(gapsize), position, gapsize, gcp,
                                false);
                        jxf.setSize(new Dimension(900, 700));
                        //jxf.setExtendedState(Frame.MAXIMIZED_BOTH);                        
                        jxf.setLocationRelativeTo(jPopupMenu);
                        jxf.setVisible(true);
                        //jxf.setResizable(false);
                    }
                });
                jPopupMenu.add(interactiveFillMenuItem);

                final JMenuItem lookupInKnowledgeDBMenuItem = new JMenuItem(
                        "Show the most similar cases from KnowledgeDB");
                lookupInKnowledgeDBMenuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final double x = gcp.getCoordinates(attrname)[0];
                        final double y = gcp.getCoordinates(attrname)[1];
                        final String season = instanceTableModel.getValueAt(modelRow, 3).toString()
                                .split("/")[0];
                        final boolean isDuringRising = instanceTableModel.getValueAt(modelRow, 11).toString()
                                .equals("true");
                        try {
                            final Calendar cal = Calendar.getInstance();
                            final String dateAsString = instanceTableModel.getValueAt(modelRow, 2).toString()
                                    .replaceAll("'", "");
                            cal.setTime(FormatterUtil.DATE_FORMAT.parse(dateAsString));
                            final int year = cal.get(Calendar.YEAR);

                            new SimilarCasesFrame(dataSet, dateIdx, gcp, attrname, gapsize, position, x, y,
                                    year, season, isDuringRising);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                });
                jPopupMenu.add(lookupInKnowledgeDBMenuItem);

                final JMenuItem mExport = new JMenuItem("Export this table as CSV");
                mExport.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final JFileChooser fc = new JFileChooser();
                        fc.setAcceptAllFileFilterUsed(false);
                        final int returnVal = fc.showSaveDialog(gapsDescriptionsTable);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                            try {
                                final File file = fc.getSelectedFile();
                                WekaDataAccessUtil.saveInstancesIntoCSVFile(gapsDescriptionsDataset, file);
                            } catch (Exception ee) {
                                ee.printStackTrace();
                            }
                        }
                    }
                });
                jPopupMenu.add(mExport);

                jPopupMenu.show(gapsDescriptionsTable, e.getX(), e.getY());
            }
        }
    });

    final int tableWidth = (int) gapsDescriptionsTable.getPreferredSize().getWidth() + 30;
    final JScrollPane scrollPane = new JScrollPane(gapsDescriptionsTable);
    scrollPane.setPreferredSize(new Dimension(Math.min(tableWidth, 500), 500));
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.tablePanel.removeAll();
    this.tablePanel.add(scrollPane, BorderLayout.CENTER);

    this.visualOverviewPanel.removeAll();

    /* automatically compute the most similar series and the 'rising' flag */
    new AbstractSimpleAsync<Void>(false) {
        @Override
        public Void execute() throws Exception {
            final int rc = gapsDescriptionsTableModel.getRowCount();
            for (int i = 0; i < rc; i++) {
                final int modelRow = i;

                try {
                    final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString();
                    final Attribute attr = dataSet.attribute(attrname);
                    final int gapsize = (int) Double
                            .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString())
                            .doubleValue();
                    final int position = (int) Double
                            .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString())
                            .doubleValue();

                    /* most similar */
                    gapsDescriptionsTableModel.setValueAt("...", modelRow, 7);
                    final int cvba = GapsUtil.getCountOfValuesBeforeAndAfter(gapsize);
                    Instances gapds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0,
                            dataSet.numAttributes() - 1, Math.max(0, position - cvba),
                            Math.min(position + gapsize + cvba, dataSet.numInstances() - 1));
                    final String mostsimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(gapds,
                            attr, WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(gapds), false);
                    gapsDescriptionsTableModel.setValueAt(mostsimilar, modelRow, 7);

                    /* 'rising' flag */
                    gapsDescriptionsTableModel.setValueAt("...", modelRow, 11);
                    final List<String> attributeNames = WekaDataStatsUtil.getAttributeNames(dataSet);
                    attributeNames.remove("timestamp");
                    final String nearestStationName = gcp.findNearestStation(attr.name(), attributeNames);
                    final Attribute nearestStationAttr = dataSet.attribute(nearestStationName);
                    //System.out.println(nearestStationName+" "+nearestStationAttr);
                    final boolean isDuringRising = GapsUtil.isDuringRising(dataSet, position, gapsize,
                            new int[] { dateIdx, attr.index(), nearestStationAttr.index() });
                    gapsDescriptionsTableModel.setValueAt(isDuringRising, modelRow, 11);

                    gapsDescriptionsTableModel.fireTableDataChanged();
                } catch (Exception e) {
                    gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 7);
                    gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 11);
                    e.printStackTrace();
                }
            }
            return null;
        }

        @Override
        public void onSuccess(Void result) {
        }

        @Override
        public void onFailure(Throwable caught) {
            caught.printStackTrace();
        }

    }.start();

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

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

/**
 * Constructor./*from  w  w  w .  j  a  va 2s. c  o  m*/
 */
GapFillingKnowledgeDBExplorerFrame(final Instances ds, final int dateIdx, final StationsDataProvider gcp)
        throws Exception {
    LogoHelper.setLogo(this);
    this.setTitle("KnowledgeDB: explorer");

    this.gcp = gcp;

    this.tablePanel = new JXPanel();
    this.tablePanel.setBorder(new TitledBorder("Cases"));

    final JXPanel highPanel = new JXPanel();
    highPanel.setLayout(new BoxLayout(highPanel, BoxLayout.X_AXIS));
    highPanel.add(this.tablePanel);

    this.geomapPanel = new JXPanel();
    this.geomapPanel.add(buildGeoMapChart(new ArrayList<String>(), new ArrayList<String>()));
    highPanel.add(this.geomapPanel);

    this.caseChartPanel = new JXPanel();
    this.caseChartPanel.setBorder(new TitledBorder("Inspected fake gap"));

    this.mostSimilarChartPanel = new JXPanel();
    this.mostSimilarChartPanel.setBorder(new TitledBorder("Most similar"));
    this.nearestChartPanel = new JXPanel();
    this.nearestChartPanel.setBorder(new TitledBorder("Nearest"));
    this.downstreamChartPanel = new JXPanel();
    this.downstreamChartPanel.setBorder(new TitledBorder("Downstream"));
    this.upstreamChartPanel = new JXPanel();
    this.upstreamChartPanel.setBorder(new TitledBorder("Upstream"));

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
    //getContentPane().add(new JCheckBox("Use incomplete series"));
    getContentPane().add(highPanel);
    //getContentPane().add(new JXButton("Export"));      
    getContentPane().add(caseChartPanel);
    getContentPane().add(mostSimilarChartPanel);
    getContentPane().add(nearestChartPanel);
    getContentPane().add(downstreamChartPanel);
    getContentPane().add(upstreamChartPanel);

    //final Instances kdbDS=GapFillingKnowledgeDB.getKnowledgeDBWithBestCasesOnly();      
    final Instances kdbDS = GapFillingKnowledgeDB.getKnowledgeDB();

    final JXTable gapsTable = buidJXTable(kdbDS);
    final JScrollPane tableScrollPane = new JScrollPane(gapsTable);
    tableScrollPane.setPreferredSize(
            new Dimension(COMPONENT_WIDTH - 100, 40 + (int) (tableScrollPane.getPreferredSize().getHeight())));
    this.tablePanel.add(tableScrollPane);

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

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

                final String mostSimilarFlag = gapsTable.getModel().getValueAt(modelRow, 14).toString();
                final String nearestFlag = gapsTable.getModel().getValueAt(modelRow, 15).toString();
                final String downstreamFlag = gapsTable.getModel().getValueAt(modelRow, 16).toString();
                final String upstreamFlag = gapsTable.getModel().getValueAt(modelRow, 17).toString();

                final String algoname = gapsTable.getModel().getValueAt(modelRow, 12).toString();
                final boolean useDiscretizedTime = Boolean
                        .valueOf(gapsTable.getModel().getValueAt(modelRow, 13).toString());

                try {
                    geomapPanel.removeAll();

                    caseChartPanel.removeAll();

                    mostSimilarChartPanel.removeAll();
                    nearestChartPanel.removeAll();
                    downstreamChartPanel.removeAll();
                    upstreamChartPanel.removeAll();

                    final Set<String> selected = new HashSet<String>();

                    final Instances tmpds = WekaDataProcessingUtil.buildFilteredDataSet(ds, 0,
                            ds.numAttributes() - 1,
                            Math.max(0, position - GapsUtil.getCountOfValuesBeforeAndAfter(gapsize)),
                            Math.min(position + gapsize + GapsUtil.getCountOfValuesBeforeAndAfter(gapsize),
                                    ds.numInstances() - 1));

                    final List<String> attributeNames = WekaTimeSeriesUtil
                            .getNamesOfAttributesWithoutGap(tmpds);
                    //final List<String> attributeNames=WekaDataStatsUtil.getAttributeNames(ds);
                    attributeNames.remove(attrname);
                    attributeNames.remove("timestamp");

                    if (Boolean.valueOf(mostSimilarFlag)) {
                        final String mostSimilarStationName = WekaTimeSeriesSimilarityUtil
                                .findMostSimilarTimeSerie(tmpds, tmpds.attribute(attrname), attributeNames,
                                        false);
                        selected.add(mostSimilarStationName);
                        final Attribute mostSimilarStationAttr = tmpds.attribute(mostSimilarStationName);

                        final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx,
                                mostSimilarStationAttr, gapsize, position);
                        cp0.getChart().removeLegend();
                        cp0.setPreferredSize(CHART_DIMENSION);
                        mostSimilarChartPanel.add(cp0);
                    }

                    if (Boolean.valueOf(nearestFlag)) {
                        final String nearestStationName = gcp.findNearestStation(attrname, attributeNames);
                        selected.add(nearestStationName);
                        final Attribute nearestStationAttr = ds.attribute(nearestStationName);

                        final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, nearestStationAttr,
                                gapsize, position);
                        cp0.getChart().removeLegend();
                        cp0.setPreferredSize(CHART_DIMENSION);
                        nearestChartPanel.add(cp0);
                    }

                    if (Boolean.valueOf(downstreamFlag)) {
                        final String downstreamStationName = gcp.findDownstreamStation(attrname,
                                attributeNames);
                        selected.add(downstreamStationName);
                        final Attribute downstreamStationAttr = ds.attribute(downstreamStationName);

                        final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, downstreamStationAttr,
                                gapsize, position);
                        cp0.getChart().removeLegend();
                        cp0.setPreferredSize(CHART_DIMENSION);
                        downstreamChartPanel.add(cp0);
                    }

                    if (Boolean.valueOf(upstreamFlag)) {
                        final String upstreamStationName = gcp.findUpstreamStation(attrname, attributeNames);
                        selected.add(upstreamStationName);
                        final Attribute upstreamStationAttr = ds.attribute(upstreamStationName);

                        final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, upstreamStationAttr,
                                gapsize, position);
                        cp0.getChart().removeLegend();
                        cp0.setPreferredSize(CHART_DIMENSION);
                        upstreamChartPanel.add(cp0);
                    }

                    final GapFiller gapFiller = GapFillerFactory.getGapFiller(algoname, useDiscretizedTime);
                    final ChartPanel cp = GapsUIUtil.buildGapChartPanelWithCorrection(ds, dateIdx,
                            ds.attribute(attrname), gapsize, position, gapFiller, selected);
                    cp.getChart().removeLegend();
                    cp.setPreferredSize(new Dimension((int) CHART_DIMENSION.getWidth(),
                            (int) (CHART_DIMENSION.getHeight() * 1.5)));
                    caseChartPanel.add(cp);

                    geomapPanel.add(buildGeoMapChart(Arrays.asList(attrname), selected));

                    getContentPane().repaint();
                    pack();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    gapsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(final MouseEvent e) {
            if (!e.isPopupTrigger()) {
                // nothing?
            } else {
                final JPopupMenu jPopupMenu = new JPopupMenu("feur");

                final JMenuItem mExport = new JMenuItem("Export this table as CSV");
                mExport.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final JFileChooser fc = new JFileChooser();
                        fc.setAcceptAllFileFilterUsed(false);
                        final int returnVal = fc.showSaveDialog(gapsTable);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                            try {
                                final File file = fc.getSelectedFile();
                                WekaDataAccessUtil.saveInstancesIntoCSVFile(kdbDS, file);
                            } catch (Exception ee) {
                                ee.printStackTrace();
                            }
                        }
                    }
                });
                jPopupMenu.add(mExport);

                jPopupMenu.show(gapsTable, e.getX(), e.getY());
            }
        }
    });

    setPreferredSize(new Dimension(FRAME_WIDTH, 1000));

    pack();
    setVisible(true);

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

From source file:dmh.kuebiko.view.NoteStackFrame.java

/**
 * Perform additional setup to the frame. This is separate from the
 * initialize() method so that the GUI builder doesn't mess with it.
 *//*  ww  w  .  ja  v  a2  s .c  o  m*/
private void additionalSetup() {
    mode = Mode.SEARCH;

    setFocusTraversalPolicy(new CustomFocusTraversalPolicy(searchText, notePanel));

    // Search Text Field.
    AutoCompleteDecorator.decorate(searchText, noteMngr.getNoteTitles(), false);
    searchText.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "clear");
    searchText.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(DocumentEvent e) {
            onSearchTextChanged();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            onSearchTextChanged();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            onSearchTextChanged();
        }
    });
    searchText.getActionMap().put("clear", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            searchText.setText(null);
        }
    });

    searchText.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            setModeToSearch();
            searchText.selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            noteTable.selectNote(searchText.getText());
        }
    });
    searchText.addActionListener(actionMngr.getAction(NewNoteAction.class));

    // Note Table.
    noteTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting()) {
                return;
            }
            final Note selectedNote = noteTable.getSelectedNote();

            if (selectedNote == null) {
                setModeToSearch();
            } else {
                setModeToEdit();
                notePanel.setNote(selectedNote);
                searchText.setText(selectedNote.getTitle());
            }
        }
    });
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetViewer.java

@Override
public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
        return;//from w ww .java  2 s.  c o  m
    }

    update();
}

From source file:ANNFileDetect.EditNet.java

public void populateList() {
    String[] nnames = new String[] { "" };
    nnames = sqlite.GetNetworkNames();//  ww w.j  a  v  a2  s.  co  m
    DefaultListModel mdl = new DefaultListModel();
    for (int i = 0; i < nnames.length; i++) {
        mdl.add(i, nnames[i]);
    }
    NetList.setModel(mdl);
    NetList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (evt.getValueIsAdjusting()) {
                return;
            } else {
                String[] images = {};
                try {
                    images = sqlite.GetImagesForNetwork(NetList.getSelectedValue().toString());
                } catch (Exception e) {
                    System.out.println("exception: " + e.toString());
                }
                DefaultListModel mdl2 = new DefaultListModel();
                if (images.length > 0) {
                    for (int i = 0; i < images.length; i++) {
                        mdl2.add(i, images[i]);
                    }
                } else {
                    mdl2.clear();
                    thresholdList.setModel(mdl2);
                }
                fileList.setModel(mdl2);
            }
        }
    });
    fileList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (evt.getValueIsAdjusting()) {
                return;
            } else {
                String[] thresh = sqlite.GetThresholds(NetList.getSelectedValue().toString(),
                        fileList.getSelectedValue().toString());
                DefaultListModel mdl3 = new DefaultListModel();
                if (thresh.length > 0) {
                    for (int i = 0; i < thresh.length; i++) {
                        String[] vals = thresh[i].split(",");
                        mdl3.add(i, "Range: " + vals[0] + "-" + vals[1] + " Score: " + vals[3] + " Weight: "
                                + vals[2]);
                    }
                } else {
                    mdl3.clear();
                }
                thresholdList.setModel(mdl3);
            }

        }
    });

}

From source file:fr.free.hd.servers.gui.FaceView.java

private JList CreateList() {
    Collection<Face> faces = facesDAO.getFaces();
    final JList list = new JList(faces.toArray());
    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override//from   w ww  .  ja  v a  2  s.c o m
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                face = (Face) list.getSelectedValue();
            }
        }

    });
    return list;
}