mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 08:56:15 +00:00
Merge pull request #3728 from millmanorama/985-suppress-NPE
show warning in less intrusive JFX notifications instead of Message b…
This commit is contained in:
commit
daf24eb84c
@ -11,7 +11,7 @@
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,110,0,0,3,65"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-93,0,0,3,71"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
@ -49,9 +49,9 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace pref="71" max="32767" attributes="0"/>
|
||||
<Component id="jTextArea1" min="-2" pref="424" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace pref="248" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -120,7 +120,7 @@
|
||||
<Component id="zoomActualButton" min="-2" pref="33" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="fitZoomButton" min="-2" pref="32" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="12" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -312,6 +312,17 @@
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javafx.embed.swing.JFXPanel" name="notificationsJFXPanel">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Last"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
|
@ -44,6 +44,7 @@ import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
@ -57,14 +58,18 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javafx.application.Platform;
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
@ -78,6 +83,7 @@ import javax.swing.JToolBar;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.controlsfx.control.Notifications;
|
||||
import org.jdesktop.layout.GroupLayout;
|
||||
import org.jdesktop.layout.LayoutStyle;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
@ -89,7 +95,6 @@ import org.openide.util.lookup.ProxyLookup;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
||||
import org.sleuthkit.autopsy.progress.ModalDialogProgressIndicator;
|
||||
import org.sleuthkit.datamodel.CommunicationsFilter;
|
||||
@ -142,12 +147,43 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
private final Map<NamedGraphLayout, JButton> layoutButtons = new HashMap<>();
|
||||
private NamedGraphLayout currentLayout;
|
||||
|
||||
@NbBundle.Messages("VisalizationPanel.paintingError=Problem painting visualization.")
|
||||
public VisualizationPanel() {
|
||||
initComponents();
|
||||
//initialize invisible JFXPanel that is used to show JFXNotifications over this window.
|
||||
notificationsJFXPanel.setScene(new Scene(new Pane()));
|
||||
|
||||
graph = new CommunicationsGraph(pinnedAccountModel, lockedVertexModel);
|
||||
|
||||
graphComponent = new mxGraphComponent(graph);
|
||||
/*
|
||||
* custom implementation of mxGraphComponent that uses... a custom
|
||||
* implementation of mxGraphControl ... that overrides paint so we can
|
||||
* catch the NPEs we are getting and deal with them. For now that means
|
||||
* just ignoring them.
|
||||
*/
|
||||
graphComponent = new mxGraphComponent(graph) {
|
||||
@Override
|
||||
protected mxGraphComponent.mxGraphControl createGraphControl() {
|
||||
|
||||
return new mxGraphControl() {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics graphics) {
|
||||
try {
|
||||
super.paint(graphics);
|
||||
} catch (NullPointerException ex) { //NOPMD
|
||||
/* We can't find the underlying cause of the NPE in
|
||||
* jgraphx, but it doesn't seem to cause any
|
||||
* noticeable problems, so we are just logging it
|
||||
* and moving on.
|
||||
*/
|
||||
logger.log(Level.WARNING, "There was a NPE while painting the VisualizationPanel", ex);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
graphComponent.setAutoExtend(true);
|
||||
graphComponent.setAutoScroll(true);
|
||||
graphComponent.setAutoscrolls(true);
|
||||
@ -350,6 +386,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
zoomLabel = new JLabel();
|
||||
clearVizButton = new JButton();
|
||||
jSeparator2 = new JToolBar.Separator();
|
||||
notificationsJFXPanel = new JFXPanel();
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
@ -368,9 +405,9 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
placeHolderPanel.setLayout(placeHolderPanelLayout);
|
||||
placeHolderPanelLayout.setHorizontalGroup(placeHolderPanelLayout.createParallelGroup(GroupLayout.LEADING)
|
||||
.add(placeHolderPanelLayout.createSequentialGroup()
|
||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap(71, Short.MAX_VALUE)
|
||||
.add(jTextArea1, GroupLayout.PREFERRED_SIZE, 424, GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(248, Short.MAX_VALUE))
|
||||
);
|
||||
placeHolderPanelLayout.setVerticalGroup(placeHolderPanelLayout.createParallelGroup(GroupLayout.LEADING)
|
||||
.add(placeHolderPanelLayout.createSequentialGroup()
|
||||
@ -499,7 +536,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
.add(zoomActualButton, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(LayoutStyle.RELATED)
|
||||
.add(fitZoomButton, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(12, Short.MAX_VALUE))
|
||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
toolbarLayout.setVerticalGroup(toolbarLayout.createParallelGroup(GroupLayout.LEADING)
|
||||
.add(toolbarLayout.createSequentialGroup()
|
||||
@ -523,6 +560,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
);
|
||||
|
||||
borderLayoutPanel.add(toolbar, BorderLayout.PAGE_START);
|
||||
borderLayoutPanel.add(notificationsJFXPanel, BorderLayout.PAGE_END);
|
||||
|
||||
splitPane.setLeftComponent(borderLayoutPanel);
|
||||
|
||||
@ -584,12 +622,15 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
get();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
logger.log(Level.WARNING, "CVT graph layout failed.", ex);
|
||||
if (lockedVertexModel.isEmpty()) {
|
||||
MessageNotifyUtil.Message.error(Bundle.VisualizationPanel_layoutFail_text(layout.getDisplayName()));
|
||||
} else {
|
||||
MessageNotifyUtil.Message.error(Bundle.VisualizationPanel_layoutFailWithLockedVertices_text(layout.getDisplayName()));
|
||||
}
|
||||
undoManager.undo();
|
||||
String message = (lockedVertexModel.isEmpty())
|
||||
? Bundle.VisualizationPanel_layoutFail_text(layout.getDisplayName())
|
||||
: Bundle.VisualizationPanel_layoutFailWithLockedVertices_text(layout.getDisplayName());
|
||||
|
||||
Platform.runLater(()
|
||||
-> Notifications.create().owner(notificationsJFXPanel.getScene().getWindow())
|
||||
.text(message)
|
||||
.showWarning()
|
||||
);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
@ -646,6 +687,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
private JToolBar.Separator jSeparator1;
|
||||
private JToolBar.Separator jSeparator2;
|
||||
private JTextArea jTextArea1;
|
||||
private JFXPanel notificationsJFXPanel;
|
||||
private JButton organicLayoutButton;
|
||||
private JPanel placeHolderPanel;
|
||||
private JSplitPane splitPane;
|
||||
@ -724,7 +766,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
@Override
|
||||
public boolean isVertexIgnored(Object vertex) {
|
||||
return super.isVertexIgnored(vertex)
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -755,7 +797,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
@Override
|
||||
public boolean isVertexIgnored(Object vertex) {
|
||||
return super.isVertexIgnored(vertex)
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -786,7 +828,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
@Override
|
||||
public boolean isVertexIgnored(Object vertex) {
|
||||
return super.isVertexIgnored(vertex)
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -816,7 +858,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
||||
@Override
|
||||
public boolean isVertexIgnored(Object vertex) {
|
||||
return super.isVertexIgnored(vertex)
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
|| lockedVertexModel.isVertexLocked((mxCell) vertex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user