-
Notifications
You must be signed in to change notification settings - Fork 240
/
LTRNetConfigurationEditor.java
417 lines (359 loc) · 15.1 KB
/
LTRNetConfigurationEditor.java
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.gui.playlist.channel;
import io.github.dsheirer.gui.playlist.decoder.AuxDecoderConfigurationEditor;
import io.github.dsheirer.gui.playlist.eventlog.EventLogConfigurationEditor;
import io.github.dsheirer.gui.playlist.record.RecordConfigurationEditor;
import io.github.dsheirer.gui.playlist.source.FrequencyEditor;
import io.github.dsheirer.gui.playlist.source.SourceConfigurationEditor;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.AuxDecodeConfiguration;
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.module.decode.ltrnet.DecodeConfigLTRNet;
import io.github.dsheirer.module.log.EventLogType;
import io.github.dsheirer.module.log.config.EventLogConfiguration;
import io.github.dsheirer.playlist.PlaylistManager;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.record.RecorderType;
import io.github.dsheirer.record.config.RecordConfiguration;
import io.github.dsheirer.source.config.SourceConfiguration;
import io.github.dsheirer.source.tuner.manager.TunerManager;
import java.util.ArrayList;
import java.util.List;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import org.controlsfx.control.SegmentedButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* LTR-Net channel configuration editor
*/
public class LTRNetConfigurationEditor extends ChannelConfigurationEditor
{
private final static Logger mLog = LoggerFactory.getLogger(LTRNetConfigurationEditor.class);
private TitledPane mAuxDecoderPane;
private TitledPane mDecoderPane;
private TitledPane mEventLogPane;
private TitledPane mRecordPane;
private TitledPane mSourcePane;
private SegmentedButton mDirectionButton;
private SourceConfigurationEditor mSourceConfigurationEditor;
private AuxDecoderConfigurationEditor mAuxDecoderConfigurationEditor;
private EventLogConfigurationEditor mEventLogConfigurationEditor;
private RecordConfigurationEditor mRecordConfigurationEditor;
/**
* Constructs an instance
* @param playlistManager for playlists
* @param tunerManager for tuners
* @param userPreferences for preferences
*/
public LTRNetConfigurationEditor(PlaylistManager playlistManager, TunerManager tunerManager,
UserPreferences userPreferences, IFilterProcessor filterProcessor)
{
super(playlistManager, tunerManager, userPreferences, filterProcessor);
getTitledPanesBox().getChildren().add(getSourcePane());
getTitledPanesBox().getChildren().add(getDecoderPane());
getTitledPanesBox().getChildren().add(getAuxDecoderPane());
getTitledPanesBox().getChildren().add(getEventLogPane());
getTitledPanesBox().getChildren().add(getRecordPane());
}
@Override
public DecoderType getDecoderType()
{
return DecoderType.LTR_NET;
}
private TitledPane getSourcePane()
{
if(mSourcePane == null)
{
mSourcePane = new TitledPane("Source", getSourceConfigurationEditor());
mSourcePane.setExpanded(true);
}
return mSourcePane;
}
private TitledPane getDecoderPane()
{
if(mDecoderPane == null)
{
mDecoderPane = new TitledPane();
mDecoderPane.setText("Decoder: LTR-Net");
mDecoderPane.setExpanded(false);
mDecoderPane.expandedProperty().addListener((observable, oldValue, newValue) -> {
//There's a bug either in the toggle group or the segmented button where setting the toggle to selected
//when the control is hidden in a titled pane prevents the selection, so we have to select the toggle
//again when the pane is expanded. This state is detected by a null selected toggle.
if(newValue)
{
if(getDirectionButton().getToggleGroup().getSelectedToggle() == null)
{
if(getItem().getDecodeConfiguration() instanceof DecodeConfigLTRNet)
{
DecodeConfigLTRNet decodeConfig = (DecodeConfigLTRNet)getItem().getDecodeConfiguration();
MessageDirection direction = decodeConfig.getMessageDirection();
if(direction == null)
{
direction = MessageDirection.OSW;
}
//This will cause the modified property to trigger, so capture the modified state before
//and re-apply after
boolean modified = modifiedProperty().get();
for(Toggle toggle: getDirectionButton().getToggleGroup().getToggles())
{
toggle.setSelected(toggle.getUserData() == direction);
}
modifiedProperty().set(modified);
}
}
}
});
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(10,10,10,10));
gridPane.setHgap(10);
Label directionLabel = new Label("Direction");
GridPane.setHalignment(directionLabel, HPos.LEFT);
GridPane.setConstraints(directionLabel, 0, 0);
gridPane.getChildren().add(directionLabel);
GridPane.setConstraints(getDirectionButton(), 1, 0);
gridPane.getChildren().add(getDirectionButton());
Label instructions = new Label("OSW: repeater output signaling (default). ISW: repeater input signaling");
GridPane.setConstraints(instructions, 2, 0);
gridPane.getChildren().addAll(instructions);
mDecoderPane.setContent(gridPane);
}
return mDecoderPane;
}
private TitledPane getEventLogPane()
{
if(mEventLogPane == null)
{
mEventLogPane = new TitledPane("Logging", getEventLogConfigurationEditor());
mEventLogPane.setExpanded(false);
}
return mEventLogPane;
}
private TitledPane getAuxDecoderPane()
{
if(mAuxDecoderPane == null)
{
mAuxDecoderPane = new TitledPane("Additional Decoders", getAuxDecoderConfigurationEditor());
mAuxDecoderPane.setExpanded(false);
}
return mAuxDecoderPane;
}
private TitledPane getRecordPane()
{
if(mRecordPane == null)
{
mRecordPane = new TitledPane();
mRecordPane.setText("Recording");
mRecordPane.setExpanded(false);
Label notice = new Label("Note: use aliases to control call audio recording");
notice.setPadding(new Insets(10, 10, 0, 10));
VBox vBox = new VBox();
vBox.getChildren().addAll(getRecordConfigurationEditor(), notice);
mRecordPane.setContent(vBox);
}
return mRecordPane;
}
private SourceConfigurationEditor getSourceConfigurationEditor()
{
if(mSourceConfigurationEditor == null)
{
mSourceConfigurationEditor = new FrequencyEditor(mTunerManager);
//Add a listener so that we can push change notifications up to this editor
mSourceConfigurationEditor.modifiedProperty()
.addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}
return mSourceConfigurationEditor;
}
private EventLogConfigurationEditor getEventLogConfigurationEditor()
{
if(mEventLogConfigurationEditor == null)
{
List<EventLogType> types = new ArrayList<>();
types.add(EventLogType.CALL_EVENT);
types.add(EventLogType.DECODED_MESSAGE);
mEventLogConfigurationEditor = new EventLogConfigurationEditor(types);
mEventLogConfigurationEditor.setPadding(new Insets(5,5,5,5));
mEventLogConfigurationEditor.modifiedProperty().addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}
return mEventLogConfigurationEditor;
}
private AuxDecoderConfigurationEditor getAuxDecoderConfigurationEditor()
{
if(mAuxDecoderConfigurationEditor == null)
{
List<DecoderType> types = new ArrayList<>();
types.add(DecoderType.FLEETSYNC2);
types.add(DecoderType.MDC1200);
mAuxDecoderConfigurationEditor = new AuxDecoderConfigurationEditor(types);
mAuxDecoderConfigurationEditor.setPadding(new Insets(5,5,5,5));
mAuxDecoderConfigurationEditor.modifiedProperty().addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}
return mAuxDecoderConfigurationEditor;
}
private SegmentedButton getDirectionButton()
{
if(mDirectionButton == null)
{
mDirectionButton = new SegmentedButton();
mDirectionButton.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK);
mDirectionButton.setDisable(true);
for(MessageDirection messageDirection: MessageDirection.ORDERED_VALUES)
{
ToggleButton toggleButton = new ToggleButton(messageDirection.name());
toggleButton.setTooltip(new Tooltip(messageDirection.toString()));
toggleButton.setUserData(messageDirection);
mDirectionButton.getButtons().add(toggleButton);
}
mDirectionButton.getToggleGroup().selectedToggleProperty()
.addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}
return mDirectionButton;
}
private RecordConfigurationEditor getRecordConfigurationEditor()
{
if(mRecordConfigurationEditor == null)
{
List<RecorderType> types = new ArrayList<>();
types.add(RecorderType.BASEBAND);
mRecordConfigurationEditor = new RecordConfigurationEditor(types);
mRecordConfigurationEditor.setDisable(true);
mRecordConfigurationEditor.modifiedProperty()
.addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}
return mRecordConfigurationEditor;
}
@Override
protected void setDecoderConfiguration(DecodeConfiguration config)
{
if(config instanceof DecodeConfigLTRNet)
{
getDirectionButton().setDisable(false);
DecodeConfigLTRNet decodeConfig = (DecodeConfigLTRNet)config;
MessageDirection direction = decodeConfig.getMessageDirection();
if(direction == null)
{
direction = MessageDirection.OSW;
decodeConfig.setMessageDirection(direction);
}
for(Toggle toggle: getDirectionButton().getToggleGroup().getToggles())
{
toggle.setSelected(toggle.getUserData() == direction);
}
}
else
{
getDirectionButton().setDisable(true);
for(Toggle toggle: getDirectionButton().getToggleGroup().getToggles())
{
toggle.setSelected(false);
}
}
}
@Override
protected void saveDecoderConfiguration()
{
DecodeConfigLTRNet config;
if(getItem().getDecodeConfiguration() instanceof DecodeConfigLTRNet)
{
config = (DecodeConfigLTRNet)getItem().getDecodeConfiguration();
}
else
{
config = new DecodeConfigLTRNet();
}
MessageDirection messageDirection = MessageDirection.OSW;
if(getDirectionButton().getToggleGroup().getSelectedToggle() != null)
{
messageDirection = (MessageDirection)getDirectionButton().getToggleGroup().getSelectedToggle().getUserData();
}
config.setMessageDirection(messageDirection);
getItem().setDecodeConfiguration(config);
}
@Override
protected void setEventLogConfiguration(EventLogConfiguration config)
{
getEventLogConfigurationEditor().setItem(config);
}
@Override
protected void saveEventLogConfiguration()
{
getEventLogConfigurationEditor().save();
if(getEventLogConfigurationEditor().getItem().getLoggers().isEmpty())
{
getItem().setEventLogConfiguration(null);
}
else
{
getItem().setEventLogConfiguration(getEventLogConfigurationEditor().getItem());
}
}
@Override
protected void setAuxDecoderConfiguration(AuxDecodeConfiguration config)
{
getAuxDecoderConfigurationEditor().setItem(config);
}
@Override
protected void saveAuxDecoderConfiguration()
{
getAuxDecoderConfigurationEditor().save();
if(getAuxDecoderConfigurationEditor().getItem().getAuxDecoders().isEmpty())
{
getItem().setAuxDecodeConfiguration(null);
}
else
{
getItem().setAuxDecodeConfiguration(getAuxDecoderConfigurationEditor().getItem());
}
}
@Override
protected void setRecordConfiguration(RecordConfiguration config)
{
getRecordConfigurationEditor().setDisable(config == null);
getRecordConfigurationEditor().setItem(config);
}
@Override
protected void saveRecordConfiguration()
{
getRecordConfigurationEditor().save();
RecordConfiguration config = getRecordConfigurationEditor().getItem();
getItem().setRecordConfiguration(config);
}
@Override
protected void setSourceConfiguration(SourceConfiguration config)
{
getSourceConfigurationEditor().setSourceConfiguration(config);
}
@Override
protected void saveSourceConfiguration()
{
getSourceConfigurationEditor().save();
SourceConfiguration sourceConfiguration = getSourceConfigurationEditor().getSourceConfiguration();
getItem().setSourceConfiguration(sourceConfiguration);
}
}