use of jmri.util.com.sun.TransferActionListener in project JMRI by JMRI.
the class TableFrames method initComponents.
@Override
public void initComponents() {
setTitle(Bundle.getMessage("TitleOBlocks"));
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
fileMenu.add(new jmri.configurexml.SaveMenu());
JMenuItem printItem = new JMenuItem(Bundle.getMessage("PrintOBlockTable"));
fileMenu.add(printItem);
printItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
// MessageFormat headerFormat = new MessageFormat(getTitle()); // not used below
MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
_oBlockTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
} catch (java.awt.print.PrinterException e1) {
log.warn("error printing: " + e1, e1);
}
}
});
printItem = new JMenuItem(Bundle.getMessage("PrintPortalTable"));
fileMenu.add(printItem);
printItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
// MessageFormat headerFormat = new MessageFormat(getTitle()); // not used below
MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
_portalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
} catch (java.awt.print.PrinterException e1) {
log.warn("error printing: " + e1, e1);
}
}
});
printItem = new JMenuItem(Bundle.getMessage("PrintSignalTable"));
fileMenu.add(printItem);
printItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
// MessageFormat headerFormat = new MessageFormat(getTitle()); // not used below
MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
_signalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
} catch (java.awt.print.PrinterException e1) {
log.warn("error printing: " + e1, e1);
}
}
});
printItem = new JMenuItem(Bundle.getMessage("PrintXRef"));
fileMenu.add(printItem);
printItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
// MessageFormat headerFormat = new MessageFormat(getTitle()); // not used below
MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
_blockPortalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
} catch (java.awt.print.PrinterException e1) {
log.warn("error printing: " + e1, e1);
}
}
});
menuBar.add(fileMenu);
JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
editMenu.setMnemonic(KeyEvent.VK_E);
TransferActionListener actionListener = new TransferActionListener();
JMenuItem menuItem = new JMenuItem(Bundle.getMessage("MenuItemCut"));
menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME));
menuItem.addActionListener(actionListener);
if (SystemType.isMacOSX()) {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.META_MASK));
} else {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
}
menuItem.setMnemonic(KeyEvent.VK_T);
editMenu.add(menuItem);
menuItem = new JMenuItem(Bundle.getMessage("MenuItemCopy"));
menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
menuItem.addActionListener(actionListener);
if (SystemType.isMacOSX()) {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.META_MASK));
} else {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
}
menuItem.setMnemonic(KeyEvent.VK_C);
editMenu.add(menuItem);
menuItem = new JMenuItem(Bundle.getMessage("MenuItemPaste"));
menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME));
menuItem.addActionListener(actionListener);
if (SystemType.isMacOSX()) {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.META_MASK));
} else {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
}
menuItem.setMnemonic(KeyEvent.VK_P);
editMenu.add(menuItem);
menuBar.add(editMenu);
JMenu optionMenu = new JMenu(Bundle.getMessage("MenuOptions"));
_showWarnItem = new JMenuItem(Bundle.getMessage("SuppressWarning"));
_showWarnItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
String cmd = event.getActionCommand();
setShowWarnings(cmd);
}
});
optionMenu.add(_showWarnItem);
setShowWarnings("ShowWarning");
menuBar.add(optionMenu);
_openMenu = new JMenu(Bundle.getMessage("OpenMenu"));
// replaces the last item with appropriate
updateOpenMenu();
menuBar.add(_openMenu);
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.logix.OBlockTable", true);
_desktop = new JDesktopPane();
_desktop.putClientProperty("JDesktopPane.dragMode", "outline");
_desktop.setPreferredSize(new Dimension(1100, 550));
setContentPane(_desktop);
_blockTableFrame = makeBlockFrame();
_blockTableFrame.setVisible(true);
_desktop.add(_blockTableFrame);
_portalTableFrame = makePortalFrame();
_portalTableFrame.setVisible(true);
_desktop.add(_portalTableFrame);
_signalTableFrame = makeSignalFrame();
_signalTableFrame.setVisible(true);
_desktop.add(_signalTableFrame);
_blockPortalXRefFrame = makeBlockPortalFrame();
_blockPortalXRefFrame.setVisible(false);
_desktop.add(_blockPortalXRefFrame);
setLocation(10, 30);
setVisible(true);
pack();
errorCheck();
}
Aggregations