Ignore:
Timestamp:
2019-04-22T14:17:40+02:00 (5 years ago)
Author:
donvip
Message:

plugin cleanup

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  
    7575    }
    7676
    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());
    8379    }
    8480
     
    10399     * @throws IllegalStateException
    104100     *             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
    107102     *             the source way
    108103     *
    109104     */
    110     private void mergeNodeList(Way source) throws IllegalStateException {
     105    private void mergeNodeList(Way source) {
    111106        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)
    116108            throw new IllegalStateException(tr(
    117109                    "Missing merge target for way with id {0}", source.getUniqueId()));
     
    120112        for (Node sourceNode : source.getNodes()) {
    121113            Node targetNode = (Node) getMergeTarget(sourceNode);
    122             if (targetNode == null)
     114            if (targetNode == null || targetNode.getDataSet() != null)
    123115                throw new IllegalStateException(tr(
    124116                        "Missing merge target for node with id {0}", sourceNode
    125117                                .getUniqueId()));
    126             if (targetNode.getDataSet() != null)
    127                 throw new IllegalStateException(tr(
    128                         "Missing merge target for way with id {0}", source.getUniqueId()));
    129 
    130118            newNodes.add(targetNode);
    131119        }
    132         cmds.add(new ChangeNodesCommand(target, newNodes));
     120        cmds.add(new ChangeNodesCommand(MainApplication.getLayerManager().getEditDataSet(), target, newNodes));
    133121    }
    134122
  • applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/EditToolDialog.java

    r34509 r34988  
    2020
    2121public class EditToolDialog extends ExtendedDialog {
    22     private ExtTool tool;
     22    private final transient ExtTool tool;
    2323
    2424    private JPanel panel = new JPanel(new GridBagLayout());
     
    4848                true);
    4949        contentInsets = new Insets(15, 15, 5, 15);
    50         setButtonIcons(new String[] { "ok.png", "cancel.png" });
     50        setButtonIcons("ok.png", "cancel.png");
    5151
    5252        this.tool = tool;
  • applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/MyToolsPanel.java

    r34509 r34988  
    66import java.awt.GridBagLayout;
    77import java.awt.Insets;
    8 import java.awt.event.ActionEvent;
    9 import java.awt.event.ActionListener;
    108
    119import javax.swing.JButton;
     
    1816import ext_tools.ToolsInformation;
    1917import org.openstreetmap.josm.gui.MainApplication;
     18import org.openstreetmap.josm.tools.Utils;
    2019
    2120public class MyToolsPanel extends JPanel {
    22     ToolsInformation tools;
     21        private final transient ToolsInformation tools;
    2322
    2423    public MyToolsPanel(ToolsInformation tools) {
     
    4948
    5049            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                        });
    6056            add(bEdit, gbc);
    6157
    6258            gbc.gridx = 2;
    6359            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                        });
    7871            add(bDel, gbc);
    7972
     
    8578
    8679        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                });
    10191        add(bNew, gbc);
    10292        gbc.gridy++;
  • applications/editors/josm/plugins/ext_tools/src/ext_tools/preferences/ToolsRepositoryPanel.java

    r33698 r34988  
    2020public class ToolsRepositoryPanel extends JPanel {
    2121
    22     ToolsInformation tools;
     22    private final transient ToolsInformation tools;
    2323
    2424    public ToolsRepositoryPanel(ToolsInformation tools) {
Note: See TracChangeset for help on using the changeset viewer.