Search in sources :

Example 1 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class DefaultLogix method startListener.

/**
     * Creates a listener of the required type and starts it
     */
private void startListener(JmriSimplePropertyListener listener) {
    String msg = "(unknown type number " + listener.getType() + ")";
    NamedBean nb;
    NamedBeanHandle<?> namedBeanHandle;
    switch(listener.getType()) {
        case LISTENER_TYPE_FASTCLOCK:
            Timebase tb = InstanceManager.getDefault(jmri.Timebase.class);
            tb.addMinuteChangeListener(listener);
            return;
        default:
            namedBeanHandle = listener.getNamedBean();
            if (namedBeanHandle == null) {
                switch(listener.getType()) {
                    case LISTENER_TYPE_SENSOR:
                        msg = "sensor";
                        break;
                    case LISTENER_TYPE_TURNOUT:
                        msg = "turnout";
                        break;
                    case LISTENER_TYPE_LIGHT:
                        msg = "light";
                        break;
                    case LISTENER_TYPE_CONDITIONAL:
                        msg = "conditional";
                        break;
                    case LISTENER_TYPE_SIGNALHEAD:
                        msg = "signalhead";
                        break;
                    case LISTENER_TYPE_SIGNALMAST:
                        msg = "signalmast";
                        break;
                    case LISTENER_TYPE_MEMORY:
                        msg = "memory";
                        break;
                    case LISTENER_TYPE_WARRANT:
                        msg = "warrant";
                        break;
                    case LISTENER_TYPE_OBLOCK:
                        msg = "oblock";
                        break;
                    case LISTENER_TYPE_ENTRYEXIT:
                        msg = "entry exit";
                        break;
                    default:
                        msg = "unknown";
                }
                break;
            }
            nb = namedBeanHandle.getBean();
            nb.addPropertyChangeListener(listener, namedBeanHandle.getName(), "Logix " + getDisplayName());
            return;
    }
    log.error("Bad name for " + msg + " \"" + listener.getDevName() + "\" when setting up Logix listener");
}
Also used : Timebase(jmri.Timebase) NamedBean(jmri.NamedBean)

Example 2 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class ClockMonPanel method initComponents.

@Override
public void initComponents(NceSystemConnectionMemo m) throws Exception {
    this.memo = m;
    this.tc = m.getNceTrafficController();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // Internal Clock Info Panel
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JPanel pane2 = new JPanel();
    GridBagLayout gLayout = new GridBagLayout();
    GridBagConstraints gConstraints = new GridBagConstraints();
    javax.swing.border.Border pane2Border = BorderFactory.createEtchedBorder();
    javax.swing.border.Border pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InternalClockStatusBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(internalDisplayStatus);
    internalDisplayStatus.setEditable(false);
    internalDisplayStatus.setBorder(BorderFactory.createEmptyBorder());
    add(pane2);
    // NCE Clock Info Panel
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("NceClockStatusBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(nceDisplayStatus);
    nceDisplayStatus.setEditable(false);
    nceDisplayStatus.setBorder(BorderFactory.createEmptyBorder());
    add(pane2);
    // setting time items
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClockValuesBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("LabelTime")));
    pane2.add(hours);
    pane2.add(new JLabel(rb.getString("LabelTimeSep")));
    pane2.add(minutes);
    pane2.add(new JLabel(rb.getString("LabelTimeSep")));
    pane2.add(seconds);
    seconds.setEditable(false);
    pane2.add(new JLabel(" "));
    pane2.add(amPm);
    amPm.setEditable(false);
    pane2.add(new JLabel(" "));
    pane2.add(setClockButton);
    add(pane2);
    // set clock ratio items
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClockRatioBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("LabelRatio")));
    pane2.add(rateNce);
    pane2.add(new JLabel(rb.getString("LabelToOne")));
    pane2.add(setRatioButton);
    add(pane2);
    // add 12/24 clock options
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClock12/24ModeBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(twentyFour);
    pane2.add(new JLabel(" "));
    pane2.add(set1224Button);
    add(pane2);
    //  pane2 = new JPanel();
    //  pane2.setLayout(new BoxLayout(pane2, BoxLayout.X_AXIS));
    //  pane2.add(new JLabel(" "));
    //  pane2.add(status);
    //  add(pane2);
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InterfaceCommandBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.setLayout(gLayout);
    gConstraints.gridx = 0;
    gConstraints.gridy = 0;
    gConstraints.gridwidth = 1;
    gConstraints.gridheight = 1;
    gConstraints.ipadx = 10;
    gConstraints.ipady = 1;
    gConstraints.insets = new Insets(1, 1, 1, 1);
    pane2.add(setStartNceButton, gConstraints);
    gConstraints.gridx++;
    pane2.add(setStopNceButton, gConstraints);
    gConstraints.gridx++;
    pane2.add(readButton, gConstraints);
    ButtonGroup modeGroup = new ButtonGroup();
    modeGroup.add(setSyncModeInternalMaster);
    modeGroup.add(setSyncModeNceMaster);
    modeGroup.add(setSyncModeOff);
    gConstraints.gridx = 0;
    gConstraints.gridy++;
    gConstraints.gridwidth = 3;
    pane2.add(setSyncModeNceMaster, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncModeInternalMaster, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncModeOff, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncButton, gConstraints);
    setSyncModeInternalMaster.setEnabled(true);
    setSyncModeNceMaster.setEnabled(true);
    if (tc.getUsbSystem() != NceTrafficController.USB_SYSTEM_NONE) {
        // needs memory commands to sync
        setSyncModeInternalMaster.setEnabled(false);
        setSyncModeNceMaster.setEnabled(false);
    }
    add(pane2);
    // add polling speed
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InterfaceUpdRateBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("InterfaceUpdRate")));
    pane2.add(new JLabel(" "));
    pane2.add(pollingSpeed);
    pollingSpeed.setText("" + pollingInterval);
    pane2.add(new JLabel(" "));
    pane2.add(new JLabel(rb.getString("InterfaceUpdRateSufix")));
    pane2.add(new JLabel(" "));
    pane2.add(setPollingSpeedButton);
    add(pane2);
    //        // add PID values
    //        gLayout = new GridBagLayout();
    //        gConstraints = new GridBagConstraints();
    //        pane2 = new JPanel();
    //        pane2Border = BorderFactory.createEtchedBorder();
    //        pane2Titled = BorderFactory.createTitledBorder(pane2Border,
    //                                                       rb.getString("InterfacePidBorderText"));
    //        pane2.setBorder(pane2Titled);
    //        pane2.setLayout(gLayout);
    //        gConstraints.gridx = 0;
    //        gConstraints.gridy = 0;
    //        gConstraints.gridwidth = 1;
    //        gConstraints.gridheight = 1;
    //        gConstraints.ipadx = 10;
    //        gConstraints.ipady = 1;
    //        gConstraints.insets = new Insets(3, 3, 3, 3);
    //        pane2.add(new JLabel(rb.getString("InterfacePidNce")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainP")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainP, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainI")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainI, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainD")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainD, gConstraints);
    //        gConstraints.gridx++;
    //        gConstraints.gridheight = 2;
    //        pane2.add(setPidButton, gConstraints);
    //        gConstraints.gridheight = 0;
    //        gConstraints.gridx = 0;
    //        gConstraints.gridy = 1;
    //        pane2.add(new JLabel(rb.getString("InterfacePidInt")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainP")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainP, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainI")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainI, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainD")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainD, gConstraints);
    //        ncePidGainP.setText(fiveDigits.format(ncePidGainPv));
    //        ncePidGainI.setText(fiveDigits.format(ncePidGainIv));
    //        ncePidGainD.setText(fiveDigits.format(ncePidGainDv));
    //        intPidGainP.setText(fiveDigits.format(intPidGainPv));
    //        intPidGainI.setText(fiveDigits.format(intPidGainIv));
    //        intPidGainD.setText(fiveDigits.format(intPidGainDv));
    //        add(pane2);
    // install "read" button handler
    readButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueReadAllRequest();
        }
    });
    // install "set" button handler
    setClockButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockSet(Integer.parseInt(hours.getText().trim()), Integer.parseInt(minutes.getText().trim()), Integer.parseInt(seconds.getText().trim()));
        }
    });
    // install "stop" clock button handler
    setStopNceButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockStop();
        }
    });
    // install "start" clock button handler
    setStartNceButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockStart();
        }
    });
    // install set fast clock ratio
    setRatioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changeNceClockRatio();
        }
    });
    // install set 12/24 button
    set1224Button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClock1224(twentyFour.isSelected());
        }
    });
    // install Sync Change Clock button
    setSyncButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changeSyncMode();
        }
    });
    // install "setPolling" button handler
    setPollingSpeedButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changePollingSpeed(Double.parseDouble(pollingSpeed.getText().trim()));
        }
    });
    // install "setPid" button handler
    setPidButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changePidValues();
        }
    });
    if (clockMode == SYNCMODE_OFF) {
        setSyncModeOff.setSelected(true);
    }
    if (clockMode == SYNCMODE_INTERNAL_MASTER) {
        setSyncModeInternalMaster.setSelected(true);
    }
    if (clockMode == SYNCMODE_NCE_MASTER) {
        setSyncModeNceMaster.setSelected(true);
    }
    this.setSize(400, 300);
    // Create a timebase listener for the Minute change events
    internalClock = InstanceManager.getNullableDefault(jmri.Timebase.class);
    if (internalClock == null) {
        log.error("No Timebase Instance; clock will not run");
        return;
    }
    minuteChangeListener = new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            newInternalMinute();
        }
    };
    internalClock.addMinuteChangeListener(minuteChangeListener);
    // start display alarm timer
    alarmDisplayUpdateHandler();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Timebase(jmri.Timebase) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup)

Example 3 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class DefaultLogix method removeListener.

/**
     * Removes a listener of the required type
     */
private void removeListener(JmriSimplePropertyListener listener) {
    String msg = null;
    NamedBean nb;
    NamedBeanHandle<?> namedBeanHandle;
    try {
        switch(listener.getType()) {
            case LISTENER_TYPE_FASTCLOCK:
                Timebase tb = InstanceManager.getDefault(jmri.Timebase.class);
                tb.removeMinuteChangeListener(listener);
                return;
            case LISTENER_TYPE_ENTRYEXIT:
                NamedBean ex = jmri.InstanceManager.getDefault(jmri.jmrit.signalling.EntryExitPairs.class).getBySystemName(listener.getDevName());
                if (ex == null) {
                    msg = "entryexit";
                    break;
                }
                ex.addPropertyChangeListener(listener);
                return;
            default:
                namedBeanHandle = listener.getNamedBean();
                if (namedBeanHandle == null) {
                    switch(listener.getType()) {
                        case LISTENER_TYPE_SENSOR:
                            msg = "sensor";
                            break;
                        case LISTENER_TYPE_TURNOUT:
                            msg = "turnout";
                            break;
                        case LISTENER_TYPE_LIGHT:
                            msg = "light";
                            break;
                        case LISTENER_TYPE_CONDITIONAL:
                            msg = "conditional";
                            break;
                        case LISTENER_TYPE_SIGNALHEAD:
                            msg = "signalhead";
                            break;
                        case LISTENER_TYPE_SIGNALMAST:
                            msg = "signalmast";
                            break;
                        case LISTENER_TYPE_MEMORY:
                            msg = "memory";
                            break;
                        case LISTENER_TYPE_WARRANT:
                            msg = "warrant";
                            break;
                        case LISTENER_TYPE_OBLOCK:
                            msg = "oblock";
                            break;
                        case LISTENER_TYPE_ENTRYEXIT:
                            msg = "entry exit";
                            break;
                        default:
                            msg = "unknown";
                    }
                    break;
                }
                nb = namedBeanHandle.getBean();
                nb.removePropertyChangeListener(listener);
                return;
        }
    } catch (Exception ex) {
        log.error("Bad name for listener on \"{}\": ", listener.getDevName(), ex);
    }
    log.error("Bad name for " + msg + " listener on \"" + listener.getDevName() + "\" when removing");
}
Also used : Timebase(jmri.Timebase) NamedBean(jmri.NamedBean) JmriException(jmri.JmriException)

Example 4 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class SimpleTimebaseXml method store.

/**
     * Default implementation for storing the contents of a SimpleTimebase.
     * <P>
     * @param o Object to start process, but not actually used
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Timebase clock = InstanceManager.getDefault(jmri.Timebase.class);
    Element elem = new Element("timebase");
    elem.setAttribute("class", this.getClass().getName());
    elem.setAttribute("time", clock.getStartTime().toString());
    elem.setAttribute("rate", "" + clock.userGetRate());
    elem.setAttribute("run", (!clock.getStartStopped() ? "yes" : "no"));
    elem.setAttribute("master", (clock.getInternalMaster() ? "yes" : "no"));
    if (!clock.getInternalMaster()) {
        elem.setAttribute("mastername", clock.getMasterName());
    }
    elem.setAttribute("sync", (clock.getSynchronize() ? "yes" : "no"));
    elem.setAttribute("correct", (clock.getCorrectHardware() ? "yes" : "no"));
    elem.setAttribute("display", (clock.use12HourDisplay() ? "yes" : "no"));
    elem.setAttribute("startstopped", (clock.getStartStopped() ? "yes" : "no"));
    elem.setAttribute("startsettime", (clock.getStartSetTime() ? "yes" : "no"));
    elem.setAttribute("startclockoption", Integer.toString(clock.getStartClockOption()));
    elem.setAttribute("showbutton", (clock.getShowStopButton() ? "yes" : "no"));
    return elem;
}
Also used : Timebase(jmri.Timebase) Element(org.jdom2.Element)

Example 5 with Timebase

use of jmri.Timebase in project JMRI by JMRI.

the class SimpleClockFrame method initComponents.

/**
     * Initialize the Clock config window.
     */
@SuppressWarnings("deprecation")
@Override
public void initComponents() throws Exception {
    setTitle(Bundle.getMessage("SimpleClockWindowTitle"));
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // Determine current state of the clock
    clock = InstanceManager.getNullableDefault(jmri.Timebase.class);
    if (clock == null) {
        // could not initialize clock
        log.error("Could not obtain a Timebase instance.");
        setVisible(false);
        dispose();
        throw new jmri.JmriException("Could not obtain a Timebase instance");
    }
    if (!clock.getIsInitialized()) {
        // if clocks have not been initialized at start up, do so now
        clock.initializeHardwareClock();
    }
    // Set up time source choice
    JPanel panel11 = new JPanel();
    panel11.add(new JLabel(Bundle.getMessage("TimeSource") + " "));
    timeSourceBox = new JComboBox<String>();
    panel11.add(timeSourceBox);
    timeSourceBox.addItem(Bundle.getMessage("ComputerClock"));
    hardwareName = InstanceManager.getDefault(jmri.ClockControl.class).getHardwareClockName();
    if (hardwareName != null) {
        timeSourceBox.addItem(hardwareName);
    }
    timeSourceBox.setToolTipText(Bundle.getMessage("TipTimeSource"));
    timeSourceBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            setTimeSourceChanged();
        }
    });
    contentPane.add(panel11);
    if (hardwareName != null) {
        if (clock.getInternalMaster()) {
            timeSourceBox.setSelectedIndex(internalSourceIndex);
        } else {
            timeSourceBox.setSelectedIndex(hardwareSourceIndex);
        }
        JPanel panel11x = new JPanel();
        synchronizeCheckBox = new JCheckBox(Bundle.getMessage("Synchronize") + " " + hardwareName);
        synchronizeCheckBox.setToolTipText(Bundle.getMessage("TipSynchronize"));
        synchronizeCheckBox.setSelected(clock.getSynchronize());
        synchronizeCheckBox.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                synchronizeChanged();
            }
        });
        panel11x.add(synchronizeCheckBox);
        contentPane.add(panel11x);
        if (InstanceManager.getDefault(jmri.ClockControl.class).canCorrectHardwareClock()) {
            JPanel panel11y = new JPanel();
            correctCheckBox = new JCheckBox(Bundle.getMessage("Correct"));
            correctCheckBox.setToolTipText(Bundle.getMessage("TipCorrect"));
            correctCheckBox.setSelected(clock.getCorrectHardware());
            correctCheckBox.addActionListener(new java.awt.event.ActionListener() {

                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    correctChanged();
                }
            });
            panel11y.add(correctCheckBox);
            contentPane.add(panel11y);
        }
        if (InstanceManager.getDefault(jmri.ClockControl.class).canSet12Or24HourClock()) {
            JPanel panel11z = new JPanel();
            displayCheckBox = new JCheckBox(Bundle.getMessage("Display12Hour"));
            displayCheckBox.setToolTipText(Bundle.getMessage("TipDisplay"));
            displayCheckBox.setSelected(clock.use12HourDisplay());
            displayCheckBox.addActionListener(new java.awt.event.ActionListener() {

                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    displayChanged();
                }
            });
            panel11z.add(displayCheckBox);
            contentPane.add(panel11z);
        }
    }
    // Set up speed up factor
    JPanel panel12 = new JPanel();
    panel12.add(new JLabel(Bundle.getMessage("SpeedUpFactor") + " "));
    panel12.add(factorField);
    factorField.setText(threeDigits.format(clock.userGetRate()));
    factorField.setToolTipText(Bundle.getMessage("TipFactorField"));
    panel12.add(new JLabel(":1 "));
    setRateButton.setToolTipText(Bundle.getMessage("TipSetRateButton"));
    setRateButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            setRateButtonActionPerformed();
        }
    });
    panel12.add(setRateButton);
    contentPane.add(panel12);
    // Set up time setup information
    JPanel panel2 = new JPanel();
    panel2.add(new JLabel(Bundle.getMessage("NewTime") + " "));
    panel2.add(hoursField);
    hoursField.setText("00");
    hoursField.setToolTipText(Bundle.getMessage("TipHoursField"));
    panel2.add(new JLabel(":"));
    panel2.add(minutesField);
    minutesField.setText("00");
    minutesField.setToolTipText(Bundle.getMessage("TipMinutesField"));
    setTimeButton.setToolTipText(Bundle.getMessage("TipSetTimeButton"));
    setTimeButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            setTimeButtonActionPerformed();
        }
    });
    panel2.add(setTimeButton);
    contentPane.add(panel2);
    // Set up startup options panel
    JPanel panel6 = new JPanel();
    panel6.setLayout(new BoxLayout(panel6, BoxLayout.Y_AXIS));
    JPanel panel61 = new JPanel();
    startStoppedCheckBox = new JCheckBox(Bundle.getMessage("StartStopped"));
    startStoppedCheckBox.setToolTipText(Bundle.getMessage("TipStartStopped"));
    startStoppedCheckBox.setSelected(clock.getStartStopped());
    startStoppedCheckBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            startStoppedChanged();
        }
    });
    panel61.add(startStoppedCheckBox);
    panel6.add(panel61);
    JPanel panel62 = new JPanel();
    startSetTimeCheckBox = new JCheckBox(Bundle.getMessage("StartSetTime"));
    startSetTimeCheckBox.setToolTipText(Bundle.getMessage("TipStartSetTime"));
    startSetTimeCheckBox.setSelected(clock.getStartSetTime());
    startSetTimeCheckBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            startSetTimeChanged();
        }
    });
    panel62.add(startSetTimeCheckBox);
    Date tem = clock.getStartTime();
    startHoursField.setText("" + tem.getHours());
    startHoursField.setToolTipText(Bundle.getMessage("TipStartHours"));
    panel62.add(startHoursField);
    panel62.add(new JLabel(":"));
    startMinutesField.setText("" + tem.getMinutes());
    startMinutesField.setToolTipText(Bundle.getMessage("TipStartMinutes"));
    panel62.add(startMinutesField);
    setStartTimeButton.setToolTipText(Bundle.getMessage("TipSetStartTimeButton"));
    setStartTimeButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            startSetTimeChanged();
        }
    });
    panel62.add(setStartTimeButton);
    panel6.add(panel62);
    JPanel panel63 = new JPanel();
    panel63.add(new JLabel(Bundle.getMessage("StartClock") + " "));
    clockStartBox = new JComboBox<String>();
    panel63.add(clockStartBox);
    clockStartBox.addItem(Bundle.getMessage("None"));
    clockStartBox.addItem(Bundle.getMessage("MenuItemNixieClock"));
    clockStartBox.addItem(Bundle.getMessage("MenuItemAnalogClock"));
    clockStartBox.addItem(Bundle.getMessage("MenuItemLcdClock"));
    clockStartBox.setSelectedIndex(startNone);
    if (clock.getStartClockOption() == Timebase.NIXIE_CLOCK) {
        clockStartBox.setSelectedIndex(startNixieClock);
    } else {
        if (clock.getStartClockOption() == Timebase.ANALOG_CLOCK) {
            clockStartBox.setSelectedIndex(startAnalogClock);
        } else {
            if (clock.getStartClockOption() == Timebase.LCD_CLOCK) {
                clockStartBox.setSelectedIndex(startLcdClock);
            }
        }
    }
    clockStartBox.setToolTipText(Bundle.getMessage("TipClockStartOption"));
    clockStartBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            setClockStartChanged();
        }
    });
    panel6.add(panel63);
    JPanel panel64 = new JPanel();
    displayStartStopButton = new JCheckBox(Bundle.getMessage("DisplayOnOff"));
    displayStartStopButton.setSelected(clock.getShowStopButton());
    displayStartStopButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            showStopButtonChanged();
        }
    });
    panel64.add(displayStartStopButton);
    panel6.add(panel64);
    Border panel6Border = BorderFactory.createEtchedBorder();
    Border panel6Titled = BorderFactory.createTitledBorder(panel6Border, Bundle.getMessage("BoxLabelStartUp"));
    panel6.setBorder(panel6Titled);
    contentPane.add(panel6);
    // Set up clock information panel
    JPanel panel3 = new JPanel();
    panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));
    JPanel panel31 = new JPanel();
    panel31.add(clockStatus);
    panel3.add(panel31);
    JPanel panel32 = new JPanel();
    panel32.add(new JLabel(Bundle.getMessage("CurrentTime") + " "));
    setTimeLabel();
    panel32.add(timeLabel);
    panel3.add(panel32);
    Border panel3Border = BorderFactory.createEtchedBorder();
    Border panel3Titled = BorderFactory.createTitledBorder(panel3Border, Bundle.getMessage("BoxLabelClockState"));
    panel3.setBorder(panel3Titled);
    contentPane.add(panel3);
    // Set up Start and Stop buttons
    JPanel panel4 = new JPanel();
    startButton.setToolTipText(Bundle.getMessage("TipStartButton"));
    startButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            startButtonActionPerformed();
        }
    });
    panel4.add(startButton);
    stopButton.setToolTipText(Bundle.getMessage("TipStopButton"));
    stopButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            stopButtonActionPerformed();
        }
    });
    panel4.add(stopButton);
    contentPane.add(panel4);
    // update contents for current status
    updateRunningButton();
    // add help menu to window
    addHelpMenu("package.jmri.jmrit.simpleclock.SimpleClockFrame", true);
    // pack for display
    pack();
    // listen for changes to the timebase parameters
    clock.addPropertyChangeListener(this);
    // request callback to update time
    clock.addMinuteChangeListener(new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            updateTime();
        }
    });
    return;
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Date(java.util.Date) Timebase(jmri.Timebase) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) Border(javax.swing.border.Border)

Aggregations

Timebase (jmri.Timebase)8 BoxLayout (javax.swing.BoxLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 NamedBean (jmri.NamedBean)2 Container (java.awt.Container)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 ButtonGroup (javax.swing.ButtonGroup)1 JCheckBox (javax.swing.JCheckBox)1 Border (javax.swing.border.Border)1 JmriException (jmri.JmriException)1 Element (org.jdom2.Element)1