Search in sources :

Example 6 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project ACS by ACS-Community.

the class BeanGrouper method startSample.

/**
	 * Method to begin the sampling of all the samples contained in the class.
	 * It initializes the SamplingDataCorrelator Object, which is used to store data to file.<br>
	 */
private void startSample() {
    double freq = 0;
    int prev_status;
    freq = ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().doubleValue();
    Date startTimestamp = new Date();
    if (getSaveButton().isSelected()) {
        _sdc = new SamplingDataCorrelator(group, ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().intValue(), startTimestamp);
        getFileNameLabel().setText("Sampling to file: " + _sdc.getFilename());
        getFileNameLabel().setToolTipText("Saving data to: " + _sdc.getFilename());
    } else {
    }
    prev_status = getStatusIcon().getStatus();
    model.clear();
    for (DataPrinter wp : samplers) {
        wp.setFrequency(freq);
        try {
            wp.startSample();
            isStopped = false;
            addToStatusList("Status: Sampling of " + wp.getComponent() + "#" + wp.getProperty() + " started");
            updateStatusList();
            setStatusIcon(StatusIcon.SAMPLING);
            ssg.setStatus(StatusIcon.CONNECTED_TO_SAMPMANAGER);
        } catch (alma.ACSErrTypeCommon.CouldntAccessComponentEx e) {
            wp.setComponentAvailable(false, "Cannot access component");
            addToStatusList("Status: Cannot access component " + wp.getComponent());
            updateStatusList();
            setStatusIcon(StatusIcon.SAMPLING_WARNING);
        } catch (alma.ACSErrTypeCommon.TypeNotSupportedEx e) {
            wp.setComponentAvailable(false, "Type not supported");
            addToStatusList("Status: Type not supported " + wp.getComponent() + "#" + wp.getProperty());
            updateStatusList();
            setStatusIcon(StatusIcon.SAMPLING_WARNING);
        } catch (alma.ACSErrTypeCommon.CouldntAccessPropertyEx e) {
            wp.setComponentAvailable(false, "Cannot access property");
            addToStatusList("Status: Cannot access property " + wp.getProperty());
            updateStatusList();
            setStatusIcon(StatusIcon.SAMPLING_WARNING);
        } catch (cl.utfsm.samplingSystemUI.core.SamplingManagerException e) {
            wp.setComponentAvailable(false, "Sampling Manager fault");
            //to have only one "Status: Sampling Manager Fault" in the statusComboBox
            if (!faultErrorAddedToStatusBox) {
                addToStatusList("Status: Sampling Manager fault");
                updateStatusList();
                faultErrorAddedToStatusBox = true;
            }
            getStatusIcon().setStatus(StatusIcon.DISCONNECTED);
            ssg.setStatus(StatusIcon.DISCONNECTED);
        }
    }
    if (isStopped) {
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        freqSpinner.setEnabled(true);
        timeSampSpinner.setEnabled(true);
        getSaveButton().setEnabled(true);
        //setStatusIcon(prev_status);
        return;
    }
    if (script != null)
        new ScriptRunner(script).start();
    int mins = ((SpinnerNumberModel) this.getTimeSampSpinner().getModel()).getNumber().intValue();
    if (script == null && mins != 0)
        new Watchdog(mins).start();
}
Also used : Date(java.util.Date) SpinnerNumberModel(javax.swing.SpinnerNumberModel)

Example 7 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project ACS by ACS-Community.

the class BeanGrouper method getTimeWindowSpinner.

/**
	 * Initializes the TextField that will allow to input the desired Time Window for the Sampling Group.<br>
	 * By default the value is 10, which means 10 minutes.<br>
	 * Also checks for its correctness when the value changes.
	 * @return javax.swing.JTextField Reference to the Text Field containing the number.
	 */
private JSpinner getTimeWindowSpinner() {
    if (timeWindowSpinner == null) {
        timeWindowSpinner = new JSpinner();
        timeWindowSpinner.setToolTipText("How much data, expressed in seconds, will the trend present in the graph.");
        timeWindowSpinner.setModel(new SpinnerNumberModel(5, 1, 900, 1));
        timeWindowSpinner.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                setTimeWindow();
            }
        });
    }
    return timeWindowSpinner;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 8 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class GuiLafConfigPane method doToolTipDismissDelay.

public void doToolTipDismissDelay(JPanel panel) {
    GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
    JLabel toolTipDismissDelayLabel = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelay"));
    toolTipDismissDelaySpinner = new JSpinner(new SpinnerNumberModel(manager.getToolTipDismissDelay() / 1000, MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME, 1));
    this.toolTipDismissDelaySpinner.addChangeListener((ChangeEvent e) -> {
        // convert to milliseconds from seconds
        manager.setToolTipDismissDelay((int) toolTipDismissDelaySpinner.getValue() * 1000);
    });
    this.toolTipDismissDelaySpinner.setToolTipText(MessageFormat.format(ConfigBundle.getMessage("GUIToolTipDismissDelayToolTip"), MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME));
    toolTipDismissDelayLabel.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    JLabel toolTipDismissDelayUoM = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelayUoM"));
    toolTipDismissDelayUoM.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    panel.add(toolTipDismissDelayLabel);
    panel.add(toolTipDismissDelaySpinner);
    panel.add(toolTipDismissDelayUoM);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner)

Example 9 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class CoordinateEdit method initSetXY.

public void initSetXY() {
    oldX = pl.getX();
    oldY = pl.getY();
    textX = new javax.swing.JLabel();
    textX.setText("X: " + pl.getX());
    textX.setVisible(true);
    textY = new javax.swing.JLabel();
    textY.setText("Y: " + pl.getY());
    textY.setVisible(true);
    SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 10000, 1);
    ChangeListener listener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText("X: " + pl.getX());
            textY.setText("Y: " + pl.getY());
        }
    };
    spinX = new javax.swing.JSpinner(model);
    spinX.setValue(Integer.valueOf(pl.getX()));
    spinX.setToolTipText(Bundle.getMessage("EnterXcoord"));
    spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
    spinX.addChangeListener(listener);
    model = new javax.swing.SpinnerNumberModel(0, 0, 10000, 1);
    spinY = new javax.swing.JSpinner(model);
    spinY.setValue(Integer.valueOf(pl.getY()));
    spinY.setToolTipText(Bundle.getMessage("EnterYcoord"));
    spinY.setMaximumSize(new Dimension(spinY.getMaximumSize().width, spinY.getPreferredSize().height));
    spinY.addChangeListener(listener);
    getContentPane().setLayout(new GridBagLayout());
    addSpinItems(true);
    okButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText("X: " + pl.getX());
            textY.setText("Y: " + pl.getY());
            dispose();
        }
    });
    okButton.getRootPane().setDefaultButton(okButton);
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            pl.setLocation(oldX, oldY);
            dispose();
        }
    });
    // make large enough to easily move
    setMinimumSize(new Dimension(250, 175));
    pack();
}
Also used : GridBagLayout(java.awt.GridBagLayout) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 10 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class DecoratorPanel method makeFontPanels.

protected void makeFontPanels() {
    JPanel fontPanel = new JPanel();
    _fontSizeBox = new AJComboBox(FONTSIZE, SIZE);
    // NOI18N
    fontPanel.add(makeBoxPanel("FontSize", _fontSizeBox));
    int row = 4;
    for (int i = 0; i < FONTSIZE.length; i++) {
        if (_util.getFontSize() == Integer.parseInt(FONTSIZE[i])) {
            row = i;
            break;
        }
    }
    _fontSizeBox.setSelectedIndex(row);
    _fontStyleBox = new AJComboBox(STYLES, STYLE);
    // NOI18N
    fontPanel.add(makeBoxPanel("FontStyle", _fontStyleBox));
    _fontStyleBox.setSelectedIndex(_util.getFont().getStyle());
    _fontJustBox = new AJComboBox(JUSTIFICATION, JUST);
    // NOI18N
    fontPanel.add(makeBoxPanel("Justification", _fontJustBox));
    switch(_util.getJustification()) {
        case PositionablePopupUtil.LEFT:
            row = 0;
            break;
        case PositionablePopupUtil.RIGHT:
            row = 2;
            break;
        case PositionablePopupUtil.CENTRE:
            row = 1;
            break;
        default:
            row = 2;
    }
    _fontJustBox.setSelectedIndex(row);
    this.add(fontPanel);
    JPanel sizePanel = new JPanel();
    SpinnerNumberModel model = new SpinnerNumberModel(_util.getBorderSize(), 0, 100, 1);
    _borderSpin = new AJSpinner(model, BORDER);
    sizePanel.add(makeSpinPanel("borderSize", _borderSpin));
    model = new SpinnerNumberModel(_util.getMargin(), 0, 100, 1);
    _marginSpin = new AJSpinner(model, MARGIN);
    sizePanel.add(makeSpinPanel("marginSize", _marginSpin));
    model = new SpinnerNumberModel(_util.getFixedWidth(), 0, 1000, 1);
    _widthSpin = new AJSpinner(model, FWIDTH);
    sizePanel.add(makeSpinPanel("fixedWidth", _widthSpin));
    model = new SpinnerNumberModel(_util.getFixedHeight(), 0, 1000, 1);
    _heightSpin = new AJSpinner(model, FHEIGHT);
    sizePanel.add(makeSpinPanel("fixedHeight", _heightSpin));
    this.add(sizePanel);
    JPanel colorPanel = new JPanel();
    colorPanel.add(makeButton(new AJRadioButton(Bundle.getMessage("borderColor"), BORDER_COLOR)));
    this.add(colorPanel);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel)

Aggregations

SpinnerNumberModel (javax.swing.SpinnerNumberModel)58 JSpinner (javax.swing.JSpinner)40 JLabel (javax.swing.JLabel)28 JPanel (javax.swing.JPanel)27 ActionEvent (java.awt.event.ActionEvent)18 ChangeEvent (javax.swing.event.ChangeEvent)16 Dimension (java.awt.Dimension)14 GridBagLayout (java.awt.GridBagLayout)14 JButton (javax.swing.JButton)9 JCheckBox (javax.swing.JCheckBox)9 JRadioButton (javax.swing.JRadioButton)9 ChangeListener (javax.swing.event.ChangeListener)9 BorderLayout (java.awt.BorderLayout)7 FormLayout (com.jgoodies.forms.layout.FormLayout)6 Insets (java.awt.Insets)6 BoxLayout (javax.swing.BoxLayout)6 JScrollPane (javax.swing.JScrollPane)6 JTextField (javax.swing.JTextField)6 GridBagConstraints (java.awt.GridBagConstraints)5 ActionListener (java.awt.event.ActionListener)5