Changeset 10179 in josm


Ignore:
Timestamp:
2016-05-11T02:44:10+02:00 (3 years ago)
Author:
Don-vip
Message:

sonar - squid:AssignmentInSubExpressionCheck - Assignments should not be made from within sub-expressions

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

Legend:

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

    r10001 r10179  
    16651665                }
    16661666            }
    1667             return projected = new EastNorth(e0+l*pe, n0+l*pn);
     1667            projected = new EastNorth(e0+l*pe, n0+l*pn);
     1668            return projected;
    16681669        }
    16691670
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r10043 r10179  
    725725                ((MoveCommand) c).applyVectorTo(currentEN);
    726726            } else {
    727                 Main.main.undoRedo.add(
    728                         c = new MoveCommand(selection, startEN, currentEN));
     727                c = new MoveCommand(selection, startEN, currentEN);
     728                Main.main.undoRedo.add(c);
    729729            }
    730730            for (Node n : affectedNodes) {
     
    834834                limit -= ((Way) osm).getNodes().size();
    835835            }
    836             if ((limit -= 1) < 0) {
     836            if (--limit < 0) {
    837837                break;
    838838            }
     
    12001200                    w = ws.way;
    12011201
    1202                     Point2D p1 = mv.getPoint2D(wnp.a = w.getNode(ws.lowerIndex));
    1203                     Point2D p2 = mv.getPoint2D(wnp.b = w.getNode(ws.lowerIndex + 1));
     1202                    wnp.a = w.getNode(ws.lowerIndex);
     1203                    wnp.b = w.getNode(ws.lowerIndex + 1);
     1204                    Point2D p1 = mv.getPoint2D(wnp.a);
     1205                    Point2D p2 = mv.getPoint2D(wnp.b);
    12041206                    if (WireframeMapRenderer.isLargeSegment(p1, p2, virtualSpace)) {
    12051207                        Point2D pc = new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r9983 r10179  
    203203     */
    204204    public static int askForOption(String text, String opts) {
    205         Integer answer;
    206205        if (!opts.isEmpty()) {
    207             String[] options = opts.split(";");
    208             answer = JOptionPane.showOptionDialog(Main.parent, text, "Question",
    209                     JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, 0);
     206            return JOptionPane.showOptionDialog(Main.parent, text, "Question",
     207                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, opts.split(";"), 0);
    210208        } else {
    211             answer = JOptionPane.showOptionDialog(Main.parent, text, "Question",
     209            return JOptionPane.showOptionDialog(Main.parent, text, "Question",
    212210                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, 2);
    213211        }
    214         if (answer == null) return -1; else return answer;
    215212    }
    216213
    217214    public static String askForText(String text) {
    218215        String s = JOptionPane.showInputDialog(Main.parent, text, tr("Enter text"), JOptionPane.QUESTION_MESSAGE);
    219         if (s != null && !(s = s.trim()).isEmpty()) {
    220             return s;
    221         } else {
    222             return "";
    223         }
     216        return s != null ? s.trim() : null;
    224217    }
    225218
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r10000 r10179  
    8484            Map<DataSet, Map<Relation, Multipolygon>> map1 = cache.get(nc);
    8585            if (map1 == null) {
    86                 cache.put(nc, map1 = new ConcurrentHashMap<>());
     86                map1 = new ConcurrentHashMap<>();
     87                cache.put(nc, map1);
    8788            }
    8889            Map<Relation, Multipolygon> map2 = map1.get(r.getDataSet());
    8990            if (map2 == null) {
    90                 map1.put(r.getDataSet(), map2 = new ConcurrentHashMap<>());
     91                map2 = new ConcurrentHashMap<>();
     92                map1.put(r.getDataSet(), map2);
    9193            }
    9294            multipolygon = map2.get(r);
    9395            if (multipolygon == null || forceRefresh) {
    94                 map2.put(r, multipolygon = new Multipolygon(r));
     96                multipolygon = new Multipolygon(r);
     97                map2.put(r, multipolygon);
    9598                for (PolyData pd : multipolygon.getCombinedPolygons()) {
    9699                    if (pd.selected) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r8510 r10179  
    158158                        List<OsmPrimitive> list = map.get(number);
    159159                        if (list == null) {
    160                             map.put(number, list = new ArrayList<>());
     160                            list = new ArrayList<>();
     161                            map.put(number, list);
    161162                        }
    162163                        list.add(p);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r9381 r10179  
    128128                    List<Way> list = map.get(value);
    129129                    if (list == null) {
    130                         map.put(value, list = new ArrayList<>());
     130                        list = new ArrayList<>();
     131                        map.put(value, list);
    131132                    }
    132133                    list.add(h);
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r10173 r10179  
    133133
    134134    /** Conflict dialog */
    135     public ConflictDialog conflictDialog;
     135    public final ConflictDialog conflictDialog;
    136136    /** Filter dialog */
    137     public FilterDialog filterDialog;
     137    public final FilterDialog filterDialog;
    138138    /** Relation list dialog */
    139     public RelationListDialog relationListDialog;
     139    public final RelationListDialog relationListDialog;
    140140    /** Validator dialog */
    141     public ValidatorDialog validatorDialog;
     141    public final ValidatorDialog validatorDialog;
    142142    /** Selection list dialog */
    143     public SelectionListDialog selectionListDialog;
     143    public final SelectionListDialog selectionListDialog;
    144144    /** Properties dialog */
    145     public PropertiesDialog propertiesDialog;
     145    public final PropertiesDialog propertiesDialog;
    146146    /** Map paint dialog */
    147     public MapPaintDialog mapPaintDialog;
     147    public final MapPaintDialog mapPaintDialog;
    148148    /** Notes dialog */
    149     public NotesDialog noteDialog;
     149    public final NotesDialog noteDialog;
    150150
    151151    // Map modes
     
    238238
    239239        // toolBarActions, map mode buttons
    240         addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
    241         addMapMode(new IconToggleButton(mapModeSelectLasso = new LassoModeAction(), true));
    242         addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
    243         addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
     240        mapModeSelect = new SelectAction(this);
     241        mapModeSelectLasso = new LassoModeAction();
     242        mapModeDraw = new DrawAction(this);
     243        mapModeZoom = new ZoomAction(this);
     244
     245        addMapMode(new IconToggleButton(mapModeSelect));
     246        addMapMode(new IconToggleButton(mapModeSelectLasso, true));
     247        addMapMode(new IconToggleButton(mapModeDraw));
     248        addMapMode(new IconToggleButton(mapModeZoom));
    244249        addMapMode(new IconToggleButton(new DeleteAction(this), true));
    245250        addMapMode(new IconToggleButton(new ParallelWayAction(this), true));
     
    251256        // toolBarToggles, toggle dialog buttons
    252257        LayerListDialog.createInstance(this);
     258        propertiesDialog = new PropertiesDialog();
     259        selectionListDialog = new SelectionListDialog();
     260        relationListDialog = new RelationListDialog();
     261        conflictDialog = new ConflictDialog();
     262        validatorDialog = new ValidatorDialog();
     263        filterDialog = new FilterDialog();
     264        mapPaintDialog = new MapPaintDialog();
     265        noteDialog = new NotesDialog();
     266
    253267        addToggleDialog(LayerListDialog.getInstance());
    254         addToggleDialog(propertiesDialog = new PropertiesDialog());
    255         addToggleDialog(selectionListDialog = new SelectionListDialog());
    256         addToggleDialog(relationListDialog = new RelationListDialog());
     268        addToggleDialog(propertiesDialog);
     269        addToggleDialog(selectionListDialog);
     270        addToggleDialog(relationListDialog);
    257271        addToggleDialog(new MinimapDialog());
    258272        addToggleDialog(new CommandStackDialog());
    259273        addToggleDialog(new UserListDialog());
    260         addToggleDialog(conflictDialog = new ConflictDialog());
    261         addToggleDialog(validatorDialog = new ValidatorDialog());
    262         addToggleDialog(filterDialog = new FilterDialog());
     274        addToggleDialog(conflictDialog);
     275        addToggleDialog(validatorDialog);
     276        addToggleDialog(filterDialog);
    263277        addToggleDialog(new ChangesetDialog(), true);
    264         addToggleDialog(mapPaintDialog = new MapPaintDialog());
    265         addToggleDialog(noteDialog = new NotesDialog());
     278        addToggleDialog(mapPaintDialog);
     279        addToggleDialog(noteDialog);
    266280        toolBarToggle.setFloatable(false);
    267281
     
    272286        boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;
    273287        if (unregisterTab) {
    274             for (JComponent c: allDialogButtons) c.setFocusTraversalKeysEnabled(false);
    275             for (JComponent c: allMapModeButtons) c.setFocusTraversalKeysEnabled(false);
     288            for (JComponent c: allDialogButtons) {
     289                c.setFocusTraversalKeysEnabled(false);
     290            }
     291            for (JComponent c: allMapModeButtons) {
     292                c.setFocusTraversalKeysEnabled(false);
     293            }
    276294        }
    277295
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r9978 r10179  
    9191 * @author imi
    9292 */
    93 public class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener {
     93public class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener {
    9494
    9595    private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(Main.pref.get("statusbar.decimal-format", "0.0"));
     
    201201    private final JProgressBar progressBar = new JProgressBar();
    202202    public final transient BackgroundProgressMonitor progressMonitor = new BackgroundProgressMonitor();
    203 
    204     private final transient SoMChangeListener somListener;
    205203
    206204    // Distance value displayed in distText, stored if refresh needed after a change of system of measurement
     
    924922        }
    925923
    926         SystemOfMeasurement.addSoMChangeListener(somListener = new SoMChangeListener() {
    927             @Override
    928             public void systemOfMeasurementChanged(String oldSoM, String newSoM) {
    929                 setDist(distValue);
    930             }
    931         });
     924        SystemOfMeasurement.addSoMChangeListener(this);
    932925
    933926        latText.addMouseListener(jumpToOnLeftClick);
     
    961954    }
    962955
     956    @Override
     957    public void systemOfMeasurementChanged(String oldSoM, String newSoM) {
     958        setDist(distValue);
     959    }
     960
    963961    /**
    964962     * Updates the system of measurement and displays a notification.
     
    10781076    @Override
    10791077    public void destroy() {
    1080         SystemOfMeasurement.removeSoMChangeListener(somListener);
     1078        SystemOfMeasurement.removeSoMChangeListener(this);
    10811079        Main.pref.removePreferenceChangeListener(this);
    10821080
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

    r10173 r10179  
    3939    /** the text area and the scroll pane for the log */
    4040    private final JosmTextArea taLog = new JosmTextArea(5, 50);
    41     private  JScrollPane spLog;
     41    private final JScrollPane spLog = new JScrollPane(taLog);
    4242
    4343    private void initDialog() {
     
    6060        gc.weighty = 1.0;
    6161        gc.weightx = 1.0;
    62         pane.add(spLog = new JScrollPane(taLog), gc);
     62        pane.add(spLog, gc);
    6363        spLog.setVisible(false);
    6464        setContentPane(pane);
  • trunk/src/org/openstreetmap/josm/gui/SideButton.java

    r9705 r10179  
    2222
    2323/**
    24  * Button that is usually used in toggle dialogs
     24 * Button that is usually used in toggle dialogs.
     25 * @since 744
    2526 */
    2627public class SideButton extends JButton implements Destroyable {
     
    2930    private transient PropertyChangeListener propertyChangeListener;
    3031
     32    /**
     33     * Constructs a new {@code SideButton}.
     34     * @param action action used to specify the new button
     35     */
    3136    public SideButton(Action action) {
    3237        super(action);
     
    3540    }
    3641
     42    /**
     43     * Constructs a new {@code SideButton}.
     44     * @param action action used to specify the new button
     45     * @param usename use action name
     46     */
    3747    public SideButton(Action action, boolean usename) {
    3848        super(action);
     
    4454    }
    4555
     56    /**
     57     * Constructs a new {@code SideButton}.
     58     * @param action action used to specify the new button
     59     * @param imagename image name in "dialogs" directory
     60     */
    4661    public SideButton(Action action, String imagename) {
    4762        super(action);
    48         setIcon(makeIcon(imagename));
     63        setIcon(getScaledImage(ImageProvider.get("dialogs", imagename).getImage()));
    4964        doStyle();
    5065    }
     
    5469        // SideButton is constructed get the proper icon size
    5570        if (action != null) {
    56             action.addPropertyChangeListener(propertyChangeListener = new PropertyChangeListener() {
     71            propertyChangeListener = new PropertyChangeListener() {
    5772                @Override
    5873                public void propertyChange(PropertyChangeEvent evt) {
     
    6176                    }
    6277                }
    63             });
     78            };
     79            action.addPropertyChangeListener(propertyChangeListener);
    6480        }
    6581        Icon i = getIcon();
     
    7793        int newWidth = im.getWidth(null) *  iconHeight / im.getHeight(null);
    7894        return new ImageIcon(im.getScaledInstance(newWidth, iconHeight, Image.SCALE_SMOOTH));
    79     }
    80 
    81     public static ImageIcon makeIcon(String imagename) {
    82         Image im = ImageProvider.get("dialogs", imagename).getImage();
    83         return getScaledImage(im);
    8495    }
    8596
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r10001 r10179  
    8585    private transient Bounds bbox;
    8686    /** the map viewer showing the selected bounding box */
    87     private TileBoundsMapView mapViewer;
     87    private final TileBoundsMapView mapViewer = new TileBoundsMapView();
    8888    /** a panel for entering a bounding box given by a  tile grid and a zoom level */
    89     private TileGridInputPanel pnlTileGrid;
    90     /** a panel for entering a bounding box given by the address of an individual OSM tile at
    91      *  a given zoom level
    92      */
    93     private TileAddressInputPanel pnlTileAddress;
     89    private final TileGridInputPanel pnlTileGrid = new TileGridInputPanel();
     90    /** a panel for entering a bounding box given by the address of an individual OSM tile at a given zoom level */
     91    private final TileAddressInputPanel pnlTileAddress = new TileAddressInputPanel();
    9492
    9593    /**
     
    103101        gc.fill = GridBagConstraints.HORIZONTAL;
    104102        gc.anchor = GridBagConstraints.NORTHWEST;
    105         add(pnlTileGrid = new TileGridInputPanel(), gc);
     103        add(pnlTileGrid, gc);
    106104
    107105        gc.gridx = 1;
    108         add(pnlTileAddress = new TileAddressInputPanel(), gc);
     106        add(pnlTileAddress, gc);
    109107
    110108        gc.gridx = 0;
     
    115113        gc.fill = GridBagConstraints.BOTH;
    116114        gc.insets = new Insets(2, 2, 2, 2);
    117         add(mapViewer = new TileBoundsMapView(), gc);
     115        add(mapViewer, gc);
    118116        mapViewer.setFocusable(false);
    119117        mapViewer.setZoomContolsVisible(false);
     
    217215        public static final String TILE_BOUNDS_PROP = TileGridInputPanel.class.getName() + ".tileBounds";
    218216
    219         private JosmTextField tfMaxY;
    220         private JosmTextField tfMinY;
    221         private JosmTextField tfMaxX;
    222         private JosmTextField tfMinX;
     217        private final JosmTextField tfMaxY = new JosmTextField();
     218        private final JosmTextField tfMinY = new JosmTextField();
     219        private final JosmTextField tfMaxX = new JosmTextField();
     220        private final JosmTextField tfMinX = new JosmTextField();
    223221        private transient TileCoordinateValidator valMaxY;
    224222        private transient TileCoordinateValidator valMinY;
    225223        private transient TileCoordinateValidator valMaxX;
    226224        private transient TileCoordinateValidator valMinX;
    227         private JSpinner spZoomLevel;
     225        private final JSpinner spZoomLevel = new JSpinner(new SpinnerNumberModel(0, 0, 18, 1));
    228226        private final transient TileBoundsBuilder tileBoundsBuilder = new TileBoundsBuilder();
    229227        private boolean doFireTileBoundChanged = true;
     
    240238            JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    241239            pnl.add(new JLabel(tr("Zoom level:")));
    242             pnl.add(spZoomLevel = new JSpinner(new SpinnerNumberModel(0, 0, 18, 1)));
     240            pnl.add(spZoomLevel);
    243241            spZoomLevel.addChangeListener(new ZomeLevelChangeHandler());
    244242            spZoomLevel.addChangeListener(tileBoundsBuilder);
     
    274272            gc.gridx = 1;
    275273            gc.weightx = 0.5;
    276             pnl.add(tfMinX = new JosmTextField(), gc);
     274            pnl.add(tfMinX, gc);
    277275            valMinX = new TileCoordinateValidator(tfMinX);
    278276            SelectAllOnFocusGainedDecorator.decorate(tfMinX);
     
    282280            gc.gridx = 2;
    283281            gc.weightx = 0.5;
    284             pnl.add(tfMaxX = new JosmTextField(), gc);
     282            pnl.add(tfMaxX, gc);
    285283            valMaxX = new TileCoordinateValidator(tfMaxX);
    286284            SelectAllOnFocusGainedDecorator.decorate(tfMaxX);
     
    295293            gc.gridx = 1;
    296294            gc.weightx = 0.5;
    297             pnl.add(tfMinY = new JosmTextField(), gc);
     295            pnl.add(tfMinY, gc);
    298296            valMinY = new TileCoordinateValidator(tfMinY);
    299297            SelectAllOnFocusGainedDecorator.decorate(tfMinY);
     
    303301            gc.gridx = 2;
    304302            gc.weightx = 0.5;
    305             pnl.add(tfMaxY = new JosmTextField(), gc);
     303            pnl.add(tfMaxY, gc);
    306304            valMaxY = new TileCoordinateValidator(tfMaxY);
    307305            SelectAllOnFocusGainedDecorator.decorate(tfMaxY);
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r9996 r10179  
    3737    private static final DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000000");
    3838
    39     private JLabel lblMyCoordinates;
    40     private JLabel lblMergedCoordinates;
    41     private JLabel lblTheirCoordinates;
    42 
    43     private JLabel lblMyDeletedState;
    44     private JLabel lblMergedDeletedState;
    45     private JLabel lblTheirDeletedState;
    46 
    47     private JLabel lblMyReferrers;
    48     private JLabel lblTheirReferrers;
     39    private final JLabel lblMyCoordinates = buildValueLabel("label.mycoordinates");
     40    private final JLabel lblMergedCoordinates = buildValueLabel("label.mergedcoordinates");
     41    private final JLabel lblTheirCoordinates = buildValueLabel("label.theircoordinates");
     42
     43    private final JLabel lblMyDeletedState = buildValueLabel("label.mydeletedstate");
     44    private final JLabel lblMergedDeletedState = buildValueLabel("label.mergeddeletedstate");
     45    private final JLabel lblTheirDeletedState = buildValueLabel("label.theirdeletedstate");
     46
     47    private final JLabel lblMyReferrers = buildValueLabel("label.myreferrers");
     48    private final JLabel lblTheirReferrers = buildValueLabel("label.theirreferrers");
    4949
    5050    private final transient PropertiesMergeModel model;
     
    6161    }
    6262
    63     protected JLabel buildValueLabel(String name) {
     63    protected static JLabel buildValueLabel(String name) {
    6464        JLabel lbl = new JLabel();
    6565        lbl.setName(name);
     
    129129        gc.weightx = 0.33;
    130130        gc.weighty = 0.0;
    131         add(lblMyCoordinates = buildValueLabel("label.mycoordinates"), gc);
     131        add(lblMyCoordinates, gc);
    132132
    133133        gc.gridx = 2;
     
    147147        gc.weightx = 0.33;
    148148        gc.weighty = 0.0;
    149         add(lblMergedCoordinates = buildValueLabel("label.mergedcoordinates"), gc);
     149        add(lblMergedCoordinates, gc);
    150150
    151151        gc.gridx = 4;
     
    164164        gc.weightx = 0.33;
    165165        gc.weighty = 0.0;
    166         add(lblTheirCoordinates = buildValueLabel("label.theircoordinates"), gc);
     166        add(lblTheirCoordinates, gc);
    167167
    168168        // ---------------------------------------------------
     
    198198        gc.weightx = 0.33;
    199199        gc.weighty = 0.0;
    200         add(lblMyDeletedState = buildValueLabel("label.mydeletedstate"), gc);
     200        add(lblMyDeletedState, gc);
    201201
    202202        gc.gridx = 2;
     
    216216        gc.weightx = 0.33;
    217217        gc.weighty = 0.0;
    218         add(lblMergedDeletedState = buildValueLabel("label.mergeddeletedstate"), gc);
     218        add(lblMergedDeletedState, gc);
    219219
    220220        gc.gridx = 4;
     
    234234        gc.weightx = 0.33;
    235235        gc.weighty = 0.0;
    236         add(lblTheirDeletedState = buildValueLabel("label.theirdeletedstate"), gc);
     236        add(lblTheirDeletedState, gc);
    237237
    238238        // ---------------------------------------------------
     
    270270        gc.weightx = 0.33;
    271271        gc.weighty = 0.0;
    272         add(lblMyReferrers = buildValueLabel("label.myreferrers"), gc);
     272        add(lblMyReferrers, gc);
    273273
    274274        gc.gridx = 5;
     
    278278        gc.weightx = 0.33;
    279279        gc.weighty = 0.0;
    280         add(lblTheirReferrers = buildValueLabel("label.theirreferrers"), gc);
     280        add(lblTheirReferrers, gc);
    281281    }
    282282
     
    289289    }
    290290
    291     public String coordToString(LatLon coord) {
     291    protected static String coordToString(LatLon coord) {
    292292        if (coord == null)
    293293            return tr("(none)");
     
    301301    }
    302302
    303     public String deletedStateToString(Boolean deleted) {
     303    protected static String deletedStateToString(Boolean deleted) {
    304304        if (deleted == null)
    305305            return tr("(none)");
     
    310310    }
    311311
    312     public String referrersToString(List<OsmPrimitive> referrers) {
     312    protected static String referrersToString(List<OsmPrimitive> referrers) {
    313313        if (referrers.isEmpty())
    314314            return tr("(none)");
     
    390390    }
    391391
     392    /**
     393     * Returns properties merge model.
     394     * @return properties merge model
     395     */
    392396    public PropertiesMergeModel getModel() {
    393397        return model;
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java

    r10035 r10179  
    172172        spTagConflictTypes.setTopComponent(buildTagConflictResolverPanel());
    173173        spTagConflictTypes.setBottomComponent(buildRelationMemberConflictResolverPanel());
    174         getContentPane().add(pnlButtons = buildButtonPanel(), BorderLayout.SOUTH);
     174        pnlButtons = buildButtonPanel();
     175        getContentPane().add(pnlButtons, BorderLayout.SOUTH);
    175176        addWindowListener(new AdjustDividerLocationAction());
    176177        HelpUtil.setHelpContext(getRootPane(), ht("/"));
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r10035 r10179  
    5757    }
    5858
    59     private TagConflictResolver allPrimitivesResolver;
    60     private transient Map<OsmPrimitiveType, TagConflictResolver> resolvers;
    61     private JTabbedPane tpResolvers;
     59    private final TagConflictResolver allPrimitivesResolver = new TagConflictResolver();
     60    private final transient Map<OsmPrimitiveType, TagConflictResolver> resolvers = new EnumMap<>(OsmPrimitiveType.class);
     61    private final JTabbedPane tpResolvers = new JTabbedPane();
    6262    private Mode mode;
    6363    private boolean canceled;
    6464
    65     private final ImageIcon iconResolved;
    66     private final ImageIcon iconUnresolved;
    67     private StatisticsTableModel statisticsModel;
    68     private JPanel pnlTagResolver;
     65    private final ImageIcon iconResolved = ImageProvider.get("dialogs/conflict", "tagconflictresolved");
     66    private final ImageIcon iconUnresolved = ImageProvider.get("dialogs/conflict", "tagconflictunresolved");
     67    private final StatisticsTableModel statisticsModel = new StatisticsTableModel();
     68    private final JPanel pnlTagResolver = new JPanel(new BorderLayout());
    6969
    7070    /**
     
    7575        super(GuiHelper.getFrameForComponent(owner), ModalityType.DOCUMENT_MODAL);
    7676        build();
    77         iconResolved = ImageProvider.get("dialogs/conflict", "tagconflictresolved");
    78         iconUnresolved = ImageProvider.get("dialogs/conflict", "tagconflictunresolved");
    7977    }
    8078
    8179    protected final void build() {
    8280        setTitle(tr("Conflicts in pasted tags"));
    83         allPrimitivesResolver = new TagConflictResolver();
    84         resolvers = new EnumMap<>(OsmPrimitiveType.class);
    8581        for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    8682            resolvers.put(type, new TagConflictResolver());
    8783            resolvers.get(type).getModel().addPropertyChangeListener(this);
    8884        }
    89         tpResolvers = new JTabbedPane();
    9085        getContentPane().setLayout(new GridBagLayout());
    9186        mode = null;
     
    10297        gc.weightx = 1.0;
    10398        gc.weighty = 1.0;
    104         getContentPane().add(pnlTagResolver = new JPanel(new BorderLayout()), gc);
     99        getContentPane().add(pnlTagResolver, gc);
    105100        gc.gridx = 0;
    106101        gc.gridy = 2;
     
    131126    protected JPanel buildSourceAndTargetInfoPanel() {
    132127        JPanel pnl = new JPanel(new BorderLayout());
    133         statisticsModel = new StatisticsTableModel();
    134128        pnl.add(new StatisticsInfoTable(statisticsModel), BorderLayout.CENTER);
    135129        return pnl;
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

    r9548 r10179  
    4040public class RelationMemberConflictResolver extends JPanel {
    4141
    42     private AutoCompletingTextField tfRole;
    43     private AutoCompletingTextField tfKey;
    44     private AutoCompletingTextField tfValue;
     42    private final AutoCompletingTextField tfRole = new AutoCompletingTextField(10);
     43    private final AutoCompletingTextField tfKey = new AutoCompletingTextField(10);
     44    private final AutoCompletingTextField tfValue = new AutoCompletingTextField(10);
    4545    private JCheckBox cbTagRelations;
    4646    private final RelationMemberConflictResolverModel model;
    47     private RelationMemberConflictResolverTable tblResolver;
    48     private JMultilineLabel lblHeader;
     47    private final RelationMemberConflictResolverTable tblResolver;
     48    private final JMultilineLabel lblHeader = new JMultilineLabel("");
    4949
    5050    protected final void build() {
    5151        setLayout(new GridBagLayout());
    5252        final JPanel pnl = new JPanel(new BorderLayout());
    53         pnl.add(lblHeader = new JMultilineLabel(""));
     53        pnl.add(lblHeader);
    5454        GridBagConstraints gc = new GridBagConstraints();
    5555        gc.fill = GridBagConstraints.HORIZONTAL;
     
    6363        gc.fill = GridBagConstraints.BOTH;
    6464        gc.insets = new Insets(0, 0, 0, 0);
    65         add(new JScrollPane(tblResolver = new RelationMemberConflictResolverTable(model)), gc);
     65        add(new JScrollPane(tblResolver), gc);
    6666
    6767        final JPanel pnl2 = new JPanel();
     
    7878        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    7979        pnl.add(new JLabel(tr("Role:")));
    80         pnl.add(tfRole = new AutoCompletingTextField(10));
     80        pnl.add(tfRole);
    8181        tfRole.setToolTipText(tr("Enter a role for all relation memberships"));
    8282        pnl.add(new JButton(new ApplyRoleAction()));
     
    102102        pnl.add(cbTagRelations);
    103103        pnl.add(new JLabel(trc("tag", "Key:")));
    104         pnl.add(tfKey = new AutoCompletingTextField(10));
     104        pnl.add(tfKey);
    105105        tfKey.setToolTipText(tr("<html>Enter a tag key, e.g. <strong><tt>fixme</tt></strong></html>"));
    106106        pnl.add(new JLabel(tr("Value:")));
    107         pnl.add(tfValue = new AutoCompletingTextField(10));
     107        pnl.add(tfValue);
    108108        tfValue.setToolTipText(tr("<html>Enter a tag value, e.g. <strong><tt>check members</tt></strong></html>"));
    109109        cbTagRelations.setSelected(false);
     
    120120    public RelationMemberConflictResolver(RelationMemberConflictResolverModel model) {
    121121        this.model = model;
     122        this.tblResolver = new RelationMemberConflictResolverTable(model);
    122123        build();
    123124    }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolver.java

    r9543 r10179  
    2121 * This is a UI widget for resolving tag conflicts, i.e. differences of the tag values
    2222 * of multiple {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s.
    23  *
    24  *
     23 * @since 2008
    2524 */
    2625public class TagConflictResolver extends JPanel {
     
    2928    private final TagConflictResolverModel model;
    3029    /** selects whether only tags with conflicts are displayed */
    31     private JCheckBox cbShowTagsWithConflictsOnly;
    32     private JCheckBox cbShowTagsWithMultiValuesOnly;
     30    private final JCheckBox cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only"));
     31    private final JCheckBox cbShowTagsWithMultiValuesOnly = new JCheckBox(tr("Show tags with multiple values only"));
     32
     33    /**
     34     * Constructs a new {@code TagConflictResolver}.
     35     */
     36    public TagConflictResolver() {
     37        this.model = new TagConflictResolverModel();
     38        build();
     39    }
    3340
    3441    protected JPanel buildInfoPanel() {
     
    4754        gc.fill = GridBagConstraints.HORIZONTAL;
    4855        gc.weighty = 0.0;
    49         pnl.add(cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only")), gc);
    50         pnl.add(cbShowTagsWithMultiValuesOnly = new JCheckBox(tr("Show tags with multiple values only")), gc);
     56        pnl.add(cbShowTagsWithConflictsOnly, gc);
     57        pnl.add(cbShowTagsWithMultiValuesOnly, gc);
    5158        cbShowTagsWithConflictsOnly.addChangeListener(
    5259                new ChangeListener() {
     
    9299
    93100    /**
    94      * Constructs a new {@code TagConflictResolver}.
    95      */
    96     public TagConflictResolver() {
    97         this.model = new TagConflictResolverModel();
    98         build();
    99     }
    100 
    101     /**
    102101     * Replies the model used by this dialog
    103102     *
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r10124 r10179  
    7272 * browser with information about a changeset. Furthermore, it can select all objects in
    7373 * the current data layer being assigned to a specific changeset.
    74  *
     74 * @since 2613
    7575 */
    7676public class ChangesetDialog extends ToggleDialog {
     
    162162        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    163163        pnl.setBorder(null);
    164         pnl.add(cbInSelectionOnly = new JCheckBox(tr("For selected objects only")));
     164        cbInSelectionOnly = new JCheckBox(tr("For selected objects only"));
     165        pnl.add(cbInSelectionOnly);
    165166        cbInSelectionOnly.setToolTipText(tr("<html>Select to show changesets for the currently selected objects only.<br>"
    166167                + "Unselect to show all changesets for objects in the current data layer.</html>"));
     
    183184        JPanel pnl = new JPanel(new BorderLayout());
    184185        pnl.add(buildFilterPanel(), BorderLayout.NORTH);
    185         pnl.add(pnlList = buildListPanel(), BorderLayout.CENTER);
     186        pnlList = buildListPanel();
     187        pnl.add(pnlList, BorderLayout.CENTER);
    186188
    187189        cbInSelectionOnly.addItemListener(new FilterChangeHandler());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DeleteFromRelationConfirmationDialog.java

    r10035 r10179  
    6969    /** the data model */
    7070    private RelationMemberTableModel model;
    71     private HtmlPanel htmlPanel;
     71    private final HtmlPanel htmlPanel = new HtmlPanel();
    7272    private boolean canceled;
    73     private SideButton btnOK;
     73    private final SideButton btnOK = new SideButton(new OKAction());
    7474
    7575    protected JPanel buildRelationMemberTablePanel() {
     
    8282    protected JPanel buildButtonPanel() {
    8383        JPanel pnl = new JPanel(new FlowLayout());
    84         pnl.add(btnOK = new SideButton(new OKAction()));
     84        pnl.add(btnOK);
    8585        btnOK.setFocusable(true);
    8686        pnl.add(new SideButton(new CancelAction()));
     
    9393        model.addTableModelListener(this);
    9494        getContentPane().setLayout(new BorderLayout());
    95         getContentPane().add(htmlPanel = new HtmlPanel(), BorderLayout.NORTH);
     95        getContentPane().add(htmlPanel, BorderLayout.NORTH);
    9696        getContentPane().add(buildRelationMemberTablePanel(), BorderLayout.CENTER);
    9797        getContentPane().add(buildButtonPanel(), BorderLayout.SOUTH);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r9996 r10179  
    8989import org.openstreetmap.josm.tools.Utils;
    9090
     91/**
     92 * Dialog to configure the map painting style.
     93 * @since 3843
     94 */
    9195public class MapPaintDialog extends ToggleDialog {
    9296
    9397    protected StylesTable tblStyles;
    9498    protected StylesModel model;
    95     protected DefaultListSelectionModel selectionModel;
     99    protected final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    96100
    97101    protected OnOffAction onoffAction;
     
    144148
    145149        tblStyles = new StylesTable(model);
    146         tblStyles.setSelectionModel(selectionModel = new DefaultListSelectionModel());
     150        tblStyles.setSelectionModel(selectionModel);
    147151        tblStyles.addMouseListener(new PopupMenuHandler());
    148152        tblStyles.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
     
    272276        public void ensureSelectedIsVisible() {
    273277            int index = selectionModel.getMinSelectionIndex();
    274             if (index < 0) return;
    275             if (index >= getRowCount()) return;
     278            if (index < 0)
     279                return;
     280            if (index >= getRowCount())
     281                return;
    276282            tblStyles.scrollToVisible(index, 0);
    277283            tblStyles.repaint();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/SingleChangesetDownloadPanel.java

    r10124 r10179  
    2626 * This panel allows to enter the ID of single changeset and to download
    2727 * the respective changeset.
    28  *
     28 * @since 2689
    2929 */
    3030public class SingleChangesetDownloadPanel extends JPanel {
    3131
    32     private ChangesetIdTextField tfChangesetId;
     32    private final ChangesetIdTextField tfChangesetId = new ChangesetIdTextField();
     33
     34    /**
     35     * Constructs a new {@link SingleChangesetDownloadPanel}
     36     */
     37    public SingleChangesetDownloadPanel() {
     38        build();
     39    }
    3340
    3441    protected void build() {
     
    4249
    4350        add(new JLabel(tr("Changeset ID: ")));
    44         add(tfChangesetId = new ChangesetIdTextField());
     51        add(tfChangesetId);
    4552        tfChangesetId.setToolTipText(tr("Enter a changeset id"));
    4653        SelectAllOnFocusGainedDecorator.decorate(tfChangesetId);
     
    5562            tfChangesetId.tryToPasteFromClipboard();
    5663        }
    57     }
    58 
    59     /**
    60      * Constructs a new {@link SingleChangesetDownloadPanel}
    61      */
    62     public SingleChangesetDownloadPanel() {
    63         build();
    6464    }
    6565
     
    9090                return;
    9191            int id = getChangesetId();
    92             if (id == 0) return;
     92            if (id == 0)
     93                return;
    9394            ChangesetContentDownloadTask task =  new ChangesetContentDownloadTask(
    9495                    SingleChangesetDownloadPanel.this,
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/AdvancedChangesetQueryPanel.java

    r10073 r10179  
    4242import org.openstreetmap.josm.tools.CheckParameterUtil;
    4343
    44 
    4544/**
    4645 * This panel allows to specify a changeset query
    47  *
     46 * @since 2689
    4847 */
    4948public class AdvancedChangesetQueryPanel extends JPanel {
    5049
    51     private JCheckBox cbUserRestriction;
    52     private JCheckBox cbOpenAndCloseRestrictions;
    53     private JCheckBox cbTimeRestrictions;
    54     private JCheckBox cbBoundingBoxRestriction;
    55     private UserRestrictionPanel pnlUserRestriction;
    56     private OpenAndCloseStateRestrictionPanel pnlOpenAndCloseRestriction;
    57     private TimeRestrictionPanel pnlTimeRestriction;
    58     private BBoxRestrictionPanel pnlBoundingBoxRestriction;
     50    private final JCheckBox cbUserRestriction = new JCheckBox();
     51    private final JCheckBox cbOpenAndCloseRestrictions = new JCheckBox();
     52    private final JCheckBox cbTimeRestrictions = new JCheckBox();
     53    private final JCheckBox cbBoundingBoxRestriction = new JCheckBox();
     54    private final UserRestrictionPanel pnlUserRestriction = new UserRestrictionPanel();
     55    private final OpenAndCloseStateRestrictionPanel pnlOpenAndCloseRestriction = new OpenAndCloseStateRestrictionPanel();
     56    private final TimeRestrictionPanel pnlTimeRestriction = new TimeRestrictionPanel();
     57    private final BBoxRestrictionPanel pnlBoundingBoxRestriction = new BBoxRestrictionPanel();
     58
     59    /**
     60     * Constructs a new {@code AdvancedChangesetQueryPanel}.
     61     */
     62    public AdvancedChangesetQueryPanel() {
     63        build();
     64    }
    5965
    6066    protected JPanel buildQueryPanel() {
     
    6975        gc.weightx = 0.0;
    7076        gc.fill = GridBagConstraints.HORIZONTAL;
    71         pnl.add(cbUserRestriction = new JCheckBox(), gc);
     77        pnl.add(cbUserRestriction, gc);
    7278        cbUserRestriction.addItemListener(stateChangeHandler);
    7379
     
    7985        gc.gridx = 1;
    8086        gc.weightx = 1.0;
    81         pnl.add(pnlUserRestriction = new UserRestrictionPanel(), gc);
     87        pnl.add(pnlUserRestriction, gc);
    8288
    8389        // -- restricting the query to open and closed changesets
     
    8894        gc.weightx = 0.0;
    8995        gc.fill = GridBagConstraints.HORIZONTAL;
    90         pnl.add(cbOpenAndCloseRestrictions = new JCheckBox(), gc);
     96        pnl.add(cbOpenAndCloseRestrictions, gc);
    9197        cbOpenAndCloseRestrictions.addItemListener(stateChangeHandler);
    9298
     
    98104        gc.gridx = 1;
    99105        gc.weightx = 1.0;
    100         pnl.add(pnlOpenAndCloseRestriction = new OpenAndCloseStateRestrictionPanel(), gc);
     106        pnl.add(pnlOpenAndCloseRestriction, gc);
    101107
    102108        // -- restricting the query to a specific time
     
    107113        gc.weightx = 0.0;
    108114        gc.fill = GridBagConstraints.HORIZONTAL;
    109         pnl.add(cbTimeRestrictions = new JCheckBox(), gc);
     115        pnl.add(cbTimeRestrictions, gc);
    110116        cbTimeRestrictions.addItemListener(stateChangeHandler);
    111117
     
    117123        gc.gridx = 1;
    118124        gc.weightx = 1.0;
    119         pnl.add(pnlTimeRestriction = new TimeRestrictionPanel(), gc);
     125        pnl.add(pnlTimeRestriction, gc);
    120126
    121127
     
    127133        gc.weightx = 0.0;
    128134        gc.fill = GridBagConstraints.HORIZONTAL;
    129         pnl.add(cbBoundingBoxRestriction = new JCheckBox(), gc);
     135        pnl.add(cbBoundingBoxRestriction, gc);
    130136        cbBoundingBoxRestriction.addItemListener(stateChangeHandler);
    131137
     
    137143        gc.gridx = 1;
    138144        gc.weightx = 1.0;
    139         pnl.add(pnlBoundingBoxRestriction = new BBoxRestrictionPanel(), gc);
     145        pnl.add(pnlBoundingBoxRestriction, gc);
    140146
    141147
     
    155161        JScrollPane spQueryPanel = GuiHelper.embedInVerticalScrollPane(buildQueryPanel());
    156162        add(spQueryPanel, BorderLayout.CENTER);
    157     }
    158 
    159     /**
    160      * Constructs a new {@code AdvancedChangesetQueryPanel}.
    161      */
    162     public AdvancedChangesetQueryPanel() {
    163         build();
    164163    }
    165164
     
    241240    class RestrictionGroupStateChangeHandler implements ItemListener {
    242241        protected void userRestrictionStateChanged() {
    243             if (pnlUserRestriction == null) return;
     242            if (pnlUserRestriction == null)
     243                return;
    244244            pnlUserRestriction.setVisible(cbUserRestriction.isSelected());
    245245        }
    246246
    247247        protected void openCloseRestrictionStateChanged() {
    248             if (pnlOpenAndCloseRestriction == null) return;
     248            if (pnlOpenAndCloseRestriction == null)
     249                return;
    249250            pnlOpenAndCloseRestriction.setVisible(cbOpenAndCloseRestrictions.isSelected());
    250251        }
    251252
    252253        protected void timeRestrictionsStateChanged() {
    253             if (pnlTimeRestriction == null) return;
     254            if (pnlTimeRestriction == null)
     255                return;
    254256            pnlTimeRestriction.setVisible(cbTimeRestrictions.isSelected());
    255257        }
    256258
    257259        protected void boundingBoxRestrictionChanged() {
    258             if (pnlBoundingBoxRestriction == null) return;
     260            if (pnlBoundingBoxRestriction == null)
     261                return;
    259262            pnlBoundingBoxRestriction.setVisible(cbBoundingBoxRestriction.isSelected());
    260263        }
     
    282285    private static class OpenAndCloseStateRestrictionPanel extends JPanel {
    283286
    284         private JRadioButton rbOpenOnly;
    285         private JRadioButton rbClosedOnly;
    286         private JRadioButton rbBoth;
     287        private final JRadioButton rbOpenOnly = new JRadioButton();
     288        private final JRadioButton rbClosedOnly = new JRadioButton();
     289        private final JRadioButton rbBoth = new JRadioButton();
     290
     291        OpenAndCloseStateRestrictionPanel() {
     292            build();
     293        }
    287294
    288295        protected void build() {
     
    299306            gc.fill = GridBagConstraints.HORIZONTAL;
    300307            gc.weightx = 0.0;
    301             add(rbOpenOnly = new JRadioButton(), gc);
     308            add(rbOpenOnly, gc);
    302309
    303310            gc.gridx = 1;
     
    308315            gc.gridx = 0;
    309316            gc.weightx = 0.0;
    310             add(rbClosedOnly = new JRadioButton(), gc);
     317            add(rbClosedOnly, gc);
    311318
    312319            gc.gridx = 1;
     
    317324            gc.gridx = 0;
    318325            gc.weightx = 0.0;
    319             add(rbBoth = new JRadioButton(), gc);
     326            add(rbBoth, gc);
    320327
    321328            gc.gridx = 1;
     
    327334            bgRestrictions.add(rbClosedOnly);
    328335            bgRestrictions.add(rbOpenOnly);
    329         }
    330 
    331         OpenAndCloseStateRestrictionPanel() {
    332             build();
    333336        }
    334337
     
    369372
    370373    /**
    371      * This is the panel for selecting whether the query should be restricted to a specific
    372      * user
    373      *
     374     * This is the panel for selecting whether the query should be restricted to a specific user
    374375     */
    375376    private static class UserRestrictionPanel extends JPanel {
    376         private ButtonGroup bgUserRestrictions;
    377         private JRadioButton rbRestrictToMyself;
    378         private JRadioButton rbRestrictToUid;
    379         private JRadioButton rbRestrictToUserName;
    380         private JosmTextField tfUid;
     377        private final ButtonGroup bgUserRestrictions = new ButtonGroup();
     378        private final JRadioButton rbRestrictToMyself = new JRadioButton();
     379        private final JRadioButton rbRestrictToUid = new JRadioButton();
     380        private final JRadioButton rbRestrictToUserName = new JRadioButton();
     381        private final JosmTextField tfUid = new JosmTextField(10);
    381382        private transient UidInputFieldValidator valUid;
    382         private JosmTextField tfUserName;
     383        private final JosmTextField tfUserName = new JosmTextField(10);
    383384        private transient UserNameValidator valUserName;
    384         private JMultilineLabel lblRestrictedToMyself;
     385        private final JMultilineLabel lblRestrictedToMyself = new JMultilineLabel(tr("Only changesets owned by myself"));
     386
     387        UserRestrictionPanel() {
     388            build();
     389        }
    385390
    386391        protected JPanel buildUidInputPanel() {
     
    393398
    394399            gc.gridx = 1;
    395             pnl.add(tfUid = new JosmTextField(10), gc);
     400            pnl.add(tfUid, gc);
    396401            SelectAllOnFocusGainedDecorator.decorate(tfUid);
    397402            valUid = UidInputFieldValidator.decorate(tfUid);
     
    413418
    414419            gc.gridx = 1;
    415             pnl.add(tfUserName = new JosmTextField(10), gc);
     420            pnl.add(tfUserName, gc);
    416421            SelectAllOnFocusGainedDecorator.decorate(tfUserName);
    417422            valUserName = new UserNameValidator(tfUserName);
     
    440445            gc.fill = GridBagConstraints.HORIZONTAL;
    441446            gc.weightx = 0.0;
    442             add(rbRestrictToMyself = new JRadioButton(), gc);
     447            add(rbRestrictToMyself, gc);
    443448            rbRestrictToMyself.addItemListener(userRestrictionChangeHandler);
    444449
     
    446451            gc.fill =  GridBagConstraints.HORIZONTAL;
    447452            gc.weightx = 1.0;
    448             add(lblRestrictedToMyself = new JMultilineLabel(tr("Only changesets owned by myself")), gc);
     453            add(lblRestrictedToMyself, gc);
    449454
    450455            gc.gridx = 0;
     
    452457            gc.fill = GridBagConstraints.HORIZONTAL;
    453458            gc.weightx = 0.0;
    454             add(rbRestrictToUid = new JRadioButton(), gc);
     459            add(rbRestrictToUid, gc);
    455460            rbRestrictToUid.addItemListener(userRestrictionChangeHandler);
    456461
     
    470475            gc.fill = GridBagConstraints.HORIZONTAL;
    471476            gc.weightx = 0.0;
    472             add(rbRestrictToUserName = new JRadioButton(), gc);
     477            add(rbRestrictToUserName, gc);
    473478            rbRestrictToUserName.addItemListener(userRestrictionChangeHandler);
    474479
     
    484489            add(buildUserNameInputPanel(), gc);
    485490
    486             bgUserRestrictions = new ButtonGroup();
    487491            bgUserRestrictions.add(rbRestrictToMyself);
    488492            bgUserRestrictions.add(rbRestrictToUid);
    489493            bgUserRestrictions.add(rbRestrictToUserName);
    490         }
    491 
    492         UserRestrictionPanel() {
    493             build();
    494494        }
    495495
     
    637637    private static class TimeRestrictionPanel extends JPanel {
    638638
    639         private JRadioButton rbClosedAfter;
    640         private JRadioButton rbClosedAfterAndCreatedBefore;
    641         private JosmTextField tfClosedAfterDate1;
     639        private final JRadioButton rbClosedAfter = new JRadioButton();
     640        private final JRadioButton rbClosedAfterAndCreatedBefore = new JRadioButton();
     641        private final JosmTextField tfClosedAfterDate1 = new JosmTextField();
    642642        private transient DateValidator valClosedAfterDate1;
    643         private JosmTextField tfClosedAfterTime1;
     643        private final JosmTextField tfClosedAfterTime1 = new JosmTextField();
    644644        private transient TimeValidator valClosedAfterTime1;
    645         private JosmTextField tfClosedAfterDate2;
     645        private final JosmTextField tfClosedAfterDate2 = new JosmTextField();
    646646        private transient DateValidator valClosedAfterDate2;
    647         private JosmTextField tfClosedAfterTime2;
     647        private final JosmTextField tfClosedAfterTime2 = new JosmTextField();
    648648        private transient TimeValidator valClosedAfterTime2;
    649         private JosmTextField tfCreatedBeforeDate;
     649        private final JosmTextField tfCreatedBeforeDate = new JosmTextField();
    650650        private transient DateValidator valCreatedBeforeDate;
    651         private JosmTextField tfCreatedBeforeTime;
     651        private final JosmTextField tfCreatedBeforeTime = new JosmTextField();
    652652        private transient TimeValidator valCreatedBeforeTime;
     653
     654        TimeRestrictionPanel() {
     655            build();
     656        }
    653657
    654658        protected JPanel buildClosedAfterInputPanel() {
     
    662666            gc.gridx = 1;
    663667            gc.weightx = 0.7;
    664             pnl.add(tfClosedAfterDate1 = new JosmTextField(), gc);
     668            pnl.add(tfClosedAfterDate1, gc);
    665669            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterDate1);
    666670            valClosedAfterDate1 = DateValidator.decorate(tfClosedAfterDate1);
     
    673677            gc.gridx = 3;
    674678            gc.weightx = 0.3;
    675             pnl.add(tfClosedAfterTime1 = new JosmTextField(), gc);
     679            pnl.add(tfClosedAfterTime1, gc);
    676680            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterTime1);
    677681            valClosedAfterTime1 = TimeValidator.decorate(tfClosedAfterTime1);
     
    696700            gc.gridx = 2;
    697701            gc.weightx = 0.7;
    698             pnl.add(tfClosedAfterDate2 = new JosmTextField(), gc);
     702            pnl.add(tfClosedAfterDate2, gc);
    699703            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterDate2);
    700704            valClosedAfterDate2 = DateValidator.decorate(tfClosedAfterDate2);
     
    706710            gc.gridx = 4;
    707711            gc.weightx = 0.3;
    708             pnl.add(tfClosedAfterTime2 = new JosmTextField(), gc);
     712            pnl.add(tfClosedAfterTime2, gc);
    709713            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterTime2);
    710714            valClosedAfterTime2 = TimeValidator.decorate(tfClosedAfterTime2);
     
    726730            gc.gridx = 2;
    727731            gc.weightx = 0.7;
    728             pnl.add(tfCreatedBeforeDate = new JosmTextField(), gc);
     732            pnl.add(tfCreatedBeforeDate, gc);
    729733            SelectAllOnFocusGainedDecorator.decorate(tfCreatedBeforeDate);
    730734            valCreatedBeforeDate = DateValidator.decorate(tfCreatedBeforeDate);
     
    737741            gc.gridx = 4;
    738742            gc.weightx = 0.3;
    739             pnl.add(tfCreatedBeforeTime = new JosmTextField(), gc);
     743            pnl.add(tfCreatedBeforeTime, gc);
    740744            SelectAllOnFocusGainedDecorator.decorate(tfCreatedBeforeTime);
    741745            valCreatedBeforeTime = TimeValidator.decorate(tfCreatedBeforeTime);
     
    762766            gc.fill = GridBagConstraints.HORIZONTAL;
    763767            gc.weightx = 0.0;
    764             add(rbClosedAfter = new JRadioButton(), gc);
     768            add(rbClosedAfter, gc);
    765769
    766770            gc.gridx = 1;
     
    783787            gc.fill = GridBagConstraints.HORIZONTAL;
    784788            gc.weightx = 0.0;
    785             add(rbClosedAfterAndCreatedBefore = new JRadioButton(), gc);
     789            add(rbClosedAfterAndCreatedBefore, gc);
    786790
    787791            gc.gridx = 1;
     
    805809
    806810            rbClosedAfter.setSelected(true);
    807         }
    808 
    809         TimeRestrictionPanel() {
    810             build();
    811811        }
    812812
     
    864864
    865865        public void displayMessageIfInvalid() {
    866             if (isValidChangesetQuery()) return;
     866            if (isValidChangesetQuery())
     867                return;
    867868            HelpAwareOptionPane.showOptionDialog(
    868869                    this,
     
    949950
    950951        public void displayMessageIfInvalid() {
    951             if (isValidChangesetQuery()) return;
     952            if (isValidChangesetQuery())
     953                return;
    952954            HelpAwareOptionPane.showOptionDialog(
    953955                    this,
     
    968970     */
    969971    private static class UidInputFieldValidator extends AbstractTextComponentValidator {
     972        UidInputFieldValidator(JTextComponent tc) {
     973            super(tc);
     974        }
     975
    970976        public static UidInputFieldValidator decorate(JTextComponent tc) {
    971977            return new UidInputFieldValidator(tc);
    972         }
    973 
    974         UidInputFieldValidator(JTextComponent tc) {
    975             super(tc);
    976978        }
    977979
     
    10061008            try {
    10071009                int uid = Integer.parseInt(value.trim());
    1008                 if (uid > 0) return uid;
     1010                if (uid > 0)
     1011                    return uid;
    10091012                return 0;
    10101013            } catch (NumberFormatException e) {
     
    10211024     */
    10221025    private static class DateValidator extends AbstractTextComponentValidator {
     1026        DateValidator(JTextComponent tc) {
     1027            super(tc);
     1028        }
     1029
    10231030        public static DateValidator decorate(JTextComponent tc) {
    10241031            return new DateValidator(tc);
    1025         }
    1026 
    1027         DateValidator(JTextComponent tc) {
    1028             super(tc);
    10291032        }
    10301033
     
    10881091     */
    10891092    private static class TimeValidator extends AbstractTextComponentValidator {
     1093        TimeValidator(JTextComponent tc) {
     1094            super(tc);
     1095        }
     1096
    10901097        public static TimeValidator decorate(JTextComponent tc) {
    10911098            return new TimeValidator(tc);
    10921099        }
    10931100
    1094         TimeValidator(JTextComponent tc) {
    1095             super(tc);
    1096         }
    1097 
    10981101        @Override
    10991102        public boolean isValid() {
    1100             if (getComponent().getText().trim().isEmpty()) return true;
     1103            if (getComponent().getText().trim().isEmpty())
     1104                return true;
    11011105            return getDate() != null;
    11021106        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java

    r8836 r10179  
    103103        gc.fill = GridBagConstraints.HORIZONTAL;
    104104        gc.weightx = 1.0;
    105         pnl.add(cbMyChangesetsOnly = new JCheckBox(tr("Download my changesets only")), gc);
     105        cbMyChangesetsOnly = new JCheckBox(tr("Download my changesets only"));
     106        pnl.add(cbMyChangesetsOnly, gc);
    106107        cbMyChangesetsOnly.setToolTipText(
    107108                tr("<html>Select to restrict the query to your changesets only.<br>Unselect to include all changesets in the query.</html>"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java

    r9916 r10179  
    3232/**
    3333 * This is a modal dialog for entering query criteria to search for changesets.
    34  *
     34 * @since 2689
    3535 */
    3636public class ChangesetQueryDialog extends JDialog {
    3737
    3838    private JTabbedPane tpQueryPanels;
    39     private BasicChangesetQueryPanel pnlBasicChangesetQueries;
    40     private UrlBasedQueryPanel pnlUrlBasedQueries;
    41     private AdvancedChangesetQueryPanel pnlAdvancedQueries;
     39    private final BasicChangesetQueryPanel pnlBasicChangesetQueries = new BasicChangesetQueryPanel();
     40    private final UrlBasedQueryPanel pnlUrlBasedQueries = new UrlBasedQueryPanel();
     41    private final AdvancedChangesetQueryPanel pnlAdvancedQueries = new AdvancedChangesetQueryPanel();
    4242    private boolean canceled;
     43
     44    /**
     45     * Constructs a new {@code ChangesetQueryDialog}.
     46     * @param parent parent window
     47     */
     48    public ChangesetQueryDialog(Window parent) {
     49        super(parent, ModalityType.DOCUMENT_MODAL);
     50        build();
     51    }
    4352
    4453    protected JPanel buildContentPanel() {
    4554        tpQueryPanels = new JTabbedPane();
    46         tpQueryPanels.add(pnlBasicChangesetQueries = new BasicChangesetQueryPanel());
    47         tpQueryPanels.add(pnlUrlBasedQueries = new UrlBasedQueryPanel());
    48         tpQueryPanels.add(pnlAdvancedQueries = new AdvancedChangesetQueryPanel());
     55        tpQueryPanels.add(pnlBasicChangesetQueries);
     56        tpQueryPanels.add(pnlUrlBasedQueries);
     57        tpQueryPanels.add(pnlAdvancedQueries);
    4958
    5059        tpQueryPanels.setTitleAt(0, tr("Basic"));
     
    92101
    93102        addWindowListener(new WindowEventHandler());
    94     }
    95 
    96     public ChangesetQueryDialog(Window parent) {
    97         super(parent, ModalityType.DOCUMENT_MODAL);
    98         build();
    99103    }
    100104
     
    184188                    }
    185189                    break;
    186 
    187190                case 2:
    188191                    if (getChangesetQuery() == null) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java

    r9079 r10179  
    3131public class UrlBasedQueryPanel extends JPanel {
    3232
    33     private JosmTextField tfUrl;
    34     private JLabel lblValid;
     33    private final JosmTextField tfUrl = new JosmTextField();
     34    private final JLabel lblValid = new JLabel();
     35
     36    /**
     37     * Constructs a new {@code UrlBasedQueryPanel}.
     38     */
     39    public UrlBasedQueryPanel() {
     40        build();
     41    }
    3542
    3643    protected JPanel buildURLPanel() {
     
    4552        gc.weightx = 1.0;
    4653        gc.fill = GridBagConstraints.HORIZONTAL;
    47         pnl.add(tfUrl = new JosmTextField(), gc);
     54        pnl.add(tfUrl, gc);
    4855        tfUrl.getDocument().addDocumentListener(new ChangetQueryUrlValidator());
    4956        tfUrl.addFocusListener(
     
    5966        gc.weightx = 0.0;
    6067        gc.fill = GridBagConstraints.HORIZONTAL;
    61         pnl.add(lblValid = new JLabel(), gc);
     68        pnl.add(lblValid, gc);
    6269        lblValid.setPreferredSize(new Dimension(20, 20));
    6370        return pnl;
     
    115122    }
    116123
    117     /**
    118      * Constructs a new {@code UrlBasedQueryPanel}.
    119      */
    120     public UrlBasedQueryPanel() {
    121         build();
    122     }
    123 
    124124    protected boolean isValidChangesetQueryUrl(String text) {
    125125        return buildChangesetQuery(text) != null;
     
    135135        String path = url.getPath();
    136136        String query = url.getQuery();
    137         if (path == null || !path.endsWith("/changesets")) return null;
     137        if (path == null || !path.endsWith("/changesets"))
     138            return null;
    138139
    139140        try {
     
    170171
    171172        protected void feedbackValid() {
    172             if ("valid".equals(getCurrentFeedback())) return;
     173            if ("valid".equals(getCurrentFeedback()))
     174                return;
    173175            lblValid.setIcon(ImageProvider.get("dialogs", "valid"));
    174176            lblValid.setToolTipText(null);
     
    177179
    178180        protected void feedbackInvalid() {
    179             if ("invalid".equals(getCurrentFeedback())) return;
     181            if ("invalid".equals(getCurrentFeedback()))
     182                return;
    180183            lblValid.setIcon(ImageProvider.get("warning-small"));
    181184            lblValid.setToolTipText(tr("This changeset query URL is invalid"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java

    r9543 r10179  
    3939    private final ReferringRelationsBrowserModel model;
    4040    private final transient OsmDataLayer layer;
    41     private JCheckBox cbReadFull;
     41    private final JCheckBox cbReadFull = new JCheckBox(tr("including immediate children of parent relations"));
    4242    private EditAction editAction;
     43
     44    /**
     45     * Constructs a new {@code ReferringRelationsBrowser}.
     46     * @param layer OSM data layer
     47     * @param model referrinf relations browser model
     48     */
     49    public ReferringRelationsBrowser(OsmDataLayer layer, ReferringRelationsBrowserModel model) {
     50        this.model = model;
     51        this.layer = layer;
     52        build();
     53    }
    4354
    4455    /**
     
    5869        referrers.getModel().addListDataListener(reloadAction);
    5970        pnl.add(new SideButton(reloadAction));
    60         pnl.add(cbReadFull = new JCheckBox(tr("including immediate children of parent relations")));
     71        pnl.add(cbReadFull);
    6172
    6273        editAction = new EditAction();
     
    6475        pnl.add(new SideButton(editAction));
    6576        add(pnl, BorderLayout.SOUTH);
    66     }
    67 
    68     public ReferringRelationsBrowser(OsmDataLayer layer, ReferringRelationsBrowserModel model) {
    69         this.model = model;
    70         this.layer = layer;
    71         build();
    7277    }
    7378
     
    157162        public void run() {
    158163            int idx = referrers.getSelectedIndex();
    159             if (idx < 0) return;
     164            if (idx < 0)
     165                return;
    160166            Relation r = model.getElementAt(idx);
    161             if (r == null) return;
     167            if (r == null)
     168                return;
    162169            RelationEditor editor = RelationEditor.getEditor(getLayer(), r, null);
    163170            editor.setVisible(true);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorter.java

    r8998 r10179  
    154154                    list = customMap.get(sorter);
    155155                    if (list == null) {
    156                         customMap.put(sorter, list = new LinkedList<>());
     156                        list = new LinkedList<>();
     157                        customMap.put(sorter, list);
    157158                    }
    158159                    list.add(m);
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java

    r9606 r10179  
    4747
    4848    /** displays information about the current download area */
    49     private JMultilineLabel lblCurrentDownloadArea;
     49    private final JMultilineLabel lblCurrentDownloadArea = new JMultilineLabel("");
    5050    private final JosmTextArea bboxDisplay = new JosmTextArea();
    5151    /** the add action */
    52     private AddAction actAdd;
     52    private final AddAction actAdd = new AddAction();
    5353
    5454    /**
     
    8484        gc.anchor = GridBagConstraints.NORTHWEST;
    8585        gc.insets = new Insets(5, 5, 5, 5);
    86         pnl.add(lblCurrentDownloadArea = new JMultilineLabel(""), gc);
     86        pnl.add(lblCurrentDownloadArea, gc);
    8787
    8888        gc.weightx = 1.0;
     
    9898        gc.weighty = 0.0;
    9999        gc.insets = new Insets(5, 5, 5, 5);
    100         pnl.add(new JButton(actAdd = new AddAction()), gc);
     100        pnl.add(new JButton(actAdd), gc);
    101101        return pnl;
    102102    }
     
    163163    @Override
    164164    public void setDownloadArea(Bounds area) {
    165         if (area == null) return;
     165        if (area == null)
     166            return;
    166167        this.currentArea = area;
    167168        bookmarks.clearSelection();
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r10173 r10179  
    8383    protected JCheckBox cbDownloadNotes;
    8484    /** the download action and button */
    85     private DownloadAction actDownload;
    86     protected SideButton btnDownload;
     85    private final DownloadAction actDownload = new DownloadAction();
     86    protected final SideButton btnDownload = new SideButton(actDownload);
    8787
    8888    private void makeCheckBoxRespondToEnter(JCheckBox cb) {
     
    190190
    191191        // -- download button
    192         pnl.add(btnDownload = new SideButton(actDownload = new DownloadAction()));
     192        pnl.add(btnDownload);
    193193        InputMapUtils.enableEnter(btnDownload);
    194194
     
    201201        SideButton btnCancel;
    202202        CancelAction actCancel = new CancelAction();
    203         pnl.add(btnCancel = new SideButton(actCancel));
     203        btnCancel = new SideButton(actCancel);
     204        pnl.add(btnCancel);
    204205        InputMapUtils.enableEnter(btnCancel);
    205206
     
    209210
    210211        // -- help button
    211         SideButton btnHelp;
    212         pnl.add(btnHelp = new SideButton(new ContextSensitiveHelpAction(getRootPane().getClientProperty("help").toString())));
     212        SideButton btnHelp = new SideButton(new ContextSensitiveHelpAction(getRootPane().getClientProperty("help").toString()));
     213        pnl.add(btnHelp);
    213214        InputMapUtils.enableEnter(btnHelp);
    214215
  • trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java

    r10055 r10179  
    8383        gc.fill = GridBagConstraints.HORIZONTAL;
    8484        gc.anchor = GridBagConstraints.NORTHWEST;
    85         add(referenceLatLonViewer = new LatLonViewer(model, PointInTimeType.REFERENCE_POINT_IN_TIME), gc);
     85        referenceLatLonViewer = new LatLonViewer(model, PointInTimeType.REFERENCE_POINT_IN_TIME);
     86        add(referenceLatLonViewer, gc);
    8687
    8788        gc.gridx = 1;
     
    9192        gc.fill = GridBagConstraints.HORIZONTAL;
    9293        gc.anchor = GridBagConstraints.NORTHWEST;
    93         add(currentLatLonViewer = new LatLonViewer(model, PointInTimeType.CURRENT_POINT_IN_TIME), gc);
     94        currentLatLonViewer = new LatLonViewer(model, PointInTimeType.CURRENT_POINT_IN_TIME);
     95        add(currentLatLonViewer, gc);
    9496
    9597        // --------------------
     
    101103        gc.weightx = 1.0;
    102104        gc.weighty = 0.0;
    103         add(distanceViewer = new DistanceViewer(model), gc);
     105        distanceViewer = new DistanceViewer(model);
     106        add(distanceViewer, gc);
    104107
    105108        // the map panel
     
    110113        gc.weightx = 1.0;
    111114        gc.weighty = 1.0;
    112         add(mapViewer = new MapViewer(model), gc);
     115        mapViewer = new MapViewer(model);
     116        add(mapViewer, gc);
    113117        mapViewer.setZoomContolsVisible(false);
    114118    }
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java

    r9543 r10179  
    3434
    3535    /**
     36     * Constructs a new {@code HistoryBrowser}.
     37     */
     38    public HistoryBrowser() {
     39        model = new HistoryBrowserModel();
     40        build();
     41    }
     42
     43    /**
     44     * Constructs a new {@code HistoryBrowser}.
     45     * @param history the history of an {@link OsmPrimitive}
     46     */
     47    public HistoryBrowser(History history) {
     48        this();
     49        populate(history);
     50    }
     51
     52    /**
    3653     * creates the table which shows the list of versions
    3754     *
     
    4057    protected JPanel createVersionTablePanel() {
    4158        JPanel pnl = new JPanel(new BorderLayout());
    42 
    43         VersionTable versionTable = new VersionTable(model);
    44         pnl.add(new JScrollPane(versionTable), BorderLayout.CENTER);
     59        pnl.add(new JScrollPane(new VersionTable(model)), BorderLayout.CENTER);
    4560        return pnl;
    4661    }
     
    8297     */
    8398    protected void build() {
    84         JPanel left;
    85         JPanel right;
     99        JPanel left = createVersionTablePanel();
     100        JPanel right = createVersionComparePanel();
    86101        setLayout(new BorderLayout());
    87         JSplitPane pane = new JSplitPane(
    88                 JSplitPane.HORIZONTAL_SPLIT,
    89                 left = createVersionTablePanel(),
    90                 right = createVersionComparePanel()
    91         );
     102        JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
    92103        add(pane, BorderLayout.CENTER);
    93104
     
    100111    }
    101112
    102     /**
    103      * constructor
    104      */
    105     public HistoryBrowser() {
    106         model = new HistoryBrowserModel();
    107         build();
    108     }
    109 
    110     /**
    111      * constructor
    112      * @param history  the history of an {@link OsmPrimitive}
    113      */
    114     public HistoryBrowser(History history) {
    115         this();
    116         populate(history);
    117     }
    118113
    119114    /**
  • trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java

    r10035 r10179  
    6161        JPanel pnl = new JPanel(new BorderLayout());
    6262        model = new DefaultListModel<>();
    63         pnl.add(new JScrollPane(lstOpenChangesets = new JList<>(model)), BorderLayout.CENTER);
     63        lstOpenChangesets = new JList<>(model);
     64        pnl.add(new JScrollPane(lstOpenChangesets), BorderLayout.CENTER);
    6465        lstOpenChangesets.setCellRenderer(new ChangesetCellRenderer());
    6566        return pnl;
     
    7273        CloseAction closeAction = new CloseAction();
    7374        lstOpenChangesets.addListSelectionListener(closeAction);
    74         pnl.add(btnCloseChangesets = new SideButton(closeAction));
     75        btnCloseChangesets = new SideButton(closeAction);
     76        pnl.add(btnCloseChangesets);
    7577        InputMapUtils.enableEnter(btnCloseChangesets);
    7678
    7779        // -- cancel action
    78         SideButton btn;
    79         pnl.add(btn = new SideButton(new CancelAction()));
     80        SideButton btn = new SideButton(new CancelAction());
     81        pnl.add(btn);
    8082        btn.setFocusable(true);
    8183        return pnl;
  • trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java

    r10173 r10179  
    117117    public void prepareForOsmApiCredentials(String username, String password) {
    118118        setTitle(tr("Enter credentials for OSM API"));
    119         getContentPane().add(pnlCredentials = new OsmApiCredentialsPanel(this), BorderLayout.CENTER);
     119        pnlCredentials = new OsmApiCredentialsPanel(this);
     120        getContentPane().add(pnlCredentials, BorderLayout.CENTER);
    120121        pnlCredentials.init(username, password);
    121122        validate();
     
    124125    public void prepareForOtherHostCredentials(String username, String password, String host) {
    125126        setTitle(tr("Enter credentials for host"));
    126         getContentPane().add(pnlCredentials = new OtherHostCredentialsPanel(this, host), BorderLayout.CENTER);
     127        pnlCredentials = new OtherHostCredentialsPanel(this, host);
     128        getContentPane().add(pnlCredentials, BorderLayout.CENTER);
    127129        pnlCredentials.init(username, password);
    128130        validate();
     
    131133    public void prepareForProxyCredentials(String username, String password) {
    132134        setTitle(tr("Enter credentials for HTTP proxy"));
    133         getContentPane().add(pnlCredentials = new HttpProxyCredentialsPanel(this), BorderLayout.CENTER);
     135        pnlCredentials = new HttpProxyCredentialsPanel(this);
     136        getContentPane().add(pnlCredentials, BorderLayout.CENTER);
    134137        pnlCredentials.init(username, password);
    135138        validate();
     
    137140
    138141    public String getUsername() {
    139         if (pnlCredentials == null) return null;
     142        if (pnlCredentials == null)
     143            return null;
    140144        return pnlCredentials.getUserName();
    141145    }
    142146
    143147    public char[] getPassword() {
    144         if (pnlCredentials == null) return null;
     148        if (pnlCredentials == null)
     149            return null;
    145150        return pnlCredentials.getPassword();
    146151    }
    147152
    148153    public boolean isSaveCredentials() {
    149         if (pnlCredentials == null) return false;
     154        if (pnlCredentials == null)
     155            return false;
    150156        return pnlCredentials.isSaveCredentials();
    151157    }
     
    155161        protected JosmPasswordField tfPassword;
    156162        protected JCheckBox cbSaveCredentials;
    157         protected JMultilineLabel lblHeading;
    158         protected JMultilineLabel lblWarning;
     163        protected final JMultilineLabel lblHeading = new JMultilineLabel("");
     164        protected final JMultilineLabel lblWarning = new JMultilineLabel("");
    159165        protected CredentialDialog owner; // owner Dependency Injection to use Key listeners for username and password text fields
    160166
     
    176182            gc.weighty = 0.0;
    177183            gc.insets = new Insets(0, 0, 10, 0);
    178             add(lblHeading = new JMultilineLabel(""), gc);
     184            add(lblHeading, gc);
    179185
    180186            gc.gridx = 0;
     
    208214            gc.weightx = 1.0;
    209215            gc.weighty = 0.0;
    210             lblWarning = new JMultilineLabel("");
    211216            lblWarning.setFont(lblWarning.getFont().deriveFont(Font.ITALIC));
    212217            add(lblWarning, gc);
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r10035 r10179  
    6767    private SaveLayersModel model;
    6868    private UserAction action = UserAction.CANCEL;
    69     private UploadAndSaveProgressRenderer pnlUploadLayers;
    70 
    71     private SaveAndProceedAction saveAndProceedAction;
    72     private SaveSessionAction saveSessionAction;
    73     private DiscardAndProceedAction discardAndProceedAction;
    74     private CancelAction cancelAction;
     69    private final UploadAndSaveProgressRenderer pnlUploadLayers = new UploadAndSaveProgressRenderer();
     70
     71    private final SaveAndProceedAction saveAndProceedAction = new SaveAndProceedAction();
     72    private final SaveSessionAction saveSessionAction = new SaveSessionAction();
     73    private final DiscardAndProceedAction discardAndProceedAction = new DiscardAndProceedAction();
     74    private final CancelAction cancelAction = new CancelAction();
    7575    private transient SaveAndUploadTask saveAndUploadTask;
     76
     77    private final JButton saveAndProceedActionButton = new JButton(saveAndProceedAction);
     78
     79    /**
     80     * Constructs a new {@code SaveLayersDialog}.
     81     * @param parent parent component
     82     */
     83    public SaveLayersDialog(Component parent) {
     84        super(GuiHelper.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL);
     85        build();
     86    }
    7687
    7788    /**
     
    96107    }
    97108
    98     private JButton saveAndProceedActionButton;
    99 
    100109    /**
    101110     * builds the button row
     
    106115        JPanel pnl = new JPanel(new GridBagLayout());
    107116
    108         saveAndProceedAction = new SaveAndProceedAction();
    109117        model.addPropertyChangeListener(saveAndProceedAction);
    110         pnl.add(saveAndProceedActionButton = new JButton(saveAndProceedAction), GBC.std(0, 0).insets(5, 5, 0, 0).fill(GBC.HORIZONTAL));
    111 
    112         saveSessionAction = new SaveSessionAction();
     118        pnl.add(saveAndProceedActionButton, GBC.std(0, 0).insets(5, 5, 0, 0).fill(GBC.HORIZONTAL));
     119
    113120        pnl.add(new JButton(saveSessionAction), GBC.std(1, 0).insets(5, 5, 5, 0).fill(GBC.HORIZONTAL));
    114121
    115         discardAndProceedAction = new DiscardAndProceedAction();
    116122        model.addPropertyChangeListener(discardAndProceedAction);
    117123        pnl.add(new JButton(discardAndProceedAction), GBC.std(0, 1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL));
    118124
    119         cancelAction = new CancelAction();
    120125        pnl.add(new JButton(cancelAction), GBC.std(1, 1).insets(5, 5, 5, 5).fill(GBC.HORIZONTAL));
    121126
    122127        JPanel pnl2 = new JPanel(new BorderLayout());
    123         pnl2.add(pnlUploadLayers = new UploadAndSaveProgressRenderer(), BorderLayout.CENTER);
     128        pnl2.add(pnlUploadLayers, BorderLayout.CENTER);
    124129        model.addPropertyChangeListener(pnlUploadLayers);
    125130        pnl2.add(pnl, BorderLayout.SOUTH);
     
    137142        this.saveAndProceedAction.initForSaveAndDelete();
    138143        this.discardAndProceedAction.initForDiscardAndDelete();
    139     }
    140 
    141     public SaveLayersDialog(Component parent) {
    142         super(GuiHelper.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL);
    143         build();
    144144    }
    145145
     
    311311        public void cancel() {
    312312            switch(model.getMode()) {
    313             case EDITING_DATA: cancelWhenInEditingModel(); break;
    314             case UPLOADING_AND_SAVING: cancelSafeAndUploadTask(); break;
     313            case EDITING_DATA: cancelWhenInEditingModel();
     314                break;
     315            case UPLOADING_AND_SAVING: cancelSafeAndUploadTask();
     316                break;
    315317            }
    316318        }
     
    350352                Mode mode = (Mode) evt.getNewValue();
    351353                switch(mode) {
    352                 case EDITING_DATA: setEnabled(true); break;
    353                 case UPLOADING_AND_SAVING: setEnabled(false); break;
     354                case EDITING_DATA: setEnabled(true);
     355                    break;
     356                case UPLOADING_AND_SAVING: setEnabled(false);
     357                    break;
    354358                }
    355359            }
     
    433437                SaveLayersModel.Mode mode = (SaveLayersModel.Mode) evt.getNewValue();
    434438                switch(mode) {
    435                 case EDITING_DATA: setEnabled(true); break;
    436                 case UPLOADING_AND_SAVING: setEnabled(false); break;
     439                case EDITING_DATA: setEnabled(true);
     440                    break;
     441                case UPLOADING_AND_SAVING: setEnabled(false);
     442                    break;
    437443                }
    438444            }
     
    560566        protected void warnBecauseOfUnsavedData() {
    561567            int numProblems = model.getNumCancel() + model.getNumFailed();
    562             if (numProblems == 0) return;
     568            if (numProblems == 0)
     569                return;
    563570            Main.warn(numProblems + " problems occured during upload/save");
    564571            String msg = trn(
  • trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java

    r10035 r10179  
    5151public class UploadSelectionDialog extends JDialog {
    5252
    53     private OsmPrimitiveList lstSelectedPrimitives;
    54     private OsmPrimitiveList lstDeletedPrimitives;
     53    private final OsmPrimitiveList lstSelectedPrimitives = new OsmPrimitiveList();
     54    private final OsmPrimitiveList lstDeletedPrimitives = new OsmPrimitiveList();
    5555    private JSplitPane spLists;
    5656    private boolean canceled;
     
    7171        lbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    7272        pnl.add(lbl, BorderLayout.NORTH);
    73         pnl.add(new JScrollPane(lstSelectedPrimitives = new OsmPrimitiveList()), BorderLayout.CENTER);
     73        pnl.add(new JScrollPane(lstSelectedPrimitives), BorderLayout.CENTER);
    7474        lbl.setLabelFor(lstSelectedPrimitives);
    7575        return pnl;
     
    8181        lbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    8282        pnl.add(lbl, BorderLayout.NORTH);
    83         pnl.add(new JScrollPane(lstDeletedPrimitives = new OsmPrimitiveList()), BorderLayout.CENTER);
     83        pnl.add(new JScrollPane(lstDeletedPrimitives), BorderLayout.CENTER);
    8484        lbl.setLabelFor(lstDeletedPrimitives);
    8585        return pnl;
     
    8989        JPanel pnl = new JPanel(new FlowLayout());
    9090        ContinueAction continueAction = new ContinueAction();
    91         pnl.add(btnContinue = new SideButton(continueAction));
     91        btnContinue = new SideButton(continueAction);
     92        pnl.add(btnContinue);
    9293        btnContinue.setFocusable(true);
    9394        lstDeletedPrimitives.getSelectionModel().addListSelectionListener(continueAction);
     
    176177
    177178    static class OsmPrimitiveList extends JList<OsmPrimitive> {
     179        OsmPrimitiveList() {
     180            this(new OsmPrimitiveListModel());
     181        }
     182
     183        OsmPrimitiveList(OsmPrimitiveListModel model) {
     184            super(model);
     185            init();
     186        }
     187
    178188        protected void init() {
    179189            setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    180190            setCellRenderer(new OsmPrimitivRenderer());
    181         }
    182 
    183         OsmPrimitiveList() {
    184             this(new OsmPrimitiveListModel());
    185         }
    186 
    187         OsmPrimitiveList(OsmPrimitiveListModel model) {
    188             super(model);
    189             init();
    190191        }
    191192
     
    208209                        public int compare(OsmPrimitive o1, OsmPrimitive o2) {
    209210                            int ret = OsmPrimitiveType.from(o1).compareTo(OsmPrimitiveType.from(o2));
    210                             if (ret != 0) return ret;
     211                            if (ret != 0)
     212                                return ret;
    211213                            return o1.getDisplayName(formatter).compareTo(o1.getDisplayName(formatter));
    212214                        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    r10173 r10179  
    5656    private transient Map<UploadStrategy, JLabel> lblNumRequests;
    5757    private transient Map<UploadStrategy, JMultilineLabel> lblStrategies;
    58     private JosmTextField tfChunkSize;
    59     private JPanel pnlMultiChangesetPolicyPanel;
    60     private JRadioButton rbFillOneChangeset;
    61     private JRadioButton rbUseMultipleChangesets;
     58    private final JosmTextField tfChunkSize = new JosmTextField(4);
     59    private final JPanel pnlMultiChangesetPolicyPanel = new JPanel(new GridBagLayout());
     60    private final JRadioButton rbFillOneChangeset = new JRadioButton(
     61            tr("Fill up one changeset and return to the Upload Dialog"));
     62    private final JRadioButton rbUseMultipleChangesets = new JRadioButton(
     63            tr("Open and use as many new changesets as necessary"));
    6264    private JMultilineLabel lblMultiChangesetPoliciesHeader;
    6365
     
    138140        gc.weighty = 0.0;
    139141        gc.gridwidth = 1;
    140         pnl.add(tfChunkSize = new JosmTextField(4), gc);
     142        pnl.add(tfChunkSize, gc);
    141143        gc.gridx = 3;
    142144        gc.gridy = 2;
     
    181183
    182184    protected JPanel buildMultiChangesetPolicyPanel() {
    183         pnlMultiChangesetPolicyPanel = new JPanel(new GridBagLayout());
    184185        GridBagConstraints gc = new GridBagConstraints();
    185186        gc.gridx = 0;
     
    188189        gc.anchor = GridBagConstraints.FIRST_LINE_START;
    189190        gc.weightx = 1.0;
    190         pnlMultiChangesetPolicyPanel.add(lblMultiChangesetPoliciesHeader = new JMultilineLabel(
     191        lblMultiChangesetPoliciesHeader = new JMultilineLabel(
    191192                tr("<html>There are <strong>multiple changesets</strong> necessary in order to upload {0} objects. " +
    192193                   "Which strategy do you want to use?</html>",
    193                         numUploadedObjects)), gc);
     194                        numUploadedObjects));
     195        pnlMultiChangesetPolicyPanel.add(lblMultiChangesetPoliciesHeader, gc);
    194196        gc.gridy = 1;
    195         pnlMultiChangesetPolicyPanel.add(rbFillOneChangeset = new JRadioButton(
    196                 tr("Fill up one changeset and return to the Upload Dialog")), gc);
    197         gc.gridy = 2;
    198         pnlMultiChangesetPolicyPanel.add(rbUseMultipleChangesets = new JRadioButton(
    199                 tr("Open and use as many new changesets as necessary")), gc);
     197        pnlMultiChangesetPolicyPanel.add(rbFillOneChangeset, gc);
     198        gc.gridy = 2;
     199        pnlMultiChangesetPolicyPanel.add(rbUseMultipleChangesets, gc);
    200200
    201201        ButtonGroup bgMultiChangesetPolicies = new ButtonGroup();
     
    473473        public void itemStateChanged(ItemEvent e) {
    474474            UploadStrategy strategy = getUploadStrategy();
    475             if (strategy == null) return;
     475            if (strategy == null)
     476                return;
    476477            switch(strategy) {
    477478            case CHUNKED_DATASET_STRATEGY:
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r10168 r10179  
    15801580                int offset = 200;
    15811581                for (String part: cachedTileLoader.getStats().split("\n")) {
    1582                     myDrawString(g, tr("Cache stats: {0}", part), 50, offset += 15);
    1583                 }
    1584 
     1582                    offset += 15;
     1583                    myDrawString(g, tr("Cache stats: {0}", part), 50, offset);
     1584                }
    15851585            }
    15861586        }
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r10173 r10179  
    103103
    104104    public double getPPD() {
    105         if (!Main.isDisplayingMapView()) return Main.getProjection().getDefaultZoomInPPD();
     105        if (!Main.isDisplayingMapView())
     106            return Main.getProjection().getDefaultZoomInPPD();
    106107        ProjectionBounds bounds = Main.map.mapView.getProjectionBounds();
    107108        return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast);
     
    122123
    123124    public void displace(double dx, double dy) {
    124         setOffset(this.dx += dx, this.dy += dy);
    125     }
    126 
     125        this.dx += dx;
     126        this.dy += dy;
     127        setOffset(this.dx, this.dy);
     128    }
     129
     130    /**
     131     * Returns imagery info.
     132     * @return imagery info
     133     */
    127134    public ImageryInfo getInfo() {
    128135        return info;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java

    r9078 r10179  
    9898            MapPaintAction a = actions.get(k);
    9999            if (a == null) {
    100                 actions.put(k, a = new MapPaintAction(style));
     100                a = new MapPaintAction(style);
     101                actions.put(k, a);
    101102                add(a.getButton());
    102103            } else {
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r10035 r10179  
    3737public class PreferenceDialog extends JDialog {
    3838
    39     private PreferenceTabbedPane tpPreferences;
     39    private final PreferenceTabbedPane tpPreferences = new PreferenceTabbedPane();
    4040    private boolean canceled;
     41
     42    /**
     43     * Constructs a new {@code PreferenceDialog}.
     44     * @param parent parent component
     45     */
     46    public PreferenceDialog(Component parent) {
     47        super(GuiHelper.getFrameForComponent(parent), tr("Preferences"), ModalityType.DOCUMENT_MODAL);
     48        build();
     49        this.setMinimumSize(new Dimension(600, 350));
     50        // set the maximum width to the current screen. If the dialog is opened on a
     51        // smaller screen than before, this will reset the stored preference.
     52        this.setMaximumSize(GuiHelper.getScreenSize());
     53    }
    4154
    4255    protected JPanel buildActionPanel() {
     
    6578        Container c = getContentPane();
    6679        c.setLayout(new BorderLayout());
    67         c.add(tpPreferences = new PreferenceTabbedPane(), BorderLayout.CENTER);
     80        c.add(tpPreferences, BorderLayout.CENTER);
    6881        tpPreferences.buildGui();
    6982        tpPreferences.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     
    7588        getRootPane().getActionMap().put("cancel", new CancelAction());
    7689        HelpUtil.setHelpContext(getRootPane(), HelpUtil.ht("/Action/Preferences"));
    77     }
    78 
    79     public PreferenceDialog(Component parent) {
    80         super(GuiHelper.getFrameForComponent(parent), tr("Preferences"), ModalityType.DOCUMENT_MODAL);
    81         build();
    82         this.setMinimumSize(new Dimension(600, 350));
    83         // set the maximum width to the current screen. If the dialog is opened on a
    84         // smaller screen than before, this will reset the stored preference.
    85         this.setMaximumSize(GuiHelper.getScreenSize());
    8690    }
    8791
     
    126130    }
    127131
     132    /**
     133     * Select preferences tab by name.
     134     * @param name preferences tab name (icon)
     135     */
    128136    public void selectPreferencesTabByName(String name) {
    129137        tpPreferences.selectTabByName(name);
    130138    }
    131139
     140    /**
     141     * Select preferences tab by class.
     142     * @param clazz preferences tab class
     143     */
    132144    public void selectPreferencesTabByClass(Class<? extends TabPreferenceSetting> clazz) {
    133145        tpPreferences.selectTabByPref(clazz);
    134146    }
    135147
     148    /**
     149     * Select preferences sub-tab by class.
     150     * @param clazz preferences sub-tab class
     151     */
    136152    public void selectSubPreferencesTabByClass(Class<? extends SubPreferenceSetting> clazz) {
    137153        tpPreferences.selectSubTabByPref(clazz);
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r10114 r10179  
    14861486                        Matcher m = Pattern.compile("^(.+);(.+)$").matcher(line);
    14871487                        if (m.matches()) {
    1488                             sources.add(last = new ExtendedSourceEntry(m.group(1), m.group(2)));
     1488                            last = new ExtendedSourceEntry(m.group(1), m.group(2));
     1489                            sources.add(last);
    14891490                        } else {
    14901491                            Main.error(tr(getStr(I18nString.ILLEGAL_FORMAT_OF_ENTRY), url, line));
     
    15281529
    15291530    class FileOrUrlCellEditor extends JPanel implements TableCellEditor {
    1530         private JosmTextField tfFileName;
     1531        private final JosmTextField tfFileName = new JosmTextField();
    15311532        private final CopyOnWriteArrayList<CellEditorListener> listeners;
    15321533        private String value;
     
    15441545            gc.weightx = 1.0;
    15451546            gc.weighty = 1.0;
    1546             add(tfFileName = new JosmTextField(), gc);
     1547            add(tfFileName, gc);
    15471548
    15481549            gc.gridx = 1;
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r10173 r10179  
    682682        private JPanel actionParametersPanel;
    683683
    684         private JButton upButton;
    685         private JButton downButton;
    686         private JButton removeButton;
    687         private JButton addButton;
     684        private final JButton upButton = createButton("up");
     685        private final JButton downButton = createButton("down");
     686        private final JButton removeButton = createButton(">");
     687        private final JButton addButton = createButton("<");
    688688
    689689        private String movingComponent;
    690690
     691        /**
     692         * Constructs a new {@code Settings}.
     693         * @param rootActionsNode root actions node
     694         */
    691695        public Settings(DefaultMutableTreeNode rootActionsNode) {
    692696            super(/* ICON(preferences/) */ "toolbar", tr("Toolbar customization"), tr("Customize the elements on the toolbar."));
     
    815819
    816820            final JPanel buttons = new JPanel(new GridLayout(6, 1));
    817             buttons.add(upButton = createButton("up"));
    818             buttons.add(addButton = createButton("<"));
    819             buttons.add(removeButton = createButton(">"));
    820             buttons.add(downButton = createButton("down"));
     821            buttons.add(upButton);
     822            buttons.add(addButton);
     823            buttons.add(removeButton);
     824            buttons.add(downButton);
    821825            updateEnabledState();
    822826
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r9778 r10179  
    6666        add(formats, GBC.eol().fill());
    6767
    68         add(wmsInstruction = new JLabel(tr("4. Verify generated WMS URL")), GBC.eol());
     68        wmsInstruction = new JLabel(tr("4. Verify generated WMS URL"));
     69        add(wmsInstruction, GBC.eol());
    6970        wmsInstruction.setLabelFor(wmsUrl);
    7071        add(wmsUrl, GBC.eop().fill());
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r10134 r10179  
    7979    private ImageryLayerInfo layerInfo;
    8080
    81     private CommonSettingsPanel commonSettings;
    82     private WMSSettingsPanel wmsSettings;
    83     private TMSSettingsPanel tmsSettings;
     81    private final CommonSettingsPanel commonSettings = new CommonSettingsPanel();
     82    private final WMSSettingsPanel wmsSettings = new WMSSettingsPanel();
     83    private final TMSSettingsPanel tmsSettings = new TMSSettingsPanel();
    8484
    8585    /**
     
    115115        p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    116116
    117         addSettingsSection(p, tr("Common Settings"), commonSettings = new CommonSettingsPanel());
    118         addSettingsSection(p, tr("WMS Settings"), wmsSettings = new WMSSettingsPanel(),
     117        addSettingsSection(p, tr("Common Settings"), commonSettings);
     118        addSettingsSection(p, tr("WMS Settings"), wmsSettings,
    119119                GBC.eol().fill(GBC.HORIZONTAL));
    120         addSettingsSection(p, tr("TMS Settings"), tmsSettings = new TMSSettingsPanel(),
     120        addSettingsSection(p, tr("TMS Settings"), tmsSettings,
    121121                GBC.eol().fill(GBC.HORIZONTAL));
    122122
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java

    r9212 r10179  
    4646
    4747        static Policy fromPreferenceValue(String preferenceValue) {
    48             if (preferenceValue == null) return null;
    49             preferenceValue = preferenceValue.trim().toLowerCase(Locale.ENGLISH);
     48            if (preferenceValue == null)
     49                return null;
     50            String prefValue = preferenceValue.trim().toLowerCase(Locale.ENGLISH);
    5051            for (Policy p: Policy.values()) {
    51                 if (p.getPreferencesValue().equals(preferenceValue))
     52                if (p.getPreferencesValue().equals(prefValue))
    5253                    return p;
    5354            }
     
    5859    private transient Map<Policy, JRadioButton> rbVersionBasedUpatePolicy;
    5960    private transient Map<Policy, JRadioButton> rbTimeBasedUpatePolicy;
    60     private JosmTextField tfUpdateInterval;
    61     private JLabel lblUpdateInterval;
     61    private final JosmTextField tfUpdateInterval = new JosmTextField(5);
     62    private final JLabel lblUpdateInterval = new JLabel(tr("Update interval (in days):"));
     63
     64    /**
     65     * Constructs a new {@code PluginUpdatePolicyPanel}.
     66     */
     67    public PluginUpdatePolicyPanel() {
     68        build();
     69        initFromPreferences();
     70    }
    6271
    6372    protected JPanel buildVersionBasedUpdatePolicyPanel() {
     
    95104    protected JPanel buildUpdateIntervalPanel() {
    96105        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    97         pnl.add(lblUpdateInterval = new JLabel(tr("Update interval (in days):")));
    98         pnl.add(tfUpdateInterval = new JosmTextField(5));
     106        pnl.add(lblUpdateInterval);
     107        pnl.add(tfUpdateInterval);
    99108        lblUpdateInterval.setLabelFor(tfUpdateInterval);
    100109        SelectAllOnFocusGainedDecorator.decorate(tfUpdateInterval);
     
    160169
    161170    /**
    162      * Constructs a new {@code PluginUpdatePolicyPanel}.
    163      */
    164     public PluginUpdatePolicyPanel() {
    165         build();
    166         initFromPreferences();
    167     }
    168 
    169     /**
    170171     * Loads the relevant preference values from the JOSM preferences
    171      *
    172172     */
    173173    public final void initFromPreferences() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeProjectionChoice.java

    r9609 r10179  
    4747    private static class CodeSelectionPanel extends JPanel implements ListSelectionListener, DocumentListener {
    4848
    49         public JosmTextField filter;
    50         private ProjectionCodeListModel model;
     49        public final JosmTextField filter = new JosmTextField(30);
     50        private final ProjectionCodeListModel model = new ProjectionCodeListModel();
    5151        public JList<String> selectionList;
    5252        private final List<String> data;
     
    8989
    9090        private void build() {
    91             filter = new JosmTextField(30);
    9291            filter.setColumns(10);
    9392            filter.getDocument().addDocumentListener(this);
    9493
    9594            selectionList = new JList<>(data.toArray(new String[0]));
    96             selectionList.setModel(model = new ProjectionCodeListModel());
     95            selectionList.setModel(model);
    9796            JScrollPane scroll = new JScrollPane(selectionList);
    9897            scroll.setPreferredSize(new Dimension(200, 214));
     
    105104        public String getCode() {
    106105            int idx = selectionList.getSelectedIndex();
    107             if (idx == -1) return lastCode;
     106            if (idx == -1)
     107                return lastCode;
    108108            return filteredData.get(selectionList.getSelectedIndex());
    109109        }
     
    174174                if (matcher2.matches()) {
    175175                    int cmp1 = matcher1.group(1).compareTo(matcher2.group(1));
    176                     if (cmp1 != 0) return cmp1;
     176                    if (cmp1 != 0)
     177                        return cmp1;
    177178                    int num1 = Integer.parseInt(matcher1.group(2));
    178179                    int num2 = Integer.parseInt(matcher2.group(2));
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r9783 r10179  
    6969    private static Map<String, ProjectionChoice> projectionChoicesById = new HashMap<>();
    7070
    71     // some ProjectionChoices that are referenced from other parts of the code
    72     public static final ProjectionChoice wgs84, mercator, lambert, utm_france_dom, lambert_cc9;
     71    /**
     72     * WGS84: Directly use latitude / longitude values as x/y.
     73     */
     74    public static final ProjectionChoice wgs84 = registerProjectionChoice(tr("WGS84 Geographic"), "core:wgs84", 4326, "epsg4326");
     75
     76    /**
     77     * Mercator Projection.
     78     *
     79     * The center of the mercator projection is always the 0 grad coordinate.
     80     *
     81     * See also USGS Bulletin 1532 (http://pubs.usgs.gov/bul/1532/report.pdf)
     82     * initially EPSG used 3785 but that has been superseded by 3857, see https://www.epsg-registry.org/
     83     */
     84    public static final ProjectionChoice mercator = registerProjectionChoice(tr("Mercator"), "core:mercator", 3857);
     85
     86    /**
     87     * Lambert conic conform 4 zones using the French geodetic system NTF.
     88     *
     89     * This newer version uses the grid translation NTF<->RGF93 provided by IGN for a submillimetric accuracy.
     90     * (RGF93 is the French geodetic system similar to WGS84 but not mathematically equal)
     91     *
     92     * Source: http://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
     93     */
     94    public static final ProjectionChoice lambert = new LambertProjectionChoice();
     95
     96    /**
     97     * French departements in the Caribbean Sea and Indian Ocean.
     98     *
     99     * Using the UTM transvers Mercator projection and specific geodesic settings.
     100     */
     101    public static final ProjectionChoice utm_france_dom = new UTMFranceDOMProjectionChoice();
     102
     103    /**
     104     * Lambert Conic Conform 9 Zones projection.
     105     *
     106     * As specified by the IGN in this document
     107     * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
     108     */
     109    public static final ProjectionChoice lambert_cc9 = new LambertCC9ZonesProjectionChoice();
    73110
    74111    static {
     
    77114         * Global projections.
    78115         */
    79 
    80         /**
    81          * WGS84: Directly use latitude / longitude values as x/y.
    82          */
    83         wgs84 = registerProjectionChoice(tr("WGS84 Geographic"), "core:wgs84", 4326, "epsg4326");
    84 
    85         /**
    86          * Mercator Projection.
    87          *
    88          * The center of the mercator projection is always the 0 grad
    89          * coordinate.
    90          *
    91          * See also USGS Bulletin 1532
    92          * (http://pubs.usgs.gov/bul/1532/report.pdf)
    93          * initially EPSG used 3785 but that has been superseded by 3857,
    94          * see https://www.epsg-registry.org/
    95          */
    96         mercator = registerProjectionChoice(tr("Mercator"), "core:mercator", 3857);
    97116
    98117        /**
     
    156175         * @author Pieren
    157176         */
    158         registerProjectionChoice(lambert = new LambertProjectionChoice());                          // FR
     177        registerProjectionChoice(lambert);                                                          // FR
    159178
    160179        /**
     
    174193         * @author Pieren
    175194         */
    176         registerProjectionChoice(lambert_cc9 = new LambertCC9ZonesProjectionChoice());              // FR
     195        registerProjectionChoice(lambert_cc9);                                                      // FR
    177196
    178197        /**
     
    181200         * Using the UTM transvers Mercator projection and specific geodesic settings.
    182201         */
    183         registerProjectionChoice(utm_france_dom = new UTMFranceDOMProjectionChoice());              // FR
     202        registerProjectionChoice(utm_france_dom);                                                   // FR
    184203
    185204        /**
     
    281300    private final JPanel projSubPrefPanelWrapper = new JPanel(new GridBagLayout());
    282301
    283     private JLabel projectionCodeLabel;
    284     private Component projectionCodeGlue;
     302    private JLabel projectionCodeLabel = new JLabel(tr("Projection code"));
     303    private Component projectionCodeGlue = GBC.glue(5, 0);
    285304    private final JLabel projectionCode = new JLabel();
    286     private JLabel projectionNameLabel;
    287     private Component projectionNameGlue;
     305    private final JLabel projectionNameLabel = new JLabel(tr("Projection name"));
     306    private final Component projectionNameGlue = GBC.glue(5, 0);
    288307    private final JLabel projectionName = new JLabel();
    289308    private final JLabel bounds = new JLabel();
     
    323342        projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
    324343        projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
    325         projPanel.add(projectionCodeLabel = new JLabel(tr("Projection code")), GBC.std().insets(25, 5, 0, 5));
    326         projPanel.add(projectionCodeGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
     344        projPanel.add(projectionCodeLabel, GBC.std().insets(25, 5, 0, 5));
     345        projPanel.add(projectionCodeGlue, GBC.std().fill(GBC.HORIZONTAL));
    327346        projPanel.add(projectionCode, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
    328         projPanel.add(projectionNameLabel = new JLabel(tr("Projection name")), GBC.std().insets(25, 5, 0, 5));
    329         projPanel.add(projectionNameGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
     347        projPanel.add(projectionNameLabel, GBC.std().insets(25, 5, 0, 5));
     348        projPanel.add(projectionNameGlue, GBC.std().fill(GBC.HORIZONTAL));
    330349        projPanel.add(projectionName, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
    331350        projPanel.add(new JLabel(tr("Bounds")), GBC.std().insets(25, 5, 0, 5));
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java

    r9543 r10179  
    2525
    2626/**
    27  * This is the preference panel for the authentication method and the authentication
    28  * parameters.
    29  *
     27 * This is the preference panel for the authentication method and the authentication parameters.
     28 * @since 2745
    3029 */
    3130public class AuthenticationPreferencesPanel extends VerticallyScrollablePanel implements PropertyChangeListener {
    3231
    3332    /** indicates whether we use basic authentication */
    34     private JRadioButton rbBasicAuthentication;
     33    private final JRadioButton rbBasicAuthentication = new JRadioButton();
    3534    /** indicates whether we use OAuth as authentication scheme */
    36     private JRadioButton rbOAuth;
    37     /** the panel which contains the authentication parameters for the respective
    38      * authentication scheme
    39      */
    40     private JPanel pnlAuthenticationParameteters;
     35    private final JRadioButton rbOAuth = new JRadioButton();
     36    /** the panel which contains the authentication parameters for the respective authentication scheme */
     37    private final JPanel pnlAuthenticationParameteters = new JPanel(new BorderLayout());
    4138    /** the panel for the basic authentication parameters */
    4239    private BasicAuthenticationPreferencesPanel pnlBasicAuthPreferences;
     
    4542    /** the panel for messages notifier preferences */
    4643    private FeaturesPanel pnlFeaturesPreferences;
     44
     45    /**
     46     * Constructs a new {@code AuthenticationPreferencesPanel}.
     47     */
     48    public AuthenticationPreferencesPanel() {
     49        build();
     50        initFromPreferences();
     51        HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#AuthenticationSettings"));
     52    }
    4753
    4854    /**
     
    6167        gc.weightx = 1.0;
    6268        gc.insets = new Insets(0, 0, 0, 3);
    63         add(rbBasicAuthentication = new JRadioButton(), gc);
     69        add(rbBasicAuthentication, gc);
    6470        rbBasicAuthentication.setText(tr("Use Basic Authentication"));
    6571        rbBasicAuthentication.setToolTipText(tr("Select to use HTTP basic authentication with your OSM username and password"));
     
    6975        gc.gridx = 0;
    7076        gc.weightx = 0.0;
    71         add(rbOAuth = new JRadioButton(), gc);
     77        add(rbOAuth, gc);
    7278        rbOAuth.setText(tr("Use OAuth"));
    7379        rbOAuth.setToolTipText(tr("Select to use OAuth as authentication mechanism"));
     
    8692        gc.weightx = 1.0;
    8793        gc.weighty = 1.0;
    88         pnlAuthenticationParameteters = new JPanel(new BorderLayout());
    8994        add(pnlAuthenticationParameteters, gc);
    9095
     
    104109        pnlFeaturesPreferences = new FeaturesPanel();
    105110        add(pnlFeaturesPreferences, gc);
    106     }
    107 
    108     /**
    109      * Constructs a new {@code AuthenticationPreferencesPanel}.
    110      */
    111     public AuthenticationPreferencesPanel() {
    112         build();
    113         initFromPreferences();
    114         HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#AuthenticationSettings"));
    115111    }
    116112
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/BasicAuthenticationPreferencesPanel.java

    r8510 r10179  
    2525
    2626/**
    27  * The preferences panel for parameters necessary for the Basic Authentication
    28  * Scheme.
    29  *
     27 * The preferences panel for parameters necessary for the Basic Authentication Scheme.
     28 * @since 2745
    3029 */
    3130public class BasicAuthenticationPreferencesPanel extends JPanel {
    3231
    3332    /** the OSM user name */
    34     private JosmTextField tfOsmUserName;
     33    private final JosmTextField tfOsmUserName = new JosmTextField();
    3534    /** the OSM password */
    36     private JosmPasswordField tfOsmPassword;
     35    private final JosmPasswordField tfOsmPassword = new JosmPasswordField();
    3736    /** a panel with further information, e.g. some warnings */
    3837    private JPanel decorationPanel;
     38
     39    /**
     40     * Constructs a new {@code BasicAuthenticationPreferencesPanel}.
     41     */
     42    public BasicAuthenticationPreferencesPanel() {
     43        build();
     44    }
    3945
    4046    /**
     
    5561        gc.gridx = 1;
    5662        gc.weightx = 1.0;
    57         add(tfOsmUserName = new JosmTextField(), gc);
     63        add(tfOsmUserName, gc);
    5864        SelectAllOnFocusGainedDecorator.decorate(tfOsmUserName);
    5965        UserNameValidator valUserName = new UserNameValidator(tfOsmUserName);
     
    6874        gc.gridx = 1;
    6975        gc.weightx = 1.0;
    70         add(tfOsmPassword = new JosmPasswordField(), gc);
     76        add(tfOsmPassword, gc);
    7177        SelectAllOnFocusGainedDecorator.decorate(tfOsmPassword);
    7278        tfOsmPassword.setToolTipText(tr("Please enter your OSM password"));
     
    8288        decorationPanel = new JPanel(new BorderLayout());
    8389        add(decorationPanel, gc);
    84     }
    85 
    86     /**
    87      * Constructs a new {@code BasicAuthenticationPreferencesPanel}.
    88      */
    89     public BasicAuthenticationPreferencesPanel() {
    90         build();
    9190    }
    9291
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java

    r10137 r10179  
    4646 */
    4747public class OAuthAuthenticationPreferencesPanel extends JPanel implements PropertyChangeListener {
    48     private JPanel pnlAuthorisationMessage;
    49     private NotYetAuthorisedPanel pnlNotYetAuthorised;
    50     private AlreadyAuthorisedPanel pnlAlreadyAuthorised;
    51     private AdvancedOAuthPropertiesPanel pnlAdvancedProperties;
     48    private final JPanel pnlAuthorisationMessage = new JPanel(new BorderLayout());
     49    private final NotYetAuthorisedPanel pnlNotYetAuthorised = new NotYetAuthorisedPanel();
     50    private final AlreadyAuthorisedPanel pnlAlreadyAuthorised = new AlreadyAuthorisedPanel();
     51    private final AdvancedOAuthPropertiesPanel pnlAdvancedProperties = new AdvancedOAuthPropertiesPanel();
    5252    private String apiUrl;
    53     private JCheckBox cbShowAdvancedParameters;
    54     private JCheckBox cbSaveToPreferences;
     53    private final JCheckBox cbShowAdvancedParameters = new JCheckBox();
     54    private final JCheckBox cbSaveToPreferences = new JCheckBox(tr("Save to preferences"));
    5555
    5656    /**
     
    7575        gc.weightx = 0.0;
    7676        gc.insets = new Insets(0, 0, 0, 3);
    77         pnl.add(cbShowAdvancedParameters = new JCheckBox(), gc);
     77        pnl.add(cbShowAdvancedParameters, gc);
    7878        cbShowAdvancedParameters.setSelected(false);
    7979        cbShowAdvancedParameters.addItemListener(
     
    9898        gc.weightx = 1.0;
    9999        gc.weighty = 1.0;
    100         pnl.add(pnlAdvancedProperties = new AdvancedOAuthPropertiesPanel(), gc);
     100        pnl.add(pnlAdvancedProperties, gc);
    101101        pnlAdvancedProperties.initFromPreferences(Main.pref);
    102102        pnlAdvancedProperties.setBorder(
     
    126126        gc.weightx = 1.0;
    127127        gc.insets = new Insets(10, 0, 0, 0);
    128         add(pnlAuthorisationMessage = new JPanel(new BorderLayout()), gc);
    129 
    130         // create these two panels, they are going to be used later in refreshView
    131         //
    132         pnlAlreadyAuthorised = new AlreadyAuthorisedPanel();
    133         pnlNotYetAuthorised = new NotYetAuthorisedPanel();
     128        add(pnlAuthorisationMessage, gc);
    134129    }
    135130
     
    196191            gc.fill = GridBagConstraints.HORIZONTAL;
    197192            gc.weightx = 1.0;
    198             JMultilineLabel lbl;
    199             add(lbl = new JMultilineLabel(
    200                     tr("You do not have an Access Token yet to access the OSM server using OAuth. Please authorize first.")), gc);
     193            JMultilineLabel lbl = new JMultilineLabel(
     194                    tr("You do not have an Access Token yet to access the OSM server using OAuth. Please authorize first."));
     195            add(lbl, gc);
    201196            lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    202197
     
    221216     */
    222217    private class AlreadyAuthorisedPanel extends JPanel {
    223         private JosmTextField tfAccessTokenKey;
    224         private JosmTextField tfAccessTokenSecret;
     218        private final JosmTextField tfAccessTokenKey = new JosmTextField();
     219        private final JosmTextField tfAccessTokenSecret = new JosmTextField();
    225220
    226221        /**
     
    240235            gc.weightx = 1.0;
    241236            gc.gridwidth = 2;
    242             JMultilineLabel lbl;
    243             add(lbl = new JMultilineLabel(tr("You already have an Access Token to access the OSM server using OAuth.")), gc);
     237            JMultilineLabel lbl = new JMultilineLabel(tr("You already have an Access Token to access the OSM server using OAuth."));
     238            add(lbl, gc);
    244239            lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    245240
     
    253248            gc.gridx = 1;
    254249            gc.weightx = 1.0;
    255             add(tfAccessTokenKey = new JosmTextField(), gc);
     250            add(tfAccessTokenKey, gc);
    256251            tfAccessTokenKey.setEditable(false);
    257252
     
    265260            gc.gridx = 1;
    266261            gc.weightx = 1.0;
    267             add(tfAccessTokenSecret = new JosmTextField(), gc);
     262            add(tfAccessTokenSecret, gc);
    268263            tfAccessTokenSecret.setEditable(false);
    269264
     
    273268            gc.gridwidth = 2;
    274269            gc.weightx = 1.0;
    275             add(cbSaveToPreferences = new JCheckBox(tr("Save to preferences")), gc);
     270            add(cbSaveToPreferences, gc);
    276271            cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
    277272
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r10137 r10179  
    4949    public static final String API_URL_PROP = OsmApiUrlInputPanel.class.getName() + ".apiUrl";
    5050
    51     private JLabel lblValid;
    52     private JLabel lblApiUrl;
    53     private HistoryComboBox tfOsmServerUrl;
     51    private final JLabel lblValid = new JLabel();
     52    private final JLabel lblApiUrl = new JLabel(tr("OSM Server URL:"));
     53    private final HistoryComboBox tfOsmServerUrl = new HistoryComboBox();
    5454    private transient ApiUrlValidator valOsmServerUrl;
    5555    private SideButton btnTest;
     
    9595        gc.weightx = 0.0;
    9696        gc.insets = new Insets(0, 0, 0, 3);
    97         add(lblApiUrl = new JLabel(tr("OSM Server URL:")), gc);
     97        add(lblApiUrl, gc);
    9898
    9999        gc.gridx = 1;
    100100        gc.weightx = 1.0;
    101         add(tfOsmServerUrl = new HistoryComboBox(), gc);
     101        add(tfOsmServerUrl, gc);
    102102        lblApiUrl.setLabelFor(tfOsmServerUrl);
    103103        SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl.getEditorComponent());
     
    110110        gc.gridx = 2;
    111111        gc.weightx = 0.0;
    112         add(lblValid = new JLabel(), gc);
     112        add(lblValid, gc);
    113113
    114114        gc.gridx = 3;
     
    116116        ValidateApiUrlAction actTest = new ValidateApiUrlAction();
    117117        tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest);
    118         add(btnTest = new SideButton(actTest), gc);
     118        btnTest = new SideButton(actTest);
     119        add(btnTest, gc);
    119120    }
    120121
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java

    r8510 r10179  
    102102
    103103    private transient Map<ProxyPolicy, JRadioButton> rbProxyPolicy;
    104     private JosmTextField tfProxyHttpHost;
    105     private JosmTextField tfProxyHttpPort;
    106     private JosmTextField tfProxySocksHost;
    107     private JosmTextField tfProxySocksPort;
    108     private JosmTextField tfProxyHttpUser;
    109     private JosmPasswordField tfProxyHttpPassword;
     104    private final JosmTextField tfProxyHttpHost = new JosmTextField();
     105    private final JosmTextField tfProxyHttpPort = new JosmTextField(5);
     106    private final JosmTextField tfProxySocksHost = new JosmTextField(20);
     107    private final JosmTextField tfProxySocksPort = new JosmTextField(5);
     108    private final JosmTextField tfProxyHttpUser = new JosmTextField(20);
     109    private final JosmPasswordField tfProxyHttpPassword = new JosmPasswordField(20);
    110110
    111111    private JPanel pnlHttpProxyConfigurationPanel;
     
    134134        gc.gridx = 1;
    135135        gc.weightx = 1.0;
    136         pnl.add(tfProxyHttpHost = new JosmTextField(), gc);
     136        pnl.add(tfProxyHttpHost, gc);
    137137
    138138        gc.gridy = 1;
     
    144144        gc.gridx = 1;
    145145        gc.weightx = 1.0;
    146         pnl.add(tfProxyHttpPort = new JosmTextField(5), gc);
     146        pnl.add(tfProxyHttpPort, gc);
    147147        tfProxyHttpPort.setMinimumSize(tfProxyHttpPort.getPreferredSize());
    148148
     
    164164        gc.gridx = 1;
    165165        gc.weightx = 1.0;
    166         pnl.add(tfProxyHttpUser = new JosmTextField(20), gc);
     166        pnl.add(tfProxyHttpUser, gc);
    167167        tfProxyHttpUser.setMinimumSize(tfProxyHttpUser.getPreferredSize());
    168168
     
    174174        gc.gridx = 1;
    175175        gc.weightx = 1.0;
    176         pnl.add(tfProxyHttpPassword = new JosmPasswordField(20), gc);
     176        pnl.add(tfProxyHttpPassword, gc);
    177177        tfProxyHttpPassword.setMinimumSize(tfProxyHttpPassword.getPreferredSize());
    178178
     
    209209        gc.gridx = 1;
    210210        gc.weightx = 1.0;
    211         pnl.add(tfProxySocksHost = new JosmTextField(20), gc);
     211        pnl.add(tfProxySocksHost, gc);
    212212
    213213        gc.gridy = 1;
     
    219219        gc.gridx = 1;
    220220        gc.weightx = 1.0;
    221         pnl.add(tfProxySocksPort = new JosmTextField(5), gc);
     221        pnl.add(tfProxySocksPort, gc);
    222222        tfProxySocksPort.setMinimumSize(tfProxySocksPort.getPreferredSize());
    223223
     
    290290        gc.weightx = 1.0;
    291291        gc.weighty = 0.0;
    292         pnl.add(pnlHttpProxyConfigurationPanel = buildHttpProxyConfigurationPanel(), gc);
     292        pnlHttpProxyConfigurationPanel = buildHttpProxyConfigurationPanel();
     293        pnl.add(pnlHttpProxyConfigurationPanel, gc);
    293294
    294295        // radio button SOCKS proxy
     
    309310        gc.weightx = 1.0;
    310311        gc.weighty = 0.0;
    311         pnl.add(pnlSocksProxyConfigurationPanel = buildSocksProxyConfigurationPanel(), gc);
     312        pnlSocksProxyConfigurationPanel = buildSocksProxyConfigurationPanel();
     313        pnl.add(pnlSocksProxyConfigurationPanel, gc);
    312314
    313315        return pnl;
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java

    r9588 r10179  
    7575        pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));
    7676
    77         // add action
    78         //
    79         JButton btn;
    80         pnl.add(btn = new JButton(tagTable.getAddAction()));
     77        buildButton(pnl, tagTable.getAddAction());
     78        buildButton(pnl, tagTable.getDeleteAction());
     79        buildButton(pnl, tagTable.getPasteAction());
     80
     81        return pnl;
     82    }
     83
     84    private void buildButton(JPanel pnl, AbstractAction action) {
     85        JButton btn = new JButton(action);
     86        pnl.add(btn);
    8187        btn.setMargin(new Insets(0, 0, 0, 0));
    8288        tagTable.addComponentNotStoppingCellEditing(btn);
    83 
    84         // delete action
    85         pnl.add(btn = new JButton(tagTable.getDeleteAction()));
    86         btn.setMargin(new Insets(0, 0, 0, 0));
    87         tagTable.addComponentNotStoppingCellEditing(btn);
    88 
    89         // paste action
    90         pnl.add(btn = new JButton(tagTable.getPasteAction()));
    91         btn.setMargin(new Insets(0, 0, 0, 0));
    92         tagTable.addComponentNotStoppingCellEditing(btn);
    93         return pnl;
    9489    }
    9590
  • trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java

    r9484 r10179  
    2222    public HistoryComboBox() {
    2323        int maxsize = Main.pref.getInteger("search.history-size", DEFAULT_SEARCH_HISTORY_SIZE);
    24         setModel(model = new ComboBoxHistory(maxsize));
     24        model = new ComboBoxHistory(maxsize);
     25        setModel(model);
    2526        setEditable(true);
    2627    }
  • trunk/src/org/openstreetmap/josm/gui/widgets/ImageLabel.java

    r9372 r10179  
    1818 */
    1919public class ImageLabel extends JPanel {
    20     private final JLabel imgLabel;
    21     private final JLabel tf;
     20    private final JLabel imgLabel = new JLabel();
     21    private final JLabel tf = new JLabel();
    2222    private final int charCount;
    2323
     
    3232        setLayout(new GridBagLayout());
    3333        setBackground(background);
    34         add(imgLabel = new JLabel(), GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0));
     34        add(imgLabel, GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0));
    3535        setIcon(img);
    36         add(tf = new JLabel(), GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2, 1, 1, 0));
     36        add(tf, GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2, 1, 1, 0));
    3737        setToolTipText(tooltip);
    3838        this.charCount = charCount;
  • trunk/src/org/openstreetmap/josm/io/OsmChangeBuilder.java

    r8840 r10179  
    1313/**
    1414 * Creates an OsmChange document from JOSM edits.
    15  * See http://wiki.openstreetmap.org/index.php/OsmChange for a documentation of the
    16  * OsmChange format.
    17  *
     15 * See http://wiki.openstreetmap.org/index.php/OsmChange for a documentation of the OsmChange format.
     16 * @since 1071
    1817 */
    1918public class OsmChangeBuilder {
     19    /** Default OSM API version */
    2020    public static final String DEFAULT_API_VERSION = "0.6";
    2121
    2222    private String currentMode;
    23     private PrintWriter writer;
    24     private StringWriter swriter;
    25     private OsmWriter osmwriter;
     23    private final PrintWriter writer;
     24    private final StringWriter swriter;
     25    private final OsmWriter osmwriter;
    2626    private String apiVersion = DEFAULT_API_VERSION;
    2727    private boolean prologWritten;
    2828
     29    /**
     30     * Constructs a new {@code OsmChangeBuilder}.
     31     * @param changeset changeset
     32     */
    2933    public OsmChangeBuilder(Changeset changeset) {
    3034        this(changeset, null /* default api version */);
    3135    }
    3236
     37    /**
     38     * Constructs a new {@code OsmChangeBuilder}.
     39     * @param changeset changeset
     40     * @param apiVersion OSM API version
     41     */
    3342    public OsmChangeBuilder(Changeset changeset, String apiVersion) {
    3443        this.apiVersion = apiVersion == null ? DEFAULT_API_VERSION : apiVersion;
    35         writer = new PrintWriter(swriter = new StringWriter());
     44        swriter = new StringWriter();
     45        writer = new PrintWriter(swriter);
    3646        osmwriter = OsmWriterFactory.createOsmWriter(writer, false, apiVersion);
    3747        osmwriter.setChangeset(changeset);
     
    90100     */
    91101    public void append(Collection<? extends IPrimitive> primitives) {
    92         if (primitives == null) return;
    93         if (!prologWritten)
    94             throw new IllegalStateException(tr("Prolog of OsmChange document not written yet. Please write first."));
     102        if (primitives == null)
     103            return;
     104        checkProlog();
    95105        for (IPrimitive p : primitives) {
    96106            write(p);
    97107        }
     108    }
     109
     110    private void checkProlog() {
     111        if (!prologWritten)
     112            throw new IllegalStateException(tr("Prolog of OsmChange document not written yet. Please write first."));
    98113    }
    99114
     
    107122     */
    108123    public void append(IPrimitive p) {
    109         if (p == null) return;
    110         if (!prologWritten)
    111             throw new IllegalStateException(tr("Prolog of OsmChange document not written yet. Please write first."));
     124        if (p == null)
     125            return;
     126        checkProlog();
    112127        write(p);
    113128    }
     
    119134     */
    120135    public void finish() {
    121         if (!prologWritten)
    122             throw new IllegalStateException(tr("Prolog of OsmChange document not written yet. Please write first."));
     136        checkProlog();
    123137        if (currentMode != null) {
    124138            writer.print("</");
     
    129143    }
    130144
     145    /**
     146     * Returns XML document.
     147     * @return XML document
     148     */
    131149    public String getDocument() {
    132150        return swriter.toString();
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10143 r10179  
    14931493
    14941494    private static class UpdatePluginsMessagePanel extends JPanel {
    1495         private JMultilineLabel lblMessage;
    1496         private JCheckBox cbDontShowAgain;
     1495        private final JMultilineLabel lblMessage = new JMultilineLabel("");
     1496        private final JCheckBox cbDontShowAgain = new JCheckBox(
     1497                tr("Do not ask again and remember my decision (go to Preferences->Plugins to change it later)"));
     1498
     1499        UpdatePluginsMessagePanel() {
     1500            build();
     1501        }
    14971502
    14981503        protected final void build() {
     
    15041509            gc.weighty = 1.0;
    15051510            gc.insets = new Insets(5, 5, 5, 5);
    1506             add(lblMessage = new JMultilineLabel(""), gc);
     1511            add(lblMessage, gc);
    15071512            lblMessage.setFont(lblMessage.getFont().deriveFont(Font.PLAIN));
    15081513
     
    15101515            gc.fill = GridBagConstraints.HORIZONTAL;
    15111516            gc.weighty = 0.0;
    1512             add(cbDontShowAgain = new JCheckBox(
    1513                     tr("Do not ask again and remember my decision (go to Preferences->Plugins to change it later)")), gc);
     1517            add(cbDontShowAgain, gc);
    15141518            cbDontShowAgain.setFont(cbDontShowAgain.getFont().deriveFont(Font.PLAIN));
    1515         }
    1516 
    1517         UpdatePluginsMessagePanel() {
    1518             build();
    15191519        }
    15201520
  • trunk/src/org/openstreetmap/josm/tools/Diff.java

    r10001 r10179  
    597597        public String toString() {
    598598            String s = String.format("%d -%d +%d %d", line0, deleted, inserted, line1);
    599             return (link != null) ? s = s + '\n' + link : s;
     599            return (link != null) ? s + '\n' + link : s;
    600600        }
    601601    }
     
    832832                Integer ir = h.get(data[i]);
    833833                if (ir == null) {
    834                     h.put(data[i], equivs[i] = equivMax++);
     834                    equivs[i] = equivMax++;
     835                    h.put(data[i], equivs[i]);
    835836                } else {
    836837                    equivs[i] = ir.intValue();
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r10140 r10179  
    5858
    5959import org.openstreetmap.josm.Main;
     60import org.openstreetmap.josm.data.osm.DataSet;
    6061import org.openstreetmap.josm.data.osm.OsmPrimitive;
    6162import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    8384import com.kitfox.svg.SVGDiagram;
    8485import com.kitfox.svg.SVGUniverse;
    85 import org.openstreetmap.josm.data.osm.DataSet;
    8686
    8787/**
     
    12291229            Map<Long, ImageResource> cacheByAngle = ROTATE_CACHE.get(img);
    12301230            if (cacheByAngle == null) {
    1231                 ROTATE_CACHE.put(img, cacheByAngle = new HashMap<>());
     1231                cacheByAngle = new HashMap<>();
     1232                ROTATE_CACHE.put(img, cacheByAngle);
    12321233            }
    12331234
     
    12571258                }
    12581259                Image image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    1259                 cacheByAngle.put(originalAngle, imageResource = new ImageResource(image));
     1260                imageResource = new ImageResource(image);
     1261                cacheByAngle.put(originalAngle, imageResource);
    12601262                Graphics g = image.getGraphics();
    12611263                Graphics2D g2d = (Graphics2D) g.create();
Note: See TracChangeset for help on using the changeset viewer.