Skip to content

Commit

Permalink
#52: add limit (100) for number of properties selected
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeFcosta committed Feb 9, 2023
1 parent 2865e9b commit 5b277a5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ ColumnsManager.LoadingCols=Loading used columns...
ColumnsManager.Filter=[Type to filter]
ColumnsManager.ToggleSelectAll=Select / Unselect All
ColumnsManager.WindowsEvt=Windows Events
ColumnsManager.LimitReachedMessage=You can select up to {0} properties
ColumnsManager.LimitReachedTitle=Limit reached
CompositeViewer.Title=Viewer
CopyProperties.Copying=Copying
CopyProperties.CSVDateFormat=MM/dd/yyyy HH:mm:ss z
Expand Down
6 changes: 3 additions & 3 deletions iped-app/src/main/java/iped/app/ui/ColumnsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,15 @@ private void initializeAllCheckBoxesState() {
}

public List<String> getSelectedProperties() {
List<String> selectedColumns = new ArrayList<>();
List<String> selectedProperties = new ArrayList<>();
for (Map.Entry<String, Boolean> hmEntry : allCheckBoxesState.entrySet()) {
String fieldName = hmEntry.getKey();
Boolean checkBoxState = hmEntry.getValue();
if (checkBoxState == true) {
selectedColumns.add(LocalizedProperties.getNonLocalizedField(fieldName));
selectedProperties.add(LocalizedProperties.getNonLocalizedField(fieldName));
}
}
return selectedColumns;
return selectedProperties;
}

protected void enableOnlySelectedProperties(List<String> props) {
Expand Down
26 changes: 26 additions & 0 deletions iped-app/src/main/java/iped/app/ui/ColumnsSelectReportUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@

import java.util.Arrays;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JOptionPane;

import iped.engine.task.index.IndexItem;
import iped.localization.LocalizedProperties;

public class ColumnsSelectReportUI extends ColumnsSelectUI {
private static ColumnsSelectReportUI instance;
protected JButton clearButton = new JButton(Messages.getString("ColumnsManager.ClearButton"));

private final int PROPERTIES_LIMIT_NUM = 100;

private static final String[] basicReportProps = { IndexItem.NAME, IndexItem.PATH, IndexItem.TYPE, IndexItem.LENGTH, IndexItem.CREATED,
IndexItem.MODIFIED, IndexItem.ACCESSED, IndexItem.DELETED, IndexItem.CARVED, IndexItem.HASH, IndexItem.ID_IN_SOURCE };
Expand Down Expand Up @@ -68,4 +76,22 @@ protected ColumnsSelectReportUI() {
}
updatePanelList();
}

@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource().equals(clearButton)) {
columnsManager.disableAllProperties();
updatePanelList();
} else if (e.getSource() instanceof JCheckBox) {
if (columnsManager.getSelectedProperties().size() > PROPERTIES_LIMIT_NUM) {
JCheckBox source = (JCheckBox) e.getSource();
String nonLocalizedText = LocalizedProperties.getNonLocalizedField(source.getText());
JOptionPane.showMessageDialog(dialog, Messages.getString("ColumnsManager.LimitReachedMessage", PROPERTIES_LIMIT_NUM),
Messages.getString("ColumnsManager.LimitReachedTitle"), JOptionPane.ERROR_MESSAGE);
columnsManager.allCheckBoxesState.put(nonLocalizedText, false);
updatePanelList();
}
}
}
}
6 changes: 1 addition & 5 deletions iped-app/src/main/java/iped/app/ui/ColumnsSelectUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class ColumnsSelectUI extends ColumnsManagerUI {

protected JCheckBox toggleSelectUnselectAllCheckBox = new JCheckBox(Messages.getString("ColumnsManager.ToggleSelectAll"));
protected JButton selectVisibleButton = new JButton(Messages.getString("ColumnsManager.SelectVisible"));
protected JButton clearButton = new JButton(Messages.getString("ColumnsManager.ClearButton"));

protected JButton okButton = new JButton("OK");

Expand Down Expand Up @@ -109,9 +108,6 @@ public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(selectVisibleButton)) {
columnsManager.enableOnlySelectedProperties(columnsManager.colState.visibleFields);
updatePanelList();
} else if (e.getSource().equals(clearButton)) {
columnsManager.disableAllProperties();
updatePanelList();
} else if (e.getSource().equals(toggleSelectUnselectAllCheckBox)) {
if (toggleSelectUnselectAllCheckBox.isSelected()) {
columnsManager.enableAllProperties();
Expand All @@ -125,7 +121,7 @@ public void actionPerformed(ActionEvent e) {
columnsManager.saveSelectedProps(saveFileName);
okButtonClicked = true;
dispose();
} else { // checkbox
} else if (e.getSource() instanceof JCheckBox) {
JCheckBox source = (JCheckBox) e.getSource();
String nonLocalizedText = LocalizedProperties.getNonLocalizedField(source.getText());
boolean isSelected = source.isSelected();
Expand Down

0 comments on commit 5b277a5

Please sign in to comment.