fix codacy warnings

This commit is contained in:
millmanorama 2018-04-07 16:19:14 +02:00
parent b5a50fd62a
commit 1bec33604b
11 changed files with 62 additions and 38 deletions

View File

@ -26,7 +26,6 @@ import org.openide.util.Utilities;
import org.openide.util.actions.Presenter;
/**
*
* Base class for actions that act on the selected AccountDeviceInstanceKeys.
* getPopupPresenter() provides a JMenuItem that works (i.e., has an icon) in
* custom context menus and also in the Netbeans Explorer views.
@ -39,8 +38,7 @@ abstract class AbstractCVTAction extends AbstractAction implements Presenter.Pop
* @return The selected accounts
*/
Collection<? extends AccountDeviceInstanceKey> getSelectedAccounts() {
final Collection<? extends AccountDeviceInstanceKey> lookupAll = Utilities.actionsGlobalContext().lookupAll(AccountDeviceInstanceKey.class);
return lookupAll;
return Utilities.actionsGlobalContext().lookupAll(AccountDeviceInstanceKey.class);
}
@Override
@ -64,5 +62,4 @@ abstract class AbstractCVTAction extends AbstractAction implements Presenter.Pop
* @return An ImageIcon used to represent this action.
*/
abstract ImageIcon getIcon();
}

View File

@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.communications;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.EventBus;
import java.util.Collection;
import java.util.Set;
import org.sleuthkit.datamodel.CommunicationsFilter;
/**

View File

@ -25,7 +25,6 @@ import com.google.common.collect.MultimapBuilder;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxICell;
import com.mxgraph.util.mxConstants;
import com.mxgraph.view.mxCellState;
import com.mxgraph.view.mxGraph;
import com.mxgraph.view.mxStylesheet;
import java.io.InputStream;
@ -38,7 +37,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.logging.Level;
import javax.swing.SwingWorker;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -96,7 +94,7 @@ final class CommunicationsGraph extends mxGraph {
CommunicationsGraph(PinnedAccountModel pinnedAccountModel, LockedVertexModel lockedVertexModel) {
super(mxStylesheet);
this.pinnedAccountModel =pinnedAccountModel;
this.pinnedAccountModel = pinnedAccountModel;
this.lockedVertexModel = lockedVertexModel;
//set fixed properties of graph.
setAutoSizeCells(true);
@ -243,20 +241,20 @@ final class CommunicationsGraph extends mxGraph {
*/
private class RebuildWorker extends SwingWorker<Void, Void> {
private final ProgressIndicator progress;
private final ProgressIndicator progressIndicator;
private final CommunicationsManager commsManager;
private final CommunicationsFilter currentFilter;
RebuildWorker(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
this.progress = progress;
this.progressIndicator = progress;
this.currentFilter = currentFilter;
this.commsManager = commsManager;
}
@Override
protected Void doInBackground() throws Exception {
progress.start("Loading accounts");
protected Void doInBackground() {
progressIndicator.start("Loading accounts");
int progressCounter = 0;
try {
/**
@ -278,7 +276,7 @@ final class CommunicationsGraph extends mxGraph {
final AccountDeviceInstanceKey relatedADIKey = new AccountDeviceInstanceKey(relatedADI, currentFilter, adiRelationshipsCount);
relatedAccounts.put(relatedADI, relatedADIKey); //store related accounts
}
progress.progress(++progressCounter);
progressIndicator.progress(++progressCounter);
}
Set<AccountDeviceInstance> accounts = relatedAccounts.keySet();
@ -286,9 +284,9 @@ final class CommunicationsGraph extends mxGraph {
Map<AccountPair, Long> relationshipCounts = commsManager.getRelationshipCountsPairwise(accounts, currentFilter);
int total = relationshipCounts.size();
int k = 0;
int progress = 0;
String progressText = "";
progress.switchToDeterminate("", 0, total);
progressIndicator.switchToDeterminate("", 0, total);
for (Map.Entry<AccountPair, Long> entry : relationshipCounts.entrySet()) {
Long count = entry.getValue();
AccountPair relationshipKey = entry.getKey();
@ -300,11 +298,10 @@ final class CommunicationsGraph extends mxGraph {
mxCell addEdge = addOrUpdateEdge(count, account1, account2);
progressText = addEdge.getId();
}
progress.progress(progressText, k++);
progressIndicator.progress(progressText, progress++);
}
} catch (TskCoreException tskCoreException) {
logger.log(Level.SEVERE, "Error", tskCoreException);
} finally {
}
return null;
@ -320,7 +317,7 @@ final class CommunicationsGraph extends mxGraph {
} catch (CancellationException ex) {
logger.log(Level.INFO, "Graph visualization cancelled");
} finally {
progress.finish();
progressIndicator.finish();
}
}
}

View File

@ -32,14 +32,6 @@ import java.util.Set;
*/
final class LockedVertexModel {
void registerhandler(Object handler) {
eventBus.register(handler);
}
void unregisterhandler(Object handler) {
eventBus.unregister(handler);
}
private final EventBus eventBus = new EventBus();
/**
@ -49,6 +41,16 @@ final class LockedVertexModel {
*/
private final Set<mxCell> lockedVertices = new HashSet<>();
void registerhandler(Object handler) {
eventBus.register(handler);
}
void unregisterhandler(Object handler) {
eventBus.unregister(handler);
}
/**
* Lock the given vertices so that applying a layout algorithm doesn't move
* them. The user can still manually position the vertices.

View File

@ -35,7 +35,6 @@ import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
import org.sleuthkit.datamodel.AccountDeviceInstance;
/**
* The right hand side of the CVT. Has a DataResultPanel to show a listing of

View File

@ -23,6 +23,10 @@ import javax.swing.ImageIcon;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
* Action that pins the AccountDevicesIntanceKeys in the ActionsGlobalContext to
* the visualizaion
*/
@NbBundle.Messages({"PinAccountsAction.pluralText=Add Selected Accounts to Visualization",
"PinAccountsAction.singularText=Add Selected Account to Visualization"})
final class PinAccountsAction extends AbstractCVTAction {
@ -31,7 +35,7 @@ final class PinAccountsAction extends AbstractCVTAction {
"/org/sleuthkit/autopsy/communications/images/marker--plus.png", false);
private static final String SINGULAR_TEXT = Bundle.PinAccountsAction_singularText();
private static final String PLURAL_TEXT = Bundle.PinAccountsAction_pluralText();
private static final PinAccountsAction instance = new PinAccountsAction();
static PinAccountsAction getInstance() {
@ -39,7 +43,7 @@ final class PinAccountsAction extends AbstractCVTAction {
}
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent event) {
CVTEvents.getCVTEventBus().post(new CVTEvents.PinAccountsEvent(getSelectedAccounts(), false));
}

View File

@ -19,9 +19,13 @@
package org.sleuthkit.autopsy.communications;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.EventBus;
import java.util.HashSet;
import java.util.Set;
/**
* Model of what accounts are pinned to a visualization.
*/
class PinnedAccountModel {
/**
@ -32,6 +36,16 @@ class PinnedAccountModel {
*/
private final Set<AccountDeviceInstanceKey> pinnedAccountDevices = new HashSet<>();
private final EventBus eventBus = new EventBus();
void registerhandler(Object handler) {
eventBus.register(handler);
}
void unregisterhandler(Object handler) {
eventBus.unregister(handler);
}
boolean isAccountPinned(AccountDeviceInstanceKey account) {
return pinnedAccountDevices.contains(account);
}

View File

@ -24,7 +24,8 @@ import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
*
* Action that clears any pinned accounts and pins the AcountDevicesInstanceKeys
* in the ActionsGlobalContext to the visualization.
*/
@NbBundle.Messages(value = {"ResetAndPinAccountsAction.singularText=Visualize Only Selected Account",
"ResetAndPinAccountsAction.pluralText=Visualize Only Selected Accounts"})
@ -42,7 +43,7 @@ final class ResetAndPinAccountsAction extends AbstractCVTAction {
}
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent event) {
CVTEvents.getCVTEventBus().post(new CVTEvents.PinAccountsEvent(getSelectedAccounts(), true));
}
@ -55,5 +56,4 @@ final class ResetAndPinAccountsAction extends AbstractCVTAction {
ImageIcon getIcon() {
return ICON;
}
}

View File

@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.communications;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -48,7 +47,7 @@ import org.sleuthkit.datamodel.TskCoreException;
*/
final class SelectionNode extends AbstractNode {
SelectionNode(Children children, Lookup lookup) {
private SelectionNode(Children children, Lookup lookup) {
super(children, lookup);
}
@ -130,9 +129,9 @@ final class SelectionNode extends AbstractNode {
}
@Override
protected Node createNodeForKey(Content t) {
if (t instanceof BlackboardArtifact) {
return new RelationshipNode((BlackboardArtifact) t);
protected Node createNodeForKey(Content content) {
if (content instanceof BlackboardArtifact) {
return new RelationshipNode((BlackboardArtifact) content);
} else {
throw new UnsupportedOperationException("Cannot create a RelationshipNode for non BlackboardArtifact content.");
}

View File

@ -23,6 +23,10 @@ import javax.swing.ImageIcon;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
* Action that unpins the AcccountDeviceInstanceKeys in the ActionsGlobalContext
* form the visualization.
*/
@NbBundle.Messages({"UnpinAccountsAction.pluralText=Remove Selected Accounts",
"UnpinAccountsAction.singularText=Remove Selected Account"})
final class UnpinAccountsAction extends AbstractCVTAction {

View File

@ -873,7 +873,10 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
}
}
private class CancelationListener implements ActionListener {
/**
* Listener that closes a ModalDialogProgreessIndicator when invoked.
*/
final private class CancelationListener implements ActionListener {
private Future<?> cancellable;
private ModalDialogProgressIndicator progress;
@ -891,6 +894,9 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
}
}
/**
* Action that un-locks the selected vertices.
*/
@NbBundle.Messages({
"VisualizationPanel.unlockAction.singularText=Unlock Selected Account",
"VisualizationPanel.unlockAction.pluralText=Unlock Selected Accounts",})
@ -911,6 +917,9 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
}
}
/**
* Action that locks the selected vertices.
*/
@NbBundle.Messages({
"VisualizationPanel.lockAction.singularText=Lock Selected Account",
"VisualizationPanel.lockAction.pluralText=Lock Selected Accounts"})