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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations