Search in sources :

Example 61 with JSpinner

use of javax.swing.JSpinner in project jgnash by ccavanaugh.

the class StartupOptions method initComponents.

private void initComponents() {
    updateCurrenciesButton = new JCheckBox(rb.getString("Button.UpdateCurrenciesStartup"));
    updateSecuritiesButton = new JCheckBox(rb.getString("Button.UpdateSecuritiesStartup"));
    openLastOnStartup = new JCheckBox(rb.getString("Button.OpenLastOnStartup"));
    removeBackupButton = new JCheckBox(rb.getString("Button.RemoveOldBackups"));
    saveBackupButton = new JCheckBox(rb.getString("Button.CreateTimeFile"));
    removeBackupCountSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 100, 1));
    if (engine != null) {
        saveBackupButton.setSelected(engine.createBackups());
        removeBackupButton.setSelected(engine.removeOldBackups());
        removeBackupCountSpinner.setValue(engine.getRetainedBackupLimit());
    } else {
        saveBackupButton.setEnabled(false);
        removeBackupButton.setEnabled(false);
        removeBackupCountSpinner.setEnabled(false);
    }
    updateCurrenciesButton.setSelected(CurrencyUpdateFactory.getUpdateOnStartup());
    updateSecuritiesButton.setSelected(UpdateFactory.getUpdateOnStartup());
    openLastOnStartup.setSelected(EngineFactory.openLastOnStartup());
    updateCurrenciesButton.addActionListener(this);
    updateSecuritiesButton.addActionListener(this);
    saveBackupButton.addActionListener(this);
    removeBackupButton.addActionListener(this);
    openLastOnStartup.addActionListener(this);
    removeBackupCountSpinner.addChangeListener(e -> {
        SpinnerModel dateModel = removeBackupCountSpinner.getModel();
        if (dateModel instanceof SpinnerNumberModel) {
            final Number count = ((SpinnerNumberModel) dateModel).getNumber();
            if (engine != null) {
                engine.setRetainedBackupLimit((Integer) count);
            }
        }
    });
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner) SpinnerModel(javax.swing.SpinnerModel)

Example 62 with JSpinner

use of javax.swing.JSpinner in project jgnash by ccavanaugh.

the class MonthTab method layoutMainPanel.

private void layoutMainPanel() {
    FormLayout layout = new FormLayout("right:p, $lcgap, f:p, 2dlu, max(48dlu;min), 2dlu, f:p, 10dlu, right:p, 4dlu, max(48dlu;min)", "f:p, $lgap, f:p, $lgap, f:p");
    layout.setRowGroups(new int[][] { { 1, 3, 5 } });
    setLayout(layout);
    setBorder(Borders.DIALOG);
    CellConstraints cc = new CellConstraints();
    noEndButton = new JRadioButton(rb.getString("Button.NoEndDate"));
    endButton = new JRadioButton();
    endDateField = new DatePanel();
    group.add(noEndButton);
    group.add(endButton);
    numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 24, 1));
    typeComboBox = new JComboBox<>();
    typeComboBox.setModel(new DefaultComboBoxModel<>(new String[] { rb.getString("Column.Date"), rb.getString("Column.Day") }));
    add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1));
    add(numberSpinner, cc.xywh(3, 1, 3, 1));
    add(new JLabel(rb.getString("Tab.Month")), cc.xy(7, 1));
    add(new JLabel(rb.getString("Label.By")), cc.xy(9, 1));
    add(typeComboBox, cc.xy(11, 1));
    add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3));
    add(noEndButton, cc.xyw(3, 3, 5));
    add(endButton, cc.xy(3, 5));
    add(endDateField, cc.xy(5, 5));
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JRadioButton(javax.swing.JRadioButton) DatePanel(jgnash.ui.components.DatePanel) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 63 with JSpinner

use of javax.swing.JSpinner in project jgnash by ccavanaugh.

the class WeekTab method layoutMainPanel.

private void layoutMainPanel() {
    FormLayout layout = new FormLayout("right:p, $lcgap, f:p, 2dlu, max(48dlu;min), $lcgap, f:p, 2dlu, f:d", "f:p, $lgap, f:p, $lgap, f:p");
    layout.setRowGroups(new int[][] { { 1, 3, 5 } });
    setLayout(layout);
    setBorder(Borders.DIALOG);
    CellConstraints cc = new CellConstraints();
    noEndButton = new JRadioButton(rb.getString("Button.NoEndDate"));
    endButton = new JRadioButton();
    endDateField = new DatePanel();
    group.add(noEndButton);
    group.add(endButton);
    numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 52, 1));
    add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1));
    add(numberSpinner, cc.xywh(3, 1, 3, 1));
    add(new JLabel(rb.getString("Tab.Week")), cc.xy(7, 1));
    add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3));
    add(noEndButton, cc.xywh(3, 3, 5, 1));
    add(endButton, cc.xy(3, 5));
    add(endDateField, cc.xy(5, 5));
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JRadioButton(javax.swing.JRadioButton) DatePanel(jgnash.ui.components.DatePanel) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 64 with JSpinner

use of javax.swing.JSpinner in project knime-core by knime.

the class DBSorterNodeDialogPanel method update.

/**
 * Updates this panel based on the DataTableSpec, the list of columns to include and the corresponding sorting
 * order.
 *
 * @param spec the DataTableSpec
 * @param incl the list to include
 * @param sortOrder the sorting order
 * @param nrsortitems the inital number of sortitems to be shown
 */
void update(final DataTableSpec spec, final List<String> incl, final boolean[] sortOrder, final int nrsortitems) {
    m_spec = spec;
    super.removeAll();
    m_components.removeAllElements();
    int interncounter = 0;
    if (spec != null) {
        Vector<DataColumnSpec> values = new Vector<DataColumnSpec>();
        values.add(NOSORT);
        for (int j = 0; j < spec.getNumColumns(); j++) {
            values.add(spec.getColumnSpec(j));
        }
        if ((incl == null) || (sortOrder == null)) {
            for (int i = 0; i < nrsortitems && i < spec.getNumColumns(); i++) {
                DataColumnSpec selected = (i == 0) ? values.get(i + 1) : values.get(0);
                DBSortItem temp = new DBSortItem(i, values, selected, true);
                super.add(temp);
                m_components.add(temp);
            }
        } else {
            for (int i = 0; i < incl.size(); i++) {
                String includeString = incl.get(i);
                int columnIndex = spec.findColumnIndex(includeString);
                if (columnIndex != -1) {
                    DataColumnSpec colspec = spec.getColumnSpec(columnIndex);
                    DBSortItem temp = new DBSortItem(interncounter, values, colspec, sortOrder[interncounter]);
                    super.add(temp);
                    m_components.add(temp);
                    interncounter++;
                } else if (includeString.equals(NOSORT.getName())) {
                    DBSortItem temp = new DBSortItem(interncounter, values, NOSORT, sortOrder[interncounter]);
                    super.add(temp);
                    m_components.add(temp);
                    interncounter++;
                } else if (columnIndex == -1) {
                    DBSortItem temp = new DBSortItem(interncounter, values, includeString, sortOrder[interncounter]);
                    super.add(temp);
                    m_components.add(temp);
                    interncounter++;
                }
            }
        }
        Box buttonbox = Box.createHorizontalBox();
        Border addColumnBorder = BorderFactory.createTitledBorder("Add columns");
        buttonbox.setBorder(addColumnBorder);
        int maxCols = m_spec.getNumColumns() - m_components.size();
        JButton addSortItemButton = new JButton("new columns");
        final JSpinner spinner = new JSpinner();
        SpinnerNumberModel snm;
        if (maxCols == 0) {
            snm = new SpinnerNumberModel(0, 0, maxCols, 1);
            spinner.setEnabled(false);
            addSortItemButton.setEnabled(false);
        } else {
            snm = new SpinnerNumberModel(1, 1, maxCols, 1);
        }
        spinner.setModel(snm);
        spinner.setMaximumSize(new Dimension(50, 25));
        spinner.setPreferredSize(new Dimension(50, 25));
        NumberEditor ne = (NumberEditor) spinner.getEditor();
        final JFormattedTextField spinnertextfield = ne.getTextField();
        // workaround to ensure same background color
        Color backColor = spinnertextfield.getBackground();
        // when spinner's text field is editable false
        spinnertextfield.setEditable(false);
        spinnertextfield.setBackground(backColor);
        addSortItemButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent ae) {
                ArrayList<String> newlist = new ArrayList<String>();
                for (int i = 0; i < m_components.size(); i++) {
                    DBSortItem temp = m_components.get(i);
                    newlist.add(temp.getColumnText());
                }
                int oldsize = m_components.size();
                String temp = spinner.getValue().toString();
                int newsize = Integer.parseInt(temp);
                for (int n = oldsize; n < oldsize + newsize; n++) {
                    newlist.add(NOSORT.getName());
                }
                boolean[] oldbool = new boolean[oldsize];
                boolean[] newbool = new boolean[oldsize + newsize];
                // copy old values
                for (int i = 0; i < m_components.size(); i++) {
                    DBSortItem temp2 = m_components.get(i);
                    newbool[i] = temp2.getSortOrder();
                }
                // create new values
                for (int i = oldbool.length; i < newbool.length; i++) {
                    newbool[i] = true;
                }
                update(m_spec, newlist, newbool, (oldsize + newsize));
            }
        });
        buttonbox.add(spinner);
        buttonbox.add(Box.createHorizontalStrut(10));
        buttonbox.add(addSortItemButton);
        super.add(buttonbox);
        revalidate();
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) Color(java.awt.Color) JButton(javax.swing.JButton) JFormattedTextField(javax.swing.JFormattedTextField) ArrayList(java.util.ArrayList) Box(javax.swing.Box) Dimension(java.awt.Dimension) SpinnerNumberModel(javax.swing.SpinnerNumberModel) DataColumnSpec(org.knime.core.data.DataColumnSpec) ActionListener(java.awt.event.ActionListener) JSpinner(javax.swing.JSpinner) Vector(java.util.Vector) Border(javax.swing.border.Border) NumberEditor(javax.swing.JSpinner.NumberEditor)

Example 65 with JSpinner

use of javax.swing.JSpinner in project knime-core by knime.

the class FileReaderNodeDialog method createAnalysisPanel.

private JPanel createAnalysisPanel() {
    JLabel scanLimitLabel = new JLabel("scan limit (number of lines): ");
    m_scanLimitSpinner = new JSpinner();
    m_scanLimitSpinner.setValue(FileAnalyzer.NUMOFLINES);
    m_analyzeCancel = new JButton("Quick Scan");
    m_analyzeCancel.setToolTipText("Analyze the specified number of lines only.");
    m_analyzeCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if ((int) m_scanLimitSpinner.getValue() < 0) {
                m_scanLimitSpinner.setValue(0);
            }
            m_analyzeCancel.setText("Scanning quickly");
            int limit = (int) m_scanLimitSpinner.getValue();
            m_scanLimitSpinner.setEnabled(false);
            m_analyzeCancel.setEnabled(false);
            m_analysisExecMonitor.setShortCutLines(limit);
            m_analysisExecMonitor.setExecuteCanceled();
        }
    });
    m_analyzeCancel.setEnabled(false);
    m_scanLimitSpinner.setEnabled(false);
    m_analyzeProgressBar = new JProgressBar();
    m_analyzeProgressBar.setIndeterminate(false);
    m_analyzeProgressBar.setStringPainted(false);
    m_analyzeProgressBar.setValue(0);
    Box msgBox = Box.createHorizontalBox();
    msgBox.add(Box.createVerticalStrut(25));
    msgBox.add(m_analyzeProgressMsg);
    msgBox.add(Box.createGlue());
    Box progressBox = Box.createVerticalBox();
    progressBox.add(msgBox);
    progressBox.add(Box.createVerticalStrut(3));
    progressBox.add(m_analyzeProgressBar);
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(Box.createHorizontalGlue());
    buttonBox.add(scanLimitLabel);
    buttonBox.add(m_scanLimitSpinner);
    buttonBox.add(m_analyzeCancel);
    buttonBox.add(Box.createHorizontalGlue());
    Box allBox = Box.createVerticalBox();
    allBox.add(progressBox);
    allBox.add(Box.createVerticalStrut(5));
    allBox.add(buttonBox);
    Box hBox = Box.createHorizontalBox();
    hBox.add(Box.createGlue());
    hBox.add(Box.createGlue());
    hBox.add(allBox);
    hBox.add(Box.createGlue());
    hBox.add(Box.createGlue());
    JPanel result = new JPanel();
    result.setLayout(new BorderLayout());
    result.add(hBox, BorderLayout.NORTH);
    return result;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox)

Aggregations

JSpinner (javax.swing.JSpinner)76 SpinnerNumberModel (javax.swing.SpinnerNumberModel)61 JLabel (javax.swing.JLabel)47 JPanel (javax.swing.JPanel)41 ActionEvent (java.awt.event.ActionEvent)28 ActionListener (java.awt.event.ActionListener)27 JCheckBox (javax.swing.JCheckBox)22 JRadioButton (javax.swing.JRadioButton)21 GridBagConstraints (java.awt.GridBagConstraints)18 Insets (java.awt.Insets)18 ChangeEvent (javax.swing.event.ChangeEvent)18 GridBagLayout (java.awt.GridBagLayout)17 JButton (javax.swing.JButton)15 Dimension (java.awt.Dimension)13 ChangeListener (javax.swing.event.ChangeListener)13 ButtonGroup (javax.swing.ButtonGroup)12 BorderLayout (java.awt.BorderLayout)11 JTextField (javax.swing.JTextField)11 JScrollPane (javax.swing.JScrollPane)10 JMenuItem (javax.swing.JMenuItem)8