| 1 | package org.openstreetmap.josm.actions;
|
|---|
| 2 |
|
|---|
| 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 4 |
|
|---|
| 5 | import java.awt.GridBagLayout;
|
|---|
| 6 | import java.awt.event.ActionEvent;
|
|---|
| 7 | import java.awt.event.KeyEvent;
|
|---|
| 8 |
|
|---|
| 9 | import javax.swing.JDialog;
|
|---|
| 10 | import javax.swing.JOptionPane;
|
|---|
| 11 | import javax.swing.JPanel;
|
|---|
| 12 |
|
|---|
| 13 | import org.openstreetmap.josm.Main;
|
|---|
| 14 | import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
|
|---|
| 15 | import org.openstreetmap.josm.tools.GBC;
|
|---|
| 16 |
|
|---|
| 17 | /**
|
|---|
| 18 | * Open the Preferences dialog.
|
|---|
| 19 | *
|
|---|
| 20 | * @author imi
|
|---|
| 21 | */
|
|---|
| 22 | public class PreferencesAction extends JosmAction {
|
|---|
| 23 |
|
|---|
| 24 | /**
|
|---|
| 25 | * Create the preference action with "&Preferences" as label.
|
|---|
| 26 | */
|
|---|
| 27 | public PreferencesAction() {
|
|---|
| 28 | super(tr("Preferences"), "preference", tr("Open a preferences page for global settings."), KeyEvent.VK_F12, 0);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * Launch the preferences dialog.
|
|---|
| 33 | */
|
|---|
| 34 | public void actionPerformed(ActionEvent e) {
|
|---|
| 35 | PreferenceDialog prefDlg = new PreferenceDialog();
|
|---|
| 36 | JPanel prefPanel = new JPanel(new GridBagLayout());
|
|---|
| 37 | prefPanel.add(prefDlg, GBC.eol().fill(GBC.BOTH));
|
|---|
| 38 |
|
|---|
| 39 | JOptionPane pane = new JOptionPane(prefPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
|
|---|
| 40 | JDialog dlg = pane.createDialog(Main.parent, tr("Preferences"));
|
|---|
| 41 | dlg.setVisible(true);
|
|---|
| 42 | if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION)
|
|---|
| 43 | prefDlg.ok();
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|