Search in sources :

Example 1 with DccLocoAddressSelector

use of jmri.jmrit.DccLocoAddressSelector 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 2 with DccLocoAddressSelector

use of jmri.jmrit.DccLocoAddressSelector 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

ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 BoxLayout (javax.swing.BoxLayout)2 JPanel (javax.swing.JPanel)2 DccLocoAddressSelector (jmri.jmrit.DccLocoAddressSelector)2 RosterEntrySelectorPanel (jmri.jmrit.roster.swing.RosterEntrySelectorPanel)2 JButton (javax.swing.JButton)1 JTabbedPane (javax.swing.JTabbedPane)1 TitledBorder (javax.swing.border.TitledBorder)1