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