mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 02:57:35 -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)
|
if(mAliasViewByIdentifierEditor == null)
|
||||||
{
|
{
|
||||||
mAliasViewByIdentifierEditor = new AliasViewByIdentifierEditor(mPlaylistManager);
|
mAliasViewByIdentifierEditor = new AliasViewByIdentifierEditor(mPlaylistManager, getAliasIdentifierTab().selectedProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
return mAliasViewByIdentifierEditor;
|
return mAliasViewByIdentifierEditor;
|
||||||
|
|||||||
@@ -25,11 +25,12 @@ import io.github.dsheirer.alias.id.AliasID;
|
|||||||
import io.github.dsheirer.alias.id.AliasIDType;
|
import io.github.dsheirer.alias.id.AliasIDType;
|
||||||
import io.github.dsheirer.eventbus.MyEventBus;
|
import io.github.dsheirer.eventbus.MyEventBus;
|
||||||
import io.github.dsheirer.playlist.PlaylistManager;
|
import io.github.dsheirer.playlist.PlaylistManager;
|
||||||
|
import javafx.beans.InvalidationListener;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ListChangeListener;
|
|
||||||
import javafx.collections.transformation.FilteredList;
|
import javafx.collections.transformation.FilteredList;
|
||||||
import javafx.geometry.HPos;
|
import javafx.geometry.HPos;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
@@ -63,15 +64,19 @@ public class AliasViewByIdentifierEditor extends VBox
|
|||||||
private TableView<AliasAndIdentifier> mAliasAndIdentifierTableView;
|
private TableView<AliasAndIdentifier> mAliasAndIdentifierTableView;
|
||||||
private TableColumn<AliasAndIdentifier,String> mIdentifierColumn;
|
private TableColumn<AliasAndIdentifier,String> mIdentifierColumn;
|
||||||
private Button mViewAliasButton;
|
private Button mViewAliasButton;
|
||||||
|
private boolean aliasListInvalidated;
|
||||||
|
|
||||||
public AliasViewByIdentifierEditor(PlaylistManager playlistManager)
|
public AliasViewByIdentifierEditor(PlaylistManager playlistManager, ReadOnlyBooleanProperty tabSelectedProperty)
|
||||||
{
|
{
|
||||||
|
aliasListInvalidated = false;
|
||||||
mPlaylistManager = playlistManager;
|
mPlaylistManager = playlistManager;
|
||||||
mPlaylistManager.getAliasModel().aliasList().addListener((ListChangeListener<Alias>)c -> {
|
//Note if aliases change since we're using a static snapshot
|
||||||
//Refresh the list any time that the aliases change since we're using a static snapshot
|
mPlaylistManager.getAliasModel().aliasList().addListener((InvalidationListener)observable -> aliasListInvalidated = true);
|
||||||
AliasIDType selected = getAliasIDTypeComboBox().getSelectionModel().getSelectedItem();
|
|
||||||
getAliasIDTypeComboBox().getSelectionModel().select(null);
|
//Only update the list when this tab is selected to avoid many slow updates in the background
|
||||||
getAliasIDTypeComboBox().getSelectionModel().select(selected);
|
tabSelectedProperty.addListener(observable -> {
|
||||||
|
if (aliasListInvalidated)
|
||||||
|
updateList();
|
||||||
});
|
});
|
||||||
|
|
||||||
GridPane gridPane = new GridPane();
|
GridPane gridPane = new GridPane();
|
||||||
@@ -131,6 +136,8 @@ public class AliasViewByIdentifierEditor extends VBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAliasAndIdentifierTableView().getSortOrder().setAll(mIdentifierColumn);
|
getAliasAndIdentifierTableView().getSortOrder().setAll(mIdentifierColumn);
|
||||||
|
|
||||||
|
aliasListInvalidated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,18 +197,18 @@ public class AliasViewByIdentifierEditor extends VBox
|
|||||||
{
|
{
|
||||||
if(mAliasAndIdentifierTableView == null)
|
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"));
|
mAliasAndIdentifierTableView.setPlaceholder(new Label("No aliases or identifiers available"));
|
||||||
mIdentifierColumn = new TableColumn<>("Identifier");
|
mIdentifierColumn = new TableColumn<>("Identifier");
|
||||||
mIdentifierColumn.setCellValueFactory(new PropertyValueFactory<>("identifier"));
|
mIdentifierColumn.setCellValueFactory(new PropertyValueFactory<>("identifier"));
|
||||||
mIdentifierColumn.setPrefWidth(350);
|
mIdentifierColumn.setPrefWidth(350);
|
||||||
|
|
||||||
TableColumn aliasColumn = new TableColumn();
|
TableColumn<AliasAndIdentifier, String> aliasColumn = new TableColumn<>();
|
||||||
aliasColumn.setText("Alias");
|
aliasColumn.setText("Alias");
|
||||||
aliasColumn.setCellValueFactory(new PropertyValueFactory<>("alias"));
|
aliasColumn.setCellValueFactory(new PropertyValueFactory<>("alias"));
|
||||||
aliasColumn.setPrefWidth(200);
|
aliasColumn.setPrefWidth(200);
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn<AliasAndIdentifier, String> groupColumn = new TableColumn<>();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Group");
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
groupColumn.setPrefWidth(200);
|
groupColumn.setPrefWidth(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user