mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #2704 from wschaeferB/2483-PasteKeywordNewline
2483 add new line before pasting into keywords list jTextArea
This commit is contained in:
commit
d34187ee04
@ -125,17 +125,6 @@
|
|||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
<SubComponents>
|
|
||||||
<Component class="javax.swing.JTextArea" name="keywordTextArea">
|
|
||||||
<Properties>
|
|
||||||
<Property name="columns" type="int" value="20"/>
|
|
||||||
<Property name="rows" type="int" value="5"/>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="keywordTextAreaMouseClicked"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
|
||||||
</Container>
|
</Container>
|
||||||
<Component class="javax.swing.JLabel" name="enterKeywordsLabel">
|
<Component class="javax.swing.JLabel" name="enterKeywordsLabel">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2016 Basis Technology Corp.
|
* Copyright 2011-2017 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -40,40 +40,24 @@ import org.openide.windows.WindowManager;
|
|||||||
class AddKeywordsDialog extends javax.swing.JDialog {
|
class AddKeywordsDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
List<String> newKeywords = new ArrayList<>();
|
List<String> newKeywords = new ArrayList<>();
|
||||||
|
private javax.swing.JTextArea keywordTextArea;
|
||||||
/**
|
/**
|
||||||
* Creates new form AddKeywordsDialog.
|
* Creates new form AddKeywordsDialog. Note that this does not display the
|
||||||
* Note that this does not display the dialog - call display() after creation.
|
* dialog - call display() after creation.
|
||||||
|
*
|
||||||
* @param initialKeywords Keywords to populate the list with
|
* @param initialKeywords Keywords to populate the list with
|
||||||
* @param type Starting keyword type
|
* @param type Starting keyword type
|
||||||
*/
|
*/
|
||||||
AddKeywordsDialog(){
|
AddKeywordsDialog() {
|
||||||
super((JFrame) WindowManager.getDefault().getMainWindow(),
|
super((JFrame) WindowManager.getDefault().getMainWindow(),
|
||||||
NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.addKeywordsTitle.text"),
|
NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.addKeywordsTitle.text"),
|
||||||
true);
|
true);
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
// Set the add button to only be active when there is text in the text area
|
// Set the add button to only be active when there is text in the text area
|
||||||
addButton.setEnabled(false);
|
addButton.setEnabled(false);
|
||||||
keywordTextArea.getDocument().addDocumentListener(new DocumentListener() {
|
initKeywordTextArea();
|
||||||
@Override
|
|
||||||
public void changedUpdate(DocumentEvent e) {
|
|
||||||
fire();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void removeUpdate(DocumentEvent e) {
|
|
||||||
fire();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void insertUpdate(DocumentEvent e) {
|
|
||||||
fire();
|
|
||||||
}
|
|
||||||
private void fire() {
|
|
||||||
enableButtons();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the dialog
|
* Display the dialog
|
||||||
*/
|
*/
|
||||||
@ -83,51 +67,107 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
setLocation((screenDimension.width - getSize().width) / 2, (screenDimension.height - getSize().height) / 2);
|
setLocation((screenDimension.width - getSize().width) / 2, (screenDimension.height - getSize().height) / 2);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initKeywordTextArea() {
|
||||||
|
keywordTextArea = new javax.swing.JTextArea() {
|
||||||
|
//Override the paste action for this jtext area to always append pasted text with a new line if necessary
|
||||||
|
@Override
|
||||||
|
public void paste() {
|
||||||
|
//if the cursor position is not at the start of a new line add the new line symbol before the pasted text
|
||||||
|
if (!(keywordTextArea.getDocument().getLength()==0) && !keywordTextArea.getText().endsWith("\n")) {
|
||||||
|
keywordTextArea.append(System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
keywordTextArea.setCaretPosition(keywordTextArea.getDocument().getLength());
|
||||||
|
super.paste();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
keywordTextArea.setColumns(
|
||||||
|
20);
|
||||||
|
keywordTextArea.setRows(
|
||||||
|
5);
|
||||||
|
keywordTextArea.addMouseListener(
|
||||||
|
new java.awt.event.MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(java.awt.event.MouseEvent evt
|
||||||
|
) {
|
||||||
|
keywordTextAreaMouseClicked(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
jScrollPane1.setViewportView(keywordTextArea);
|
||||||
|
|
||||||
|
keywordTextArea.getDocument()
|
||||||
|
.addDocumentListener(new DocumentListener() {
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(DocumentEvent e
|
||||||
|
) {
|
||||||
|
fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeUpdate(DocumentEvent e
|
||||||
|
) {
|
||||||
|
fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertUpdate(DocumentEvent e
|
||||||
|
) {
|
||||||
|
fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fire() {
|
||||||
|
enableButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the initial contents of the text box.
|
* Set the initial contents of the text box. Intended to be used to
|
||||||
* Intended to be used to redisplay any keywords that contained errors
|
* redisplay any keywords that contained errors
|
||||||
* @param initialKeywords
|
*
|
||||||
|
* @param initialKeywords
|
||||||
*/
|
*/
|
||||||
void setInitialKeywordList(String initialKeywords, boolean isLiteral, boolean isWholeWord){
|
void setInitialKeywordList(String initialKeywords, boolean isLiteral, boolean isWholeWord) {
|
||||||
keywordTextArea.setText(initialKeywords);
|
keywordTextArea.setText(initialKeywords);
|
||||||
if (!isLiteral){
|
if (!isLiteral) {
|
||||||
regexRadioButton.setSelected(true);
|
regexRadioButton.setSelected(true);
|
||||||
}
|
} else if (isWholeWord) {
|
||||||
else if (isWholeWord){
|
|
||||||
exactRadioButton.setSelected(true);
|
exactRadioButton.setSelected(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
substringRadioButton.setSelected(true);
|
substringRadioButton.setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableButtons() {
|
||||||
private void enableButtons(){
|
addButton.setEnabled(!keywordTextArea.getText().isEmpty());
|
||||||
addButton.setEnabled(! keywordTextArea.getText().isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of keywords from the text area
|
* Get the list of keywords from the text area
|
||||||
|
*
|
||||||
* @return list of keywords
|
* @return list of keywords
|
||||||
*/
|
*/
|
||||||
List<String> getKeywords(){
|
List<String> getKeywords() {
|
||||||
return newKeywords;
|
return newKeywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the regex option is selected
|
* Get whether the regex option is selected
|
||||||
|
*
|
||||||
* @return true if the regex radio button is selected
|
* @return true if the regex radio button is selected
|
||||||
*/
|
*/
|
||||||
boolean isKeywordRegex(){
|
boolean isKeywordRegex() {
|
||||||
return regexRadioButton.isSelected();
|
return regexRadioButton.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the exact match option is selected
|
* Get whether the exact match option is selected
|
||||||
|
*
|
||||||
* @return true if the exact match radio button is selected
|
* @return true if the exact match radio button is selected
|
||||||
*/
|
*/
|
||||||
boolean isKeywordExact(){
|
boolean isKeywordExact() {
|
||||||
return exactRadioButton.isSelected();
|
return exactRadioButton.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +185,6 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
substringRadioButton = new javax.swing.JRadioButton();
|
substringRadioButton = new javax.swing.JRadioButton();
|
||||||
regexRadioButton = new javax.swing.JRadioButton();
|
regexRadioButton = new javax.swing.JRadioButton();
|
||||||
jScrollPane1 = new javax.swing.JScrollPane();
|
jScrollPane1 = new javax.swing.JScrollPane();
|
||||||
keywordTextArea = new javax.swing.JTextArea();
|
|
||||||
enterKeywordsLabel = new javax.swing.JLabel();
|
enterKeywordsLabel = new javax.swing.JLabel();
|
||||||
keywordTypeLabel = new javax.swing.JLabel();
|
keywordTypeLabel = new javax.swing.JLabel();
|
||||||
addButton = new javax.swing.JButton();
|
addButton = new javax.swing.JButton();
|
||||||
@ -164,15 +203,6 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
keywordTypeButtonGroup.add(regexRadioButton);
|
keywordTypeButtonGroup.add(regexRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(regexRadioButton, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.regexRadioButton.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(regexRadioButton, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.regexRadioButton.text")); // NOI18N
|
||||||
|
|
||||||
keywordTextArea.setColumns(20);
|
|
||||||
keywordTextArea.setRows(5);
|
|
||||||
keywordTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
|
|
||||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
|
||||||
keywordTextAreaMouseClicked(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
jScrollPane1.setViewportView(keywordTextArea);
|
|
||||||
|
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(enterKeywordsLabel, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.enterKeywordsLabel.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(enterKeywordsLabel, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.enterKeywordsLabel.text")); // NOI18N
|
||||||
|
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(keywordTypeLabel, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.keywordTypeLabel.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(keywordTypeLabel, org.openide.util.NbBundle.getMessage(AddKeywordsDialog.class, "AddKeywordsDialog.keywordTypeLabel.text")); // NOI18N
|
||||||
@ -261,7 +291,7 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
|
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
|
||||||
// Save the values from the list
|
// Save the values from the list
|
||||||
newKeywords.addAll(Arrays.asList(keywordTextArea.getText().split("\\r?\\n")));
|
newKeywords.addAll(Arrays.asList(keywordTextArea.getText().split("\\r?\\n")));
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
dispose();
|
dispose();
|
||||||
}//GEN-LAST:event_addButtonActionPerformed
|
}//GEN-LAST:event_addButtonActionPerformed
|
||||||
@ -271,7 +301,7 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
dispose();
|
dispose();
|
||||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||||
|
|
||||||
private void keywordTextAreaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_keywordTextAreaMouseClicked
|
private void keywordTextAreaMouseClicked(java.awt.event.MouseEvent evt) {
|
||||||
if (SwingUtilities.isRightMouseButton(evt)) {
|
if (SwingUtilities.isRightMouseButton(evt)) {
|
||||||
JPopupMenu popup = new JPopupMenu();
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
|
||||||
@ -304,16 +334,13 @@ class AddKeywordsDialog extends javax.swing.JDialog {
|
|||||||
popup.add(pasteMenu);
|
popup.add(pasteMenu);
|
||||||
popup.show(keywordTextArea, evt.getX(), evt.getY());
|
popup.show(keywordTextArea, evt.getX(), evt.getY());
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_keywordTextAreaMouseClicked
|
}
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton addButton;
|
private javax.swing.JButton addButton;
|
||||||
private javax.swing.JButton cancelButton;
|
private javax.swing.JButton cancelButton;
|
||||||
private javax.swing.JLabel enterKeywordsLabel;
|
private javax.swing.JLabel enterKeywordsLabel;
|
||||||
private javax.swing.JRadioButton exactRadioButton;
|
private javax.swing.JRadioButton exactRadioButton;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
private javax.swing.JTextArea keywordTextArea;
|
|
||||||
private javax.swing.ButtonGroup keywordTypeButtonGroup;
|
private javax.swing.ButtonGroup keywordTypeButtonGroup;
|
||||||
private javax.swing.JLabel keywordTypeLabel;
|
private javax.swing.JLabel keywordTypeLabel;
|
||||||
private javax.swing.JButton pasteButton;
|
private javax.swing.JButton pasteButton;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user