Changeset 10183 in josm for trunk


Ignore:
Timestamp:
2016-05-11T05:02:01+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/oauth
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/oauth/AccessTokenInfoPanel.java

    r8510 r10183  
    1818/**
    1919 * Displays the key and the secret of an OAuth Access Token.
    20  *
     20 * @since 2746
    2121 */
    2222public class AccessTokenInfoPanel extends JPanel {
    2323
    24     private JosmTextField tfAccessTokenKey;
    25     private JosmTextField tfAccessTokenSecret;
    26     private JCheckBox cbSaveAccessTokenInPreferences;
     24    private final JosmTextField tfAccessTokenKey = new JosmTextField();
     25    private final JosmTextField tfAccessTokenSecret = new JosmTextField();
     26    private final JCheckBox cbSaveAccessTokenInPreferences = new JCheckBox(tr("Save Access Token in preferences"));
     27
     28    /**
     29     * Constructs a new {@code AccessTokenInfoPanel}.
     30     */
     31    public AccessTokenInfoPanel() {
     32        build();
     33    }
    2734
    2835    protected final void build() {
     
    3946        gc.gridx = 1;
    4047        gc.weightx = 1.0;
    41         add(tfAccessTokenKey = new JosmTextField(), gc);
     48        add(tfAccessTokenKey, gc);
    4249        tfAccessTokenKey.setEditable(false);
    4350
     
    5158        gc.gridx = 1;
    5259        gc.weightx = 1.0;
    53         add(tfAccessTokenSecret = new JosmTextField(), gc);
     60        add(tfAccessTokenSecret, gc);
    5461        tfAccessTokenSecret.setEditable(false);
    5562
     
    5865        gc.gridy = 2;
    5966        gc.gridwidth = 2;
    60         add(cbSaveAccessTokenInPreferences = new JCheckBox(tr("Save Access Token in preferences")), gc);
     67        add(cbSaveAccessTokenInPreferences, gc);
    6168        cbSaveAccessTokenInPreferences.setToolTipText(tr(
    6269                "<html>Select to save the Access Token in the JOSM preferences.<br>"
     
    7380        gc.gridwidth = 2;
    7481        add(new JPanel(), gc);
    75     }
    76 
    77     public AccessTokenInfoPanel() {
    78         build();
    7982    }
    8083
  • trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java

    r9917 r10183  
    4444public class AdvancedOAuthPropertiesPanel extends VerticallyScrollablePanel {
    4545
    46     private JCheckBox cbUseDefaults;
    47     private JosmTextField tfConsumerKey;
    48     private JosmTextField tfConsumerSecret;
    49     private JosmTextField tfRequestTokenURL;
    50     private JosmTextField tfAccessTokenURL;
    51     private JosmTextField tfAuthoriseURL;
    52     private JosmTextField tfOsmLoginURL;
    53     private JosmTextField tfOsmLogoutURL;
     46    private final JCheckBox cbUseDefaults = new JCheckBox(tr("Use default settings"));
     47    private final JosmTextField tfConsumerKey = new JosmTextField();
     48    private final JosmTextField tfConsumerSecret = new JosmTextField();
     49    private final JosmTextField tfRequestTokenURL = new JosmTextField();
     50    private final JosmTextField tfAccessTokenURL = new JosmTextField();
     51    private final JosmTextField tfAuthoriseURL = new JosmTextField();
     52    private final JosmTextField tfOsmLoginURL = new JosmTextField();
     53    private final JosmTextField tfOsmLogoutURL = new JosmTextField();
    5454    private transient UseDefaultItemListener ilUseDefault;
    5555    private String apiUrl;
     
    6565        gc.insets = new Insets(0, 0, 3, 3);
    6666        gc.gridwidth = 2;
    67         cbUseDefaults = new JCheckBox(tr("Use default settings"));
    6867        add(cbUseDefaults, gc);
    6968
     
    7675        gc.gridx = 1;
    7776        gc.weightx = 1.0;
    78         add(tfConsumerKey = new JosmTextField(), gc);
     77        add(tfConsumerKey, gc);
    7978        SelectAllOnFocusGainedDecorator.decorate(tfConsumerKey);
    8079
     
    8786        gc.gridx = 1;
    8887        gc.weightx = 1.0;
    89         add(tfConsumerSecret = new JosmTextField(), gc);
     88        add(tfConsumerSecret, gc);
    9089        SelectAllOnFocusGainedDecorator.decorate(tfConsumerSecret);
    9190
     
    9897        gc.gridx = 1;
    9998        gc.weightx = 1.0;
    100         add(tfRequestTokenURL = new JosmTextField(), gc);
     99        add(tfRequestTokenURL, gc);
    101100        SelectAllOnFocusGainedDecorator.decorate(tfRequestTokenURL);
    102101
     
    109108        gc.gridx = 1;
    110109        gc.weightx = 1.0;
    111         add(tfAccessTokenURL = new JosmTextField(), gc);
     110        add(tfAccessTokenURL, gc);
    112111        SelectAllOnFocusGainedDecorator.decorate(tfAccessTokenURL);
    113112
     
    121120        gc.gridx = 1;
    122121        gc.weightx = 1.0;
    123         add(tfAuthoriseURL = new JosmTextField(), gc);
     122        add(tfAuthoriseURL, gc);
    124123        SelectAllOnFocusGainedDecorator.decorate(tfAuthoriseURL);
    125124
     
    133132        gc.gridx = 1;
    134133        gc.weightx = 1.0;
    135         add(tfOsmLoginURL = new JosmTextField(), gc);
     134        add(tfOsmLoginURL, gc);
    136135        SelectAllOnFocusGainedDecorator.decorate(tfOsmLoginURL);
    137136
     
    145144        gc.gridx = 1;
    146145        gc.weightx = 1.0;
    147         add(tfOsmLogoutURL = new JosmTextField(), gc);
     146        add(tfOsmLogoutURL, gc);
    148147        SelectAllOnFocusGainedDecorator.decorate(tfOsmLogoutURL);
    149148
  • trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java

    r10173 r10183  
    6060public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
    6161
    62     private JosmTextField tfUserName;
    63     private JosmPasswordField tfPassword;
     62    private final JosmTextField tfUserName = new JosmTextField();
     63    private final JosmPasswordField tfPassword = new JosmPasswordField();
    6464    private transient UserNameValidator valUserName;
    6565    private transient PasswordValidator valPassword;
    66     private AccessTokenInfoPanel pnlAccessTokenInfo;
     66    private final AccessTokenInfoPanel pnlAccessTokenInfo = new AccessTokenInfoPanel();
    6767    private OsmPrivilegesPanel pnlOsmPrivileges;
    6868    private JPanel pnlPropertiesPanel;
     
    120120        gc.gridx = 1;
    121121        gc.weightx = 1.0;
    122         pnl.add(tfUserName = new JosmTextField(), gc);
     122        pnl.add(tfUserName, gc);
    123123        SelectAllOnFocusGainedDecorator.decorate(tfUserName);
    124124        valUserName = new UserNameValidator(tfUserName);
     
    135135        gc.gridx = 1;
    136136        gc.weightx = 1.0;
    137         pnl.add(tfPassword = new JosmPasswordField(), gc);
     137        pnl.add(tfPassword, gc);
    138138        SelectAllOnFocusGainedDecorator.decorate(tfPassword);
    139139        valPassword = new PasswordValidator(tfPassword);
     
    232232        gc.gridy = 1;
    233233        gc.insets = new Insets(5, 0, 0, 0);
    234         pnl.add(pnlAccessTokenInfo = new AccessTokenInfoPanel(), gc);
     234        pnl.add(pnlAccessTokenInfo, gc);
    235235
    236236        // the actions
  • trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java

    r10073 r10183  
    1919public class FullyAutomaticPropertiesPanel extends JPanel {
    2020
    21     private JosmTextField tfUserName;
    22     private JosmPasswordField tfPassword;
    23 
    24     protected final JPanel buildUserNamePasswordPanel() {
    25         JPanel pnl = new JPanel(new GridBagLayout());
    26         GridBagConstraints gc = new GridBagConstraints();
    27 
    28         gc.anchor = GridBagConstraints.NORTHWEST;
    29         gc.fill = GridBagConstraints.HORIZONTAL;
    30         gc.weightx = 0.0;
    31         gc.insets = new Insets(0, 0, 3, 3);
    32         pnl.add(new JLabel(tr("Username: ")), gc);
    33 
    34         gc.gridx = 1;
    35         gc.weightx = 1.0;
    36         pnl.add(tfUserName = new JosmTextField(), gc);
    37         SelectAllOnFocusGainedDecorator.decorate(tfUserName);
    38         UserNameValidator valUserName = new UserNameValidator(tfUserName);
    39         valUserName.validate();
    40 
    41         gc.anchor = GridBagConstraints.NORTHWEST;
    42         gc.fill = GridBagConstraints.HORIZONTAL;
    43         gc.gridy = 1;
    44         gc.gridx = 0;
    45         gc.weightx = 0.0;
    46         pnl.add(new JLabel(tr("Password: ")), gc);
    47 
    48         gc.gridx = 1;
    49         gc.weightx = 1.0;
    50         pnl.add(tfPassword = new JosmPasswordField(), gc);
    51         SelectAllOnFocusGainedDecorator.decorate(tfPassword);
    52 
    53         return pnl;
    54     }
     21    private final JosmTextField tfUserName = new JosmTextField();
     22    private final JosmPasswordField tfPassword = new JosmPasswordField();
    5523
    5624    /**
     
    7240        add(new JPanel(), gc);
    7341    }
     42
     43    protected final JPanel buildUserNamePasswordPanel() {
     44        JPanel pnl = new JPanel(new GridBagLayout());
     45        GridBagConstraints gc = new GridBagConstraints();
     46
     47        gc.anchor = GridBagConstraints.NORTHWEST;
     48        gc.fill = GridBagConstraints.HORIZONTAL;
     49        gc.weightx = 0.0;
     50        gc.insets = new Insets(0, 0, 3, 3);
     51        pnl.add(new JLabel(tr("Username: ")), gc);
     52
     53        gc.gridx = 1;
     54        gc.weightx = 1.0;
     55        pnl.add(tfUserName, gc);
     56        SelectAllOnFocusGainedDecorator.decorate(tfUserName);
     57        UserNameValidator valUserName = new UserNameValidator(tfUserName);
     58        valUserName.validate();
     59
     60        gc.anchor = GridBagConstraints.NORTHWEST;
     61        gc.fill = GridBagConstraints.HORIZONTAL;
     62        gc.gridy = 1;
     63        gc.gridx = 0;
     64        gc.weightx = 0.0;
     65        pnl.add(new JLabel(tr("Password: ")), gc);
     66
     67        gc.gridx = 1;
     68        gc.weightx = 1.0;
     69        pnl.add(tfPassword, gc);
     70        SelectAllOnFocusGainedDecorator.decorate(tfPassword);
     71
     72        return pnl;
     73    }
    7474}
  • trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java

    r10073 r10183  
    3434
    3535/**
    36  * This is an UI which supports a JOSM user to get an OAuth Access Token in a fully
    37  * manual process.
     36 * This is an UI which supports a JOSM user to get an OAuth Access Token in a fully manual process.
    3837 *
    3938 * @since 2746
     
    4140public class ManualAuthorizationUI extends AbstractAuthorizationUI {
    4241
    43     private JosmTextField tfAccessTokenKey;
     42    private final JosmTextField tfAccessTokenKey = new JosmTextField();
    4443    private transient AccessTokenKeyValidator valAccessTokenKey;
    45     private JosmTextField tfAccessTokenSecret;
     44    private final JosmTextField tfAccessTokenSecret = new JosmTextField();
    4645    private transient AccessTokenSecretValidator valAccessTokenSecret;
    47     private JCheckBox cbSaveToPreferences;
    48     private HtmlPanel pnlMessage;
     46    private final JCheckBox cbSaveToPreferences = new JCheckBox(tr("Save Access Token in preferences"));
     47    private final HtmlPanel pnlMessage = new HtmlPanel();
    4948    private final transient Executor executor;
     49
     50    /**
     51     * Constructs a new {@code ManualAuthorizationUI} for the given API URL.
     52     * @param apiUrl The OSM API URL
     53     * @param executor the executor used for running the HTTP requests for the authorization
     54     * @since 5422
     55     */
     56    public ManualAuthorizationUI(String apiUrl, Executor executor) {
     57        super(apiUrl);
     58        this.executor = executor;
     59        build();
     60    }
    5061
    5162    protected JPanel buildAccessTokenPanel() {
     
    6172        gc.gridwidth = 2;
    6273        gc.insets = new Insets(0, 0, 5, 0);
    63         pnlMessage = new HtmlPanel();
    6474        pnlMessage.setText("<html><body>"
    6575                + tr("Please enter an OAuth Access Token which is authorized to access the OSM server "
     
    7787        gc.gridx = 1;
    7888        gc.weightx = 1.0;
    79         pnl.add(tfAccessTokenKey = new JosmTextField(), gc);
     89        pnl.add(tfAccessTokenKey, gc);
    8090        SelectAllOnFocusGainedDecorator.decorate(tfAccessTokenKey);
    8191        valAccessTokenKey = new AccessTokenKeyValidator(tfAccessTokenKey);
     
    91101        gc.gridx = 1;
    92102        gc.weightx = 1.0;
    93         pnl.add(tfAccessTokenSecret = new JosmTextField(), gc);
     103        pnl.add(tfAccessTokenSecret, gc);
    94104        SelectAllOnFocusGainedDecorator.decorate(tfAccessTokenSecret);
    95105        valAccessTokenSecret = new AccessTokenSecretValidator(tfAccessTokenSecret);
     
    102112        gc.gridwidth = 2;
    103113        gc.weightx = 1.0;
    104         pnl.add(cbSaveToPreferences = new JCheckBox(tr("Save Access Token in preferences")), gc);
     114        pnl.add(cbSaveToPreferences, gc);
    105115        cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
    106116
     
    161171    }
    162172
    163     /**
    164      * Constructs a new {@code ManualAuthorizationUI} for the given API URL.
    165      * @param apiUrl The OSM API URL
    166      * @param executor the executor used for running the HTTP requests for the authorization
    167      * @since 5422
    168      */
    169     public ManualAuthorizationUI(String apiUrl, Executor executor) {
    170         super(apiUrl);
    171         this.executor = executor;
    172         build();
    173     }
    174 
    175173    @Override
    176174    public boolean isSaveAccessTokenToPreferences() {
  • trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java

    r10173 r10183  
    6464    private final String apiUrl;
    6565
    66     private AuthorizationProcedureComboBox cbAuthorisationProcedure;
     66    private final AuthorizationProcedureComboBox cbAuthorisationProcedure = new AuthorizationProcedureComboBox();
    6767    private FullyAutomaticAuthorizationUI pnlFullyAutomaticAuthorisationUI;
    6868    private SemiAutomaticAuthorizationUI pnlSemiAutomaticAuthorisationUI;
     
    150150        gc.gridwidth = 1;
    151151        gc.weightx = 1.0;
    152         pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc);
     152        pnl.add(cbAuthorisationProcedure, gc);
    153153        cbAuthorisationProcedure.addItemListener(new AuthorisationProcedureChangeListener());
    154154        lbl.setLabelFor(cbAuthorisationProcedure);
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmPrivilegesPanel.java

    r9059 r10183  
    1717public class OsmPrivilegesPanel extends VerticallyScrollablePanel {
    1818
    19     private JCheckBox cbWriteApi;
    20     private JCheckBox cbWriteGpx;
    21     private JCheckBox cbReadGpx;
    22     private JCheckBox cbWritePrefs;
    23     private JCheckBox cbReadPrefs;
    24     private JCheckBox cbModifyNotes;
     19    private final JCheckBox cbWriteApi = new JCheckBox();
     20    private final JCheckBox cbWriteGpx = new JCheckBox();
     21    private final JCheckBox cbReadGpx = new JCheckBox();
     22    private final JCheckBox cbWritePrefs = new JCheckBox();
     23    private final JCheckBox cbReadPrefs = new JCheckBox();
     24    private final JCheckBox cbModifyNotes = new JCheckBox();
     25
     26    /**
     27     * Constructs a new {@code OsmPrivilegesPanel}.
     28     */
     29    public OsmPrivilegesPanel() {
     30        build();
     31    }
    2532
    2633    protected final void build() {
     
    3542        gc.weightx = 1.0;
    3643        gc.insets = new Insets(0, 0, 3, 3);
    37         add(cbWriteApi = new JCheckBox(), gc);
     44        add(cbWriteApi, gc);
    3845        cbWriteApi.setText(tr("Allow to upload map data"));
    3946        cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
     
    4350        //
    4451        gc.gridy = 1;
    45         add(cbWriteGpx = new JCheckBox(), gc);
     52        add(cbWriteGpx, gc);
    4653        cbWriteGpx.setText(tr("Allow to upload GPS traces"));
    4754        cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
     
    5158        //
    5259        gc.gridy = 2;
    53         add(cbReadGpx = new JCheckBox(), gc);
     60        add(cbReadGpx, gc);
    5461        cbReadGpx.setText(tr("Allow to download your private GPS traces"));
    5562        cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
     
    5966        //
    6067        gc.gridy = 3;
    61         add(cbReadPrefs = new JCheckBox(), gc);
     68        add(cbReadPrefs, gc);
    6269        cbReadPrefs.setText(tr("Allow to read your preferences"));
    6370        cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
     
    6774        //
    6875        gc.gridy = 4;
    69         add(cbWritePrefs = new JCheckBox(), gc);
     76        add(cbWritePrefs, gc);
    7077        cbWritePrefs.setText(tr("Allow to write your preferences"));
    7178        cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
     
    7380
    7481        gc.gridy = 5;
    75         add(cbModifyNotes = new JCheckBox(), gc);
     82        add(cbModifyNotes, gc);
    7683        cbModifyNotes.setText(tr("Allow modifications of notes"));
    7784        cbModifyNotes.setToolTipText(tr("Select to grant JOSM the right to modify notes on your behalf"));
     
    8491        gc.weighty = 1.0;
    8592        add(new JPanel(), gc);
    86     }
    87 
    88     /**
    89      * Constructs a new {@code OsmPrivilegesPanel}.
    90      */
    91     public OsmPrivilegesPanel() {
    92         build();
    9393    }
    9494
  • trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java

    r10073 r10183  
    4141 */
    4242public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
    43     private AccessTokenInfoPanel pnlAccessTokenInfo;
     43    private final AccessTokenInfoPanel pnlAccessTokenInfo = new AccessTokenInfoPanel();
    4444    private transient OAuthToken requestToken;
    4545
     
    217217    private class RetrieveAccessTokenPanel extends JPanel {
    218218
    219         private JosmTextField tfAuthoriseUrl;
     219        private final JosmTextField tfAuthoriseUrl = new JosmTextField();
    220220
    221221        /**
     
    261261            gc.gridx = 1;
    262262            gc.weightx = 1.0;
    263             pnl.add(tfAuthoriseUrl = new JosmTextField(), gc);
     263            pnl.add(tfAuthoriseUrl, gc);
    264264            tfAuthoriseUrl.setEditable(false);
    265265
     
    340340            gc.weightx = 1.0;
    341341            gc.gridwidth = 1;
    342             pnl.add(pnlAccessTokenInfo = new AccessTokenInfoPanel(), gc);
     342            pnl.add(pnlAccessTokenInfo, gc);
    343343            pnlAccessTokenInfo.setSaveToPreferences(
    344344                    OAuthAccessTokenHolder.getInstance().isSaveToPreferences()
Note: See TracChangeset for help on using the changeset viewer.