Changeset 27964 in osm for applications/editors/josm


Ignore:
Timestamp:
2012-03-01T19:49:28+01:00 (13 years ago)
Author:
jttt
Message:

Use action instead of ActionListener for SideButton

Location:
applications/editors/josm/plugins/licensechange
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseChangeDialog.java

    r27852 r27964  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
    7 import java.awt.BorderLayout;
    8 import java.awt.GridLayout;
    97import java.awt.event.ActionEvent;
    108import java.awt.event.ActionListener;
     
    1210import java.awt.event.MouseAdapter;
    1311import java.awt.event.MouseEvent;
    14 import java.io.IOException;
    15 import java.lang.reflect.InvocationTargetException;
    1612import java.util.Arrays;
    17 import java.util.ArrayList;
    1813import java.util.Collection;
    1914import java.util.Enumeration;
    2015import java.util.HashSet;
    21 import java.util.LinkedList;
    2216import java.util.List;
    23 import java.util.Set;
    24 
     17
     18import javax.swing.AbstractAction;
    2519import javax.swing.JMenuItem;
    26 import javax.swing.JOptionPane;
    2720import javax.swing.JPopupMenu;
    2821import javax.swing.JScrollPane;
    29 import javax.swing.SwingUtilities;
    3022import javax.swing.event.TreeSelectionEvent;
    3123import javax.swing.event.TreeSelectionListener;
     
    3527import org.openstreetmap.josm.Main;
    3628import org.openstreetmap.josm.actions.AutoScaleAction;
    37 import org.openstreetmap.josm.command.Command;
    3829import org.openstreetmap.josm.data.osm.DataSet;
    3930import org.openstreetmap.josm.data.osm.Node;
     
    4132import org.openstreetmap.josm.data.osm.WaySegment;
    4233import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    43 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    4434import org.openstreetmap.josm.gui.SideButton;
    4535import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    46 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    47 import org.openstreetmap.josm.io.OsmTransferException;
     36import org.openstreetmap.josm.tools.ImageProvider;
    4837import org.openstreetmap.josm.tools.Shortcut;
    49 import org.xml.sax.SAXException;
    5038
    5139/**
     
    5442 * the list while single click will make the clicked entry the only selection.
    5543 */
    56 public class LicenseChangeDialog extends ToggleDialog implements ActionListener {
     44public class LicenseChangeDialog extends ToggleDialog {
    5745    private LicenseChangePlugin plugin;
    5846
     
    7260     * Constructor
    7361     */
    74     public LicenseChangeDialog(LicenseChangePlugin plugin) 
     62    public LicenseChangeDialog(LicenseChangePlugin plugin)
    7563    {
    7664        super(tr("Relicensing problems"), "licensechange", tr("Open the relicensing window."),
     
    8371        JMenuItem zoomTo = new JMenuItem(tr("Zoom to problem"));
    8472        zoomTo.addActionListener(new ActionListener() {
    85             public void actionPerformed(ActionEvent e) {
     73            @Override
     74                        public void actionPerformed(ActionEvent e) {
    8675                zoomToProblem();
    8776            }
     
    9382        tree.addTreeSelectionListener(new SelectionWatch());
    9483
    95         selectButton = new SideButton(marktr("Select"), "select", "LicenseChange",
    96                 tr("Set the selected elements on the map to the selected items in the list above."), this);
     84        selectButton = new SideButton(new AbstractAction() {
     85                {
     86                        putValue(NAME, marktr("Select"));
     87                        putValue(SHORT_DESCRIPTION, tr("Set the selected elements on the map to the selected items in the list above."));
     88                        putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));
     89                        putValue("help", "Dialog/LicenseChange/select");
     90                }
     91                        @Override
     92                        public void actionPerformed(ActionEvent e) {
     93                                setSelectedItems();
     94                        }
     95        });
    9796        selectButton.setEnabled(false);
    9897
     
    103102
    104103    @Override
    105     public void showNotify() 
     104    public void showNotify()
    106105    {
    107106        DataSet ds = Main.main.getCurrentDataSet();
     
    112111
    113112    @Override
    114     public void setVisible(boolean v) 
     113    public void setVisible(boolean v)
    115114    {
    116115        if (tree != null)
     
    121120
    122121    @SuppressWarnings("unchecked")
    123     private void showPopupMenu(MouseEvent e) 
     122    private void showPopupMenu(MouseEvent e)
    124123    {
    125124        if (!e.isPopupTrigger())
     
    136135    }
    137136
    138     private void zoomToProblem() 
     137    private void zoomToProblem()
    139138    {
    140139        if (popupMenuError == null)
     
    152151     */
    153152    @SuppressWarnings("unchecked")
    154     private void setSelectedItems() 
     153    private void setSelectedItems()
    155154    {
    156155        if (tree == null)
     
    179178    }
    180179
    181     public void actionPerformed(ActionEvent e)
    182     {
    183         String actionCommand = e.getActionCommand();
    184         if (actionCommand.equals("Select"))
    185             setSelectedItems();
    186     }
    187 
    188180    /**
    189181     * @param sel
     
    230222     * Watches for clicks.
    231223     */
    232     public class ClickWatch extends MouseAdapter 
     224    public class ClickWatch extends MouseAdapter
    233225    {
    234226        @Override
     
    264256     * Watches for tree selection.
    265257     */
    266     public class SelectionWatch implements TreeSelectionListener
    267     {
    268         public void valueChanged(TreeSelectionEvent e) {
     258    public class SelectionWatch implements TreeSelectionListener
     259    {
     260        @Override
     261                public void valueChanged(TreeSelectionEvent e) {
    269262            selectButton.setEnabled(false);
    270263
     
    279272    }
    280273
    281     public static class LicenseChangeBoundingXYVisitor extends BoundingXYVisitor implements LicenseChangeVisitor
    282     {
    283         public void visit(OsmPrimitive p) {
     274    public static class LicenseChangeBoundingXYVisitor extends BoundingXYVisitor implements LicenseChangeVisitor
     275    {
     276        @Override
     277                public void visit(OsmPrimitive p) {
    284278            if (p.isUsable()) {
    285279                p.visit(this);
     
    294288        }
    295289
    296         public void visit(List<Node> nodes) {
     290        @Override
     291                public void visit(List<Node> nodes) {
    297292            for (Node n: nodes) {
    298293                visit(n);
     
    301296    }
    302297
    303     public void updateSelection(Collection<? extends OsmPrimitive> newSelection) 
     298    public void updateSelection(Collection<? extends OsmPrimitive> newSelection)
    304299    {
    305300        if (newSelection.isEmpty())
Note: See TracChangeset for help on using the changeset viewer.