Search in sources :

Example 31 with JSeparator

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

the class AppsLaunchFrame method debugMenu.

protected void debugMenu(JMenuBar menuBar, WindowInterface wi, AppsLaunchPane pane) {
    JMenu d = new DebugMenu(pane);
    // also add some tentative items from jmrix
    d.add(new JSeparator());
    d.add(new jmri.jmrix.pricom.PricomMenu());
    d.add(new JSeparator());
    d.add(new jmri.jmrix.jinput.treecontrol.TreeAction());
    d.add(new jmri.jmrix.libusb.UsbViewAction());
    d.add(new JSeparator());
    try {
        d.add(new RunJythonScript(Bundle.getMessage("MenuRailDriverThrottle"), new File(FileUtil.findURL("jython/RailDriver.py").toURI())));
    } catch (URISyntaxException | NullPointerException ex) {
        log.error("Unable to load RailDriver Throttle", ex);
        JMenuItem i = new JMenuItem(Bundle.getMessage("MenuRailDriverThrottle"));
        i.setEnabled(false);
        d.add(i);
    }
    // also add some tentative items from webserver
    d.add(new JSeparator());
    d.add(new WebServerAction());
    d.add(new JSeparator());
    d.add(new WiThrottleCreationAction());
    menuBar.add(d);
}
Also used : RunJythonScript(jmri.jmrit.jython.RunJythonScript) URISyntaxException(java.net.URISyntaxException) JSeparator(javax.swing.JSeparator) DebugMenu(jmri.jmrit.DebugMenu) WiThrottleCreationAction(jmri.jmrit.withrottle.WiThrottleCreationAction) WebServerAction(jmri.web.server.WebServerAction) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JMenu(javax.swing.JMenu)

Example 32 with JSeparator

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

the class AppsLaunchFrame method developmentMenu.

protected void developmentMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu devMenu = new JMenu("Development");
    menuBar.add(devMenu);
    devMenu.add(new jmri.jmrit.symbolicprog.autospeed.AutoSpeedAction("Auto-speed tool"));
    devMenu.add(new JSeparator());
    devMenu.add(new jmri.jmrit.automat.SampleAutomatonAction("Sample automaton 1"));
    devMenu.add(new jmri.jmrit.automat.SampleAutomaton2Action("Sample automaton 2"));
    devMenu.add(new jmri.jmrit.automat.SampleAutomaton3Action("Sample automaton 3"));
//devMenu.add(new JSeparator());
//devMenu.add(new jmri.jmrix.serialsensor.SerialSensorAction("Serial port sensors"));
}
Also used : JMenu(javax.swing.JMenu) JSeparator(javax.swing.JSeparator)

Example 33 with JSeparator

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

the class TransitTableAction method addEditPressed.

void addEditPressed() {
    pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
    if (addFrame == null) {
        addFrame = new JmriJFrame(Bundle.getMessage("TitleAddTransit"));
        addFrame.addHelpMenu("package.jmri.jmrit.beantable.TransitAddEdit", true);
        addFrame.getContentPane().setLayout(new BoxLayout(addFrame.getContentPane(), BoxLayout.Y_AXIS));
        JPanel p;
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(sysNameLabel);
        p.add(sysNameFixed);
        p.add(sysName);
        sysName.setToolTipText(rbx.getString("TransitSystemNameHint"));
        p.add(new JLabel("     "));
        p.add(userNameLabel);
        p.add(userName);
        userName.setToolTipText(rbx.getString("TransitUserNameHint"));
        addFrame.getContentPane().add(p);
        p = new JPanel();
        ((FlowLayout) p.getLayout()).setVgap(0);
        p.add(_autoSystemName);
        _autoSystemName.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                autoSystemName();
            }
        });
        if (pref.getSimplePreferenceState(systemNameAuto)) {
            _autoSystemName.setSelected(true);
        }
        addFrame.getContentPane().add(p);
        addFrame.getContentPane().add(new JSeparator());
        JPanel p1 = new JPanel();
        p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
        JPanel p11 = new JPanel();
        p11.setLayout(new FlowLayout());
        p11.add(new JLabel(rbx.getString("SectionTableMessage")));
        p1.add(p11);
        JPanel p12 = new JPanel();
        // initialize table of sections
        sectionTableModel = new SectionTableModel();
        JTable sectionTable = new JTable(sectionTableModel);
        sectionTable.setRowSelectionAllowed(false);
        sectionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(650, 150));
        TableColumnModel sectionColumnModel = sectionTable.getColumnModel();
        TableColumn sequenceColumn = sectionColumnModel.getColumn(SectionTableModel.SEQUENCE_COLUMN);
        sequenceColumn.setResizable(true);
        sequenceColumn.setMinWidth(50);
        sequenceColumn.setMaxWidth(70);
        TableColumn sectionColumn = sectionColumnModel.getColumn(SectionTableModel.SECTIONNAME_COLUMN);
        sectionColumn.setResizable(true);
        sectionColumn.setMinWidth(150);
        sectionColumn.setMaxWidth(210);
        TableColumn actionColumn = sectionColumnModel.getColumn(SectionTableModel.ACTION_COLUMN);
        // install button renderer and editor
        ButtonRenderer buttonRenderer = new ButtonRenderer();
        sectionTable.setDefaultRenderer(JButton.class, buttonRenderer);
        TableCellEditor buttonEditor = new ButtonEditor(new JButton());
        sectionTable.setDefaultEditor(JButton.class, buttonEditor);
        JButton testButton = new JButton(rbx.getString("AddEditActions"));
        sectionTable.setRowHeight(testButton.getPreferredSize().height);
        actionColumn.setResizable(false);
        actionColumn.setMinWidth(testButton.getPreferredSize().width);
        TableColumn alternateColumn = sectionColumnModel.getColumn(SectionTableModel.ALTERNATE_COLUMN);
        alternateColumn.setResizable(true);
        alternateColumn.setMinWidth(140);
        alternateColumn.setMaxWidth(170);
        JScrollPane sectionTableScrollPane = new JScrollPane(sectionTable);
        p12.add(sectionTableScrollPane, BorderLayout.CENTER);
        p1.add(p12);
        JPanel p13 = new JPanel();
        p13.setLayout(new FlowLayout());
        p13.add(primarySectionBox);
        primarySectionBox.setToolTipText(rbx.getString("PrimarySectionBoxHint"));
        p13.add(addNextSection = new JButton(rbx.getString("AddPrimaryButton")));
        addNextSection.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addNextSectionPressed(e);
            }
        });
        addNextSection.setToolTipText(rbx.getString("AddPrimaryButtonHint"));
        p1.add(p13);
        JPanel p14 = new JPanel();
        p14.setLayout(new FlowLayout());
        p14.add(alternateSectionBox);
        alternateSectionBox.setToolTipText(rbx.getString("AlternateSectionBoxHint"));
        p14.add(addAlternateSection = new JButton(rbx.getString("AddAlternateButton")));
        addAlternateSection.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addAlternateSectionPressed(e);
            }
        });
        addAlternateSection.setToolTipText(rbx.getString("AddAlternateButtonHint"));
        p14.add(new JLabel("        "));
        p14.add(insertAtBeginningBox);
        insertAtBeginningBox.setToolTipText(rbx.getString("InsertAtBeginningBoxHint"));
        p14.add(insertAtBeginning = new JButton(rbx.getString("InsertAtBeginningButton")));
        insertAtBeginning.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                insertAtBeginningPressed(e);
            }
        });
        insertAtBeginning.setToolTipText(rbx.getString("InsertAtBeginningButtonHint"));
        p1.add(p14);
        p1.add(new JSeparator());
        JPanel p15 = new JPanel();
        p15.setLayout(new FlowLayout());
        p15.add(deleteSections = new JButton(rbx.getString("DeleteSectionsButton")));
        deleteSections.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                deleteAllSections(e);
            }
        });
        deleteSections.setToolTipText(rbx.getString("DeleteSectionsButtonHint"));
        p15.add(new JLabel("     "));
        p15.add(removeLastSection = new JButton(rbx.getString("RemoveLastButton")));
        removeLastSection.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                removeLastSectionPressed(e);
            }
        });
        removeLastSection.setToolTipText(rbx.getString("RemoveLastButtonHint"));
        p15.add(new JLabel("     "));
        p15.add(removeFirstSection = new JButton(rbx.getString("RemoveFirstButton")));
        removeFirstSection.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                removeFirstSectionPressed(e);
            }
        });
        removeFirstSection.setToolTipText(rbx.getString("RemoveFirstButtonHint"));
        p1.add(p15);
        JPanel p16 = new JPanel();
        p16.setLayout(new FlowLayout());
        p16.add(seqNumLabel);
        p16.add(new JLabel("   "));
        p16.add(seqNum);
        seqNum.setToolTipText(rbx.getString("SeqNumHint"));
        p1.add(p16);
        JPanel p17 = new JPanel();
        p17.setLayout(new FlowLayout());
        p17.add(replacePrimaryForSequence = new JButton(rbx.getString("ReplacePrimaryForSeqButton")));
        replacePrimaryForSequence.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                replacePrimaryForSeqPressed(e);
            }
        });
        replacePrimaryForSequence.setToolTipText(rbx.getString("ReplacePrimaryForSeqButtonHint"));
        p17.add(new JLabel("     "));
        p17.add(deleteAlternateForSequence = new JButton(rbx.getString("DeleteAlternateForSeqButton")));
        deleteAlternateForSequence.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                deleteAlternateForSeqPressed(e);
            }
        });
        deleteAlternateForSequence.setToolTipText(rbx.getString("DeleteAlternateForSeqButtonHint"));
        p17.add(new JLabel("     "));
        p17.add(addAlternateForSequence = new JButton(rbx.getString("AddAlternateForSeqButton")));
        addAlternateForSequence.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addAlternateForSeqPressed(e);
            }
        });
        addAlternateForSequence.setToolTipText(rbx.getString("AddAlternateForSeqButtonHint"));
        p1.add(p17);
        addFrame.getContentPane().add(p1);
        // set up bottom buttons
        addFrame.getContentPane().add(new JSeparator());
        JButton cancel = null;
        JPanel pb = new JPanel();
        pb.setLayout(new FlowLayout());
        pb.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
        cancel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelPressed(e);
            }
        });
        cancel.setToolTipText(rbx.getString("CancelButtonHint"));
        pb.add(create = new JButton(Bundle.getMessage("ButtonCreate")));
        create.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                createPressed(e);
            }
        });
        create.setToolTipText(rbx.getString("SectionCreateButtonHint"));
        pb.add(update = new JButton(Bundle.getMessage("ButtonUpdate")));
        update.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updatePressed(e);
            }
        });
        update.setToolTipText(rbx.getString("SectionUpdateButtonHint"));
        addFrame.getContentPane().add(pb);
    }
    if (editMode) {
        // setup for edit window
        _autoSystemName.setVisible(false);
        sysNameLabel.setEnabled(true);
        create.setVisible(false);
        update.setVisible(true);
        sysName.setVisible(false);
        sysNameFixed.setVisible(true);
        initializeEditInformation();
    } else {
        // setup for create window
        _autoSystemName.setVisible(true);
        _autoSystemName.setEnabled(true);
        autoSystemName();
        create.setVisible(true);
        create.setEnabled(true);
        update.setVisible(false);
        sysName.setVisible(true);
        sysNameFixed.setVisible(false);
        if (duplicateMode) {
            // setup with information from previous Transit
            initializeEditInformation();
            sysName.setText(curTransit.getSystemName());
            curTransit = null;
        } else {
            deleteAllSections(null);
        }
    }
    initializeSectionCombos();
    addFrame.pack();
    addFrame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ButtonEditor(jmri.util.table.ButtonEditor) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) JSeparator(javax.swing.JSeparator) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) JTable(javax.swing.JTable) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 34 with JSeparator

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

the class MemoryIcon method showPopUp.

@Override
public boolean showPopUp(JPopupMenu popup) {
    if (isEditable() && selectable) {
        popup.add(new JSeparator());
        java.util.Iterator<String> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            //String value = ((NamedIcon)map.get(key)).getName();
            popup.add(new AbstractAction(key) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String key = e.getActionCommand();
                    setValue(key);
                }
            });
        }
        return true;
    }
    // end of selectable
    if (re != null) {
        popup.add(new AbstractAction(Bundle.getMessage("OpenThrottle")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                ThrottleFrame tf = ThrottleFrameManager.instance().createThrottleFrame();
                tf.toFront();
                tf.getAddressPanel().setRosterEntry(re);
            }
        });
        //don't like the idea of refering specifically to the layout block manager for this, but it has to be done if we are to allow the panel editor to also assign trains to block, when used with a layouteditor
        if ((InstanceManager.getDefault(jmri.SectionManager.class).getSystemNameList().size()) > 0 && jmri.InstanceManager.getDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class).getBlockWithMemoryAssigned(getMemory()) != null) {
            final jmri.jmrit.dispatcher.DispatcherFrame df = jmri.InstanceManager.getNullableDefault(jmri.jmrit.dispatcher.DispatcherFrame.class);
            if (df != null) {
                final jmri.jmrit.dispatcher.ActiveTrain at = df.getActiveTrainForRoster(re);
                if (at != null) {
                    popup.add(new AbstractAction(Bundle.getMessage("MenuTerminateTrain")) {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            df.terminateActiveTrain(at);
                        }
                    });
                    popup.add(new AbstractAction(Bundle.getMessage("MenuAllocateExtra")) {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            //Just brings up the standard allocate extra frame, this could be expanded in the future 
                            //As a point and click operation.
                            df.allocateExtraSection(e, at);
                        }
                    });
                    if (at.getStatus() == jmri.jmrit.dispatcher.ActiveTrain.DONE) {
                        popup.add(new AbstractAction(Bundle.getMessage("MenuRestartTrain")) {

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                at.allocateAFresh();
                            }
                        });
                    }
                } else {
                    popup.add(new AbstractAction(Bundle.getMessage("MenuNewTrain")) {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            if (!df.getNewTrainActive()) {
                                df.getActiveTrainFrame().initiateTrain(e, re, jmri.InstanceManager.getDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class).getBlockWithMemoryAssigned(getMemory()).getBlock());
                                df.setNewTrainActive(true);
                            } else {
                                df.getActiveTrainFrame().showActivateFrame(re);
                            }
                        }
                    });
                }
            }
        }
        return true;
    }
    return false;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JSeparator(javax.swing.JSeparator) ThrottleFrame(jmri.jmrit.throttle.ThrottleFrame) AbstractAction(javax.swing.AbstractAction)

Example 35 with JSeparator

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

the class PaneProgAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameServiceProgrammerSetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // ensure status line is cleared on close so it is normal if re-opened
    f.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent we) {
            statusLabel.setText(SymbolicProgBundle.getMessage("StateIdle"));
            f.windowClosing(we);
        }
    });
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
    menuBar.add(j);
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // new Loco on programming track
    JPanel pane1 = new CombinedLocoSelTreePane(statusLabel, modePane) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { "new decoder" });
            if (re != null) {
                title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { re.getId() });
            }
            JFrame p = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePane.getProgrammer());
            p.pack();
            p.setVisible(true);
        // f.setVisible(false);
        // f.dispose();
        }
    };
    // load primary frame
    JPanel tempPane = new JPanel();
    tempPane.add(modePane);
    f.getContentPane().add(tempPane);
    f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
    statusLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(statusLabel);
    f.pack();
    if (log.isDebugEnabled()) {
        log.debug("Tab-Programmer setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) WindowAdapter(java.awt.event.WindowAdapter) JSeparator(javax.swing.JSeparator) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) CombinedLocoSelTreePane(jmri.jmrit.symbolicprog.CombinedLocoSelTreePane)

Aggregations

JSeparator (javax.swing.JSeparator)147 JPanel (javax.swing.JPanel)74 JLabel (javax.swing.JLabel)65 ActionEvent (java.awt.event.ActionEvent)44 BoxLayout (javax.swing.BoxLayout)44 JButton (javax.swing.JButton)44 JMenuItem (javax.swing.JMenuItem)38 JMenu (javax.swing.JMenu)32 GridBagConstraints (java.awt.GridBagConstraints)31 Insets (java.awt.Insets)30 ActionListener (java.awt.event.ActionListener)30 Dimension (java.awt.Dimension)24 FlowLayout (java.awt.FlowLayout)24 JScrollPane (javax.swing.JScrollPane)24 GridBagLayout (java.awt.GridBagLayout)22 JPopupMenu (javax.swing.JPopupMenu)19 BorderLayout (java.awt.BorderLayout)16 JTextField (javax.swing.JTextField)16 JCheckBox (javax.swing.JCheckBox)13 AbstractAction (javax.swing.AbstractAction)12