#82 WIP - converted all classes to get icons from IconManager and removed icon management from the SettingsManager

This commit is contained in:
Denny
2017-01-08 21:06:02 -05:00
parent 488dc9da4c
commit b6498d048a
43 changed files with 4809 additions and 5084 deletions

View File

@@ -1,27 +1,28 @@
/*******************************************************************************
* 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/>
* sdrtrunk
* Copyright (C) 2014-2017 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 module.decode.event;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableCellRenderer;
import settings.SettingsManager;
import alias.Alias;
import icon.IconManager;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
/**
* Custom renderer for JTable cells that contain Alias objects. Renders the
@@ -30,45 +31,45 @@ import alias.Alias;
*/
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
{
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private SettingsManager mSettingsManager;
public CallEventAliasCellRenderer( SettingsManager settingsManager )
{
super();
mSettingsManager = settingsManager;
}
public void setValue( Object obj )
{
if( obj != null && obj instanceof Alias )
{
Alias alias = (Alias)obj;
setText( alias.getName() );
ImageIcon icon = getIcon( alias, SettingsManager.DEFAULT_ICON_SIZE );
if( icon != null )
{
setIcon( icon );
}
}
else
{
setText( " " );
setIcon( null );
}
}
private ImageIcon getIcon( Alias alias, int height )
{
if( mSettingsManager != null && alias != null )
{
return mSettingsManager.getImageIcon( alias.getIconName(), height );
}
return null;
}
private IconManager mIconManager;
public CallEventAliasCellRenderer(IconManager iconManager)
{
super();
mIconManager = iconManager;
}
public void setValue(Object obj)
{
if(obj != null && obj instanceof Alias)
{
Alias alias = (Alias) obj;
setText(alias.getName());
ImageIcon icon = getIcon(alias, IconManager.DEFAULT_ICON_SIZE);
if(icon != null)
{
setIcon(icon);
}
}
else
{
setText(" ");
setIcon(null);
}
}
private ImageIcon getIcon(Alias alias, int height)
{
if(mIconManager != null && alias != null)
{
return mIconManager.getIcon(alias.getIconName(), height);
}
return null;
}
}

View File

@@ -1,36 +1,34 @@
/*******************************************************************************
* 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/>
* sdrtrunk
* Copyright (C) 2014-2017 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 module.decode.event;
import java.awt.EventQueue;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import module.ProcessingChain;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import controller.channel.Channel;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEvent.Event;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelProcessingManager;
import icon.IconManager;
import module.ProcessingChain;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
public class CallEventPanel extends JPanel implements ChannelEventListener
{
@@ -41,100 +39,91 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
private CallEventAliasCellRenderer mRenderer;
private ChannelProcessingManager mChannelProcessingManager;
public CallEventPanel( SettingsManager settingsManager,
ChannelProcessingManager channelProcessingManager )
{
mChannelProcessingManager = channelProcessingManager;
setLayout( new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]") );
JTable table = new JTable( new CallEventModel() );
table.setAutoCreateRowSorter( true );
table.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
mRenderer = new CallEventAliasCellRenderer( settingsManager );
table.getColumnModel().getColumn( CallEventModel.FROM_ALIAS )
.setCellRenderer( mRenderer );
table.getColumnModel().getColumn( CallEventModel.TO_ALIAS )
.setCellRenderer( mRenderer );
mEmptyScroller = new JScrollPane( table );
add( mEmptyScroller );
}
@Override
public void channelChanged( final ChannelEvent event )
public CallEventPanel(IconManager iconManager, ChannelProcessingManager channelProcessingManager)
{
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
event.getChannel().isSelected() )
{
if( mDisplayedChannel == null ||
( mDisplayedChannel != null &&
mDisplayedChannel != event.getChannel() ) )
{
ProcessingChain chain = mChannelProcessingManager
.getProcessingChain( event.getChannel() );
if( chain != null )
{
final CallEventModel model = chain.getCallEventModel();
if( model != null )
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
removeAll();
JTable table = new JTable( model );
mChannelProcessingManager = channelProcessingManager;
table.setAutoCreateRowSorter( true );
table.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
table.getColumnModel().getColumn( CallEventModel.FROM_ALIAS )
.setCellRenderer( mRenderer );
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
table.getColumnModel().getColumn( CallEventModel.TO_ALIAS )
.setCellRenderer( mRenderer );
add( new JScrollPane( table ) );
mDisplayedChannel = event.getChannel();
revalidate();
repaint();
}
} );
}
}
}
}
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
event.getEvent() == Event.REQUEST_DISABLE )
{
if( mDisplayedChannel != null &&
mDisplayedChannel == event.getChannel() )
{
mDisplayedChannel = null;
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
removeAll();
add( mEmptyScroller );
JTable table = new JTable(new CallEventModel());
table.setAutoCreateRowSorter(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
revalidate();
repaint();
}
} );
}
}
mRenderer = new CallEventAliasCellRenderer(iconManager);
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
mEmptyScroller = new JScrollPane(table);
add(mEmptyScroller);
}
@Override
public void channelChanged(final ChannelEvent event)
{
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE && event.getChannel().isSelected())
{
if(mDisplayedChannel == null || (mDisplayedChannel != null && mDisplayedChannel != event.getChannel()))
{
ProcessingChain chain = mChannelProcessingManager.getProcessingChain(event.getChannel());
if(chain != null)
{
final CallEventModel model = chain.getCallEventModel();
if(model != null)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
removeAll();
JTable table = new JTable(model);
table.setAutoCreateRowSorter(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS)
.setCellRenderer(mRenderer);
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS)
.setCellRenderer(mRenderer);
add(new JScrollPane(table));
mDisplayedChannel = event.getChannel();
revalidate();
repaint();
}
});
}
}
}
}
else if(event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP || event.getEvent() == Event.REQUEST_DISABLE)
{
if(mDisplayedChannel != null && mDisplayedChannel == event.getChannel())
{
mDisplayedChannel = null;
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
removeAll();
add(mEmptyScroller);
revalidate();
repaint();
}
});
}
}
}
}