Skip to content

Commit

Permalink
'#1973 Improves code adding the method addSelection to replace redundant
Browse files Browse the repository at this point in the history
code.
  • Loading branch information
patrickdalla committed Nov 16, 2023
1 parent 4228855 commit 2917d16
Showing 2 changed files with 18 additions and 29 deletions.
31 changes: 17 additions & 14 deletions iped-geo/src/main/java/iped/geo/impl/AppMapPanel.java
Original file line number Diff line number Diff line change
@@ -315,27 +315,30 @@ private void syncSelectedItems() {
for (int i = 0; i < selected.length; i++) {
int rowModel = resultsTable.convertRowIndexToModel(selected[i]);
IItemId item = results.getItem(rowModel);

if (kmlResult != null && kmlResult.getGPSItems().containsKey(item)) {
List<Integer> subitems = kmlResult.getGPSItems().get(item);
if (subitems == null) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId(); //$NON-NLS-1$ //$NON-NLS-2$
selecoes.put(gid, true);
} else {
for (Integer subitem : subitems) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId() + "_" //$NON-NLS-1$ //$NON-NLS-2$
+ subitem;
selecoes.put(gid, true);
}
}
}
addSelection(selecoes, item);
}

mapViewer.updateMapLeadCursor();

browserCanvas.sendSelection(selecoes);
}

public void addSelection(HashMap<String, Boolean> selecoes, IItemId item) {
if (kmlResult != null && kmlResult.getGPSItems().containsKey(item)) {
List<Integer> subitems = kmlResult.getGPSItems().get(item);
if (subitems == null) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId(); //$NON-NLS-1$ //$NON-NLS-2$
selecoes.put(gid, true);
} else {
for (Integer subitem : subitems) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId() + "_" //$NON-NLS-1$ //$NON-NLS-2$
+ subitem;
selecoes.put(gid, true);
}
}
}
}

@Override
public void accept(Object[] result) {
KMLResult kmlResult = (KMLResult) result[0];
16 changes: 1 addition & 15 deletions iped-geo/src/main/java/iped/geo/impl/MapViewer.java
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;

import javax.swing.JPanel;
@@ -218,20 +217,7 @@ public void run() {
int rowModel = resultsTable.convertRowIndexToModel(i);

IItemId item = results.getItem(rowModel);

if (mapaPanel.kmlResult != null && mapaPanel.kmlResult.getGPSItems().containsKey(item)) {
List<Integer> subitems = mapaPanel.kmlResult.getGPSItems().get(item);
if (subitems == null) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId(); //$NON-NLS-1$ //$NON-NLS-2$
selecoes.put(gid, selected);
} else {
for (Integer subitem : subitems) {
String gid = "marker_" + item.getSourceId() + "_" + item.getId() + "_" //$NON-NLS-1$ //$NON-NLS-2$
+ subitem;
selecoes.put(gid, selected);
}
}
}
mapaPanel.addSelection(selecoes, item);
} catch (Exception e) {
e.printStackTrace();
}

0 comments on commit 2917d16

Please sign in to comment.