Search in sources :

Example 16 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class DecoderPro method main.

// Main entry point
public static void main(String[] args) {
    // show splash screen early
    splash(true);
    Apps.setStartupInfo("DecoderPro");
    setConfigFilename("DecoderProConfig2.xml", args);
    JmriJFrame f = new JmriJFrame("DecoderPro");
    DecoderPro dp = new DecoderPro(f);
    createFrame(dp, f);
    log.debug("main initialization done");
    splash(false);
}
Also used : JmriJFrame(jmri.util.JmriJFrame)

Example 17 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class LogixTableAction method makeWhereUsedWindow.

// *********** Methods for Conditional References Window ********************
/**
     * Builds the conditional references window when the Conditional Variable
     * References menu item is selected.
     * <p>
     * This is a stand-alone window that can be closed at any time.
     * @since 4.7.4
     */
void makeWhereUsedWindow() {
    JmriJFrame referenceListFrame = new JmriJFrame(rbx.getString("LabelRefTitle"));
    Container contentPane = referenceListFrame.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // build header information
    JPanel panel1 = new JPanel();
    panel1.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
    panel1.add(new JLabel(rbx.getString("LabelRefTarget")));
    panel1.add(new JLabel(rbx.getString("LabelRefSource")));
    contentPane.add(panel1);
    JScrollPane scrollPane = null;
    condText = new javax.swing.JTextArea(50, 50);
    // Build the conditional references listing
    buildWhereUsedListing();
    scrollPane = new JScrollPane(condText);
    contentPane.add(scrollPane);
    referenceListFrame.pack();
    referenceListFrame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) JmriJFrame(jmri.util.JmriJFrame) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea)

Example 18 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class LogixTableAction method makeAddLogixFrame.

/**
     * Create or copy Logix frame.
     *
     * @param titleId property key to fetch as title of the frame
     * @param messageId part 1 of property key to fetch as user instruction on pane,
     *                  either 1 or 2 is added to form the whole key
     * @return the button JPanel
     */
JPanel makeAddLogixFrame(String titleId, String messageId) {
    addLogixFrame = new JmriJFrame(rbx.getString(titleId));
    addLogixFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
    addLogixFrame.setLocation(50, 30);
    Container contentPane = addLogixFrame.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    JPanel p;
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints c = new java.awt.GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.EAST;
    p.add(_sysNameLabel, c);
    c.gridy = 1;
    p.add(_userNameLabel, c);
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.WEST;
    c.weightx = 1.0;
    // text field will expand
    c.fill = java.awt.GridBagConstraints.HORIZONTAL;
    p.add(_systemName, c);
    c.gridy = 1;
    p.add(_addUserName, c);
    c.gridx = 2;
    c.gridy = 1;
    c.anchor = java.awt.GridBagConstraints.WEST;
    c.weightx = 1.0;
    // text field will expand
    c.fill = java.awt.GridBagConstraints.HORIZONTAL;
    c.gridy = 0;
    p.add(_autoSystemName, c);
    _addUserName.setToolTipText(rbx.getString("LogixUserNameHint"));
    _systemName.setToolTipText(rbx.getString("LogixSystemNameHint"));
    contentPane.add(p);
    // set up message
    JPanel panel3 = new JPanel();
    panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));
    JPanel panel31 = new JPanel();
    panel31.setLayout(new FlowLayout());
    JLabel message1 = new JLabel(rbx.getString(messageId + "1"));
    panel31.add(message1);
    JPanel panel32 = new JPanel();
    JLabel message2 = new JLabel(rbx.getString(messageId + "2"));
    panel32.add(message2);
    panel3.add(panel31);
    panel3.add(panel32);
    contentPane.add(panel3);
    // set up create and cancel buttons
    JPanel panel5 = new JPanel();
    panel5.setLayout(new FlowLayout());
    // Cancel
    JButton cancel = new JButton(Bundle.getMessage("ButtonCancel"));
    panel5.add(cancel);
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancelAddPressed(e);
        }
    });
    cancel.setToolTipText(rbx.getString("CancelLogixButtonHint"));
    addLogixFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            cancelAddPressed(null);
        }
    });
    contentPane.add(panel5);
    _autoSystemName.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            autoSystemName();
        }
    });
    return panel5;
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) ItemListener(java.awt.event.ItemListener)

Example 19 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class LogixTableAction method makeBrowserWindow.

// buildConditionalListing
/**
     * creates and initializes the conditionals browser window
     */
void makeBrowserWindow() {
    condBrowserFrame = new JmriJFrame(rbx.getString("BrowserTitle"));
    condBrowserFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
    Container contentPane = condBrowserFrame.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // LOGIX header information
    JPanel panel1 = new JPanel();
    panel1.setLayout(new FlowLayout());
    String tStr = rbx.getString("BrowserLogix") + " " + _curLogix.getSystemName() + "    " + _curLogix.getUserName() + "    " + (Boolean.valueOf(_curLogix.getEnabled()) ? rbx.getString("BrowserEnabled") : rbx.getString("BrowserDisabled"));
    panel1.add(new JLabel(tStr));
    contentPane.add(panel1);
    JScrollPane scrollPane = null;
    condText = new javax.swing.JTextArea(50, 50);
    condText.setEditable(false);
    condText.setTabSize(4);
    // Build the conditionals listing
    buildConditionalListing();
    scrollPane = new JScrollPane(condText);
    contentPane.add(scrollPane);
    condBrowserFrame.pack();
    condBrowserFrame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) JmriJFrame(jmri.util.JmriJFrame) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea)

Example 20 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class RouteTableAction method addPressed.

@Override
protected void addPressed(ActionEvent e) {
    pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
    if (editMode) {
        cancelEdit();
    }
    jmri.TurnoutManager tm = InstanceManager.turnoutManagerInstance();
    List<String> systemNameList = tm.getSystemNameList();
    _turnoutList = new ArrayList<>(systemNameList.size());
    Iterator<String> iter = systemNameList.iterator();
    while (iter.hasNext()) {
        String systemName = iter.next();
        String userName = tm.getBySystemName(systemName).getUserName();
        _turnoutList.add(new RouteTurnout(systemName, userName));
    }
    jmri.SensorManager sm = InstanceManager.sensorManagerInstance();
    systemNameList = sm.getSystemNameList();
    _sensorList = new ArrayList<>(systemNameList.size());
    iter = systemNameList.iterator();
    while (iter.hasNext()) {
        String systemName = iter.next();
        Sensor s = sm.getBySystemName(systemName);
        if (s != null) {
            String userName = s.getUserName();
            _sensorList.add(new RouteSensor(systemName, userName));
        } else {
            log.error("Failed to get sensor {}", systemName);
        }
    }
    initializeIncludedList();
    // Set up window
    if (addFrame == null) {
        turnoutsAlignedSensor = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
        sensor1 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
        sensor2 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
        sensor3 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
        cTurnout = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance());
        cLockTurnout = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance());
        addFrame = new JmriJFrame(Bundle.getMessage("TitleAddRoute"), false, true);
        addFrame.addHelpMenu("package.jmri.jmrit.beantable.RouteAddEdit", true);
        addFrame.setLocation(100, 30);
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
        // add system name
        JPanel ps = new JPanel();
        ps.setLayout(new FlowLayout());
        ps.add(nameLabel);
        ps.add(_systemName);
        ps.add(_autoSystemName);
        _autoSystemName.addActionListener((ActionEvent e1) -> {
            autoSystemName();
        });
        if (pref.getSimplePreferenceState(systemNameAuto)) {
            _autoSystemName.setSelected(true);
        }
        _systemName.setToolTipText(Bundle.getMessage("TooltipRouteSystemName"));
        ps.add(fixedSystemName);
        fixedSystemName.setVisible(false);
        contentPanel.add(ps);
        // add user name
        JPanel p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(userLabel);
        p.add(_userName);
        _userName.setToolTipText(Bundle.getMessage("TooltipRouteUserName"));
        contentPanel.add(p);
        // add Turnout Display Choice
        JPanel py = new JPanel();
        py.add(new JLabel(Bundle.getMessage("Show") + ":"));
        selGroup = new ButtonGroup();
        allButton = new JRadioButton(Bundle.getMessage("All"), true);
        selGroup.add(allButton);
        py.add(allButton);
        allButton.addActionListener((ActionEvent e1) -> {
            // Setup for display of all Turnouts, if needed
            if (!showAll) {
                showAll = true;
                _routeTurnoutModel.fireTableDataChanged();
                _routeSensorModel.fireTableDataChanged();
            }
        });
        includedButton = new JRadioButton(Bundle.getMessage("Included"), false);
        selGroup.add(includedButton);
        py.add(includedButton);
        includedButton.addActionListener((ActionEvent e1) -> {
            // Setup for display of included Turnouts only, if needed
            if (showAll) {
                showAll = false;
                initializeIncludedList();
                _routeTurnoutModel.fireTableDataChanged();
                _routeSensorModel.fireTableDataChanged();
            }
        });
        py.add(new JLabel(Bundle.getMessage("_and_", Bundle.getMessage("Turnouts"), Bundle.getMessage("Sensors"))));
        // keys are in jmri.jmrit.Bundle
        contentPanel.add(py);
        // add Turnout table
        p2xt = new JPanel();
        JPanel p2xtSpace = new JPanel();
        p2xtSpace.setLayout(new BoxLayout(p2xtSpace, BoxLayout.Y_AXIS));
        p2xtSpace.add(new JLabel("XXX"));
        p2xt.add(p2xtSpace);
        JPanel p21t = new JPanel();
        p21t.setLayout(new BoxLayout(p21t, BoxLayout.Y_AXIS));
        p21t.add(new JLabel(Bundle.getMessage("SelectInRoute", Bundle.getMessage("Turnouts"))));
        p2xt.add(p21t);
        _routeTurnoutModel = new RouteTurnoutModel();
        JTable routeTurnoutTable = new JTable(_routeTurnoutModel);
        TableRowSorter<RouteTurnoutModel> rtSorter = new TableRowSorter<>(_routeTurnoutModel);
        rtSorter.setComparator(RouteTurnoutModel.SNAME_COLUMN, new SystemNameComparator());
        RowSorterUtil.setSortOrder(rtSorter, RouteTurnoutModel.SNAME_COLUMN, SortOrder.ASCENDING);
        routeTurnoutTable.setRowSorter(rtSorter);
        routeTurnoutTable.setRowSelectionAllowed(false);
        routeTurnoutTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
        ROW_HEIGHT = routeTurnoutTable.getRowHeight();
        JComboBox<String> stateTCombo = new JComboBox<>();
        stateTCombo.addItem(SET_TO_CLOSED);
        stateTCombo.addItem(SET_TO_THROWN);
        stateTCombo.addItem(SET_TO_TOGGLE);
        TableColumnModel routeTurnoutColumnModel = routeTurnoutTable.getColumnModel();
        TableColumn includeColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.INCLUDE_COLUMN);
        includeColumnT.setResizable(false);
        includeColumnT.setMinWidth(50);
        includeColumnT.setMaxWidth(60);
        TableColumn sNameColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.SNAME_COLUMN);
        sNameColumnT.setResizable(true);
        sNameColumnT.setMinWidth(75);
        sNameColumnT.setMaxWidth(95);
        TableColumn uNameColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.UNAME_COLUMN);
        uNameColumnT.setResizable(true);
        uNameColumnT.setMinWidth(210);
        uNameColumnT.setMaxWidth(260);
        TableColumn stateColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.STATE_COLUMN);
        stateColumnT.setCellEditor(new DefaultCellEditor(stateTCombo));
        stateColumnT.setResizable(false);
        stateColumnT.setMinWidth(90);
        stateColumnT.setMaxWidth(100);
        _routeTurnoutScrollPane = new JScrollPane(routeTurnoutTable);
        p2xt.add(_routeTurnoutScrollPane, BorderLayout.CENTER);
        contentPanel.add(p2xt);
        p2xt.setVisible(true);
        // add Sensor table
        p2xs = new JPanel();
        JPanel p2xsSpace = new JPanel();
        p2xsSpace.setLayout(new BoxLayout(p2xsSpace, BoxLayout.Y_AXIS));
        p2xsSpace.add(new JLabel("XXX"));
        p2xs.add(p2xsSpace);
        JPanel p21s = new JPanel();
        p21s.setLayout(new BoxLayout(p21s, BoxLayout.Y_AXIS));
        p21s.add(new JLabel(Bundle.getMessage("SelectInRoute", Bundle.getMessage("Sensors"))));
        p2xs.add(p21s);
        _routeSensorModel = new RouteSensorModel();
        JTable routeSensorTable = new JTable(_routeSensorModel);
        TableRowSorter<RouteSensorModel> rsSorter = new TableRowSorter<>(_routeSensorModel);
        rsSorter.setComparator(RouteSensorModel.SNAME_COLUMN, new SystemNameComparator());
        RowSorterUtil.setSortOrder(rsSorter, RouteSensorModel.SNAME_COLUMN, SortOrder.ASCENDING);
        routeSensorTable.setRowSorter(rsSorter);
        routeSensorTable.setRowSelectionAllowed(false);
        routeSensorTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
        JComboBox<String> stateSCombo = new JComboBox<>();
        stateSCombo.addItem(SET_TO_ACTIVE);
        stateSCombo.addItem(SET_TO_INACTIVE);
        stateSCombo.addItem(SET_TO_TOGGLE);
        TableColumnModel routeSensorColumnModel = routeSensorTable.getColumnModel();
        TableColumn includeColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.INCLUDE_COLUMN);
        includeColumnS.setResizable(false);
        includeColumnS.setMinWidth(50);
        includeColumnS.setMaxWidth(60);
        TableColumn sNameColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.SNAME_COLUMN);
        sNameColumnS.setResizable(true);
        sNameColumnS.setMinWidth(75);
        sNameColumnS.setMaxWidth(95);
        TableColumn uNameColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.UNAME_COLUMN);
        uNameColumnS.setResizable(true);
        uNameColumnS.setMinWidth(210);
        uNameColumnS.setMaxWidth(260);
        TableColumn stateColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.STATE_COLUMN);
        stateColumnS.setCellEditor(new DefaultCellEditor(stateSCombo));
        stateColumnS.setResizable(false);
        stateColumnS.setMinWidth(90);
        stateColumnS.setMaxWidth(100);
        _routeSensorScrollPane = new JScrollPane(routeSensorTable);
        p2xs.add(_routeSensorScrollPane, BorderLayout.CENTER);
        contentPanel.add(p2xs);
        p2xs.setVisible(true);
        // Enter filenames for sound, script
        JPanel p25 = new JPanel();
        p25.setLayout(new FlowLayout());
        p25.add(new JLabel(Bundle.getMessage("LabelPlaySound")));
        p25.add(soundFile);
        //NO18N
        JButton ss = new JButton("...");
        ss.addActionListener((ActionEvent e1) -> {
            setSoundPressed();
        });
        ss.setToolTipText(Bundle.getMessage("TooltipOpenFile", Bundle.getMessage("BeanNameAudio")));
        p25.add(ss);
        p25.add(new JLabel(Bundle.getMessage("LabelRunScript")));
        p25.add(scriptFile);
        //NO18N
        ss = new JButton("...");
        ss.addActionListener((ActionEvent e1) -> {
            setScriptPressed();
        });
        ss.setToolTipText(Bundle.getMessage("TooltipOpenFile", Bundle.getMessage("Script")));
        p25.add(ss);
        contentPanel.add(p25);
        //add turnouts aligned Sensor
        JPanel p27 = new JPanel();
        p27.setLayout(new FlowLayout());
        p27.add(new JLabel(Bundle.getMessage("LabelEnterSensorAligned")));
        p27.add(turnoutsAlignedSensor);
        turnoutsAlignedSensor.setFirstItemBlank(true);
        turnoutsAlignedSensor.setSelectedBean(null);
        turnoutsAlignedSensor.setToolTipText(Bundle.getMessage("TooltipEnterSensor"));
        contentPanel.add(p27);
        // add Control Sensor table
        JPanel p3 = new JPanel();
        p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
        JPanel p31 = new JPanel();
        p31.add(new JLabel(Bundle.getMessage("LabelEnterSensors")));
        p3.add(p31);
        JPanel p32 = new JPanel();
        //Sensor 1
        JPanel pS = new JPanel();
        pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 1"));
        pS.add(sensor1);
        pS.add(sensor1mode);
        p32.add(pS);
        //Sensor 2
        pS = new JPanel();
        pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 2"));
        pS.add(sensor2);
        pS.add(sensor2mode);
        p32.add(pS);
        //Sensor 3
        pS = new JPanel();
        pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 3"));
        pS.add(sensor3);
        pS.add(sensor3mode);
        p32.add(pS);
        sensor1.setFirstItemBlank(true);
        sensor2.setFirstItemBlank(true);
        sensor3.setFirstItemBlank(true);
        sensor1.setSelectedBean(null);
        sensor2.setSelectedBean(null);
        sensor3.setSelectedBean(null);
        String sensorHint = Bundle.getMessage("TooltipEnterSensors");
        sensor1.setToolTipText(sensorHint);
        sensor2.setToolTipText(sensorHint);
        sensor3.setToolTipText(sensorHint);
        p3.add(p32);
        // add control turnout
        JPanel p33 = new JPanel();
        p33.add(new JLabel(Bundle.getMessage("LabelEnterTurnout")));
        p3.add(p33);
        JPanel p34 = new JPanel();
        p34.add(new JLabel(Bundle.getMessage("BeanNameTurnout") + ":"));
        p34.add(cTurnout);
        cTurnout.setFirstItemBlank(true);
        cTurnout.setSelectedBean(null);
        cTurnout.setToolTipText(Bundle.getMessage("TooltipEnterTurnout"));
        p34.add(new JLabel("   " + Bundle.getMessage("LabelCondition") + ":"));
        cTurnoutStateBox.setToolTipText(Bundle.getMessage("TooltipTurnoutCondition"));
        p34.add(cTurnoutStateBox);
        p3.add(p34);
        // add added delay
        JPanel p36 = new JPanel();
        p36.add(new JLabel(Bundle.getMessage("LabelTurnoutDelay") + ":"));
        p36.add(timeDelay);
        timeDelay.setText("0");
        timeDelay.setToolTipText(Bundle.getMessage("TooltipTurnoutDelay"));
        p36.add(new JLabel(" " + Bundle.getMessage("LabelMilliseconds")));
        p3.add(p36);
        // complete this panel
        Border p3Border = BorderFactory.createEtchedBorder();
        p3.setBorder(p3Border);
        contentPanel.add(p3);
        // add lock control table
        JPanel p4 = new JPanel();
        p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
        // add lock control turnout
        JPanel p43 = new JPanel();
        p43.add(new JLabel(Bundle.getMessage("LabelLockTurnout")));
        p4.add(p43);
        JPanel p44 = new JPanel();
        p44.add(new JLabel(Bundle.getMessage("BeanNameTurnout") + ":"));
        p44.add(cLockTurnout);
        cLockTurnout.setFirstItemBlank(true);
        cLockTurnout.setSelectedBean(null);
        cLockTurnout.setToolTipText(Bundle.getMessage("TooltipEnterTurnout"));
        p44.add(new JLabel("   " + Bundle.getMessage("LabelCondition") + ":"));
        cLockTurnoutStateBox.setToolTipText(Bundle.getMessage("TooltipLockTurnout"));
        p44.add(cLockTurnoutStateBox);
        p4.add(p44);
        // complete this panel
        Border p4Border = BorderFactory.createEtchedBorder();
        p4.setBorder(p4Border);
        contentPanel.add(p4);
        // add notes panel
        JPanel pa = new JPanel();
        pa.setLayout(new BoxLayout(pa, BoxLayout.Y_AXIS));
        JPanel p1 = new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(status1);
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(status2);
        pa.add(p1);
        pa.add(p2);
        Border pBorder = BorderFactory.createEtchedBorder();
        pa.setBorder(pBorder);
        contentPanel.add(pa);
        // add Buttons panel
        JPanel pb = new JPanel();
        pb.setLayout(new FlowLayout(FlowLayout.TRAILING));
        // Cancel (Add) button
        pb.add(cancelButton);
        cancelButton.addActionListener(this::cancelAddPressed);
        // CancelEdit button
        pb.add(cancelEditButton);
        cancelEditButton.addActionListener(this::cancelPressed);
        cancelEditButton.setToolTipText(Bundle.getMessage("TooltipCancelRoute"));
        // Add Create Route button
        pb.add(createButton);
        createButton.addActionListener(this::createPressed);
        createButton.setToolTipText(Bundle.getMessage("TooltipCreateRoute"));
        // Edit Route button 
        pb.add(editButton);
        editButton.addActionListener(this::editPressed);
        editButton.setToolTipText(Bundle.getMessage("TooltipEditRoute"));
        // Delete Route button
        pb.add(deleteButton);
        deleteButton.addActionListener(this::deletePressed);
        deleteButton.setToolTipText(Bundle.getMessage("TooltipDeleteRoute"));
        // Update Route button
        pb.add(updateButton);
        updateButton.addActionListener((ActionEvent e1) -> {
            updatePressed(e1, false);
        });
        updateButton.setToolTipText(Bundle.getMessage("TooltipUpdateRoute"));
        // Export button
        pb.add(exportButton);
        exportButton.addActionListener(this::exportPressed);
        exportButton.setToolTipText(Bundle.getMessage("TooltipExportRoute"));
        // Show the initial buttons, and hide the others
        exportButton.setVisible(false);
        // show CancelAdd button
        cancelButton.setVisible(true);
        cancelEditButton.setVisible(false);
        updateButton.setVisible(true);
        editButton.setVisible(true);
        createButton.setVisible(true);
        deleteButton.setVisible(false);
        contentPanel.add(pb);
        addFrame.getContentPane().add(new JScrollPane(contentPanel), BorderLayout.CENTER);
        // pack and release space
        addFrame.pack();
        p2xsSpace.setVisible(false);
        p2xtSpace.setVisible(false);
    }
    // set listener for window closing
    addFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            // remind to save, if Route was created or edited
            if (routeDirty) {
                InstanceManager.getDefault(jmri.UserPreferencesManager.class).showInfoMessage(Bundle.getMessage("ReminderTitle"), Bundle.getMessage("ReminderSaveString", Bundle.getMessage("MenuItemRouteTable")), getClassName(), //NOI18N
                "remindSaveRoute");
                routeDirty = false;
            }
            // hide addFrame
            if (addFrame != null) {
                addFrame.setVisible(false);
            // addFrame.dispose(); // causes multiple empty Routes next time
            }
            // if in Edit, cancel edit mode
            if (editMode) {
                cancelEdit();
            }
            _routeSensorModel.dispose();
            _routeTurnoutModel.dispose();
        }
    });
    // display the window
    addFrame.setVisible(true);
    autoSystemName();
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor) JmriJFrame(jmri.util.JmriJFrame) ButtonGroup(javax.swing.ButtonGroup) JTable(javax.swing.JTable) SystemNameComparator(jmri.util.SystemNameComparator) Border(javax.swing.border.Border) Sensor(jmri.Sensor)

Aggregations

JmriJFrame (jmri.util.JmriJFrame)111 ActionEvent (java.awt.event.ActionEvent)46 BoxLayout (javax.swing.BoxLayout)44 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)38 ActionListener (java.awt.event.ActionListener)33 FlowLayout (java.awt.FlowLayout)30 JLabel (javax.swing.JLabel)30 Test (org.junit.Test)22 Container (java.awt.Container)20 JScrollPane (javax.swing.JScrollPane)20 JFrame (javax.swing.JFrame)16 JSeparator (javax.swing.JSeparator)10 JTable (javax.swing.JTable)10 JComboBox (javax.swing.JComboBox)9 TableColumn (javax.swing.table.TableColumn)9 TableColumnModel (javax.swing.table.TableColumnModel)9 ButtonGroup (javax.swing.ButtonGroup)8 JCheckBox (javax.swing.JCheckBox)8 JMenuBar (javax.swing.JMenuBar)8