1
1
/*
2
2
* *****************************************************************************
3
- * Copyright (C) 2014-2020 Dennis Sheirer
3
+ * Copyright (C) 2014-2023 Dennis Sheirer
4
4
*
5
5
* This program is free software: you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
34
34
import io .github .dsheirer .rrapi .type .System ;
35
35
import io .github .dsheirer .rrapi .type .Talkgroup ;
36
36
import io .github .dsheirer .rrapi .type .TalkgroupCategory ;
37
+ import java .util .ArrayList ;
38
+ import java .util .Collections ;
39
+ import java .util .Comparator ;
40
+ import java .util .List ;
41
+ import java .util .Optional ;
42
+ import java .util .function .Predicate ;
37
43
import javafx .animation .RotateTransition ;
38
44
import javafx .beans .property .SimpleStringProperty ;
39
45
import javafx .beans .property .StringProperty ;
71
77
import org .slf4j .Logger ;
72
78
import org .slf4j .LoggerFactory ;
73
79
74
- import java .util .Collections ;
75
- import java .util .Comparator ;
76
- import java .util .List ;
77
- import java .util .Optional ;
78
- import java .util .function .Predicate ;
79
-
80
80
public class SystemTalkgroupSelectionEditor extends GridPane
81
81
{
82
82
private static final Logger mLog = LoggerFactory .getLogger (SystemTalkgroupSelectionEditor .class );
@@ -323,13 +323,20 @@ private Button getImportAllTalkgroupsButton()
323
323
}
324
324
else
325
325
{
326
+ List <Talkgroup > aliasesToCreate = new ArrayList <>();
327
+
326
328
for (AliasedTalkgroup aliasedTalkgroup : mTalkgroupFilteredList )
327
329
{
328
330
if (!aliasedTalkgroup .hasAlias ())
329
331
{
330
- createAlias (aliasedTalkgroup .getTalkgroup ());
332
+ aliasesToCreate . add (aliasedTalkgroup .getTalkgroup ());
331
333
}
332
334
}
335
+
336
+ if (!aliasesToCreate .isEmpty ())
337
+ {
338
+ createAliases (aliasesToCreate );
339
+ }
333
340
}
334
341
});
335
342
}
@@ -338,24 +345,31 @@ private Button getImportAllTalkgroupsButton()
338
345
}
339
346
340
347
/**
341
- * Creates an alias for the specified talkgroup and adds it to the currently selected alias list
342
- * @param talkgroup to alias
348
+ * Creates an alias for each of the specified talkgroups and adds it to the currently selected alias list
349
+ * @param talkgroups to alias
343
350
*/
344
- public void createAlias ( Talkgroup talkgroup )
351
+ public void createAliases ( List < Talkgroup > talkgroups )
345
352
{
346
- TalkgroupCategory talkgroupCategory = getTalkgroupCategory (talkgroup );
347
- String group = (talkgroupCategory != null ? talkgroupCategory .getName () : null );
348
- Alias alias = getRadioReferenceDecoder ().createAlias (talkgroup , getCurrentSystem (),
349
- getAliasListNameComboBox ().getSelectionModel ().getSelectedItem (), group );
353
+ List <Alias > createdAliases = new ArrayList <>();
350
354
351
- if (getEncryptedAsDoNotMonitorCheckBox ().selectedProperty ().get () &&
352
- TalkgroupEncryption .lookup (talkgroup .getEncryptionState ()) == TalkgroupEncryption .FULL )
355
+ for (Talkgroup talkgroup : talkgroups )
353
356
{
354
- int priority = io .github .dsheirer .alias .id .priority .Priority .DO_NOT_MONITOR ;
355
- alias .addAliasID (new io .github .dsheirer .alias .id .priority .Priority (priority ));
357
+ TalkgroupCategory talkgroupCategory = getTalkgroupCategory (talkgroup );
358
+ String group = (talkgroupCategory != null ? talkgroupCategory .getName () : null );
359
+ Alias alias = getRadioReferenceDecoder ().createAlias (talkgroup , getCurrentSystem (),
360
+ getAliasListNameComboBox ().getSelectionModel ().getSelectedItem (), group );
361
+
362
+ if (getEncryptedAsDoNotMonitorCheckBox ().selectedProperty ().get () &&
363
+ TalkgroupEncryption .lookup (talkgroup .getEncryptionState ()) == TalkgroupEncryption .FULL )
364
+ {
365
+ int priority = io .github .dsheirer .alias .id .priority .Priority .DO_NOT_MONITOR ;
366
+ alias .addAliasID (new io .github .dsheirer .alias .id .priority .Priority (priority ));
367
+ }
368
+
369
+ createdAliases .add (alias );
356
370
}
357
371
358
- mPlaylistManager .getAliasModel ().addAlias ( alias );
372
+ mPlaylistManager .getAliasModel ().addAliases ( createdAliases );
359
373
}
360
374
361
375
/**
0 commit comments