mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-08 06:09:32 +00:00
Make the toolbar be singleton and initialized once.
Solves TSK-564 Toolbar widgets sometimes disabled
This commit is contained in:
parent
c78462d6a4
commit
e8d16d5588
@ -16,17 +16,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.sleuthkit.autopsy.ingest;
|
package org.sleuthkit.autopsy.ingest;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import org.openide.util.actions.Presenter;
|
import org.openide.util.actions.Presenter;
|
||||||
import org.openide.windows.Mode;
|
|
||||||
import org.openide.windows.WindowManager;
|
|
||||||
|
|
||||||
|
|
||||||
//@ActionID(category = "File",
|
//@ActionID(category = "File",
|
||||||
//id = "org.sleuthkit.autopsy.ingest.IngestMessagesAction")
|
//id = "org.sleuthkit.autopsy.ingest.IngestMessagesAction")
|
||||||
@ -40,11 +35,10 @@ public final class IngestMessagesAction extends AbstractAction implements Prese
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getToolbarPresenter() {
|
public Component getToolbarPresenter() {
|
||||||
return new IngestMessagesToolbar();
|
return IngestMessagesToolbar.getDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
@ -37,17 +37,30 @@ import org.sleuthkit.autopsy.casemodule.Case;
|
|||||||
public class IngestMessagesToolbar extends javax.swing.JPanel {
|
public class IngestMessagesToolbar extends javax.swing.JPanel {
|
||||||
|
|
||||||
private IngestMessagesButton ingestMessagesButton = new IngestMessagesButton();
|
private IngestMessagesButton ingestMessagesButton = new IngestMessagesButton();
|
||||||
|
private static IngestMessagesToolbar instance;
|
||||||
|
|
||||||
/** Creates new form IngestMessagesToolbar */
|
/**
|
||||||
public IngestMessagesToolbar() {
|
* Creates new form IngestMessagesToolbar
|
||||||
|
*/
|
||||||
|
private IngestMessagesToolbar() {
|
||||||
initComponents();
|
initComponents();
|
||||||
customizeComponents();
|
customizeComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* @return the default instance IngestMessagesToolbar
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
*/
|
||||||
* always regenerated by the Form Editor.
|
public static IngestMessagesToolbar getDefault() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new IngestMessagesToolbar();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
@ -82,7 +95,6 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
ingestMessagesButton.setMinimumSize(new java.awt.Dimension(38, 24));
|
ingestMessagesButton.setMinimumSize(new java.awt.Dimension(38, 24));
|
||||||
ingestMessagesButton.setPreferredSize(new java.awt.Dimension(38, 24));
|
ingestMessagesButton.setPreferredSize(new java.awt.Dimension(38, 24));
|
||||||
ingestMessagesButton.addActionListener(new java.awt.event.ActionListener() {
|
ingestMessagesButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
showIngestMessages();
|
showIngestMessages();
|
||||||
@ -98,7 +110,6 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
this.setBorder(null);
|
this.setBorder(null);
|
||||||
|
|
||||||
IngestMessagePanel.addPropertyChangeSupportListener(new PropertyChangeListener() {
|
IngestMessagePanel.addPropertyChangeSupportListener(new PropertyChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
final int numberMessages = (Integer) evt.getNewValue();
|
final int numberMessages = (Integer) evt.getNewValue();
|
||||||
@ -110,7 +121,6 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Case.addPropertyChangeListener(new PropertyChangeListener() {
|
Case.addPropertyChangeListener(new PropertyChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
if (evt.getPropertyName().equals(Case.CASE_CURRENT_CASE)) {
|
if (evt.getPropertyName().equals(Case.CASE_CURRENT_CASE)) {
|
||||||
@ -140,7 +150,6 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
|
|
||||||
private static class IngestMessagesButton extends JButton {
|
private static class IngestMessagesButton extends JButton {
|
||||||
|
|
||||||
|
|
||||||
private static final int fontSize = 9;
|
private static final int fontSize = 9;
|
||||||
private static final Font messagesFont = new java.awt.Font("Tahoma", Font.PLAIN, fontSize);
|
private static final Font messagesFont = new java.awt.Font("Tahoma", Font.PLAIN, fontSize);
|
||||||
private int messages = 0;
|
private int messages = 0;
|
||||||
@ -149,8 +158,9 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
|
|
||||||
if (messages == 0)
|
if (messages == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
//paint text
|
//paint text
|
||||||
String messageStr = Integer.toString(messages);
|
String messageStr = Integer.toString(messages);
|
||||||
final int len = messageStr.length();
|
final int len = messageStr.length();
|
||||||
@ -158,13 +168,14 @@ public class IngestMessagesToolbar extends javax.swing.JPanel {
|
|||||||
|
|
||||||
int dx = len * 5 + 5;
|
int dx = len * 5 + 5;
|
||||||
int x = getSize().width - dx;
|
int x = getSize().width - dx;
|
||||||
if (x<0)
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
|
}
|
||||||
g.setColor(Color.GRAY);
|
g.setColor(Color.GRAY);
|
||||||
//g.fillRect(x, 1, dx, fontSize);
|
//g.fillRect(x, 1, dx, fontSize);
|
||||||
g.fillRoundRect(x, 1, dx, fontSize, 2, 2);
|
g.fillRoundRect(x, 1, dx, fontSize, 2, 2);
|
||||||
g.setColor(Color.WHITE);
|
g.setColor(Color.WHITE);
|
||||||
g.drawString(messageStr, x+2, fontSize);
|
g.drawString(messageStr, x + 2, fontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMessages(int messages) {
|
void setMessages(int messages) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user