Changeset 34988 in osm for applications/editors/josm/plugins/ext_tools
- Timestamp:
- 2019-04-22T14:17:40+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/ext_tools/src/ext_tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ext_tools/src/ext_tools/DataSetToCmd.java
r34987 r34988 75 75 } 76 76 77 private OsmPrimitive getMergeTarget(OsmPrimitive mergeSource) 78 throws IllegalStateException { 79 OsmPrimitive target = mergedMap.get(mergeSource.getPrimitiveId()); 80 if (target == null) 81 return null; 82 return target; 77 private OsmPrimitive getMergeTarget(OsmPrimitive mergeSource) { 78 return mergedMap.get(mergeSource.getPrimitiveId()); 83 79 } 84 80 … … 103 99 * @throws IllegalStateException 104 100 * thrown if no target way can be found for the source way 105 * @throws IllegalStateException 106 * thrown if there isn't a target node for one of the nodes in 101 * or if there isn't a target node for one of the nodes in 107 102 * the source way 108 103 * 109 104 */ 110 private void mergeNodeList(Way source) throws IllegalStateException{105 private void mergeNodeList(Way source) { 111 106 Way target = (Way) getMergeTarget(source); 112 if (target == null) 113 throw new IllegalStateException(tr( 114 "Missing merge target for way with id {0}", source.getUniqueId())); 115 if (target.getDataSet() != null) 107 if (target == null || target.getDataSet() != null) 116 108 throw new IllegalStateException(tr( 117 109 "Missing merge target for way with id {0}", source.getUniqueId())); … … 120 112 for (Node sourceNode : source.getNodes()) { 121 113 Node targetNode = (Node) getMergeTarget(sourceNode); 122 if (targetNode == null) 114 if (targetNode == null || targetNode.getDataSet() != null) 123 115 throw new IllegalStateException(tr( 124 116 "Missing merge target for node with id {0}", sourceNode 125 117 .getUniqueId())); 126 if (targetNode.getDataSet() != null)127 throw new IllegalStateException(tr(128 "Missing merge target for way with id {0}", source.getUniqueId()));129 130 118 newNodes.add(targetNode); 131 119 } 132 cmds.add(new ChangeNodesCommand(target, newNodes)); 120 cmds.add(new ChangeNodesCommand(MainApplication.getLayerManager().getEditDataSet(), target, newNodes)); 133 121 } 134 122 -
applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/EditToolDialog.java
r34509 r34988 20 20 21 21 public class EditToolDialog extends ExtendedDialog { 22 private ExtTool tool; 22 private final transient ExtTool tool; 23 23 24 24 private JPanel panel = new JPanel(new GridBagLayout()); … … 48 48 true); 49 49 contentInsets = new Insets(15, 15, 5, 15); 50 setButtonIcons( new String[] {"ok.png", "cancel.png"});50 setButtonIcons("ok.png", "cancel.png"); 51 51 52 52 this.tool = tool; -
applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/MyToolsPanel.java
r34509 r34988 6 6 import java.awt.GridBagLayout; 7 7 import java.awt.Insets; 8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 8 11 9 import javax.swing.JButton; … … 18 16 import ext_tools.ToolsInformation; 19 17 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.tools.Utils; 20 19 21 20 public class MyToolsPanel extends JPanel { 22 21 private final transient ToolsInformation tools; 23 22 24 23 public MyToolsPanel(ToolsInformation tools) { … … 49 48 50 49 final JButton bEdit = new JButton(tr("Edit")); 51 bEdit.addActionListener(new ActionListener() { 52 @Override 53 public void actionPerformed(ActionEvent arg0) { 54 JDialog dlg = new EditToolDialog(tool); 55 dlg.setVisible(true); 56 dlg.dispose(); 57 refresh(); 58 } 59 }); 50 bEdit.addActionListener(e -> { 51 JDialog dlg = new EditToolDialog(tool); 52 dlg.setVisible(true); 53 dlg.dispose(); 54 refresh(); 55 }); 60 56 add(bEdit, gbc); 61 57 62 58 gbc.gridx = 2; 63 59 final JButton bDel = new JButton("X"); 64 bDel.addActionListener(new ActionListener() { 65 @Override 66 public void actionPerformed(ActionEvent arg0) { 67 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 68 tr("Delete tool \"{0}\"?", tool.name), 69 tr("Are you sure?"), 70 JOptionPane.YES_NO_OPTION, 71 JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) 72 { 73 tools.removeTool(tool); 74 refresh(); 75 } 76 } 77 }); 60 bDel.addActionListener(e -> { 61 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 62 tr("Delete tool \"{0}\"?", tool.name), 63 tr("Are you sure?"), 64 JOptionPane.YES_NO_OPTION, 65 JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) 66 { 67 tools.removeTool(tool); 68 refresh(); 69 } 70 }); 78 71 add(bDel, gbc); 79 72 … … 85 78 86 79 final JButton bNew = new JButton(tr("New tool...")); 87 bNew.addActionListener(new ActionListener() { 88 @Override 89 public void actionPerformed(ActionEvent arg0) { 90 ExtTool tool = new ExtTool(); 91 JDialog dlg = new EditToolDialog(tool); 92 dlg.setVisible(true); 93 dlg.dispose(); 94 if (tool.name != null && (!"".equals(tool.name))) { 95 tools.addTool(tool); 96 tool.setEnabled(true); 97 } 98 refresh(); 99 } 100 }); 80 bNew.addActionListener(e -> { 81 ExtTool tool = new ExtTool(); 82 JDialog dlg = new EditToolDialog(tool); 83 dlg.setVisible(true); 84 dlg.dispose(); 85 if (!Utils.isStripEmpty(tool.name)) { 86 tools.addTool(tool); 87 tool.setEnabled(true); 88 } 89 refresh(); 90 }); 101 91 add(bNew, gbc); 102 92 gbc.gridy++; -
applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/ToolsRepositoryPanel.java
r33698 r34988 20 20 public class ToolsRepositoryPanel extends JPanel { 21 21 22 ToolsInformation tools; 22 private final transient ToolsInformation tools; 23 23 24 24 public ToolsRepositoryPanel(ToolsInformation tools) {
Note:
See TracChangeset
for help on using the changeset viewer.