Ignore:
Timestamp:
2015-06-20T23:42:21+02:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle: enable relevant whitespace checks and fix them

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/properties
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java

    r8390 r8510  
    6060                        otherCount = v.size();
    6161                    } else {
    62                         blankCount = (Integer)v.get("");
     62                        blankCount = (Integer) v.get("");
    6363                        otherCount = v.size()-1;
    6464                    }
     
    7575                        sb.append(trn("{0} different", "{0} different", otherCount, otherCount));
    7676                    }
    77                     if(blankCount > 0) {
     77                    if (blankCount > 0) {
    7878                        /* I18n: properties display partial string joined with comma */
    7979                        sb.append(trn(", {0} unset", ", {0} unset", blankCount, blankCount));
     
    8888                }
    8989            }
    90             ((JLabel)c).putClientProperty("html.disable", Boolean.TRUE); // Fix #8730
    91             ((JLabel)c).setText(str);
     90            ((JLabel) c).putClientProperty("html.disable", Boolean.TRUE); // Fix #8730
     91            ((JLabel) c).setText(str);
    9292            if (Main.pref.getBoolean("display.discardable-keys", false)) {
    9393                String key = null;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r8509 r8510  
    188188    private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true);
    189189
    190     private final transient HighlightHelper highlightHelper= new HighlightHelper();
     190    private final transient HighlightHelper highlightHelper = new HighlightHelper();
    191191
    192192    /**
     
    225225    };
    226226
    227     // <editor-fold defaultstate="collapsed" desc="Dialog construction and helper methods">
    228 
    229227    /**
    230228     * Create a new PropertiesDialog
     
    246244        boolean top = Main.pref.getBoolean("properties.presets.top", true);
    247245        bothTables.setLayout(new GridBagLayout());
    248         if(top) {
     246        if (top) {
    249247            bothTables.add(presets, GBC.std().fill(GBC.HORIZONTAL).insets(5, 2, 5, 2).anchor(GBC.NORTHWEST));
    250248            double epsilon = Double.MIN_VALUE; // need to set a weight or else anchor value is ignored
    251             bothTables.add(pluginHook, GBC.eol().insets(0,1,1,1).anchor(GBC.NORTHEAST).weight(epsilon, epsilon));
     249            bothTables.add(pluginHook, GBC.eol().insets(0, 1, 1, 1).anchor(GBC.NORTHEAST).weight(epsilon, epsilon));
    252250        }
    253251        bothTables.add(selectSth, GBC.eol().fill().insets(10, 10, 10, 10));
     
    256254        bothTables.add(membershipTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL));
    257255        bothTables.add(membershipTable, GBC.eol().fill(GBC.BOTH));
    258         if(!top) {
     256        if (!top) {
    259257            bothTables.add(presets, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 2, 5, 2));
    260258        }
     
    287285    private void buildTagsTable() {
    288286        // setting up the tags table
    289         tagData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")});
     287        tagData.setColumnIdentifiers(new String[]{tr("Key"), tr("Value")});
    290288        tagTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    291289        tagTable.getTableHeader().setReorderingAllowed(false);
     
    297295
    298296    private void buildMembershipTable() {
    299         membershipData.setColumnIdentifiers(new String[]{tr("Member Of"),tr("Role"),tr("Position")});
     297        membershipData.setColumnIdentifiers(new String[]{tr("Member Of"), tr("Role"), tr("Position")});
    300298        membershipTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    301299
     
    309307                    return this;
    310308                if (c instanceof JLabel) {
    311                     JLabel label = (JLabel)c;
    312                     Relation r = (Relation)value;
     309                    JLabel label = (JLabel) c;
     310                    Relation r = (Relation) value;
    313311                    label.setText(r.getDisplayName(DefaultNameFormatter.getInstance()));
    314312                    if (r.isDisabledAndHidden()) {
     
    326324                    return this;
    327325                Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
    328                 boolean isDisabledAndHidden = ((Relation)table.getValueAt(row, 0)).isDisabledAndHidden();
     326                boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();
    329327                if (c instanceof JLabel) {
    330328                    JLabel label = (JLabel) c;
     
    342340                    boolean isSelected, boolean hasFocus, int row, int column) {
    343341                Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
    344                 boolean isDisabledAndHidden = ((Relation)table.getValueAt(row, 0)).isDisabledAndHidden();
     342                boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();
    345343                if (c instanceof JLabel) {
    346                     JLabel label = (JLabel)c;
     344                    JLabel label = (JLabel) c;
    347345                    label.setText(((MemberInfo) table.getValueAt(row, 1)).getPositionString());
    348346                    if (isDisabledAndHidden) {
     
    416414                if (Main.isDisplayingMapView()) {
    417415                    int row = membershipTable.rowAtPoint(e.getPoint());
    418                     if (row>=0) {
     416                    if (row >= 0) {
    419417                        if (highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0))) {
    420418                            Main.map.mapView.repaint();
     
    462460        tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    463461                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter");
    464         tagTable.getActionMap().put("onTableEnter",editAction);
     462        tagTable.getActionMap().put("onTableEnter", editAction);
    465463        membershipTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    466                 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),"onTableEnter");
    467         membershipTable.getActionMap().put("onTableEnter",editAction);
     464                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter");
     465        membershipTable.getActionMap().put("onTableEnter", editAction);
    468466
    469467        // INSERT button = addAction, open "add tag" dialog
    470468        tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    471                 .put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0),"onTableInsert");
    472         tagTable.getActionMap().put("onTableInsert",addAction);
     469                .put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), "onTableInsert");
     470        tagTable.getActionMap().put("onTableInsert", addAction);
    473471
    474472        // unassign some standard shortcuts for JTable to allow upload / download / image browsing
     
    480478
    481479        tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    482                 .put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),"onCopy");
    483         tagTable.getActionMap().put("onCopy",copyKeyValueAction);
     480                .put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "onCopy");
     481        tagTable.getActionMap().put("onCopy", copyKeyValueAction);
    484482
    485483        // allow using enter to add tags for all look&feel configurations
     
    488486        // DEL button = deleteAction
    489487        getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
    490                 KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),"delete"
     488                KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"
    491489                );
    492490        getActionMap().put("delete", deleteAction);
     
    505503     */
    506504    private void editMembership(int row) {
    507         Relation relation = (Relation)membershipData.getValueAt(row, 0);
     505        Relation relation = (Relation) membershipData.getValueAt(row, 0);
    508506        Main.map.relationListDialog.selectRelation(relation);
    509507        RelationEditor.getEditor(
     
    515513
    516514    private int findRow(TableModel model, Object value) {
    517         for (int i=0; i<model.getRowCount(); i++) {
     515        for (int i = 0; i < model.getRowCount(); i++) {
    518516            if (model.getValueAt(i, 0).equals(value))
    519517                return i;
     
    529527        selectionChanged(null);
    530528    }
    531 
    532    // </editor-fold>
    533 
    534     // <editor-fold defaultstate="collapsed" desc="Event listeners methods">
    535529
    536530    @Override
     
    596590        selectedTag = editHelper.getChangedKey(); // select last added or last edited key by default
    597591        if (selectedTag == null && tagTable.getSelectedRowCount() == 1) {
    598             selectedTag = (String)tagData.getValueAt(tagTable.getSelectedRow(), 0);
     592            selectedTag = (String) tagData.getValueAt(tagTable.getSelectedRow(), 0);
    599593        }
    600594        if (membershipTable.getSelectedRowCount() == 1) {
    601             selectedRelation = (Relation)membershipData.getValueAt(membershipTable.getSelectedRow(), 0);
     595            selectedRelation = (Relation) membershipData.getValueAt(membershipTable.getSelectedRow(), 0);
    602596        }
    603597
     
    648642                    Relation r = (Relation) ref;
    649643                    MemberInfo mi = roles.get(r);
    650                     if(mi == null) {
     644                    if (mi == null) {
    651645                        mi = new MemberInfo(newSel);
    652646                    }
     
    696690        } else if (selectedRelation != null && (selectedIndex = findRow(membershipData, selectedRelation)) != -1) {
    697691            membershipTable.changeSelection(selectedIndex, 0, false, false);
    698         } else if(hasTags) {
     692        } else if (hasTags) {
    699693            tagTable.changeSelection(0, 0, false, false);
    700         } else if(hasMemberships) {
     694        } else if (hasMemberships) {
    701695            membershipTable.changeSelection(0, 0, false, false);
    702696        }
    703697
    704         if(tagData.getRowCount() != 0 || membershipData.getRowCount() != 0) {
    705             if(newSel.size() > 1) {
     698        if (tagData.getRowCount() != 0 || membershipData.getRowCount() != 0) {
     699            if (newSel.size() > 1) {
    706700                setTitle(tr("Objects: {2} / Tags: {0} / Memberships: {1}",
    707701                    tagData.getRowCount(), membershipData.getRowCount(), newSel.size()));
     
    734728    }
    735729
    736     // </editor-fold>
    737 
    738     // <editor-fold defaultstate="collapsed" desc="Methods that are called by plugins to extend fuctionality ">
    739 
    740730    /**
    741731     * Replies the tag popup menu handler.
     
    777767    }
    778768
    779     // </editor-fold>
    780 
    781      /**
     769    /**
    782770     * Class that watches for mouse clicks
    783771     * @author imi
    784772     */
    785773    public class MouseClickWatch extends MouseAdapter {
    786         @Override public void mouseClicked(MouseEvent e) {
     774        @Override
     775        public void mouseClicked(MouseEvent e) {
    787776            if (e.getClickCount() < 2) {
    788777                // single click, clear selection in other table not clicked in
     
    812801            }
    813802        }
    814         @Override public void mousePressed(MouseEvent e) {
     803
     804        @Override
     805        public void mousePressed(MouseEvent e) {
    815806            if (e.getSource() == tagTable) {
    816807                membershipTable.clearSelection();
     
    880871     */
    881872    public static class ReadOnlyTableModel extends DefaultTableModel {
    882         @Override public boolean isCellEditable(int row, int column) {
     873        @Override
     874        public boolean isCellEditable(int row, int column) {
    883875            return false;
    884876        }
    885         @Override public Class<?> getColumnClass(int columnIndex) {
     877
     878        @Override
     879        public Class<?> getColumnClass(int columnIndex) {
    886880            return String.class;
    887881        }
     
    902896        }
    903897
    904         protected void deleteTags(int[] rows){
     898        protected void deleteTags(int[] rows) {
    905899            // convert list of rows to HashMap (and find gap for nextKey)
    906900            Map<String, String> tags = new HashMap<>(rows.length);
     
    925919                    nextKeyIndex++;
    926920                }
    927                 nextKey = (String)tagData.getValueAt(nextKeyIndex, 0);
     921                nextKey = (String) tagData.getValueAt(nextKeyIndex, 0);
    928922            }
    929923
     
    938932
    939933        protected void deleteFromRelation(int row) {
    940             Relation cur = (Relation)membershipData.getValueAt(row, 0);
     934            Relation cur = (Relation) membershipData.getValueAt(row, 0);
    941935
    942936            Relation nextRelation = null;
    943937            int rowCount = membershipTable.getRowCount();
    944938            if (rowCount > 1) {
    945                 nextRelation = (Relation)membershipData.getValueAt(row + 1 < rowCount ? row + 1 : row - 1, 0);
     939                nextRelation = (Relation) membershipData.getValueAt(row + 1 < rowCount ? row + 1 : row - 1, 0);
    946940            }
    947941
     
    954948            ed.showDialog();
    955949
    956             if(ed.getValue() != 1)
     950            if (ed.getValue() != 1)
    957951                return;
    958952
     
    978972                int[] rows = membershipTable.getSelectedRows();
    979973                // delete from last relation to conserve row numbers in the table
    980                 for (int i=rows.length-1; i>=0; i--) {
     974                for (int i = rows.length-1; i >= 0; i--) {
    981975                    deleteFromRelation(rows[i]);
    982976                }
     
    10831077                } else if (membershipTable.getSelectedRowCount() == 1) {
    10841078                    row = membershipTable.getSelectedRow();
    1085                     String type = ((Relation)membershipData.getValueAt(row, 0)).get("type");
     1079                    String type = ((Relation) membershipData.getValueAt(row, 0)).get("type");
    10861080                    if (type != null) {
    10871081                        type = Utils.encodeUrl(type);
     
    11011095                }
    11021096
    1103                 Main.worker.execute(new Runnable(){
     1097                Main.worker.execute(new Runnable() {
    11041098                    @Override public void run() {
    11051099                        try {
     
    11081102                            for (URI u : uris) {
    11091103                                conn = Utils.openHttpConnection(u.toURL());
    1110                                 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000);
     1104                                conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);
    11111105
    11121106                                if (conn.getResponseCode() != 200) {
     
    11221116                                                .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=")
    11231117                                                ).toURL());
    1124                                         conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000);
     1118                                        conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);
    11251119                                    }
    11261120
     
    11871181                    return;
    11881182                for (OsmPrimitive p : sel) {
    1189                     Collection<String> s = getString(p,key);
     1183                    Collection<String> s = getString(p, key);
    11901184                    if (s != null) {
    11911185                        values.addAll(s);
     
    12011195    class CopyValueAction extends AbstractCopyAction {
    12021196
     1197        /**
     1198         * Constructs a new {@code CopyValueAction}.
     1199         */
    12031200        public CopyValueAction() {
    12041201            putValue(NAME, tr("Copy Value"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r8509 r8510  
    153153
    154154        String key = tagData.getValueAt(row, 0).toString();
    155         objKey=key;
     155        objKey = key;
    156156
    157157        @SuppressWarnings("unchecked")
     
    262262            @Override
    263263            public Component getListCellRendererComponent(JList<? extends AutoCompletionListItem> list,
    264                     AutoCompletionListItem value, int index, boolean isSelected,  boolean cellHasFocus){
     264                    AutoCompletionListItem value, int index, boolean isSelected,  boolean cellHasFocus) {
    265265                Component c = def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    266266                if (c instanceof JLabel) {
     
    280280
    281281        private EditTagDialog(String key, Map<String, Integer> map, final boolean initialFocusOnKey) {
    282             super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"),tr("Cancel")});
    283             setButtonIcons(new String[] {"ok","cancel"});
     282            super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"), tr("Cancel")});
     283            setButtonIcons(new String[] {"ok", "cancel"});
    284284            setCancelButton(2);
    285285            configureContextsensitiveHelp("/Dialog/EditValue", true /* show help button */);
     
    307307            keys.setSelectedItem(key);
    308308
    309             p.add(Box.createVerticalStrut(5),GBC.eol());
     309            p.add(Box.createVerticalStrut(5), GBC.eol());
    310310            p.add(new JLabel(tr("Key")), GBC.std());
    311311            p.add(Box.createHorizontalStrut(10), GBC.std());
     
    315315            Collections.sort(valueList, usedValuesAwareComparator);
    316316
    317             final String selection= m.size()!=1?tr("<different>"):m.entrySet().iterator().next().getKey();
     317            final String selection = m.size() != 1 ? tr("<different>") : m.entrySet().iterator().next().getKey();
    318318
    319319            values = new AutoCompletingComboBox(selection);
     
    324324            values.setSelectedItem(selection);
    325325            values.getEditor().setItem(selection);
    326             p.add(Box.createVerticalStrut(5),GBC.eol());
     326            p.add(Box.createVerticalStrut(5), GBC.eol());
    327327            p.add(new JLabel(tr("Value")), GBC.std());
    328328            p.add(Box.createHorizontalStrut(10), GBC.std());
     
    496496        protected FocusAdapter addFocusAdapter(final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) {
    497497           // get the combo box' editor component
    498            JTextComponent editor = (JTextComponent)values.getEditor().getEditorComponent();
     498           JTextComponent editor = (JTextComponent) values.getEditor().getEditorComponent();
    499499           // Refresh the values model when focus is gained
    500500           FocusAdapter focus = new FocusAdapter() {
     
    508508                   values.setPossibleACItems(valueList);
    509509                   values.getEditor().selectAll();
    510                    objKey=key;
     510                   objKey = key;
    511511               }
    512512           };
     
    517517        protected JPopupMenu popupMenu = new JPopupMenu() {
    518518            private JCheckBoxMenuItem fixTagLanguageCb = new JCheckBoxMenuItem(
    519                 new AbstractAction(tr("Use English language for tag by default")){
     519                new AbstractAction(tr("Use English language for tag by default")) {
    520520                @Override
    521521                public void actionPerformed(ActionEvent e) {
    522                     boolean use=((JCheckBoxMenuItem) e.getSource()).getState();
     522                    boolean use = ((JCheckBoxMenuItem) e.getSource()).getState();
    523523                    PROPERTY_FIX_TAG_LOCALE.put(use);
    524524                    keys.setFixedLocale(use);
     
    539539
    540540        public AddTagsDialog() {
    541             super(Main.parent, tr("Add value?"), new String[] {tr("OK"),tr("Cancel")});
    542             setButtonIcons(new String[] {"ok","cancel"});
     541            super(Main.parent, tr("Add value?"), new String[] {tr("OK"), tr("Cancel")});
     542            setButtonIcons(new String[] {"ok", "cancel"});
    543543            setCancelButton(2);
    544544            configureContextsensitiveHelp("/Dialog/AddValue", true /* show help button */);
     
    549549
    550550            mainPanel.add(new JLabel("<html>"+trn("This will change up to {0} object.",
    551                 "This will change up to {0} objects.", sel.size(),sel.size())
     551                "This will change up to {0} objects.", sel.size(), sel.size())
    552552                +"<br><br>"+tr("Please select a key")), GBC.eol().fill(GBC.HORIZONTAL));
    553553
     
    624624            });
    625625            JCheckBoxMenuItem rememberLastTags = new JCheckBoxMenuItem(
    626                 new AbstractAction(tr("Remember last used tags after a restart")){
     626                new AbstractAction(tr("Remember last used tags after a restart")) {
    627627                @Override
    628628                public void actionPerformed(ActionEvent e) {
    629                     boolean sel=((JCheckBoxMenuItem) e.getSource()).getState();
     629                    boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState();
    630630                    PROPERTY_REMEMBER_TAGS.put(sel);
    631631                    if (sel) saveTagsIfNeeded();
     
    650650            lines.add(code(KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK)+"+"+KeyEvent.getKeyText(KeyEvent.VK_ENTER))
    651651                    +tr("to add without closing the dialog"));
    652             sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
     652            sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK);
    653653            if (sc != null) {
    654654                lines.add(code(sc.getKeyText()) + tr("to add first suggestion without closing the dialog"));
     
    667667            try {
    668668                int v = Integer.parseInt(s);
    669                 if (v>=0 && v<=MAX_LRU_TAGS_NUMBER) {
     669                if (v >= 0 && v <= MAX_LRU_TAGS_NUMBER) {
    670670                    PROPERTY_RECENT_TAGS_NUMBER.put(v);
    671671                    return;
     
    762762                            action.actionPerformed(null);
    763763                            // add tags and close window on double-click
    764                             if (e.getClickCount()>1) {
     764                            if (e.getClickCount() > 1) {
    765765                                buttonAction(0, null); // emulate OK click and close the dialog
    766766                            }
Note: See TracChangeset for help on using the changeset viewer.