bug fixes

This commit is contained in:
Greg DiCristofaro 2021-03-11 12:51:28 -05:00
parent c4fcc7aa98
commit ccf2a66c81
5 changed files with 146 additions and 77 deletions

View File

@ -154,8 +154,8 @@ class AddEditCategoryDialog extends javax.swing.JDialog {
validationMessage = Bundle.AddEditCategoryDialog_onValueUpdate_badCategory(WebCategoriesDataModel.getMaxCategoryLength()); validationMessage = Bundle.AddEditCategoryDialog_onValueUpdate_badCategory(WebCategoriesDataModel.getMaxCategoryLength());
} else if (currentSuffixes.contains(normalizedSuffix) && } else if (currentSuffixes.contains(normalizedSuffix) &&
currentDomainCategory != null && (currentDomainCategory == null ||
!normalizedSuffix.equals(currentDomainCategory.getHostSuffix())) { !normalizedSuffix.equals(currentDomainCategory.getHostSuffix()))) {
validationMessage = Bundle.AddEditCategoryDialog_onValueUpdate_suffixRepeat(); validationMessage = Bundle.AddEditCategoryDialog_onValueUpdate_suffixRepeat();

View File

@ -1,13 +1,14 @@
AddEditCategoryDialog_Add=Add Entry AddEditCategoryDialog_Add=Add Entry
AddEditCategoryDialog_Edit=Edit Entry AddEditCategoryDialog_Edit=Edit Entry
# {0} - maxCategoryLen # {0} - maxCategoryLen
AddEditCategoryDialog_onValueUpdate_badCategory=Please provide a domain suffix that is no more than {0} characters. AddEditCategoryDialog_onValueUpdate_badCategory=Please provide a category that is no more than {0} characters.
# {0} - maxSuffixLen # {0} - maxSuffixLen
AddEditCategoryDialog_onValueUpdate_badSuffix=Please provide a domain suffix that is no more than {0} characters. AddEditCategoryDialog_onValueUpdate_badSuffix=Please provide a domain suffix that is no more than {0} characters.
AddEditCategoryDialog_onValueUpdate_sameCategory=Please provide a new category for this domain suffix. AddEditCategoryDialog_onValueUpdate_sameCategory=Please provide a new category for this domain suffix.
AddEditCategoryDialog_onValueUpdate_suffixRepeat=Please provide a unique domain suffix. AddEditCategoryDialog_onValueUpdate_suffixRepeat=Please provide a unique domain suffix.
WebCategoriesOptionsPanel_categoryTable_categoryColumnName=Category WebCategoriesOptionsPanel_categoryTable_categoryColumnName=Category
WebCategoriesOptionsPanel_categoryTable_suffixColumnName=Domain Suffix WebCategoriesOptionsPanel_categoryTable_suffixColumnName=Domain Suffix
WebCategoriesOptionsPanel_exportSetButtonActionPerformed_defaultFileName=Custom Categories Export
WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorMessage=There was an error exporting. WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorMessage=There was an error exporting.
WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorTitle=Export Error WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorTitle=Export Error
WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage=There was an error importing this json file. WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage=There was an error importing this json file.

View File

@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.url.analytics.domaincategorization; package org.sleuthkit.autopsy.url.analytics.domaincategorization;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
@ -81,6 +82,7 @@ class WebCategoriesDataModel implements AutoCloseable {
* *
* @return The category. * @return The category.
*/ */
@JsonGetter("category")
String getCategory() { String getCategory() {
return category; return category;
} }
@ -90,6 +92,7 @@ class WebCategoriesDataModel implements AutoCloseable {
* *
* @return The list of domain suffixes in this category. * @return The list of domain suffixes in this category.
*/ */
@JsonGetter("domains")
List<String> getDomains() { List<String> getDomains() {
return domains; return domains;
} }
@ -278,7 +281,7 @@ class WebCategoriesDataModel implements AutoCloseable {
String categoryStr = getNormalizedCategory(category.getCategory()); String categoryStr = getNormalizedCategory(category.getCategory());
for (int listIdx = 0; listIdx < category.getDomains().size(); i++) { for (int listIdx = 0; listIdx < category.getDomains().size(); listIdx++) {
String domain = category.getDomains().get(listIdx); String domain = category.getDomains().get(listIdx);
if (domain == null) { if (domain == null) {
logger.log(Level.WARNING, String.format("Could not process domain at idx: %d in category %s for file %s", logger.log(Level.WARNING, String.format("Could not process domain at idx: %d in category %s for file %s",

View File

@ -18,6 +18,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="panelDescription"> <Component class="javax.swing.JLabel" name="panelDescription">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/url/analytics/domaincategorization/Bundle.properties" key="WebCategoriesOptionsPanel.panelDescription.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/url/analytics/domaincategorization/Bundle.properties" key="WebCategoriesOptionsPanel.panelDescription.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
@ -40,7 +41,7 @@
</AuxValues> </AuxValues>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="3" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="10" insetsBottom="10" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="-1" gridY="-1" gridWidth="3" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="10" insetsBottom="10" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -60,6 +61,32 @@
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
<Container class="javax.swing.JPanel" name="categoryTablePanel">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 300]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 600]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="categoryTable"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="3" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="10" insetsBottom="10" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
<Component class="javax.swing.JButton" name="newEntryButton"> <Component class="javax.swing.JButton" name="newEntryButton">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@ -71,7 +98,7 @@
</Events> </Events>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -86,7 +113,7 @@
</Events> </Events>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="1" gridY="3" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -116,7 +143,7 @@
</Events> </Events>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="21" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -136,28 +163,9 @@
</Constraints> </Constraints>
</Component> </Component>
<Container class="javax.swing.JPanel" name="bottomStrut"> <Container class="javax.swing.JPanel" name="bottomStrut">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="3" gridY="6" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
<Container class="javax.swing.JScrollPane" name="tableScrollPane">
<Properties> <Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[325, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[500, 300]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[500, 400]"/> <Dimension value="[10, 0]"/>
</Property> </Property>
</Properties> </Properties>
<AuxValues> <AuxValues>
@ -166,23 +174,12 @@
</AuxValues> </AuxValues>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="3" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="10" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="3" gridY="6" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="categoryTablePanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="categoryTable"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container> </Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="ingestRunningWarning"> <Component class="javax.swing.JLabel" name="ingestRunningWarning">
<Properties> <Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">

View File

@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.url.analytics.domaincategorization; package org.sleuthkit.autopsy.url.analytics.domaincategorization;
import java.awt.Cursor;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -32,6 +33,7 @@ import java.util.stream.Collectors;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.WeakListeners; import org.openide.util.WeakListeners;
@ -94,6 +96,7 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
fileChooser.setFileFilter(DB_FILTER); fileChooser.setFileFilter(DB_FILTER);
categoryTable.setCellListener((evt) -> refreshComponentStates()); categoryTable.setCellListener((evt) -> refreshComponentStates());
IngestManager.getInstance().addIngestJobEventListener(weakIngestListener); IngestManager.getInstance().addIngestJobEventListener(weakIngestListener);
setDefaultCursor();
refresh(); refresh();
} }
@ -154,14 +157,16 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
newEntryButton.setEnabled(operationsPermitted); newEntryButton.setEnabled(operationsPermitted);
exportSetButton.setEnabled(operationsPermitted); exportSetButton.setEnabled(operationsPermitted);
importSetButton.setEnabled(operationsPermitted); importSetButton.setEnabled(operationsPermitted);
ingestRunningWarning.setEnabled(operationsPermitted);
ingestRunningWarning.setVisible(isIngestRunning); ingestRunningWarning.setVisible(isIngestRunning);
} }
/** /**
* Shows the AddEditCategoryDialog to the user and returns the user-inputted DomainCategory or null if nothing was saved. * Shows the AddEditCategoryDialog to the user and returns the user-inputted
* @param original If editing a value, this is the original value being edited. If adding a new value, this should be null. * DomainCategory or null if nothing was saved.
*
* @param original If editing a value, this is the original value being
* edited. If adding a new value, this should be null.
* @return * @return
*/ */
private DomainCategory getAddEditValue(DomainCategory original) { private DomainCategory getAddEditValue(DomainCategory original) {
@ -182,6 +187,51 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
} }
} }
/**
* Set cursor to waiting.
*/
private void setWaitingCursor() {
SwingUtilities.invokeLater(() -> this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)));
}
/**
* Set cursor to default.
*/
private void setDefaultCursor() {
SwingUtilities.invokeLater(() -> this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)));
}
/**
* An action for updating or altering data in the custom configuration.
*/
private interface UpdateAction {
/**
* A runnable action to update custom configuration.
*
* @throws IllegalArgumentException
* @throws IOException
* @throws SQLException
*/
void run() throws IllegalArgumentException, IOException, SQLException;
}
/**
* Runs an action to update the state of the configuration and runs refresh
* when complete.
*
* @param runnable The runnable action.
* @throws IllegalArgumentException
* @throws IOException
* @throws SQLException
*/
private void runUpdateAction(UpdateAction runnable) throws IllegalArgumentException, IOException, SQLException {
setWaitingCursor();
runnable.run();
setDefaultCursor();
refresh();
}
/** /**
* This method is called from within the constructor to initialize the form. * 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 * WARNING: Do NOT modify this code. The content of this method is always
@ -194,23 +244,23 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
javax.swing.JLabel panelDescription = new javax.swing.JLabel(); javax.swing.JLabel panelDescription = new javax.swing.JLabel();
javax.swing.JLabel categoriesTitle = new javax.swing.JLabel(); javax.swing.JLabel categoriesTitle = new javax.swing.JLabel();
javax.swing.JPanel categoryTablePanel = categoryTable;
newEntryButton = new javax.swing.JButton(); newEntryButton = new javax.swing.JButton();
editEntryButton = new javax.swing.JButton(); editEntryButton = new javax.swing.JButton();
deleteEntryButton = new javax.swing.JButton(); deleteEntryButton = new javax.swing.JButton();
importSetButton = new javax.swing.JButton(); importSetButton = new javax.swing.JButton();
exportSetButton = new javax.swing.JButton(); exportSetButton = new javax.swing.JButton();
javax.swing.JPanel bottomStrut = new javax.swing.JPanel(); javax.swing.JPanel bottomStrut = new javax.swing.JPanel();
javax.swing.JScrollPane tableScrollPane = new javax.swing.JScrollPane();
javax.swing.JPanel categoryTablePanel = categoryTable;
ingestRunningWarning = new javax.swing.JLabel(); ingestRunningWarning = new javax.swing.JLabel();
setLayout(new java.awt.GridBagLayout()); setLayout(new java.awt.GridBagLayout());
panelDescription.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
panelDescription.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.panelDescription.text")); // NOI18N panelDescription.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.panelDescription.text")); // NOI18N
panelDescription.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))); panelDescription.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 3; gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0); gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0);
add(panelDescription, gridBagConstraints); add(panelDescription, gridBagConstraints);
@ -224,6 +274,19 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
add(categoriesTitle, gridBagConstraints); add(categoriesTitle, gridBagConstraints);
categoryTablePanel.setAutoscrolls(true);
categoryTablePanel.setMaximumSize(new java.awt.Dimension(400, 32767));
categoryTablePanel.setMinimumSize(new java.awt.Dimension(400, 300));
categoryTablePanel.setPreferredSize(new java.awt.Dimension(400, 600));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(2, 10, 10, 0);
add(categoryTablePanel, gridBagConstraints);
newEntryButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.newEntryButton.text")); // NOI18N newEntryButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.newEntryButton.text")); // NOI18N
newEntryButton.addActionListener(new java.awt.event.ActionListener() { newEntryButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -233,6 +296,7 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3; gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5); gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5);
add(newEntryButton, gridBagConstraints); add(newEntryButton, gridBagConstraints);
@ -246,6 +310,7 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1; gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3; gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5); gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
add(editEntryButton, gridBagConstraints); add(editEntryButton, gridBagConstraints);
@ -272,6 +337,7 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4; gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5); gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5);
add(importSetButton, gridBagConstraints); add(importSetButton, gridBagConstraints);
@ -288,27 +354,15 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5); gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
add(exportSetButton, gridBagConstraints); add(exportSetButton, gridBagConstraints);
bottomStrut.setPreferredSize(new java.awt.Dimension(10, 0));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3; gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 6; gridBagConstraints.gridy = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0; gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(bottomStrut, gridBagConstraints); add(bottomStrut, gridBagConstraints);
tableScrollPane.setMaximumSize(new java.awt.Dimension(325, 32767));
tableScrollPane.setMinimumSize(new java.awt.Dimension(500, 300));
tableScrollPane.setPreferredSize(new java.awt.Dimension(500, 400));
tableScrollPane.setViewportView(categoryTablePanel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 10, 5, 0);
add(tableScrollPane, gridBagConstraints);
ingestRunningWarning.setForeground(java.awt.Color.RED); ingestRunningWarning.setForeground(java.awt.Color.RED);
ingestRunningWarning.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.ingestRunningWarning.text")); // NOI18N ingestRunningWarning.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.ingestRunningWarning.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
@ -324,9 +378,9 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
DomainCategory selected = getSelected(); DomainCategory selected = getSelected();
if (selected != null && selected.getHostSuffix() != null) { if (selected != null && selected.getHostSuffix() != null) {
try { try {
dataModel.deleteRecord(selected.getHostSuffix()); runUpdateAction(() -> dataModel.deleteRecord(selected.getHostSuffix()));
refresh(); } catch (IllegalArgumentException | SQLException | IOException ex) {
} catch (IllegalArgumentException | SQLException ex) { setDefaultCursor();
logger.log(Level.WARNING, "There was an error while deleting: " + selected.getHostSuffix(), ex); logger.log(Level.WARNING, "There was an error while deleting: " + selected.getHostSuffix(), ex);
} }
} }
@ -336,9 +390,9 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
DomainCategory newCategory = getAddEditValue(null); DomainCategory newCategory = getAddEditValue(null);
if (newCategory != null) { if (newCategory != null) {
try { try {
dataModel.insertUpdateSuffix(newCategory); runUpdateAction(() -> dataModel.insertUpdateSuffix(newCategory));
refresh(); } catch (IllegalArgumentException | SQLException | IOException ex) {
} catch (IllegalArgumentException | SQLException ex) { setDefaultCursor();
logger.log(Level.WARNING, "There was an error while adding new record: " + newCategory.getHostSuffix(), ex); logger.log(Level.WARNING, "There was an error while adding new record: " + newCategory.getHostSuffix(), ex);
} }
} }
@ -350,10 +404,10 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
try { try {
DomainCategory newCategory = getAddEditValue(selected); DomainCategory newCategory = getAddEditValue(selected);
if (newCategory != null) { if (newCategory != null) {
dataModel.insertUpdateSuffix(newCategory); runUpdateAction(() -> dataModel.insertUpdateSuffix(newCategory));
refresh();
} }
} catch (IllegalArgumentException | SQLException ex) { } catch (IllegalArgumentException | SQLException | IOException ex) {
setDefaultCursor();
logger.log(Level.WARNING, "There was an error while editing: " + selected.getHostSuffix(), ex); logger.log(Level.WARNING, "There was an error while editing: " + selected.getHostSuffix(), ex);
} }
} }
@ -363,14 +417,15 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
"WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage=There was an error importing this json file.", "WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage=There was an error importing this json file.",
"WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle=Import Error",}) "WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle=Import Error",})
private void importSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSetButtonActionPerformed private void importSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSetButtonActionPerformed
fileChooser.setSelectedFile(null);
int result = fileChooser.showOpenDialog(this); int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooser.getSelectedFile();
if (selectedFile != null && selectedFile.exists()) { if (selectedFile != null && selectedFile.exists()) {
try { try {
dataModel.importJson(selectedFile); runUpdateAction(() -> dataModel.importJson(selectedFile));
refresh(); } catch (IllegalArgumentException | SQLException | IOException ex) {
} catch (SQLException | IOException ex) { setDefaultCursor();
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
this, this,
Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(), Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(),
@ -384,15 +439,28 @@ public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel i
@Messages({ @Messages({
"WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorMessage=There was an error exporting.", "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorMessage=There was an error exporting.",
"WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorTitle=Export Error",}) "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorTitle=Export Error",
"WebCategoriesOptionsPanel_exportSetButtonActionPerformed_defaultFileName=Custom Categories Export"
})
private void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportSetButtonActionPerformed private void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportSetButtonActionPerformed
fileChooser.setSelectedFile(new File(String.format("%s.json", Bundle.WebCategoriesOptionsPanel_exportSetButtonActionPerformed_defaultFileName())));
int result = fileChooser.showSaveDialog(this); int result = fileChooser.showSaveDialog(this);
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooser.getSelectedFile();
if (selectedFile != null) { if (selectedFile != null) {
if (selectedFile.exists()) {
JOptionPane.showMessageDialog(
this,
Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(),
Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle(),
JOptionPane.ERROR);
}
try { try {
setWaitingCursor();
dataModel.exportToJson(selectedFile); dataModel.exportToJson(selectedFile);
setDefaultCursor();
} catch (SQLException | IOException ex) { } catch (SQLException | IOException ex) {
setDefaultCursor();
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
this, this,
Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(), Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(),