Changeset 17500 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2021-02-21T01:02:50+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java
r17371 r17500 15 15 import javax.swing.AbstractAction; 16 16 import javax.swing.BorderFactory; 17 import javax.swing.JOptionPane; 17 18 import javax.swing.JPanel; 18 19 import javax.swing.JScrollPane; 19 20 import javax.swing.JTable; 20 21 import javax.swing.JToolBar; 22 import javax.swing.SwingConstants; 21 23 22 24 import org.openstreetmap.josm.actions.downloadtasks.ChangesetHeaderDownloadTask; … … 24 26 import org.openstreetmap.josm.data.osm.Changeset; 25 27 import org.openstreetmap.josm.gui.MainApplication; 28 import org.openstreetmap.josm.gui.NoteInputDialog; 26 29 import org.openstreetmap.josm.io.NetworkManager; 27 30 import org.openstreetmap.josm.io.OnlineResource; 31 import org.openstreetmap.josm.io.OsmApi; 32 import org.openstreetmap.josm.io.OsmTransferException; 33 import org.openstreetmap.josm.tools.ExceptionUtil; 28 34 import org.openstreetmap.josm.tools.ImageProvider; 35 import org.openstreetmap.josm.tools.Logging; 29 36 30 37 /** … … 39 46 40 47 private final UpdateChangesetDiscussionAction actUpdateChangesets = new UpdateChangesetDiscussionAction(); 48 private final AddChangesetCommentAction actAddChangesetComment = new AddChangesetCommentAction(); 41 49 42 50 private final ChangesetDiscussionTableModel model = new ChangesetDiscussionTableModel(); … … 49 57 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT)); 50 58 51 JToolBar tb = new JToolBar( JToolBar.VERTICAL);59 JToolBar tb = new JToolBar(SwingConstants.VERTICAL); 52 60 tb.setFloatable(false); 53 61 54 62 // -- changeset discussion update 55 63 tb.add(actUpdateChangesets); 56 actUpdateChangesets.initProperties(current); 64 // -- add a comment to changeset discussion 65 tb.add(actAddChangesetComment); 66 67 initProperties(); 57 68 58 69 pnl.add(tb); 59 70 return pnl; 71 } 72 73 void initProperties() { 74 actUpdateChangesets.initProperties(current); 75 actAddChangesetComment.initProperties(current); 60 76 } 61 77 … … 82 98 } 83 99 84 publicvoid initProperties(Changeset cs) {100 void initProperties(Changeset cs) { 85 101 setEnabled(cs != null && !NetworkManager.isOffline(OnlineResource.OSM_API)); 102 } 103 } 104 105 /** 106 * Adds a discussion comment to the current changeset 107 */ 108 class AddChangesetCommentAction extends AbstractAction { 109 AddChangesetCommentAction() { 110 putValue(NAME, tr("Comment")); 111 new ImageProvider("dialogs/notes", "note_comment").getResource().attachImageIcon(this); 112 putValue(SHORT_DESCRIPTION, tr("Add comment")); 113 } 114 115 @Override 116 public void actionPerformed(ActionEvent evt) { 117 if (current == null) 118 return; 119 NoteInputDialog dialog = new NoteInputDialog(MainApplication.getMainFrame(), tr("Comment on changeset"), tr("Add comment")); 120 dialog.showNoteDialog(tr("Add comment to changeset:"), ImageProvider.get("dialogs/notes", "note_comment")); 121 if (dialog.getValue() != 1) { 122 return; 123 } 124 try { 125 OsmApi.getOsmApi().addCommentToChangeset(current, dialog.getInputText(), null); 126 } catch (OsmTransferException e) { 127 Logging.error(e); 128 JOptionPane.showMessageDialog( 129 MainApplication.getMainFrame(), 130 ExceptionUtil.explainOsmTransferException(e), 131 tr("Error"), 132 JOptionPane.ERROR_MESSAGE); 133 } 134 } 135 136 void initProperties(Changeset cs) { 137 setEnabled(cs != null && !cs.isOpen() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 86 138 } 87 139 } … … 101 153 updateView(cs); 102 154 } 103 actUpdateChangesets.initProperties(current);155 initProperties(); 104 156 if (cs != null && cs.getDiscussion().size() < cs.getCommentsCount()) { 105 157 actUpdateChangesets.actionPerformed(null);
Note:
See TracChangeset
for help on using the changeset viewer.