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

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

Location:
trunk/src/org/openstreetmap/josm/gui/preferences
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.