Changeset 32913 in osm for applications/editors


Ignore:
Timestamp:
2016-09-03T17:06:49+02:00 (8 years ago)
Author:
donvip
Message:

fix some error-prone warnings

Location:
applications/editors/josm/plugins/tageditor
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java

    r32508 r32913  
    4646/**
    4747 * The dialog for editing name/value-pairs (aka <em>tags</em>) associated with {@link OsmPrimitive}s.
    48  * 
     48 *
    4949 */
    5050@SuppressWarnings("serial")
     
    5757    /**
    5858     * Access to the singleton instance
    59      * 
     59     *
    6060     * @return the singleton instance of the dialog
    6161     */
     
    9191    protected JPanel buildButtonRow() {
    9292        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
    93        
     93
    9494        // the ok button
    9595        //
     
    108108        //
    109109        tagEditor = new TagEditor();
    110        
     110
    111111        // create the auto completion list viewer and connect it
    112112        // to the tag editor
     
    120120        JPanel pnlTagGrid = new JPanel();
    121121        pnlTagGrid.setLayout(new BorderLayout());
    122        
    123        
     122
     123
    124124        pnlTagGrid.add(tagEditor, BorderLayout.CENTER);
    125125        pnlTagGrid.add(aclViewer, BorderLayout.EAST);
    126126        pnlTagGrid.setBorder(BorderFactory.createEmptyBorder(5, 0,0,0));
    127        
     127
    128128        JSplitPane splitPane = new JSplitPane(
    129129                JSplitPane.HORIZONTAL_SPLIT,
    130                 tagEditor, 
     130                tagEditor,
    131131                aclViewer
    132132        );
    133133        splitPane.setOneTouchExpandable(false);
    134         splitPane.setDividerLocation(600);     
     134        splitPane.setDividerLocation(600);
    135135        pnlTagGrid.add(splitPane, BorderLayout.CENTER);
    136136        return pnlTagGrid;
    137137    }
    138        
     138
    139139    /**
    140140     * build the GUI
     
    148148        setSize(PREFERRED_SIZE);
    149149        setTitle(tr("JOSM Tag Editor Plugin"));
    150        
     150
    151151        JPanel pnlTagGrid = buildTagGridPanel();
    152152
     
    156156        presetSelector.addPresetSelectorListener(
    157157                new IPresetSelectorListener() {
     158                    @Override
    158159                    public void itemSelected(TaggingPreset item) {
    159160                        tagEditor.stopEditing();
     
    174175        tagSelector.addTagSelectorListener(
    175176                new ITagSelectorListener() {
     177                    @Override
    176178                    public void itemSelected(KeyValuePair pair) {
    177179                        tagEditor.stopEditing();
     
    192194        tabbedPane.add(pnlTagSelector, tr("Tags"));
    193195
    194        
     196
    195197        // create split pane
    196198        //
    197199        JSplitPane splitPane = new JSplitPane(
    198200                JSplitPane.VERTICAL_SPLIT,
    199                 tabbedPane, 
     201                tabbedPane,
    200202                pnlTagGrid
    201203        );
     
    216218                    @Override public void windowActivated(WindowEvent e) {
    217219                        SwingUtilities.invokeLater(new Runnable(){
     220                            @Override
    218221                            public void run()
    219222                            {
     
    291294        }
    292295
     296        @Override
    293297        public void actionPerformed(ActionEvent arg0) {
    294298            setVisible(false);
     
    305309        }
    306310
     311        @Override
    307312        public void actionPerformed(ActionEvent e) {
    308313            run();
     
    318323        }
    319324
     325        @Override
    320326        public void propertyChange(PropertyChangeEvent evt) {
    321327            if (! evt.getPropertyName().equals(TagEditorModel.PROP_DIRTY))
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java

    r30703 r32913  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.tageditor.ac;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.Component;
     
    1214import javax.swing.UIManager;
    1315import javax.swing.table.TableCellRenderer;
     16
     17import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;
    1418import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem;
    15 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;
    16 import static org.openstreetmap.josm.tools.I18n.tr;
    1719
    1820/**
    1921 * This is the table cell renderer for the list of auto completion list items.
    20  * 
     22 *
    2123 */
    2224public class AutoCompletionListRenderer extends JLabel implements TableCellRenderer {
     
    6668    /**
    6769     * prepares the renderer for rendering a specific icon
    68      * 
     70     *
    6971     * @param item the item to be rendered
    7072     */
     
    101103    }
    102104
     105    @Override
    103106    public Component getTableCellRendererComponent(JTable table, Object value,
    104107            boolean isSelected, boolean hasFocus, int row, int column) {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetItemListCellRenderer.java

    r31615 r32913  
    1616    //private static final Logger logger = Logger.getLogger(PresetItemListCellRenderer.class.getName());
    1717
     18    @Override
    1819    public Component getListCellRendererComponent(JList<? extends TaggingPreset> list, TaggingPreset item,
    1920            int index, boolean isSelected, boolean cellHasFocus) {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetManager.java

    r31615 r32913  
    4141
    4242        presets.addItemListener(
    43                 new ItemListener(){
     43                new ItemListener() {
     44                    @Override
    4445                    public void itemStateChanged(ItemEvent e) {
    4546                        syncWidgetStates();
     
    5354        btnHighlight = new JButton(tr("Highlight"));
    5455        btnHighlight.addActionListener(
    55                 new ActionListener()  {
     56                new ActionListener() {
     57                    @Override
    5658                    public void actionPerformed(ActionEvent arg0) {
    5759                        highlightCurrentPreset();
     
    6567        btnRemove.addActionListener(
    6668                new ActionListener()  {
     69                    @Override
    6770                    public void actionPerformed(ActionEvent arg0) {
    6871                        removeCurrentPreset();
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java

    r31560 r32913  
    2828 *   <li>the main table with the tag names and tag values
    2929 * </ul>
    30  * 
     30 *
    3131 *  This component depends on a couple of other components which have to be
    3232 *  injected with the respective setter methods:
     
    4747 *     AutoCompletionCache autoCompletionCache = ... // init the auto completion cache
    4848 *     TagEditorModel model = ... // init the tag editor model
    49  * 
     49 *
    5050 *     TagEditor tagEditor = new TagEditor();
    5151 *     tagEditor.setTagEditorModel(model);
     
    6161    private TagTable tblTagEditor;
    6262    private PresetManager presetManager;
    63    
     63
    6464     /**
    6565     * builds the panel with the button row
     
    8383        return pnl;
    8484    }
    85    
     85
    8686    public void addComponentNotStoppingCellEditing(Component c) {
    8787        tblTagEditor.addComponentNotStoppingCellEditing(c);
    8888    }
    89    
     89
    9090    /**
    9191     * builds the GUI
     
    9696        DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel();
    9797        DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel();
    98        
     98
    9999        tagEditorModel = new TagEditorModel(rowSelectionModel,colSelectionModel);
    100        
     100
    101101        // build the scrollable table for editing tag names and tag values
    102102        //
     
    129129        gc.anchor = GridBagConstraints.CENTER;
    130130        pnl.add(pnlTagTable,gc);
    131        
     131
    132132        return pnl;
    133133    }
    134    
     134
    135135    /**
    136136     * builds the GUI
    137      * 
     137     *
    138138     */
    139139    protected void build() {
    140140        setLayout(new BorderLayout());
    141        
     141
    142142        add(buildTagEditorPanel(), BorderLayout.CENTER);
    143143
     
    163163        return tagEditorModel;
    164164    }
    165    
     165
    166166    public void clearSelection() {
    167167        tblTagEditor.getSelectionModel().clearSelection();
     
    174174        }
    175175    }
    176    
     176
    177177    public void setAutoCompletionList(AutoCompletionList autoCompletionList) {
    178178        tblTagEditor.setAutoCompletionList(autoCompletionList);
     
    183183    }
    184184
     185    @Override
    185186    public void autoCompletionItemSelected(String item) {
    186187        logger.info("autocompletion item selected ...");
     
    194195        tblTagEditor.requestFocusInCell(0,0);
    195196    }
    196    
     197
    197198    public TagEditorModel getModel() {
    198199        return tagEditorModel;
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagSpecificationAwareTagCellEditor.java

    r31560 r32913  
    2525     * values from the current JOSM data set. Keys already present in the
    2626     * current tag model are removed from the auto completion list.
    27      * 
     27     *
    2828     * @param model  the tag editor model
    2929     * @param currentTag  the current tag
    3030     */
    31     protected void initAutoCompletionListForKeys(TagEditorModel model, TagModel currentTag) {       
     31    protected void initAutoCompletionListForKeys(TagEditorModel model, TagModel currentTag) {
    3232        if (getAutoCompletionList() == null) {
    3333            logger.warning("autoCompletionList is null. Make sure an instance of AutoCompletionList is injected into TableCellEditor.");
     
    7272     * set of standard values for a given key and the set of values present in the
    7373     * current data set for the given key.
    74      * 
     74     *
    7575     * @param forKey the key
    7676     */
     77    @Override
    7778    protected void initAutoCompletionListForValues(String forKey) {
    7879
     
    8384        autoCompletionList.clear();
    8485        autocomplete.populateWithTagValues(autoCompletionList, forKey);
    85        
     86
    8687        AutoCompletionContext context = new AutoCompletionContext();
    8788        try {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTableCellRenderer.java

    r31615 r32913  
    2323 */
    2424public class TagTableCellRenderer extends JLabel implements TableCellRenderer  {
    25    
     25
    2626    //private static Logger logger = Logger.getLogger(TagTableCellRenderer.class.getName());
    2727    public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204);
    28        
     28
    2929    private Font fontStandard = null;
    3030    private Font fontItalic = null;
    31    
     31
    3232    public TagTableCellRenderer() {
    3333        fontStandard = getFont();
     
    3636        setBorder(new EmptyBorder(5,5,5,5));
    3737    }
    38    
     38
    3939    /**
    4040     * renders the name of a tag in the second column of
    4141     * the table
    42      * 
    43      * @param tag  the tag 
     42     *
     43     * @param tag  the tag
    4444     */
    4545    protected void renderTagName(TagModel tag) {
    4646        setText(tag.getName());
    4747    }
    48    
     48
    4949    /**
    50      * renders the value of a a tag in the third column of 
     50     * renders the value of a a tag in the third column of
    5151     * the table
    52      * 
    53      * @param tag  the  tag 
     52     *
     53     * @param tag  the  tag
    5454     */
    5555    protected void renderTagValue(TagModel tag) {
     
    6363        }
    6464    }
    65    
     65
    6666    /**
    67      * resets the renderer 
     67     * resets the renderer
    6868     */
    6969    protected void resetRenderer() {
     
    7272        setFont(fontStandard);
    7373    }
    74    
     74
    7575    protected TagEditorModel getModel(JTable table) {
    7676        return (TagEditorModel)table.getModel();
    7777    }
    78    
     78
    7979    protected boolean belongsToSelectedPreset(TagModel tagModel, TagEditorModel model) {
    80        
     80
    8181        // current tag is empty or consists of whitespace only => can't belong to
    8282        // a selected preset
     
    8585            return false;
    8686        }
    87        
    88         // no current preset selected? 
     87
     88        // no current preset selected?
    8989        //
    9090        TaggingPreset item = (TaggingPreset)model.getAppliedPresetsModel().getSelectedItem();
     
    9292            return false;
    9393        }
    94        
     94
    9595        for(AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) {
    9696            if (tag.getValue() == null) {
    9797                if (tagModel.getName().equals(tag.getKey())) {
    98                     return true; 
     98                    return true;
    9999                }
    100100            } else {
    101101                if (tagModel.getName().equals(tag.getKey())
    102102                    && tagModel.getValue().equals(tag.getValue())) {
    103                     return true; 
     103                    return true;
    104104                }
    105105            }
    106         }       
     106        }
    107107        return false;
    108108    }
    109    
     109
    110110    /**
    111111     * renders the background color. The default color is white. It is
    112112     * set to {@see TableCellRenderer#BG_COLOR_HIGHLIGHTED} if this cell
    113      * displays the tag which is suggested by the currently selected 
     113     * displays the tag which is suggested by the currently selected
    114114     * preset.
    115      * 
    116      * @param tagModel the tag model 
    117      * @param model the tag editor model 
     115     *
     116     * @param tagModel the tag model
     117     * @param model the tag editor model
    118118     */
    119119    protected void renderColor(TagModel tagModel, TagEditorModel model, boolean isSelected) {
     
    124124            setBackground(UIManager.getColor("Table.background"));
    125125            setForeground(UIManager.getColor("Table.foreground"));
    126         }       
     126        }
    127127        if (belongsToSelectedPreset(tagModel, model)) {
    128128            setBackground(BG_COLOR_HIGHLIGHTED);
    129129        }
    130130    }
    131    
     131
    132132    /**
    133      * replies the cell renderer component for a specific cell 
    134      * 
     133     * replies the cell renderer component for a specific cell
     134     *
    135135     * @param table  the table
    136136     * @param value the value to be rendered
    137      * @param isSelected  true, if the value is selected 
    138      * @param hasFocus true, if the cell has focus 
    139      * @param rowIndex the row index 
    140      * @param vColIndex the column index 
    141      * 
    142      * @return the renderer component 
     137     * @param isSelected  true, if the value is selected
     138     * @param hasFocus true, if the cell has focus
     139     * @param rowIndex the row index
     140     * @param vColIndex the column index
     141     *
     142     * @return the renderer component
    143143     */
     144    @Override
    144145    public Component getTableCellRendererComponent(JTable table, Object value,
    145146            boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
    146        
     147
    147148        resetRenderer();
    148149        TagModel tagModel  = (TagModel)value;
    149         switch(vColIndex) { 
     150        switch(vColIndex) {
    150151            case 0: renderTagName(tagModel); break;
    151152            case 1: renderTagValue(tagModel); break;
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/NameIconCellRenderer.java

    r31615 r32913  
    1414public class NameIconCellRenderer extends JLabel implements TableCellRenderer {
    1515
    16     //private static Logger logger = Logger.getLogger(NameIconCellRenderer.class.getName());
    1716    public static final Color BG_COLOR_SELECTED = new Color(143,170,255);
    1817
     
    2625    }
    2726
     27    @Override
    2828    public Component getTableCellRendererComponent(JTable table, Object value,
    2929            boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTableModel.java

    r31615 r32913  
    5353    }
    5454
     55    @Override
    5556    public int getColumnCount() {
    5657        return 2;
    5758    }
    5859
     60    @Override
    5961    public int getRowCount() {
    6062        return visibleItems.size();
    6163    }
    6264
     65    @Override
    6366    public Object getValueAt(int rowIndex, int columnIndex) {
    6467        TaggingPreset item = visibleItems.get(rowIndex);
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/TabularPresetSelector.java

    r31615 r32913  
    5555        btn.addActionListener(
    5656                new ActionListener() {
     57                    @Override
    5758                    public void actionPerformed(ActionEvent e) {
    5859                        tfFilter.setText("");
     
    9596        presetsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0));
    9697        ActionListener enterAction = new ActionListener() {
     98            @Override
    9799            public void actionPerformed(ActionEvent e) {
    98100                int rowNum = presetsTable.getSelectedRow();
     
    120122        btnApply.addActionListener(
    121123                new ActionListener() {
     124                    @Override
    122125                    public void actionPerformed(ActionEvent arg0) {
    123126                        int row = presetsTable.getSelectedRow();
     
    141144        tfFilter.getDocument().addDocumentListener(
    142145                new DocumentListener() {
     146                    @Override
    143147                    public void changedUpdate(DocumentEvent arg0) {
    144148                        onUpdate();
    145149                    }
    146150
     151                    @Override
    147152                    public void insertUpdate(DocumentEvent arg0) {
    148153                        onUpdate();
    149154                    }
    150155
     156                    @Override
    151157                    public void removeUpdate(DocumentEvent arg0) {
    152158                        onUpdate();
     
    161167        tfFilter.addActionListener(
    162168                new ActionListener() {
     169                    @Override
    163170                    public void actionPerformed(ActionEvent e) {
    164171                        filter(tfFilter.getText());
     
    171178        presetsTable.getSelectionModel().addListSelectionListener(
    172179                new ListSelectionListener() {
     180                    @Override
    173181                    public void valueChanged(ListSelectionEvent e) {
    174182                        btnApply.setEnabled(presetsTable.getSelectedRowCount() != 0);
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecifications.java

    r30738 r32913  
    7474        }
    7575        try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
    76                 TagSpecifications spec = new TagSpecifications();
    77                 spec.load(reader);
    78                 instance = spec;
     76            TagSpecifications spec = new TagSpecifications();
     77            spec.load(reader);
     78            instance = spec;
    7979        }
    8080    }
     
    350350    }
    351351
    352     class ResourceEntityResolver implements EntityResolver {
     352    static class ResourceEntityResolver implements EntityResolver {
    353353
    354354        @Override
     
    366366    }
    367367
    368     static public void main(String args[]) throws Exception{
     368    public static void main(String args[]) throws Exception{
    369369        TagSpecifications.loadFromResources();
    370370    }
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/KeyValueCellRenderer.java

    r30488 r32913  
    1212public class KeyValueCellRenderer extends JLabel implements TableCellRenderer  {
    1313
    14     //private static final Logger logger = Logger.getLogger(KeyValueCellRenderer.class.getName());
    15 
    1614    protected void init() {
    1715        setFont(new Font("Courier",Font.PLAIN,getFont().getSize()));
     
    2321    }
    2422
     23    @Override
    2524    public Component getTableCellRendererComponent(JTable table, Object value,
    2625            boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TabularTagSelector.java

    r30737 r32913  
    5151        btn.addActionListener(
    5252                new ActionListener() {
     53                    @Override
    5354                    public void actionPerformed(ActionEvent e) {
    5455                        tfFilter.setText("");
     
    9293        tagsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0));
    9394        ActionListener enterAction = new ActionListener() {
     95            @Override
    9496            public void actionPerformed(ActionEvent e) {
    9597                int rowNum = tagsTable.getSelectedRow();
     
    118120        btnApply.addActionListener(
    119121                new ActionListener() {
     122                    @Override
    120123                    public void actionPerformed(ActionEvent arg0) {
    121124                        int row = tagsTable.getSelectedRow();
     
    141144        tfFilter.getDocument().addDocumentListener(
    142145                new DocumentListener() {
     146                    @Override
    143147                    public void changedUpdate(DocumentEvent arg0) {
    144148                        onUpdate();
    145149                    }
    146150
     151                    @Override
    147152                    public void insertUpdate(DocumentEvent arg0) {
    148153                        onUpdate();
    149154                    }
    150155
     156                    @Override
    151157                    public void removeUpdate(DocumentEvent arg0) {
    152158                        onUpdate();
     
    161167        tfFilter.addActionListener(
    162168                new ActionListener() {
     169                    @Override
    163170                    public void actionPerformed(ActionEvent e) {
    164171                        filter(tfFilter.getText());
     
    171178        tagsTable.getSelectionModel().addListSelectionListener(
    172179                new ListSelectionListener() {
     180                    @Override
    173181                    public void valueChanged(ListSelectionEvent e) {
    174182                        btnApply.setEnabled(tagsTable.getSelectedRowCount() != 0);
     
    177185        );
    178186
    179 
    180187        // load the set of presets and bind them to the preset table
    181188        //
    182189        tagsTable.getSelectionModel().clearSelection();
    183190        btnApply.setEnabled(false);
    184 
    185191    }
    186192
     
    188194        build();
    189195    }
    190 
    191196
    192197    public void filter(String filter) {
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableModel.java

    r30737 r32913  
    3131                items,
    3232                new Comparator<KeyValuePair>() {
     33                    @Override
    3334                    public int compare(KeyValuePair self,
    3435                            KeyValuePair other) {
     
    6768    }
    6869
     70    @Override
    6971    public int getColumnCount() {
    7072        return 2;
    7173    }
    7274
     75    @Override
    7376    public int getRowCount() {
    7477        return visibleItems.size();
    7578    }
    7679
     80    @Override
    7781    public Object getValueAt(int row, int col) {
    7882        KeyValuePair pair = visibleItems.get(row);
Note: See TracChangeset for help on using the changeset viewer.