mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-10 23:57:25 -05:00
* Updates playlist to fully clean aliases from the alias list when deleted and to perform a delete and re-add on any alias that changes, to ensure that the alias list is kept fully up to date. Removed site id as an alias identifier. Add support for converting ltr-net uid's to talkgroups in playlist updater and updated playlist to version 3 to ensure anyone using current codebase will have their playlists fully updated. Moved MIN, UniqueID and Site ID to the legacy package and updated label descriptions to signify that they are no longer supported.
158 lines
4.4 KiB
Java
158 lines
4.4 KiB
Java
/*******************************************************************************
|
|
* SDR Trunk
|
|
* Copyright (C) 2014-2016 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 io.github.dsheirer.alias;
|
|
|
|
import com.jidesoft.swing.JideTabbedPane;
|
|
import io.github.dsheirer.alias.action.AliasActionEditor;
|
|
import io.github.dsheirer.alias.id.AliasIdentifierEditor;
|
|
import io.github.dsheirer.audio.broadcast.BroadcastModel;
|
|
import io.github.dsheirer.gui.editor.Editor;
|
|
import io.github.dsheirer.icon.IconManager;
|
|
import io.github.dsheirer.sample.Listener;
|
|
import net.miginfocom.swing.MigLayout;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
public class AliasEditor extends Editor<Alias> implements ActionListener, Listener<AliasEvent>
|
|
{
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private static final String DEFAULT_NAME = "select an alias";
|
|
|
|
private AliasModel mAliasModel;
|
|
|
|
private JLabel mAliasLabel;
|
|
private AliasNameEditor mAliasNameEditor;
|
|
private AliasIdentifierEditor mAliasIdentifierEditor;
|
|
private AliasActionEditor mAliasActionEditor;
|
|
|
|
public AliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager )
|
|
{
|
|
mAliasModel = aliasModel;
|
|
mAliasNameEditor = new AliasNameEditor( mAliasModel, iconManager );
|
|
mAliasIdentifierEditor = new AliasIdentifierEditor( aliasModel, broadcastModel );
|
|
mAliasActionEditor = new AliasActionEditor( aliasModel );
|
|
|
|
mAliasModel.addListener( this );
|
|
|
|
init();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setItem( Alias alias )
|
|
{
|
|
super.setItem( alias );
|
|
|
|
if( hasItem() )
|
|
{
|
|
mAliasLabel.setText( getItem().getName() );
|
|
}
|
|
else
|
|
{
|
|
mAliasLabel.setText( DEFAULT_NAME );
|
|
}
|
|
|
|
mAliasNameEditor.setItem( alias );
|
|
mAliasIdentifierEditor.setItem( alias );
|
|
mAliasActionEditor.setItem( alias );
|
|
}
|
|
|
|
private void init()
|
|
{
|
|
setLayout( new MigLayout( "fill,wrap 2", "[grow,fill][grow,fill]",
|
|
"[][][][][][grow,fill]" ) );
|
|
|
|
add( new JLabel( "Alias:" ), "align right" );
|
|
mAliasLabel = new JLabel( DEFAULT_NAME );
|
|
add( mAliasLabel, "align left" );
|
|
|
|
add( new JSeparator( JSeparator.HORIZONTAL ), "span,growx,push" );
|
|
|
|
JideTabbedPane tabs = new JideTabbedPane();
|
|
tabs.setFont( this.getFont() );
|
|
tabs.setForeground( Color.BLACK );
|
|
|
|
tabs.addTab( "Alias", mAliasNameEditor );
|
|
tabs.addTab( "Audio / Identifier", mAliasIdentifierEditor );
|
|
tabs.addTab( "Action", mAliasActionEditor );
|
|
add( tabs, "span,grow" );
|
|
|
|
//Playlist management buttons
|
|
JButton btnSave = new JButton( "Save" );
|
|
btnSave.setToolTipText( "Save alias changes to the playlist" );
|
|
btnSave.addActionListener( AliasEditor.this );
|
|
add( btnSave );
|
|
|
|
JButton btnReset = new JButton( "Reset" );
|
|
btnReset.setToolTipText( "Reset alias changes since last save" );
|
|
btnReset.addActionListener( AliasEditor.this );
|
|
add( btnReset, "wrap" );
|
|
}
|
|
|
|
@Override
|
|
public void receive( AliasEvent event )
|
|
{
|
|
//If this is the currently displayed alias, reload it
|
|
if( hasItem() && getItem() == event.getAlias() )
|
|
{
|
|
switch( event.getEvent() )
|
|
{
|
|
case CHANGE:
|
|
//Alias changed - reset the editor with changed alias
|
|
setItem( event.getAlias() );
|
|
break;
|
|
case DELETE:
|
|
setItem( null );
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void actionPerformed( ActionEvent e )
|
|
{
|
|
if( hasItem() )
|
|
{
|
|
String command = e.getActionCommand();
|
|
|
|
if( command.contentEquals( "Save" ) )
|
|
{
|
|
save();
|
|
}
|
|
else if( command.contentEquals( "Reset" ) )
|
|
{
|
|
reset();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void save()
|
|
{
|
|
mAliasNameEditor.save();
|
|
mAliasIdentifierEditor.save();
|
|
mAliasActionEditor.save();
|
|
}
|
|
}
|