Skip to content

Commit

Permalink
'#1864 Adds support for multiple group selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdalla committed Feb 22, 2024
1 parent daae03c commit 16a5caf
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 91 deletions.
48 changes: 27 additions & 21 deletions iped-app/src/main/java/iped/app/timelinegraph/IpedChartsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.font.TextAttribute;
Expand Down Expand Up @@ -42,7 +42,6 @@

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
Expand Down Expand Up @@ -100,6 +99,7 @@
import iped.app.ui.ClearFilterListener;
import iped.app.ui.ColumnsManager;
import iped.app.ui.controls.CheckboxListCellRenderer;
import iped.app.ui.controls.JComboCheckBox;
import iped.app.ui.themes.ThemeManager;
import iped.data.IItemId;
import iped.engine.search.QueryBuilder;
Expand All @@ -118,7 +118,7 @@
* @author Patrick Dalla Bernardina
*/
public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableModelListener, ListSelectionListener,
IQueryFilterer, ClearFilterListener, ComponentListener, ItemListener {
IQueryFilterer, ClearFilterListener, ComponentListener, ActionListener {
JTable resultsTable;
IMultiSearchResultProvider resultsProvider;
GUIProvider guiProvider;
Expand Down Expand Up @@ -154,7 +154,7 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod
IpedChartPanel chartPanel = null;
JList legendList = new JList();
JScrollPane listScroller = new JScrollPane(legendList);
JComboBox<TimeEventGroup> tegCombo = new JComboBox<>();
JComboCheckBox<TimeEventGroup> tegCombo = new JComboCheckBox<>();

IpedStackedXYBarRenderer renderer = null;
XYLineAndShapeRenderer highlightsRenderer = new XYLineAndShapeRenderer();
Expand All @@ -180,7 +180,7 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod

Color fgColor;
Color bgColor;
private TimeEventGroup currentTeGroup = TimeEventGroup.BASIC_EVENTS;
private ArrayList<TimeEventGroup> selectedTeGroups = new ArrayList<TimeEventGroup>();

private static final String resPath = '/' + App.class.getPackageName().replace('.', '/') + '/';

Expand All @@ -205,6 +205,7 @@ public IpedChartsPanel(boolean b) {
super(b);

this.setLayout(new GridLayout());

}

class LegendCellRenderer extends JLabel implements ListCellRenderer<LegendItemBlockContainer> {
Expand Down Expand Up @@ -299,15 +300,17 @@ public void init(JTable resultsTable, IMultiSearchResultProvider resultsProvider


chartPanel = new IpedChartPanel(chart, this);
tegCombo.setRenderer(new CheckboxListCellRenderer<TimeEventGroup>(new Predicate<TimeEventGroup>() {
@Override
public boolean test(TimeEventGroup t) {
return true;
}
}));
chartPanel.add(tegCombo);

tegCombo.addItemListener(this);
CheckboxListCellRenderer cblcRenderer = new CheckboxListCellRenderer<TimeEventGroup>(
new Predicate<TimeEventGroup>() {
@Override
public boolean test(TimeEventGroup t) {
return selectedTeGroups.contains(t);
}
});
tegCombo.setRenderer(cblcRenderer);
chartPanel.add(tegCombo);
tegCombo.addActionListener(this);

legendListModel = new DefaultListModel<LegendItemBlockContainer>();
legendList.setModel(legendListModel);
Expand Down Expand Up @@ -418,15 +421,15 @@ public HashMap<String, AbstractIntervalXYDataset> createDataSets() {
if (selectedBookmarks.size() > 0 && chartPanel.getSplitByBookmark()) {
for (String bookmark : selectedBookmarks) {
result.put(bookmark,
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, bookmark));
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, selectedTeGroups, bookmark));
}
} else if (selectedCategories.size() > 0 && chartPanel.getSplitByCategory()) {
for (String category : selectedCategories) {
result.put(category,
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, category));
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, selectedTeGroups, category));
}
} else {
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, null));
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, selectedTeGroups, null));
}
return result;
} catch (Exception e) {
Expand Down Expand Up @@ -1112,10 +1115,13 @@ public static String[] getOrdToEventName() {
}

@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
currentTeGroup = (TimeEventGroup) e.getItem();
refreshChart(true);
public void actionPerformed(ActionEvent e) {
TimeEventGroup teGroup = (TimeEventGroup) tegCombo.getSelectedItem();
if (selectedTeGroups.contains(teGroup)) {
selectedTeGroups.remove(teGroup);
} else {
selectedTeGroups.add(teGroup);
}
refreshChart(false);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package iped.app.timelinegraph;

import java.util.Collection;
import java.util.HashSet;

import org.roaringbitmap.RoaringBitmap;

/**
* Class that represents a collection of event to use as a filter to graph
* events viewing. Also, the cache will be managed/persisted based on this event
Expand All @@ -14,6 +17,7 @@ public class TimeEventGroup {
public static final TimeEventGroup BASIC_EVENTS = new TimeEventGroup("BasicProperties");

HashSet eventNames = new HashSet<String>();
RoaringBitmap eventOrds = new RoaringBitmap();

String name;

Expand Down Expand Up @@ -50,12 +54,21 @@ public String getName() {
return name;
}

public void addEvent(String eventName) {
public void addEvent(String eventName, int ord) {
eventNames.add(eventName);
eventOrds.add(ord);
}

@Override
public String toString() {
return name;
}

public Collection<? extends String> getEventNames() {
return eventNames;
}

public RoaringBitmap getEventOrds() {
return eventOrds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class IndexTimeStampCache implements TimeStampCache {
IMultiSearchResultProvider resultsProvider;
IpedChartsPanel ipedChartsPanel;
TimeZone timezone;
TimeEventGroup teGroup = TimeEventGroup.ALL_EVENTS;//default TimeEventGroup
TimeEventGroup teGroup;// default TimeEventGroup

TimeIndexedMap newCache = new TimeIndexedMap();

Expand Down Expand Up @@ -73,7 +73,7 @@ public void run() {
for (Class periodClasses : periodClassesToCache) {
CachePersistance cp = CachePersistance.getInstance();
try {
TimeIndexedMap c = cp.loadNewCache(periodClasses);
TimeIndexedMap c = cp.loadNewCache(teGroup, periodClasses);
if (c != null) {
cacheExists = true;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public void run() {
} else {
CachePersistance cp = CachePersistance.getInstance();
for (Class periodClasses : periodClassesToCache) {
newCache.setIndexFile(periodClasses.getSimpleName(), cp.getBaseDir());
newCache.setIndexFile(teGroup, periodClasses.getSimpleName(), cp.getBaseDir());
}
newCache.createOrLoadUpperPeriodIndex(this);
}
Expand Down Expand Up @@ -318,4 +318,14 @@ public TimeEventGroup getTimeEventGroup() {
return this.teGroup;
}

@Override
public boolean isFromEventGroup(ArrayList<TimeEventGroup> selectedTeGroups) {
for (TimeEventGroup teGroup : selectedTeGroups) {
if (isFromEventGroup(teGroup)) {
return true;
}
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ public void setIndexFile(TimeEventGroup teGroup, String periodName, File f) thro
}
}

public void setIndexFile(String periodName, File f) throws IOException {
}

Date lastStartDate = null;
Date lastEndDate = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ public interface TimeStampCache extends Runnable {
public void setTimeEventGroup(TimeEventGroup teGroup);

public TimeEventGroup getTimeEventGroup();

public boolean isFromEventGroup(ArrayList<TimeEventGroup> selectedTeGroups);
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,25 @@ public void run() {
}
}

public TimeIndexedMap loadNewCache(Class<? extends TimePeriod> className) throws IOException {
public TimeIndexedMap loadNewCache(TimeEventGroup teGroup, Class<? extends TimePeriod> className)
throws IOException {
TimeIndexedMap newCache = null;

for (File f : baseDir.listFiles()) {
if (f.getName().equals(className.getSimpleName())) {
newCache = new TimeIndexedMap();
newCache.setIndexFile(className.getSimpleName(), baseDir);
break;
File[] files = baseDir.listFiles();
if (files != null) {
for (File f : files) {
if (f.getName().equals(teGroup.getName())) {
File[] files2 = f.listFiles();
if (files2 != null) {
for (File f2 : files2) {
if (f2.getName().equals(className.getSimpleName())) {
newCache = new TimeIndexedMap();
newCache.setIndexFile(teGroup, className.getSimpleName(), baseDir);
break;
}
}
}
}
}
}

Expand Down
Loading

0 comments on commit 16a5caf

Please sign in to comment.