|
@@ -24,6 +24,7 @@ package com.dmdirc.commandparser;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.config.ConfigManager;
|
26
|
26
|
import java.util.HashMap;
|
|
27
|
+import java.util.List;
|
27
|
28
|
import java.util.Map;
|
28
|
29
|
|
29
|
30
|
/**
|
|
@@ -42,20 +43,31 @@ public class PopupManager {
|
42
|
43
|
|
43
|
44
|
/**
|
44
|
45
|
* Retrieves a map of the menu items that should be in a certain menu type.
|
|
46
|
+ * If the command is equal to "-", the entry should be treated as a divider.
|
45
|
47
|
*
|
46
|
48
|
* @param menuType The type of menu that is being built
|
47
|
49
|
* @param configManager The config manager for the current context
|
|
50
|
+ * @param arguments Any arguments appropriate for the menuType
|
|
51
|
+ *
|
48
|
52
|
* @return A map of "friendly names" to commands (without command characters)
|
49
|
53
|
*/
|
50
|
54
|
public static Map<String, String> getMenuItems(final PopupType menuType,
|
51
|
|
- final ConfigManager configManager) {
|
|
55
|
+ final ConfigManager configManager, final Object ... arguments) {
|
52
|
56
|
final Map<String, String> res = new HashMap<String, String>();
|
53
|
57
|
|
|
58
|
+ int dividerCount = 0;
|
|
59
|
+
|
54
|
60
|
for (String domain : menuType.getDomains()) {
|
55
|
|
- for (String option : configManager.getOptions(domain)) {
|
56
|
|
- final String command = configManager.getOption(domain, option);
|
57
|
|
- if (!command.isEmpty()) {
|
58
|
|
- res.put(option, command);
|
|
61
|
+ final List<String> commands = configManager.getOptionList("popups", domain);
|
|
62
|
+
|
|
63
|
+ for (String command : commands) {
|
|
64
|
+ if ("-".equals(command)) {
|
|
65
|
+ res.put("divider" + (++dividerCount), "-");
|
|
66
|
+ } else {
|
|
67
|
+ final String name = command.substring(0, command.indexOf(':'));
|
|
68
|
+ final String value = command.substring(command.indexOf(':'));
|
|
69
|
+
|
|
70
|
+ res.put(name, String.format(value, arguments));
|
59
|
71
|
}
|
60
|
72
|
}
|
61
|
73
|
}
|