use of javax.swing.AbstractAction in project JMRI by JMRI.
the class LayoutTurntable method showPopUp.
/**
* Display popup menu for information and editing
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
JMenuItem jmi = popup.add(rb.getString("Turntable"));
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editTurntable(instance);
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeTurntable(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class TrackSegment method showPopUp.
/**
* Display popup menu for information and editing.
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
String info = rb.getString("TrackSegment");
if (getArc()) {
if (getCircle()) {
info = info + " (" + Bundle.getMessage("Circle") + ")";
} else {
info = info + " (" + Bundle.getMessage("Ellipse") + ")";
}
} else if (getBezier()) {
info = info + " (" + Bundle.getMessage("Bezier") + ")";
} else {
info = info + " (" + Bundle.getMessage("Line") + ")";
}
JMenuItem jmi = popup.add(info);
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
if (!dashed) {
jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Solid"));
} else {
jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Dashed"));
}
jmi.setEnabled(false);
if (!mainline) {
jmi = popup.add(rb.getString("NotMainline"));
} else {
jmi = popup.add(rb.getString("Mainline"));
}
jmi.setEnabled(false);
if (blockName.equals("")) {
jmi = popup.add(rb.getString("NoBlock"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
}
jmi.setEnabled(false);
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editTrackSegment();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
layoutEditor.removeTrackSegment(instance);
remove();
dispose();
}
});
JMenu lineType = new JMenu(rb.getString("ChangeTo"));
lineType.add(new AbstractAction(Bundle.getMessage("Line")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(0);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Circle")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(1);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Ellipse")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(2);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Bezier")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(3);
}
});
popup.add(lineType);
if (getArc()) {
popup.add(new AbstractAction(rb.getString("FlipAngle")) {
@Override
public void actionPerformed(ActionEvent e) {
flipAngle();
}
});
}
if (getArc() || getBezier()) {
if (hideConstructionLines()) {
popup.add(new AbstractAction(rb.getString("ShowConstruct")) {
@Override
public void actionPerformed(ActionEvent e) {
hideConstructionLines(SHOWCON);
}
});
} else {
popup.add(new AbstractAction(rb.getString("HideConstruct")) {
@Override
public void actionPerformed(ActionEvent e) {
hideConstructionLines(HIDECON);
}
});
}
}
if ((!blockName.equals("")) && (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled())) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
}
popup.show(e.getComponent(), e.getX(), e.getY());
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class UserInterface method buildMenu.
protected void buildMenu() {
this.setJMenuBar(new JMenuBar());
JMenu menu = new JMenu(rb.getString("MenuMenu"));
serverOnOff = new JMenuItem(rb.getString("MenuMenuStop"));
serverOnOff.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
if (isListen) {
// Stop server
disableServer();
serverOnOff.setText(rb.getString("MenuMenuStart"));
portLabel.setText(rb.getString("LabelNone"));
manualPortLabel.setText(null);
} else {
// Restart server
serverOnOff.setText(rb.getString("MenuMenuStop"));
isListen = true;
createServerThread();
}
}
});
menu.add(serverOnOff);
menu.add(new ControllerFilterAction());
Action prefsAction = new apps.gui3.TabbedPreferencesAction(ResourceBundle.getBundle("apps.AppsBundle").getString("MenuItemPreferences"), "WITHROTTLE");
menu.add(prefsAction);
this.getJMenuBar().add(menu);
// add help menu
addHelpMenu("package.jmri.jmrit.withrottle.UserInterface", true);
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class Apps method fileMenu.
/**
* Create default File menu
*
* @param menuBar Menu bar to be populated
* @param wi WindowInterface where this menu will appear as part of the
* menu bar
*/
protected void fileMenu(JMenuBar menuBar, WindowInterface wi) {
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(fileMenu);
fileMenu.add(new PrintDecoderListAction(Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false));
fileMenu.add(new PrintDecoderListAction(Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true));
// Use Mac OS X native Quit if using Aqua look and feel
if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) {
fileMenu.add(new JSeparator());
fileMenu.add(new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
@Override
public void actionPerformed(ActionEvent e) {
handleQuit();
}
});
}
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class SignalPro method statusPanel.
@Override
protected JPanel statusPanel() {
JPanel j = new JPanel();
j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
j.add(super.statusPanel());
// Buttons
Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
@Override
public void actionPerformed(ActionEvent e) {
Apps.handleQuit();
}
};
JPanel p3 = new JPanel();
p3.setLayout(new java.awt.FlowLayout());
JButton h1 = new JButton(Bundle.getMessage("ButtonHelp"));
jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.SignalPro.SignalPro");
h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(h1);
JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
q1.addActionListener(quit);
q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(q1);
j.add(p3);
return j;
}
Aggregations