mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
* WIP - Adds support for aliasing P25 Phase 2 tones.Playlist editor - adds editor support for alias actions * Playlist editor implementation and integration into application is complete. Adds JavaFX window monitoring to persist window size/location across application runs. Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -37,7 +37,7 @@ public class PreferenceEditorFactory
|
||||
{
|
||||
switch(preferenceEditorType)
|
||||
{
|
||||
case AUDIO_PLAYBACK:
|
||||
case AUDIO_OUTPUT:
|
||||
return new PlaybackPreferenceEditor(userPreferences);
|
||||
case AUDIO_RECORD:
|
||||
return new RecordPreferenceEditor(userPreferences);
|
||||
|
||||
@@ -28,7 +28,7 @@ public enum PreferenceEditorType
|
||||
DIRECTORY("Directories"),
|
||||
JMBE_LIBRARY("JMBE Audio Library"),
|
||||
AUDIO_RECORD("Record"),
|
||||
AUDIO_PLAYBACK("Playback"),
|
||||
AUDIO_OUTPUT("Output/Tones"),
|
||||
SOURCE_CHANNEL_MULTIPLE_FREQUENCY("Channel - Multiple Frequency"),
|
||||
SOURCE_TUNER_CHANNELIZER("Tuner Channelizer"),
|
||||
TALKGROUP_FORMAT("Talkgroup & Radio ID"),
|
||||
|
||||
@@ -34,6 +34,8 @@ import javafx.scene.control.Separator;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Preference settings for channel event view
|
||||
@@ -68,7 +70,8 @@ public class TalkgroupFormatPreferenceEditor extends HBox
|
||||
GridPane.setMargin(label, new Insets(0, 10, 0, 0));
|
||||
GridPane.setHalignment(label, HPos.LEFT);
|
||||
mEditorPane.add(label, 0, row);
|
||||
IntegerFormatEditor editor = new IntegerFormatEditor(mTalkgroupFormatPreference, protocol);
|
||||
IntegerFormatEditor editor = new IntegerFormatEditor(mTalkgroupFormatPreference, protocol,
|
||||
TalkgroupFormatPreference.getFormats(protocol));
|
||||
GridPane.setMargin(editor, new Insets(5,5,5,5));
|
||||
mEditorPane.add(editor, 1, row);
|
||||
FixedWidthEditor fixedWidthEditor = new FixedWidthEditor(mTalkgroupFormatPreference, protocol);
|
||||
@@ -89,13 +92,13 @@ public class TalkgroupFormatPreferenceEditor extends HBox
|
||||
private TalkgroupFormatPreference mTalkgroupFormatPreference;
|
||||
private Protocol mProtocol;
|
||||
|
||||
public IntegerFormatEditor(TalkgroupFormatPreference preference, Protocol protocol)
|
||||
public IntegerFormatEditor(TalkgroupFormatPreference preference, Protocol protocol, Set<IntegerFormat> formats)
|
||||
{
|
||||
mTalkgroupFormatPreference = preference;
|
||||
mProtocol = protocol;
|
||||
getItems().addAll(IntegerFormat.values());
|
||||
setMaxWidth(Double.MAX_VALUE);
|
||||
getItems().addAll(formats);
|
||||
getSelectionModel().select(mTalkgroupFormatPreference.getTalkgroupFormat(mProtocol));
|
||||
|
||||
setOnAction(event -> {
|
||||
IntegerFormat selected = getSelectionModel().getSelectedItem();
|
||||
mTalkgroupFormatPreference.setTalkgroupFormat(mProtocol, selected);
|
||||
|
||||
@@ -19,15 +19,26 @@ package io.github.dsheirer.gui.preference;
|
||||
/**
|
||||
* Request to launch the preferences editor and scroll to a specific editor view
|
||||
*/
|
||||
public class PreferenceEditorViewRequest
|
||||
public class UserPreferenceEditorViewRequest
|
||||
{
|
||||
private PreferenceEditorType mPreferenceType;
|
||||
|
||||
public PreferenceEditorViewRequest(PreferenceEditorType preferenceEditorType)
|
||||
/**
|
||||
* Request to show the preference editor and focus the specified editor type control
|
||||
* @param preferenceEditorType to focus
|
||||
*/
|
||||
public UserPreferenceEditorViewRequest(PreferenceEditorType preferenceEditorType)
|
||||
{
|
||||
mPreferenceType = preferenceEditorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to simply show the preference editor without focusing any of the components
|
||||
*/
|
||||
public UserPreferenceEditorViewRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public PreferenceEditorType getPreferenceType()
|
||||
{
|
||||
return mPreferenceType;
|
||||
@@ -19,26 +19,28 @@
|
||||
|
||||
package io.github.dsheirer.gui.preference;
|
||||
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.gui.playlist.ViewPlaylistRequest;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.protocol.Protocol;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -50,40 +52,33 @@ import java.util.Map;
|
||||
/**
|
||||
* Preferences editor dialog
|
||||
*/
|
||||
public class PreferencesEditor extends Application
|
||||
public class UserPreferencesEditor extends BorderPane
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(PreferencesEditor.class);
|
||||
private final static Logger mLog = LoggerFactory.getLogger(UserPreferencesEditor.class);
|
||||
|
||||
private Map<PreferenceEditorType,Node> mEditors = new EnumMap<>(PreferenceEditorType.class);
|
||||
private UserPreferences mUserPreferences;
|
||||
private HBox mParentBox;
|
||||
private MenuBar mMenuBar;
|
||||
private TreeView mEditorSelectionTreeView;
|
||||
private VBox mEditorAndButtonsBox;
|
||||
private Node mEditor;
|
||||
private HBox mButtonsBox;
|
||||
|
||||
public Stage getStage()
|
||||
{
|
||||
try
|
||||
{
|
||||
Window window = getParentBox().getScene().getWindow();
|
||||
|
||||
if(window instanceof Stage)
|
||||
{
|
||||
return (Stage)window;
|
||||
}
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
mLog.debug("Error", t);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PreferencesEditor(UserPreferences userPreferences)
|
||||
/**
|
||||
* Constructs an instance
|
||||
*
|
||||
* @param userPreferences to edit
|
||||
*/
|
||||
public UserPreferencesEditor(UserPreferences userPreferences)
|
||||
{
|
||||
mUserPreferences = userPreferences;
|
||||
|
||||
setTop(getMenuBar());
|
||||
|
||||
HBox contentBox = new HBox();
|
||||
HBox.setHgrow(getEditorAndButtonsBox(), Priority.ALWAYS);
|
||||
contentBox.getChildren().addAll(getEditorSelectionTreeView(), getEditorAndButtonsBox());
|
||||
setCenter(contentBox);
|
||||
}
|
||||
|
||||
private UserPreferences getUserPreferences()
|
||||
@@ -96,28 +91,25 @@ public class PreferencesEditor extends Application
|
||||
return mUserPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception
|
||||
{
|
||||
stage.setTitle("Preferences");
|
||||
Scene scene = new Scene(getParentBox(), 900, 500);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the editor specified in the request by scrolling the editor view tree to the selected item.
|
||||
*/
|
||||
public void showEditor(PreferenceEditorViewRequest request)
|
||||
public void process(UserPreferenceEditorViewRequest request)
|
||||
{
|
||||
TreeItem toSelect = recursivelyFindEditorType(getEditorSelectionTreeView().getRoot(), request.getPreferenceType());
|
||||
|
||||
if(toSelect != null)
|
||||
if(request.getPreferenceType() != null)
|
||||
{
|
||||
getEditorSelectionTreeView().getSelectionModel().select(toSelect);
|
||||
TreeItem toSelect = recursivelyFindEditorType(getEditorSelectionTreeView().getRoot(), request.getPreferenceType());
|
||||
|
||||
if(toSelect != null)
|
||||
{
|
||||
getEditorSelectionTreeView().getSelectionModel().select(toSelect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively finds the tree branch that matches the editor type
|
||||
*/
|
||||
private TreeItem recursivelyFindEditorType(TreeItem parent, PreferenceEditorType type)
|
||||
{
|
||||
|
||||
@@ -136,23 +128,6 @@ public class PreferencesEditor extends Application
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Primary layout for the editor window
|
||||
*/
|
||||
private HBox getParentBox()
|
||||
{
|
||||
if(mParentBox == null)
|
||||
{
|
||||
mParentBox = new HBox();
|
||||
mParentBox.getChildren().add(getEditorSelectionTreeView());
|
||||
HBox.setHgrow(getEditorAndButtonsBox(), Priority.ALWAYS);
|
||||
mParentBox.getChildren().add(getEditorAndButtonsBox());
|
||||
}
|
||||
|
||||
return mParentBox;
|
||||
}
|
||||
|
||||
private VBox getEditorAndButtonsBox()
|
||||
{
|
||||
if(mEditorAndButtonsBox == null)
|
||||
@@ -194,7 +169,7 @@ public class PreferencesEditor extends Application
|
||||
TreeItem<String> treeRoot = new TreeItem<>("Root node");
|
||||
|
||||
TreeItem<String> audioItem = new TreeItem<>("Audio");
|
||||
audioItem.getChildren().add(new TreeItem(PreferenceEditorType.AUDIO_PLAYBACK));
|
||||
audioItem.getChildren().add(new TreeItem(PreferenceEditorType.AUDIO_OUTPUT));
|
||||
audioItem.getChildren().add(new TreeItem(PreferenceEditorType.AUDIO_RECORD));
|
||||
treeRoot.getChildren().add(audioItem);
|
||||
audioItem.setExpanded(true);
|
||||
@@ -245,7 +220,7 @@ public class PreferencesEditor extends Application
|
||||
mButtonsBox.setMaxWidth(Double.MAX_VALUE);
|
||||
Button okButton = new Button("Ok");
|
||||
okButton.setOnAction(event -> {
|
||||
Stage stage = (Stage)getParentBox().getScene().getWindow();
|
||||
Stage stage = (Stage)getButtonsBox().getScene().getWindow();
|
||||
stage.close();
|
||||
});
|
||||
HBox.setMargin(okButton, new Insets(5, 5, 5, 5));
|
||||
@@ -256,6 +231,31 @@ public class PreferencesEditor extends Application
|
||||
return mButtonsBox;
|
||||
}
|
||||
|
||||
private MenuBar getMenuBar()
|
||||
{
|
||||
if(mMenuBar == null)
|
||||
{
|
||||
mMenuBar = new MenuBar();
|
||||
|
||||
//File Menu
|
||||
Menu fileMenu = new Menu("File");
|
||||
|
||||
MenuItem closeItem = new MenuItem("Close");
|
||||
closeItem.setOnAction(event -> getMenuBar().getParent().getScene().getWindow().hide());
|
||||
fileMenu.getItems().add(closeItem);
|
||||
|
||||
mMenuBar.getMenus().add(fileMenu);
|
||||
|
||||
Menu viewMenu = new Menu("View");
|
||||
MenuItem playlistEditorItem = new MenuItem("Playlist Editor");
|
||||
playlistEditorItem.setOnAction(event -> MyEventBus.getEventBus().post(new ViewPlaylistRequest()));
|
||||
viewMenu.getItems().add(playlistEditorItem);
|
||||
mMenuBar.getMenus().add(viewMenu);
|
||||
}
|
||||
|
||||
return mMenuBar;
|
||||
}
|
||||
|
||||
private void setEditor(PreferenceEditorType type)
|
||||
{
|
||||
Node editor = mEditors.get(type);
|
||||
@@ -286,7 +286,6 @@ public class PreferencesEditor extends Application
|
||||
*/
|
||||
public class EditorTreeSelectionListener implements ChangeListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public void changed(ObservableValue observable, Object oldValue, Object newValue)
|
||||
{
|
||||
@@ -304,9 +303,4 @@ public class PreferencesEditor extends Application
|
||||
setEditor(PreferenceEditorType.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,23 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2019 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.
|
||||
* * ******************************************************************************
|
||||
* * 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 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.preference.tuner;
|
||||
@@ -26,6 +28,7 @@ import io.github.dsheirer.preference.source.TunerPreference;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.Label;
|
||||
@@ -109,6 +112,7 @@ public class TunerPreferenceEditor extends HBox
|
||||
label.setWrapText(true);
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.getDialogPane().setContent(label);
|
||||
alert.initOwner(((Node)getChannelizerTypeChoiceBox()).getScene().getWindow());
|
||||
alert.show();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user