Changeset 17709 in josm for trunk/src


Ignore:
Timestamp:
2021-04-07T21:20:49+02:00 (4 years ago)
Author:
simon04
Message:

fix #20708 - Re-organize the upload dialog

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r17475 r17709  
    1919
    2020import javax.swing.BorderFactory;
    21 import javax.swing.BoxLayout;
    2221import javax.swing.JCheckBox;
    2322import javax.swing.JEditorPane;
     
    208207
    209208    protected void build() {
    210         setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
     209        setLayout(new GridBagLayout());
    211210        setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    212         add(buildUploadCommentPanel());
    213         add(buildUploadSourcePanel());
    214         add(pnlUploadParameterSummary);
     211        GBC gbc = GBC.eol().insets(0, 0, 0, 20).fill(GBC.HORIZONTAL);
     212        add(buildUploadCommentPanel(), gbc);
     213        add(buildUploadSourcePanel(), gbc);
     214        add(pnlUploadParameterSummary, gbc);
    215215        if (Config.getPref().getBoolean("upload.show.review.request", true)) {
    216             JPanel pnl = new JPanel(new GridBagLayout());
    217             pnl.add(cbRequestReview, GBC.eol().fill(GBC.HORIZONTAL));
    218             add(pnl);
     216            add(cbRequestReview, gbc);
    219217            cbRequestReview.addItemListener(e -> changesetReviewModel.setReviewRequested(e.getStateChange() == ItemEvent.SELECTED));
    220218        }
    221         JPanel pnl = new JPanel(new GridBagLayout());
    222         pnl.add(areaValidatorFeedback, GBC.eol().fill(GBC.HORIZONTAL));
    223         add(pnl);
     219        add(areaValidatorFeedback, gbc);
     220        add(new JPanel(), GBC.std().fill(GBC.BOTH));
    224221    }
    225222
  • trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java

    r14977 r17709  
    157157        cbCloseAfterUpload.addItemListener(new CloseAfterUploadItemStateListener());
    158158
    159         gc.gridx = 0;
    160         gc.gridy = 5;
    161         gc.gridwidth = 4;
    162         gc.weightx = 1.0;
    163         gc.weighty = 1.0;
    164         gc.fill = GridBagConstraints.BOTH;
    165         add(new JPanel(), gc);
    166 
    167159        rbUseNew.getModel().addItemListener(new RadioButtonHandler());
    168160        rbExisting.getModel().addItemListener(new RadioButtonHandler());
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r17708 r17709  
    66import static org.openstreetmap.josm.tools.I18n.trn;
    77
     8import java.awt.BorderLayout;
    89import java.awt.Component;
    910import java.awt.Dimension;
     
    3435import javax.swing.JOptionPane;
    3536import javax.swing.JPanel;
     37import javax.swing.JSplitPane;
    3638import javax.swing.JTabbedPane;
     39import javax.swing.border.TitledBorder;
    3740
    3841import org.openstreetmap.josm.data.APIDataSet;
     
    8184    private UploadStrategySelectionPanel pnlUploadStrategySelectionPanel;
    8285
     86    private TitledBorder tagSettingsBorder;
    8387    /** checkbox for selecting whether an atomic upload is to be used  */
    8488    private TagSettingsPanel pnlTagSettings;
     
    122126     */
    123127    protected JPanel buildContentPanel() {
    124         JPanel pnl = new JPanel(new GridBagLayout());
    125         pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     128        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     129        splitPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    126130
    127131        // the panel with the list of uploaded objects
    128132        pnlUploadedObjects = new UploadedObjectsSummaryPanel();
    129         pnl.add(pnlUploadedObjects, GBC.eol().fill(GBC.BOTH));
     133        pnlUploadedObjects.setMinimumSize(new Dimension(200, 50));
     134        splitPane.setLeftComponent(pnlUploadedObjects);
    130135
    131136        // a tabbed pane with configuration panels in the lower half
    132137        tpConfigPanels = new CompactTabbedPane();
     138        splitPane.setRightComponent(tpConfigPanels);
    133139
    134140        pnlBasicUploadSettings = new BasicUploadSettingsPanel(changesetCommentModel, changesetSourceModel, changesetReviewModel);
    135141        tpConfigPanels.add(pnlBasicUploadSettings);
    136         tpConfigPanels.setTitleAt(0, tr("Settings"));
     142        tpConfigPanels.setTitleAt(0, tr("Description"));
    137143        tpConfigPanels.setToolTipTextAt(0, tr("Decide how to upload the data and which changeset to use"));
    138144
     145        tagSettingsBorder = BorderFactory.createTitledBorder(tr("Tags of new changeset"));
    139146        pnlTagSettings = new TagSettingsPanel(changesetCommentModel, changesetSourceModel, changesetReviewModel);
    140         tpConfigPanels.add(pnlTagSettings);
    141         tpConfigPanels.setTitleAt(1, tr("Tags of new changeset"));
    142         tpConfigPanels.setToolTipTextAt(1, tr("Apply tags to the changeset data is uploaded to"));
    143 
     147        pnlTagSettings.setBorder(tagSettingsBorder);
    144148        pnlChangesetManagement = new ChangesetManagementPanel(changesetCommentModel);
    145         tpConfigPanels.add(pnlChangesetManagement);
    146         tpConfigPanels.setTitleAt(2, tr("Changesets"));
    147         tpConfigPanels.setToolTipTextAt(2, tr("Manage open changesets and select a changeset to upload to"));
    148 
    149149        pnlUploadStrategySelectionPanel = new UploadStrategySelectionPanel();
    150         tpConfigPanels.add(pnlUploadStrategySelectionPanel);
    151         tpConfigPanels.setTitleAt(3, tr("Advanced"));
    152         tpConfigPanels.setToolTipTextAt(3, tr("Configure advanced settings"));
    153 
    154         pnl.add(tpConfigPanels, GBC.eol().fill(GBC.HORIZONTAL));
    155 
    156         pnl.add(buildActionPanel(), GBC.eol().fill(GBC.HORIZONTAL));
     150        JPanel pnlChangeset = new JPanel(new GridBagLayout());
     151        pnlChangeset.add(pnlChangesetManagement, GBC.eop().fill(GBC.HORIZONTAL));
     152        pnlChangeset.add(pnlUploadStrategySelectionPanel, GBC.eop().fill(GBC.HORIZONTAL));
     153        pnlChangeset.add(pnlTagSettings, GBC.eol().fill(GBC.BOTH));
     154        tpConfigPanels.add(pnlChangeset);
     155        tpConfigPanels.setTitleAt(1, tr("Settings"));
     156
     157        JPanel pnl = new JPanel(new BorderLayout());
     158        pnl.add(splitPane, BorderLayout.CENTER);
     159        pnl.add(buildActionPanel(), BorderLayout.SOUTH);
    157160        return pnl;
    158161    }
     
    212215        //
    213216        pnlBasicUploadSettings.getUploadParameterSummaryPanel().setConfigurationParameterRequestListener(
    214                 new ConfigurationParameterRequestHandler() {
    215                     @Override
    216                     public void handleUploadStrategyConfigurationRequest() {
    217                         tpConfigPanels.setSelectedIndex(3);
    218                     }
    219 
    220                     @Override
    221                     public void handleChangesetConfigurationRequest() {
    222                         tpConfigPanels.setSelectedIndex(2);
    223                     }
    224                 }
     217                () -> tpConfigPanels.setSelectedIndex(2)
    225218        );
    226219
     
    419412                    WindowGeometry.centerInWindow(
    420413                            MainApplication.getMainFrame(),
    421                             new Dimension(400, 600)
     414                            new Dimension(800, 600)
    422415                    )
    423416            ).applySafe(this);
     
    465458        static boolean isUploadCommentTooShort(String comment) {
    466459            String s = Utils.strip(comment);
    467             boolean result = true;
    468             if (!s.isEmpty()) {
    469                 UnicodeBlock block = Character.UnicodeBlock.of(s.charAt(0));
    470                 if (block != null && block.toString().contains("CJK")) {
    471                     result = s.length() < 4;
    472                 } else {
    473                     result = s.length() < 10;
    474                 }
    475             }
    476             return result;
     460            if (s.isEmpty()) {
     461                return true;
     462            }
     463            UnicodeBlock block = Character.UnicodeBlock.of(s.charAt(0));
     464            if (block != null && block.toString().contains("CJK")) {
     465                return s.length() < 4;
     466            } else {
     467                return s.length() < 10;
     468            }
    477469        }
    478470
     
    599591            setChangesetTags(dataSet, cs == null); // keep comment/source of first tab for new changesets
    600592            if (cs == null) {
    601                 tpConfigPanels.setTitleAt(1, tr("Tags of new changeset"));
     593                tagSettingsBorder.setTitle(tr("Tags of new changeset"));
    602594            } else {
    603                 tpConfigPanels.setTitleAt(1, tr("Tags of changeset {0}", cs.getId()));
     595                tagSettingsBorder.setTitle(tr("Tags of changeset {0}", cs.getId()));
    604596            }
    605597        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java

    r16730 r17709  
    99import java.beans.PropertyChangeListener;
    1010import java.util.Optional;
     11import java.util.stream.Stream;
    1112
    1213import javax.swing.BorderFactory;
     
    2324import org.openstreetmap.josm.spi.preferences.Config;
    2425import org.openstreetmap.josm.tools.ImageProvider;
     26import org.openstreetmap.josm.tools.StreamUtils;
    2527
    2628/**
     
    3739    private transient Changeset selectedChangeset;
    3840    private boolean closeChangesetAfterNextUpload;
    39     private transient ConfigurationParameterRequestHandler configHandler;
     41    private transient Runnable configHandler;
    4042
    4143    /**
     
    4850
    4951    protected String buildChangesetSummary() {
    50         StringBuilder msg = new StringBuilder(96);
    5152        if (selectedChangeset == null || selectedChangeset.isNew()) {
    52             msg.append(tr("Objects are uploaded to a <strong>new changeset</strong>."));
     53            return tr("Objects are uploaded to a <strong>new changeset</strong>.");
    5354        } else {
    54             msg.append(tr("Objects are uploaded to the <strong>open changeset</strong> {0} with upload comment ''{1}''.",
     55            return tr("Objects are uploaded to the <strong>open changeset</strong> {0} with upload comment ''{1}''.",
    5556                    selectedChangeset.getId(),
    5657                    selectedChangeset.getComment()
    57             ));
    58         }
    59         msg.append(' ');
     58            );
     59        }
     60    }
     61
     62    protected String buildChangesetSummary2() {
    6063        if (closeChangesetAfterNextUpload) {
    61             msg.append(tr("The changeset is going to be <strong>closed</strong> after this upload"));
     64            return tr("The changeset is going to be <strong>closed</strong> after this upload");
    6265        } else {
    63             msg.append(tr("The changeset is <strong>left open</strong> after this upload"));
    64         }
    65         msg.append(" (<a href=\"urn:changeset-configuration\">").append(tr("configure changeset")).append("</a>)");
    66         return msg.toString();
     66            return tr("The changeset is <strong>left open</strong> after this upload");
     67        }
    6768    }
    6869
     
    8081
    8182        int numRequests = spec.getNumRequests(numObjects);
    82         String msg = null;
    8383        if (useOneChangeset) {
    8484            lblWarning.setVisible(false);
    8585            if (numRequests == 0) {
    86                 msg = trn(
     86                return trn(
    8787                        "Uploading <strong>{0} object</strong> to <strong>1 changeset</strong>",
    8888                        "Uploading <strong>{0} objects</strong> to <strong>1 changeset</strong>",
     
    9090                );
    9191            } else if (numRequests == 1) {
    92                 msg = trn(
     92                return trn(
    9393                        "Uploading <strong>{0} object</strong> to <strong>1 changeset</strong> using <strong>1 request</strong>",
    9494                        "Uploading <strong>{0} objects</strong> to <strong>1 changeset</strong> using <strong>1 request</strong>",
     
    9696                );
    9797            } else if (numRequests > 1) {
    98                 msg = tr("Uploading <strong>{0} objects</strong> to <strong>1 changeset</strong> using <strong>{1} requests</strong>",
     98                return tr("Uploading <strong>{0} objects</strong> to <strong>1 changeset</strong> using <strong>{1} requests</strong>",
    9999                        numObjects, numRequests);
    100100            }
    101             msg = msg + " (<a href=\"urn:advanced-configuration\">" + tr("advanced configuration") + "</a>)";
    102101        } else {
    103102            lblWarning.setVisible(true);
    104103            if (numRequests == 0) {
    105                 msg = tr("{0} objects exceed the max. allowed {1} objects in a changeset on the server ''{2}''. " +
    106                         "Please <a href=\"urn:advanced-configuration\">configure</a> how to proceed with <strong>multiple changesets</strong>",
     104                return tr("{0} objects exceed the max. allowed {1} objects in a changeset on the server ''{2}''. " +
     105                        "Please <a href=\"urn:changeset-configuration\">configure</a> how to proceed with <strong>multiple changesets</strong>",
    107106                        numObjects, maxChunkSize, OsmApi.getOsmApi().getBaseUrl());
    108107            } else if (numRequests > 1) {
    109                 msg = tr("Uploading <strong>{0} objects</strong> to <strong>multiple changesets</strong> using <strong>{1} requests</strong>",
     108                return tr("Uploading <strong>{0} objects</strong> to <strong>multiple changesets</strong> using <strong>{1} requests</strong>",
    110109                        numObjects, numRequests);
    111                 msg = msg + " (<a href=\"urn:advanced-configuration\">" + tr("advanced configuration") + "</a>)";
    112110            }
    113111        }
    114         return msg;
     112        return "";
    115113    }
    116114
     
    120118
    121119        setLayout(new BorderLayout());
     120        setBorder(BorderFactory.createTitledBorder(tr("Settings:")));
    122121        add(jepMessage, BorderLayout.CENTER);
    123122        lblWarning = new JLabel("");
     
    131130    }
    132131
    133     public void setConfigurationParameterRequestListener(ConfigurationParameterRequestHandler handler) {
     132    public void setConfigurationParameterRequestListener(Runnable handler) {
    134133        this.configHandler = handler;
    135134    }
     
    167166                .map(url -> tr("… to server: <strong>{0}</strong>", url))
    168167                .orElse("");
    169         jepMessage.setText("<html>"
    170                 + "<br>"
    171                 + buildChangesetSummary()
    172                 + "<br><br>"
    173                 + buildStrategySummary()
    174                 + "<br>"
    175                 + server
    176                 + "</html>");
     168        final String html = Stream.of(buildChangesetSummary(), buildChangesetSummary2(), buildStrategySummary(), server)
     169                .filter(s -> s != null && !s.isEmpty())
     170                .collect(StreamUtils.toHtmlList());
     171        jepMessage.setText(html);
    177172        validate();
    178173    }
     
    188183                return;
    189184            if ("urn:changeset-configuration".equals(desc)) {
    190                 configHandler.handleChangesetConfigurationRequest();
    191             } else if ("urn:advanced-configuration".equals(desc)) {
    192                 configHandler.handleUploadStrategyConfigurationRequest();
     185                configHandler.run();
    193186            }
    194187        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    r16972 r17709  
    2121import java.util.Map.Entry;
    2222
     23import javax.swing.BorderFactory;
    2324import javax.swing.ButtonGroup;
    2425import javax.swing.JLabel;
     
    5455    private transient Map<UploadStrategy, JRadioButton> rbStrategy;
    5556    private transient Map<UploadStrategy, JLabel> lblNumRequests;
    56     private transient Map<UploadStrategy, JMultilineLabel> lblStrategies;
    5757    private final JosmTextField tfChunkSize = new JosmTextField(4);
    5858    private final JPanel pnlMultiChangesetPolicyPanel = new JPanel(new GridBagLayout());
     
    7474    protected JPanel buildUploadStrategyPanel() {
    7575        JPanel pnl = new JPanel(new GridBagLayout());
     76        pnl.setBorder(BorderFactory.createTitledBorder(tr("Please select the upload strategy:")));
    7677        ButtonGroup bgStrategies = new ButtonGroup();
    7778        rbStrategy = new EnumMap<>(UploadStrategy.class);
    78         lblStrategies = new EnumMap<>(UploadStrategy.class);
    7979        lblNumRequests = new EnumMap<>(UploadStrategy.class);
    8080        for (UploadStrategy strategy: UploadStrategy.values()) {
    8181            rbStrategy.put(strategy, new JRadioButton());
    8282            lblNumRequests.put(strategy, new JLabel());
    83             lblStrategies.put(strategy, new JMultilineLabel(""));
    8483            bgStrategies.add(rbStrategy.get(strategy));
    8584        }
    8685
    87         // -- headline
     86        // -- single request strategy
    8887        GridBagConstraints gc = new GridBagConstraints();
    8988        gc.gridx = 0;
    90         gc.gridy = 0;
    91         gc.weightx = 1.0;
    92         gc.weighty = 0.0;
    93         gc.gridwidth = 4;
     89        gc.gridy = 1;
     90        gc.weightx = 0.0;
     91        gc.weighty = 0.0;
     92        gc.gridwidth = 1;
    9493        gc.fill = GridBagConstraints.HORIZONTAL;
    9594        gc.insets = new Insets(0, 0, 3, 0);
    9695        gc.anchor = GridBagConstraints.FIRST_LINE_START;
    97         pnl.add(new JMultilineLabel(tr("Please select the upload strategy:")), gc);
    98 
    99         // -- single request strategy
    100         gc.gridx = 0;
    101         gc.gridy = 1;
    102         gc.weightx = 0.0;
    103         gc.weighty = 0.0;
    104         gc.gridwidth = 1;
    105         gc.anchor = GridBagConstraints.FIRST_LINE_START;
    106         pnl.add(rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY), gc);
    107         gc.gridx = 1;
     96        JRadioButton radioButton = rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
     97        radioButton.setText(tr("Upload data in one request"));
     98        pnl.add(radioButton, gc);
     99        gc.gridx = 3;
    108100        gc.gridy = 1;
    109101        gc.weightx = 1.0;
    110         gc.weighty = 0.0;
    111         gc.gridwidth = 2;
    112         JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    113         lbl.setText(tr("Upload data in one request"));
    114         pnl.add(lbl, gc);
    115         gc.gridx = 3;
    116         gc.gridy = 1;
    117         gc.weightx = 0.0;
    118102        gc.weighty = 0.0;
    119103        gc.gridwidth = 1;
     
    125109        gc.weightx = 0.0;
    126110        gc.weighty = 0.0;
    127         pnl.add(rbStrategy.get(UploadStrategy.CHUNKED_DATASET_STRATEGY), gc);
    128         gc.gridx = 1;
    129         gc.gridy = 2;
    130         gc.weightx = 1.0;
    131         gc.weighty = 0.0;
    132         gc.gridwidth = 1;
    133         lbl = lblStrategies.get(UploadStrategy.CHUNKED_DATASET_STRATEGY);
    134         lbl.setText(tr("Upload data in chunks of objects. Chunk size: "));
    135         pnl.add(lbl, gc);
     111        radioButton = rbStrategy.get(UploadStrategy.CHUNKED_DATASET_STRATEGY);
     112        radioButton.setText(tr("Upload data in chunks of objects. Chunk size: "));
     113        pnl.add(radioButton, gc);
    136114        gc.gridx = 2;
    137115        gc.gridy = 2;
     
    152130        gc.weightx = 0.0;
    153131        gc.weighty = 0.0;
    154         pnl.add(rbStrategy.get(UploadStrategy.INDIVIDUAL_OBJECTS_STRATEGY), gc);
    155         gc.gridx = 1;
    156         gc.gridy = 3;
    157         gc.weightx = 1.0;
    158         gc.weighty = 0.0;
    159         gc.gridwidth = 2;
    160         lbl = lblStrategies.get(UploadStrategy.INDIVIDUAL_OBJECTS_STRATEGY);
    161         lbl.setText(tr("Upload each object individually"));
    162         pnl.add(lbl, gc);
     132        radioButton = rbStrategy.get(UploadStrategy.INDIVIDUAL_OBJECTS_STRATEGY);
     133        radioButton.setText(tr("Upload each object individually"));
     134        pnl.add(radioButton, gc);
    163135        gc.gridx = 3;
    164136        gc.gridy = 3;
     
    340312        if (maxChunkSize > 0 && numUploadedObjects > maxChunkSize) {
    341313            rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY).setEnabled(false);
    342             JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
     314            JRadioButton lbl = rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    343315            lbl.setText(tr("Upload in one request not possible (too many objects to upload)"));
    344316            lbl.setToolTipText(tr("<html>Cannot upload {0} objects in one request because the<br>"
     
    361333        } else {
    362334            rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY).setEnabled(true);
    363             JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
     335            JRadioButton lbl = rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    364336            lbl.setText(tr("Upload data in one request"));
    365337            lbl.setToolTipText(null);
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java

    r14877 r17709  
    231231        AddAction() {
    232232            new ImageProvider("dialogs", "add").getResource().attachImageIcon(this);
    233             putValue(SHORT_DESCRIPTION, tr("Add a new tag"));
     233            putValue(SHORT_DESCRIPTION, tr("Add Tag"));
    234234            TagTable.this.addPropertyChangeListener(this);
    235235            updateEnabledState();
     
    265265        PasteAction() {
    266266            new ImageProvider("pastetags").getResource().attachImageIcon(this);
    267             putValue(SHORT_DESCRIPTION, tr("Paste tags from buffer"));
     267            putValue(SHORT_DESCRIPTION, tr("Paste Tags"));
    268268            TagTable.this.addPropertyChangeListener(this);
    269269            updateEnabledState();
Note: See TracChangeset for help on using the changeset viewer.