|
@@ -141,78 +141,92 @@ public class WindowStatusManager implements ConfigChangeListener, SelectionListe
|
141
|
141
|
if (current == null) {
|
142
|
142
|
return;
|
143
|
143
|
}
|
144
|
|
- final StringBuilder textString = new StringBuilder();
|
|
144
|
+ final String textString;
|
145
|
145
|
|
146
|
146
|
if (current instanceof Connection) {
|
147
|
|
- textString.append(((Connection) current).getAddress());
|
|
147
|
+ textString = updateStatusConnection((Connection) current);
|
148
|
148
|
} else if (current instanceof Channel) {
|
149
|
|
- final ChannelInfo chan = ((Channel) current).getChannelInfo();
|
150
|
|
- final Map<Integer, String> names = new HashMap<>();
|
151
|
|
- final Map<Integer, Integer> types = new HashMap<>();
|
152
|
|
-
|
153
|
|
- textString.append(chan.getName());
|
154
|
|
- textString.append(" - Nicks: ");
|
155
|
|
- textString.append(chan.getChannelClientCount());
|
156
|
|
- textString.append(" (");
|
157
|
|
-
|
158
|
|
- for (ChannelClientInfo client : chan.getChannelClients()) {
|
159
|
|
- String mode = client.getImportantModePrefix();
|
160
|
|
- final Integer im = client.getClient().getParser()
|
161
|
|
- .getChannelUserModes().indexOf(mode);
|
162
|
|
-
|
163
|
|
- if (!names.containsKey(im)) {
|
164
|
|
- if (mode.isEmpty()) {
|
165
|
|
- if (shownone) {
|
166
|
|
- mode = nonePrefix;
|
167
|
|
- } else {
|
168
|
|
- continue;
|
169
|
|
- }
|
170
|
|
- }
|
171
|
|
- names.put(im, mode);
|
172
|
|
- }
|
|
149
|
+ textString = updateStatusChannel((Channel) current);
|
|
150
|
+ } else if (current instanceof Query) {
|
|
151
|
+ textString = updateStatusQuery((Query) current);
|
|
152
|
+ } else {
|
|
153
|
+ textString = "???";
|
|
154
|
+ }
|
|
155
|
+ if (panel != null) {
|
|
156
|
+ panel.setText(textString);
|
|
157
|
+ }
|
|
158
|
+ }
|
173
|
159
|
|
174
|
|
- Integer count = types.get(im);
|
|
160
|
+ private String updateStatusConnection(final Connection connection) {
|
|
161
|
+ return connection.getAddress();
|
|
162
|
+ }
|
175
|
163
|
|
176
|
|
- if (count == null) {
|
177
|
|
- count = 1;
|
178
|
|
- } else {
|
179
|
|
- count++;
|
|
164
|
+ private String updateStatusChannel(final Channel frame) {
|
|
165
|
+ final StringBuilder textString = new StringBuilder();
|
|
166
|
+ final ChannelInfo chan = frame.getChannelInfo();
|
|
167
|
+ final Map<Integer, String> names = new HashMap<>();
|
|
168
|
+ final Map<Integer, Integer> types = new HashMap<>();
|
|
169
|
+
|
|
170
|
+ textString.append(chan.getName());
|
|
171
|
+ textString.append(" - Nicks: ");
|
|
172
|
+ textString.append(chan.getChannelClientCount());
|
|
173
|
+ textString.append(" (");
|
|
174
|
+
|
|
175
|
+ for (ChannelClientInfo client : chan.getChannelClients()) {
|
|
176
|
+ String mode = client.getImportantModePrefix();
|
|
177
|
+ final Integer im = client.getClient().getParser()
|
|
178
|
+ .getChannelUserModes().indexOf(mode);
|
|
179
|
+
|
|
180
|
+ if (!names.containsKey(im)) {
|
|
181
|
+ if (mode.isEmpty()) {
|
|
182
|
+ if (shownone) {
|
|
183
|
+ mode = nonePrefix;
|
|
184
|
+ } else {
|
|
185
|
+ continue;
|
|
186
|
+ }
|
180
|
187
|
}
|
181
|
|
- types.put(im, count);
|
|
188
|
+ names.put(im, mode);
|
182
|
189
|
}
|
183
|
190
|
|
184
|
|
- boolean isFirst = true;
|
|
191
|
+ Integer count = types.get(im);
|
185
|
192
|
|
186
|
|
- for (Map.Entry<Integer, Integer> entry : types.entrySet()) {
|
187
|
|
- if (isFirst) {
|
188
|
|
- isFirst = false;
|
189
|
|
- } else {
|
190
|
|
- textString.append(' ');
|
191
|
|
- }
|
192
|
|
- textString.append(names.get(entry.getKey()));
|
193
|
|
- textString.append(entry.getValue());
|
|
193
|
+ if (count == null) {
|
|
194
|
+ count = 1;
|
|
195
|
+ } else {
|
|
196
|
+ count++;
|
194
|
197
|
}
|
|
198
|
+ types.put(im, count);
|
|
199
|
+ }
|
195
|
200
|
|
196
|
|
- textString.append(')');
|
197
|
|
- } else if (current instanceof Query) {
|
198
|
|
- final Query frame = (Query) current;
|
199
|
|
-
|
200
|
|
- textString.append(frame.getHost());
|
201
|
|
- if (showname && frame.getConnection().getParser() != null) {
|
202
|
|
- final ClientInfo client = frame.getConnection().getParser()
|
203
|
|
- .getClient(frame.getHost());
|
204
|
|
- final String realname = client.getRealname();
|
205
|
|
- if (realname != null && !realname.isEmpty()) {
|
206
|
|
- textString.append(" - ");
|
207
|
|
- textString.append(client.getRealname());
|
208
|
|
- }
|
|
201
|
+ boolean isFirst = true;
|
|
202
|
+
|
|
203
|
+ for (Map.Entry<Integer, Integer> entry : types.entrySet()) {
|
|
204
|
+ if (isFirst) {
|
|
205
|
+ isFirst = false;
|
|
206
|
+ } else {
|
|
207
|
+ textString.append(' ');
|
209
|
208
|
}
|
210
|
|
- } else {
|
211
|
|
- textString.append("???");
|
|
209
|
+ textString.append(names.get(entry.getKey()));
|
|
210
|
+ textString.append(entry.getValue());
|
212
|
211
|
}
|
213
|
|
- if (panel != null) {
|
214
|
|
- panel.setText(textString.toString());
|
|
212
|
+
|
|
213
|
+ textString.append(')');
|
|
214
|
+ return textString.toString();
|
|
215
|
+ }
|
|
216
|
+
|
|
217
|
+ private String updateStatusQuery(final Query frame) {
|
|
218
|
+ final StringBuilder textString = new StringBuilder();
|
|
219
|
+ textString.append(frame.getHost());
|
|
220
|
+ if (showname && frame.getConnection().getParser() != null) {
|
|
221
|
+ final ClientInfo client = frame.getConnection().getParser()
|
|
222
|
+ .getClient(frame.getHost());
|
|
223
|
+ final String realname = client.getRealname();
|
|
224
|
+ if (realname != null && !realname.isEmpty()) {
|
|
225
|
+ textString.append(" - ");
|
|
226
|
+ textString.append(client.getRealname());
|
|
227
|
+ }
|
215
|
228
|
}
|
|
229
|
+ return textString.toString();
|
216
|
230
|
}
|
217
|
231
|
|
218
|
232
|
@Override
|