Changeset 7720 in josm for trunk/src/org
- Timestamp:
- 2014-11-10T02:07:41+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java
r7608 r7720 6 6 import java.awt.event.MouseEvent; 7 7 8 import javax.swing.JLabel;9 8 import javax.swing.JOptionPane; 10 import javax.swing.JScrollPane;11 import javax.swing.JTextArea;12 9 13 10 import org.openstreetmap.josm.Main; … … 15 12 import org.openstreetmap.josm.data.osm.NoteData; 16 13 import org.openstreetmap.josm.gui.MapFrame; 14 import org.openstreetmap.josm.gui.NoteInputDialog; 17 15 import org.openstreetmap.josm.gui.Notification; 18 16 import org.openstreetmap.josm.gui.dialogs.NoteDialog; … … 63 61 Main.map.selectMapMode(Main.map.mapModeSelect); 64 62 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);71 63 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(); 88 78 } 89 79 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/NoteDialog.java
r7699 r7720 35 35 import org.openstreetmap.josm.gui.MapView; 36 36 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 37 import org.openstreetmap.josm.gui.NoteInputDialog; 37 38 import org.openstreetmap.josm.gui.SideButton; 38 39 import org.openstreetmap.josm.gui.layer.Layer; … … 294 295 return; 295 296 } 296 Object userInput = JOptionPane.showInputDialog(Main.map, 297 tr("Add comment to note:"), 298 tr("Add comment"), 299 JOptionPane.QUESTION_MESSAGE, 300 ICON_COMMENT, 301 null,null); 302 if (userInput == null) { //user pressed cancel 297 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Comment on note"), tr("Add comment")); 298 dialog.showNoteDialog(tr("Add comment to note:"), NoteDialog.ICON_COMMENT); 299 if (dialog.getValue() != 1) { 300 Main.debug("User aborted note reopening"); 303 301 return; 304 302 } 305 noteData.addCommentToNote(note, userInput.toString());303 noteData.addCommentToNote(note, dialog.getInputText()); 306 304 } 307 305 } … … 317 315 @Override 318 316 public void actionPerformed(ActionEvent e) { 319 Object userInput = JOptionPane.showInputDialog(Main.map, 320 tr("Close note with message:"), 321 tr("Close Note"), 322 JOptionPane.QUESTION_MESSAGE, 323 ICON_CLOSED, 324 null,null); 325 if (userInput == null) { //user pressed cancel 317 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Close note"), tr("Close note")); 318 dialog.showNoteDialog(tr("Close note with message:"), NoteDialog.ICON_CLOSED); 319 if (dialog.getValue() != 1) { 320 Main.debug("User aborted note closing"); 326 321 return; 327 322 } 328 323 Note note = displayList.getSelectedValue(); 329 noteData.closeNote(note, userInput.toString());324 noteData.closeNote(note, dialog.getInputText()); 330 325 } 331 326 } … … 358 353 @Override 359 354 public void actionPerformed(ActionEvent e) { 360 Object userInput = JOptionPane.showInputDialog(Main.map, 361 tr("Reopen note with message:"), 362 tr("Reopen note"), 363 JOptionPane.QUESTION_MESSAGE, 364 ICON_OPEN, 365 null,null); 366 if (userInput == null) { //user pressed cancel 355 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Reopen note"), tr("Reopen note")); 356 dialog.showNoteDialog(tr("Reopen note with message:"), NoteDialog.ICON_OPEN); 357 if (dialog.getValue() != 1) { 358 Main.debug("User aborted note reopening"); 367 359 return; 368 360 } 361 369 362 Note note = displayList.getSelectedValue(); 370 noteData.reOpenNote(note, userInput.toString());363 noteData.reOpenNote(note, dialog.getInputText()); 371 364 } 372 365 }
Note:
See TracChangeset
for help on using the changeset viewer.