Skip to content

Commit

Permalink
967 Updates bulk alias editor to support editing alias recordable sta…
Browse files Browse the repository at this point in the history
…tus.
  • Loading branch information
Dennis Sheirer committed Nov 9, 2023
1 parent 7302e28 commit 50edb18
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/github/dsheirer/alias/AliasFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public static Alias shallowCopyOf(Alias original)
copy.setGroup(original.getGroup());
copy.setColor(original.getColor());
copy.setIconName(original.getIconName());
copy.setRecordable(original.isRecordable());
return copy;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2021 Dennis Sheirer
* 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
Expand All @@ -19,16 +19,12 @@

package io.github.dsheirer.gui.playlist.alias;

import java.util.List;

import org.controlsfx.control.ToggleSwitch;

import com.google.common.collect.Ordering;

import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.gui.playlist.Editor;
import io.github.dsheirer.icon.Icon;
import io.github.dsheirer.playlist.PlaylistManager;
import java.util.List;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
Expand All @@ -49,6 +45,7 @@
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.util.Callback;
import org.controlsfx.control.ToggleSwitch;

/**
* Editor for multiple selected aliases providing limited options for changing attributes of multiple aliases
Expand All @@ -65,6 +62,8 @@ public class AliasBulkEditor extends Editor<List<Alias>>
private ToggleSwitch mMonitorAudioToggleSwitch;
private ComboBox<Integer> mMonitorPriorityComboBox;
private Button mApplyMonitorButton;
private ToggleSwitch mRecordToggleSwitch;
private Button mApplyRecordButton;

private BooleanProperty mChangeInProgressProperty;
private ReadOnlyBooleanProperty mChangeInProgressROProperty;
Expand Down Expand Up @@ -144,6 +143,17 @@ public AliasBulkEditor(PlaylistManager playlistManager)
GridPane.setConstraints(getApplyMonitorButton(), 4, row);
gridPane.getChildren().add(getApplyMonitorButton());

Label recordLabel = new Label("Record");
GridPane.setHalignment(recordLabel, HPos.RIGHT);
GridPane.setConstraints(recordLabel, 0, ++row);
gridPane.getChildren().add(recordLabel);

GridPane.setConstraints(getRecordToggleSwitch(), 1, row);
gridPane.getChildren().add(getRecordToggleSwitch());

GridPane.setConstraints(getApplyRecordButton(), 4, row);
gridPane.getChildren().add(getApplyRecordButton());

getChildren().add(gridPane);
}

Expand Down Expand Up @@ -326,6 +336,19 @@ private ToggleSwitch getMonitorAudioToggleSwitch()
return mMonitorAudioToggleSwitch;
}

private ToggleSwitch getRecordToggleSwitch()
{
if(mRecordToggleSwitch == null)
{
mRecordToggleSwitch = new ToggleSwitch();
mRecordToggleSwitch.setSelected(false);
mRecordToggleSwitch.selectedProperty()
.addListener((observable, oldValue, newValue) -> modifiedProperty().set(true));
}

return mRecordToggleSwitch;
}

private ComboBox<Integer> getMonitorPriorityComboBox()
{
if(mMonitorPriorityComboBox == null)
Expand All @@ -346,8 +369,6 @@ private ComboBox<Integer> getMonitorPriorityComboBox()
return mMonitorPriorityComboBox;
}

private static int setCount = 0;

private Button getApplyMonitorButton()
{
if(mApplyMonitorButton == null)
Expand Down Expand Up @@ -378,7 +399,6 @@ public void handle(ActionEvent event)
for(Alias alias : getItem())
{
alias.setCallPriority(pri);
//System.out.println(++setCount);
}

endChange();
Expand All @@ -389,6 +409,25 @@ public void handle(ActionEvent event)
return mApplyMonitorButton;
}

private Button getApplyRecordButton()
{
if(mApplyRecordButton == null)
{
mApplyRecordButton = new Button("Apply");
mApplyRecordButton.setOnAction(event -> {
startChange();
boolean record = getRecordToggleSwitch().isSelected();
for(Alias alias : getItem())
{
alias.setRecordable(record);
}
endChange();
});
}

return mApplyRecordButton;
}

/**
* Cell factory for combo box for dislaying icon name and graphic
*/
Expand Down

0 comments on commit 50edb18

Please sign in to comment.