Example usage for javax.swing ListSelectionModel MULTIPLE_INTERVAL_SELECTION

List of usage examples for javax.swing ListSelectionModel MULTIPLE_INTERVAL_SELECTION

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel MULTIPLE_INTERVAL_SELECTION.

Prototype

int MULTIPLE_INTERVAL_SELECTION

To view the source code for javax.swing ListSelectionModel MULTIPLE_INTERVAL_SELECTION.

Click Source Link

Document

A value for the selectionMode property: select one or more contiguous ranges of indices at a time.

Usage

From source file:org.simmi.GeneSetHead.java

License:asdf

public List getSelspecContigs(List<JComponent> complist, final Map<String, List<Sequence>> speccontigMap,
        final String... selspec) {
    List<Sequence> contigs = null;
    final List<String> specs = new ArrayList<String>(speccontigMap.keySet());
    final JTable stable = new JTable();
    stable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    final TableModel stablemodel = new TableModel() {
        @Override//from w  ww  .  ja  v a 2 s .c  o  m
        public int getRowCount() {
            return specs.size();
        }

        @Override
        public int getColumnCount() {
            return 1;
        }

        @Override
        public String getColumnName(int columnIndex) {
            return "Species";
        }

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            return String.class;
        }

        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            if (rowIndex >= 0 && rowIndex < specs.size())
                return specs.get(rowIndex);
            return null;
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        }

        @Override
        public void addTableModelListener(TableModelListener l) {
        }

        @Override
        public void removeTableModelListener(TableModelListener l) {
        }
    };
    stable.setModel(stablemodel);

    final JTable ctable = new JTable();
    ctable.setAutoCreateRowSorter(true);
    final TableModel ctablemodel = new TableModel() {
        @Override
        public int getRowCount() {
            int r = stable.getSelectedRow();
            String spec = selspec.length > 0 ? selspec[0] : (String) stable.getValueAt(r, 0);
            if (spec != null) {
                List<Sequence> contigs = geneset.speccontigMap.get(spec);
                return contigs.size();
            }
            return 0;
        }

        @Override
        public int getColumnCount() {
            return 1;
        }

        @Override
        public String getColumnName(int columnIndex) {
            return "Contigs";
        }

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            return Sequence.class;
        }

        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            int r = stable.getSelectedRow();
            String spec = selspec.length > 0 ? selspec[0] : (String) stable.getValueAt(r, 0);
            List<Sequence> contigs = geneset.speccontigMap.get(spec);
            return contigs.get(rowIndex);
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        }

        @Override
        public void addTableModelListener(TableModelListener l) {
        }

        @Override
        public void removeTableModelListener(TableModelListener l) {
        }
    };
    ctable.setModel(ctablemodel);

    JScrollPane sscrollpane = new JScrollPane(stable);
    JScrollPane cscrollpane = new JScrollPane(ctable);

    FlowLayout flowlayout = new FlowLayout();
    JComponent c = new JComponent() {
    };
    c.setLayout(flowlayout);
    if (selspec.length == 0)
        c.add(sscrollpane);
    c.add(cscrollpane);

    if (complist != null) {
        for (JComponent comp : complist) {
            c.add(comp);
        }
    }

    stable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ctable.tableChanged(new TableModelEvent(ctablemodel));
        }
    });
    JOptionPane.showMessageDialog(this, c);

    int[] rr = stable.getSelectedRows();
    if (rr.length > 1) {
        List slist = new ArrayList();
        for (int r : rr) {
            int i = stable.convertRowIndexToModel(r);
            slist.add(specs.get(i));
        }

        return slist;
    } else {
        int sr = stable.getSelectedRow();
        String spec = selspec.length > 0 ? selspec[0] : (String) stable.getValueAt(sr, 0);
        if (spec != null) {
            List<Sequence> ctgs = geneset.speccontigMap.get(spec);
            rr = ctable.getSelectedRows();
            contigs = new ArrayList<Sequence>();
            for (int r : rr) {
                int i = ctable.convertRowIndexToModel(r);
                contigs.add(ctgs.get(i));
            }
        }

        return contigs;
    }
}

From source file:org.tranche.gui.AnnotationPanel.java

public AnnotationPanel() {
    setSize(400, 400);/*from ww  w .  j a va2s  .  com*/
    setLayout(new BorderLayout());

    // add the menu bar
    {
        GenericMenuItem blankMenuItem = new GenericMenuItem("Blank");
        blankMenuItem.setMnemonic('b');
        blankMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Thread t = new Thread() {

                    @Override
                    public void run() {
                        model.addRow("", "");
                    }
                };
                t.setDaemon(true);
                t.start();
            }
        });
        addMenu.add(blankMenuItem);

        JSeparator separator = new JSeparator();
        separator.setForeground(blankMenuItem.getForeground());
        addMenu.add(separator);

        GenericMenuItem removeMenuItem = new GenericMenuItem("Remove");
        removeMenuItem.setMnemonic('r');
        removeMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Thread t = new Thread() {

                    @Override
                    public void run() {
                        int[] rows = table.getSelectedRows();
                        for (int i = rows.length - 1; i >= 0; i--) {
                            model.rows.remove(rows[i]);
                        }
                        model.fireTableDataChanged();
                    }
                };
                t.setDaemon(true);
                t.start();
            }
        });
        selectionMenu.add(removeMenuItem);

        addMenu.setMnemonic('a');
        menuBar.add(addMenu);
        selectionMenu.setMnemonic('s');
        menuBar.add(selectionMenu);
        add(menuBar, BorderLayout.NORTH);
    }

    // set up the table
    model = new TagTableModel();
    table = new GenericTable(model, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    GenericScrollPane scrollPane = new GenericScrollPane(table);
    scrollPane.setBorder(Styles.BORDER_NONE);
    scrollPane.setBackground(table.getTableHeader().getBackground());
    scrollPane.setVerticalScrollBar(new GenericScrollBar());
    scrollPane.setHorizontalScrollBar(new GenericScrollBar());
    add(scrollPane, BorderLayout.CENTER);
}

From source file:org.ut.biolab.medsavant.client.filter.TabularFilterView.java

protected final void initContentPanel() {

    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    if (availableValues == null) {
        JTextArea label = new JTextArea(
                "There are too many unique values to generate this list. You will not be able to filter on this column. ");
        label.setOpaque(false);/*from ww  w.  j  a  v  a  2  s .com*/
        label.setLineWrap(true);
        label.setWrapStyleWord(true);

        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(3, 3, 3, 3);
        add(label, gbc);
        this.showViewCard();
        return;
    }

    applyButton = new JButton("Apply");
    applyButton.setEnabled(false);

    AbstractListModel model = new SimpleListModel();

    field = new QuickListFilterField(model);
    field.setHintText("Type here to filter options");

    // the width of the field has to be less than the width
    // provided to the filter, otherwise, it will push the grid wider
    // and components will be inaccessible
    field.setPreferredSize(new Dimension(FIELD_WIDTH, 22));

    filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) {
        @Override
        public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
            return -1;
        }

        @Override
        public boolean isCheckBoxEnabled(int index) {
            return true;
        }
    };
    filterableList.getCheckBoxListSelectionModel()
            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    if (model.getSize() > 0) {
        filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size.
    }

    SearchableUtils.installSearchable(filterableList);

    filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                applyButton.setEnabled(true);
            }
        }
    });

    setAllSelected(true);

    applyButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            applyFilter();
        }
    });

    JScrollPane jsp = new JScrollPane(filterableList) {
        @Override
        public Dimension getPreferredSize() {
            Dimension result = super.getPreferredSize();
            result = new Dimension(Math.min(result.width, TabularFilterView.this.getWidth() - 20),
                    result.height);
            return result;
        }
    };

    selectAll = ViewUtil.createHyperLinkButton("Select All");
    selectAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(true);
            applyButton.setEnabled(true);
        }
    });

    JButton selectNone = ViewUtil.createHyperLinkButton("Select None");

    selectNone.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(false);
            applyButton.setEnabled(true);
        }
    });

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(3, 15, 3, 15);
    add(field, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(3, 3, 3, 3);
    add(jsp, gbc);

    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    add(selectAll, gbc);
    add(selectNone, gbc);

    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.EAST;
    add(applyButton, gbc);

    this.showViewCard();

}

From source file:org.ut.biolab.medsavant.client.view.component.ListViewTablePanel.java

public ListViewTablePanel(Object[][] data, String[] columnNames, Class[] columnClasses, int[] hiddenColumns,
        boolean allowSearch, boolean allowSort, boolean allowPages, boolean allowSelection) {

    this.hiddenColumns = hiddenColumns;
    table = new SortableTable() {
        @Override// w ww.ja  v a 2  s.  c om
        public Component prepareRenderer(TableCellRenderer renderer, int Index_row, int Index_col) {
            Component comp = super.prepareRenderer(renderer, Index_row, Index_col);
            //even index, selected or not selected

            if (isRowSelected(Index_row)) {
                comp.setBackground(ViewUtil.detailSelectedBackground);
            } else {
                if (Index_row % 2 == 0) {
                    comp.setBackground(evenRowColor);
                } else {
                    comp.setBackground(oddRowColor);
                }
            }
            comp.setForeground(ViewUtil.detailForeground);

            comp.setFont(comp.getFont().deriveFont(fontSize));

            return comp;
        }
    };

    table.setBorder(null);
    table.setSelectionForeground(Color.darkGray);
    table.setRowHeight(30);
    table.setClearSelectionOnTableDataChanges(true);
    table.setOptimized(true);
    table.setColumnAutoResizable(true);
    table.setAutoResort(false);
    //table.setDragEnabled(false);
    //table.setRowHeight(20);
    table.setSortable(allowSort);
    table.setSortingEnabled(allowSort);
    table.setFocusable(allowSelection);
    table.setCellSelectionEnabled(allowSelection);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    //table.setMinimumSize(new Dimension(500,999));
    //table.setPreferredSize(new Dimension(500,999));

    //column chooser
    TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
    installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
    columnChooser = new ColumnChooser(table);
    installer.addTableHeaderPopupMenuCustomizer(columnChooser);

    AutoFilterTableHeader header = new AutoFilterTableHeader(table);
    header.setAutoFilterEnabled(true);
    header.setShowFilterIcon(true);
    header.setShowFilterName(true);
    table.setTableHeader(header);

    filterField = new QuickTableFilterField(model);
    filterField.setHintText("Type to search");

    setLayout(new BorderLayout(3, 3));
    fieldPanel = ViewUtil.getClearPanel();
    fieldPanel.setLayout(new GridBagLayout());
    setOpaque(false);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.fill = GridBagConstraints.BOTH;
    if (allowSearch) {
        fieldPanel.add(filterField, gbc);
    }
    if (columnNames.length > 1) {
        JButton chooseColumnButton = new JButton("Fields");
        chooseColumnButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent e) {
                columnChooser.showDialog();
            }
        });
        gbc.weightx = 0.0;
        gbc.fill = GridBagConstraints.NONE;
        fieldPanel.add(chooseColumnButton, gbc);
    }

    setTableModel(data, columnNames, columnClasses);

    if (allowSort) {
        add(fieldPanel, BorderLayout.NORTH);
    }

    JScrollPane jsp = new JScrollPane(table);
    jsp.setBorder(null);
    add(jsp, BorderLayout.CENTER);

    updateData(data);
    updateView();
}

From source file:org.ut.biolab.medsavant.client.view.component.SelectableListView.java

protected final void initContentPanel() {

    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    if (availableValues == null) {
        JTextArea label = new JTextArea("There are too many values to display.");
        label.setOpaque(false);/*from w  w w .j a v a 2s  .  co m*/
        label.setLineWrap(true);
        label.setWrapStyleWord(true);

        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(3, 3, 3, 3);
        add(label, gbc);
        return;
    }

    AbstractListModel model = new SelectableListView.SimpleListModel();

    field = new QuickListFilterField(model);
    field.setHintText("Type here to filter options");

    // the width of the field has to be less than the width
    // provided to the filter, otherwise, it will push the grid wider
    // and components will be inaccessible
    field.setPreferredSize(new Dimension(FIELD_WIDTH, 22));

    filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) {
        @Override
        public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
            return -1;
        }

        @Override
        public boolean isCheckBoxEnabled(int index) {
            return true;
        }
    };
    filterableList.getCheckBoxListSelectionModel()
            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    if (model.getSize() > 0) {
        filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size.
    }

    SearchableUtils.installSearchable(filterableList);

    setAllSelected(true);

    JScrollPane jsp = new JScrollPane(filterableList) {
        @Override
        public Dimension getPreferredSize() {
            Dimension result = super.getPreferredSize();
            result = new Dimension(Math.min(result.width, SelectableListView.this.getWidth() - 20),
                    result.height);
            return result;
        }
    };

    selectAll = ViewUtil.createHyperLinkButton("Select All");
    selectAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(true);
        }
    });

    JButton selectNone = ViewUtil.createHyperLinkButton("Select None");

    selectNone.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(false);
        }
    });

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(3, 15, 3, 15);
    add(field, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(3, 3, 3, 3);
    add(jsp, gbc);

    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    JPanel bottom = new JPanel();
    ViewUtil.applyHorizontalBoxLayout(bottom);

    bottom.add(selectAll);
    bottom.add(selectNone);
    bottom.add(Box.createHorizontalGlue());

    JButton applyButton = new JButton("Apply");
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            saveSelections();
        }

    });
    bottom.add(applyButton);
    add(bottom, gbc);
}

From source file:pipeline.GUI_utils.ListOfPointsView.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*from   ww  w.  j a  v  a2 s . c  om*/
public void show() {
    if (frame != null)
        frame.toFront();
    if (table == null) {
        spreadsheetEngine = new DependencyEngine(new BasicEngineProvider());
        setupTableModel(points);
        silenceUpdates.incrementAndGet();
        table = new JXTablePerColumnFiltering(tableModel);

        table.setRolloverEnabled(true);
        // table.setDragEnabled(true);
        table.setFillsViewportHeight(false);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setColumnSelectionAllowed(true);
        table.setRowSelectionAllowed(true);
        table.setColumnControlVisible(true);
        table.setHighlighters(new Highlighter[] { HighlighterFactory.createAlternateStriping() });

        table.addPropertyChangeListener("horizontalScrollEnabled", new PropertyChangeListener() {

            JViewport viewPort, filteringViewPort, columnDescViewPort;
            int lastX;

            ChangeListener scrollListener = new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    if (viewPort == null || filteringViewPort == null) {
                        return;
                    }
                    Point position = viewPort.getViewPosition();
                    if (position.x == lastX) {
                        return;
                    }
                    filteringViewPort.setViewPosition(position);
                    columnDescViewPort.setViewPosition(position);
                    lastX = position.x;
                }

            };

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (viewPort != null) {
                    viewPort.removeChangeListener(scrollListener);
                }
                if (evt.getNewValue().equals(true)) {
                    viewPort = getTableViewPort(table);
                    if (viewPort == null) {
                        return;
                    }
                    table.filteringTable.setHorizontalScrollEnabled(true);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(true);
                    table.updateFilteringTableSetup();
                    filteringViewPort = getTableViewPort(table.filteringTable);
                    columnDescViewPort = getTableViewPort(table.tableForColumnDescriptions);
                    viewPort.addChangeListener(scrollListener);
                    scrollListener.stateChanged(null);
                } else {
                    table.filteringTable.setHorizontalScrollEnabled(false);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(false);
                }
            }
        });

        modelForColumnDescriptions = new dataModelAllEditable(1, tableModel.getColumnCount());
        Vector<String> rowVector0 = (Vector<String>) modelForColumnDescriptions.getDataVector().get(0);
        for (int j = 0; j < tableModel.getColumnCount(); j++) {
            rowVector0.setElementAt(tableModel.getColumnName(j), j);
        }

        boolean done;
        do {
            done = true;
            for (TableColumn i : table.getColumns(true)) {
                TableColumnExt iCast = (TableColumnExt) i;
                if (iCast.getTitle().equals("Class") || iCast.getTitle().equals("c")
                        || iCast.getTitle().equals("t") || iCast.getTitle().equals("clusterID")
                        || iCast.getTitle().equals("userCell 2") || iCast.getTitle().equals("userCell 3")) {
                    if (iCast.isVisible()) {
                        iCast.setVisible(false);
                        done = false;
                        break;
                    }
                }
            }
        } while (!done);

        SwingUtilities.invokeLater(modelForColumnDescriptions::fireTableDataChanged);

        JScrollPane scrollPane = new JScrollPane(table);
        scrollPane.setPreferredSize(new Dimension(2000, 2000));

        updateColumnDescriptions();
        silenceUpdates.decrementAndGet();

        setSpreadsheetColumnEditorAndRenderer();

        tableForColumnDescriptions = new JXTable(modelForColumnDescriptions);
        table.tableForColumnDescriptions = tableForColumnDescriptions;

        JScrollPane jScrollPaneForNames = new JScrollPane(tableForColumnDescriptions);
        jScrollPaneForNames.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());

        JButton createScatterPlotButton = new JButton("Scatter plot from selected columns");
        controlPanel.add(createScatterPlotButton);
        createScatterPlotButton.setActionCommand("Scatter plot from selected columns");
        createScatterPlotButton.addActionListener(this);

        realTimeUpdateCheckbox = new JCheckBox("Update display in real time");
        controlPanel.add(realTimeUpdateCheckbox);
        realTimeUpdateCheckbox.setActionCommand("Update display in real time");
        realTimeUpdateCheckbox.addActionListener(this);

        JButton forceUpdate = new JButton("Force display update");
        controlPanel.add(forceUpdate);
        forceUpdate.setActionCommand("Force display update");
        forceUpdate.addActionListener(this);

        JButton extendFormula = new JButton("Extend formula to column");
        controlPanel.add(extendFormula);
        extendFormula.setActionCommand("Extend formula to column");
        extendFormula.addActionListener(this);

        JButton saveFormulas = new JButton("Save user formulas...");
        saveFormulas.addActionListener(this);
        saveFormulas.setActionCommand("Save user formulas");
        controlPanel.add(saveFormulas);

        JButton reloadFormulas = new JButton("Reload user formulas...");
        reloadFormulas.addActionListener(this);
        reloadFormulas.setActionCommand("Reload user formulas");
        controlPanel.add(reloadFormulas);

        controlPanel.add(new JLabel("Color with:"));
        coloringComboBox = new JComboBox();
        controlPanel.add(coloringComboBox);
        DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel();
        coloringComboBox.addActionListener(this);

        for (int i = 0; i < tableModel.getColumnCount(); i++) {
            comboBoxModel.addElement(tableModel.getColumnName(i));
        }

        JButton saveTableToFile = new JButton("Save table to file");
        controlPanel.add(saveTableToFile);
        saveTableToFile.setActionCommand("Save table to file");
        saveTableToFile.addActionListener(this);

        /*
        final JCheckBox useCalibration = new JCheckBox("Use calibration");
        useCalibration.addActionListener(e -> {
           if (points == null)
              return;
           boolean selected = useCalibration.isSelected();
           if (selected && !(points instanceof PluginIOCalibrable)) {
              Utils.displayMessage("Type " + points.getClass().getName() + " does not have calibration", true,
             LogLevel.ERROR);
              return;
           }
           PluginIOCalibrable calibrable = (PluginIOCalibrable) points;
           if (selected && (calibrable.getCalibration() == null)) {
              Utils.displayMessage("Calibration information is not present in the segmentation; one "
             + "way of adding it is to give the source image (with calibration) as an input "
             + "to the active contour plugin", true, LogLevel.ERROR);
              return;
           }
           float xyCalibration = selected ? ((float) calibrable.getCalibration().pixelWidth) : 0;
           float zCalibration = selected ? ((float) calibrable.getCalibration().pixelDepth) : 0;
           updateCalibration(xyCalibration, zCalibration);
        });
        PluginIOCalibrable calibrable = null;
        if (points instanceof PluginIOCalibrable)
           calibrable = (PluginIOCalibrable) points;
        boolean calibrationPresent = calibrable != null && calibrable.getCalibration() != null;
        useCalibration.setSelected(calibrationPresent);
        if (calibrationPresent) {
           updateCalibration((float) calibrable.getCalibration().pixelWidth,
          (float) calibrable.getCalibration().pixelDepth);
        }
        controlPanel.add(useCalibration);
        */

        frame = new JFrame(points.getName());
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        listener = new WindowListenerWeakRef(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                close();// So all references to data are nulled, to ensure garbage collection
            }

        });
        frame.addWindowListener(listener);

        frame.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = GridBagConstraints.RELATIVE;
        c.weighty = 0.75;
        c.weightx = 1.0;
        c.gridwidth = 1;
        c.gridheight = 1;

        frame.add(scrollPane, c);

        c.weighty = 0.0;
        JScrollPane scrollPane2 = new JScrollPane(table.filteringTable);
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setMinimumSize(new Dimension(1, 250));
        frame.add(scrollPane2, c);

        c.weighty = 0.0;
        jScrollPaneForNames.setMinimumSize(new Dimension(1, 40));
        jScrollPaneForNames.setMaximumSize(new Dimension(9999999, 40));
        frame.add(jScrollPaneForNames, c);

        c.weighty = 0.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        controlPanel.setMinimumSize(new Dimension(1, 80));
        frame.add(controlPanel, c);

        table.setHorizontalScrollEnabled(true);
        table.updateFilteringTableSetup();

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        frame.setSize((int) (0.67 * width), height / 2);
        frame.setLocation((int) (0.33 * width), height / 2);
        frame.setVisible(true);
    }

    if ((tableUpdateThread == null) || (!tableUpdateThread.isAlive())) {
        tableUpdateThread = new Thread(() -> {
            try {
                checkForDirtiness();
            } catch (Exception e) {
                Utils.log("Exception in ListOfPointsView GUI update thread", LogLevel.ERROR);
                Utils.printStack(e);
            }
        }, "ListOfPointsView GUI update thread");

        tableUpdateThread.start();
    }
}

From source file:pipeline.parameter_cell_views.MultiList.java

public MultiList() {
    super();/*from   w  w w.  j  a  va  2  s.c  o m*/

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;

    list = new JList<>(listContents);
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setVisibleRowCount(-1);
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridwidth = 1;

    this.setMinimumSize(new Dimension(50, 100));

    scrollPane = new JScrollPane(list);
    scrollPane.setMaximumSize(new Dimension(maximalWidth, maximalHeight));
    add(scrollPane, c);

    list.addListSelectionListener(new MultiListListener());
}

From source file:pl.otros.logview.filter.MultipleSelectionFilter.java

public MultipleSelectionFilter(String name, String desc, String label, char mnemonic) {
    super(name, desc);
    this.name = name;
    this.desc = desc;
    this.label = label;
    this.mnemonic = mnemonic;
    selectedItems = new HashSet<>();
    listModel = new DefaultListModel<>();
    jList = new JList<>(listModel);
    jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    jList.addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            selectedItems.clear();//  w w  w.j  a va  2  s  .c om
            Object[] selectedValues = jList.getSelectedValues();
            for (Object selectedValue : selectedValues) {
                selectedItems.add((String) selectedValue);
            }
            listener.valueChanged();
        }
    });
    JLabel jLabel = new JLabel(label);
    jLabel.setLabelFor(jList);
    jLabel.setDisplayedMnemonic(mnemonic);
    panel = new JPanel(new MigLayout());
    panel.add(jLabel, "wrap");
    jList.setVisibleRowCount(5);
    JScrollPane jScrollPane = new JScrollPane(jList);
    jScrollPane.setPreferredSize(new Dimension(100, 100));
    jScrollPane.setMinimumSize(new Dimension(100, 100));
    panel.add(new JScrollPane(jList), "wrap, right, growx");
    panel.add(new JLabel("Use CTRL for multi selection"), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Invert selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            invertSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Clear selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Reload threads") {
        @Override
        public void actionPerformed(ActionEvent e) {
            reloadFilterSet();
        }
    }), "wrap");
}

From source file:pl.otros.logview.filter.ThreadFilter.java

public ThreadFilter() {
    super(NAME, DESCRIPTION);
    selectedThread = new HashSet<String>();
    listModel = new DefaultListModel();
    jList = new JList(listModel);
    jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    jList.addListSelectionListener(new ListSelectionListener() {
        @Override//from w  w  w  . ja  v a2  s . c  o m
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                selectedThread.clear();
                Object[] selectedValues = jList.getSelectedValues();
                for (Object selectedValue : selectedValues) {
                    selectedThread.add((String) selectedValue);
                }
                listener.valueChanged();
            }
        }
    });
    JLabel jLabel = new JLabel("Threads:");
    jLabel.setLabelFor(jList);
    jLabel.setDisplayedMnemonic('t');
    panel = new JPanel(new MigLayout());
    panel.add(jLabel, "wrap");
    panel.add(new JScrollPane(jList), "wrap, right, growx");
    panel.add(new JLabel("Use CTRL for multi selection"), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Invert selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            invertSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Clear selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Reload threads") {
        @Override
        public void actionPerformed(ActionEvent e) {
            reloadThreads();
        }
    }), "wrap");
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

public void setMultiSelectionEnabled(boolean b) {
    int selectionMode = b ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION;
    tableFiles.getSelectionModel().setSelectionMode(selectionMode);
    if (multiSelectionEnabled == b) {
        return;/*from  w  w w . j  a v  a2s.  c  o m*/
    }
    boolean oldValue = multiSelectionEnabled;
    multiSelectionEnabled = b;
    firePropertyChange(MULTI_SELECTION_ENABLED_CHANGED_PROPERTY, oldValue, multiSelectionEnabled);
    try {
        selectionChanged();
    } catch (FileSystemException e) {
        LOGGER.error("Error during update state", e);
    }
}