Changeset 2132 in josm for trunk/src/org


Ignore:
Timestamp:
2009-09-14T21:00:54+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3478: Remember size of download dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/DownloadAction.java

    r2017 r2132  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.GridBagLayout;
     6import java.awt.BorderLayout;
     7import java.awt.Dimension;
    78import java.awt.event.ActionEvent;
    89import java.awt.event.KeyEvent;
    910
    10 import javax.swing.JDialog;
    1111import javax.swing.JOptionPane;
    1212import javax.swing.JPanel;
    1313
    1414import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.gui.ExtendedDialog;
    1516import org.openstreetmap.josm.gui.download.DownloadDialog;
    1617import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
    17 import org.openstreetmap.josm.tools.GBC;
    1818import org.openstreetmap.josm.tools.Shortcut;
     19import org.openstreetmap.josm.tools.WindowGeometry;
    1920
    2021/**
     
    3536    }
    3637
     38    /**
     39     * Creates the download dialog
     40     * @return the downlaod dialog
     41     */
     42    protected ExtendedDialog createUploadDialog() {
     43        dialog = new DownloadDialog();
     44        JPanel downPanel = new JPanel(new BorderLayout());
     45        downPanel.add(dialog, BorderLayout.CENTER);
     46
     47        final String prefName = dialog.getClass().getName()+ ".geometry";
     48        ExtendedDialog dialog = new ExtendedDialog(Main.parent, tr("Download"), new String[] {tr("OK"), tr("Cancel")}) {
     49            @Override
     50            public void setVisible(boolean visible) {
     51                if (visible) {
     52                    new WindowGeometry(
     53                            prefName,
     54                            WindowGeometry.centerInWindow(Main.parent, new Dimension(1000,600))
     55                    ).apply(this);
     56                } else {
     57                    new WindowGeometry(this).remember(prefName);
     58                }
     59                super.setVisible(visible);
     60            }
     61        };
     62        dialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */);
     63        dialog.setButtonIcons(new String[] {"ok", "cancel"});
     64        return dialog;
     65    }
     66
    3767    public void actionPerformed(ActionEvent e) {
    38         dialog = new DownloadDialog();
    39 
    40         JPanel downPanel = new JPanel(new GridBagLayout());
    41         downPanel.add(dialog, GBC.eol().fill(GBC.BOTH));
    42 
    43         JOptionPane pane = new JOptionPane(downPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    44         JDialog dlg = pane.createDialog(Main.parent, tr("Download"));
    45         dlg.setResizable(true);
    46         dialog.setOptionPane(pane);
    47 
    48         if (dlg.getWidth() > 1000) {
    49             dlg.setSize(1000, dlg.getHeight());
    50         }
    51         if (dlg.getHeight() > 600) {
    52             dlg.setSize(dlg.getWidth(),600);
    53         }
    54 
     68        ExtendedDialog dlg = createUploadDialog();
    5569        boolean finish = false;
    5670        while (!finish) {
    57             dlg.setVisible(true);
     71            dlg.showDialog();
    5872            Main.pref.put("download.newlayer", dialog.newLayer.isSelected());
    59             if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION) {
     73            if (dlg.getValue() == 1 /* OK */) {
    6074                Main.pref.put("download.tab", Integer.toString(dialog.getSelectedTab()));
    6175                for (DownloadTask task : dialog.downloadTasks) {
Note: See TracChangeset for help on using the changeset viewer.