java.lang.Object
net.i2p.router.web.helpers.ConfigRestartBean
Simple helper to control restarts/shutdowns in the left hand nav.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringProperty selecting the advanced button set.private static final String[]All these are tagged below so no need to _x them here.private static final String[]Button labels shown to a basic-mode user.private static final String[]Button labels shown to an advanced-mode user.private static final String[]Button labels shown when the router may only stop.Constructor Summary
ConstructorsConstructorDescriptionCreates a bean; the container calls it with no arguments before rendering the nav.Method Summary
Modifier and TypeMethodDescriptionprivate static String_t(String s, Object o, RouterContext ctx) Translates a label with one argument substituted.private static String_t(String s, RouterContext ctx) Translates a label using the router's language.private static voidbuttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) Value,class,label,...private static StringformatDelay(int seconds) Format seconds as "1m 30s" or just "45s".static longThis is for sidebar.jsp.static booleanCheck if advanced mode is enabled.static booleanCheck if the router is restarting.static booleanCheck if the router is shutting down.private static Stringngettext(String s, String p, int n, RouterContext ctx) Translate a string whose form depends on a count (ngettext).static StringrenderStatus(String urlBase, String action, HttpSession session, String nextNonce, String nonce) This also initiates the restart/shutdown based on action.
Field Details
SET1
All these are tagged below so no need to _x them here. order is: form value, form class, display text.SET2
Button labels shown to a basic-mode user.SET3
Button labels shown to an advanced-mode user.SET4
Button labels shown when the router may only stop.PROP_ADVANCED
Property selecting the advanced button set.- See Also:
Constructor Details
ConfigRestartBean
public ConfigRestartBean()Creates a bean; the container calls it with no arguments before rendering the nav.
Method Details
isAdvanced
public static boolean isAdvanced()Check if advanced mode is enabled.- Returns:
- true if advanced mode is enabled
renderStatus
public static String renderStatus(String urlBase, String action, HttpSession session, String nextNonce, String nonce) This also initiates the restart/shutdown based on action.- Parameters:
urlBase- the base URLaction- the action to performsession- the HTTP sessionnextNonce- the next nonce to output in the formnonce- the nonce to be validated for actions- Returns:
- the rendered HTML
buttons
private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) Value,class,label,... triplets.- Parameters:
ctx- the router context used to translate the button labelsbuf- the HTML form is appended tourl- the form's action URLnonce- the console nonce, added as a hidden fields- value,class,label,... triplets
isShuttingDown
Check if the router is shutting down.- Parameters:
ctx- the router context- Returns:
- true if shutting down
isRestarting
Check if the router is restarting.- Parameters:
ctx- the router context- Returns:
- true if restarting
getRestartTimeRemaining
public static long getRestartTimeRemaining()This is for sidebar.jsp.- Returns:
- the time remaining until restart
_t
Translates a label using the router's language.- Parameters:
s- the text to translatectx- the context holding the language- Returns:
- the translated text
_t
Translates a label with one argument substituted.- Parameters:
s- the text to translateo- the argument to substitutectx- the context holding the language- Returns:
- the translated text
ngettext
Translate a string whose form depends on a count (ngettext).- Parameters:
s- the singular English text, also the lookup keyp- the plural English textn- the count deciding which form is usedctx- the router context supplying the language- Returns:
- the translated string for that count
formatDelay
Format seconds as "1m 30s" or just "45s".- Parameters:
seconds- the delay to format, 0 or less is shown as "0s"- Returns:
- the delay with an m and an s part, either omitted when it is zero