Ignore:
Timestamp:
2016-06-23T18:26:53+02:00 (8 years ago)
Author:
stoecker
Message:

Old style SideButton usage (see #josm12994)

Location:
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java

    r32375 r32386  
    120120            putValue(NAME, tr("Copy"));
    121121            putValue(SHORT_DESCRIPTION, tr("Copy to the clipboard"));
    122             putValue(SMALL_ICON, ImageProvider.get("copy"));
     122            new ImageProvider("copy").getResource().attachImageIcon(this);
    123123            putValue(ACCELERATOR_KEY, Shortcut.getCopyKeyStroke());
    124124            delegate = lstSelection.getActionMap().get("copy");
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/RelationMemberTable.java

    r29854 r32386  
    9797            putValue(NAME, tr("Delete"));
    9898            putValue(SHORT_DESCRIPTION, tr("Clear the selected roles or delete the selected members"));
    99             putValue(SMALL_ICON, ImageProvider.get("deletesmall"));
     99            new ImageProvider("deletesmall").getResource().attachImageIcon(this);
    100100            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
    101101            updateEnabledState();
     
    123123            putValue(NAME, tr("Paste"));
    124124            putValue(SHORT_DESCRIPTION, tr("Insert new relation members from object in the clipboard"));
    125             putValue(SMALL_ICON, ImageProvider.get("paste"));
     125            new ImageProvider("paste").getResource().attachImageIcon(this);
    126126            putValue(ACCELERATOR_KEY, Shortcut.getPasteKeyStroke());
    127127            updateEnabledState();
     
    164164            putValue(SHORT_DESCRIPTION, tr("Move the selected relation members down by one position"));
    165165            putValue(ACCELERATOR_KEY,keyStroke);
    166             putValue(SMALL_ICON, ImageProvider.get("dialogs", "movedown"));
     166            new ImageProvider("dialogs", "movedown").getResource().attachImageIcon(this);
    167167            updateEnabledState();
    168168        }
     
    191191            putValue(SHORT_DESCRIPTION, tr("Move the selected relation members up by one position"));
    192192            putValue(ACCELERATOR_KEY,keyStroke);
    193             putValue(SMALL_ICON, ImageProvider.get("dialogs", "moveup"));
     193            new ImageProvider("dialogs", "moveup").getResource().attachImageIcon(this);
    194194            updateEnabledState();
    195195        }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java

    r32375 r32386  
    2323
    2424import javax.swing.AbstractAction;
     25import javax.swing.JButton;
    2526import javax.swing.JComponent;
    2627import javax.swing.JDialog;
     
    4647import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    4748import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    48 import org.openstreetmap.josm.gui.SideButton;
    4949import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    5050import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
     
    9999        pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
    100100
    101         SideButton b;
    102         pnl.add(b = new SideButton(new OKAction()));
     101        JButton b;
     102        pnl.add(b = new JButton(new OKAction()));
    103103        b.setName("btnOK");
    104         pnl.add(b = new SideButton(new CancelAction()));
     104        pnl.add(b = new JButton(new CancelAction()));
    105105        b.setName("btnCancel");
    106         pnl.add(b = new SideButton(new ContextSensitiveHelpAction(ht("/Plugin/TurnRestrictions#TurnRestrictionEditor"))));
     106        pnl.add(b = new JButton(new ContextSensitiveHelpAction(ht("/Plugin/TurnRestrictions#TurnRestrictionEditor"))));
    107107        b.setName("btnHelp");
    108108        return pnl;
     
    643643        public ApplyAction() {
    644644            putValue(SHORT_DESCRIPTION, tr("Apply the current updates"));
    645             putValue(SMALL_ICON, ImageProvider.get("save"));
     645            new ImageProvider("save").getResource().attachImageIcon(this);
    646646            putValue(NAME, tr("Apply"));
    647647            setEnabled(true);
     
    687687        public OKAction() {
    688688            putValue(SHORT_DESCRIPTION, tr("Apply the updates and close the dialog"));
    689             putValue(SMALL_ICON, ImageProvider.get("ok"));
     689            new ImageProvider("ok").getResource().attachImageIcon(this);
    690690            putValue(NAME, tr("OK"));
    691691            setEnabled(true);
     
    742742        public CancelAction() {
    743743            putValue(SHORT_DESCRIPTION, tr("Cancel the updates and close the dialog"));
    744             putValue(SMALL_ICON, ImageProvider.get("cancel"));
     744            new ImageProvider("cancel").getResource().attachImageIcon(this);
    745745            putValue(NAME, tr("Cancel"));
    746746            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("ESCAPE"));
     
    759759            putValue(NAME, tr("Delete"));
    760760            putValue(SHORT_DESCRIPTION, tr("Delete this turn restriction"));
    761             putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
     761            new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this);
    762762            updateEnabledState();
    763763        }
     
    791791            putValue(NAME, tr("Select"));
    792792            putValue(SHORT_DESCRIPTION, tr("Select this turn restriction"));
    793             putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));
     793            new ImageProvider("dialogs", "select").getResource().attachImageIcon(this);
    794794            updateEnabledState();
    795795        }
     
    819819            putValue(NAME, tr("Zoom to"));
    820820            putValue(SHORT_DESCRIPTION, tr("Activate the layer this turn restriction belongs to and zoom to it"));
    821             putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale", "data"));
     821            new ImageProvider("dialogs/autoscale", "data").getResource().attachImageIcon(this);
    822822            updateEnabledState();
    823823        }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java

    r30737 r32386  
    6060public class TurnRestrictionLegEditor extends JPanel implements Observer, PrimitiveIdListProvider {
    6161    //static private final Logger logger = Logger.getLogger(TurnRestrictionLegEditor.class.getName());
    62  
     62
    6363    private JLabel lblOsmObject;
    6464    private final Set<OsmPrimitive> legs = new HashSet<>();
    6565    private TurnRestrictionEditorModel model;
    66     private TurnRestrictionLegRole role; 
     66    private TurnRestrictionLegRole role;
    6767    private DeleteAction actDelete;
    6868    private CopyAction actCopy;
     
    7070    private AcceptAction actAccept;
    7171    private TransferHandler transferHandler;
    72    
    73     /**
    74      * builds the UI 
     72
     73    /**
     74     * builds the UI
    7575     */
    7676    protected void build() {
    7777        setLayout(new BorderLayout());
    78         add(lblOsmObject = new JLabel(), BorderLayout.CENTER);     
     78        add(lblOsmObject = new JLabel(), BorderLayout.CENTER);
    7979        lblOsmObject.setOpaque(true);
    8080        lblOsmObject.setBorder(null);
     
    8585                )
    8686        );
    87        
     87
    8888        JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.LEFT,0,0));
    8989        pnlButtons.setBorder(null);
     
    9494        btn.setText(null);
    9595        btn.setBorder(BorderFactory.createRaisedBevelBorder());
    96        
     96
    9797        actAccept = new AcceptAction();
    9898        pnlButtons.add(btn = new JButton(actAccept));
     
    101101        btn.setBorder(BorderFactory.createRaisedBevelBorder());
    102102        add(pnlButtons, BorderLayout.EAST);
    103                
     103
    104104        // focus handling
    105105        FocusHandler fh  = new FocusHandler();
    106         lblOsmObject.setFocusable(true);   
    107         lblOsmObject.addFocusListener(fh);     
     106        lblOsmObject.setFocusable(true);
     107        lblOsmObject.addFocusListener(fh);
    108108        this.addFocusListener(fh);
    109109
     
    113113        addMouseListener(meh);
    114114        lblOsmObject.addMouseListener(new PopupLauncher());
    115        
     115
    116116        // enable DEL to remove the object from the turn restriction
    117117        registerKeyboardAction(actDelete,KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0) , JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
     
    127127                JComponent c = (JComponent)e.getSource();
    128128                TransferHandler th = c.getTransferHandler();
    129                 th.exportAsDrag(c, e, TransferHandler.COPY);               
    130             }                   
     129                th.exportAsDrag(c, e, TransferHandler.COPY);
     130            }
    131131        });
    132132        actCopy = new CopyAction();
    133133        actPaste = new PasteAction();
    134134    }
    135    
    136     /**
    137      * Constructor 
    138      * 
     135
     136    /**
     137     * Constructor
     138     *
    139139     * @param model the model. Must not be null.
    140140     * @param role the leg role of the leg this editor is editing. Must not be null.
     
    145145        CheckParameterUtil.ensureParameterNotNull(model, "model");
    146146        CheckParameterUtil.ensureParameterNotNull(role, "role");
    147        
     147
    148148        this.model = model;
    149149        this.role = role;
    150150        build();
    151151        model.addObserver(this);
    152         refresh(); 
     152        refresh();
    153153    }
    154154
     
    171171            lblOsmObject.setIcon(null);
    172172            lblOsmObject.setText(tr("multiple objects with role ''{0}''",this.role.getOsmRole()));
    173             lblOsmObject.setToolTipText(null);         
     173            lblOsmObject.setToolTipText(null);
    174174        }
    175175        renderColors();
    176176        actDelete.updateEnabledState();
    177177    }
    178    
     178
    179179    /**
    180180     * Render the foreground and background color
     
    191191        }
    192192    }
    193    
     193
    194194    /**
    195195     * Replies the model for this editor
    196      * 
    197      * @return the model 
     196     *
     197     * @return the model
    198198     */
    199199    public TurnRestrictionEditorModel getModel() {
    200200        return model;
    201201    }
    202    
    203     /**
    204      * Replies the role of this editor 
    205      * 
    206      * @return the role 
     202
     203    /**
     204     * Replies the role of this editor
     205     *
     206     * @return the role
    207207     */
    208208    public TurnRestrictionLegRole getRole() {
    209209        return role;
    210     }       
    211    
     210    }
     211
    212212    /* ----------------------------------------------------------------------------- */
    213213    /* interface Observer                                                            */
    214214    /* ----------------------------------------------------------------------------- */
    215215    public void update(Observable o, Object arg) {
    216         refresh();     
    217     }
    218    
     216        refresh();
     217    }
     218
    219219    /* ----------------------------------------------------------------------------- */
    220220    /* interface PrimitiveIdListProvider                                                            */
     
    226226        return Collections.emptyList();
    227227    }
    228    
     228
    229229    /* ----------------------------------------------------------------------------- */
    230230    /* inner classes                                                                 */
    231     /* ----------------------------------------------------------------------------- */ 
    232     /**
    233      * Responds to focus change events 
     231    /* ----------------------------------------------------------------------------- */
     232    /**
     233     * Responds to focus change events
    234234     */
    235235    class FocusHandler extends FocusAdapter {
     
    242242        public void focusLost(FocusEvent e) {
    243243            renderColors();
    244         }       
    245     }
    246    
     244        }
     245    }
     246
    247247    class MouseEventHandler extends MouseAdapter {
    248248        @Override
    249249        public void mouseClicked(MouseEvent e) {
    250250            lblOsmObject.requestFocusInWindow();
    251         }       
    252     }
    253    
    254     /**
    255      * Deletes the way from the turn restriction 
     251        }
     252    }
     253
     254    /**
     255     * Deletes the way from the turn restriction
    256256     */
    257257    class DeleteAction extends AbstractAction {
     
    259259            putValue(SHORT_DESCRIPTION, tr("Delete from turn restriction"));
    260260            putValue(NAME, tr("Delete"));
    261             putValue(SMALL_ICON, ImageProvider.get("deletesmall"));
     261            new ImageProvider("deletesmall").getResource().attachImageIcon(this);
    262262            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
    263263            updateEnabledState();
    264264        }
    265        
     265
    266266        public void actionPerformed(ActionEvent e) {
    267             model.setTurnRestrictionLeg(role, null);           
    268         }       
    269        
     267            model.setTurnRestrictionLeg(role, null);
     268        }
     269
    270270        public void updateEnabledState() {
    271271            setEnabled(legs.size()>0);
    272272        }
    273273    }
    274    
     274
    275275    /**
    276276     * Accepts the currently selected way as turn restriction leg. Only enabled,
    277      * if there is exactly one way selected 
     277     * if there is exactly one way selected
    278278     */
    279279    class AcceptAction extends AbstractAction implements ListSelectionListener {
    280        
     280
    281281        public AcceptAction() {
    282282             putValue(SHORT_DESCRIPTION, tr("Accept the currently selected way"));
    283283             putValue(NAME, tr("Accept"));
    284              putValue(SMALL_ICON, ImageProvider.get("accept"));
     284             new ImageProvider("accept").getResource().attachImageIcon(this);
    285285             model.getJosmSelectionListModel().getListSelectionModel().addListSelectionListener(this);
    286286             updateEnabledState();
    287287        }
    288        
     288
    289289         public void actionPerformed(ActionEvent e) {
    290290             List<Way> selWays = OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class);
    291291             if (selWays.size() != 1) return;
    292292             Way w = selWays.get(0);
    293              model.setTurnRestrictionLeg(role, w);           
    294          }       
    295          
     293             model.setTurnRestrictionLeg(role, w);
     294         }
     295
    296296         public void updateEnabledState() {
    297297            setEnabled(OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1);
     
    303303        }
    304304    }
    305    
    306     /**
    307      * The transfer handler for Drag-and-Drop. 
     305
     306    /**
     307     * The transfer handler for Drag-and-Drop.
    308308     */
    309309    class LegEditorTransferHandler extends PrimitiveIdListTransferHandler {
    310310        Logger logger = Logger.getLogger(LegEditorTransferHandler.class.getName());
    311        
     311
    312312        public LegEditorTransferHandler(PrimitiveIdListProvider provider){
    313313            super(provider);
     
    341341        }
    342342    }
    343    
     343
    344344    class PopupLauncher extends PopupMenuLauncher {
    345345        @Override
    346346        public void launch(MouseEvent evt) {
    347347            new PopupMenu().show(lblOsmObject, evt.getX(), evt.getY());
    348         }       
    349     }
    350    
     348        }
     349    }
     350
    351351    class PopupMenu extends JPopupMenu {
    352352        public PopupMenu() {
     
    355355            item.setTransferHandler(transferHandler);
    356356            actPaste.updateEnabledState();
    357             item = add(actPaste);           
     357            item = add(actPaste);
    358358            item.setTransferHandler(transferHandler);
    359359            addSeparator();
     
    361361        }
    362362    }
    363    
     363
    364364    class CopyAction extends AbstractAction {
    365365        private Action delegate;
    366        
     366
    367367        public CopyAction(){
    368368            putValue(NAME, tr("Copy"));
    369369            putValue(SHORT_DESCRIPTION, tr("Copy to the clipboard"));
    370             putValue(SMALL_ICON, ImageProvider.get("copy"));
     370            new ImageProvider("copy").getResource().attachImageIcon(this);
    371371            putValue(ACCELERATOR_KEY, Shortcut.getCopyKeyStroke());
    372372            delegate = TurnRestrictionLegEditor.this.getActionMap().get("copy");
     
    377377            delegate.actionPerformed(e);
    378378        }
    379        
     379
    380380        public void updateEnabledState() {
    381381            setEnabled(legs.size() == 1);
    382382        }
    383383    }
    384    
     384
    385385    class PasteAction extends AbstractAction {
    386386        private Action delegate;
    387        
     387
    388388        public boolean canPaste() {
    389389            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    390390            for (DataFlavor df: clipboard.getAvailableDataFlavors()) {
    391391                if (df.equals(PrimitiveIdTransferable.PRIMITIVE_ID_LIST_FLAVOR)) return true;
    392             }           
    393             // FIXME: check whether there are selected objects in the JOSM copy/paste buffer 
     392            }
     393            // FIXME: check whether there are selected objects in the JOSM copy/paste buffer
    394394            return false;
    395395        }
    396        
     396
    397397        public PasteAction(){
    398398            putValue(NAME, tr("Paste"));
    399399            putValue(SHORT_DESCRIPTION, tr("Paste from the clipboard"));
    400             putValue(SMALL_ICON, ImageProvider.get("paste"));
     400            new ImageProvider("paste").getResource().attachImageIcon(this);
    401401            putValue(ACCELERATOR_KEY, Shortcut.getPasteKeyStroke());
    402402            delegate = TurnRestrictionLegEditor.this.getActionMap().get("paste");
    403403        }
    404        
     404
    405405        public void updateEnabledState() {
    406406            setEnabled(canPaste());
     
    408408
    409409        public void actionPerformed(ActionEvent e) {
    410             delegate.actionPerformed(e);           
    411         }
    412     }
    413    
    414      
     410            delegate.actionPerformed(e);
     411        }
     412    }
     413
     414
    415415}
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionSelectionPopupPanel.java

    r30737 r32386  
    5656    private JButton btnNew;
    5757    /** the table with the turn restrictions which can be edited */
    58     private JTable tblTurnRestrictions; 
     58    private JTable tblTurnRestrictions;
    5959    private OsmDataLayer layer;
    60    
     60
    6161    /**
    6262     * Replies the collection of turn restrictions the primitives in {@code primitives}
    6363     * currently participate in.
    64      * 
     64     *
    6565     * @param primitives the collection of primitives. May be null.
    66      * @return the collection of "parent" turn restrictions. 
     66     * @return the collection of "parent" turn restrictions.
    6767     */
    6868    static public Collection<Relation> getTurnRestrictionsParticipatingIn(Collection<OsmPrimitive> primitives){
     
    8282        return ret;
    8383    }
    84    
     84
    8585    /**
    8686     * Registers 1..9 shortcuts for the first 9 turn restrictions to
    8787     * edit
    88      * 
    89      * @param editCandiates the edit candidates 
     88     *
     89     * @param editCandiates the edit candidates
    9090     */
    9191    protected void registerEditShortcuts(Collection<Relation> editCandiates){
     
    107107    }
    108108    /**
    109      * Builds the panel with the turn restrictions table 
    110      * 
    111      * @param editCandiates the list of edit candiates 
    112      * @return the panel 
     109     * Builds the panel with the turn restrictions table
     110     *
     111     * @param editCandiates the list of edit candiates
     112     * @return the panel
    113113     */
    114114    protected JPanel buildTurnRestrictionTablePanel(Collection<Relation> editCandiates) {
     
    118118        TurnRestrictionCellRenderer renderer = new TurnRestrictionCellRenderer();
    119119        tblTurnRestrictions.setRowHeight((int)renderer.getPreferredSize().getHeight());
    120        
    121         // create a scroll pane, remove the table header 
     120
     121        // create a scroll pane, remove the table header
    122122        JScrollPane pane = new JScrollPane(tblTurnRestrictions);
    123123        pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     
    125125        tblTurnRestrictions.setTableHeader(null);
    126126        pane.setColumnHeaderView(null);
    127        
    128         // respond to double click and ENTER 
     127
     128        // respond to double click and ENTER
    129129        EditSelectedTurnRestrictionAction action = new EditSelectedTurnRestrictionAction();
    130130        tblTurnRestrictions.addMouseListener(action);
    131131        tblTurnRestrictions.registerKeyboardAction(action, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), WHEN_FOCUSED);
    132        
     132
    133133        tblTurnRestrictions.addFocusListener(new FocusHandler());
    134        
     134
    135135        JPanel pnl = new JPanel(new BorderLayout());
    136136        pnl.add(pane, BorderLayout.CENTER);
    137        
     137
    138138        pnl.setBackground(UIManager.getColor("Table.background"));
    139139        pane.setBackground(UIManager.getColor("Table.background"));
    140         return pnl;     
    141     }
    142    
    143     /**
    144      * Builds the panel 
    145      * 
     140        return pnl;
     141    }
     142
     143    /**
     144     * Builds the panel
     145     *
    146146     * @param editCandiates the edit candidates
    147147     */
     
    153153        registerKeyboardAction(new CloseAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    154154        registerKeyboardAction(btnNew.getAction(), KeyStroke.getKeyStroke(KeyEvent.VK_N,0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    155        
     155
    156156        btnNew.addFocusListener(new FocusHandler());
    157        
     157
    158158        if (editCandiates != null && ! editCandiates.isEmpty()) {
    159             add(buildTurnRestrictionTablePanel(editCandiates), BorderLayout.CENTER);   
     159            add(buildTurnRestrictionTablePanel(editCandiates), BorderLayout.CENTER);
    160160            registerEditShortcuts(editCandiates);
    161161        }
    162        
    163         setBackground(UIManager.getColor("Table.background"));     
    164     }
    165 
    166    
     162
     163        setBackground(UIManager.getColor("Table.background"));
     164    }
     165
     166
    167167    /**
    168168     * Creates the panel
    169      * 
     169     *
    170170     * @param layer the reference OSM data layer. Must not be null.
    171171     * @throws IllegalArgumentException thrown if {@code layer} is null
     
    176176        build(getTurnRestrictionsParticipatingIn(layer.data.getSelected()));
    177177    }
    178    
     178
    179179    /**
    180180     * Creates the panel
    181      * 
     181     *
    182182     * @param layer the reference OSM data layer. Must not be null.
    183      * @param editCandidates a collection of turn restrictions as edit candidates. May be null. 
     183     * @param editCandidates a collection of turn restrictions as edit candidates. May be null.
    184184     * @throws IllegalArgumentException thrown if {@code layer} is null
    185185     */
     
    189189        build(editCandiates);
    190190    }
    191    
    192     /**
    193      * Launches a popup with this panel as content 
     191
     192    /**
     193     * Launches a popup with this panel as content
    194194     */
    195195    public void launch(){
     
    208208        return new Dimension(300, bestheight);
    209209    }
    210    
     210
    211211    /* --------------------------------------------------------------------------------------- */
    212212    /* inner classes                                                                           */
    213213    /* --------------------------------------------------------------------------------------- */
    214    
     214
    215215    private class NewAction extends AbstractAction {
    216216        public NewAction() {
    217217            putValue(NAME, tr("Create new turn restriction"));
    218218            putValue(SHORT_DESCRIPTION, tr("Launch the turn restriction editor to create a new turn restriction"));
    219             putValue(SMALL_ICON, ImageProvider.get("new"));
     219            new ImageProvider("new").getResource().attachImageIcon(this);
    220220            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, 0));
    221221        }
     
    232232        }
    233233    }
    234    
     234
    235235    abstract private  class AbstractEditTurnRestrictionAction extends AbstractAction {
    236236        protected void launchEditor(Relation tr){
     
    251251        }
    252252    }
    253    
     253
    254254    private class EditTurnRestrictionAction extends AbstractEditTurnRestrictionAction {
    255255        private int idx;
    256        
     256
    257257        public EditTurnRestrictionAction(int idx){
    258258            this.idx = idx;
    259259        }
    260        
     260
    261261        public void actionPerformed(ActionEvent e) {
    262262            Relation tr = (Relation)tblTurnRestrictions.getModel().getValueAt(idx, 1);
    263263            launchEditor(tr);
    264         }       
    265     }
    266    
     264        }
     265    }
     266
    267267    private class EditSelectedTurnRestrictionAction extends AbstractEditTurnRestrictionAction implements MouseListener{
    268268        public void editTurnRestrictionAtRow(int row){
     
    279279            int row = tblTurnRestrictions.rowAtPoint(e.getPoint());
    280280            if (row < 0) return;
    281             editTurnRestrictionAtRow(row);         
     281            editTurnRestrictionAtRow(row);
    282282        }
    283283        public void mouseEntered(MouseEvent e) {}
     
    286286        public void mouseReleased(MouseEvent e) {}
    287287    }
    288    
     288
    289289    private class CloseAction extends AbstractAction {
    290290        public void actionPerformed(ActionEvent e) {
     
    292292                parentPopup.hide();
    293293            }
    294         }       
    295     }
    296    
     294        }
     295    }
     296
    297297    private static class TurnRestrictionTableModel extends AbstractTableModel {
    298298        private final ArrayList<Relation> turnrestrictions = new ArrayList<>();
     
    305305            fireTableDataChanged();
    306306        }
    307        
     307
    308308        public int getRowCount() {
    309309            return turnrestrictions.size();
     
    329329        }
    330330    }
    331    
    332     private static class TurnRestrictionTableColumnModel extends DefaultTableColumnModel {     
    333         public TurnRestrictionTableColumnModel() {         
     331
     332    private static class TurnRestrictionTableColumnModel extends DefaultTableColumnModel {
     333        public TurnRestrictionTableColumnModel() {
    334334            // the idx column
    335             TableColumn col = new TableColumn(0);           
     335            TableColumn col = new TableColumn(0);
    336336            col.setResizable(false);
    337337            col.setWidth(50);
    338338            addColumn(col);
    339            
    340             // the column displaying turn restrictions 
    341             col = new TableColumn(1);           
     339
     340            // the column displaying turn restrictions
     341            col = new TableColumn(1);
    342342            col.setResizable(false);
    343343            col.setPreferredWidth(400);
    344344            col.setCellRenderer(new TurnRestrictionCellRenderer());
    345             addColumn(col);         
    346         }
    347     }
    348    
    349     private class FocusHandler extends FocusAdapter {       
     345            addColumn(col);
     346        }
     347    }
     348
     349    private class FocusHandler extends FocusAdapter {
    350350        @Override
    351351        public void focusLost(FocusEvent e) {
    352352            // if we loose the focus to a component outside of the popup panel
    353             // we hide the popup           
     353            // we hide the popup
    354354            if (e.getOppositeComponent() == null ||!SwingUtilities.isDescendingFrom(e.getOppositeComponent(), TurnRestrictionSelectionPopupPanel.this)) {
    355355                if (parentPopup != null){
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaList.java

    r30454 r32386  
    4141/**
    4242 * <p>ViaList is a JList which displays the 'via' members of a turn restriction.</p>
    43  * 
     43 *
    4444 * <p>A ViaList is connected to a {@link TurnRestrictionEditorModel} through its
    45  * {@link ViaListModel}.</p> 
    46  * 
     45 * {@link ViaListModel}.</p>
     46 *
    4747 */
    4848public class ViaList extends JList<OsmPrimitive> {
    49    
     49
    5050    //static private final Logger logger = Logger.getLogger(ViaList.class.getName());
    5151
     
    5757    private PasteAction actPaste;
    5858    private TransferHandler transferHandler;
    59    
     59
    6060    /**
    61      * Constructor 
    62      * 
     61     * Constructor
     62     *
    6363     * @param model the via list model. Must not be null.
    6464     * @param selectionModel the selection model. Must not be null.
    65      * 
     65     *
    6666     */
    6767    public ViaList(ViaListModel model, DefaultListSelectionModel selectionModel) {
     
    7171        setSelectionModel(selectionModel);
    7272        setCellRenderer(new OsmPrimitivRenderer());
    73         setDragEnabled(true);       
     73        setDragEnabled(true);
    7474        setTransferHandler(transferHandler =new ViaListTransferHandler(model));
    7575        setVisibleRowCount(4);
    76        
     76
    7777        actDelete = new DeleteAction();
    7878        selectionModel.addListSelectionListener(actDelete);
    7979        registerKeyboardAction(actDelete, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    80        
     80
    8181        actMoveDown = new MoveDownAction();
    8282        selectionModel.addListSelectionListener(actMoveDown);
     
    8686        selectionModel.addListSelectionListener(actMoveUp);
    8787        registerKeyboardAction(actMoveUp, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    88        
     88
    8989        actCopy = new CopyAction();
    9090        actPaste = new PasteAction();
    9191        getSelectionModel().addListSelectionListener(actCopy);
    92        
    93         addMouseListener(new ViaListPopupMenuLaucher());           
    94     }
    95    
     92
     93        addMouseListener(new ViaListPopupMenuLaucher());
     94    }
     95
    9696    /**
    97      * The transfer handler for Drag-and-Drop. 
     97     * The transfer handler for Drag-and-Drop.
    9898     */
    9999    class ViaListTransferHandler extends PrimitiveIdListTransferHandler {
    100100        Logger logger = Logger.getLogger(ViaListTransferHandler.class.getName());
    101        
     101
    102102        private boolean isViaListInDragOperation = false;
    103103        private List<Integer> selectedRowsMemento = null;
    104        
     104
    105105        public ViaListTransferHandler(PrimitiveIdListProvider provider) {
    106106            super(provider);
     
    111111            // a drag operation on itself is always allowed
    112112            if (isViaListInDragOperation) return true;
    113             return isSupportedFlavor(transferFlavors);         
     113            return isSupportedFlavor(transferFlavors);
    114114        }
    115115
    116116        @SuppressWarnings("unchecked")
    117117        @Override
    118         public boolean importData(JComponent comp, Transferable t) {   
     118        public boolean importData(JComponent comp, Transferable t) {
    119119            if (!isSupportedFlavor(t.getTransferDataFlavors())) return false;
    120120            if (isViaListInDragOperation) {
     
    122122                int targetRow = getSelectedIndex();
    123123                if (targetRow <0) return true;
    124                 model.moveVias(selectedRowsMemento, targetRow);             
     124                model.moveVias(selectedRowsMemento, targetRow);
    125125            } else {
    126126                // this is a drag operation from another component
     
    148148            selectedRowsMemento = model.getSelectedRows();
    149149            super.exportAsDrag(comp, e, action);
    150         }       
    151     }   
    152    
     150        }
     151    }
     152
    153153    class DeleteAction extends AbstractAction implements ListSelectionListener {
    154154        public DeleteAction() {
    155155            putValue(NAME, tr("Remove"));
    156             putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
    157             putValue(SHORT_DESCRIPTION,tr("Remove the currently selected vias"));       
    158             putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));         
    159             updateEnabledState();
    160         }
    161        
     156            new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this);
     157            putValue(SHORT_DESCRIPTION,tr("Remove the currently selected vias"));
     158            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
     159            updateEnabledState();
     160        }
     161
    162162        public void valueChanged(ListSelectionEvent e) {
    163             updateEnabledState();           
    164         }
    165        
     163            updateEnabledState();
     164        }
     165
    166166        public void updateEnabledState() {
    167167            setEnabled(getSelectedIndex() >= 0);
     
    169169
    170170        public void actionPerformed(ActionEvent e) {
    171             model.removeSelectedVias();         
    172         }
    173     }
    174    
    175     class MoveDownAction extends AbstractAction implements ListSelectionListener{       
     171            model.removeSelectedVias();
     172        }
     173    }
     174
     175    class MoveDownAction extends AbstractAction implements ListSelectionListener{
    176176        public MoveDownAction(){
    177177            putValue(NAME, tr("Move down"));
    178178            putValue(SHORT_DESCRIPTION, tr("Move the selected vias down by one position"));
    179179            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK));
    180             putValue(SMALL_ICON, ImageProvider.get("dialogs", "movedown"));
    181             updateEnabledState();
    182         }
    183        
     180            new ImageProvider("dialogs", "movedown").getResource().attachImageIcon(this);
     181            updateEnabledState();
     182        }
     183
    184184        public void actionPerformed(ActionEvent e) {
    185185            model.moveDown();
     
    193193            setEnabled(getSelectionModel().getMaxSelectionIndex() < getModel().getSize() -1);
    194194        }
    195        
     195
    196196        public void valueChanged(ListSelectionEvent e) {
    197             updateEnabledState();           
    198         }
    199     }
    200    
    201     class MoveUpAction extends AbstractAction implements ListSelectionListener{     
     197            updateEnabledState();
     198        }
     199    }
     200
     201    class MoveUpAction extends AbstractAction implements ListSelectionListener{
    202202        public MoveUpAction() {
    203203            putValue(NAME, tr("Move up"));
    204204            putValue(SHORT_DESCRIPTION, tr("Move the selected vias up by one position"));
    205205            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK));
    206             putValue(SMALL_ICON, ImageProvider.get("dialogs", "moveup"));
    207             updateEnabledState();
    208         }
    209        
     206            new ImageProvider("dialogs", "moveup").getResource().attachImageIcon(this);
     207            updateEnabledState();
     208        }
     209
    210210        public void actionPerformed(ActionEvent e) {
    211211            model.moveUp();
     
    219219            setEnabled(getSelectionModel().getMinSelectionIndex() > 0);
    220220        }
    221        
     221
    222222        public void valueChanged(ListSelectionEvent e) {
    223             updateEnabledState();           
     223            updateEnabledState();
    224224        }
    225225    }
     
    227227    class CopyAction extends AbstractAction implements ListSelectionListener {
    228228        private Action delegate;
    229        
     229
    230230        public CopyAction(){
    231231            putValue(NAME, tr("Copy"));
    232232            putValue(SHORT_DESCRIPTION, tr("Copy the selected vias to the clipboard"));
    233             putValue(SMALL_ICON, ImageProvider.get("copy"));
     233            new ImageProvider("copy").getResource().attachImageIcon(this);
    234234            putValue(ACCELERATOR_KEY, Shortcut.getCopyKeyStroke());
    235235            delegate = ViaList.this.getActionMap().get("copy");
    236236        }
    237237
    238         public void actionPerformed(ActionEvent e) {           
     238        public void actionPerformed(ActionEvent e) {
    239239            delegate.actionPerformed(e);
    240240        }
     
    243243            setEnabled(!model.getSelectedVias().isEmpty());
    244244        }
    245        
     245
    246246        public void valueChanged(ListSelectionEvent e) {
    247247            updateEnabledState();
    248248        }
    249249    }
    250    
     250
    251251    class PasteAction extends AbstractAction {
    252252        private Action delegate;
    253        
     253
    254254        public boolean canPaste() {
    255255            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    256256            for (DataFlavor df: clipboard.getAvailableDataFlavors()) {
    257257                if (df.equals(PrimitiveIdTransferable.PRIMITIVE_ID_LIST_FLAVOR)) return true;
    258             }           
    259             // FIXME: check whether there are selected objects in the JOSM copy/paste buffer 
     258            }
     259            // FIXME: check whether there are selected objects in the JOSM copy/paste buffer
    260260            return false;
    261261        }
    262        
     262
    263263        public PasteAction(){
    264264            putValue(NAME, tr("Paste"));
    265265            putValue(SHORT_DESCRIPTION, tr("Insert ''via'' objects from the clipboard"));
    266             putValue(SMALL_ICON, ImageProvider.get("paste"));
     266            new ImageProvider("paste").getResource().attachImageIcon(this);
    267267            putValue(ACCELERATOR_KEY, Shortcut.getPasteKeyStroke());
    268268            delegate = ViaList.this.getActionMap().get("paste");
     
    273273            setEnabled(canPaste());
    274274        }
    275        
    276         public void actionPerformed(ActionEvent e) {
    277             delegate.actionPerformed(e);           
    278         }
    279     }
    280    
     275
     276        public void actionPerformed(ActionEvent e) {
     277            delegate.actionPerformed(e);
     278        }
     279    }
     280
    281281    class ViaListPopupMenu extends JPopupMenu {
    282282        public ViaListPopupMenu() {
    283283            JMenuItem item = add(actCopy);
    284             item.setTransferHandler(transferHandler);           
     284            item.setTransferHandler(transferHandler);
    285285            item = add(actPaste);
    286286            actPaste.updateEnabledState();
     
    293293        }
    294294    }
    295    
     295
    296296    class ViaListPopupMenuLaucher extends PopupMenuLauncher {
    297297        @Override
     
    304304            }
    305305            new ViaListPopupMenu().show(ViaList.this, evt.getX(), evt.getY());
    306         }       
    307     }   
     306        }
     307    }
    308308}
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsListDialog.java

    r32375 r32386  
    200200        public EditAction() {
    201201            putValue(SHORT_DESCRIPTION,tr("Open an editor for the selected turn restriction"));
    202             new ImageProvider("dialogs", "edit").getResource().attachImageIcon(this);
     202            new ImageProvider("dialogs", "edit").getResource().attachImageIcon(this, true);
    203203            putValue(NAME, tr("Edit"));
    204204            setEnabled(false);
     
    261261        public DeleteAction() {
    262262            putValue(SHORT_DESCRIPTION,tr("Delete the selected turn restriction"));
    263             new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this);
     263            new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
    264264            putValue(NAME, tr("Delete"));
    265265            setEnabled(false);
     
    301301        public NewAction() {
    302302            putValue(SHORT_DESCRIPTION,tr("Create a new turn restriction"));
    303             new ImageProvider("new").getResource().attachImageIcon(this);
     303            new ImageProvider("new").getResource().attachImageIcon(this, true);
    304304            putValue(NAME, tr("New"));
    305305            updateEnabledState();
     
    341341        public SelectSelectedTurnRestrictions() {
    342342            putValue(SHORT_DESCRIPTION,tr("Set the current JOSM selection to the selected turn restrictions"));
    343             putValue(SMALL_ICON, ImageProvider.get("selectall"));
     343            new ImageProvider("selectall").getResource().attachImageIcon(this);
    344344            putValue(NAME, tr("Select in current data layer"));
    345345            setEnabled(false);
     
    376376        public ZoomToAction() {
    377377            putValue(SHORT_DESCRIPTION,tr("Zoom to the currently selected turn restrictions"));
    378             putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale/selection"));
     378            new ImageProvider("dialogs/autoscale/selection").getResource().attachImageIcon(this);
    379379            putValue(NAME, tr("Zoom to"));
    380380            setEnabled(false);
Note: See TracChangeset for help on using the changeset viewer.