Search in sources :

Example 6 with JInternalFrame

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

the class TableFrames method makeSignalFrame.

/*
     * ********************* SignalFrame *****************************
     */
protected JInternalFrame makeSignalFrame() {
    JInternalFrame frame = new JInternalFrame(Bundle.getMessage("TitleSignalTable"), true, false, false, true);
    _signalModel = new SignalTableModel(this);
    _signalModel.init();
    _signalTable = new JTable(_signalModel);
    TableRowSorter<SignalTableModel> sorter = new TableRowSorter<>(_signalModel);
    _signalTable.setRowSorter(sorter);
    _signalTable.setTransferHandler(new jmri.util.DnDTableImportExportHandler(new int[] { SignalTableModel.UNITSCOL, SignalTableModel.DELETE_COL }));
    _signalTable.setDragEnabled(true);
    _signalTable.getColumnModel().getColumn(SignalTableModel.UNITSCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("cm"), Bundle.getMessage("in")));
    _signalTable.getColumnModel().getColumn(SignalTableModel.DELETE_COL).setCellEditor(new ButtonEditor(new JButton()));
    _signalTable.getColumnModel().getColumn(SignalTableModel.DELETE_COL).setCellRenderer(new ButtonRenderer());
    for (int i = 0; i < _signalModel.getColumnCount(); i++) {
        int width = SignalTableModel.getPreferredWidth(i);
        _signalTable.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
    _signalTable.sizeColumnsToFit(-1);
    int tableWidth = _signalTable.getPreferredSize().width;
    _signalTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 8));
    _signalTablePane = new JScrollPane(_signalTable);
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(5, 5));
    JLabel prompt = new JLabel(Bundle.getMessage("AddSignalPrompt"));
    contentPane.add(prompt, BorderLayout.NORTH);
    contentPane.add(_signalTablePane, BorderLayout.CENTER);
    frame.setContentPane(contentPane);
    frame.setLocation(200, 350);
    frame.pack();
    return frame;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Point(java.awt.Point) Dimension(java.awt.Dimension) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) JInternalFrame(javax.swing.JInternalFrame) TableRowSorter(javax.swing.table.TableRowSorter) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 7 with JInternalFrame

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

the class TableFrames method makeBlockFrame.

/*
     * ********************* BlockFrame *****************************
     */
protected JInternalFrame makeBlockFrame() {
    JInternalFrame frame = new JInternalFrame(Bundle.getMessage("TitleBlockTable"), true, false, false, true);
    _oBlockModel = new OBlockTableModel(this);
    _oBlockTable = new JTable(_oBlockModel);
    TableRowSorter<OBlockTableModel> sorter = new TableRowSorter<>(_oBlockModel);
    sorter.setComparator(OBlockTableModel.SYSNAMECOL, new jmri.util.SystemNameComparator());
    _oBlockTable.setRowSorter(sorter);
    _oBlockTable.setTransferHandler(new jmri.util.DnDTableImportExportHandler(new int[] { OBlockTableModel.EDIT_COL, OBlockTableModel.DELETE_COL, OBlockTableModel.REPORT_CURRENTCOL, OBlockTableModel.SPEEDCOL, OBlockTableModel.PERMISSIONCOL, OBlockTableModel.UNITSCOL }));
    _oBlockTable.setDragEnabled(true);
    // Use XTableColumnModel so we can control which columns are visible
    XTableColumnModel tcm = new XTableColumnModel();
    _oBlockTable.setColumnModel(tcm);
    _oBlockTable.getTableHeader().setReorderingAllowed(true);
    _oBlockTable.createDefaultColumnsFromModel();
    _oBlockModel.addHeaderListener(_oBlockTable);
    _oBlockTable.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.EDIT_COL).setCellEditor(new ButtonEditor(new JButton()));
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.EDIT_COL).setCellRenderer(new ButtonRenderer());
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.DELETE_COL).setCellEditor(new ButtonEditor(new JButton()));
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.DELETE_COL).setCellRenderer(new ButtonRenderer());
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.UNITSCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("cm"), Bundle.getMessage("in")));
    JComboBox<String> box = new JComboBox<String>(OBlockTableModel.curveOptions);
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.CURVECOL).setCellEditor(new DefaultCellEditor(box));
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.REPORT_CURRENTCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("Current"), Bundle.getMessage("Last")));
    box = new JComboBox<String>(jmri.InstanceManager.getDefault(SignalSpeedMap.class).getValidSpeedNames());
    box.addItem("");
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.SPEEDCOL).setCellEditor(new DefaultCellEditor(box));
    _oBlockTable.getColumnModel().getColumn(OBlockTableModel.PERMISSIONCOL).setCellRenderer(new MyBooleanRenderer(Bundle.getMessage("Permissive"), Bundle.getMessage("Absolute")));
    _oBlockTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent me) {
            showPopup(me);
        }

        @Override
        public void mouseReleased(MouseEvent me) {
            showPopup(me);
        }
    });
    for (int i = 0; i < _oBlockModel.getColumnCount(); i++) {
        int width = _oBlockModel.getPreferredWidth(i);
        _oBlockTable.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
    _oBlockTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    ROW_HEIGHT = _oBlockTable.getRowHeight();
    int tableWidth = _desktop.getPreferredSize().width;
    _oBlockTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 10));
    _blockTablePane = new JScrollPane(_oBlockTable);
    tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.REPORTERCOL), false);
    tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.REPORT_CURRENTCOL), false);
    tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.PERMISSIONCOL), false);
    //        tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.SPEEDCOL), false);
    //        tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.ERR_SENSORCOL), false);
    tcm.setColumnVisible(tcm.getColumnByModelIndex(OBlockTableModel.CURVECOL), false);
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(5, 5));
    JLabel prompt = new JLabel(Bundle.getMessage("AddBlockPrompt"));
    contentPane.add(prompt, BorderLayout.NORTH);
    contentPane.add(_blockTablePane, BorderLayout.CENTER);
    frame.setContentPane(contentPane);
    frame.pack();
    return frame;
}
Also used : JPanel(javax.swing.JPanel) ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) SignalSpeedMap(jmri.implementation.SignalSpeedMap) BorderLayout(java.awt.BorderLayout) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) XTableColumnModel(jmri.util.swing.XTableColumnModel) Point(java.awt.Point) DefaultCellEditor(javax.swing.DefaultCellEditor) Dimension(java.awt.Dimension) JTable(javax.swing.JTable) JInternalFrame(javax.swing.JInternalFrame) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 8 with JInternalFrame

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

the class TableFrames method makeBlockPortalFrame.

/*
     * ********************* BlockPortalFrame *****************************
     */
protected JInternalFrame makeBlockPortalFrame() {
    JInternalFrame frame = new JInternalFrame(Bundle.getMessage("TitleBlockPortalXRef"), true, false, false, true);
    _blockPortalXRefModel = new BlockPortalTableModel(_oBlockModel);
    _blockPortalTable = new JTable(_blockPortalXRefModel);
    _blockPortalTable.setTransferHandler(new jmri.util.DnDTableExportHandler());
    _blockPortalTable.setDragEnabled(true);
    _blockPortalTable.setDefaultRenderer(String.class, new jmri.jmrit.symbolicprog.ValueRenderer());
    _blockPortalTable.setDefaultEditor(String.class, new jmri.jmrit.symbolicprog.ValueEditor());
    for (int i = 0; i < _blockPortalXRefModel.getColumnCount(); i++) {
        int width = _blockPortalXRefModel.getPreferredWidth(i);
        _blockPortalTable.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
    _blockPortalTable.sizeColumnsToFit(-1);
    int tableWidth = _blockPortalTable.getPreferredSize().width;
    _blockPortalTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 25));
    JScrollPane tablePane = new JScrollPane(_blockPortalTable);
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(5, 5));
    contentPane.add(tablePane, BorderLayout.CENTER);
    frame.addInternalFrameListener(this);
    frame.setContentPane(contentPane);
    frame.setLocation(700, 30);
    frame.pack();
    return frame;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Point(java.awt.Point) Dimension(java.awt.Dimension) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) JInternalFrame(javax.swing.JInternalFrame)

Example 9 with JInternalFrame

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

the class TableFrames method makePortalFrame.

/*
     * ********************* PortalFrame *****************************
     */
protected JInternalFrame makePortalFrame() {
    JInternalFrame frame = new JInternalFrame(Bundle.getMessage("TitlePortalTable"), true, false, false, true);
    _portalModel = new PortalTableModel(this);
    _portalTable = new JTable(_portalModel);
    TableRowSorter<PortalTableModel> sorter = new TableRowSorter<>(_portalModel);
    sorter.setComparator(PortalTableModel.FROM_BLOCK_COLUMN, new jmri.util.SystemNameComparator());
    sorter.setComparator(PortalTableModel.TO_BLOCK_COLUMN, new jmri.util.SystemNameComparator());
    _portalTable.setRowSorter(sorter);
    _portalTable.setTransferHandler(new jmri.util.DnDTableImportExportHandler(new int[] { PortalTableModel.DELETE_COL }));
    _portalTable.setDragEnabled(true);
    _portalTable.getColumnModel().getColumn(PortalTableModel.DELETE_COL).setCellEditor(new ButtonEditor(new JButton()));
    _portalTable.getColumnModel().getColumn(PortalTableModel.DELETE_COL).setCellRenderer(new ButtonRenderer());
    for (int i = 0; i < _portalModel.getColumnCount(); i++) {
        int width = _portalModel.getPreferredWidth(i);
        _portalTable.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
    _portalTable.sizeColumnsToFit(-1);
    int tableWidth = _portalTable.getPreferredSize().width;
    _portalTable.setPreferredScrollableViewportSize(new java.awt.Dimension(tableWidth, ROW_HEIGHT * 10));
    _portalTablePane = new JScrollPane(_portalTable);
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(5, 5));
    JLabel prompt = new JLabel(Bundle.getMessage("AddPortalPrompt"));
    contentPane.add(prompt, BorderLayout.NORTH);
    contentPane.add(_portalTablePane, BorderLayout.CENTER);
    frame.setContentPane(contentPane);
    frame.setLocation(0, 200);
    frame.pack();
    return frame;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Point(java.awt.Point) Dimension(java.awt.Dimension) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) JInternalFrame(javax.swing.JInternalFrame) TableRowSorter(javax.swing.table.TableRowSorter) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 10 with JInternalFrame

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

the class ThrottleFrame method ynstrument.

// #JYNSTRUMENT# here instantiate the Jynstrument, put it in a component, initialize the context and start it
public JInternalFrame ynstrument(String path) {
    if (path == null) {
        return null;
    }
    // everything is there
    Jynstrument it = JynstrumentFactory.createInstrument(path, this);
    if (it == null) {
        log.error("Error while creating Jynstrument " + path);
        return null;
    }
    setTransparentBackground(it);
    JInternalFrame newiFrame = new JInternalFrame(it.getClassName());
    newiFrame.add(it);
    newiFrame.addInternalFrameListener(frameListener);
    newiFrame.setDoubleBuffered(true);
    newiFrame.setResizable(true);
    newiFrame.setClosable(true);
    newiFrame.setIconifiable(true);
    newiFrame.getContentPane().addContainerListener(new ContainerListener() {

        @Override
        public void componentAdded(ContainerEvent e) {
        }

        @Override
        public void componentRemoved(ContainerEvent e) {
            Container c = e.getContainer();
            while ((!(c instanceof JInternalFrame)) && (!(c instanceof TranslucentJPanel))) {
                c = c.getParent();
            }
            c.setVisible(false);
            remove(c);
            repaint();
        }
    });
    newiFrame.pack();
    add(newiFrame, PANEL_LAYER_FRAME);
    newiFrame.setVisible(true);
    return newiFrame;
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) Jynstrument(jmri.jmrit.jython.Jynstrument) Container(java.awt.Container) ContainerListener(java.awt.event.ContainerListener) JInternalFrame(javax.swing.JInternalFrame)

Aggregations

JInternalFrame (javax.swing.JInternalFrame)36 Point (java.awt.Point)12 PropertyVetoException (java.beans.PropertyVetoException)12 Dimension (java.awt.Dimension)9 Component (java.awt.Component)7 JPanel (javax.swing.JPanel)7 JScrollPane (javax.swing.JScrollPane)7 JTable (javax.swing.JTable)7 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 JLabel (javax.swing.JLabel)6 JComponent (javax.swing.JComponent)5 JMenu (javax.swing.JMenu)4 Jynstrument (jmri.jmrit.jython.Jynstrument)4 Container (java.awt.Container)3 JDesktopPane (javax.swing.JDesktopPane)3 JMenuBar (javax.swing.JMenuBar)3 JMenuItem (javax.swing.JMenuItem)3 TableRowSorter (javax.swing.table.TableRowSorter)3 ButtonEditor (jmri.util.table.ButtonEditor)3