Ignore:
Timestamp:
2014-11-10T02:07:41+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #10739 - Improve note input dialogs (patch by ToeBee)

File:
1 edited

Legend:

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

    r7608 r7720  
    66import java.awt.event.MouseEvent;
    77
    8 import javax.swing.JLabel;
    98import javax.swing.JOptionPane;
    10 import javax.swing.JScrollPane;
    11 import javax.swing.JTextArea;
    129
    1310import org.openstreetmap.josm.Main;
     
    1512import org.openstreetmap.josm.data.osm.NoteData;
    1613import org.openstreetmap.josm.gui.MapFrame;
     14import org.openstreetmap.josm.gui.NoteInputDialog;
    1715import org.openstreetmap.josm.gui.Notification;
    1816import org.openstreetmap.josm.gui.dialogs.NoteDialog;
     
    6361        Main.map.selectMapMode(Main.map.mapModeSelect);
    6462        LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
    65         JLabel label = new JLabel(tr("Enter a comment for a new note"));
    66         JTextArea textArea = new JTextArea();
    67         textArea.setRows(6);
    68         textArea.setColumns(30);
    69         textArea.setLineWrap(true);
    70         JScrollPane scrollPane = new JScrollPane(textArea);
    7163
    72         Object[] components = new Object[]{label, scrollPane};
    73         int option = JOptionPane.showConfirmDialog(Main.map,
    74                 components,
    75                 tr("Create new note"),
    76                 JOptionPane.OK_CANCEL_OPTION,
    77                 JOptionPane.PLAIN_MESSAGE,
    78                 NoteDialog.ICON_NEW);
    79         if (option == JOptionPane.OK_OPTION) {
    80             String input = textArea.getText();
    81             if (input != null && !input.isEmpty()) {
    82                 noteData.createNote(latlon, input);
    83             } else {
    84                 Notification notification = new Notification("You must enter a comment to create a new note");
    85                 notification.setIcon(JOptionPane.WARNING_MESSAGE);
    86                 notification.show();
    87             }
     64        NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note"));
     65        dialog.showNoteDialog(tr("Enter a detailed comment to create a note"), NoteDialog.ICON_NEW);
     66
     67        if (dialog.getValue() != 1) {
     68            Main.debug("User aborted note creation");
     69            return;
     70        }
     71        String input = dialog.getInputText();
     72        if (input != null && !input.isEmpty()) {
     73            noteData.createNote(latlon, input);
     74        } else {
     75            Notification notification = new Notification(tr("You must enter a comment to create a new note"));
     76            notification.setIcon(JOptionPane.WARNING_MESSAGE);
     77            notification.show();
    8878        }
    8979    }
Note: See TracChangeset for help on using the changeset viewer.