mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
WIP #34 - more work on tuner model and view. Includes new tuner
configuration and tuner configuration assignment editors. Beginning of tuner editor panel rework. Removes most of the remaining JTree configuration pieces. Updates the settings manager to load and save tuners and refactors all of the tuner configuration management out into the tuner configuration model.
This commit is contained in:
@@ -1,196 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
public class BaseNode extends DefaultMutableTreeNode
|
||||
implements Comparable<BaseNode>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Model backing the JTree and nodes. Since we're primarily interacting
|
||||
* with the model via JTree tree nodes via context menus, injecting a
|
||||
* reference to the model facilitates nodal access to the model's methods
|
||||
*/
|
||||
protected ConfigurationControllerModel mModel = null;
|
||||
|
||||
/**
|
||||
* Implements a base node that has a reference to the underlying
|
||||
* tree data model to facilitate tree node operations from nodal context
|
||||
* menus.
|
||||
*/
|
||||
public BaseNode( Object object )
|
||||
{
|
||||
super( object );
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to return a custom icon for the node
|
||||
* @return
|
||||
*/
|
||||
public String getIconPath()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Color getBackgroundColor()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if( getUserObject() != null )
|
||||
{
|
||||
return (String)getUserObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "SDRTrunk";
|
||||
}
|
||||
}
|
||||
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new EmptyEditor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator to support nodal sorting/ordering
|
||||
*/
|
||||
@Override
|
||||
public int compareTo( BaseNode node )
|
||||
{
|
||||
return toString().compareTo( node.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* This method only needs to be called once on the root node and all nodes
|
||||
* in the tree will then have a reference to the model via getModel()
|
||||
*/
|
||||
public void setModel( ConfigurationControllerModel model )
|
||||
{
|
||||
mModel = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns reference to the SystemTreeModel. Only ConfigurableNode types
|
||||
* or children are allowed in this tree, so this method assumes that the
|
||||
* node or parent is of ConfigurableNode class or subclass.
|
||||
*
|
||||
* Reference to the model is required to enable node context operations
|
||||
* like adding/deleting/stopping/starting.
|
||||
*/
|
||||
public ConfigurationControllerModel getModel()
|
||||
{
|
||||
if( mModel == null )
|
||||
{
|
||||
TreeNode parent = getParent();
|
||||
|
||||
if( parent != null )
|
||||
{
|
||||
return ((BaseNode)parent).getModel();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return mModel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports a context menu for any children of the BaseNode. Override the
|
||||
* method in the child node to provide a custom context menu for that node.
|
||||
*/
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a recursive delete() on all children to perform any cleanup
|
||||
* operations prior to deleting. Override this method to perform cleanup
|
||||
* operations specific to the node. Remember to also either invoke
|
||||
* super.delete(), or specifically call .delete() on any children of the
|
||||
* node with the custom delete method.
|
||||
*/
|
||||
public void delete()
|
||||
{
|
||||
for( int x = 0; x < getChildCount(); x++ )
|
||||
{
|
||||
BaseNode node = (BaseNode)getChildAt( x );
|
||||
|
||||
//Tell the node to delete its children
|
||||
node.delete();
|
||||
|
||||
//Delete the child node
|
||||
getModel().deleteNode( node );
|
||||
}
|
||||
}
|
||||
|
||||
public void show()
|
||||
{
|
||||
getModel().showNode( this );
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
if( getModel() != null )
|
||||
{
|
||||
getModel().nodeChanged( this );
|
||||
}
|
||||
}
|
||||
|
||||
public void sort()
|
||||
{
|
||||
List<BaseNode> nodesToSort = new ArrayList<BaseNode>();
|
||||
|
||||
while( children().hasMoreElements() )
|
||||
{
|
||||
BaseNode child = (BaseNode)children().nextElement();
|
||||
|
||||
nodesToSort.add( child );
|
||||
|
||||
getModel().removeNodeFromParent( child );
|
||||
}
|
||||
|
||||
if( !nodesToSort.isEmpty() )
|
||||
{
|
||||
Collections.sort( nodesToSort );
|
||||
|
||||
for( BaseNode node: nodesToSort )
|
||||
{
|
||||
getModel().insertNodeInto( node, this, getChildCount() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import playlist.PlaylistManager;
|
||||
|
||||
public abstract class ConfigurableNode extends BaseNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PlaylistManager mPlaylistManager;
|
||||
|
||||
public ConfigurableNode( PlaylistManager playlistManager, Object object )
|
||||
{
|
||||
super( object );
|
||||
|
||||
mPlaylistManager = playlistManager;
|
||||
}
|
||||
|
||||
protected PlaylistManager getPlaylistManager()
|
||||
{
|
||||
return mPlaylistManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves changes to the node
|
||||
*/
|
||||
public void save()
|
||||
{
|
||||
mPlaylistManager.save();
|
||||
|
||||
BaseNode parent = (BaseNode)getParent();
|
||||
|
||||
if( parent instanceof ConfigurableNode )
|
||||
{
|
||||
((ConfigurableNode)parent).sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.MutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import module.decode.DecoderType;
|
||||
import settings.SettingsManager;
|
||||
import source.SourceManager;
|
||||
import source.tuner.Tuner;
|
||||
import source.tuner.TunerGroupNode;
|
||||
import source.tuner.TunerNode;
|
||||
import source.tuner.TunerSelectionListener;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
|
||||
public class ConfigurationControllerModel extends DefaultTreeModel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JTree mTree;
|
||||
|
||||
private ArrayList<TunerSelectionListener> mTunerSelectionListeners =
|
||||
new ArrayList<TunerSelectionListener>();
|
||||
|
||||
private TunerGroupNode mTunerGroupNode;
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
/**
|
||||
* Implements a merged system controller and (tree) model. The user will
|
||||
* primarily interact with the system nodes via the tree view, so from a
|
||||
* design perspective, the model and the control are necessarily merged to
|
||||
* work well with the JTree as the system view.
|
||||
*/
|
||||
public ConfigurationControllerModel( ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
SettingsManager settingsManager,
|
||||
SourceManager sourceManager )
|
||||
{
|
||||
super( new BaseNode( null ) );
|
||||
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mSourceManager = sourceManager;
|
||||
|
||||
/**
|
||||
* Give the root node a reference to this model, so that all nodes can
|
||||
* invoke add/delete operations on the tree via context menu
|
||||
*/
|
||||
((BaseNode)getRoot()).setModel( this );
|
||||
}
|
||||
|
||||
public JTree getTree()
|
||||
{
|
||||
return mTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* init() gets invoked manually/externally, after all of the references
|
||||
* are established in the constructor
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
/**
|
||||
* Add the tuner group node
|
||||
*/
|
||||
mTunerGroupNode = new TunerGroupNode();
|
||||
insertNodeInto( mTunerGroupNode, (MutableTreeNode)root, 0 );
|
||||
addTuners( mTunerGroupNode );
|
||||
|
||||
/**
|
||||
* Add the recording group node
|
||||
*/
|
||||
// mRecordingGroupNode = new RecordingGroupNode();
|
||||
// insertNodeInto( mRecordingGroupNode, (MutableTreeNode)root, 1 );
|
||||
// mRecordingGroupNode.loadRecordings();
|
||||
|
||||
// /**
|
||||
// * Add the playlist node
|
||||
// */
|
||||
// mPlaylistNode = new PlaylistNode( mChannelModel, mChannelProcessingManager,
|
||||
// mPlaylistManager, mSettingsManager, mSourceManager );
|
||||
// insertNodeInto( mPlaylistNode, (MutableTreeNode)root, 1 );
|
||||
// mPlaylistNode.loadPlaylist();
|
||||
}
|
||||
|
||||
public void showNode( DefaultMutableTreeNode node )
|
||||
{
|
||||
if( mTree != null && node != null )
|
||||
{
|
||||
mTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void setTree( JTree tree )
|
||||
{
|
||||
mTree = tree;
|
||||
}
|
||||
|
||||
private void addTuners( TunerGroupNode parent )
|
||||
{
|
||||
List<Tuner> tuners = mSourceManager.getTunerManager().getTuners();
|
||||
|
||||
for( Tuner tuner: tuners )
|
||||
{
|
||||
TunerNode child = new TunerNode( mChannelModel,
|
||||
mChannelProcessingManager, mSettingsManager, tuner );
|
||||
|
||||
insertNodeInto( child, parent, parent.getChildCount() );
|
||||
|
||||
parent.sort();
|
||||
|
||||
show( child );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add a new default system, site and channel to
|
||||
* the tree
|
||||
*/
|
||||
public void createChannel( long frequency, DecoderType decoder )
|
||||
{
|
||||
throw new UnsupportedOperationException( "This has to be updated to new channel model format" );
|
||||
// System system = new System();
|
||||
//
|
||||
// Site site = new Site();
|
||||
// system.addSite( site );
|
||||
//
|
||||
// Channel channel = new Channel();
|
||||
// channel.setDecodeConfiguration(
|
||||
// DecodeConfigFactory.getDecodeConfiguration( decoder ) );
|
||||
// SourceConfigTuner sourceConfig = new SourceConfigTuner();
|
||||
// sourceConfig.setFrequency( frequency );
|
||||
// channel.setSourceConfiguration( sourceConfig );
|
||||
// mResourceManager.getChannelManager().channelChanged( new ChannelEvent( channel, Event.NOTIFICATION_ADD ) );
|
||||
// channel.setEnabled( true, true );
|
||||
// site.addChannel( channel );
|
||||
//
|
||||
// mPlaylistNode.getPlaylist().getSystemList().addSystem( system );
|
||||
//
|
||||
// SystemNode systemNode = new SystemNode( system );
|
||||
// SystemListNode systemListNode = mPlaylistNode.getSystemListNode();
|
||||
// addNode( systemNode, systemListNode, systemListNode.getChildCount() );
|
||||
// systemNode.init();
|
||||
//
|
||||
// systemNode.save();
|
||||
}
|
||||
|
||||
public void addNode( BaseNode child, BaseNode parent, int index )
|
||||
{
|
||||
insertNodeInto( child, parent, index );
|
||||
show( child );
|
||||
}
|
||||
|
||||
public void deleteNode( BaseNode node )
|
||||
{
|
||||
node.delete();
|
||||
}
|
||||
|
||||
private void show( BaseNode node )
|
||||
{
|
||||
if( mTree != null )
|
||||
{
|
||||
mTree.scrollPathToVisible( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener( TunerSelectionListener listener )
|
||||
{
|
||||
mTunerSelectionListeners.add( listener );
|
||||
}
|
||||
|
||||
public void removeListener( TunerSelectionListener listener )
|
||||
{
|
||||
mTunerSelectionListeners.remove( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies registered listeners that the tuner has been selected
|
||||
*/
|
||||
public void fireTunerSelectedEvent( Tuner tuner )
|
||||
{
|
||||
Iterator<TunerSelectionListener> it =
|
||||
mTunerSelectionListeners.iterator();
|
||||
|
||||
while( it.hasNext() )
|
||||
{
|
||||
it.next().tunerSelected( tuner );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a tuner selection event for the first tuner listed in the tree.
|
||||
* This is mainly used on application startup to show the spectral display
|
||||
* of the first tuner in the spectrum panel.
|
||||
*/
|
||||
public void fireFirstTunerSelected()
|
||||
{
|
||||
if( mTunerGroupNode.getChildCount() > 0 )
|
||||
{
|
||||
TunerNode node = (TunerNode)mTunerGroupNode.getChildAt( 0 );
|
||||
|
||||
fireTunerSelectedEvent( node.getTuner() );
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Channel> getCurrentChannelConfigs()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private ArrayList<Channel> getChannelConfigs( DefaultMutableTreeNode parent )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
public class ConfigurationTreePanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected JTree mSystemTree;
|
||||
protected ConfigurationControllerModel mTreeModel;
|
||||
|
||||
public ConfigurationTreePanel( ConfigurationControllerModel model )
|
||||
{
|
||||
mTreeModel = model;
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
|
||||
|
||||
mSystemTree = new JTree( mTreeModel );
|
||||
mSystemTree.getSelectionModel().setSelectionMode(
|
||||
TreeSelectionModel.SINGLE_TREE_SELECTION );
|
||||
mSystemTree.setShowsRootHandles( true );
|
||||
mSystemTree.addMouseListener( new MouseHandler() );
|
||||
mSystemTree.setCellRenderer( new ControllerTreeCellRenderer() );
|
||||
|
||||
//Give the model a reference to the tree, so that it can force newly
|
||||
//added nodes to be displayed
|
||||
mTreeModel.setTree( mSystemTree );
|
||||
|
||||
JScrollPane treeScroll = new JScrollPane( mSystemTree );
|
||||
add( treeScroll, "cell 0 0,span,grow" );
|
||||
}
|
||||
|
||||
public void addTreeSelectionListener( TreeSelectionListener listener )
|
||||
{
|
||||
mSystemTree.addTreeSelectionListener( listener );
|
||||
}
|
||||
|
||||
public class MouseHandler implements MouseListener
|
||||
{
|
||||
public MouseHandler()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent event )
|
||||
{
|
||||
if( SwingUtilities.isRightMouseButton( event ) )
|
||||
{
|
||||
int row = mSystemTree.getRowForLocation( event.getX(),
|
||||
event.getY() );
|
||||
|
||||
if( row != -1 )
|
||||
{
|
||||
mSystemTree.setSelectionRow( row );
|
||||
|
||||
Object selectedNode =
|
||||
mSystemTree.getLastSelectedPathComponent();
|
||||
|
||||
if( selectedNode instanceof BaseNode )
|
||||
{
|
||||
JPopupMenu contextMenu =
|
||||
((BaseNode)selectedNode).getContextMenu();
|
||||
|
||||
if( contextMenu != null )
|
||||
{
|
||||
contextMenu.show( mSystemTree,
|
||||
event.getX(),
|
||||
event.getY() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ){}
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ){}
|
||||
@Override
|
||||
public void mouseEntered( MouseEvent e ){}
|
||||
@Override
|
||||
public void mouseExited( MouseEvent e ){}
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,8 @@ import module.decode.state.ChannelList;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
import source.SourceManager;
|
||||
import source.TunerViewPanel;
|
||||
import source.TunerModel;
|
||||
import source.tuner.TunerModel;
|
||||
import source.tuner.TunerViewPanel;
|
||||
import spectrum.ChannelSpectrumPanel;
|
||||
import alias.AliasController;
|
||||
import alias.AliasModel;
|
||||
@@ -55,36 +55,21 @@ public class ControllerPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChannelList mChannelStateList;
|
||||
|
||||
private TunerViewPanel mTunerManagerPanel;
|
||||
|
||||
private CallEventPanel mCallEventPanel;
|
||||
|
||||
private MessageActivityPanel mMessageActivityPanel;
|
||||
|
||||
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
||||
|
||||
private AliasController mAliasController;
|
||||
|
||||
private ChannelController mChannelController;
|
||||
|
||||
private JideTabbedPane mTabbedPane;
|
||||
|
||||
// protected ConfigurationTreePanel mSystemControlViewPanel;
|
||||
// protected OldConfigurationEditor mConfigurationEditor;
|
||||
// protected JideSplitPane mSystemControlSplitPane;
|
||||
|
||||
protected JTable mChannelActivityTable = new JTable();
|
||||
private AudioPanel mAudioPanel;
|
||||
private MapPanel mMapPanel;
|
||||
|
||||
private CallEventPanel mCallEventPanel;
|
||||
private ChannelController mChannelController;
|
||||
private ChannelList mChannelStateList;
|
||||
private ChannelModel mChannelModel;
|
||||
private ConfigurationControllerModel mController;
|
||||
protected SettingsManager mSettingsManager;
|
||||
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
||||
private MapPanel mMapPanel;
|
||||
private MessageActivityPanel mMessageActivityPanel;
|
||||
private TunerViewPanel mTunerManagerPanel;
|
||||
|
||||
private JideTabbedPane mTabbedPane;
|
||||
protected JTable mChannelActivityTable = new JTable();
|
||||
|
||||
public ControllerPanel( AudioManager audioManager,
|
||||
ConfigurationControllerModel controller,
|
||||
AliasModel aliasModel,
|
||||
ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
@@ -95,29 +80,27 @@ public class ControllerPanel extends JPanel
|
||||
TunerModel tunerModel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mController = controller;
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
mAudioPanel = new AudioPanel( mSettingsManager, sourceManager, audioManager );
|
||||
mAudioPanel = new AudioPanel( settingsManager, sourceManager, audioManager );
|
||||
|
||||
mMapPanel = new MapPanel( mapService, mSettingsManager );
|
||||
mMapPanel = new MapPanel( mapService, settingsManager );
|
||||
|
||||
mMessageActivityPanel = new MessageActivityPanel( channelProcessingManager );
|
||||
|
||||
mCallEventPanel = new CallEventPanel( mSettingsManager, channelProcessingManager );
|
||||
mCallEventPanel = new CallEventPanel( settingsManager, channelProcessingManager );
|
||||
|
||||
mChannelSpectrumPanel = new ChannelSpectrumPanel( mSettingsManager,
|
||||
mChannelSpectrumPanel = new ChannelSpectrumPanel( settingsManager,
|
||||
channelProcessingManager );
|
||||
|
||||
mChannelStateList = new ChannelList( channelModel, channelProcessingManager,
|
||||
mSettingsManager );
|
||||
settingsManager );
|
||||
|
||||
mChannelController = new ChannelController( channelModel, channelMapModel,
|
||||
sourceManager, aliasModel );
|
||||
|
||||
mAliasController = new AliasController( aliasModel, mSettingsManager );
|
||||
mAliasController = new AliasController( aliasModel, settingsManager );
|
||||
|
||||
mTunerManagerPanel = new TunerViewPanel( tunerModel, mSettingsManager );
|
||||
mTunerManagerPanel = new TunerViewPanel( tunerModel );
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -128,17 +111,6 @@ public class ControllerPanel extends JPanel
|
||||
"[grow,fill]",
|
||||
"[grow,fill]") );
|
||||
|
||||
// //System Configuration View and Editor
|
||||
// mConfigurationEditor = new OldConfigurationEditor();
|
||||
//
|
||||
// mSystemControlViewPanel = new ConfigurationTreePanel( mController );
|
||||
// mSystemControlViewPanel.addTreeSelectionListener( mConfigurationEditor );
|
||||
|
||||
// mSystemControlSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
// mSystemControlSplitPane.setDividerSize( 5 );
|
||||
// mSystemControlSplitPane.add( mSystemControlViewPanel );
|
||||
// mSystemControlSplitPane.add( mConfigurationEditor );
|
||||
|
||||
//Tabbed View - configuration, calls, messages, map
|
||||
mTabbedPane = new JideTabbedPane();
|
||||
mTabbedPane.setFont( this.getFont() );
|
||||
@@ -146,7 +118,6 @@ public class ControllerPanel extends JPanel
|
||||
mTabbedPane.addTab( "Tuners", mTunerManagerPanel );
|
||||
mTabbedPane.addTab( "Channels", mChannelController );
|
||||
mTabbedPane.addTab( "Aliases", mAliasController );
|
||||
// mTabbedPane.addTab( "Configuration", mSystemControlSplitPane );
|
||||
mTabbedPane.addTab( "Channel Spectrum", mChannelSpectrumPanel );
|
||||
mTabbedPane.addTab( "Events", mCallEventPanel );
|
||||
mTabbedPane.addTab( "Messages", mMessageActivityPanel );
|
||||
@@ -191,6 +162,10 @@ public class ControllerPanel extends JPanel
|
||||
audioChannelListSplit.setDividerSize( 5 );
|
||||
audioChannelListSplit.add( mAudioPanel );
|
||||
audioChannelListSplit.add( channelStateListScroll );
|
||||
|
||||
//Set preferred size to influence the split between these panels
|
||||
audioChannelListSplit.setPreferredSize( new Dimension( 400, 500 ) );
|
||||
mTabbedPane.setPreferredSize( new Dimension( 880, 500 ) );
|
||||
|
||||
JideSplitPane channelSplit = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
channelSplit.setDividerSize( 5 );
|
||||
@@ -199,9 +174,4 @@ public class ControllerPanel extends JPanel
|
||||
|
||||
add( channelSplit );
|
||||
}
|
||||
|
||||
public ConfigurationControllerModel getController()
|
||||
{
|
||||
return mController;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
|
||||
public class ControllerTreeCellRenderer extends DefaultTreeCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int MAX_ICON_HEIGHT = 16;
|
||||
private HashMap<String,ImageIcon> mIcons = new HashMap<String,ImageIcon>();
|
||||
|
||||
public ControllerTreeCellRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent( JTree tree,
|
||||
Object value, boolean selected, boolean expanded, boolean isLeaf,
|
||||
int row, boolean focused )
|
||||
{
|
||||
Component c = super.getTreeCellRendererComponent( tree, value, selected,
|
||||
expanded, isLeaf, row, focused );
|
||||
|
||||
if( value instanceof BaseNode )
|
||||
{
|
||||
BaseNode node = (BaseNode)value;
|
||||
|
||||
ImageIcon icon = getIcon( node );
|
||||
|
||||
setIcon( icon );
|
||||
|
||||
Color background = node.getBackgroundColor();
|
||||
|
||||
if( background != null )
|
||||
{
|
||||
setBackground( background );
|
||||
setOpaque( true );
|
||||
|
||||
if( selected )
|
||||
{
|
||||
if( background == Color.CYAN )
|
||||
{
|
||||
setForeground( Color.ORANGE );
|
||||
}
|
||||
else if( background == Color.GREEN )
|
||||
{
|
||||
setForeground( Color.MAGENTA );
|
||||
}
|
||||
else if( background == Color.RED )
|
||||
{
|
||||
setForeground( Color.YELLOW );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setOpaque( false );
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
private ImageIcon getIcon( BaseNode node )
|
||||
{
|
||||
ImageIcon icon = null;
|
||||
|
||||
String filepath = node.getIconPath();
|
||||
|
||||
if( filepath != null )
|
||||
{
|
||||
if( mIcons.containsKey( filepath ) )
|
||||
{
|
||||
icon = mIcons.get( filepath );
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = new ImageIcon( filepath );
|
||||
|
||||
if( icon.getIconHeight() > MAX_ICON_HEIGHT )
|
||||
{
|
||||
Image image = icon.getImage();
|
||||
|
||||
double scale = (double)icon.getIconHeight() / (double)MAX_ICON_HEIGHT;
|
||||
|
||||
int scaledWidth = (int)( (double)icon.getIconWidth() / scale );
|
||||
|
||||
Image scaledImage = image.getScaledInstance( scaledWidth,
|
||||
MAX_ICON_HEIGHT, java.awt.Image.SCALE_SMOOTH );
|
||||
|
||||
mIcons.put( filepath, new ImageIcon( scaledImage ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mIcons.put( filepath, icon );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class EmptyEditor extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EmptyEditor()
|
||||
{
|
||||
setLayout( new BorderLayout() );
|
||||
setPreferredSize( new Dimension( 200, (int)getPreferredSize().getHeight() ) );
|
||||
|
||||
String text = "<html>"
|
||||
+ "<p>SDR Trunk</p>"
|
||||
+ "<br>"
|
||||
+ "<p>Use the tree structure to the left to configure SDRTrunk"
|
||||
+ " to use multiple SDR tuners and sound card sources to"
|
||||
+ " decode multiple trunked and digital radio channels.</p>"
|
||||
+ "<br>"
|
||||
+ "<p>Each tree branch can be accessed by clicking on the branch"
|
||||
+ " and a configuration editor will appear here.</p>"
|
||||
+ "<br>"
|
||||
+ "<p>Many of the branches contain context sensitive menus that "
|
||||
+ " you can access by right-clicking on the node.</p>"
|
||||
+ "<br>"
|
||||
+ "<p>To begin, right-click on the 'Systems' branch under 'Playlist'"
|
||||
+ "and create a new 'System'. Right-click the 'System' node to create "
|
||||
+ "a new 'Site'. Right-click on the 'Site' node to create a new Channel.</p>"
|
||||
+ "<br>"
|
||||
+ "<p>In the new channel, select a channel source and decoder "
|
||||
+ "and select event logging and recording options. Check 'Enabled'"
|
||||
+ " and hit the 'Save' button to begin decoding.</p>"
|
||||
+ "</html>";
|
||||
|
||||
add( new JLabel( text ), BorderLayout.NORTH );
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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/>
|
||||
******************************************************************************/
|
||||
package controller;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
|
||||
public class OldConfigurationEditor extends JPanel
|
||||
implements TreeSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Host for configuration editor display panels
|
||||
*/
|
||||
public OldConfigurationEditor()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
setPanel( new EmptyEditor() );
|
||||
}
|
||||
|
||||
public void setPanel( JPanel display )
|
||||
{
|
||||
removeAll();
|
||||
|
||||
setLayout( new BorderLayout() );
|
||||
|
||||
JScrollPane scroll = new JScrollPane( display );
|
||||
|
||||
add( scroll, BorderLayout.CENTER );
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( TreeSelectionEvent e )
|
||||
{
|
||||
JTree tree = (JTree)e.getSource();
|
||||
|
||||
BaseNode node =
|
||||
(BaseNode)tree.getLastSelectedPathComponent();
|
||||
|
||||
if( node != null )
|
||||
{
|
||||
setPanel( node.getEditor() );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user