Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
134 lines (118 loc) · 3.12 KB

File metadata and controls

134 lines (118 loc) · 3.12 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package org.lcdproc.lcdjava;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* RingMenuItem.
* <p>Item to display a text and a status indicator.
* The status can be one of the strings specified for the item.
* @author StefanKrupop
*/
public class RingMenuItem extends AbstractMenuItem
{
private int _value;
private List<String> _items;
/**
* Constructor.
* @param id the of the action.
* @param menu the Submenu that knows about this MenuItem.
*/
protected RingMenuItem(String id, Submenu menu)
{
super(id, menu);
_items = new ArrayList<String>();
_value = 0;
}
/**
* Get the menu item type.
* @return the menu item type.
*/
public String getType()
{
return MENUITEM_RING;
}
public void setItems(List<String> items) {
_items = items;
_value = 0;
update();
}
/**
* Sets current value of the ring
* @param value current value
*/
public void setValue(String value) {
for (int i = 0; i < _items.size(); ++i) {
if (value.equals(_items.get(i))) {
_value = i;
}
}
update();
}
/**
* Sets current value of the ring but does not send the change to LCDd
* @param value current value
*/
public void setValueNoUpdate(int value) {
if (value >= 0 && value < _items.size()) {
_value = value;
}
}
/**
* Gets the current value of the ring
* @return value of the ring
*/
public String getValue() {
return _items.get(_value);
}
@Override
public String getData() {
StringBuilder strb = new StringBuilder();
strb.append(super.getData());
strb.append(" -value ");
strb.append(_value);
strb.append(" -strings \"");
boolean first = true;
for (String item : _items) {
if (!first) {
strb.append('\t');
}
strb.append(item);
first = false;
}
strb.append('"');
return strb.toString();
}
/**
* Construct a new RingMenuItem.
* @param menu the Submenu that owns the menu item.
* @param text the menu text.
* @param items the items in the ring
* @return a new RingMenuItem.
*/
public static RingMenuItem construct(Submenu menu, String text, String... items)
{
return construct(menu, text, Arrays.asList(items));
}
/**
* Construct a new RingMenuItem.
* @param menu the Submenu that owns the menu item.
* @param text the menu text.
* @param items the items in the ring
* @return a new RingMenuItem.
*/
public static RingMenuItem construct(Submenu menu, String text, List<String> items)
{
RingMenuItem menuItem = null;
try
{
menuItem = (RingMenuItem)menu.constructMenuItem(MENUITEM_RING);
menuItem.setItems(items);
menuItem.setText(text);
}
catch (LCDException e) //NOPMD
{
// Supress, would only get one if we asked for an invalid menu item.
}
return menuItem;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.