Work in progress.

-Removed channel collection panel since panels will only have 1 channel
now
-Resolved issue with channel list and channel selection events
-Fixed some of the classes from the rebase to master branch
This commit is contained in:
denny
2016-02-15 07:10:41 -05:00
parent 1f654b5b9c
commit 2c6e35c739
19 changed files with 244 additions and 330 deletions

View File

@@ -0,0 +1,29 @@
package module.decode.state;
import controller.channel.Channel.ChannelType;
/**
* Allows decoders to change the call timeout setting in the channel state
*/
public class ChangeChannelTimeoutEvent extends DecoderStateEvent
{
private ChannelType mChannelType;
private long mCallTimeout;
public ChangeChannelTimeoutEvent( Object source, ChannelType channelType, long timeout )
{
super( source, Event.CHANGE_CALL_TIMEOUT, State.IDLE );
mChannelType = channelType;
mCallTimeout = timeout;
}
public ChannelType getChannelType()
{
return mChannelType;
}
public long getCallTimeout()
{
return mCallTimeout;
}
}

View File

@@ -1,154 +0,0 @@
package module.decode.state;
import java.awt.Component;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import settings.SettingsManager;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
/**
* Channel Collection assembles a primary channel panel and any related decoder
* state panels, provides contextual access to the channel and supports channel
* selection.
*/
public class ChannelCollectionPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( ChannelCollectionPanel.class );
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private PlaylistManager mPlaylistManager;
private SettingsManager mSettingsManager;
private List<ChannelStatePanel> mChannelPanels = new ArrayList<ChannelStatePanel>();
public ChannelCollectionPanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SettingsManager settingsManager,
Channel channel )
{
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mPlaylistManager = playlistManager;
mSettingsManager = settingsManager;
init( channel );
}
protected void init( Channel channel )
{
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
setOpaque( false );
ChannelStatePanel csp = new ChannelStatePanel( mChannelModel,
mChannelProcessingManager, mPlaylistManager, mSettingsManager, channel );
mChannelPanels.add( csp );
add( csp, "span,grow" );
}
public Channel getChannel()
{
if( mChannelPanels.size() >= 1 )
{
return mChannelPanels.get( 0 ).getChannel();
}
return null;
}
public void dispose()
{
for( ChannelStatePanel panel: mChannelPanels )
{
panel.dispose();
}
mChannelPanels.clear();
mPlaylistManager = null;
mSettingsManager = null;
}
/**
* Toggles the selection state of the channel if it matches the channel
* argument. Otherwise, sets the selection state to false.
*/
public void setSelectedChannel( Channel channel )
{
for( ChannelStatePanel panel: mChannelPanels )
{
if( panel.getChannel() == channel )
{
/* Toggle the selection state */
panel.getChannel().setSelected( !panel.getChannel().isSelected() );
panel.repaint();
}
else
{
if( panel.getChannel().isSelected() )
{
panel.getChannel().setSelected( false );
panel.repaint();
}
}
}
}
/**
* Returns the channel represented by the channel panel at the gui point
* location, to selecting the channel
*
* @param point - current location of the mouse
*
* @return - channel or null
*/
public Channel getChannelAt( Point point )
{
Component c = this.getComponentAt( point );
if( c instanceof ChannelCollectionPanel )
{
return ((ChannelCollectionPanel)c).getChannel();
}
else
{
return getChannel();
}
}
protected SettingsManager getSettingsManager()
{
return mSettingsManager;
}
public JMenu getContextMenu()
{
if( !mChannelPanels.isEmpty() )
{
return mChannelPanels.get( 0 ).getContextMenu();
}
return null;
}
}

View File

@@ -23,6 +23,7 @@ import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JMenu;
import javax.swing.JPanel;
@@ -42,6 +43,7 @@ import settings.ColorSettingResetMenuItem;
import settings.SettingsManager;
import controller.channel.Channel;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEvent.Event;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
@@ -55,8 +57,7 @@ public class ChannelList extends JPanel implements ChannelEventListener
private final static Logger mLog = LoggerFactory.getLogger( ChannelList.class );
private HashMap<Channel,ChannelCollectionPanel> mDisplayedPanels =
new HashMap<Channel,ChannelCollectionPanel>();
private Map<Channel,ChannelPanel> mDisplayedPanels = new HashMap<Channel,ChannelPanel>();
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
@@ -104,12 +105,12 @@ public class ChannelList extends JPanel implements ChannelEventListener
{
if( !mDisplayedPanels.containsKey( channel ) )
{
ChannelCollectionPanel panel = new ChannelCollectionPanel( mChannelModel,
mChannelProcessingManager, mPlaylistManager, mSettingsManager, channel );
ChannelPanel channelPanel = new ChannelPanel( mChannelModel,
mChannelProcessingManager, mPlaylistManager, mSettingsManager, channel );
add( panel, "wrap" );
add( channelPanel, "wrap" );
mDisplayedPanels.put( channel, panel );
mDisplayedPanels.put( channel, channelPanel );
revalidate();
repaint();
@@ -120,7 +121,7 @@ public class ChannelList extends JPanel implements ChannelEventListener
{
if( mDisplayedPanels.containsKey( channel ) )
{
ChannelCollectionPanel panel = mDisplayedPanels.remove( channel );
ChannelPanel panel = mDisplayedPanels.remove( channel );
if( panel != null )
{
@@ -134,15 +135,6 @@ public class ChannelList extends JPanel implements ChannelEventListener
}
}
public void setSelectedChannel( Channel channel )
{
/* Send channel selection to each channel panel */
for( ChannelCollectionPanel panel: mDisplayedPanels.values() )
{
panel.setSelectedChannel( channel );
}
}
public class ListSelectionListener implements MouseListener
{
@Override
@@ -150,18 +142,22 @@ public class ChannelList extends JPanel implements ChannelEventListener
{
Component component = getComponentAt( e.getPoint() );
if( component instanceof ChannelCollectionPanel )
if( component instanceof ChannelPanel )
{
ChannelCollectionPanel panel = (ChannelCollectionPanel)component;
ChannelPanel panel = (ChannelPanel)component;
Point translatedPoint = SwingUtilities
.convertPoint( e.getComponent(), e.getPoint(), panel );
Channel channel = panel.getChannelAt( translatedPoint );
Channel channel = panel.getChannel();
if( e.getButton() == MouseEvent.BUTTON1 )
{
setSelectedChannel( channel );
if( channel.isSelected() )
{
mChannelModel.broadcast( new ChannelEvent( channel, Event.REQUEST_DESELECT ) );
}
else
{
mChannelModel.broadcast( new ChannelEvent( channel, Event.REQUEST_SELECT ) );
}
}
else if( e.getButton() == MouseEvent.BUTTON3 )
{

View File

@@ -15,13 +15,12 @@ import javax.swing.JMenu;
import javax.swing.JPanel;
import module.ProcessingChain;
import module.decode.DecoderFactory;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import controller.channel.Channel;
import controller.channel.ChannelUtils;
import module.decode.DecoderFactory;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import record.RecorderType;
import record.config.RecordConfiguration;
@@ -31,18 +30,22 @@ import settings.ColorSetting.ColorSettingName;
import settings.Setting;
import settings.SettingChangeListener;
import settings.SettingsManager;
import controller.channel.Channel;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEvent.Event;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
import controller.channel.ChannelUtils;
public class ChannelStatePanel extends JPanel
implements Listener<ChangedAttribute>, SettingChangeListener
public class ChannelPanel extends JPanel
implements Listener<ChangedAttribute>,
SettingChangeListener,
ChannelEventListener
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( ChannelStatePanel.class );
private final static Logger mLog = LoggerFactory.getLogger( ChannelPanel.class );
private Font mFontDetails = new Font( Font.MONOSPACED, Font.PLAIN, 12 );
private Font mFontDecoder = new Font( Font.MONOSPACED, Font.PLAIN, 12 );
@@ -88,19 +91,16 @@ public class ChannelStatePanel extends JPanel
*
* Updates color background according to current channel state.
*/
public ChannelStatePanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SettingsManager settingsManager,
Channel channel )
public ChannelPanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SettingsManager settingsManager,
Channel channel )
{
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mPlaylistManager = playlistManager;
mSettingsManager = settingsManager;
mSettingsManager.addListener( this );
mChannel = channel;
ProcessingChain processingChain =
@@ -109,9 +109,7 @@ public class ChannelStatePanel extends JPanel
if( processingChain != null )
{
mChannelState = processingChain.getChannelState();
mChannelState.setChangedAttributeListener( this );
init();
for( DecoderState decoderState: processingChain.getDecoderStates() )
@@ -120,6 +118,10 @@ public class ChannelStatePanel extends JPanel
mDecoderPanels.add( panel );
add( panel, "grow,span" );
}
mChannelState.setChangedAttributeListener( this );
mChannelModel.addListener( this );
mSettingsManager.addListener( this );
}
else
{
@@ -191,6 +193,11 @@ public class ChannelStatePanel extends JPanel
public void dispose()
{
mChannelModel.removeListener( this );
mChannelModel = null;
mChannelProcessingManager = null;
mPlaylistManager = null;
mSettingsManager.removeListener( this );
@@ -426,6 +433,16 @@ public class ChannelStatePanel extends JPanel
public JMenu getContextMenu()
{
return ChannelUtils.getContextMenu( mChannelModel, mChannelProcessingManager,
mPlaylistManager, mChannel, ChannelStatePanel.this );
mPlaylistManager, mChannel, ChannelPanel.this );
}
@Override
public void channelChanged( ChannelEvent event )
{
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
event.getChannel() == mChannel )
{
repaint();
}
}
}