Ticket #23808: 23808.patch
| File 23808.patch, 5.6 KB (added by , 21 months ago) |
|---|
-
src/org/openstreetmap/josm/actions/AlignInCircleAction.java
Subject: [PATCH] 23808 --- IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/actions/AlignInCircleAction.java b/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
a b 5 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 6 6 import static org.openstreetmap.josm.tools.I18n.tr; 7 7 8 import java.awt.Color; 9 import java.awt.GridBagConstraints; 10 import java.awt.GridBagLayout; 8 11 import java.awt.event.ActionEvent; 9 12 import java.awt.event.KeyEvent; 10 13 import java.util.ArrayList; … … 18 21 import java.util.TreeMap; 19 22 import java.util.stream.Collectors; 20 23 24 import javax.swing.AbstractAction; 25 import javax.swing.Action; 26 import javax.swing.JButton; 27 import javax.swing.JEditorPane; 21 28 import javax.swing.JOptionPane; 29 import javax.swing.JPanel; 22 30 23 31 import org.openstreetmap.josm.command.Command; 24 32 import org.openstreetmap.josm.command.MoveCommand; … … 29 37 import org.openstreetmap.josm.data.osm.DataSet; 30 38 import org.openstreetmap.josm.data.osm.Node; 31 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 40 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 32 41 import org.openstreetmap.josm.data.osm.Way; 33 42 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 34 43 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay; 35 44 import org.openstreetmap.josm.data.validation.tests.CrossingWays; 36 45 import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay; 46 import org.openstreetmap.josm.gui.MainApplication; 37 47 import org.openstreetmap.josm.gui.Notification; 48 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 49 import org.openstreetmap.josm.tools.GBC; 38 50 import org.openstreetmap.josm.tools.Geometry; 39 51 import org.openstreetmap.josm.tools.Logging; 40 52 import org.openstreetmap.josm.tools.Shortcut; … … 82 94 super(msg); 83 95 } 84 96 } 97 98 /** 99 * IncompleteReferrers exception has to be raised when action can't be performed due to objects without 100 * referrer information 101 */ 102 public static class IncompleteReferrers extends InvalidSelection { 103 private final long[] nodeIds; 104 105 /** 106 * Create an IncompleteReferrers exception with specific message 107 * @param msg Message that will be displayed to the user 108 * @param nodeIds The nodes that are missing referrers 109 */ 110 IncompleteReferrers(String msg, long... nodeIds) { 111 super(msg); 112 this.nodeIds = nodeIds; 113 } 114 115 public long[] getNodeIds() { 116 return this.nodeIds; 117 } 118 } 85 119 86 120 /** 87 121 * Add a {@link MoveCommand} to move a node to a PolarCoor if there is a significant move. … … 120 154 .show(); 121 155 122 156 } 157 } catch (IncompleteReferrers except) { 158 Logging.debug(except); 159 final JPanel panel = new JPanel(new GridBagLayout()); 160 final JMultilineLabel lbl = new JMultilineLabel(except.getMessage()); 161 final DataSet editDataSet = getLayerManager().getEditDataSet(); 162 final Action downloadReferrers = new AbstractAction(tr("Download Referrers ({0} nodes)", except.getNodeIds().length)) { 163 @Override 164 public void actionPerformed(ActionEvent e) { 165 Collection<OsmPrimitive> toDownload = new ArrayList<>(except.getNodeIds().length); 166 for (long nodeId : except.getNodeIds()) { 167 toDownload.add(editDataSet.getPrimitiveById(nodeId, OsmPrimitiveType.NODE)); 168 } 169 DownloadReferrersAction.downloadReferrers(getLayerManager().getEditLayer(), toDownload); 170 } 171 }; 172 final Action downloadAlong = new AbstractAction("Download Along") { 173 @Override 174 public void actionPerformed(ActionEvent e) { 175 MainApplication.getMenu().downloadAlongWay.actionPerformed(e); 176 } 177 }; 178 lbl.setMaxWidth(Notification.DEFAULT_CONTENT_WIDTH); 179 lbl.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); 180 lbl.setForeground(Color.BLACK); 181 panel.setOpaque(false); 182 panel.add(lbl, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 183 panel.add(new JButton(downloadReferrers)); 184 panel.add(new JButton(downloadAlong), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 185 new Notification().setContent(panel) 186 .setIcon(JOptionPane.INFORMATION_MESSAGE) 187 .setDuration(Notification.TIME_SHORT) 188 .show(); 123 189 } catch (InvalidSelection except) { 124 190 Logging.debug(except); 125 191 new Notification(except.getMessage()) … … 274 340 275 341 // Check if one or more nodes does not have all parents available 276 342 if (nodes.stream().anyMatch(not(Node::isReferrersDownloaded))) 277 throw new InvalidSelection(tr("One or more nodes involved in this action may have additional referrers.")); 343 throw new IncompleteReferrers(tr("One or more nodes involved in this action may have additional referrers."), 344 nodes.stream().filter(not(Node::isReferrersDownloaded)).mapToLong(Node::getUniqueId).toArray()); 278 345 279 346 280 347 if (center == null) {
