forked from I2P_Developers/i2p.i2p
Replaced text fields for ordering summary bar with movement buttons (CSS styling needed)
This commit is contained in:
@@ -26,6 +26,10 @@ public class ConfigSummaryHandler extends FormHandler {
|
|||||||
boolean deleting = _action.equals(_("Delete selected"));
|
boolean deleting = _action.equals(_("Delete selected"));
|
||||||
boolean adding = _action.equals(_("Add item"));
|
boolean adding = _action.equals(_("Add item"));
|
||||||
boolean saving = _action.equals(_("Save order"));
|
boolean saving = _action.equals(_("Save order"));
|
||||||
|
boolean movingTop = _action.substring(_action.indexOf(' ') + 1).equals(_("Top"));
|
||||||
|
boolean movingUp = _action.substring(_action.indexOf(' ') + 1).equals(_("Up"));
|
||||||
|
boolean movingDown = _action.substring(_action.indexOf(' ') + 1).equals(_("Down"));
|
||||||
|
boolean movingBottom = _action.substring(_action.indexOf(' ') + 1).equals(_("Bottom"));
|
||||||
if (_action.equals(_("Save")) && "0".equals(group)) {
|
if (_action.equals(_("Save")) && "0".equals(group)) {
|
||||||
try {
|
try {
|
||||||
int refreshInterval = Integer.parseInt(getJettyString("refreshInterval"));
|
int refreshInterval = Integer.parseInt(getJettyString("refreshInterval"));
|
||||||
@@ -46,7 +50,8 @@ public class ConfigSummaryHandler extends FormHandler {
|
|||||||
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_MINIMAL);
|
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_MINIMAL);
|
||||||
addFormNotice(_("Minimal summary bar default restored.") + " " +
|
addFormNotice(_("Minimal summary bar default restored.") + " " +
|
||||||
_("Summary bar will refresh shortly."));
|
_("Summary bar will refresh shortly."));
|
||||||
} else if (adding || deleting || saving) {
|
} else if (adding || deleting || saving ||
|
||||||
|
movingTop || movingUp || movingDown || movingBottom) {
|
||||||
Map<Integer, String> sections = new TreeMap<Integer, String>();
|
Map<Integer, String> sections = new TreeMap<Integer, String>();
|
||||||
for (Object o : _settings.keySet()) {
|
for (Object o : _settings.keySet()) {
|
||||||
if (!(o instanceof String))
|
if (!(o instanceof String))
|
||||||
@@ -110,6 +115,32 @@ public class ConfigSummaryHandler extends FormHandler {
|
|||||||
addFormNotice(_("Removed") + ": " + removedName);
|
addFormNotice(_("Removed") + ": " + removedName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (movingTop || movingUp || movingDown || movingBottom) {
|
||||||
|
int start = _action.indexOf('[');
|
||||||
|
int end = _action.indexOf(']');
|
||||||
|
String fromStr = _action.substring(start + 1, end - start);
|
||||||
|
try {
|
||||||
|
int from = Integer.parseInt(fromStr);
|
||||||
|
int to = 0;
|
||||||
|
if (movingUp)
|
||||||
|
to = from - 1;
|
||||||
|
if (movingDown)
|
||||||
|
to = from + 1;
|
||||||
|
if (movingBottom)
|
||||||
|
to = sections.size() - 1;
|
||||||
|
int n = -1;
|
||||||
|
if (movingDown || movingBottom)
|
||||||
|
n = 1;
|
||||||
|
for (int i = from; n * i < n * to; i += n) {
|
||||||
|
String temp = sections.get(i + n);
|
||||||
|
sections.put(i + n, sections.get(i));
|
||||||
|
sections.put(i, temp);
|
||||||
|
}
|
||||||
|
addFormNotice(_("Moved") + ": " + sections.get(to));
|
||||||
|
} catch (java.lang.NumberFormatException e) {
|
||||||
|
addFormError(_("Order must be an integer"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SummaryHelper.saveSummaryBarSections(_context, "default", sections);
|
SummaryHelper.saveSummaryBarSections(_context, "default", sections);
|
||||||
addFormError(_("Saved order of sections.") + " " +
|
addFormError(_("Saved order of sections.") + " " +
|
||||||
|
@@ -811,11 +811,36 @@ public class SummaryHelper extends HelperBase {
|
|||||||
int i = sections.indexOf(section);
|
int i = sections.indexOf(section);
|
||||||
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"delete_")
|
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"delete_")
|
||||||
.append(i)
|
.append(i)
|
||||||
.append("\"></td><td align=\"center\"><input type=\"text\" name=\"order_")
|
.append("\"></td><td align=\"center\"><input type=\"hidden\" name=\"order_")
|
||||||
.append(i + "_" + section)
|
.append(i + "_" + section)
|
||||||
.append("\" value=\"")
|
.append("\" value=\"")
|
||||||
.append(i)
|
.append(i)
|
||||||
.append("\"></td><td align=\"left\">")
|
.append("\">");
|
||||||
|
if (i > 0) {
|
||||||
|
buf.append("<input type=\"submit\" class=\"buttonTop\" name=\"action\" value=\"[")
|
||||||
|
.append(i)
|
||||||
|
.append("] ")
|
||||||
|
.append(_("Top"))
|
||||||
|
.append("\">");
|
||||||
|
buf.append("<input type=\"submit\" class=\"buttonUp\" name=\"action\" value=\"[")
|
||||||
|
.append(i)
|
||||||
|
.append("] ")
|
||||||
|
.append(_("Up"))
|
||||||
|
.append("\">");
|
||||||
|
}
|
||||||
|
if (i < sections.size() - 1) {
|
||||||
|
buf.append("<input type=\"submit\" class=\"buttonDown\" name=\"action\" value=\"[")
|
||||||
|
.append(i)
|
||||||
|
.append("] ")
|
||||||
|
.append(_("Down"))
|
||||||
|
.append("\">");
|
||||||
|
buf.append("<input type=\"submit\" class=\"buttonBottom\" name=\"action\" value=\"[")
|
||||||
|
.append(i)
|
||||||
|
.append("] ")
|
||||||
|
.append(_("Bottom"))
|
||||||
|
.append("\">");
|
||||||
|
}
|
||||||
|
buf.append("</td><td align=\"left\">")
|
||||||
.append(section)
|
.append(section)
|
||||||
.append("</td></tr>\n");
|
.append("</td></tr>\n");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user