Code cleanup.

This commit is contained in:
Dennis Sheirer
2021-11-14 07:57:14 -05:00
parent 87e9bf8749
commit 560cbad5d7
2 changed files with 141 additions and 123 deletions

View File

@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2020 Dennis Sheirer
* Copyright (C) 2014-2021 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
@@ -71,6 +71,7 @@ public class AliasBulkEditor extends Editor<List<Alias>>
/**
* Constructs an instance
*
* @param playlistManager for accessing icon manager
*/
public AliasBulkEditor(PlaylistManager playlistManager)
@@ -174,12 +175,15 @@ public class AliasBulkEditor extends Editor<List<Alias>>
/**
* Property indicating whether a bulk change is in progress. Bulk changes may cause drastic
* slow downs in some UI components.
*
* @return changeInProgressProperty
*/
public ReadOnlyBooleanProperty changeInProgressProperty()
{
if(mChangeInProgressROProperty == null)
{
mChangeInProgressROProperty = BooleanProperty.readOnlyBooleanProperty(mChangeInProgressProperty);
}
return mChangeInProgressROProperty;
}
@@ -221,7 +225,8 @@ public class AliasBulkEditor extends Editor<List<Alias>>
if(mApplyColorButton == null)
{
mApplyColorButton = new Button("Apply");
mApplyColorButton.setOnAction(event -> {
mApplyColorButton.setOnAction(event ->
{
startChange();
int colorValue = ColorUtil.toInteger(getColorPicker().getValue());
@@ -243,7 +248,8 @@ public class AliasBulkEditor extends Editor<List<Alias>>
if(mResetColorButton == null)
{
mResetColorButton = new Button("Reset Color");
mResetColorButton.setOnAction(event -> {
mResetColorButton.setOnAction(event ->
{
startChange();
for(Alias alias : getItem())
@@ -341,6 +347,7 @@ public class AliasBulkEditor extends Editor<List<Alias>>
}
private static int setCount = 0;
private Button getApplyMonitorButton()
{
if(mApplyMonitorButton == null)

View File

@@ -1,23 +1,20 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2021 Dennis Sheirer
*
* * ******************************************************************************
* * Copyright (C) 2014-2020 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/>
* * *****************************************************************************
* 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.alias;
@@ -125,8 +122,9 @@ public class AliasConfigurationEditor extends SplitPane
/**
* Request to show the specified alias in the editor.
*
* <p>
* Note: this must be called on the FX platform thread
*
* @param alias to show
*/
public void show(Alias alias)
@@ -175,7 +173,8 @@ public class AliasConfigurationEditor extends SplitPane
//Workaround for JavaFX KDE on Linux bug in FX 10/11: https://bugs.openjdk.java.net/browse/JDK-8179073
alert.setResizable(true);
alert.onShownProperty().addListener(e -> {
alert.onShownProperty().addListener(e ->
{
Platform.runLater(() -> alert.setResizable(false));
});
@@ -293,7 +292,8 @@ public class AliasConfigurationEditor extends SplitPane
{
mAliasListNameComboBox = new ComboBox<>(mPlaylistManager.getAliasModel().aliasListNames());
mAliasListNameComboBox.getSelectionModel().selectedItemProperty()
.addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
.addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) ->
{
getNewAliasButton().setDisable(newValue == null || newValue.contentEquals(AliasModel.NO_ALIAS_LIST));
update();
});
@@ -323,7 +323,8 @@ public class AliasConfigurationEditor extends SplitPane
if(mNewAliasListButton == null)
{
mNewAliasListButton = new Button("New Alias List");
mNewAliasListButton.setOnAction(event -> {
mNewAliasListButton.setOnAction(event ->
{
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Create New Alias List");
dialog.setHeaderText("Please enter an alias list name (max 25 chars).");
@@ -331,7 +332,8 @@ public class AliasConfigurationEditor extends SplitPane
dialog.getEditor().setTextFormatter(new TextFormatter<String>(new MaxLengthUnaryOperator(25)));
Optional<String> result = dialog.showAndWait();
result.ifPresent(s -> {
result.ifPresent(s ->
{
String name = result.get();
if(name != null && !name.isEmpty())
@@ -389,7 +391,8 @@ public class AliasConfigurationEditor extends SplitPane
TableColumn<Alias, Boolean> errorsColumn = new TableColumn<>("Error");
errorsColumn.setPrefWidth(80);
errorsColumn.setCellValueFactory(new PropertyValueFactory<>("overlap"));
errorsColumn.setCellFactory(param -> {
errorsColumn.setCellFactory(param ->
{
TableCell<Alias, Boolean> tableCell = new TableCell<>()
{
@Override
@@ -422,7 +425,8 @@ public class AliasConfigurationEditor extends SplitPane
mAliasTableView.setPlaceholder(getPlaceholderLabel());
mAliasTableView.setItems(getAliasSortedList());
mAliasTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
mAliasTableView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Alias>)c -> {
mAliasTableView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Alias>) c ->
{
Platform.runLater(() -> setAliases(mAliasTableView.getSelectionModel().getSelectedItems()));
});
}
@@ -448,7 +452,8 @@ public class AliasConfigurationEditor extends SplitPane
mAliasSortedList.comparatorProperty().bind(getAliasTableView().comparatorProperty());
//Don't re-sort while the bulk editor is still applying changes to aliases
getAliasBulkEditor().changeInProgressProperty().addListener((observable, oldValue, newValue) -> {
getAliasBulkEditor().changeInProgressProperty().addListener((observable, oldValue, newValue) ->
{
if(newValue)
{
mAliasSortedList.comparatorProperty().unbind();
@@ -499,13 +504,15 @@ public class AliasConfigurationEditor extends SplitPane
mNewAliasButton.setDisable(true);
mNewAliasButton.setAlignment(Pos.CENTER);
mNewAliasButton.setMaxWidth(Double.MAX_VALUE);
mNewAliasButton.setOnAction(event -> {
mNewAliasButton.setOnAction(event ->
{
Alias alias = new Alias("New Alias");
alias.setAliasListName(getAliasListNameComboBox().getSelectionModel().getSelectedItem());
mPlaylistManager.getAliasModel().addAlias(alias);
//Queue a select alias action to allow table to update filter predicate and display the alias
Platform.runLater(() -> {
Platform.runLater(() ->
{
getAliasTableView().getSelectionModel().clearSelection();
getAliasTableView().getSelectionModel().select(alias);
getAliasTableView().scrollTo(alias);
@@ -523,7 +530,8 @@ public class AliasConfigurationEditor extends SplitPane
mDeleteAliasButton = new Button("Delete");
mDeleteAliasButton.setDisable(true);
mDeleteAliasButton.setMaxWidth(Double.MAX_VALUE);
mDeleteAliasButton.setOnAction(event -> {
mDeleteAliasButton.setOnAction(event ->
{
boolean multiple = getAliasTableView().getSelectionModel().getSelectedItems().size() > 1;
@@ -558,7 +566,8 @@ public class AliasConfigurationEditor extends SplitPane
mCloneAliasButton = new Button("Clone");
mCloneAliasButton.setDisable(true);
mCloneAliasButton.setMaxWidth(Double.MAX_VALUE);
mCloneAliasButton.setOnAction(event -> {
mCloneAliasButton.setOnAction(event ->
{
Alias original = getAliasTableView().getSelectionModel().getSelectedItem();
Alias copy = AliasFactory.shallowCopyOf(original);
mPlaylistManager.getAliasModel().addAlias(copy);
@@ -577,7 +586,8 @@ public class AliasConfigurationEditor extends SplitPane
{
mMoveToAliasButton = new MenuButton("Move To");
mMoveToAliasButton.setDisable(true);
mMoveToAliasButton.setOnShowing(event -> {
mMoveToAliasButton.setOnShowing(event ->
{
mMoveToAliasButton.getItems().clear();
MenuItem emptyItem = new MenuItem("Alias Lists");
@@ -606,7 +616,8 @@ public class AliasConfigurationEditor extends SplitPane
{
super(aliasList);
setOnAction(event -> {
setOnAction(event ->
{
List<Alias> selectedAliases = new ArrayList<>(getAliasTableView().getSelectionModel().getSelectedItems());
for(Alias selected : selectedAliases)
{