mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 04:55:55 -05:00
Resolves issue with empty string list models in channel editor
This commit is contained in:
@@ -17,34 +17,29 @@
|
||||
******************************************************************************/
|
||||
package controller.channel;
|
||||
|
||||
import alias.AliasModel;
|
||||
import gui.editor.Editor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.AliasModel;
|
||||
|
||||
public class NameConfigurationEditor extends Editor<Channel> implements DocumentListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger(NameConfigurationEditor.class);
|
||||
|
||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_SYSTEM_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_SITE_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_ALIAS_LIST_MODEL = new DefaultComboBoxModel<>();
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private ChannelModel mChannelModel;
|
||||
@@ -73,7 +68,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
add(new JLabel("Name:"));
|
||||
add(mChannelName);
|
||||
|
||||
mSystemNameCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
mSystemNameCombo = new JComboBox<>(EMPTY_SYSTEM_MODEL);
|
||||
mSystemNameCombo.setEnabled(false);
|
||||
mSystemNameCombo.setEditable(true);
|
||||
mSystemNameCombo.addActionListener(new ActionListener()
|
||||
@@ -96,12 +91,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
|
||||
if(sites.isEmpty())
|
||||
{
|
||||
mSiteNameCombo.setModel( EMPTY_MODEL );
|
||||
mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
sites.toArray( new String[ sites.size() ] ) ) );;
|
||||
sites.toArray(new String[sites.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mSiteNameCombo.setSelectedItem(getItem().getSite());
|
||||
@@ -114,7 +110,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
add(new JLabel("System:"));
|
||||
add(mSystemNameCombo);
|
||||
|
||||
mAliasListCombo = new JComboBox<String>();
|
||||
mAliasListCombo = new JComboBox<String>(EMPTY_ALIAS_LIST_MODEL);
|
||||
mAliasListCombo.setEnabled(false);
|
||||
mAliasListCombo.setEditable(true);
|
||||
mAliasListCombo.addActionListener(new ActionListener()
|
||||
@@ -129,7 +125,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
add(new JLabel("Alias List:"));
|
||||
add(mAliasListCombo);
|
||||
|
||||
mSiteNameCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
mSiteNameCombo = new JComboBox<>(EMPTY_SITE_MODEL);
|
||||
mSiteNameCombo.setEnabled(false);
|
||||
mSiteNameCombo.setEditable(true);
|
||||
mSiteNameCombo.addActionListener(new ActionListener()
|
||||
@@ -203,12 +199,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
|
||||
if(systems.isEmpty())
|
||||
{
|
||||
mSystemNameCombo.setModel( EMPTY_MODEL );
|
||||
mSystemNameCombo.setModel(EMPTY_SYSTEM_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSystemNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
systems.toArray( new String[ systems.size() ] ) ) );;
|
||||
systems.toArray(new String[systems.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mSystemNameCombo.setSelectedItem(channel.getSystem());
|
||||
@@ -217,12 +214,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
|
||||
|
||||
if(sites.isEmpty())
|
||||
{
|
||||
mSiteNameCombo.setModel( EMPTY_MODEL );
|
||||
mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
sites.toArray( new String[ sites.size() ] ) ) );;
|
||||
sites.toArray(new String[sites.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
if(channel.getSite() != null)
|
||||
|
||||
Reference in New Issue
Block a user