Changeset c59496f3


Ignore:
Timestamp:
Dec 18, 2015 2:43:31 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d0eaf4d
Parents:
8226e92
Message:

Console: Consolidate "checked" code

Location:
apps/routerconsole/java/src/net/i2p/router/web
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java

    r8226e92 rc59496f3  
    77
    88public class ConfigAdvancedHelper extends HelperBase {
    9     private final static String CHECKED = " checked=\"checked\" ";
    109    static final String PROP_FLOODFILL_PARTICIPANT = "router.floodfillParticipant";
    1110
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java

    r8226e92 rc59496f3  
    6565            (mode == 1 && (!disabled) && (!ssl)) ||
    6666            (mode == 2 && (!disabled) && ssl))
    67             return "checked=\"checked\"";
     67            return CHECKED;
    6868        return "";
    6969    }
     
    7373        boolean enabled =  _context.getBooleanProperty(PROP_AUTH);
    7474        if (enabled)
    75             return "checked=\"checked\"";
     75            return CHECKED;
    7676        return "";
    7777    }
     
    343343        buf.append("</td><td align=\"center\" width=\"10%\"><input type=\"checkbox\" class=\"optbox\" name=\"").append(index).append(".enabled\"");
    344344        if (enabled) {
    345             buf.append("checked=\"checked\" ");
     345            buf.append(CHECKED);
    346346            if (ro || preventDisable)
    347347                buf.append("disabled=\"disabled\" ");
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java

    r8226e92 rc59496f3  
    2626    final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
    2727    final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
    28     private final static String CHECKED = " checked=\"checked\" ";
    2928
    3029    public String getUdphostname() {
     
    7978    }
    8079
    81     /** @param prop must default to false */
    82     public String getChecked(String prop) {
    83         if (_context.getBooleanProperty(prop))
    84             return CHECKED;
    85         return "";
    86     }
    87 
    8880    public String getDynamicKeysChecked() {
    8981        return getChecked(Router.PROP_DYNAMIC_KEYS);
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHelper.java

    r8226e92 rc59496f3  
    5757            (mode == 1 && (!disabled) && required) ||
    5858            (mode == 2 && disabled))
    59             return "checked=\"checked\"";
     59            return CHECKED;
    6060        return "";
    6161    }
    6262
    6363    public String getEnable() {
    64         return checked(Reseeder.PROP_PROXY_ENABLE);
     64        return getChecked(Reseeder.PROP_PROXY_ENABLE);
    6565    }
    6666
    6767    /** @since 0.8.9 */
    6868    public String getAuth() {
    69         return checked(Reseeder.PROP_PROXY_AUTH_ENABLE);
     69        return getChecked(Reseeder.PROP_PROXY_AUTH_ENABLE);
    7070    }
    7171
    7272    public String getSenable() {
    73         return checked(Reseeder.PROP_SPROXY_ENABLE);
     73        return getChecked(Reseeder.PROP_SPROXY_ENABLE);
    7474    }
    7575
    7676    /** @since 0.8.9 */
    7777    public String getSauth() {
    78         return checked(Reseeder.PROP_SPROXY_AUTH_ENABLE);
    79     }
    80 
    81     /** @since 0.8.9 */
    82     private String checked(String prop) {
    83         boolean enabled =  _context.getBooleanProperty(prop);
    84         if (enabled)
    85             return "checked=\"checked\"";
    86         return "";
     78        return getChecked(Reseeder.PROP_SPROXY_AUTH_ENABLE);
    8779    }
    8880
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUIHelper.java

    r8226e92 rc59496f3  
    1515            buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
    1616            if (theme.equals(current))
    17                 buf.append("checked=\"checked\" ");
     17                buf.append(CHECKED);
    1818            buf.append("value=\"").append(theme).append("\">").append(_t(theme)).append("<br>\n");
    1919        }
     
    2121        buf.append("<input type=\"checkbox\" name=\"universalTheming\" ");
    2222        if (universalTheming)
    23             buf.append("checked=\"checked\" ");
     23            buf.append(CHECKED);
    2424        buf.append("value=\"1\">")
    2525           .append(_t("Set theme universally across all apps"))
     
    3333        buf.append("<input type=\"checkbox\" name=\"forceMobileConsole\" ");
    3434        if (forceMobileConsole)
    35             buf.append("checked=\"checked\" ");
     35            buf.append(CHECKED);
    3636        buf.append("value=\"1\">")
    3737           .append(_t("Force the mobile console to be used"))
     
    139139            String lang = langs[i][0];
    140140            if (lang.equals(current))
    141                 buf.append("checked=\"checked\" ");
     141                buf.append(CHECKED);
    142142            buf.append("value=\"").append(lang).append("\">")
    143143               .append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(langs[i][1]).append("\"> ");
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java

    r8226e92 rc59496f3  
    9191   
    9292    public String getUpdateUnsigned() {
    93         if (_context.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED))
    94             return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"checked\" >";
    95         else
    96             return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" >";
     93        return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" " +
     94               getChecked(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED) + '>';
    9795    }
    9896   
    9997    /** @since 0.9.20 */
    10098    public String getUpdateDevSU3() {
    101         if (_context.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_DEV_SU3))
    102             return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateDevSU3\" checked=\"checked\" >";
    103         else
    104             return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateDevSU3\" >";
     99        return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateDevSU3\" " +
     100               getChecked(ConfigUpdateHandler.PROP_UPDATE_DEV_SU3) + '>';
    105101    }
    106102   
  • apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java

    r8226e92 rc59496f3  
    359359                       "<input type=\"hidden\" name=\"nonce\" value=\"" + nonce + "\" >\n");
    360360            _out.write(_t("Periods") + ": <input size=\"5\" style=\"text-align: right;\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\"><br>\n");
    361             _out.write(_t("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"checked\" ") + "> ");
    362             _out.write(_t("or")+ " " +_t("plot events") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"checked\" " : "") + "><br>\n");
     361            _out.write(_t("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : HelperBase.CHECKED) + "> ");
     362            _out.write(_t("or")+ " " +_t("plot events") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? HelperBase.CHECKED : "") + "><br>\n");
    363363            _out.write(_t("Image sizes") + ": " + _t("width") + ": <input size=\"4\" style=\"text-align: right;\" type=\"text\" name=\"width\" value=\"" + _width
    364364                       + "\"> " + _t("pixels") + ", " + _t("height") + ": <input size=\"4\" style=\"text-align: right;\" type=\"text\" name=\"height\" value=\"" + _height 
     
    383383            boolean persistent = _context.getBooleanPropertyDefaultTrue(SummaryListener.PROP_PERSISTENT);
    384384            if (persistent)
    385                 _out.write(" checked=\"checked\"");
     385                _out.write(HelperBase.CHECKED);
    386386            _out.write(">" +
    387387                       "<hr><div class=\"formaction\"><input type=\"submit\" class=\"accept\" value=\"" + _t("Save settings and redraw graphs") + "\"></div></form>");
  • apps/routerconsole/java/src/net/i2p/router/web/HelperBase.java

    r8226e92 rc59496f3  
    1313
    1414    static final String PROP_ADVANCED = "routerconsole.advanced";
     15    static final String CHECKED = " checked=\"checked\" ";
    1516
    1617    /**
     
    4344     */
    4445    public void storeWriter(Writer out) { _out = out; }
     46
     47    /**
     48     *  Is a boolean property set to true?
     49     *
     50     *  @param prop must default to false
     51     *  @return non-null, either "" or " checked=\"checked\" "
     52     *  @since 0.9.24 consolidated from various helpers
     53     */
     54    protected String getChecked(String prop) {
     55        if (_context.getBooleanProperty(prop))
     56            return CHECKED;
     57        return "";
     58    }
    4559
    4660    /** translate a string */
  • apps/routerconsole/java/src/net/i2p/router/web/HomeHelper.java

    r8226e92 rc59496f3  
    104104
    105105    public String getConfigHome() {
    106         boolean oldHome = _context.getBooleanProperty(PROP_OLDHOME);
    107         return oldHome ? "checked=\"checked\"" : "";
     106        return getChecked(PROP_OLDHOME);
    108107    }
    109108
Note: See TracChangeset for help on using the changeset viewer.