Merge pull request #7484 from kellykelly3/8126-fixed-account-node-icons

8126 Fixed the communication account icons
This commit is contained in:
Ann Priestman 2021-12-22 13:02:16 -05:00 committed by GitHub
commit ef653d004d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 5 deletions

View File

@ -25,7 +25,7 @@ import java.util.TimeZone;
import javax.swing.table.TableCellRenderer;
import org.netbeans.swing.outline.Outline;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.datamodel.accounts.Accounts;
import org.sleuthkit.autopsy.datamodel.utils.IconsUtil;
import org.sleuthkit.datamodel.Account;
/**
@ -48,7 +48,7 @@ public final class Utils {
* @return The path of the icon for the given Account Type.
*/
static public final String getIconFilePath(Account.Type type) {
return Accounts.getIconFilePath(type);
return IconsUtil.getIconFilePath(type);
}
static public void setColumnWidths(Outline outline) {

View File

@ -18,6 +18,7 @@
*/
package org.sleuthkit.autopsy.datamodel.utils;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
@ -25,6 +26,8 @@ import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
* Utility methods for handling icons
*/
public final class IconsUtil {
private static final String ICON_BASE_PATH = "/org/sleuthkit/autopsy/images/"; //NON-NLS
private IconsUtil() {
@ -150,4 +153,38 @@ public final class IconsUtil {
}
return "/org/sleuthkit/autopsy/images/" + imageFile;
}
/**
* Get the path of the icon for the given Account Type.
*
* @return The path of the icon for the given Account Type.
*/
public static String getIconFilePath(Account.Type type) {
if (type.equals(Account.Type.CREDIT_CARD)) {
return ICON_BASE_PATH + "credit-card.png";
} else if (type.equals(Account.Type.DEVICE)) {
return ICON_BASE_PATH + "image.png";
} else if (type.equals(Account.Type.EMAIL)) {
return ICON_BASE_PATH + "email.png";
} else if (type.equals(Account.Type.FACEBOOK)) {
return ICON_BASE_PATH + "facebook.png";
} else if (type.equals(Account.Type.INSTAGRAM)) {
return ICON_BASE_PATH + "instagram.png";
} else if (type.equals(Account.Type.MESSAGING_APP)) {
return ICON_BASE_PATH + "messaging.png";
} else if (type.equals(Account.Type.PHONE)) {
return ICON_BASE_PATH + "phone.png";
} else if (type.equals(Account.Type.TWITTER)) {
return ICON_BASE_PATH + "twitter.png";
} else if (type.equals(Account.Type.WEBSITE)) {
return ICON_BASE_PATH + "web-file.png";
} else if (type.equals(Account.Type.WHATSAPP)) {
return ICON_BASE_PATH + "WhatsApp.png";
} else {
//there could be a default icon instead...
return ICON_BASE_PATH + "face.png";
// throw new IllegalArgumentException("Unknown Account.Type: " + type.getTypeName());
}
}
}

View File

@ -45,6 +45,7 @@ import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION_UNITS;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_SIZE;
import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableSearchResultsDTO.CommAccoutTableSearchResultsDTO;
import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO.TreeDisplayCount;
import org.sleuthkit.autopsy.mainui.datamodel.events.CommAccountsEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEvent;
@ -155,7 +156,7 @@ public class CommAccountsDAO extends AbstractDAO {
DataArtifactDAO dataArtDAO = MainDAO.getInstance().getDataArtifactsDAO();
BlackboardArtifactDAO.TableData tableData = dataArtDAO.createTableData(BlackboardArtifact.Type.TSK_ACCOUNT, pagedArtifacts);
return new DataArtifactTableSearchResultsDTO(BlackboardArtifact.Type.TSK_ACCOUNT, tableData.columnKeys, tableData.rows, cacheKey.getStartItem(), allArtifacts.size());
return new CommAccoutTableSearchResultsDTO(type, BlackboardArtifact.Type.TSK_ACCOUNT, tableData.columnKeys, tableData.rows, cacheKey.getStartItem(), allArtifacts.size());
}
private static TreeResultsDTO.TreeItemDTO<CommAccountsSearchParams> createAccountTreeItem(Account.Type accountType, Long dataSourceId, TreeResultsDTO.TreeDisplayCount count) {

View File

@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.mainui.datamodel;
import java.util.List;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.BlackboardArtifact;
/**
@ -39,4 +40,19 @@ public class DataArtifactTableSearchResultsDTO extends BaseSearchResultsDTO {
public BlackboardArtifact.Type getArtifactType() {
return artifactType;
}
public static class CommAccoutTableSearchResultsDTO extends DataArtifactTableSearchResultsDTO {
private final Account.Type accountType;
public CommAccoutTableSearchResultsDTO(Account.Type accountType, BlackboardArtifact.Type artifactType, List<ColumnKey> columns, List<RowDTO> items, long startItem, long totalResultsCount) {
super(artifactType, columns, items, startItem, totalResultsCount);
this.accountType = accountType;
}
public Account.Type getAccountType() {
return accountType;
}
}
}

View File

@ -25,6 +25,7 @@ import org.sleuthkit.autopsy.datamodel.utils.IconsUtil;
import org.sleuthkit.autopsy.datamodel.DataArtifactItem;
import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactRowDTO;
import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableSearchResultsDTO;
import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableSearchResultsDTO.CommAccoutTableSearchResultsDTO;
import org.sleuthkit.datamodel.DataArtifact;
/**
@ -44,10 +45,18 @@ public class DataArtifactNode extends ArtifactNode<DataArtifact, DataArtifactRow
}
public DataArtifactNode(DataArtifactTableSearchResultsDTO tableData, DataArtifactRowDTO artifactRow) {
this(tableData, artifactRow, IconsUtil.getIconFilePath(tableData.getArtifactType().getTypeID()));
this(tableData, artifactRow, getIconFilePath(tableData));
}
public DataArtifactNode(DataArtifactTableSearchResultsDTO tableData, DataArtifactRowDTO artifactRow, String iconPath) {
super(artifactRow, tableData.getColumns(), tableData.getArtifactType(), createLookup(artifactRow), iconPath);
}
private static String getIconFilePath(DataArtifactTableSearchResultsDTO tableData) {
if(!(tableData instanceof CommAccoutTableSearchResultsDTO)) {
return IconsUtil.getIconFilePath(tableData.getArtifactType().getTypeID());
}
return IconsUtil.getIconFilePath(((CommAccoutTableSearchResultsDTO)tableData).getAccountType());
}
}

View File

@ -255,7 +255,7 @@ public class DataArtifactTypeFactory extends TreeChildFactory<DataArtifactSearch
*/
public AccountTypeNode(TreeResultsDTO.TreeItemDTO<? extends CommAccountsSearchParams> itemData) {
super(itemData.getSearchParams().getType().getTypeName(),
Accounts.getIconFilePath(itemData.getSearchParams().getType()),
IconsUtil.getIconFilePath(itemData.getSearchParams().getType()),
itemData);
}

View File

@ -18,3 +18,5 @@ ActionsFactory_getTimelineSrcContentAction_actionDisplayName=View Source {0} in
ActionsFactory_viewFileInDir_text=View File in Directory
# {0} - contentType
ArtifactFactory_getViewSrcContentAction_displayName=View Source {0} in Directory
# {0} - contentType
ArtifactFactory_getViewSrcContentAction_displayName2=View Source {0}