mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#1368 Restructures Message and Event filter framework.
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
/**
|
||||
* AbstractTableModel implementation supporting clearable method options.
|
||||
*/
|
||||
public abstract class ClearableHistoryModel<T> extends AbstractTableModel
|
||||
{
|
||||
public static final int DEFAULT_HISTORY_SIZE = 200;
|
||||
private LinkedList<T> mItems = new LinkedList<>();
|
||||
private int mHistorySize = DEFAULT_HISTORY_SIZE;
|
||||
|
||||
/**
|
||||
* Access an item/row by the model index value.
|
||||
* @param index to retrieve
|
||||
* @return item or null
|
||||
*/
|
||||
public T getItem(int index)
|
||||
{
|
||||
if(index < mItems.size())
|
||||
{
|
||||
return mItems.get(index);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the item to the top of the item list and removes any tail items while the item list size exceeds the
|
||||
* maximum history size for this model.
|
||||
* @param item to add
|
||||
*/
|
||||
public void add(T item)
|
||||
{
|
||||
mItems.addFirst(item);
|
||||
ClearableHistoryModel.this.fireTableRowsInserted(0, 0);
|
||||
while(mItems.size() > mHistorySize)
|
||||
{
|
||||
mItems.removeLast();
|
||||
super.fireTableRowsDeleted(mItems.size() - 1, mItems.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all messages from history
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
EventQueue.invokeLater(() -> {
|
||||
mItems.clear();
|
||||
fireTableDataChanged();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current messages and loads the messages argument
|
||||
*/
|
||||
public void clearAndSet(List<T> items)
|
||||
{
|
||||
EventQueue.invokeLater(() -> {
|
||||
mItems.clear();
|
||||
fireTableDataChanged();
|
||||
for(T item: items)
|
||||
{
|
||||
add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Current history size
|
||||
* @return history size
|
||||
*/
|
||||
public int getHistorySize()
|
||||
{
|
||||
return mHistorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the history size to the default value.
|
||||
*/
|
||||
public void resetHistorySize()
|
||||
{
|
||||
setHistorySize(DEFAULT_HISTORY_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the history size
|
||||
* @param historySize
|
||||
*/
|
||||
public void setHistorySize(int historySize)
|
||||
{
|
||||
mHistorySize = historySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mItems.size();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -32,27 +32,33 @@ public class DecodeEvent implements IDecodeEvent
|
||||
{
|
||||
private long mTimeStart;
|
||||
private long mTimeEnd;
|
||||
private String mEventDescription;
|
||||
private DecodeEventType mDecodeEventType;
|
||||
private IdentifierCollection mIdentifierCollection;
|
||||
private IChannelDescriptor mChannelDescriptor;
|
||||
private String mDetails;
|
||||
private Protocol mProtocol;
|
||||
private Integer mTimeslot;
|
||||
private int mTimeslot = -1;
|
||||
|
||||
public DecodeEvent(long start)
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param decodeEventType is mandatory to support event filtering by event type.
|
||||
* @param start time of the event.
|
||||
*/
|
||||
public DecodeEvent(DecodeEventType decodeEventType, long start)
|
||||
{
|
||||
mDecodeEventType = decodeEventType;
|
||||
mTimeStart = start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decode event builder with the specified start timestamp.
|
||||
* @param decodeEventType for the event
|
||||
* @param timeStart for the event
|
||||
* @return builder
|
||||
*/
|
||||
public static DecodeEventBuilder builder(long timeStart)
|
||||
public static DecodeEventBuilder builder(DecodeEventType decodeEventType, long timeStart)
|
||||
{
|
||||
return new DecodeEventBuilder(timeStart);
|
||||
return new DecodeEventBuilder(decodeEventType, timeStart);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,23 +121,6 @@ public class DecodeEvent implements IDecodeEvent
|
||||
mTimeEnd = mTimeStart + duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event description
|
||||
*/
|
||||
@Override
|
||||
public String getEventDescription()
|
||||
{
|
||||
return mEventDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the event description text
|
||||
*/
|
||||
public void setEventDescription(String description)
|
||||
{
|
||||
mEventDescription = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link DecodeEventType}
|
||||
*/
|
||||
@@ -140,13 +129,6 @@ public class DecodeEvent implements IDecodeEvent
|
||||
return mDecodeEventType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link DecodeEventType}
|
||||
*/
|
||||
public void setEventType(DecodeEventType eventType) {
|
||||
this.mDecodeEventType = eventType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier collection for this event.
|
||||
*/
|
||||
@@ -222,24 +204,24 @@ public class DecodeEvent implements IDecodeEvent
|
||||
* @return timeslot or default value of 0
|
||||
*/
|
||||
@Override
|
||||
public Integer getTimeslot()
|
||||
public int getTimeslot()
|
||||
{
|
||||
return mTimeslot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this event specifies a timeslot
|
||||
* Indicates if this event specifies a timeslot that is not negative
|
||||
*/
|
||||
public boolean hasTimeslot()
|
||||
{
|
||||
return mTimeslot != null;
|
||||
return mTimeslot >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeslot for this event
|
||||
* @param timeslot of the event
|
||||
*/
|
||||
public void setTimeslot(Integer timeslot)
|
||||
public void setTimeslot(int timeslot)
|
||||
{
|
||||
mTimeslot = timeslot;
|
||||
}
|
||||
@@ -249,7 +231,7 @@ public class DecodeEvent implements IDecodeEvent
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(mProtocol);
|
||||
sb.append(" DECODE EVENT: ").append(getEventDescription());
|
||||
sb.append(" DECODE EVENT: ").append(getEventType());
|
||||
sb.append(" DETAILS:").append(getDetails());
|
||||
if(mIdentifierCollection != null)
|
||||
{
|
||||
@@ -267,19 +249,19 @@ public class DecodeEvent implements IDecodeEvent
|
||||
{
|
||||
protected long mTimeStart;
|
||||
protected long mDuration;
|
||||
protected String mEventDescription;
|
||||
protected DecodeEventType mDecodeEventType;
|
||||
protected IdentifierCollection mIdentifierCollection;
|
||||
protected IChannelDescriptor mChannelDescriptor;
|
||||
protected String mDetails;
|
||||
protected Protocol mProtocol = Protocol.UNKNOWN;
|
||||
protected Integer mTimeslot;
|
||||
protected int mTimeslot = -1;
|
||||
|
||||
/**
|
||||
* Constructs a builder instance with the specified start time in milliseconds
|
||||
*/
|
||||
public DecodeEventBuilder(long timeStart)
|
||||
public DecodeEventBuilder(DecodeEventType decodeEventType, long timeStart)
|
||||
{
|
||||
mDecodeEventType = decodeEventType;
|
||||
mTimeStart = timeStart;
|
||||
}
|
||||
|
||||
@@ -313,25 +295,6 @@ public class DecodeEvent implements IDecodeEvent
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Decode Event type for this event.
|
||||
* @param eventType
|
||||
*/
|
||||
public DecodeEventBuilder eventType(DecodeEventType eventType) {
|
||||
mDecodeEventType = eventType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the event description text
|
||||
* @param description of the event
|
||||
*/
|
||||
public DecodeEventBuilder eventDescription(String description)
|
||||
{
|
||||
mEventDescription = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the identifier collection.
|
||||
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
|
||||
@@ -363,7 +326,12 @@ public class DecodeEvent implements IDecodeEvent
|
||||
return this;
|
||||
}
|
||||
|
||||
public DecodeEventBuilder timeslot(Integer timeslot)
|
||||
/**
|
||||
* Sets the timeslot for this event
|
||||
* @param timeslot
|
||||
* @return
|
||||
*/
|
||||
public DecodeEventBuilder timeslot(int timeslot)
|
||||
{
|
||||
mTimeslot = timeslot;
|
||||
return this;
|
||||
@@ -374,12 +342,10 @@ public class DecodeEvent implements IDecodeEvent
|
||||
*/
|
||||
public DecodeEvent build()
|
||||
{
|
||||
DecodeEvent decodeEvent = new DecodeEvent(mTimeStart);
|
||||
DecodeEvent decodeEvent = new DecodeEvent(mDecodeEventType, mTimeStart);
|
||||
decodeEvent.setChannelDescriptor(mChannelDescriptor);
|
||||
decodeEvent.setDetails(mDetails);
|
||||
decodeEvent.setDuration(mDuration);
|
||||
decodeEvent.setEventType(mDecodeEventType);
|
||||
decodeEvent.setEventDescription(mEventDescription);
|
||||
decodeEvent.setIdentifierCollection(mIdentifierCollection);
|
||||
decodeEvent.setProtocol(mProtocol);
|
||||
decodeEvent.setTimeslot(mTimeslot);
|
||||
|
||||
@@ -21,25 +21,20 @@ package io.github.dsheirer.module.decode.event;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.module.decode.event.filter.DecodeEventFilterSet;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.awt.EventQueue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
public class DecodeEventModel extends AbstractTableModel implements Listener<IDecodeEvent>, EventFilterProvider<IDecodeEvent>
|
||||
/**
|
||||
* Decode event table model
|
||||
*/
|
||||
public class DecodeEventModel extends ClearableHistoryModel<IDecodeEvent> implements Listener<IDecodeEvent>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(DecodeEventModel.class);
|
||||
|
||||
public static final int COLUMN_TIME = 0;
|
||||
public static final int COLUMN_DURATION = 1;
|
||||
public static final int COLUMN_EVENT = 2;
|
||||
@@ -50,12 +45,6 @@ public class DecodeEventModel extends AbstractTableModel implements Listener<IDe
|
||||
public static final int COLUMN_CHANNEL = 7;
|
||||
public static final int COLUMN_FREQUENCY = 8;
|
||||
public static final int COLUMN_DETAILS = 9;
|
||||
|
||||
protected int mMaxMessages = 200;
|
||||
|
||||
protected List<IDecodeEvent> mEvents = new ArrayList<>();
|
||||
protected FilterSet<IDecodeEvent> mEventFilterSet = new DecodeEventFilterSet();
|
||||
|
||||
protected String[] mHeaders = new String[]{"Time", "Duration", "Event", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Details"};
|
||||
|
||||
public DecodeEventModel()
|
||||
@@ -70,72 +59,10 @@ public class DecodeEventModel extends AbstractTableModel implements Listener<IDe
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT)
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT || preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_TIME);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
else if(preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_FROM_ID);
|
||||
fireTableCellUpdated(row, COLUMN_TO_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the complete list of events managed by this model.
|
||||
*/
|
||||
public List<IDecodeEvent> getEvents()
|
||||
{
|
||||
return new ArrayList<>(mEvents);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().unregister(this);
|
||||
Iterator<IDecodeEvent> it = mEvents.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
mEvents.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all events from this model and loads the events argument
|
||||
*/
|
||||
public void clearAndSet(List<IDecodeEvent> events)
|
||||
{
|
||||
mEvents.clear();
|
||||
mEvents.addAll(events);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
dispose();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public int getMaxMessageCount()
|
||||
{
|
||||
return mMaxMessages;
|
||||
}
|
||||
|
||||
public void setMaxMessageCount(int count)
|
||||
{
|
||||
mMaxMessages = count;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,49 +73,7 @@ public class DecodeEventModel extends AbstractTableModel implements Listener<IDe
|
||||
*/
|
||||
public void receive(final IDecodeEvent event)
|
||||
{
|
||||
//Disabled until #1368 decode event is fully implemented
|
||||
// if (!mEventFilterSet.passes(event))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(!mEvents.contains(event))
|
||||
{
|
||||
mEvents.add(0, event);
|
||||
fireTableRowsInserted(0, 0);
|
||||
prune();
|
||||
}
|
||||
else
|
||||
{
|
||||
int row = mEvents.indexOf(event);
|
||||
fireTableRowsUpdated(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
private void prune()
|
||||
{
|
||||
while(mEvents.size() > mMaxMessages)
|
||||
{
|
||||
int index = mEvents.size() - 1;
|
||||
mEvents.remove(index);
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterSet<IDecodeEvent> getFilterSet() {
|
||||
return mEventFilterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterSet(FilterSet<IDecodeEvent> filterSet) {
|
||||
this.mEventFilterSet = filterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mEvents.size();
|
||||
EventQueue.invokeLater(() -> add(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,58 +90,55 @@ public class DecodeEventModel extends AbstractTableModel implements Listener<IDe
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
synchronized(mEvents)
|
||||
IDecodeEvent event = getItem(rowIndex);
|
||||
|
||||
if(event != null)
|
||||
{
|
||||
IDecodeEvent event = mEvents.get(rowIndex);
|
||||
|
||||
if(event != null)
|
||||
switch(columnIndex)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_TIME:
|
||||
return event.getTimeStart();
|
||||
case COLUMN_DURATION:
|
||||
return event.getDuration();
|
||||
case COLUMN_EVENT:
|
||||
return event.getEventDescription();
|
||||
case COLUMN_FROM_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_FROM_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_CHANNEL:
|
||||
IChannelDescriptor channelDescriptor = event.getChannelDescriptor();
|
||||
case COLUMN_TIME:
|
||||
return event.getTimeStart();
|
||||
case COLUMN_DURATION:
|
||||
return event.getDuration();
|
||||
case COLUMN_EVENT:
|
||||
return event.getEventType().getLabel();
|
||||
case COLUMN_FROM_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_FROM_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_CHANNEL:
|
||||
IChannelDescriptor channelDescriptor = event.getChannelDescriptor();
|
||||
|
||||
if(channelDescriptor != null)
|
||||
if(channelDescriptor != null)
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return channelDescriptor.toString() + " TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return channelDescriptor.toString();
|
||||
}
|
||||
return channelDescriptor + " TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return "TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return channelDescriptor.toString();
|
||||
}
|
||||
case COLUMN_FREQUENCY:
|
||||
return event.getChannelDescriptor();
|
||||
case COLUMN_DETAILS:
|
||||
return event.getDetails();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return "TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
case COLUMN_FREQUENCY:
|
||||
return event.getChannelDescriptor();
|
||||
case COLUMN_DETAILS:
|
||||
return event.getDetails();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -25,7 +25,6 @@ import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.AllPassFilter;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
@@ -33,10 +32,7 @@ import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearHandler;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.module.decode.event.filter.DecodeEventFilterSet;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
@@ -58,7 +54,10 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.RowFilter;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain>
|
||||
{
|
||||
@@ -75,7 +74,10 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
|
||||
private AliasModel mAliasModel;
|
||||
private UserPreferences mUserPreferences;
|
||||
private TimestampCellRenderer mTimestampCellRenderer;
|
||||
private EventManagementPanel mEventManagementPanel;
|
||||
private FilterSet<IDecodeEvent> mFilterSet = new DecodeEventFilterSet();
|
||||
private TableRowSorter<TableModel> mTableRowSorter;
|
||||
private HistoryManagementPanel<IDecodeEvent> mHistoryManagementPanel;
|
||||
|
||||
|
||||
/**
|
||||
* View for call event table
|
||||
@@ -91,17 +93,20 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
|
||||
mUserPreferences = userPreferences;
|
||||
mTimestampCellRenderer = new TimestampCellRenderer();
|
||||
mTable = new JTable(mEventModel);
|
||||
mTable.setAutoCreateRowSorter(true);
|
||||
mTableRowSorter = new TableRowSorter<>(mEventModel);
|
||||
mTableRowSorter.setRowFilter(new EventRowFilter());
|
||||
mTable.setRowSorter(mTableRowSorter);
|
||||
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
mEventManagementPanel = new EventManagementPanel();
|
||||
mTableColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTable, TABLE_PREFERENCE_KEY);
|
||||
updateCellRenderers();
|
||||
|
||||
//Disabled until #1368 decode event is fully implemented
|
||||
// add(mEventManagementPanel, "span,growx");
|
||||
|
||||
mHistoryManagementPanel = new HistoryManagementPanel<>(mEventModel, "Event Filter Editor");
|
||||
mHistoryManagementPanel.updateFilterSet(mFilterSet);
|
||||
add(mHistoryManagementPanel, "span,growx");
|
||||
mEmptyScroller = new JScrollPane(mTable);
|
||||
add(mEmptyScroller);
|
||||
|
||||
//Register filter change listener to refresh the table any time the event filters are changed.
|
||||
mFilterSet.register(() -> mEventModel.fireTableDataChanged());
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
@@ -124,22 +129,14 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
|
||||
|
||||
private void updateCellRenderers()
|
||||
{
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME)
|
||||
.setCellRenderer(mTimestampCellRenderer);
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION)
|
||||
.setCellRenderer(new DurationCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL)
|
||||
.setCellRenderer(new ChannelDescriptorCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME).setCellRenderer(mTimestampCellRenderer);
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION).setCellRenderer(new DurationCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID).setCellRenderer(new IdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS).setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID).setCellRenderer(new IdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS).setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL).setCellRenderer(new ChannelDescriptorCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY).setCellRenderer(new FrequencyCellRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,76 +153,17 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
|
||||
mCurrentEventHistory = processingChain.getDecodeEventHistory();
|
||||
mEventModel.clearAndSet(mCurrentEventHistory.getItems());
|
||||
processingChain.getDecodeEventHistory().addListener(mEventModel);
|
||||
mEventManagementPanel.enableButtons();
|
||||
mHistoryManagementPanel.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentEventHistory = null;
|
||||
mEventModel.clearAndSet(Collections.emptyList());
|
||||
mEventManagementPanel.disableButtons();
|
||||
mHistoryManagementPanel.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class EventManagementPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private EventFilterButton<IDecodeEvent> mFilterButton;
|
||||
private EventClearButton mEventClearButton;
|
||||
|
||||
public EventManagementPanel()
|
||||
{
|
||||
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
||||
|
||||
initializeFilterButton();
|
||||
initializeClearButton();
|
||||
disableButtons();
|
||||
|
||||
add(mFilterButton);
|
||||
add(mEventClearButton);
|
||||
}
|
||||
|
||||
public void enableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(true);
|
||||
mEventClearButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(false);
|
||||
mEventClearButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void initializeFilterButton()
|
||||
{
|
||||
EventFilterProvider<IDecodeEvent> filterProvider = (EventFilterProvider<IDecodeEvent>) mTable.getModel();
|
||||
FilterSet<IDecodeEvent> filterSet = new FilterSet<>(new AllPassFilter<>());
|
||||
if (filterProvider != null) {
|
||||
filterSet = filterProvider.getFilterSet();
|
||||
}
|
||||
mFilterButton = new EventFilterButton<>("Message Filter Editor", filterSet);
|
||||
}
|
||||
|
||||
private void initializeClearButton() {
|
||||
mEventClearButton = new EventClearButton(
|
||||
((DecodeEventModel) mTable.getModel()).getMaxMessageCount()
|
||||
);
|
||||
mEventClearButton.setEventClearHandler(new EventClearHandler() {
|
||||
@Override
|
||||
public void onHistoryLimitChanged(int newHistoryLimit) {
|
||||
((DecodeEventModel) mTable.getModel()).setMaxMessageCount(newHistoryLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClearHistoryClicked() {
|
||||
((DecodeEventModel) mTable.getModel()).clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom cell renderer for displaying identifiers from an identifier collection
|
||||
*/
|
||||
@@ -479,4 +417,26 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Row filter for decode events
|
||||
*/
|
||||
public class EventRowFilter extends RowFilter<TableModel, Integer>
|
||||
{
|
||||
@Override
|
||||
public boolean include(Entry<? extends TableModel, ? extends Integer> entry)
|
||||
{
|
||||
if(entry.getModel() instanceof DecodeEventModel model)
|
||||
{
|
||||
IDecodeEvent event = model.getItem(entry.getIdentifier());
|
||||
|
||||
if(event != null)
|
||||
{
|
||||
return mFilterSet.canProcess(event) && mFilterSet.passes(event);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,17 @@
|
||||
*
|
||||
* 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.module.decode.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Enumeration of event types for decoded events.
|
||||
*/
|
||||
public enum DecodeEventType
|
||||
{
|
||||
AFFILIATE("Affiliate"),
|
||||
@@ -43,6 +49,7 @@ public enum DecodeEventType
|
||||
CALL_UNIT_TO_UNIT_ENCRYPTED("Encrypted Unit To Unit Call"),
|
||||
CALL_NO_TUNER("Call - No Tuner"),
|
||||
CALL_TIMEOUT("Call Timeout"),
|
||||
CELLOCATOR("Cellocator"),
|
||||
COMMAND("Command"),
|
||||
DATA_CALL("Data Call"),
|
||||
DATA_CALL_ENCRYPTED("Encrypted Data Call"),
|
||||
@@ -55,6 +62,7 @@ public enum DecodeEventType
|
||||
ID_ANI("ANI"),
|
||||
ID_UNIQUE("Unique ID"),
|
||||
IP_PACKET("IP Packet"),
|
||||
LRRP("Motorola LRRP"),
|
||||
NOTIFICATION("Notification"),
|
||||
PAGE("Page"),
|
||||
QUERY("Query"),
|
||||
@@ -74,16 +82,82 @@ public enum DecodeEventType
|
||||
|
||||
private String mLabel;
|
||||
|
||||
/**
|
||||
* Encrypted voice call event types for filtering
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> VOICE_CALLS_ENCRYPTED = EnumSet.of(DecodeEventType.CALL_ENCRYPTED,
|
||||
DecodeEventType.CALL_GROUP_ENCRYPTED, DecodeEventType.CALL_PATCH_GROUP_ENCRYPTED,
|
||||
DecodeEventType.CALL_INTERCONNECT_ENCRYPTED, DecodeEventType.CALL_UNIT_TO_UNIT_ENCRYPTED);
|
||||
|
||||
/**
|
||||
* Voice call event types for filtering
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> VOICE_CALLS = EnumSet.of(DecodeEventType.CALL_GROUP,
|
||||
DecodeEventType.CALL_PATCH_GROUP, DecodeEventType.CALL_ALERT, DecodeEventType.CALL_DETECT,
|
||||
DecodeEventType.CALL_DO_NOT_MONITOR, DecodeEventType.CALL_END, DecodeEventType.CALL_INTERCONNECT,
|
||||
DecodeEventType.CALL_UNIQUE_ID, DecodeEventType.CALL_UNIT_TO_UNIT, DecodeEventType.CALL_NO_TUNER,
|
||||
DecodeEventType.CALL_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Command event types for filtering
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> COMMANDS = EnumSet.of(DecodeEventType.ANNOUNCEMENT,
|
||||
DecodeEventType.STATION_ID, DecodeEventType.ACKNOWLEDGE, DecodeEventType.PAGE, DecodeEventType.QUERY,
|
||||
DecodeEventType.RADIO_CHECK, DecodeEventType.STATUS, DecodeEventType.COMMAND, DecodeEventType.EMERGENCY,
|
||||
DecodeEventType.NOTIFICATION, DecodeEventType.FUNCTION);
|
||||
|
||||
/**
|
||||
* Data call event types for filtering
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> DATA_CALLS = EnumSet.of(DecodeEventType.DATA_CALL,
|
||||
DecodeEventType.DATA_CALL_ENCRYPTED, DecodeEventType.DATA_PACKET, DecodeEventType.GPS,
|
||||
DecodeEventType.IP_PACKET, DecodeEventType.UDP_PACKET, DecodeEventType.SDM, DecodeEventType.ID_ANI,
|
||||
DecodeEventType.ID_UNIQUE);
|
||||
|
||||
/**
|
||||
* Registration event types for filtering
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> REGISTRATION = EnumSet.of(DecodeEventType.AFFILIATE,
|
||||
DecodeEventType.AUTOMATIC_REGISTRATION_SERVICE, DecodeEventType.REGISTER, DecodeEventType.REGISTER_ESN,
|
||||
DecodeEventType.DEREGISTER, DecodeEventType.REQUEST, DecodeEventType.RESPONSE, DecodeEventType.RESPONSE_PACKET);
|
||||
|
||||
/**
|
||||
* All other event types of this enumeration that are not included in the groupings above.
|
||||
*/
|
||||
public static final EnumSet<DecodeEventType> OTHERS = EnumSet.copyOf(Arrays.stream(DecodeEventType.values())
|
||||
.filter(decodeEventType -> !decodeEventType.isGrouped()).toList());
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param label for the element
|
||||
*/
|
||||
DecodeEventType(String label)
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the enumeration element is contained in one of the enumset groupings above.
|
||||
* @return true if the element is grouped.
|
||||
*/
|
||||
public boolean isGrouped()
|
||||
{
|
||||
return VOICE_CALLS.contains(this) || VOICE_CALLS_ENCRYPTED.contains(this) || COMMANDS.contains(this) ||
|
||||
DATA_CALLS.contains(this) || REGISTRATION.contains(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Label or pretty value for the element
|
||||
* @return label
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses label as the default string value.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return mLabel;
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event;
|
||||
|
||||
import io.github.dsheirer.filter.FilterEditor;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* History management panel with controls for managing item histories.
|
||||
*/
|
||||
public class HistoryManagementPanel<T> extends JPanel
|
||||
{
|
||||
private ClearableHistoryModel mModel;
|
||||
private FilterSet<T> mFilterSet;
|
||||
private FilterEditor<T> mFilterEditor;
|
||||
private JButton mClearButton;
|
||||
private JButton mFilterButton;
|
||||
private JSlider mHistorySlider;
|
||||
private JLabel mHistoryTitleLabel;
|
||||
private JLabel mHistoryValueLabel;
|
||||
private String mFilterEditorTitle;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param model to manage
|
||||
*/
|
||||
public HistoryManagementPanel(ClearableHistoryModel model, String filterEditorTitle)
|
||||
{
|
||||
mModel = model;
|
||||
mFilterEditorTitle = filterEditorTitle;
|
||||
setLayout(new MigLayout("insets 6 1 5 5", "[]5[]10[]5[]5[][grow]", ""));
|
||||
add(getFilterButton());
|
||||
add(getClearButton());
|
||||
add(getHistoryTitleLabel());
|
||||
add(getHistorySlider());
|
||||
add(getHistoryValueLabel());
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the filter set
|
||||
* @param filterSet to use
|
||||
*/
|
||||
public void updateFilterSet(FilterSet<T> filterSet)
|
||||
{
|
||||
mFilterSet = filterSet;
|
||||
|
||||
if(mFilterEditor != null)
|
||||
{
|
||||
getFilterEditor().updateFilterSet(filterSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the panel method to also set the enabled state for the child controls.
|
||||
* @param enabled true if this component should be enabled, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
super.setEnabled(enabled);
|
||||
getClearButton().setEnabled(enabled);
|
||||
getFilterButton().setEnabled(enabled);
|
||||
getHistoryValueLabel().setEnabled(enabled);
|
||||
getHistoryTitleLabel().setEnabled(enabled);
|
||||
getHistorySlider().setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter editor
|
||||
* @return editor lazily constructed
|
||||
*/
|
||||
private FilterEditor<T> getFilterEditor()
|
||||
{
|
||||
if(mFilterEditor == null)
|
||||
{
|
||||
mFilterEditor = new FilterEditor<>(mFilterEditorTitle, getFilterButton(), mFilterSet);
|
||||
}
|
||||
|
||||
return mFilterEditor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter button for accessing the filter editor
|
||||
* @return filter button
|
||||
*/
|
||||
private JButton getFilterButton()
|
||||
{
|
||||
if(mFilterButton == null)
|
||||
{
|
||||
mFilterButton = new JButton("Filters");
|
||||
mFilterButton.setToolTipText("Edit filters");
|
||||
mFilterButton.addActionListener(arg0 -> EventQueue.invokeLater(() -> getFilterEditor().setVisible(true)));
|
||||
}
|
||||
|
||||
return mFilterButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear button
|
||||
* @return clear button
|
||||
*/
|
||||
private JButton getClearButton()
|
||||
{
|
||||
if(mClearButton == null)
|
||||
{
|
||||
mClearButton = new JButton("Clear");
|
||||
mClearButton.addActionListener(e -> mModel.clear());
|
||||
mClearButton.setToolTipText("Clears the history");
|
||||
}
|
||||
|
||||
return mClearButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* History value label.
|
||||
* @return label
|
||||
*/
|
||||
private JLabel getHistoryValueLabel()
|
||||
{
|
||||
if(mHistoryValueLabel == null)
|
||||
{
|
||||
mHistoryValueLabel = new JLabel(String.valueOf(ClearableHistoryModel.DEFAULT_HISTORY_SIZE));
|
||||
}
|
||||
|
||||
return mHistoryValueLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* History title label
|
||||
* @return label
|
||||
*/
|
||||
private JLabel getHistoryTitleLabel()
|
||||
{
|
||||
if(mHistoryTitleLabel == null)
|
||||
{
|
||||
mHistoryTitleLabel = new JLabel("History:");
|
||||
}
|
||||
|
||||
return mHistoryTitleLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* History value slider control
|
||||
* @return slider
|
||||
*/
|
||||
private JSlider getHistorySlider()
|
||||
{
|
||||
if(mHistorySlider == null)
|
||||
{
|
||||
mHistorySlider = new JSlider();
|
||||
mHistorySlider.setToolTipText("Adjust history size. Double-click to reset to default 200");
|
||||
mHistorySlider.setMinimum(0);
|
||||
mHistorySlider.setMaximum(2000);
|
||||
mHistorySlider.setMinorTickSpacing(25);
|
||||
mHistorySlider.setMajorTickSpacing(500);
|
||||
mHistorySlider.setPaintTicks(false);
|
||||
mHistorySlider.setPaintLabels(false);
|
||||
mHistorySlider.addMouseListener(new MouseListener()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0)
|
||||
{
|
||||
if(SwingUtilities.isLeftMouseButton(arg0) && arg0.getClickCount() == 2)
|
||||
{
|
||||
mHistorySlider.setValue(ClearableHistoryModel.DEFAULT_HISTORY_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent arg0) {}
|
||||
public void mouseExited(MouseEvent arg0) {}
|
||||
public void mousePressed(MouseEvent arg0) {}
|
||||
public void mouseReleased(MouseEvent arg0) {}
|
||||
});
|
||||
|
||||
mHistorySlider.setValue(mModel.getHistorySize());
|
||||
mHistorySlider.addChangeListener(e -> {
|
||||
mModel.setHistorySize(mHistorySlider.getValue());
|
||||
getHistoryValueLabel().setText(String.valueOf(mHistorySlider.getValue()));
|
||||
});
|
||||
}
|
||||
|
||||
return mHistorySlider;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -48,11 +48,6 @@ public interface IDecodeEvent
|
||||
*/
|
||||
long getDuration();
|
||||
|
||||
/**
|
||||
* A description of the event or event type
|
||||
*/
|
||||
String getEventDescription();
|
||||
|
||||
/**
|
||||
* Collection of identifiers associated with the event. This collection should contain a
|
||||
* Role.FROM and a Role.TO identifier, a Decoder Type identifier, and (optionally) an Alias List
|
||||
@@ -86,7 +81,7 @@ public interface IDecodeEvent
|
||||
* Timeslot for the event.
|
||||
* @return timeslot or default of 0
|
||||
*/
|
||||
Integer getTimeslot();
|
||||
int getTimeslot();
|
||||
|
||||
/**
|
||||
* Indicates if the event has a timeslot specified
|
||||
|
||||
@@ -18,19 +18,16 @@
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.event;
|
||||
|
||||
import io.github.dsheirer.filter.AllPassFilter;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.message.StuffBitsMessage;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.awt.EventQueue;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
public class MessageActivityModel extends AbstractTableModel implements Listener<IMessage>
|
||||
/**
|
||||
* Table Model for decoded IMessages.
|
||||
*/
|
||||
public class MessageActivityModel extends ClearableHistoryModel<MessageItem> implements Listener<IMessage>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int TIME = 0;
|
||||
@@ -38,95 +35,20 @@ public class MessageActivityModel extends AbstractTableModel implements Listener
|
||||
private static final int TIMESLOT = 2;
|
||||
private static final int MESSAGE = 3;
|
||||
|
||||
protected int mMaxMessages = 200;
|
||||
protected LinkedList<MessageItem> mMessageItems = new LinkedList<>();
|
||||
protected int[] mColumnWidths = {20, 20, 500};
|
||||
protected String[] mHeaders = new String[]{"Time", "Protocol", "Timeslot", "Message"};
|
||||
|
||||
private String[] mHeaders = new String[]{"Time", "Protocol", "Timeslot", "Message"};
|
||||
private SimpleDateFormat mSDFTime = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
|
||||
|
||||
private FilterSet<IMessage> mMessageFilterSet = new FilterSet<>(new AllPassFilter<>());
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public MessageActivityModel()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the filter set
|
||||
* Implements the listener interface and wraps the IMessage in table-compatible message item wrapper.
|
||||
* @param message to add to the model
|
||||
*/
|
||||
public void setFilters(FilterSet filterSet)
|
||||
{
|
||||
mMessageFilterSet = filterSet;
|
||||
}
|
||||
|
||||
public void clearFilters()
|
||||
{
|
||||
mMessageFilterSet = new FilterSet<>(new AllPassFilter<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all messages from history
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
EventQueue.invokeLater(() -> {
|
||||
mMessageItems.clear();
|
||||
fireTableDataChanged();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current messages and loads the messages argument
|
||||
*/
|
||||
public void clearAndSet(List<IMessage> messages)
|
||||
{
|
||||
EventQueue.invokeLater(() -> {
|
||||
mMessageItems.clear();
|
||||
fireTableDataChanged();
|
||||
for(IMessage message: messages)
|
||||
{
|
||||
receive(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public FilterSet<IMessage> getMessageFilterSet()
|
||||
{
|
||||
return mMessageFilterSet;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mMessageItems.clear();
|
||||
}
|
||||
|
||||
public int[] getColumnWidths()
|
||||
{
|
||||
return mColumnWidths;
|
||||
}
|
||||
|
||||
public void setColumnWidths(int[] widths)
|
||||
{
|
||||
if(widths.length != 3)
|
||||
{
|
||||
throw new IllegalArgumentException("MessageActivityModel - column widths array should have 3 elements");
|
||||
}
|
||||
else
|
||||
{
|
||||
mColumnWidths = widths;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxMessageCount()
|
||||
{
|
||||
return mMaxMessages;
|
||||
}
|
||||
|
||||
public void setMaxMessageCount(int count)
|
||||
{
|
||||
mMaxMessages = count;
|
||||
}
|
||||
|
||||
public void receive(final IMessage message)
|
||||
{
|
||||
//Don't process tail bits or stuff bits message fragments
|
||||
@@ -135,39 +57,7 @@ public class MessageActivityModel extends AbstractTableModel implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if(mMessageFilterSet.passes(message))
|
||||
{
|
||||
final MessageItem messageItem = new MessageItem(message);
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mMessageItems.addFirst(messageItem);
|
||||
|
||||
MessageActivityModel.this.fireTableRowsInserted(0, 0);
|
||||
|
||||
prune();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void prune()
|
||||
{
|
||||
while(mMessageItems.size() > mMaxMessages)
|
||||
{
|
||||
MessageItem removed = mMessageItems.removeLast();
|
||||
removed.dispose();
|
||||
super.fireTableRowsDeleted(mMessageItems.size() - 1, mMessageItems.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mMessageItems.size();
|
||||
EventQueue.invokeLater(() -> add(new MessageItem(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,20 +74,20 @@ public class MessageActivityModel extends AbstractTableModel implements Listener
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
if(0 <= rowIndex && rowIndex < mMessageItems.size())
|
||||
{
|
||||
MessageItem messageItem = mMessageItems.get(rowIndex);
|
||||
MessageItem item = getItem(rowIndex);
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case TIME:
|
||||
return messageItem.getTimestamp(mSDFTime);
|
||||
return item.getTimestamp(mSDFTime);
|
||||
case PROTOCOL:
|
||||
return messageItem.getProtocol();
|
||||
return item.getProtocol();
|
||||
case TIMESLOT:
|
||||
return messageItem.getTimeslot();
|
||||
return item.getTimeslot();
|
||||
case MESSAGE:
|
||||
return messageItem.getText();
|
||||
return item.getText();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2019 Dennis Sheirer
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -15,13 +14,10 @@
|
||||
*
|
||||
* 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.module.decode.event;
|
||||
|
||||
import com.jidesoft.swing.JideButton;
|
||||
import com.jidesoft.swing.JideSplitButton;
|
||||
import io.github.dsheirer.filter.FilterEditorPanel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.message.MessageHistory;
|
||||
@@ -30,37 +26,35 @@ import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import javax.swing.RowFilter;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
/**
|
||||
* Panel to display decoded messages/activity.
|
||||
*/
|
||||
public class MessageActivityPanel extends JPanel implements Listener<ProcessingChain>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MessageActivityPanel.class);
|
||||
private static final String TABLE_PREFERENCE_KEY = "message.activity.panel";
|
||||
private static MessageActivityModel mMessageModel = new MessageActivityModel();
|
||||
private static final Logger mLog = LoggerFactory.getLogger(MessageActivityPanel.class);
|
||||
private final String TABLE_PREFERENCE_KEY = "message.activity.panel";
|
||||
private MessageActivityModel mMessageModel = new MessageActivityModel();
|
||||
private MessageHistory mCurrentMessageHistory;
|
||||
private JTable mTable = new JTable(mMessageModel);
|
||||
private TableRowSorter<TableModel> mTableRowSorter;
|
||||
private JTableColumnWidthMonitor mTableColumnWidthMonitor;
|
||||
private UserPreferences mUserPreferences;
|
||||
private MessageManagementPanel mManagementPanel = new MessageManagementPanel();
|
||||
private FilterSet<IMessage> mMessageFilterSet;
|
||||
private HistoryManagementPanel<IMessage> mHistoryManagementPanel;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
@@ -69,13 +63,14 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
|
||||
public MessageActivityPanel(UserPreferences userPreferences)
|
||||
{
|
||||
mUserPreferences = userPreferences;
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill]", "[]0[grow,fill]"));
|
||||
|
||||
add(mManagementPanel, "span,growx");
|
||||
|
||||
add(new JScrollPane(mTable), "span,grow");
|
||||
mTableRowSorter = new TableRowSorter<>(mMessageModel);
|
||||
mTableRowSorter.setRowFilter(new MessageRowFilter());
|
||||
mTable.setRowSorter(mTableRowSorter);
|
||||
mTableColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTable, TABLE_PREFERENCE_KEY);
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill]", "[]0[grow,fill]"));
|
||||
mHistoryManagementPanel = new HistoryManagementPanel<>(mMessageModel, "Message Filter Editor");
|
||||
add(mHistoryManagementPanel, "span,growx");
|
||||
add(new JScrollPane(mTable), "span,grow");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,182 +84,62 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
|
||||
mCurrentMessageHistory.removeListener(mMessageModel);
|
||||
}
|
||||
|
||||
//Unregister from changes made to the filter set
|
||||
if(mMessageFilterSet != null)
|
||||
{
|
||||
mMessageFilterSet.register(null);
|
||||
}
|
||||
|
||||
if(processingChain != null)
|
||||
{
|
||||
mCurrentMessageHistory = processingChain.getMessageHistory();
|
||||
mMessageModel.setFilters(DecoderFactory.getMessageFilters(processingChain.getModules()));
|
||||
mMessageModel.clearAndSet(mCurrentMessageHistory.getItems());
|
||||
mMessageFilterSet = DecoderFactory.getMessageFilters(processingChain.getModules());
|
||||
//Register filter change listener to refresh the table any time the event filters are changed.
|
||||
mMessageFilterSet.register(() -> mMessageModel.fireTableDataChanged());
|
||||
if(mHistoryManagementPanel != null)
|
||||
{
|
||||
mHistoryManagementPanel.updateFilterSet(mMessageFilterSet);
|
||||
}
|
||||
|
||||
List<MessageItem> currentHistory = new ArrayList<>();
|
||||
for(IMessage message: mCurrentMessageHistory.getItems())
|
||||
{
|
||||
currentHistory.add(new MessageItem(message));
|
||||
}
|
||||
|
||||
mMessageModel.clearAndSet(currentHistory);
|
||||
mCurrentMessageHistory.addListener(mMessageModel);
|
||||
mManagementPanel.enableButtons();
|
||||
mHistoryManagementPanel.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentMessageHistory = null;
|
||||
mMessageModel.clearFilters();
|
||||
mMessageFilterSet = null;
|
||||
mMessageModel.clear();
|
||||
mManagementPanel.disableButtons();
|
||||
mHistoryManagementPanel.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageManagementPanel extends JPanel
|
||||
/**
|
||||
* Row visibility filter for messages
|
||||
*/
|
||||
public class MessageRowFilter extends RowFilter<TableModel, Integer>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MessageHistoryButton mHistoryButton = new MessageHistoryButton();
|
||||
private MessageFilterButton mFilterButton = new MessageFilterButton();
|
||||
|
||||
public MessageManagementPanel()
|
||||
@Override
|
||||
public boolean include(Entry<? extends TableModel, ? extends Integer> entry)
|
||||
{
|
||||
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
||||
|
||||
disableButtons();
|
||||
|
||||
add(mFilterButton);
|
||||
add(mHistoryButton);
|
||||
}
|
||||
|
||||
public void enableButtons()
|
||||
{
|
||||
mHistoryButton.setEnabled(true);
|
||||
mFilterButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableButtons()
|
||||
{
|
||||
mHistoryButton.setEnabled(false);
|
||||
mFilterButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageHistoryButton extends JideSplitButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MessageHistoryButton()
|
||||
{
|
||||
super("Clear");
|
||||
|
||||
JPanel historyPanel = new JPanel();
|
||||
|
||||
historyPanel.add(new JLabel("Message History:"));
|
||||
|
||||
final JSlider slider = new JSlider();
|
||||
slider.setMinimum(0);
|
||||
slider.setMaximum(2000);
|
||||
slider.setMajorTickSpacing(500);
|
||||
slider.setPaintTicks(true);
|
||||
slider.setPaintLabels(true);
|
||||
|
||||
slider.addMouseListener(new MouseListener()
|
||||
if(entry.getModel() instanceof MessageActivityModel model)
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0)
|
||||
MessageItem item = model.getItem(entry.getIdentifier());
|
||||
|
||||
if(mMessageFilterSet != null && item != null && item.getMessage() != null)
|
||||
{
|
||||
if(SwingUtilities.isLeftMouseButton(arg0) && arg0.getClickCount() == 2)
|
||||
{
|
||||
slider.setValue(500); //default
|
||||
}
|
||||
IMessage message = item.getMessage();
|
||||
return mMessageFilterSet.canProcess(message) && mMessageFilterSet.passes(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent arg0)
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
slider.setValue(((MessageActivityModel) mTable.getModel()).getMaxMessageCount());
|
||||
slider.addChangeListener(new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent arg0)
|
||||
{
|
||||
((MessageActivityModel) mTable.getModel()).setMaxMessageCount(slider.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
historyPanel.add(slider);
|
||||
|
||||
add(historyPanel);
|
||||
|
||||
/* Clear messages */
|
||||
addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
((MessageActivityModel) mTable.getModel()).clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageFilterButton extends JideButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MessageFilterButton()
|
||||
{
|
||||
super("Filter");
|
||||
|
||||
addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
final JFrame editor = new JFrame();
|
||||
|
||||
editor.setTitle("Message Filter Editor");
|
||||
editor.setSize(600, 400);
|
||||
editor.setLocationRelativeTo(MessageFilterButton.this);
|
||||
editor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
editor.setLayout(new MigLayout("", "[grow,fill]",
|
||||
"[grow,fill][][]"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
FilterSet<IMessage> filter = (FilterSet<IMessage>) ((MessageActivityModel) mTable.getModel())
|
||||
.getMessageFilterSet();
|
||||
|
||||
FilterEditorPanel<IMessage> panel = new FilterEditorPanel<>(filter);
|
||||
|
||||
JScrollPane scroller = new JScrollPane(panel);
|
||||
scroller.setViewportView(panel);
|
||||
|
||||
editor.add(scroller, "wrap");
|
||||
|
||||
editor.add(new JLabel("Right-click to select/deselect all nodes"), "wrap");
|
||||
|
||||
JButton close = new JButton("Close");
|
||||
close.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
editor.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
editor.add(close);
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
editor.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -15,7 +14,7 @@
|
||||
*
|
||||
* 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.module.decode.event;
|
||||
@@ -31,19 +30,20 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
private double mHeading;
|
||||
private double mSpeed;
|
||||
|
||||
public PlottableDecodeEvent(long start)
|
||||
public PlottableDecodeEvent(DecodeEventType decodeEventType, long start)
|
||||
{
|
||||
super(start);
|
||||
super(decodeEventType, start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decode event builder with the specified start timestamp.
|
||||
* @param decodeEventType for the event
|
||||
* @param timeStart for the event
|
||||
* @return builder
|
||||
*/
|
||||
public static PlottableDecodeEventBuilder plottableBuilder(long timeStart)
|
||||
public static PlottableDecodeEventBuilder plottableBuilder(DecodeEventType decodeEventType, long timeStart)
|
||||
{
|
||||
return new PlottableDecodeEventBuilder(timeStart);
|
||||
return new PlottableDecodeEventBuilder(decodeEventType, timeStart);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,6 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
{
|
||||
private long mTimeStart;
|
||||
private long mDuration;
|
||||
private String mEventDescription;
|
||||
private DecodeEventType mDecodeEventType;
|
||||
private IdentifierCollection mIdentifierCollection;
|
||||
private IChannelDescriptor mChannelDescriptor;
|
||||
@@ -115,8 +114,9 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
/**
|
||||
* Constructs a builder instance with the specified start time in milliseconds
|
||||
*/
|
||||
public PlottableDecodeEventBuilder(long timeStart)
|
||||
public PlottableDecodeEventBuilder(DecodeEventType decodeEventType, long timeStart)
|
||||
{
|
||||
mDecodeEventType = decodeEventType;
|
||||
mTimeStart = timeStart;
|
||||
}
|
||||
|
||||
@@ -150,16 +150,6 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the event description text
|
||||
* @param description of the event
|
||||
*/
|
||||
public PlottableDecodeEventBuilder eventDescription(String description)
|
||||
{
|
||||
mEventDescription = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the identifier collection.
|
||||
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
|
||||
@@ -191,15 +181,6 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Decode Event type for this event.
|
||||
* @param eventType
|
||||
*/
|
||||
public PlottableDecodeEventBuilder eventType(DecodeEventType eventType) {
|
||||
mDecodeEventType = eventType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location for the plottable event
|
||||
*/
|
||||
@@ -232,12 +213,10 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
*/
|
||||
public PlottableDecodeEvent build()
|
||||
{
|
||||
PlottableDecodeEvent decodeEvent = new PlottableDecodeEvent(mTimeStart);
|
||||
PlottableDecodeEvent decodeEvent = new PlottableDecodeEvent(mDecodeEventType, mTimeStart);
|
||||
decodeEvent.setChannelDescriptor(mChannelDescriptor);
|
||||
decodeEvent.setDetails(mDetails);
|
||||
decodeEvent.setDuration(mDuration);
|
||||
decodeEvent.setEventType(mDecodeEventType);
|
||||
decodeEvent.setEventDescription(mEventDescription);
|
||||
decodeEvent.setIdentifierCollection(mIdentifierCollection);
|
||||
decodeEvent.setProtocol(mProtocol);
|
||||
decodeEvent.setLocation(mGeoPosition);
|
||||
@@ -246,5 +225,4 @@ public class PlottableDecodeEvent extends DecodeEvent
|
||||
return decodeEvent;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -17,19 +17,23 @@
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.event.filter.lastseen;
|
||||
package io.github.dsheirer.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
|
||||
/**
|
||||
* Request for decode event history from a processing chain for the specified channel.
|
||||
* Event filter for decode event types that are not specified in other event filters.
|
||||
*
|
||||
* This is intended as a catch-all for any elements of the DecodeEventType enumeration that may get added in the
|
||||
* future and are not deliberately added to the various event filter groupings listed in the enumeration.
|
||||
*/
|
||||
public class LastSeenHistoryRequest extends ModuleEventBusMessage
|
||||
public class AllOtherEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
* Constructor
|
||||
*/
|
||||
public LastSeenHistoryRequest()
|
||||
public AllOtherEventFilter()
|
||||
{
|
||||
super("Other", DecodeEventType.OTHERS);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,40 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
|
||||
public class DecodeEventFilterSet extends FilterSet<IDecodeEvent> {
|
||||
public DecodeEventFilterSet() {
|
||||
super ("All Messages");
|
||||
|
||||
/**
|
||||
* Top-level decode event filter set.
|
||||
*/
|
||||
public class DecodeEventFilterSet extends FilterSet<IDecodeEvent>
|
||||
{
|
||||
public DecodeEventFilterSet()
|
||||
{
|
||||
super ("All Events");
|
||||
addFilter(new DecodedCallEventFilter());
|
||||
addFilter(new DecodedCallEncryptedEventFilter());
|
||||
addFilter(new DecodedDataEventFilter());
|
||||
addFilter(new DecodedCommandEventFilter());
|
||||
addFilter(new DecodedRegistrationEventFilter());
|
||||
addFilter(new AllOtherEventFilter());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,36 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Encrypted call events filter
|
||||
*/
|
||||
public class DecodedCallEncryptedEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public DecodedCallEncryptedEventFilter()
|
||||
{
|
||||
super("Voice Calls - Encrypted", Arrays.asList(
|
||||
DecodeEventType.CALL_ENCRYPTED,
|
||||
DecodeEventType.CALL_GROUP_ENCRYPTED,
|
||||
DecodeEventType.CALL_PATCH_GROUP_ENCRYPTED,
|
||||
DecodeEventType.CALL_INTERCONNECT_ENCRYPTED,
|
||||
DecodeEventType.CALL_UNIT_TO_UNIT_ENCRYPTED
|
||||
));
|
||||
super("Voice Calls - Encrypted", DecodeEventType.VOICE_CALLS_ENCRYPTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Call events filter
|
||||
*/
|
||||
public class DecodedCallEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public DecodedCallEventFilter()
|
||||
{
|
||||
super("Voice Calls", Arrays.asList(
|
||||
DecodeEventType.CALL_GROUP,
|
||||
DecodeEventType.CALL_PATCH_GROUP,
|
||||
DecodeEventType.CALL_ALERT,
|
||||
DecodeEventType.CALL_DETECT,
|
||||
DecodeEventType.CALL_DO_NOT_MONITOR,
|
||||
DecodeEventType.CALL_END,
|
||||
DecodeEventType.CALL_INTERCONNECT,
|
||||
DecodeEventType.CALL_UNIQUE_ID,
|
||||
DecodeEventType.CALL_UNIT_TO_UNIT,
|
||||
DecodeEventType.CALL_NO_TUNER,
|
||||
DecodeEventType.CALL_TIMEOUT
|
||||
));
|
||||
super("Voice Calls", DecodeEventType.VOICE_CALLS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 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
|
||||
@@ -20,24 +20,17 @@
|
||||
package io.github.dsheirer.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Event filter for network commands.
|
||||
*/
|
||||
public class DecodedCommandEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public DecodedCommandEventFilter()
|
||||
{
|
||||
super("Commands", Arrays.asList(
|
||||
DecodeEventType.ANNOUNCEMENT,
|
||||
DecodeEventType.STATION_ID,
|
||||
DecodeEventType.ACKNOWLEDGE,
|
||||
DecodeEventType.PAGE,
|
||||
DecodeEventType.QUERY,
|
||||
DecodeEventType.RADIO_CHECK,
|
||||
DecodeEventType.STATUS,
|
||||
DecodeEventType.COMMAND,
|
||||
DecodeEventType.EMERGENCY,
|
||||
DecodeEventType.NOTIFICATION,
|
||||
DecodeEventType.FUNCTION
|
||||
));
|
||||
super("Commands", DecodeEventType.COMMANDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Event filter for data call event types
|
||||
*/
|
||||
public class DecodedDataEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public DecodedDataEventFilter()
|
||||
{
|
||||
super("Data Calls", Arrays.asList(
|
||||
DecodeEventType.DATA_CALL,
|
||||
DecodeEventType.DATA_CALL_ENCRYPTED,
|
||||
DecodeEventType.DATA_PACKET,
|
||||
DecodeEventType.GPS,
|
||||
DecodeEventType.IP_PACKET,
|
||||
DecodeEventType.UDP_PACKET,
|
||||
DecodeEventType.SDM,
|
||||
DecodeEventType.ID_ANI,
|
||||
DecodeEventType.ID_UNIQUE
|
||||
));
|
||||
super("Data Calls", DecodeEventType.DATA_CALLS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,36 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Event filter for registration related events
|
||||
*/
|
||||
public class DecodedRegistrationEventFilter extends EventFilter
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DecodedRegistrationEventFilter()
|
||||
{
|
||||
super("Registrations", Arrays.asList(
|
||||
DecodeEventType.AFFILIATE,
|
||||
DecodeEventType.AUTOMATIC_REGISTRATION_SERVICE,
|
||||
DecodeEventType.REGISTER,
|
||||
DecodeEventType.REGISTER_ESN,
|
||||
DecodeEventType.DEREGISTER,
|
||||
DecodeEventType.REQUEST,
|
||||
DecodeEventType.RESPONSE,
|
||||
DecodeEventType.RESPONSE_PACKET
|
||||
));
|
||||
super("Registrations", DecodeEventType.REGISTRATION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import com.jidesoft.swing.JideSplitButton;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class EventClearButton extends JideSplitButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -21,37 +39,29 @@ public class EventClearButton extends JideSplitButton
|
||||
|
||||
JPanel historyPanel = new JPanel();
|
||||
|
||||
historyPanel.add(new JLabel("History Entries:"));
|
||||
|
||||
historyPanel.add(new JLabel("History Size:"));
|
||||
final JSlider historySlider = initializeHistorySlider();
|
||||
JLabel valueLabel = new JLabel(String.valueOf(maxHistoryCount));
|
||||
|
||||
historySlider.setValue(maxHistoryCount);
|
||||
historySlider.addChangeListener(new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent arg0)
|
||||
historySlider.addChangeListener(arg0 -> {
|
||||
if (mEventClearHandler != null)
|
||||
{
|
||||
if (mEventClearHandler != null)
|
||||
{
|
||||
mEventClearHandler.onHistoryLimitChanged(historySlider.getValue());
|
||||
}
|
||||
mEventClearHandler.onHistoryLimitChanged(historySlider.getValue());
|
||||
}
|
||||
|
||||
valueLabel.setText(String.valueOf(historySlider.getValue()));
|
||||
});
|
||||
|
||||
historyPanel.add(historySlider);
|
||||
|
||||
historyPanel.add(valueLabel);
|
||||
add(historyPanel);
|
||||
|
||||
/* This handles the click action on the main button. Clear messages */
|
||||
addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
addActionListener(e -> {
|
||||
if (mEventClearHandler != null)
|
||||
{
|
||||
if (mEventClearHandler != null)
|
||||
{
|
||||
mEventClearHandler.onClearHistoryClicked();
|
||||
}
|
||||
mEventClearHandler.onClearHistoryClicked();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,37 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
public interface EventClearHandler {
|
||||
/**
|
||||
* Handler interface for changes to the event history size or content.
|
||||
*/
|
||||
public interface EventClearHandler
|
||||
{
|
||||
/**
|
||||
* Invoked when the retained history size limit is changed
|
||||
* @param newHistoryLimit new size
|
||||
*/
|
||||
void onHistoryLimitChanged(int newHistoryLimit);
|
||||
|
||||
/**
|
||||
* Invoked when the history is cleared
|
||||
*/
|
||||
void onClearHistoryClicked();
|
||||
}
|
||||
|
||||
@@ -1,56 +1,74 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.filter.Filter;
|
||||
import io.github.dsheirer.filter.FilterElement;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventType;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* This is used as a base for {@link IDecodeEvent} types.
|
||||
* This will take a list of {@link IDecodeEvent}s and generate filters for the list.
|
||||
* This will default canProcess to TRUE. Override if other value or evaluation is needed.
|
||||
*
|
||||
*/
|
||||
public class EventFilter extends Filter<IDecodeEvent>
|
||||
public class EventFilter extends Filter<IDecodeEvent,DecodeEventType>
|
||||
{
|
||||
private Map<DecodeEventType, FilterElement<DecodeEventType>> mElements = new EnumMap<>(DecodeEventType.class);
|
||||
private EventKeyExtractor mKeyExtractor = new EventKeyExtractor();
|
||||
|
||||
public EventFilter(String name, List<DecodeEventType> eventTypes)
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param name of this filter
|
||||
* @param decodeEventTypes to filter against
|
||||
*/
|
||||
public EventFilter(String name, Collection<DecodeEventType> decodeEventTypes)
|
||||
{
|
||||
super(name);
|
||||
|
||||
for (DecodeEventType eventType : eventTypes) {
|
||||
mElements.put(eventType, new FilterElement<>(eventType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passes(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
if (mEnabled && canProcess(iDecodeEvent))
|
||||
for (DecodeEventType decodeEventType : decodeEventTypes)
|
||||
{
|
||||
if (mElements.containsKey(iDecodeEvent.getEventType()))
|
||||
{
|
||||
return mElements.get(iDecodeEvent.getEventType()).isEnabled();
|
||||
}
|
||||
add(new FilterElement<>(decodeEventType));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Key extractor function
|
||||
* @return function.
|
||||
*/
|
||||
@Override
|
||||
public boolean canProcess(IDecodeEvent iDecodeEvent)
|
||||
public Function<IDecodeEvent, DecodeEventType> getKeyExtractor()
|
||||
{
|
||||
return true;
|
||||
return mKeyExtractor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterElement<?>> getFilterElements()
|
||||
/**
|
||||
* Key extractor function for decode events to extract the decode event type
|
||||
*/
|
||||
public static class EventKeyExtractor implements Function<IDecodeEvent,DecodeEventType>
|
||||
{
|
||||
return new ArrayList<>(mElements.values());
|
||||
@Override
|
||||
public DecodeEventType apply(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
return iDecodeEvent.getEventType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +1,103 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 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.module.decode.event.filter;
|
||||
|
||||
import com.jidesoft.swing.JideButton;
|
||||
import io.github.dsheirer.filter.FilterEditorPanel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* Event filter button that includes split button functionality to allow user to select filter items.
|
||||
*
|
||||
* @param <T> type of filter.
|
||||
*/
|
||||
public class EventFilterButton<T> extends JideButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param dialogTitle for the dialog/panel that appears
|
||||
* @param filterSet to include in the editor panel.
|
||||
*/
|
||||
public EventFilterButton(String dialogTitle, FilterSet<T> filterSet)
|
||||
{
|
||||
this("Filter", dialogTitle, filterSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param buttonLabel to use on the button
|
||||
* @param dialogTitle for the dialog/panel that appears
|
||||
* @param filterSet to include in the editor panel.
|
||||
*/
|
||||
public EventFilterButton(String buttonLabel, String dialogTitle, FilterSet<T> filterSet)
|
||||
{
|
||||
super(buttonLabel);
|
||||
|
||||
addActionListener(
|
||||
new EventFilterActionHandler(dialogTitle, filterSet)
|
||||
);
|
||||
addActionListener(new EventFilterActionHandler(dialogTitle, filterSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler for the button
|
||||
*/
|
||||
public class EventFilterActionHandler implements ActionListener
|
||||
{
|
||||
private String title;
|
||||
private FilterSet<T> filterSet;
|
||||
private String mTitle;
|
||||
private FilterSet<T> mFilterSet;
|
||||
|
||||
public EventFilterActionHandler( String title, FilterSet<T> filterSet)
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param title for this panel
|
||||
* @param filterSet to edit
|
||||
*/
|
||||
public EventFilterActionHandler(String title, FilterSet<T> filterSet)
|
||||
{
|
||||
this.title = title;
|
||||
this.filterSet = filterSet;
|
||||
mTitle = title;
|
||||
mFilterSet = filterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
final JFrame editor = new JFrame();
|
||||
|
||||
editor.setTitle(title);
|
||||
editor.setTitle(mTitle);
|
||||
editor.setLocationRelativeTo(EventFilterButton.this);
|
||||
editor.setSize(600, 400);
|
||||
editor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
editor.setLayout(new MigLayout("", "[grow,fill]",
|
||||
"[grow,fill][][]"));
|
||||
|
||||
FilterEditorPanel<T> panel = new FilterEditorPanel<T>(filterSet);
|
||||
|
||||
editor.setLayout(new MigLayout("", "[grow,fill]", "[grow,fill][][]"));
|
||||
FilterEditorPanel<T> panel = new FilterEditorPanel<T>(mFilterSet);
|
||||
JScrollPane scroller = new JScrollPane(panel);
|
||||
scroller.setViewportView(panel);
|
||||
|
||||
editor.add(scroller, "wrap");
|
||||
|
||||
editor.add(new JLabel("Right-click to select/deselect all nodes"), "wrap");
|
||||
|
||||
JButton close = new JButton("Close");
|
||||
close.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
editor.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
close.addActionListener(e1 -> editor.dispose());
|
||||
editor.add(close);
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
editor.setVisible(true);
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(() -> editor.setVisible(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package io.github.dsheirer.module.decode.event.filter;
|
||||
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
|
||||
public interface EventFilterProvider<T> {
|
||||
FilterSet<T> getFilterSet();
|
||||
void setFilterSet(FilterSet<T> filterSet);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.github.dsheirer.module.decode.event.filter.lastheard;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
|
||||
public class LastHeardFilterSet extends FilterSet<IDecodeEvent>
|
||||
{
|
||||
|
||||
public LastHeardFilterSet(AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
super("Last Heard To Channel");
|
||||
|
||||
addFilter(new LastHeardIconFilter("Icon", aliasModel, iconModel));
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.module.decode.event.filter.lastheard;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.module.HistoryModule;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventHistoryPreloadData;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEventListener;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
/**
|
||||
* Decode event history module. Maintains a history of decode events and constrains the total history size.
|
||||
*/
|
||||
public class LastHeardHistory extends HistoryModule<IDecodeEvent> implements IDecodeEventListener
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public LastHeardHistory(int historySize)
|
||||
{
|
||||
super(historySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IDecodeEventListener interface - delegates to receive(event) method.
|
||||
*/
|
||||
@Override
|
||||
public Listener<IDecodeEvent> getDecodeEventListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process preload data
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(DecodeEventHistoryPreloadData preloadData)
|
||||
{
|
||||
for(IDecodeEvent decodeEvent: preloadData.getData())
|
||||
{
|
||||
receive(decodeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request for decode event history and posts the response back
|
||||
* to the processing chain event bus so that any of the modules can receive that history.
|
||||
*
|
||||
* Note: this is principally used by the DMR decoder for Capacity+ REST channel rotation to transfer the decode
|
||||
* event history from a traffic channel conversion to the new rest channel.
|
||||
*
|
||||
* @param request for decode event history
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(LastHeardHistoryRequest request)
|
||||
{
|
||||
getInterModuleEventBus().post(new LastHeardHistoryResponse(this));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.module.decode.event.filter.lastheard;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
|
||||
/**
|
||||
* Request for decode event history from a processing chain for the specified channel.
|
||||
*/
|
||||
public class LastHeardHistoryRequest extends ModuleEventBusMessage
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public LastHeardHistoryRequest()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.module.decode.event.filter.lastheard;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
|
||||
/**
|
||||
* Response to decode event history request from a processing chain for the specified channel.
|
||||
*/
|
||||
public class LastHeardHistoryResponse extends ModuleEventBusMessage
|
||||
{
|
||||
private LastHeardHistory mLastHeardHistory;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param history that has a decode event history
|
||||
*/
|
||||
public LastHeardHistoryResponse(LastHeardHistory history)
|
||||
{
|
||||
mLastHeardHistory = history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode event history module
|
||||
*/
|
||||
public LastHeardHistory getDecodeEventHistory()
|
||||
{
|
||||
return mLastHeardHistory;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package io.github.dsheirer.module.decode.event.filter.lastheard;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.filter.Filter;
|
||||
import io.github.dsheirer.filter.FilterElement;
|
||||
import io.github.dsheirer.icon.Icon;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LastHeardIconFilter extends Filter<IDecodeEvent>
|
||||
{
|
||||
private AliasModel mAliasModel;
|
||||
private Map<String, FilterElement<String>> mElements = new HashMap<>();
|
||||
|
||||
public LastHeardIconFilter(String name, AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
super(name);
|
||||
this.mAliasModel = aliasModel;
|
||||
|
||||
ObservableList<Icon> icons = iconModel.iconsProperty();
|
||||
for (Icon icon : icons) {
|
||||
mElements.put(icon.getName(), new FilterElement<>(icon.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passes(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
if (mEnabled && canProcess(iDecodeEvent))
|
||||
{
|
||||
return matchAliasToFilter(iDecodeEvent)
|
||||
.map(FilterElement::isEnabled)
|
||||
.orElse(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Optional<FilterElement<String>> matchAliasToFilter(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
IdentifierCollection identifierCollection = iDecodeEvent.getIdentifierCollection();
|
||||
List<Identifier> identifiers = identifierCollection.getIdentifiers(Role.TO);
|
||||
if (iDecodeEvent.getDuration() > 0 && identifiers != null && !identifiers.isEmpty())
|
||||
{
|
||||
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
|
||||
if (aliasList != null)
|
||||
{
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
if (identifier.getForm() == Form.TALKGROUP)
|
||||
{
|
||||
List<Alias> aliases = aliasList.getAliases(identifier);
|
||||
if (!aliases.isEmpty())
|
||||
{
|
||||
for (Alias alias : aliases) {
|
||||
if (alias.getIconName() == null)
|
||||
{
|
||||
// Return any to match aliases with no icon defined.
|
||||
return Optional.of(mElements.get(IconModel.DEFAULT_ICON));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Optional.of(mElements.get(alias.getIconName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcess(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterElement<?>> getFilterElements()
|
||||
{
|
||||
return new ArrayList<>(mElements.values());
|
||||
}
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2019 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.module.decode.event.filter.lastheard;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LastHeardModel extends AbstractTableModel implements Listener<IDecodeEvent>, EventFilterProvider<IDecodeEvent>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(LastHeardModel.class);
|
||||
|
||||
public static final int COLUMN_TIME = 0;
|
||||
public static final int COLUMN_DURATION = 1;
|
||||
public static final int COLUMN_EVENT = 2;
|
||||
public static final int COLUMN_FROM_ID = 3;
|
||||
public static final int COLUMN_FROM_ALIAS = 4;
|
||||
public static final int COLUMN_TO_ID = 5;
|
||||
public static final int COLUMN_TO_ALIAS = 6;
|
||||
public static final int COLUMN_CHANNEL = 7;
|
||||
public static final int COLUMN_FREQUENCY = 8;
|
||||
public static final int COLUMN_DETAILS = 9;
|
||||
|
||||
protected int mMaxMessages = 500;
|
||||
|
||||
protected List<IDecodeEvent> mEvents = new ArrayList<>();
|
||||
protected FilterSet<IDecodeEvent> mLastSeenFilterSet;
|
||||
|
||||
protected String[] mHeaders = new String[]{"Time", "Duration", "Event", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Details"};
|
||||
|
||||
public LastHeardModel(AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
mLastSeenFilterSet = new LastHeardFilterSet(aliasModel, iconModel);
|
||||
MyEventBus.getGlobalEventBus().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_TIME);
|
||||
}
|
||||
}
|
||||
else if(preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_FROM_ID);
|
||||
fireTableCellUpdated(row, COLUMN_TO_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the complete list of events managed by this model.
|
||||
*/
|
||||
public List<IDecodeEvent> getEvents()
|
||||
{
|
||||
return new ArrayList<>(mEvents);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().unregister(this);
|
||||
Iterator<IDecodeEvent> it = mEvents.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
mEvents.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all events from this model and loads the events argument
|
||||
*/
|
||||
public void clearAndSet(List<IDecodeEvent> events)
|
||||
{
|
||||
mEvents.clear();
|
||||
mEvents.addAll(events);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
dispose();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public int getMaxMessageCount()
|
||||
{
|
||||
return mMaxMessages;
|
||||
}
|
||||
|
||||
public void setMaxMessageCount(int count)
|
||||
{
|
||||
mMaxMessages = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds, updates or deletes the event from the model. Producers can send
|
||||
* the same call event multiple times to indicate that information in the
|
||||
* event is updated. Producers can also mark the event as invalid and the
|
||||
* event will be removed from the model.
|
||||
*/
|
||||
public void receive(final IDecodeEvent event)
|
||||
{
|
||||
if (mLastSeenFilterSet != null && !mLastSeenFilterSet.passes(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!mEvents.contains(event))
|
||||
{
|
||||
mEvents.add(0, event);
|
||||
fireTableRowsInserted(0, 0);
|
||||
prune();
|
||||
}
|
||||
else
|
||||
{
|
||||
int row = mEvents.indexOf(event);
|
||||
fireTableRowsUpdated(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
private void prune()
|
||||
{
|
||||
while(mEvents.size() > mMaxMessages)
|
||||
{
|
||||
int index = mEvents.size() - 1;
|
||||
mEvents.remove(index);
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterSet<IDecodeEvent> getFilterSet() {
|
||||
return mLastSeenFilterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterSet(FilterSet<IDecodeEvent> filterSet) {
|
||||
this.mLastSeenFilterSet = filterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mEvents.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return mHeaders.length;
|
||||
}
|
||||
|
||||
public String getColumnName(int column)
|
||||
{
|
||||
return mHeaders[column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
synchronized(mEvents)
|
||||
{
|
||||
IDecodeEvent event = mEvents.get(rowIndex);
|
||||
|
||||
if(event != null)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_TIME:
|
||||
return event.getTimeStart();
|
||||
case COLUMN_DURATION:
|
||||
return event.getDuration();
|
||||
case COLUMN_EVENT:
|
||||
return event.getEventDescription();
|
||||
case COLUMN_FROM_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_FROM_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_CHANNEL:
|
||||
IChannelDescriptor channelDescriptor = event.getChannelDescriptor();
|
||||
|
||||
if(channelDescriptor != null)
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return channelDescriptor.toString() + " TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return channelDescriptor.toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return "TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
case COLUMN_FREQUENCY:
|
||||
return event.getChannelDescriptor();
|
||||
case COLUMN_DETAILS:
|
||||
return event.getDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_DURATION:
|
||||
case COLUMN_TIME:
|
||||
return Long.class;
|
||||
case COLUMN_DETAILS:
|
||||
case COLUMN_EVENT:
|
||||
return String.class;
|
||||
case COLUMN_FREQUENCY:
|
||||
case COLUMN_FROM_ALIAS:
|
||||
case COLUMN_FROM_ID:
|
||||
case COLUMN_TO_ALIAS:
|
||||
case COLUMN_TO_ID:
|
||||
return IdentifierCollection.class;
|
||||
case COLUMN_CHANNEL:
|
||||
return String.class;
|
||||
}
|
||||
return super.getColumnClass(columnIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,482 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2019 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.module.decode.event.filter.lastheard;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.AllPassFilter;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventHistory;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventModel;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearHandler;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class LastHeardPanel extends JPanel implements Listener<ProcessingChain>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(LastHeardPanel.class);
|
||||
private static final String TABLE_PREFERENCE_KEY = "decode.lastseen.panel";
|
||||
|
||||
private JTable mTable;
|
||||
private JTableColumnWidthMonitor mTableColumnWidthMonitor;
|
||||
private LastHeardModel mLastHeardModel;
|
||||
private DecodeEventHistory mCurrentEventHistory;
|
||||
private JScrollPane mEmptyScroller;
|
||||
private IconModel mIconModel;
|
||||
private AliasModel mAliasModel;
|
||||
private UserPreferences mUserPreferences;
|
||||
private TimestampCellRenderer mTimestampCellRenderer;
|
||||
private LastSeenManagementPanel mLastSeenManagementPanel;
|
||||
|
||||
/**
|
||||
* View for call event table
|
||||
* @param iconModel to display alias icons in table rows
|
||||
*/
|
||||
public LastHeardPanel(IconModel iconModel, UserPreferences userPreferences, AliasModel aliasModel)
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().register(this);
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||
mIconModel = iconModel;
|
||||
mAliasModel = aliasModel;
|
||||
mLastHeardModel = new LastHeardModel(aliasModel, iconModel);
|
||||
mUserPreferences = userPreferences;
|
||||
mTimestampCellRenderer = new TimestampCellRenderer();
|
||||
mTable = new JTable(mLastHeardModel);
|
||||
mTable.setAutoCreateRowSorter(true);
|
||||
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
mLastSeenManagementPanel = new LastSeenManagementPanel();
|
||||
mTableColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTable, TABLE_PREFERENCE_KEY);
|
||||
updateCellRenderers();
|
||||
|
||||
add(mLastSeenManagementPanel, "span,growx");
|
||||
|
||||
mEmptyScroller = new JScrollPane(mTable);
|
||||
add(mEmptyScroller);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().unregister(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT || preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
EventQueue.invokeLater(() -> mTimestampCellRenderer.updatePreferences());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCellRenderers()
|
||||
{
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME)
|
||||
.setCellRenderer(mTimestampCellRenderer);
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION)
|
||||
.setCellRenderer(new DurationCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL)
|
||||
.setCellRenderer(new ChannelDescriptorCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ProcessingChain processingChain)
|
||||
{
|
||||
if(mCurrentEventHistory != null)
|
||||
{
|
||||
mCurrentEventHistory.removeListener(mLastHeardModel);
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
if(processingChain != null)
|
||||
{
|
||||
mCurrentEventHistory = processingChain.getDecodeEventHistory();
|
||||
mLastHeardModel.clearAndSet(mCurrentEventHistory.getItems());
|
||||
processingChain.getDecodeEventHistory().addListener(mLastHeardModel);
|
||||
mLastSeenManagementPanel.enableButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentEventHistory = null;
|
||||
mLastHeardModel.clearAndSet(Collections.emptyList());
|
||||
mLastSeenManagementPanel.disableButtons();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class LastSeenManagementPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private EventFilterButton<IDecodeEvent> mFilterButton;
|
||||
private EventClearButton mEventClearButton;
|
||||
|
||||
public LastSeenManagementPanel()
|
||||
{
|
||||
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
||||
|
||||
initializeFilterButton();
|
||||
initializeClearButton();
|
||||
disableButtons();
|
||||
|
||||
add(mFilterButton);
|
||||
add(mEventClearButton);
|
||||
}
|
||||
|
||||
public void enableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(true);
|
||||
mEventClearButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(false);
|
||||
mEventClearButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void initializeFilterButton()
|
||||
{
|
||||
EventFilterProvider<IDecodeEvent> filterProvider = (EventFilterProvider<IDecodeEvent>) mTable.getModel();
|
||||
FilterSet<IDecodeEvent> filterSet = new FilterSet<>(new AllPassFilter<>());
|
||||
if (filterProvider != null) {
|
||||
filterSet = filterProvider.getFilterSet();
|
||||
}
|
||||
mFilterButton = new EventFilterButton<>("Last Heard To Channel Filter Editor", filterSet);
|
||||
}
|
||||
|
||||
private void initializeClearButton() {
|
||||
mEventClearButton = new EventClearButton(
|
||||
((LastHeardModel) mTable.getModel()).getMaxMessageCount()
|
||||
);
|
||||
mEventClearButton.setEventClearHandler(new EventClearHandler() {
|
||||
@Override
|
||||
public void onHistoryLimitChanged(int newHistoryLimit) {
|
||||
((LastHeardModel) mTable.getModel()).setMaxMessageCount(newHistoryLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClearHistoryClicked() {
|
||||
((LastHeardModel) mTable.getModel()).clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom cell renderer for displaying identifiers from an identifier collection
|
||||
*/
|
||||
public class IdentifierCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
protected Role mRole;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the cell renderer.
|
||||
*
|
||||
* @param role of the identifier
|
||||
*/
|
||||
public IdentifierCellRenderer(Role role)
|
||||
{
|
||||
mRole = role;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof IdentifierCollection)
|
||||
{
|
||||
List<Identifier> identifiers = ((IdentifierCollection)value).getIdentifiers(mRole);
|
||||
label.setText(format(identifiers));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a list of identifiers as a comma separated list of values
|
||||
* @param identifiers to format
|
||||
* @return formatted list or null
|
||||
*/
|
||||
protected String format(List<Identifier> identifiers)
|
||||
{
|
||||
if(identifiers == null || identifiers.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
if(sb.length() > 0)
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
if(identifier.getForm() == Form.TALKGROUP)
|
||||
{
|
||||
sb.append(mUserPreferences.getTalkgroupFormatPreference().format(identifier));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(identifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell renderer for identifier aliases
|
||||
*/
|
||||
public class AliasedIdentifierCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private Role mRole;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the cell renderer.
|
||||
*
|
||||
* @param role of the identifier
|
||||
*/
|
||||
public AliasedIdentifierCellRenderer(Role role)
|
||||
{
|
||||
mRole = role;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
Color color = mTable.getForeground();
|
||||
ImageIcon icon = null;
|
||||
String text = null;
|
||||
|
||||
if(value instanceof IdentifierCollection)
|
||||
{
|
||||
IdentifierCollection identifierCollection = (IdentifierCollection)value;
|
||||
List<Identifier> identifiers = identifierCollection.getIdentifiers(mRole);
|
||||
|
||||
if(identifiers != null && !identifiers.isEmpty())
|
||||
{
|
||||
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
|
||||
|
||||
if(aliasList != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
List<Alias> aliases = aliasList.getAliases(identifier);
|
||||
|
||||
if(!aliases.isEmpty())
|
||||
{
|
||||
if(sb.length() > 0)
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(Joiner.on(", ").skipNulls().join(aliases));
|
||||
color = aliases.get(0).getDisplayColor();
|
||||
icon = mIconModel.getIcon(aliases.get(0).getIconName(), IconModel.DEFAULT_ICON_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
text = sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(text);
|
||||
label.setForeground(color);
|
||||
label.setIcon(icon);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public class TimestampCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private SimpleDateFormat mTimestampFormatter;
|
||||
|
||||
public TimestampCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
updatePreferences();
|
||||
}
|
||||
|
||||
public void updatePreferences()
|
||||
{
|
||||
mTimestampFormatter = mUserPreferences.getDecodeEventPreference().getTimestampFormat().getFormatter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof Long)
|
||||
{
|
||||
label.setText(mTimestampFormatter.format(new Date((long)value)));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public class DurationCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private DecimalFormat mDecimalFormat = new DecimalFormat("0.0");
|
||||
|
||||
public DurationCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
String formatted = null;
|
||||
|
||||
if(value instanceof Long)
|
||||
{
|
||||
long duration = (long)value;
|
||||
|
||||
if(duration > 0)
|
||||
{
|
||||
formatted = mDecimalFormat.format((double)duration / 1e3d);
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(formatted);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frequency value cell renderer
|
||||
*/
|
||||
public class FrequencyCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private DecimalFormat mFrequencyFormatter = new DecimalFormat("0.00000");
|
||||
|
||||
public FrequencyCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
String formatted = null;
|
||||
|
||||
if(value instanceof IChannelDescriptor)
|
||||
{
|
||||
IChannelDescriptor channelDescriptor = (IChannelDescriptor)value;
|
||||
|
||||
long frequency = channelDescriptor.getDownlinkFrequency();
|
||||
|
||||
if(frequency > 0)
|
||||
{
|
||||
formatted = mFrequencyFormatter.format(frequency / 1e6d);
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(formatted);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel descriptor value cell renderer
|
||||
*/
|
||||
public class ChannelDescriptorCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
public ChannelDescriptorCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.github.dsheirer.module.decode.event.filter.lastseen;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
|
||||
public class LastSeenFilterSet extends FilterSet<IDecodeEvent>
|
||||
{
|
||||
|
||||
public LastSeenFilterSet(AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
super("Last Seen From Radio");
|
||||
|
||||
addFilter(new LastSeenIconFilter("Icon", aliasModel, iconModel));
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.module.decode.event.filter.lastseen;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.module.HistoryModule;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventHistoryPreloadData;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEventListener;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
/**
|
||||
* Decode event history module. Maintains a history of decode events and constrains the total history size.
|
||||
*/
|
||||
public class LastSeenHistory extends HistoryModule<IDecodeEvent> implements IDecodeEventListener
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public LastSeenHistory(int historySize)
|
||||
{
|
||||
super(historySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IDecodeEventListener interface - delegates to receive(event) method.
|
||||
*/
|
||||
@Override
|
||||
public Listener<IDecodeEvent> getDecodeEventListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process preload data
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(DecodeEventHistoryPreloadData preloadData)
|
||||
{
|
||||
for(IDecodeEvent decodeEvent: preloadData.getData())
|
||||
{
|
||||
receive(decodeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request for decode event history and posts the response back
|
||||
* to the processing chain event bus so that any of the modules can receive that history.
|
||||
*
|
||||
* Note: this is principally used by the DMR decoder for Capacity+ REST channel rotation to transfer the decode
|
||||
* event history from a traffic channel conversion to the new rest channel.
|
||||
*
|
||||
* @param request for decode event history
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(LastSeenHistoryRequest request)
|
||||
{
|
||||
getInterModuleEventBus().post(new LastSeenHistoryResponse(this));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.module.decode.event.filter.lastseen;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
|
||||
/**
|
||||
* Response to decode event history request from a processing chain for the specified channel.
|
||||
*/
|
||||
public class LastSeenHistoryResponse extends ModuleEventBusMessage
|
||||
{
|
||||
private LastSeenHistory mLastSeenHistory;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param history that has a decode event history
|
||||
*/
|
||||
public LastSeenHistoryResponse(LastSeenHistory history)
|
||||
{
|
||||
mLastSeenHistory = history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode event history module
|
||||
*/
|
||||
public LastSeenHistory getDecodeEventHistory()
|
||||
{
|
||||
return mLastSeenHistory;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package io.github.dsheirer.module.decode.event.filter.lastseen;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.filter.Filter;
|
||||
import io.github.dsheirer.filter.FilterElement;
|
||||
import io.github.dsheirer.icon.Icon;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LastSeenIconFilter extends Filter<IDecodeEvent>
|
||||
{
|
||||
private AliasModel mAliasModel;
|
||||
private Map<String, FilterElement<String>> mElements = new HashMap<>();
|
||||
|
||||
public LastSeenIconFilter(String name, AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
super(name);
|
||||
this.mAliasModel = aliasModel;
|
||||
|
||||
ObservableList<Icon> icons = iconModel.iconsProperty();
|
||||
for (Icon icon : icons) {
|
||||
mElements.put(icon.getName(), new FilterElement<>(icon.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passes(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
if (mEnabled && canProcess(iDecodeEvent))
|
||||
{
|
||||
return matchAliasToFilter(iDecodeEvent)
|
||||
.map(FilterElement::isEnabled)
|
||||
.orElse(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Optional<FilterElement<String>> matchAliasToFilter(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
IdentifierCollection identifierCollection = iDecodeEvent.getIdentifierCollection();
|
||||
List<Identifier> identifiers = identifierCollection.getIdentifiers();
|
||||
if (identifiers != null && !identifiers.isEmpty())
|
||||
{
|
||||
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
|
||||
if (aliasList != null)
|
||||
{
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
if (identifier.getForm() == Form.RADIO)
|
||||
{
|
||||
List<Alias> aliases = aliasList.getAliases(identifier);
|
||||
if (!aliases.isEmpty())
|
||||
{
|
||||
for (Alias alias : aliases) {
|
||||
if (alias.getIconName() == null)
|
||||
{
|
||||
// Return any to match aliases with no icon defined.
|
||||
return Optional.of(mElements.get(IconModel.DEFAULT_ICON));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Optional.of(mElements.get(alias.getIconName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcess(IDecodeEvent iDecodeEvent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterElement<?>> getFilterElements()
|
||||
{
|
||||
return new ArrayList<>(mElements.values());
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2019 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.module.decode.event.filter.lastseen;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LastSeenModel extends AbstractTableModel implements Listener<IDecodeEvent>, EventFilterProvider<IDecodeEvent>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int COLUMN_TIME = 0;
|
||||
public static final int COLUMN_DURATION = 1;
|
||||
public static final int COLUMN_EVENT = 2;
|
||||
public static final int COLUMN_FROM_ID = 3;
|
||||
public static final int COLUMN_FROM_ALIAS = 4;
|
||||
public static final int COLUMN_TO_ID = 5;
|
||||
public static final int COLUMN_TO_ALIAS = 6;
|
||||
public static final int COLUMN_CHANNEL = 7;
|
||||
public static final int COLUMN_FREQUENCY = 8;
|
||||
public static final int COLUMN_DETAILS = 9;
|
||||
|
||||
protected int mMaxMessages = 500;
|
||||
|
||||
protected List<IDecodeEvent> mEvents = new ArrayList<>();
|
||||
protected FilterSet<IDecodeEvent> mLastSeenFilterSet;
|
||||
|
||||
protected String[] mHeaders = new String[]{"Time", "Duration", "Event", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Details"};
|
||||
|
||||
public LastSeenModel(AliasModel aliasModel, IconModel iconModel)
|
||||
{
|
||||
mLastSeenFilterSet = new LastSeenFilterSet(aliasModel, iconModel);
|
||||
MyEventBus.getGlobalEventBus().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_TIME);
|
||||
}
|
||||
}
|
||||
else if(preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
for(int row = 0; row < mEvents.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_FROM_ID);
|
||||
fireTableCellUpdated(row, COLUMN_TO_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the complete list of events managed by this model.
|
||||
*/
|
||||
public List<IDecodeEvent> getEvents()
|
||||
{
|
||||
return new ArrayList<>(mEvents);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().unregister(this);
|
||||
Iterator<IDecodeEvent> it = mEvents.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
mEvents.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all events from this model and loads the events argument
|
||||
*/
|
||||
public void clearAndSet(List<IDecodeEvent> events)
|
||||
{
|
||||
mEvents.clear();
|
||||
mEvents.addAll(events);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
dispose();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public int getMaxMessageCount()
|
||||
{
|
||||
return mMaxMessages;
|
||||
}
|
||||
|
||||
public void setMaxMessageCount(int count)
|
||||
{
|
||||
mMaxMessages = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds, updates or deletes the event from the model. Producers can send
|
||||
* the same call event multiple times to indicate that information in the
|
||||
* event is updated. Producers can also mark the event as invalid and the
|
||||
* event will be removed from the model.
|
||||
*/
|
||||
public void receive(final IDecodeEvent event)
|
||||
{
|
||||
if (mLastSeenFilterSet != null && !mLastSeenFilterSet.passes(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!mEvents.contains(event))
|
||||
{
|
||||
mEvents.add(0, event);
|
||||
fireTableRowsInserted(0, 0);
|
||||
prune();
|
||||
}
|
||||
else
|
||||
{
|
||||
int row = mEvents.indexOf(event);
|
||||
fireTableRowsUpdated(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
private void prune()
|
||||
{
|
||||
while(mEvents.size() > mMaxMessages)
|
||||
{
|
||||
int index = mEvents.size() - 1;
|
||||
mEvents.remove(index);
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterSet<IDecodeEvent> getFilterSet() {
|
||||
return mLastSeenFilterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterSet(FilterSet<IDecodeEvent> filterSet) {
|
||||
this.mLastSeenFilterSet = filterSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mEvents.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return mHeaders.length;
|
||||
}
|
||||
|
||||
public String getColumnName(int column)
|
||||
{
|
||||
return mHeaders[column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
synchronized(mEvents)
|
||||
{
|
||||
IDecodeEvent event = mEvents.get(rowIndex);
|
||||
|
||||
if(event != null)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_TIME:
|
||||
return event.getTimeStart();
|
||||
case COLUMN_DURATION:
|
||||
return event.getDuration();
|
||||
case COLUMN_EVENT:
|
||||
return event.getEventDescription();
|
||||
case COLUMN_FROM_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_FROM_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ID:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_TO_ALIAS:
|
||||
return event.getIdentifierCollection();
|
||||
case COLUMN_CHANNEL:
|
||||
IChannelDescriptor channelDescriptor = event.getChannelDescriptor();
|
||||
|
||||
if(channelDescriptor != null)
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return channelDescriptor.toString() + " TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return channelDescriptor.toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.hasTimeslot())
|
||||
{
|
||||
return "TS:" + event.getTimeslot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
case COLUMN_FREQUENCY:
|
||||
return event.getChannelDescriptor();
|
||||
case COLUMN_DETAILS:
|
||||
return event.getDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_DURATION:
|
||||
case COLUMN_TIME:
|
||||
return Long.class;
|
||||
case COLUMN_DETAILS:
|
||||
case COLUMN_EVENT:
|
||||
return String.class;
|
||||
case COLUMN_FREQUENCY:
|
||||
case COLUMN_FROM_ALIAS:
|
||||
case COLUMN_FROM_ID:
|
||||
case COLUMN_TO_ALIAS:
|
||||
case COLUMN_TO_ID:
|
||||
return IdentifierCollection.class;
|
||||
case COLUMN_CHANNEL:
|
||||
return String.class;
|
||||
}
|
||||
return super.getColumnClass(columnIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,482 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2019 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.module.decode.event.filter.lastseen;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.filter.AllPassFilter;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventHistory;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventModel;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventClearHandler;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterButton;
|
||||
import io.github.dsheirer.module.decode.event.filter.EventFilterProvider;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class LastSeenPanel extends JPanel implements Listener<ProcessingChain>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(LastSeenPanel.class);
|
||||
private static final String TABLE_PREFERENCE_KEY = "decode.lastseen.panel";
|
||||
|
||||
private JTable mTable;
|
||||
private JTableColumnWidthMonitor mTableColumnWidthMonitor;
|
||||
private LastSeenModel mLastSeenModel;
|
||||
private DecodeEventHistory mCurrentEventHistory;
|
||||
private JScrollPane mEmptyScroller;
|
||||
private IconModel mIconModel;
|
||||
private AliasModel mAliasModel;
|
||||
private UserPreferences mUserPreferences;
|
||||
private TimestampCellRenderer mTimestampCellRenderer;
|
||||
private LastSeenManagementPanel mLastSeenManagementPanel;
|
||||
|
||||
/**
|
||||
* View for call event table
|
||||
* @param iconModel to display alias icons in table rows
|
||||
*/
|
||||
public LastSeenPanel(IconModel iconModel, UserPreferences userPreferences, AliasModel aliasModel)
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().register(this);
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||
mIconModel = iconModel;
|
||||
mAliasModel = aliasModel;
|
||||
mLastSeenModel = new LastSeenModel(aliasModel, iconModel);
|
||||
mUserPreferences = userPreferences;
|
||||
mTimestampCellRenderer = new TimestampCellRenderer();
|
||||
mTable = new JTable(mLastSeenModel);
|
||||
mTable.setAutoCreateRowSorter(true);
|
||||
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
mLastSeenManagementPanel = new LastSeenManagementPanel();
|
||||
mTableColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTable, TABLE_PREFERENCE_KEY);
|
||||
updateCellRenderers();
|
||||
|
||||
add(mLastSeenManagementPanel, "span,growx");
|
||||
|
||||
mEmptyScroller = new JScrollPane(mTable);
|
||||
add(mEmptyScroller);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
MyEventBus.getGlobalEventBus().unregister(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.DECODE_EVENT || preferenceType == PreferenceType.TALKGROUP_FORMAT)
|
||||
{
|
||||
EventQueue.invokeLater(() -> mTimestampCellRenderer.updatePreferences());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCellRenderers()
|
||||
{
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME)
|
||||
.setCellRenderer(mTimestampCellRenderer);
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION)
|
||||
.setCellRenderer(new DurationCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID)
|
||||
.setCellRenderer(new IdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS)
|
||||
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL)
|
||||
.setCellRenderer(new ChannelDescriptorCellRenderer());
|
||||
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ProcessingChain processingChain)
|
||||
{
|
||||
if(mCurrentEventHistory != null)
|
||||
{
|
||||
mCurrentEventHistory.removeListener(mLastSeenModel);
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
if(processingChain != null)
|
||||
{
|
||||
mCurrentEventHistory = processingChain.getDecodeEventHistory();
|
||||
mLastSeenModel.clearAndSet(mCurrentEventHistory.getItems());
|
||||
processingChain.getDecodeEventHistory().addListener(mLastSeenModel);
|
||||
mLastSeenManagementPanel.enableButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentEventHistory = null;
|
||||
mLastSeenModel.clearAndSet(Collections.emptyList());
|
||||
mLastSeenManagementPanel.disableButtons();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class LastSeenManagementPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private EventFilterButton<IDecodeEvent> mFilterButton;
|
||||
private EventClearButton mEventClearButton;
|
||||
|
||||
public LastSeenManagementPanel()
|
||||
{
|
||||
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
||||
|
||||
initializeFilterButton();
|
||||
initializeClearButton();
|
||||
disableButtons();
|
||||
|
||||
add(mFilterButton);
|
||||
add(mEventClearButton);
|
||||
}
|
||||
|
||||
public void enableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(true);
|
||||
mEventClearButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableButtons()
|
||||
{
|
||||
mFilterButton.setEnabled(false);
|
||||
mEventClearButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void initializeFilterButton()
|
||||
{
|
||||
EventFilterProvider<IDecodeEvent> filterProvider = (EventFilterProvider<IDecodeEvent>) mTable.getModel();
|
||||
FilterSet<IDecodeEvent> filterSet = new FilterSet<>(new AllPassFilter<>());
|
||||
if (filterProvider != null) {
|
||||
filterSet = filterProvider.getFilterSet();
|
||||
}
|
||||
mFilterButton = new EventFilterButton<>("Last Seen From Radio Filter Editor", filterSet);
|
||||
}
|
||||
|
||||
private void initializeClearButton() {
|
||||
mEventClearButton = new EventClearButton(
|
||||
((LastSeenModel) mTable.getModel()).getMaxMessageCount()
|
||||
);
|
||||
mEventClearButton.setEventClearHandler(new EventClearHandler() {
|
||||
@Override
|
||||
public void onHistoryLimitChanged(int newHistoryLimit) {
|
||||
((LastSeenModel) mTable.getModel()).setMaxMessageCount(newHistoryLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClearHistoryClicked() {
|
||||
((LastSeenModel) mTable.getModel()).clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom cell renderer for displaying identifiers from an identifier collection
|
||||
*/
|
||||
public class IdentifierCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
protected Role mRole;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the cell renderer.
|
||||
*
|
||||
* @param role of the identifier
|
||||
*/
|
||||
public IdentifierCellRenderer(Role role)
|
||||
{
|
||||
mRole = role;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof IdentifierCollection)
|
||||
{
|
||||
List<Identifier> identifiers = ((IdentifierCollection)value).getIdentifiers(mRole);
|
||||
label.setText(format(identifiers));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a list of identifiers as a comma separated list of values
|
||||
* @param identifiers to format
|
||||
* @return formatted list or null
|
||||
*/
|
||||
protected String format(List<Identifier> identifiers)
|
||||
{
|
||||
if(identifiers == null || identifiers.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
if(sb.length() > 0)
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
if(identifier.getForm() == Form.TALKGROUP)
|
||||
{
|
||||
sb.append(mUserPreferences.getTalkgroupFormatPreference().format(identifier));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(identifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell renderer for identifier aliases
|
||||
*/
|
||||
public class AliasedIdentifierCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private Role mRole;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the cell renderer.
|
||||
*
|
||||
* @param role of the identifier
|
||||
*/
|
||||
public AliasedIdentifierCellRenderer(Role role)
|
||||
{
|
||||
mRole = role;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
Color color = mTable.getForeground();
|
||||
ImageIcon icon = null;
|
||||
String text = null;
|
||||
|
||||
if(value instanceof IdentifierCollection)
|
||||
{
|
||||
IdentifierCollection identifierCollection = (IdentifierCollection)value;
|
||||
List<Identifier> identifiers = identifierCollection.getIdentifiers(mRole);
|
||||
|
||||
if(identifiers != null && !identifiers.isEmpty())
|
||||
{
|
||||
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
|
||||
|
||||
if(aliasList != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(Identifier identifier: identifiers)
|
||||
{
|
||||
List<Alias> aliases = aliasList.getAliases(identifier);
|
||||
|
||||
if(!aliases.isEmpty())
|
||||
{
|
||||
if(sb.length() > 0)
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(Joiner.on(", ").skipNulls().join(aliases));
|
||||
color = aliases.get(0).getDisplayColor();
|
||||
icon = mIconModel.getIcon(aliases.get(0).getIconName(), IconModel.DEFAULT_ICON_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
text = sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(text);
|
||||
label.setForeground(color);
|
||||
label.setIcon(icon);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public class TimestampCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private SimpleDateFormat mTimestampFormatter;
|
||||
|
||||
public TimestampCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
updatePreferences();
|
||||
}
|
||||
|
||||
public void updatePreferences()
|
||||
{
|
||||
mTimestampFormatter = mUserPreferences.getDecodeEventPreference().getTimestampFormat().getFormatter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof Long)
|
||||
{
|
||||
label.setText(mTimestampFormatter.format(new Date((long)value)));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public class DurationCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private DecimalFormat mDecimalFormat = new DecimalFormat("0.0");
|
||||
|
||||
public DurationCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
String formatted = null;
|
||||
|
||||
if(value instanceof Long)
|
||||
{
|
||||
long duration = (long)value;
|
||||
|
||||
if(duration > 0)
|
||||
{
|
||||
formatted = mDecimalFormat.format((double)duration / 1e3d);
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(formatted);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frequency value cell renderer
|
||||
*/
|
||||
public class FrequencyCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private DecimalFormat mFrequencyFormatter = new DecimalFormat("0.00000");
|
||||
|
||||
public FrequencyCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
String formatted = null;
|
||||
|
||||
if(value instanceof IChannelDescriptor)
|
||||
{
|
||||
IChannelDescriptor channelDescriptor = (IChannelDescriptor)value;
|
||||
|
||||
long frequency = channelDescriptor.getDownlinkFrequency();
|
||||
|
||||
if(frequency > 0)
|
||||
{
|
||||
formatted = mFrequencyFormatter.format(frequency / 1e6d);
|
||||
}
|
||||
}
|
||||
|
||||
label.setText(formatted);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel descriptor value cell renderer
|
||||
*/
|
||||
public class ChannelDescriptorCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
public ChannelDescriptorCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user