Search in sources :

Example 1 with RosterEntrySelectorPanel

use of jmri.jmrit.roster.swing.RosterEntrySelectorPanel in project JMRI by JMRI.

the class AddressPanel method initGUI.

/**
     * Create, initialize and place the GUI objects.
     */
private void initGUI() {
    mainPanel = new JPanel();
    this.setContentPane(mainPanel);
    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(2, 2, 2, 2);
    constraints.weightx = 1;
    constraints.weighty = 0;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.ipadx = -16;
    if (jmri.util.SystemType.isLinux()) {
        constraints.ipady = 0;
    } else {
        constraints.ipady = -16;
    }
    addrSelector.setVariableSize(true);
    mainPanel.add(addrSelector.getCombinedJPanel(), constraints);
    setButton = new JButton(Bundle.getMessage("ButtonSet"));
    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.fill = GridBagConstraints.NONE;
    constraints.weightx = 0;
    constraints.ipadx = constraints.ipady = 0;
    mainPanel.add(setButton, constraints);
    setButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            consistAddress = null;
            changeOfAddress();
        }
    });
    rosterBox = new RosterEntrySelectorPanel();
    getRosterEntrySelector().setNonSelectedItem(Bundle.getMessage("NoLocoSelected"));
    getRosterEntrySelector().setToolTipText(Bundle.getMessage("SelectLocoFromRosterTT"));
    getRosterEntrySelector().addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            rosterItemSelected();
        }
    });
    constraints.gridx = 0;
    constraints.gridy = GridBagConstraints.RELATIVE;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 0;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(getRosterEntrySelector(), constraints);
    conRosterBox = NceConsistRoster.instance().fullRosterComboBox();
    if (NceConsistRoster.instance().numEntries() > 0) {
        // empty entry
        conRosterBox.insertItemAt(Bundle.getMessage("NoConsistSelected"), 0);
        conRosterBox.setSelectedIndex(0);
        conRosterBox.setToolTipText(Bundle.getMessage("SelectConsistFromRosterTT"));
        conRosterBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                consistRosterSelected();
            }
        });
        constraints.gridx = 0;
        constraints.gridy = GridBagConstraints.RELATIVE;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.weightx = 1;
        constraints.weighty = 0;
        mainPanel.add(conRosterBox, constraints);
    }
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    dispatchButton = new JButton(Bundle.getMessage("ButtonDispatch"));
    buttonPanel.add(dispatchButton);
    dispatchButton.setEnabled(false);
    dispatchButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispatchAddress();
        }
    });
    releaseButton = new JButton(Bundle.getMessage("ButtonRelease"));
    buttonPanel.add(releaseButton);
    releaseButton.setEnabled(false);
    releaseButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            releaseAddress();
        }
    });
    progButton = new JButton(Bundle.getMessage("ButtonProgram"));
    buttonPanel.add(progButton);
    progButton.setEnabled(false);
    progButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            openProgrammer();
        }
    });
    constraints.gridx = 0;
    constraints.gridy = GridBagConstraints.RELATIVE;
    constraints.gridwidth = 2;
    constraints.weighty = 0;
    constraints.insets = new Insets(0, 0, 0, 0);
    mainPanel.add(buttonPanel, constraints);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) PropertyChangeEvent(java.beans.PropertyChangeEvent) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel)

Example 2 with RosterEntrySelectorPanel

use of jmri.jmrit.roster.swing.RosterEntrySelectorPanel in project JMRI by JMRI.

the class Editor method locoMarkerFromRoster.

/*
     * *********************** End Popup Methods **********************
     */
/*
     * ****************** Marker Menu ***************************
     */
protected void locoMarkerFromRoster() {
    final JmriJFrame locoRosterFrame = new JmriJFrame();
    locoRosterFrame.getContentPane().setLayout(new FlowLayout());
    locoRosterFrame.setTitle(Bundle.getMessage("LocoFromRoster"));
    javax.swing.JLabel mtext = new javax.swing.JLabel();
    mtext.setText(Bundle.getMessage("SelectLoco") + ":");
    locoRosterFrame.getContentPane().add(mtext);
    final RosterEntrySelectorPanel rosterBox = new RosterEntrySelectorPanel();
    rosterBox.addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            if (rosterBox.getSelectedRosterEntries().length != 0) {
                selectLoco(rosterBox.getSelectedRosterEntries()[0]);
            }
        }
    });
    locoRosterFrame.getContentPane().add(rosterBox);
    locoRosterFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            locoRosterFrame.dispose();
        }
    });
    locoRosterFrame.pack();
    locoRosterFrame.setVisible(true);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) FlowLayout(java.awt.FlowLayout) PropertyChangeListener(java.beans.PropertyChangeListener) JLabel(javax.swing.JLabel) JmriJFrame(jmri.util.JmriJFrame) JLabel(javax.swing.JLabel) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel)

Example 3 with RosterEntrySelectorPanel

use of jmri.jmrit.roster.swing.RosterEntrySelectorPanel in project JMRI by JMRI.

the class KnownLocoSelPane method init.

protected void init() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel pane2a = new JPanel();
    pane2a.setLayout(new BoxLayout(pane2a, BoxLayout.X_AXIS));
    pane2a.add(new JLabel(java.util.ResourceBundle.getBundle("jmri/jmrit/symbolicprog/SymbolicProgBundle").getString("UseExisting")));
    if (mCanIdent) {
        JButton idloco = new JButton(java.util.ResourceBundle.getBundle("jmri/jmrit/symbolicprog/SymbolicProgBundle").getString("ReadAndSelect"));
        idloco.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (log.isDebugEnabled()) {
                    log.debug("Identify locomotive pressed");
                }
                startIdentify();
            }
        });
        pane2a.add(idloco);
        pane2a.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    }
    add(pane2a);
    locoBox = new RosterEntrySelectorPanel();
    locoBox.setNonSelectedItem("Locomotive");
    add(locoBox);
    addProgrammerBox();
    JButton go2 = new JButton(Bundle.getMessage("OpenProgrammer"));
    go2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (log.isDebugEnabled()) {
                log.debug("Open programmer pressed");
            }
            openButton();
        }
    });
    add(go2);
    setBorder(new EmptyBorder(6, 6, 6, 6));
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 4 with RosterEntrySelectorPanel

use of jmri.jmrit.roster.swing.RosterEntrySelectorPanel in project JMRI by JMRI.

the class VSDConfigDialog method initComponents.

/**
     * Init the GUI components
     */
protected void initComponents() {
    this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS));
    // Tabbed pane for loco select (Roster or Manual)
    locoSelectPanel = new JTabbedPane();
    TitledBorder title = BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), Bundle.getMessage("LocoTabbedPaneTitle"));
    title.setTitlePosition(TitledBorder.DEFAULT_POSITION);
    locoSelectPanel.setBorder(title);
    // Roster Tab and Address Tab
    rosterPanel = new JPanel();
    rosterPanel.setLayout(new BoxLayout(rosterPanel, BoxLayout.LINE_AXIS));
    addressPanel = new JPanel();
    addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.LINE_AXIS));
    // tab name
    locoSelectPanel.addTab(Bundle.getMessage("RosterLabel"), rosterPanel);
    locoSelectPanel.addTab(Bundle.getMessage("LocoTabbedPaneManualTab"), addressPanel);
    // has the focus.  Oh well.
    try {
        locoSelectPanel.setToolTipTextAt(locoSelectPanel.indexOfTab(Bundle.getMessage("RosterLabel")), Bundle.getMessage("LTPRosterTabToolTip"));
        locoSelectPanel.setMnemonicAt(locoSelectPanel.indexOfTab(Bundle.getMessage("RosterLabel")), Mnemonics.get("RosterTab"));
        locoSelectPanel.setToolTipTextAt(locoSelectPanel.indexOfTab(Bundle.getMessage("LocoTabbedPaneManualTab")), Bundle.getMessage("LTPManualTabToolTip"));
        locoSelectPanel.setMnemonicAt(locoSelectPanel.indexOfTab(Bundle.getMessage("LocoTabbedPaneManualTab")), Mnemonics.get("ManualTab"));
    } catch (IndexOutOfBoundsException iobe) {
        log.debug("Index out of bounds setting up tabbed Pane: " + iobe);
    // Ignore out-of-bounds exception.  We just won't have mnemonics or tool tips this go round.
    }
    // Roster Tab components
    rosterSelector = new RosterEntrySelectorPanel();
    rosterSelector.setNonSelectedItem(Bundle.getMessage("EmptyRosterBox"));
    rosterSelector.setToolTipText(Bundle.getMessage("LTPRosterSelectorToolTip"));
    //rosterComboBox.setToolTipText("tool tip for roster box");
    rosterSelector.addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            rosterItemSelectAction(null);
        }
    });
    rosterPanel.add(rosterSelector);
    rosterLabel = new javax.swing.JLabel();
    rosterLabel.setText(Bundle.getMessage("RosterLabel"));
    // Address Tab Components
    addressLabel = new javax.swing.JLabel();
    addressSelector = new DccLocoAddressSelector();
    addressSelector.setToolTipText(Bundle.getMessage("LTPAddressSelectorToolTip", Bundle.getMessage("ButtonSet")));
    addressSetButton = new javax.swing.JButton();
    addressSetButton.setText(Bundle.getMessage("ButtonSet"));
    addressSetButton.setEnabled(true);
    addressSetButton.setToolTipText(Bundle.getMessage("AddressSetButtonToolTip"));
    addressSetButton.setMnemonic(Mnemonics.get("AddressSet"));
    addressSetButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addressSetButtonActionPerformed(evt);
        }
    });
    addressPanel.add(addressSelector.getCombinedJPanel());
    addressPanel.add(addressSetButton);
    addressPanel.add(addressLabel);
    // Profile select Pane
    profilePanel = new JPanel();
    profilePanel.setLayout(new BoxLayout(profilePanel, BoxLayout.PAGE_AXIS));
    profileComboBox = new javax.swing.JComboBox<>();
    profileComboBox.setToolTipText(Bundle.getMessage("ProfileComboBoxToolTip"));
    profileLabel = new javax.swing.JLabel();
    profileLoadButton = new JButton(Bundle.getMessage("VSDecoderFileMenuLoadVSDFile"));
    profileLoadButton.setToolTipText(Bundle.getMessage("ProfileLoadButtonToolTip"));
    profileLoadButton.setMnemonic(Mnemonics.get("ProfileLoad"));
    profileLoadButton.setEnabled(true);
    TitledBorder title2 = BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), Bundle.getMessage("ProfileSelectorPaneTitle"));
    title.setTitlePosition(TitledBorder.DEFAULT_POSITION);
    profilePanel.setBorder(title2);
    profileComboBox.setModel(new javax.swing.DefaultComboBoxModel<>());
    // Add any already-loaded profile names
    ArrayList<String> sl = VSDecoderManager.instance().getVSDProfileNames();
    if (sl.isEmpty()) {
        profileComboBox.setEnabled(false);
    } else {
        profileComboBox.setEnabled(true);
    }
    updateProfileList(sl);
    profileComboBox.addItem((loadProfilePrompt = new NullProfileBoxItem()));
    profileComboBox.setSelectedItem(loadProfilePrompt);
    profileComboBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            profileComboBoxActionPerformed(evt);
        }
    });
    profilePanel.add(profileComboBox);
    profilePanel.add(profileLoadButton);
    profileLoadButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            profileLoadButtonActionPerformed(evt);
        }
    });
    profileLabel.setText(Bundle.getMessage("SoundProfileLabel"));
    rosterSaveButton = new javax.swing.JButton();
    rosterSaveButton.setText(Bundle.getMessage("ConfigSaveButtonLabel"));
    rosterSaveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            rosterSaveButtonAction(e);
        }
    });
    // temporarily disable this until we update the RosterEntry
    rosterSaveButton.setEnabled(false);
    rosterSaveButton.setToolTipText(Bundle.getMessage("RosterSaveButtonToolTip"));
    rosterSaveButton.setMnemonic(Mnemonics.get("RosterSave"));
    JPanel cbPanel = new JPanel();
    closeButton = new JButton(Bundle.getMessage("ButtonOK"));
    closeButton.setEnabled(false);
    closeButton.setToolTipText(Bundle.getMessage("CD_CloseButtonToolTip"));
    closeButton.setMnemonic(Mnemonics.get("CloseButton"));
    closeButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            closeButtonActionPerformed(e);
        }
    });
    JButton cancelButton = new JButton(Bundle.getMessage("ButtonCancel"));
    cancelButton.setToolTipText(Bundle.getMessage("CD_CancelButtonToolTip"));
    cancelButton.setMnemonic(Mnemonics.get("CancelButton"));
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });
    cbPanel.add(cancelButton);
    cbPanel.add(rosterSaveButton);
    cbPanel.add(closeButton);
    this.add(locoSelectPanel);
    this.add(profilePanel);
    //this.add(rosterSaveButton);
    this.add(cbPanel);
    this.pack();
    this.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DccLocoAddressSelector(jmri.jmrit.DccLocoAddressSelector) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) TitledBorder(javax.swing.border.TitledBorder) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener)

Example 5 with RosterEntrySelectorPanel

use of jmri.jmrit.roster.swing.RosterEntrySelectorPanel in project JMRI by JMRI.

the class VSDConfigPanel method initComponents.

// initComponents()
//
// Build the GUI components and initialize them.
@Override
public void initComponents() {
    // Connect to the VSDecoderManager, so we know when the Profile list changes.
    VSDecoderManager.instance().addEventListener(new VSDManagerListener() {

        @Override
        public void eventAction(VSDManagerEvent e) {
            if (e.getType() == VSDManagerEvent.EventType.PROFILE_LIST_CHANGE) {
                log.debug("Received Decoder List Change Event");
                handleDecoderListChange(e);
            }
        }
    });
    // Build the GUI.
    //setLayout(new BorderLayout(10, 10));
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    rosterPanel = new JPanel();
    rosterPanel.setLayout(new BoxLayout(rosterPanel, BoxLayout.LINE_AXIS));
    profilePanel = new JPanel();
    profilePanel.setLayout(new BoxLayout(profilePanel, BoxLayout.LINE_AXIS));
    addressPanel = new JPanel();
    addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.LINE_AXIS));
    //this.add(profilePanel, BorderLayout.PAGE_START);
    //this.add(addressPanel, BorderLayout.CENTER);
    //this.add(rosterPanel, BorderLayout.PAGE_END);
    this.add(profilePanel);
    this.add(addressPanel);
    this.add(rosterPanel);
    rosterSelector = new RosterEntrySelectorPanel();
    rosterSelector.setNonSelectedItem("No Loco Selected");
    //rosterComboBox.setToolTipText("tool tip for roster box");
    rosterSelector.addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            rosterItemSelectAction(null);
        }
    });
    rosterPanel.add(rosterSelector);
    rosterLabel = new javax.swing.JLabel();
    rosterLabel.setText("Roster");
    rosterPanel.add(rosterLabel);
    rosterSaveButton = new javax.swing.JButton();
    rosterSaveButton.setText("Save");
    rosterSaveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            rosterSaveButtonAction(e);
        }
    });
    // temporarily disable this until we update the RosterEntry
    rosterSaveButton.setEnabled(false);
    rosterSaveButton.setToolTipText(Bundle.getMessage("RosterSaveButtonToolTip"));
    rosterPanel.add(rosterSaveButton);
    addressLabel = new javax.swing.JLabel();
    addressSetButton = new javax.swing.JButton();
    addressSelector = new DccLocoAddressSelector();
    profileComboBox = new javax.swing.JComboBox<>();
    profileLabel = new javax.swing.JLabel();
    profileComboBox.setModel(new javax.swing.DefaultComboBoxModel<>());
    // Add any already-loaded profile names
    ArrayList<String> sl = VSDecoderManager.instance().getVSDProfileNames();
    if (sl.isEmpty()) {
        profileComboBox.setEnabled(false);
    } else {
        profileComboBox.setEnabled(true);
    }
    updateProfileList(sl);
    profileComboBox.addItem((loadProfilePrompt = new NullProfileBoxItem()));
    profileComboBox.setSelectedItem(loadProfilePrompt);
    profile_selected = false;
    profileComboBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            profileComboBoxActionPerformed(evt);
        }
    });
    profilePanel.add(profileComboBox);
    profileLabel.setText("Sound Profile");
    profilePanel.add(profileLabel);
    addressLabel.setText("Address");
    //addressLabel.setMaximumSize(addressLabel.getPreferredSize());
    addressSetButton.setText("Set");
    addressSetButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addressSetButtonActionPerformed(evt);
        }
    });
    addressSetButton.setEnabled(false);
    addressSetButton.setToolTipText("AddressSetButtonToolTip");
    addressPanel.add(addressSelector.getCombinedJPanel());
    addressPanel.add(addressSetButton);
    addressPanel.add(addressLabel);
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) DccLocoAddressSelector(jmri.jmrit.DccLocoAddressSelector) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel)

Aggregations

RosterEntrySelectorPanel (jmri.jmrit.roster.swing.RosterEntrySelectorPanel)5 ActionListener (java.awt.event.ActionListener)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 JPanel (javax.swing.JPanel)4 ActionEvent (java.awt.event.ActionEvent)3 BoxLayout (javax.swing.BoxLayout)3 JButton (javax.swing.JButton)3 FlowLayout (java.awt.FlowLayout)2 JLabel (javax.swing.JLabel)2 DccLocoAddressSelector (jmri.jmrit.DccLocoAddressSelector)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 JTabbedPane (javax.swing.JTabbedPane)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TitledBorder (javax.swing.border.TitledBorder)1 JmriJFrame (jmri.util.JmriJFrame)1