Changeset 2748 in josm for trunk/src/org/openstreetmap/josm/actions/PreferencesAction.java
- Timestamp:
- 06.01.2010 20:35:56 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/PreferencesAction.java
r2323 r2748 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 import java.awt.Dimension;8 import java.awt.GridBagLayout;9 7 import java.awt.event.ActionEvent; 10 8 import java.awt.event.KeyEvent; 11 9 12 import javax.swing.JDialog;13 import javax.swing.JOptionPane;14 import javax.swing.JPanel;15 16 10 import org.openstreetmap.josm.Main; 17 11 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 18 import org.openstreetmap.josm.tools.GBC;19 12 import org.openstreetmap.josm.tools.Shortcut; 20 13 … … 30 23 */ 31 24 public PreferencesAction() { 32 super(tr("Preferences..."), "preference", tr("Open a preferences pagefor global settings."),33 Shortcut.registerShortcut("system:preferences", tr("Preferences"), KeyEvent.VK_F12, Shortcut.GROUP_DIRECT), true);25 super(tr("Preferences..."), "preference", tr("Open a preferences dialog for global settings."), 26 Shortcut.registerShortcut("system:preferences", tr("Preferences"), KeyEvent.VK_F12, Shortcut.GROUP_DIRECT), true); 34 27 putValue("help", ht("/Action/Preferences")); 35 28 } … … 43 36 44 37 public void run() { 45 PreferenceDialog prefDlg = new PreferenceDialog(); 46 prefDlg.setMinimumSize(new Dimension(400,300)); 47 JPanel prefPanel = new JPanel(new GridBagLayout()); 48 prefPanel.add(prefDlg, GBC.eol().fill(GBC.BOTH)); 49 50 JOptionPane pane = new JOptionPane(prefPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); 51 JDialog dlg = pane.createDialog(Main.parent, tr("Preferences")); 52 dlg.setResizable(true); 53 dlg.setMinimumSize(new Dimension(500,400)); 54 55 // if (dlg.getWidth() > 600) 56 // dlg.setSize(600, dlg.getHeight()); 57 // if (dlg.getHeight() > 600) 58 // dlg.setSize(dlg.getWidth(),600); 59 60 int JOSMWidth = Main.parent.getWidth(); 61 int JOSMHeight = Main.parent.getHeight(); 62 63 if (JOSMWidth > 2000 && JOSMWidth > JOSMHeight * 2) 64 // don't center on horizontal span monitor configurations (yes, can be selfish sometimes) 65 JOSMWidth /= 2; 66 67 int targetWidth = JOSMWidth / 2; 68 if (targetWidth < 600) targetWidth = 600; 69 if (targetWidth > 1200) targetWidth = 1200; 70 int targetHeight = (JOSMHeight * 3) / 4; 71 if (targetHeight < 600) targetHeight = 600; 72 if (targetHeight > 1200) targetHeight = 1200; 73 74 int targetX = Main.parent.getX() + JOSMWidth / 2 - targetWidth / 2; 75 int targetY = Main.parent.getY() + JOSMHeight / 2 - targetHeight / 2; 76 77 dlg.setBounds(targetX, targetY, targetWidth, targetHeight); 78 79 dlg.setModal(true); 80 dlg.setVisible(true); 81 if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION) 82 prefDlg.ok(); 83 dlg.dispose(); 38 new PreferenceDialog(Main.parent).setVisible(true); 84 39 } 85 40 }
Note: See TracChangeset
for help on using the changeset viewer.
