Search in sources :

Example 16 with JMenuBar

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

the class MultiPaneWindow method addMainMenuBar.

protected void addMainMenuBar(String menuFile) {
    JMenuBar menuBar = new JMenuBar();
    JMenu[] menus = JMenuUtil.loadMenu(menuFile, rightTopWI, null);
    for (JMenu j : menus) {
        menuBar.add(j);
    }
    setJMenuBar(menuBar);
}
Also used : JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 17 with JMenuBar

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

the class MdiMainFrame method addMainMenuBar.

protected void addMainMenuBar(String menuFile) {
    JMenuBar menuBar = new JMenuBar();
    // no central context
    JMenu[] menus = JMenuUtil.loadMenu(menuFile, rightWI, null);
    for (JMenu j : menus) {
        menuBar.add(j);
    }
    setJMenuBar(menuBar);
}
Also used : JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 18 with JMenuBar

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

the class DispatcherFrame method openDispatcherWindow.

void openDispatcherWindow() {
    if (dispatcherFrame == null) {
        dispatcherFrame = this;
        dispatcherFrame.setTitle(Bundle.getMessage("TitleDispatcher"));
        JMenuBar menuBar = new JMenuBar();
        optionsMenu = new OptionsMenu(this);
        menuBar.add(optionsMenu);
        setJMenuBar(menuBar);
        dispatcherFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Dispatcher", true);
        contentPane = dispatcherFrame.getContentPane();
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
        // set up active trains table
        JPanel p11 = new JPanel();
        p11.setLayout(new FlowLayout());
        p11.add(new JLabel(Bundle.getMessage("ActiveTrainTableTitle")));
        contentPane.add(p11);
        JPanel p12 = new JPanel();
        p12.setLayout(new FlowLayout());
        activeTrainsTableModel = new ActiveTrainsTableModel();
        JTable activeTrainsTable = new JTable(activeTrainsTableModel);
        activeTrainsTable.setRowSelectionAllowed(false);
        activeTrainsTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 160));
        TableColumnModel activeTrainsColumnModel = activeTrainsTable.getColumnModel();
        TableColumn transitColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRANSIT_COLUMN);
        transitColumn.setResizable(true);
        transitColumn.setMinWidth(140);
        transitColumn.setMaxWidth(220);
        TableColumn trainColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRAIN_COLUMN);
        trainColumn.setResizable(true);
        trainColumn.setMinWidth(90);
        trainColumn.setMaxWidth(160);
        TableColumn typeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TYPE_COLUMN);
        typeColumn.setResizable(true);
        typeColumn.setMinWidth(130);
        typeColumn.setMaxWidth(190);
        TableColumn statusColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.STATUS_COLUMN);
        statusColumn.setResizable(true);
        statusColumn.setMinWidth(90);
        statusColumn.setMaxWidth(140);
        TableColumn modeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.MODE_COLUMN);
        modeColumn.setResizable(true);
        modeColumn.setMinWidth(90);
        modeColumn.setMaxWidth(140);
        TableColumn allocatedColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATED_COLUMN);
        allocatedColumn.setResizable(true);
        allocatedColumn.setMinWidth(120);
        allocatedColumn.setMaxWidth(200);
        TableColumn nextSectionColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.NEXTSECTION_COLUMN);
        nextSectionColumn.setResizable(true);
        nextSectionColumn.setMinWidth(120);
        nextSectionColumn.setMaxWidth(200);
        TableColumn allocateButtonColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATEBUTTON_COLUMN);
        allocateButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
        allocateButtonColumn.setMinWidth(110);
        allocateButtonColumn.setMaxWidth(190);
        allocateButtonColumn.setResizable(false);
        ButtonRenderer buttonRenderer = new ButtonRenderer();
        activeTrainsTable.setDefaultRenderer(JButton.class, buttonRenderer);
        JButton sampleButton = new JButton(Bundle.getMessage("AllocateButtonName"));
        activeTrainsTable.setRowHeight(sampleButton.getPreferredSize().height);
        allocateButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
        JScrollPane activeTrainsTableScrollPane = new JScrollPane(activeTrainsTable);
        p12.add(activeTrainsTableScrollPane, BorderLayout.CENTER);
        contentPane.add(p12);
        JPanel p13 = new JPanel();
        p13.setLayout(new FlowLayout());
        p13.add(addTrainButton = new JButton(Bundle.getMessage("InitiateTrain") + "..."));
        addTrainButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!newTrainActive) {
                    atFrame.initiateTrain(e);
                    newTrainActive = true;
                } else {
                    atFrame.showActivateFrame();
                }
            }
        });
        addTrainButton.setToolTipText(Bundle.getMessage("InitiateTrainButtonHint"));
        p13.add(new JLabel("   "));
        p13.add(new JLabel("   "));
        p13.add(allocateExtraButton = new JButton(Bundle.getMessage("AllocateExtra") + "..."));
        allocateExtraButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                allocateExtraSection(e);
            }
        });
        allocateExtraButton.setToolTipText(Bundle.getMessage("AllocateExtraButtonHint"));
        p13.add(new JLabel("   "));
        p13.add(cancelRestartButton = new JButton(Bundle.getMessage("CancelRestart") + "..."));
        cancelRestartButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!newTrainActive) {
                    cancelRestart(e);
                } else if (restartingTrainsList.size() > 0) {
                    atFrame.showActivateFrame();
                    JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message2"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
                } else {
                    atFrame.showActivateFrame();
                }
            }
        });
        cancelRestartButton.setToolTipText(Bundle.getMessage("CancelRestartButtonHint"));
        p13.add(new JLabel("   "));
        p13.add(terminateTrainButton = new JButton(Bundle.getMessage("TerminateTrain") + "..."));
        terminateTrainButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!newTrainActive) {
                    terminateTrain(e);
                } else if (activeTrainsList.size() > 0) {
                    atFrame.showActivateFrame();
                    JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message1"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
                } else {
                    atFrame.showActivateFrame();
                }
            }
        });
        terminateTrainButton.setToolTipText(Bundle.getMessage("TerminateTrainButtonHint"));
        contentPane.add(p13);
        // set up pending allocations table
        contentPane.add(new JSeparator());
        JPanel p21 = new JPanel();
        p21.setLayout(new FlowLayout());
        p21.add(new JLabel(Bundle.getMessage("RequestedAllocationsTableTitle")));
        contentPane.add(p21);
        JPanel p22 = new JPanel();
        p22.setLayout(new FlowLayout());
        allocationRequestTableModel = new AllocationRequestTableModel();
        JTable allocationRequestTable = new JTable(allocationRequestTableModel);
        allocationRequestTable.setRowSelectionAllowed(false);
        allocationRequestTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 100));
        TableColumnModel allocationRequestColumnModel = allocationRequestTable.getColumnModel();
        TableColumn activeColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ACTIVE_COLUMN);
        activeColumn.setResizable(true);
        activeColumn.setMinWidth(210);
        activeColumn.setMaxWidth(260);
        TableColumn priorityColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.PRIORITY_COLUMN);
        priorityColumn.setResizable(true);
        priorityColumn.setMinWidth(40);
        priorityColumn.setMaxWidth(60);
        TableColumn trainTypColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.TRAINTYPE_COLUMN);
        trainTypColumn.setResizable(true);
        trainTypColumn.setMinWidth(130);
        trainTypColumn.setMaxWidth(190);
        TableColumn sectionColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTION_COLUMN);
        sectionColumn.setResizable(true);
        sectionColumn.setMinWidth(140);
        sectionColumn.setMaxWidth(210);
        TableColumn secStatusColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.STATUS_COLUMN);
        secStatusColumn.setResizable(true);
        secStatusColumn.setMinWidth(90);
        secStatusColumn.setMaxWidth(150);
        TableColumn occupancyColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.OCCUPANCY_COLUMN);
        occupancyColumn.setResizable(true);
        occupancyColumn.setMinWidth(80);
        occupancyColumn.setMaxWidth(130);
        TableColumn secLengthColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTIONLENGTH_COLUMN);
        secLengthColumn.setResizable(true);
        secLengthColumn.setMinWidth(40);
        secLengthColumn.setMaxWidth(60);
        TableColumn allocateColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ALLOCATEBUTTON_COLUMN);
        allocateColumn.setCellEditor(new ButtonEditor(new JButton()));
        allocateColumn.setMinWidth(90);
        allocateColumn.setMaxWidth(170);
        allocateColumn.setResizable(false);
        allocationRequestTable.setDefaultRenderer(JButton.class, buttonRenderer);
        sampleButton = new JButton(Bundle.getMessage("AllocateButton"));
        allocationRequestTable.setRowHeight(sampleButton.getPreferredSize().height);
        allocateColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
        TableColumn cancelButtonColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.CANCELBUTTON_COLUMN);
        cancelButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
        cancelButtonColumn.setMinWidth(75);
        cancelButtonColumn.setMaxWidth(170);
        cancelButtonColumn.setResizable(false);
        cancelButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
        JScrollPane allocationRequestTableScrollPane = new JScrollPane(allocationRequestTable);
        p22.add(allocationRequestTableScrollPane, BorderLayout.CENTER);
        contentPane.add(p22);
        // set up allocated sections table
        contentPane.add(new JSeparator());
        JPanel p30 = new JPanel();
        p30.setLayout(new FlowLayout());
        p30.add(new JLabel(Bundle.getMessage("AllocatedSectionsTitle") + "    "));
        autoReleaseBox = new JCheckBox(Bundle.getMessage("AutoReleaseBoxLabel"));
        p30.add(autoReleaseBox);
        autoReleaseBox.setToolTipText(Bundle.getMessage("AutoReleaseBoxHint"));
        autoReleaseBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleAutoReleaseChanged(e);
            }
        });
        // initiallize autoRelease to match autoAllocate
        autoReleaseBox.setSelected(_AutoAllocate);
        autoAllocateBox = new JCheckBox(Bundle.getMessage("AutoDispatchItem"));
        p30.add(autoAllocateBox);
        autoAllocateBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
        autoAllocateBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleAutoAllocateChanged(e);
            }
        });
        contentPane.add(p30);
        autoAllocateBox.setSelected(_AutoAllocate);
        JPanel p31 = new JPanel();
        p31.setLayout(new FlowLayout());
        allocatedSectionTableModel = new AllocatedSectionTableModel();
        JTable allocatedSectionTable = new JTable(allocatedSectionTableModel);
        allocatedSectionTable.setRowSelectionAllowed(false);
        allocatedSectionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(730, 200));
        TableColumnModel allocatedSectionColumnModel = allocatedSectionTable.getColumnModel();
        TableColumn activeAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.ACTIVE_COLUMN);
        activeAColumn.setResizable(true);
        activeAColumn.setMinWidth(250);
        activeAColumn.setMaxWidth(350);
        TableColumn sectionAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.SECTION_COLUMN);
        sectionAColumn.setResizable(true);
        sectionAColumn.setMinWidth(200);
        sectionAColumn.setMaxWidth(350);
        TableColumn occupancyAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.OCCUPANCY_COLUMN);
        occupancyAColumn.setResizable(true);
        occupancyAColumn.setMinWidth(80);
        occupancyAColumn.setMaxWidth(140);
        TableColumn useStatusColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.USESTATUS_COLUMN);
        useStatusColumn.setResizable(true);
        useStatusColumn.setMinWidth(90);
        useStatusColumn.setMaxWidth(150);
        TableColumn releaseColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.RELEASEBUTTON_COLUMN);
        releaseColumn.setCellEditor(new ButtonEditor(new JButton()));
        releaseColumn.setMinWidth(90);
        releaseColumn.setMaxWidth(170);
        releaseColumn.setResizable(false);
        allocatedSectionTable.setDefaultRenderer(JButton.class, buttonRenderer);
        JButton sampleAButton = new JButton(Bundle.getMessage("ReleaseButton"));
        allocatedSectionTable.setRowHeight(sampleAButton.getPreferredSize().height);
        releaseColumn.setPreferredWidth((sampleAButton.getPreferredSize().width) + 2);
        JScrollPane allocatedSectionTableScrollPane = new JScrollPane(allocatedSectionTable);
        p31.add(allocatedSectionTableScrollPane, BorderLayout.CENTER);
        contentPane.add(p31);
    }
    dispatcherFrame.pack();
    dispatcherFrame.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) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) JMenuBar(javax.swing.JMenuBar) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 19 with JMenuBar

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

the class Editor method makeAddIconFrame.

protected JFrameItem makeAddIconFrame(String name, boolean add, boolean table, IconAdder editor) {
    log.debug("makeAddIconFrame for {}, add= {}, table= ", name, add, table);
    String txt;
    String BundleName;
    JFrameItem frame = new JFrameItem(name, editor);
    // use NamedBeanBundle property for basic beans like "Turnout" I18N
    if ("Sensor".equals(name)) {
        BundleName = "BeanNameSensor";
    } else if ("SignalHead".equals(name)) {
        BundleName = "BeanNameSignalHead";
    } else if ("SignalMast".equals(name)) {
        BundleName = "BeanNameSignalMast";
    } else if ("Memory".equals(name)) {
        BundleName = "BeanNameMemory";
    } else if ("Reporter".equals(name)) {
        BundleName = "BeanNameReporter";
    } else if ("Light".equals(name)) {
        BundleName = "BeanNameLight";
    } else if ("Turnout".equals(name)) {
        // called by RightTurnout and LeftTurnout objects in TurnoutIcon.java edit() method
        BundleName = "BeanNameTurnout";
    } else if ("Block".equals(name)) {
        BundleName = "BeanNameBlock";
    } else {
        BundleName = name;
    }
    if (editor != null) {
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        if (add) {
            txt = java.text.MessageFormat.format(Bundle.getMessage("addItemToPanel"), Bundle.getMessage(BundleName));
        } else {
            txt = java.text.MessageFormat.format(Bundle.getMessage("editItemInPanel"), Bundle.getMessage(BundleName));
        }
        p.add(new JLabel(txt));
        if (table) {
            txt = java.text.MessageFormat.format(Bundle.getMessage("TableSelect"), Bundle.getMessage(BundleName), (add ? Bundle.getMessage("ButtonAddIcon") : Bundle.getMessage("ButtonUpdateIcon")));
        } else {
            if ("MultiSensor".equals(name)) {
                txt = java.text.MessageFormat.format(Bundle.getMessage("SelectMultiSensor", Bundle.getMessage("ButtonAddIcon")), (add ? Bundle.getMessage("ButtonAddIcon") : Bundle.getMessage("ButtonUpdateIcon")));
            } else {
                txt = java.text.MessageFormat.format(Bundle.getMessage("IconSelect"), Bundle.getMessage(BundleName), (add ? Bundle.getMessage("ButtonAddIcon") : Bundle.getMessage("ButtonUpdateIcon")));
            }
        }
        p.add(new JLabel(txt));
        // add a bit of space on pane above icons
        p.add(new JLabel("    "));
        frame.getContentPane().add(p, BorderLayout.NORTH);
        frame.getContentPane().add(editor);
        JMenuBar menuBar = new JMenuBar();
        JMenu findIcon = new JMenu(Bundle.getMessage("findIconMenu"));
        menuBar.add(findIcon);
        JMenuItem editItem = new JMenuItem(Bundle.getMessage("editIndexMenu"));
        editItem.addActionListener(new ActionListener() {

            Editor editor;

            @Override
            public void actionPerformed(ActionEvent e) {
                ImageIndexEditor ii = ImageIndexEditor.instance(editor);
                ii.pack();
                ii.setVisible(true);
            }

            ActionListener init(Editor ed) {
                editor = ed;
                return this;
            }
        }.init(this));
        findIcon.add(editItem);
        findIcon.addSeparator();
        JMenuItem searchItem = new JMenuItem(Bundle.getMessage("searchFSMenu"));
        searchItem.addActionListener(new ActionListener() {

            IconAdder ea;

            @Override
            public void actionPerformed(ActionEvent e) {
                jmri.jmrit.catalog.DirectorySearcher.instance().searchFS();
                ea.addDirectoryToCatalog();
            }

            ActionListener init(IconAdder ed) {
                ea = ed;
                return this;
            }
        }.init(editor));
        findIcon.add(searchItem);
        frame.setJMenuBar(menuBar);
        editor.setParent(frame);
        // when this window closes, check for saving
        if (add) {
            frame.addWindowListener(new java.awt.event.WindowAdapter() {

                @Override
                public void windowClosing(java.awt.event.WindowEvent e) {
                    setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                    if (log.isDebugEnabled()) {
                        log.debug("windowClosing: HIDE {}", toString());
                    }
                }
            });
        }
    } else {
        //NOI18N
        log.error("No icon editor specified for {}", name);
    }
    if (add) {
        txt = java.text.MessageFormat.format(Bundle.getMessage("AddItem"), Bundle.getMessage(BundleName));
        _iconEditorFrame.put(name, frame);
    } else {
        txt = java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage(BundleName));
    }
    frame.setTitle(txt + " (" + getTitle() + ")");
    frame.pack();
    return frame;
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) ActionListener(java.awt.event.ActionListener) ImageIndexEditor(jmri.jmrit.catalog.ImageIndexEditor) JMenuItem(javax.swing.JMenuItem) ImageIndexEditor(jmri.jmrit.catalog.ImageIndexEditor) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 20 with JMenuBar

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

the class SwitchboardEditor method init.

/**
     * Initialize the newly created SwitchBoard.
     *
     * @param name name of the switchboard frame
     */
@Override
protected void init(String name) {
    //setVisible(false);
    // Editor
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // make menus
    setGlobalSetsLocalFlag(false);
    setUseGlobalFlag(false);
    _menuBar = new JMenuBar();
    makeOptionMenu();
    //makeEditMenu();
    makeFileMenu();
    setJMenuBar(_menuBar);
    addHelpMenu("package.jmri.jmrit.display.SwitchboardEditor", true);
    //super.setTargetPanel(null, makeFrame(name)); // original CPE version
    //extends JLayeredPane();
    switchboardLayeredPane = new TargetPane();
    switchboardLayeredPane.setPreferredSize(new Dimension(300, 310));
    switchboardLayeredPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(defaultTextColor), Bundle.getMessage("SwitchboardBanner"), TitledBorder.LEADING, TitledBorder.ABOVE_BOTTOM, getFont(), defaultTextColor));
    // create contrast with background, should also specify border style
    // specify title for turnout, sensor, light, mixed? (wait for the Editor to be created)
    switchboardLayeredPane.addMouseMotionListener(this);
    //Add control pane and layered pane to this JPanel
    JPanel beanSetupPane = new JPanel();
    beanSetupPane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    JLabel beanTypeTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanTypeLabel")));
    beanSetupPane.add(beanTypeTitle);
    beanTypeList = new JComboBox(beanTypeStrings);
    // select Turnout in comboBox
    beanTypeList.setSelectedIndex(0);
    beanTypeList.setActionCommand(LAYER_COMMAND);
    beanTypeList.addActionListener(this);
    beanSetupPane.add(beanTypeList);
    //Add connection selection comboBox
    // translate from selectedIndex to char
    beanTypeChar = getSwitchType().charAt(0);
    log.debug("beanTypeChar set to [{}]", beanTypeChar);
    JLabel beanManuTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("ConnectionLabel")));
    beanSetupPane.add(beanManuTitle);
    beanManuNames = new JComboBox();
    if (getManager(beanTypeChar) instanceof jmri.managers.AbstractProxyManager) {
        // from abstractTableTabAction
        jmri.managers.AbstractProxyManager proxy = (jmri.managers.AbstractProxyManager) getManager(beanTypeChar);
        List<jmri.Manager> managerList = proxy.getManagerList();
        for (int x = 0; x < managerList.size(); x++) {
            String manuPrefix = managerList.get(x).getSystemPrefix();
            log.debug("Prefix = [{}]", manuPrefix);
            String manuName = ConnectionNameFromSystemName.getConnectionName(manuPrefix);
            log.debug("Connection name = [{}]", manuName);
            // add to comboBox
            beanManuNames.addItem(manuName);
            // add to list
            beanManuPrefixes.add(manuPrefix);
        }
    } else {
        String manuPrefix = getManager(beanTypeChar).getSystemPrefix();
        String manuName = ConnectionNameFromSystemName.getConnectionName(manuPrefix);
        beanManuNames.addItem(manuName);
        // add to list (as only item)
        beanManuPrefixes.add(manuPrefix);
    }
    beanManuNames.setSelectedIndex(0);
    beanManuNames.setActionCommand(MANU_COMMAND);
    beanManuNames.addActionListener(this);
    beanSetupPane.add(beanManuNames);
    add(beanSetupPane);
    // add shape combobox
    JPanel switchShapePane = new JPanel();
    switchShapePane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    JLabel switchShapeTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("SwitchShape")));
    switchShapePane.add(switchShapeTitle);
    switchShapeList = new JComboBox(switchShapeStrings);
    // select Button in comboBox
    switchShapeList.setSelectedIndex(0);
    switchShapeList.setActionCommand(SWITCHTYPE_COMMAND);
    switchShapeList.addActionListener(this);
    switchShapePane.add(switchShapeList);
    // add column spinner
    JLabel columnLabel = new JLabel(Bundle.getMessage("NumberOfColumns"));
    switchShapePane.add(columnLabel);
    switchShapePane.add(Columns);
    add(switchShapePane);
    JCheckBox hideUnconnected = new JCheckBox(Bundle.getMessage("CheckBoxHideUnconnected"));
    hideUnconnected.setSelected(hideUnconnected());
    hideUnconnected.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setHideUnconnected(hideUnconnected.isSelected());
        }
    });
    add(hideUnconnected);
    // Next, add the buttons to the layered pane.
    switchboardLayeredPane.setLayout(new GridLayout(java.lang.Math.max(2, _range % ((Integer) Columns.getValue())), (Integer) Columns.getValue()));
    // vertical (at least 2 rows), horizontal
    // TODO do some calculation from JPanel size, icon size and determine optimal cols/rows
    addSwitchRange((Integer) minSpinner.getValue(), (Integer) maxSpinner.getValue(), beanTypeList.getSelectedIndex(), beanManuPrefixes.get(beanManuNames.getSelectedIndex()), switchShapeList.getSelectedIndex());
    // provide a JLayeredPane to place the switches on
    super.setTargetPanel(switchboardLayeredPane, makeFrame(name));
    // width x height
    super.getTargetFrame().setSize(550, 330);
    // To do: Add component listener to handle frame resizing event
    // set scrollbar initial state
    setScroll(SCROLL_NONE);
    scrollNone.setSelected(true);
    super.setDefaultToolTip(new ToolTip(null, 0, 0, new Font("Serif", Font.PLAIN, 12), Color.black, new Color(255, 250, 210), Color.black));
    // register the resulting panel for later configuration
    ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.registerUser(this);
    }
    add(createControlPanel());
    JPanel updatePanel = new JPanel();
    JButton updateButton = new JButton(Bundle.getMessage("ButtonUpdate"));
    updateButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            log.debug("Update clicked");
            updatePressed();
        }
    });
    updatePanel.add(updateButton);
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    contentPane.add(updatePanel);
    //re-layout all the toolbar items
    setupToolBar();
    // refresh default Switchboard
    updatePressed();
    pack();
    setVisible(true);
// TODO choose your own icons
//        class makeCatalog extends SwingWorker<CatalogPanel, Object> {
//
//            @Override
//            public CatalogPanel doInBackground() {
//                return CatalogPanel.makeDefaultCatalog();
//            }
//        }
//        (new makeCatalog()).execute();
//        log.debug("Init SwingWorker launched");
}
Also used : ToolTip(jmri.jmrit.display.ToolTip) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) InstanceManager(jmri.InstanceManager) ConfigureManager(jmri.ConfigureManager) Manager(jmri.Manager) Font(java.awt.Font) Container(java.awt.Container) GridLayout(java.awt.GridLayout) ConfigureManager(jmri.ConfigureManager) JComboBox(javax.swing.JComboBox) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JMenuBar(javax.swing.JMenuBar)

Aggregations

JMenuBar (javax.swing.JMenuBar)119 JMenu (javax.swing.JMenu)83 JMenuItem (javax.swing.JMenuItem)45 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)28 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JScrollPane (javax.swing.JScrollPane)15 JLabel (javax.swing.JLabel)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)11 BorderLayout (java.awt.BorderLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 JPopupMenu (javax.swing.JPopupMenu)6