Changeset 27966 in osm for applications


Ignore:
Timestamp:
2012-03-01T20:36:21+01:00 (12 years ago)
Author:
jttt
Message:

Use action instead of ActionListener for SideButton

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckDialog.java

    r27852 r27966  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.BorderLayout;
    76import java.awt.GridLayout;
    87import java.awt.event.ActionEvent;
    9 import java.awt.event.ActionListener;
    108import java.awt.event.KeyEvent;
    119import java.util.Arrays;
    1210import java.util.Collection;
    1311
     12import javax.swing.AbstractAction;
    1413import javax.swing.BoxLayout;
    1514import javax.swing.JCheckBox;
     
    2524import org.openstreetmap.josm.gui.SideButton;
    2625import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
     26import org.openstreetmap.josm.tools.ImageProvider;
    2727import org.openstreetmap.josm.tools.Shortcut;
    2828
     
    3030 * @author  joerg
    3131 */
    32 public class JunctionCheckDialog extends ToggleDialog implements ActionListener, SelectionChangedListener{
     32public class JunctionCheckDialog extends ToggleDialog implements SelectionChangedListener{
    3333
    3434        private final JunctionCheckerPlugin plugin;
     
    8888
    8989                // ButtonPanel
    90                 createDigraphButton = new SideButton(marktr("Create"), "digraphcreation", tr ("start the channel digraph creation"),
    91                                 tr("create the channel digraph"), this);
    92                 checkJunctionButton = new SideButton(marktr("Check "), "junctioncheck", tr("check a marked subset if it is a junction"),
    93                                 tr("check the subust for junction properties"), this);
     90                createDigraphButton = new SideButton(new AbstractAction() {
     91                        {
     92                                putValue(NAME, marktr("Create"));
     93                                putValue(SHORT_DESCRIPTION, tr("create the channel digraph"));
     94                                putValue(SMALL_ICON, ImageProvider.get("dialogs", "digraphcreation"));
     95                        }
     96                        @Override
     97                        public void actionPerformed(ActionEvent e) {
     98                                        DigraphCreationTask dct = new DigraphCreationTask(plugin, digraphsealcb.isSelected(), sccCB.isSelected());
     99                                        Main.worker.submit(dct);
     100                                        setActivateJunctionCheckOrSearch(true);
     101                        }
     102                });
     103                checkJunctionButton = new SideButton(new AbstractAction() {
     104                        {
     105                                putValue(NAME, marktr("Check "));
     106                                putValue(SHORT_DESCRIPTION, tr("check the subust for junction properties"));
     107                                putValue(SMALL_ICON, ImageProvider.get("dialogs", "junctioncheck"));
     108                        }
     109                        @Override
     110                        public void actionPerformed(ActionEvent e) {
     111                                PrepareJunctionCheckorSearch pjc = new PrepareJunctionCheckorSearch(plugin, smodel.getNumber().intValue(), produceRelation.isSelected());
     112                                pjc.prepareJunctionCheck();
     113                        }
     114                });
    94115                checkJunctionButton.setEnabled(false);
    95                 searchJunctionButton = new SideButton(marktr("Search "), "junctionsearch", tr ("search for junctions into a subset of channels"),
    96                                 tr("search for junctions in the channel subset"), this);
     116                searchJunctionButton = new SideButton(new AbstractAction() {
     117                        {
     118                                putValue(NAME, marktr("Search "));
     119                                putValue(SHORT_DESCRIPTION, tr("search for junctions in the channel subset"));
     120                                putValue(SMALL_ICON, ImageProvider.get("dialogs", "junctionsearch"));
     121                        }
     122                        @Override
     123                        public void actionPerformed(ActionEvent e) {
     124                                PrepareJunctionCheckorSearch pjc = new PrepareJunctionCheckorSearch(plugin, smodel.getNumber().intValue(), produceRelation.isSelected());
     125                                pjc.prepareJunctionSearch();
     126                        }
     127                });
    97128                searchJunctionButton.setEnabled(false);
    98129
     
    102133        }
    103134
    104 
    105         public void actionPerformed(ActionEvent e) {
    106                 String actionCommand = e.getActionCommand();
    107                 if (actionCommand.equals("Create")) {
    108                         DigraphCreationTask dct = new DigraphCreationTask(plugin, digraphsealcb.isSelected(), sccCB.isSelected());
    109                         Main.worker.submit(dct);
    110                         setActivateJunctionCheckOrSearch(true);
    111                 }
    112                 else if (actionCommand.equals("Check ")) {
    113                         PrepareJunctionCheckorSearch pjc = new PrepareJunctionCheckorSearch(plugin, smodel.getNumber().intValue(), produceRelation.isSelected());
    114                         pjc.prepareJunctionCheck();
    115 
    116                 }
    117                 else if (actionCommand.equals("Search ")) {
    118                         PrepareJunctionCheckorSearch pjc = new PrepareJunctionCheckorSearch(plugin, smodel.getNumber().intValue(), produceRelation.isSelected());
    119                         pjc.prepareJunctionSearch();
    120                 }
    121         }
    122135
    123136        /**
     
    143156        }
    144157
     158        @Override
    145159        public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    146160
Note: See TracChangeset for help on using the changeset viewer.