mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Only update ViewByIdentifierEditor's list when the editor is selected (#944)
* Add type parameters to TableColumns to fix compiler warnings * Only update AliasViewByIdentifierEditor list when the editor is selected This prevents the editor's list from being rebuilt in the background as aliases are updated. This caused a massive slowdown when editing many aliases with the AliasBulkEditor. Bulk editing 1000 aliases apply time reduced from over a minute to under 5 seconds.
This commit is contained in:
@@ -124,7 +124,7 @@ public class AliasEditor extends TabPane
|
||||
{
|
||||
if(mAliasViewByIdentifierEditor == null)
|
||||
{
|
||||
mAliasViewByIdentifierEditor = new AliasViewByIdentifierEditor(mPlaylistManager);
|
||||
mAliasViewByIdentifierEditor = new AliasViewByIdentifierEditor(mPlaylistManager, getAliasIdentifierTab().selectedProperty());
|
||||
}
|
||||
|
||||
return mAliasViewByIdentifierEditor;
|
||||
|
||||
@@ -25,11 +25,12 @@ import io.github.dsheirer.alias.id.AliasID;
|
||||
import io.github.dsheirer.alias.id.AliasIDType;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.playlist.PlaylistManager;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
@@ -63,15 +64,19 @@ public class AliasViewByIdentifierEditor extends VBox
|
||||
private TableView<AliasAndIdentifier> mAliasAndIdentifierTableView;
|
||||
private TableColumn<AliasAndIdentifier,String> mIdentifierColumn;
|
||||
private Button mViewAliasButton;
|
||||
private boolean aliasListInvalidated;
|
||||
|
||||
public AliasViewByIdentifierEditor(PlaylistManager playlistManager)
|
||||
public AliasViewByIdentifierEditor(PlaylistManager playlistManager, ReadOnlyBooleanProperty tabSelectedProperty)
|
||||
{
|
||||
aliasListInvalidated = false;
|
||||
mPlaylistManager = playlistManager;
|
||||
mPlaylistManager.getAliasModel().aliasList().addListener((ListChangeListener<Alias>)c -> {
|
||||
//Refresh the list any time that the aliases change since we're using a static snapshot
|
||||
AliasIDType selected = getAliasIDTypeComboBox().getSelectionModel().getSelectedItem();
|
||||
getAliasIDTypeComboBox().getSelectionModel().select(null);
|
||||
getAliasIDTypeComboBox().getSelectionModel().select(selected);
|
||||
//Note if aliases change since we're using a static snapshot
|
||||
mPlaylistManager.getAliasModel().aliasList().addListener((InvalidationListener)observable -> aliasListInvalidated = true);
|
||||
|
||||
//Only update the list when this tab is selected to avoid many slow updates in the background
|
||||
tabSelectedProperty.addListener(observable -> {
|
||||
if (aliasListInvalidated)
|
||||
updateList();
|
||||
});
|
||||
|
||||
GridPane gridPane = new GridPane();
|
||||
@@ -131,6 +136,8 @@ public class AliasViewByIdentifierEditor extends VBox
|
||||
}
|
||||
|
||||
getAliasAndIdentifierTableView().getSortOrder().setAll(mIdentifierColumn);
|
||||
|
||||
aliasListInvalidated = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,22 +197,22 @@ public class AliasViewByIdentifierEditor extends VBox
|
||||
{
|
||||
if(mAliasAndIdentifierTableView == null)
|
||||
{
|
||||
mAliasAndIdentifierTableView = new TableView(FXCollections.observableArrayList(AliasAndIdentifier.extractor()));
|
||||
mAliasAndIdentifierTableView = new TableView<>(FXCollections.observableArrayList(AliasAndIdentifier.extractor()));
|
||||
mAliasAndIdentifierTableView.setPlaceholder(new Label("No aliases or identifiers available"));
|
||||
mIdentifierColumn = new TableColumn<>("Identifier");
|
||||
mIdentifierColumn.setCellValueFactory(new PropertyValueFactory<>("identifier"));
|
||||
mIdentifierColumn.setPrefWidth(350);
|
||||
|
||||
TableColumn aliasColumn = new TableColumn();
|
||||
TableColumn<AliasAndIdentifier, String> aliasColumn = new TableColumn<>();
|
||||
aliasColumn.setText("Alias");
|
||||
aliasColumn.setCellValueFactory(new PropertyValueFactory<>("alias"));
|
||||
aliasColumn.setPrefWidth(200);
|
||||
|
||||
TableColumn groupColumn = new TableColumn();
|
||||
TableColumn<AliasAndIdentifier, String> groupColumn = new TableColumn<>();
|
||||
groupColumn.setText("Group");
|
||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||
groupColumn.setPrefWidth(200);
|
||||
|
||||
|
||||
mAliasAndIdentifierTableView.getColumns().addAll(mIdentifierColumn, aliasColumn, groupColumn);
|
||||
mAliasAndIdentifierTableView.setMaxHeight(Double.MAX_VALUE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user