Changeset 6623 in josm


Ignore:
Timestamp:
2014-01-04T06:39:00+01:00 (6 years ago)
Author:
Don-vip
Message:

fix Sonar issues

Location:
trunk/src/org/openstreetmap/josm
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r6608 r6623  
    211211                return null;
    212212            // try to zoom to the first selected layer
    213             //
    214213            Layer l = getFirstSelectedLayer();
    215214            if (l == null) return null;
     
    245244            // ensure reasonable zoom level when zooming onto single nodes.
    246245            v.enlargeToMinDegrees(0.0005);
    247         }
    248         else if (mode.equals("download")) {
     246        } else if (mode.equals("download")) {
    249247            Bounds bounds = DownloadDialog.getSavedDownloadBounds();
    250248            if (bounds != null) {
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r6622 r6623  
    6161    /**
    6262     * Constructs a new {@code CreateMultipolygonAction}.
     63     * @param update {@code true} if the multipolygon must be updated, {@code false} if it must be created
    6364     */
    6465    public CreateMultipolygonAction(final boolean update) {
    6566        super(getName(update), "multipoly_create", getName(update),
    66                 update
    67                         ? null
     67                update  ? null
    6868                        : Shortcut.registerShortcut("tools:multipoly", tr("Tool: {0}", getName(false)), KeyEvent.VK_A, Shortcut.ALT_CTRL),
    6969                true, update ? "multipoly_update" : "multipoly_create", true);
     
    7373    private static String getName(boolean update) {
    7474        return update ? tr("Update multipolygon") : tr("Create multipolygon");
     75    }
     76   
     77    private class CreateUpdateMultipolygonTask implements Runnable {
     78        private final Collection<Way> selectedWays;
     79        private final Relation multipolygonRelation;
     80
     81        public CreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) {
     82            this.selectedWays = selectedWays;
     83            this.multipolygonRelation = multipolygonRelation;
     84        }
     85
     86        @Override
     87        public void run() {
     88            final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation);
     89            if (commandAndRelation == null) {
     90                return;
     91            }
     92            final Command command = commandAndRelation.a;
     93            final Relation relation = commandAndRelation.b;
     94
     95
     96            // to avoid EDT violations
     97            SwingUtilities.invokeLater(new Runnable() {
     98                @Override
     99                public void run() {
     100                    Main.main.undoRedo.add(command);
     101                }
     102            });
     103
     104            // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
     105            // knows about the new relation before we try to select it.
     106            // (Yes, we are already in event dispatch thread. But DatasetEventManager
     107            // uses 'SwingUtilities.invokeLater' to fire events so we have to do
     108            // the same.)
     109            SwingUtilities.invokeLater(new Runnable() {
     110                @Override
     111                public void run() {
     112                    Main.map.relationListDialog.selectRelation(relation);
     113                    if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) {
     114                        //Open relation edit window, if set up in preferences
     115                        RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null);
     116
     117                        editor.setModal(true);
     118                        editor.setVisible(true);
     119                    }
     120                }
     121            });
     122        }
    75123    }
    76124
     
    109157                : null;
    110158
    111         // runnable to create/update multipolygon relation
    112         final Runnable createOrUpdateMultipolygonTask = new Runnable() {
    113             @Override
    114             public void run() {
    115                 final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation);
    116                 if (commandAndRelation == null) {
    117                     return;
    118                 }
    119                 final Command command = commandAndRelation.a;
    120                 final Relation relation = commandAndRelation.b;
    121 
    122 
    123                 // to avoid EDT violations
    124                 SwingUtilities.invokeLater(new Runnable() {
    125                     @Override
    126                     public void run() {
    127                         Main.main.undoRedo.add(command);
    128                     }
    129                 });
    130 
    131                 // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
    132                 // knows about the new relation before we try to select it.
    133                 // (Yes, we are already in event dispatch thread. But DatasetEventManager
    134                 // uses 'SwingUtilities.invokeLater' to fire events so we have to do
    135                 // the same.)
    136                 SwingUtilities.invokeLater(new Runnable() {
    137                     @Override
    138                     public void run() {
    139                         Main.map.relationListDialog.selectRelation(relation);
    140                         if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) {
    141                             //Open relation edit window, if set up in preferences
    142                             RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null);
    143 
    144                             editor.setModal(true);
    145                             editor.setVisible(true);
    146                         }
    147                     }
    148                 });
    149             }
    150         };
    151 
    152159        // download incomplete relation if necessary
    153160        if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) {
     
    155162        }
    156163        // create/update multipolygon relation
    157         Main.worker.submit(createOrUpdateMultipolygonTask);
     164        Main.worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation));
    158165
    159166    }
     
    181188
    182189        // add ways of existing relation to include them in polygon analysis
    183         selectedWays = new HashSet<Way>(selectedWays);
    184         selectedWays.addAll(selectedMultipolygonRelation.getMemberPrimitives(Way.class));
    185 
    186         final MultipolygonCreate polygon = analyzeWays(selectedWays, true);
     190        Set<Way> ways = new HashSet<Way>(selectedWays);
     191        ways.addAll(selectedMultipolygonRelation.getMemberPrimitives(Way.class));
     192
     193        final MultipolygonCreate polygon = analyzeWays(ways, true);
    187194        if (polygon == null) {
    188195            return null; //could not make multipolygon.
     
    206213
    207214    /**
    208      * Returns a pair of a multipolygon creating/modifying {@link Command} as well as the multipolygon {@link Relation}.
     215     * Returns a {@link Pair} of a multipolygon creating/modifying {@link Command} as well as the multipolygon {@link Relation}.
    209216     */
    210217    public static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) {
     
    309316    }
    310317
    311     static public final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
     318    public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
    312319
    313320    /**
  • trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java

    r6603 r6623  
    44import java.util.Collection;
    55import java.util.LinkedList;
     6import java.util.Set;
    67import java.util.TreeSet;
    78
     
    2021     * outer endpoints of selected ways
    2122     */
    22     TreeSet<Node> outerNodes;
     23    Set<Node> outerNodes;
    2324    /**
    2425     * endpoints of selected ways
    2526     */
    26     TreeSet<Node> nodes;
     27    Set<Node> nodes;
    2728
    2829    /**
  • trunk/src/org/openstreetmap/josm/data/osm/history/History.java

    r6316 r6623  
    209209    }
    210210
    211     public HistoryOsmPrimitive get(int idx) {
     211    public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException {
    212212        if (idx < 0 || idx >= versions.size())
    213213            throw new IndexOutOfBoundsException(MessageFormat.format("Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx));
     
    231231    }
    232232
    233     public boolean isEmpty() {
     233    /**
     234     * Returns true if this history contains no version.
     235     * @return {@code true} if this history contains no version, {@code false} otherwise
     236     */
     237    public final boolean isEmpty() {
    234238        return versions.isEmpty();
    235239    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r6608 r6623  
    156156        double enlargeEast = Math.min(maxEnlargePercent - 10*Math.log(diffEast), 1)/100;
    157157        double enlargeNorth = Math.min(maxEnlargePercent - 10*Math.log(diffNorth), 1)/100;
    158         System.out.println(enlargeEast);
    159158
    160159        visit(bounds.getMin().add(-enlargeEast/2, -enlargeNorth/2));
    161160        visit(bounds.getMax().add(+enlargeEast/2, +enlargeNorth/2));
    162161    }
    163 
    164162
    165163    /**
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r6591 r6623  
    3434 * @author frsantos
    3535 */
    36 public class Test extends AbstractVisitor
    37 {
     36public class Test extends AbstractVisitor {
     37
    3838    /** Name of the test */
    3939    protected final String name;
     
    9090     * A test that forwards all primitives to {@link #check(OsmPrimitive)}.
    9191     */
    92     public static abstract class TagTest extends Test {
     92    public abstract static class TagTest extends Test {
     93        /**
     94         * Constructs a new {@code TagTest} with given name and description.
     95         * @param name The test name
     96         * @param description The test description
     97         */
    9398        public TagTest(String name, String description) {
    9499            super(name, description);
    95100        }
    96101
     102        /**
     103         * Constructs a new {@code TagTest} with given name.
     104         * @param name The test name
     105         */
    97106        public TagTest(String name) {
    98107            super(name);
    99108        }
    100109
     110        /**
     111         * Checks the tags of the given primitive.
     112         * @param p The primitive to test
     113         */
    101114        public abstract void check(final OsmPrimitive p);
    102115
     
    163176     * actions and destroy the used structures.
    164177     * <p>
    165      * If you override this method, don't forget to cleanup {@link #progressMonitor}
     178     * If you override this method, don't forget to cleanup {@code progressMonitor}
    166179     * (most overrides call {@code super.endTest()} to do this).
    167180     */
     
    191204    }
    192205
     206    /**
     207     * Determines if the primitive is usable for tests.
     208     * @param p The primitive
     209     * @return {@code true} if the primitive can be tested, {@code false} otherwise
     210     */
    193211    public boolean isPrimitiveUsable(OsmPrimitive p) {
    194212        return p.isUsable() && (!(p instanceof Way) || (((Way) p).getNodesCount() > 1)); // test only Ways with at least 2 nodes
     
    222240    /**
    223241     * Called when the used submits the preferences
     242     * @return {@code true} if restart is required, {@code false} otherwise
    224243     */
    225244    public boolean ok() {
     
    265284    }
    266285
     286    /**
     287     * Returns the test name.
     288     * @return The test name
     289     */
    267290    public String getName() {
    268291        return name;
    269292    }
    270293
     294    /**
     295     * Determines if the test has been canceled.
     296     * @return {@code true} if the test has been canceled, {@code false} otherwise
     297     */
    271298    public boolean isCanceled() {
    272299        return progressMonitor.isCanceled();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r6581 r6623  
    3333public abstract class CrossingWays extends Test {
    3434    protected static final int CROSSING_WAYS = 601;
     35   
     36    private static final String HIGHWAY = "highway";
     37    private static final String RAILWAY = "railway";
     38    private static final String WATERWAY = "waterway";
    3539
    3640    /** All way segments, grouped by cells */
     
    4751            return super.isPrimitiveUsable(w)
    4852                    && !isProposedOrAbandoned(w)
    49                     && (w.hasKey("highway")
    50                     || w.hasKey("waterway")
    51                     || (w.hasKey("railway") && !isSubwayOrTram(w))
     53                    && (w.hasKey(HIGHWAY)
     54                    || w.hasKey(WATERWAY)
     55                    || (w.hasKey(RAILWAY) && !isSubwayOrTram(w))
    5256                    || isCoastline(w)
    5357                    || isBuilding(w));
     
    5963                return true;
    6064            }
    61             if (w1.hasKey("highway") && w2.hasKey("highway") && !Utils.equal(w1.get("level"), w2.get("level"))) {
     65            if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Utils.equal(w1.get("level"), w2.get("level"))) {
    6266                return true;
    6367            }
     
    6872                return true;
    6973            }
    70             if ((w1.hasTag("waterway", "river") && w2.hasTag("waterway", "riverbank"))
    71                     || (w2.hasTag("waterway", "river") && w1.hasTag("waterway", "riverbank"))) {
     74            if ((w1.hasTag(WATERWAY, "river") && w2.hasTag(WATERWAY, "riverbank"))
     75                    || (w2.hasTag(WATERWAY, "river") && w1.hasTag(WATERWAY, "riverbank"))) {
    7276                return true;
    7377            }
     
    8286            if (isBuilding(w1)) {
    8387                return ("Crossing buildings");
    84             } else if (w1.hasKey("waterway") && w2.hasKey("waterway")) {
     88            } else if (w1.hasKey(WATERWAY) && w2.hasKey(WATERWAY)) {
    8589                return tr("Crossing waterways");
    86             } else if ((w1.hasKey("highway") && w2.hasKey("waterway"))
    87                     || (w2.hasKey("highway") && w1.hasKey("waterway"))) {
     90            } else if ((w1.hasKey(HIGHWAY) && w2.hasKey(WATERWAY))
     91                    || (w2.hasKey(HIGHWAY) && w1.hasKey(WATERWAY))) {
    8892                return tr("Crossing waterway/highway");
    8993            } else {
     
    207211
    208212    static boolean isSubwayOrTram(OsmPrimitive w) {
    209         return w.hasTag("railway", "subway", "tram");
     213        return w.hasTag(RAILWAY, "subway", "tram");
    210214    }
    211215
    212216    static boolean isProposedOrAbandoned(OsmPrimitive w) {
    213         return w.hasTag("highway", "proposed") || w.hasTag("railway", "proposed", "abandoned");
     217        return w.hasTag(HIGHWAY, "proposed") || w.hasTag(RAILWAY, "proposed", "abandoned");
    214218    }
    215219
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r6605 r6623  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.command.ChangePropertyCommand;
    19 import org.openstreetmap.josm.data.osm.Node;
    2019import org.openstreetmap.josm.data.osm.OsmPrimitive;
    21 import org.openstreetmap.josm.data.osm.Relation;
    22 import org.openstreetmap.josm.data.osm.Way;
    2320import org.openstreetmap.josm.data.validation.FixableTestError;
    2421import org.openstreetmap.josm.data.validation.Severity;
     
    194191            return Collections.emptyList();
    195192        }
     193        final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>();
    196194        try {
    197195            final Object r = parse(value, mode);
    198             final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>();
    199196            String prettifiedValue = null;
    200197            try {
     
    212209                errors.add(new OpeningHoursTestError(tr("opening_hours value can be prettified"), Severity.OTHER, prettifiedValue));
    213210            }
    214             return errors;
    215         } catch (final Exception ex) {
    216             throw new RuntimeException(ex);
    217         }
     211        } catch (ScriptException ex) {
     212            Main.error(ex);
     213        } catch (NoSuchMethodException ex) {
     214            Main.error(ex);
     215        }
     216        return errors;
    218217    }
    219218
  • trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java

    r6595 r6623  
    3333 */
    3434public final class ConditionalOptionPaneUtil {
    35     static public final int DIALOG_DISABLED_OPTION = Integer.MIN_VALUE;
     35    public static final int DIALOG_DISABLED_OPTION = Integer.MIN_VALUE;
    3636
    3737    /** (preference key => return value) mappings valid for the current operation (no, those two maps cannot be combined) */
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java

    r6616 r6623  
    1414import javax.swing.table.TableCellRenderer;
    1515
     16import org.openstreetmap.josm.Main;
    1617import org.openstreetmap.josm.gui.conflict.ConflictColors;
    1718import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     
    6465                        setBackground(ConflictColors.BGCOLOR_TAG_KEEP_ALL.get());
    6566                        break;
     67                    default:
     68                        Main.error("Unknown decision type: "+decision.getDecisionType());
    6669                    }
    6770                } else {
     
    143146
    144147        MultiValueResolutionDecision decision = (MultiValueResolutionDecision)value;
    145         TagConflictResolverModel model = (TagConflictResolverModel) table.getModel();
    146         boolean conflict = model.getKeysWithConflicts().contains(model.getKey(row));
     148        TagConflictResolverModel tagModel = (TagConflictResolverModel) table.getModel();
     149        boolean conflict = tagModel.getKeysWithConflicts().contains(tagModel.getKey(row));
    147150        renderColors(decision, isSelected, conflict);
    148151        renderToolTipText(decision);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java

    r6616 r6623  
    1818public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel {
    1919
     20    private final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
     21   
     22    private final OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
     23        @Override
     24        public Component getTableCellRendererComponent(JTable table,
     25                Object value, boolean isSelected, boolean hasFocus, int row, int column) {
     26            return setColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
     27                    table, isSelected, row);
     28        }
     29    };
     30   
     31    private final TableCellRenderer tableRenderer = new TableCellRenderer() {
     32        @Override
     33        public Component getTableCellRendererComponent(JTable table, Object value,
     34                boolean isSelected, boolean hasFocus, int row, int column) {
     35            return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
     36                    table, isSelected, row);
     37        }
     38    };
     39   
    2040    private static Component setColors(Component comp, JTable table, boolean isSelected, int row) {
    2141        RelationMemberConflictResolverModel model = (RelationMemberConflictResolverModel) table.getModel();
     
    4060    }
    4161   
    42     protected void createColumns() {
    43         final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
    44        
    45         OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
    46             @Override
    47             public Component getTableCellRendererComponent(JTable table,
    48                     Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    49                 return setColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
    50                         table, isSelected, row);
    51             }
    52         };
    53        
    54         TableCellRenderer tableRenderer = new TableCellRenderer() {
    55             @Override
    56             public Component getTableCellRendererComponent(JTable table, Object value,
    57                     boolean isSelected, boolean hasFocus, int row, int column) {
    58                 return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
    59                         table, isSelected, row);
    60             }
    61         };
     62    protected final void createColumns() {
    6263       
    6364        AutoCompletingTextField roleEditor = new AutoCompletingTextField();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r6595 r6623  
    560560        }
    561561       
    562         // Discard parameter as we do not want to operate always on real selection here, especially in draw mode
    563         newSelection = Main.main.getInProgressSelection();
    564         if (newSelection == null) {
    565             newSelection = Collections.<OsmPrimitive>emptyList();
     562        // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode
     563        Collection<OsmPrimitive> newSel = Main.main.getInProgressSelection();
     564        if (newSel == null) {
     565            newSel = Collections.<OsmPrimitive>emptyList();
    566566        }
    567567
     
    584584        valueCount.clear();
    585585        EnumSet<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class);
    586         for (OsmPrimitive osm : newSelection) {
     586        for (OsmPrimitive osm : newSel) {
    587587            types.add(TaggingPresetType.forPrimitive(osm));
    588588            for (String key : osm.keySet()) {
     
    606606                count += e1.getValue();
    607607            }
    608             if (count < newSelection.size()) {
    609                 e.getValue().put("", newSelection.size() - count);
     608            if (count < newSel.size()) {
     609                e.getValue().put("", newSel.size() - count);
    610610            }
    611611            tagData.addRow(new Object[]{e.getKey(), e.getValue()});
     
    617617
    618618        Map<Relation, MemberInfo> roles = new HashMap<Relation, MemberInfo>();
    619         for (OsmPrimitive primitive: newSelection) {
     619        for (OsmPrimitive primitive: newSel) {
    620620            for (OsmPrimitive ref: primitive.getReferrers()) {
    621621                if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {
     
    657657        membershipTable.setVisible(membershipData.getRowCount() > 0);
    658658
    659         boolean hasSelection = !newSelection.isEmpty();
     659        boolean hasSelection = !newSel.isEmpty();
    660660        boolean hasTags = hasSelection && tagData.getRowCount() > 0;
    661661        boolean hasMemberships = hasSelection && membershipData.getRowCount() > 0;
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r6520 r6623  
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.actions.AbstractInfoAction;
     33import org.openstreetmap.josm.data.osm.history.History;
    3334import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    3435import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     
    5859            public void keyReleased(KeyEvent e) {
    5960                // navigate history down/up using the corresponding arrow keys.
    60                 try {
    61                     final HistoryOsmPrimitive ref = model.getReferencePointInTime();
    62                     final HistoryOsmPrimitive cur = model.getCurrentPointInTime();
    63                     if (e.getKeyCode() == KeyEvent.VK_DOWN) {
    64                         // compute both values first and set them afterwards such that nothing is changed in case of an exception (e.g., reached top/bottom)
    65                         final HistoryOsmPrimitive refNext = model.getHistory().from(ref.getVersion()).sortAscending().get(1);
    66                         final HistoryOsmPrimitive curNext = model.getHistory().from(cur.getVersion()).sortAscending().get(1);
    67                         model.setReferencePointInTime(refNext);
    68                         model.setCurrentPointInTime(curNext);
    69                     } else if (e.getKeyCode() == KeyEvent.VK_UP) {
    70                         // compute both values first and set them afterwards such that nothing is changed in case of an exception (e.g., reached top/bottom)
    71                         final HistoryOsmPrimitive refNext = model.getHistory().until(ref.getVersion()).sortDescending().get(1);
    72                         final HistoryOsmPrimitive curNext = model.getHistory().until(cur.getVersion()).sortDescending().get(1);
    73                         model.setReferencePointInTime(refNext);
    74                         model.setCurrentPointInTime(curNext);
     61                long ref = model.getReferencePointInTime().getVersion();
     62                long cur = model.getCurrentPointInTime().getVersion();
     63                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
     64                    History refNext = model.getHistory().from(ref);
     65                    History curNext = model.getHistory().from(cur);
     66                    if (refNext.getNumVersions() > 1 && curNext.getNumVersions() > 1) {
     67                        model.setReferencePointInTime(refNext.sortAscending().get(1));
     68                        model.setCurrentPointInTime(curNext.sortAscending().get(1));
    7569                    }
    76                 } catch (NullPointerException ignore) {
    77                 } catch (IndexOutOfBoundsException ignore) {
     70                } else if (e.getKeyCode() == KeyEvent.VK_UP) {
     71                    History refNext = model.getHistory().until(ref);
     72                    History curNext = model.getHistory().until(cur);
     73                    if (refNext.getNumVersions() > 1 && curNext.getNumVersions() > 1) {
     74                        model.setReferencePointInTime(refNext.sortDescending().get(1));
     75                        model.setCurrentPointInTime(curNext.sortDescending().get(1));
     76                    }
    7877                }
    7978            }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java

    r6603 r6623  
    153153         * The list of default name tags from which a label candidate is derived.
    154154         */
    155         public static final String[] DEFAULT_NAME_TAGS = {
     155        private static final String[] DEFAULT_NAME_TAGS = {
    156156            "name:" + LanguageInfo.getJOSMLocaleCode(),
    157157            "name",
     
    165165        /**
    166166         * The list of default name complement tags from which a label candidate is derived.
    167          * @since 6541
    168          */
    169         public static final String[] DEFAULT_NAME_COMPLEMENT_TAGS = {
     167         */
     168        private static final String[] DEFAULT_NAME_COMPLEMENT_TAGS = {
    170169            "capacity"
    171170        };
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r6613 r6623  
    181181        }
    182182
    183         private class CrossingFinder extends AbstractFinder {
     183        private final class CrossingFinder extends AbstractFinder {
    184184            private CrossingFinder(Environment e) {
    185185                super(e);
     
    197197        }
    198198
    199         private class ContainsFinder extends AbstractFinder {
     199        private final class ContainsFinder extends AbstractFinder {
    200200            private ContainsFinder(Environment e) {
    201201                super(e);
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r6603 r6623  
    1313import java.awt.event.ComponentAdapter;
    1414import java.awt.event.ComponentEvent;
     15import java.lang.reflect.InvocationTargetException;
    1516import java.util.ArrayList;
    1617import java.util.Collection;
     
    138139        gc.gridx = 1;
    139140        gc.weightx = 1.0;
    140         pnl.add(tfFilter = new JosmTextField(), gc);
     141        tfFilter = new JosmTextField();
     142        pnl.add(tfFilter, gc);
    141143        tfFilter.setToolTipText(tr("Enter a search expression"));
    142144        SelectAllOnFocusGainedDecorator.decorate(tfFilter);
     
    158160        pnl.add(buildSearchFieldPanel(), BorderLayout.NORTH);
    159161        model  = new PluginPreferencesModel();
    160         spPluginPreferences = new JScrollPane(pnlPluginPreferences = new PluginListPanel(model));
     162        pnlPluginPreferences = new PluginListPanel(model);
     163        spPluginPreferences = new JScrollPane(pnlPluginPreferences);
    161164        spPluginPreferences.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    162165        spPluginPreferences.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     
    181184    protected JTabbedPane buildContentPane() {
    182185        JTabbedPane pane = getTabPane();
     186        pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel();
    183187        pane.addTab(tr("Plugins"), buildPluginListPanel());
    184         pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel());
     188        pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy);
    185189        return pane;
    186190    }
     
    363367                    }
    364368                });
    365             } catch (Exception e) {
    366                 e.printStackTrace();
     369            } catch (InterruptedException e) {
     370                Main.error(e);
     371            } catch (InvocationTargetException e) {
     372                Main.error(e);
    367373            }
    368374        }
     
    482488        private DefaultListModel model;
    483489
    484         protected void build() {
     490        protected final void build() {
    485491            setLayout(new GridBagLayout());
    486492            add(new JLabel(tr("Add JOSM Plugin description URL.")), GBC.eol());
  • trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java

    r6529 r6623  
    7979        remote.add(portLabel, GBC.eol().insets(5, 5, 0, 10).fill(GBC.HORIZONTAL));
    8080
    81         remote.add(enableRemoteControl = new JCheckBox(tr("Enable remote control"), RemoteControl.PROP_REMOTECONTROL_ENABLED.get()), GBC.eol());
     81        enableRemoteControl = new JCheckBox(tr("Enable remote control"), RemoteControl.PROP_REMOTECONTROL_ENABLED.get());
     82        remote.add(enableRemoteControl, GBC.eol());
    8283
    8384        final JPanel wrapper = new JPanel();
     
    8889
    8990        wrapper.add(new JLabel(tr("Permitted actions:")), GBC.eol());
    90         int INDENT = 15;
    9191        for (JCheckBox p : prefs.values()) {
    92             wrapper.add(p, GBC.eol().insets(INDENT, 5, 0, 0).fill(GBC.HORIZONTAL));
     92            wrapper.add(p, GBC.eol().insets(15, 5, 0, 0).fill(GBC.HORIZONTAL));
    9393        }
    9494
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java

    r6529 r6623  
    1414 * @since 6523
    1515 */
    16 public class AuthenticationPreference implements SubPreferenceSetting {
     16public final class AuthenticationPreference implements SubPreferenceSetting {
    1717
    1818    /**
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java

    r6525 r6623  
    113113     * Initializes the panel from preferences
    114114     */
    115     public void initFromPreferences() {
     115    public final void initFromPreferences() {
    116116        String authMethod = Main.pref.get("osm-server.auth-method", "basic");
    117117        if (authMethod.equals("basic")) {
     
    131131     * Saves the current values to preferences
    132132     */
    133     public void saveToPreferences() {
     133    public final void saveToPreferences() {
    134134        // save the authentication method
    135135        String authMethod;
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java

    r6529 r6623  
    1717 * @since 6523
    1818 */
    19 public class ProxyPreference implements SubPreferenceSetting {
     19public final class ProxyPreference implements SubPreferenceSetting {
    2020
    2121    /**
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java

    r6529 r6623  
    8080        gc.weightx = 1.0;
    8181        gc.insets = new Insets(0,0,0,0);
    82         pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel(), gc);
     82        pnlApiUrlPreferences = new OsmApiUrlInputPanel();
     83        pnl.add(pnlApiUrlPreferences, gc);
    8384
    8485        // the remaining access properties
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6617 r6623  
    887887     *  a subclass of <code>klass</code>. The casted value otherwise.
    888888     */
     889    @SuppressWarnings("unchecked")
    889890    public static <T> T cast(Object o, Class<T> klass) {
    890891        if (klass.isInstance(o)) {
    891             @SuppressWarnings("unchecked")
    892             T ret = (T) o;
    893             return ret;
     892            return (T) o;
    894893        }
    895894        return null;
Note: See TracChangeset for help on using the changeset viewer.