Search in sources :

Example 1 with SetupExcelProgramSwitchListFrameAction

use of jmri.jmrit.operations.trains.excel.SetupExcelProgramSwitchListFrameAction in project JMRI by JMRI.

the class TrainSwitchListEditFrame method initComponents.

@Override
public void initComponents() {
    // listen for any changes in the number of locations
    locationManager.addPropertyChangeListener(this);
    // the following code sets the frame's initial state
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // tool tips
    switchListRealTimeCheckBox.setToolTipText(Bundle.getMessage("RealTimeTip"));
    switchListAllTrainsCheckBox.setToolTipText(Bundle.getMessage("AllTrainsTip"));
    switchListPageComboBox.setToolTipText(Bundle.getMessage("PageTrainTip"));
    csvChangeButton.setToolTipText(Bundle.getMessage("CsvChangesTip"));
    printChangesButton.setToolTipText(Bundle.getMessage("PrintChangesTip"));
    resetButton.setToolTipText(Bundle.getMessage("ResetSwitchListTip"));
    switchPane = new JScrollPane(locationPanelCheckBoxes);
    switchPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    switchPane.setBorder(BorderFactory.createTitledBorder(""));
    // Layout the panel by rows
    locationPanelCheckBoxes.setLayout(new GridBagLayout());
    updateLocationCheckboxes();
    enableChangeButtons();
    // Clear and set buttons
    JPanel pButtons = new JPanel();
    pButtons.setLayout(new GridBagLayout());
    pButtons.setBorder(BorderFactory.createTitledBorder(""));
    addItem(pButtons, clearButton, 0, 1);
    addItem(pButtons, setButton, 1, 1);
    // options
    JPanel pSwitchListOptions = new JPanel();
    pSwitchListOptions.setLayout(new GridBagLayout());
    pSwitchListOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListOptions")));
    JPanel pSwitchListPageFormat = new JPanel();
    pSwitchListPageFormat.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListPageFormat")));
    pSwitchListPageFormat.add(switchListPageComboBox);
    addItem(pSwitchListOptions, switchListAllTrainsCheckBox, 1, 0);
    addItem(pSwitchListOptions, pSwitchListPageFormat, 2, 0);
    addItem(pSwitchListOptions, switchListRealTimeCheckBox, 3, 0);
    addItem(pSwitchListOptions, saveButton, 4, 0);
    // buttons
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new GridBagLayout());
    controlPanel.setBorder(BorderFactory.createTitledBorder(""));
    // row 3
    addItem(controlPanel, previewButton, 0, 2);
    addItem(controlPanel, printButton, 1, 2);
    addItem(controlPanel, printChangesButton, 2, 2);
    // row 4
    addItem(controlPanel, updateButton, 0, 3);
    addItem(controlPanel, resetButton, 1, 3);
    // row 5
    customPanel = new JPanel();
    customPanel.setLayout(new GridBagLayout());
    customPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutCustomSwitchLists")));
    addItem(customPanel, csvGenerateButton, 1, 4);
    addItem(customPanel, csvChangeButton, 2, 4);
    addItem(customPanel, runButton, 1, 5);
    addItem(customPanel, runChangeButton, 2, 5);
    getContentPane().add(switchPane);
    getContentPane().add(pButtons);
    getContentPane().add(pSwitchListOptions);
    getContentPane().add(controlPanel);
    getContentPane().add(customPanel);
    customPanel.setVisible(Setup.isGenerateCsvSwitchListEnabled());
    // Set the state
    switchListRealTimeCheckBox.setSelected(Setup.isSwitchListRealTime());
    switchListAllTrainsCheckBox.setSelected(Setup.isSwitchListAllTrainsEnabled());
    switchListPageComboBox.setSelectedItem(Setup.getSwitchListPageFormat());
    updateButton.setVisible(!switchListRealTimeCheckBox.isSelected());
    resetButton.setVisible(!switchListRealTimeCheckBox.isSelected());
    saveButton.setEnabled(false);
    addButtonAction(clearButton);
    addButtonAction(setButton);
    addButtonAction(printButton);
    addButtonAction(previewButton);
    addButtonAction(printChangesButton);
    addButtonAction(runButton);
    addButtonAction(runChangeButton);
    addButtonAction(csvGenerateButton);
    addButtonAction(csvChangeButton);
    addButtonAction(updateButton);
    addButtonAction(resetButton);
    addButtonAction(saveButton);
    addCheckBoxAction(switchListRealTimeCheckBox);
    addCheckBoxAction(switchListAllTrainsCheckBox);
    addComboBoxAction(switchListPageComboBox);
    Setup.addPropertyChangeListener(this);
    // build menu
    JMenuBar menuBar = new JMenuBar();
    JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    toolMenu.add(new SetupExcelProgramSwitchListFrameAction(Bundle.getMessage("MenuItemSetupExcelProgramSwitchList")));
    menuBar.add(toolMenu);
    setJMenuBar(menuBar);
    // add help menu to window
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_SwitchList", true);
    // set frame size and train for display
    initMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight500));
}
Also used : JScrollPane(javax.swing.JScrollPane) SetupExcelProgramSwitchListFrameAction(jmri.jmrit.operations.trains.excel.SetupExcelProgramSwitchListFrameAction) JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 BoxLayout (javax.swing.BoxLayout)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 SetupExcelProgramSwitchListFrameAction (jmri.jmrit.operations.trains.excel.SetupExcelProgramSwitchListFrameAction)1