Added Solr settings to Multi User options panel.

This commit is contained in:
Eamonn Saunders 2015-04-15 14:58:19 -04:00
parent c28c2d3934
commit a2c78156a9
2 changed files with 226 additions and 31 deletions

View File

@ -16,7 +16,7 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="pnOverallPanel" pref="481" max="32767" attributes="0"/> <Component id="pnOverallPanel" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
@ -39,7 +39,7 @@
<Component id="pnDatabaseSettings" alignment="0" max="32767" attributes="0"/> <Component id="pnDatabaseSettings" alignment="0" max="32767" attributes="0"/>
<Component id="pnMessagingSettings" alignment="0" max="32767" attributes="0"/> <Component id="pnMessagingSettings" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace max="32767" attributes="0"/> <EmptySpace pref="21" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -51,10 +51,10 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="pnDatabaseSettings" min="-2" max="-2" attributes="0"/> <Component id="pnDatabaseSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="pnSolrSettings" min="-2" max="-2" attributes="0"/> <Component id="pnSolrSettings" min="-2" pref="106" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="pnMessagingSettings" min="-2" max="-2" attributes="0"/> <Component id="pnMessagingSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="143" max="32767" attributes="0"/> <EmptySpace pref="137" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -126,6 +126,9 @@
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbHostnameOrIp.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbHostnameOrIp.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbHostnameOrIpActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JTextField" name="tbPortNumber"> <Component class="javax.swing.JTextField" name="tbPortNumber">
<Properties> <Properties>
@ -205,10 +208,18 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lbSolrSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="lbSolrMsg" min="-2" pref="320" max="-2" attributes="0"/>
</Group>
<Component id="tbIndexingServerHost" alignment="1" max="32767" attributes="0"/>
<Component id="tbIndexingServerPort" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lbSolrSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -216,8 +227,15 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lbSolrSettings" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace pref="75" max="32767" attributes="0"/> <Component id="lbSolrSettings" min="-2" max="-2" attributes="0"/>
<Component id="lbSolrMsg" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="tbIndexingServerHost" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="tbIndexingServerPort" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -233,6 +251,52 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="tbIndexingServerHost">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbIndexingServerHost.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbIndexingServerHost.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbIndexingServerHostActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="tbIndexingServerPort">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbIndexingServerPort.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.tbIndexingServerPort.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbIndexingServerPortActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lbSolrMsg">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="12" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="MultiUserSettingsPanel.lbSolrMsg.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="pnMessagingSettings"> <Container class="javax.swing.JPanel" name="pnMessagingSettings">

View File

@ -6,8 +6,14 @@
package org.sleuthkit.autopsy.corecomponents; package org.sleuthkit.autopsy.corecomponents;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import org.openide.util.NbBundle;
import org.sleuthkit.datamodel.CaseDbConnectionInfo; import org.sleuthkit.datamodel.CaseDbConnectionInfo;
import org.sleuthkit.datamodel.CaseDbConnectionInfo.DbType; import org.sleuthkit.datamodel.CaseDbConnectionInfo.DbType;
import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferences;
@ -28,19 +34,26 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
TextPrompt tpPortNumber = new TextPrompt("Port Number", tbPortNumber); TextPrompt tpPortNumber = new TextPrompt("Port Number", tbPortNumber);
TextPrompt tpUsername = new TextPrompt("User Name", tbUsername); TextPrompt tpUsername = new TextPrompt("User Name", tbUsername);
TextPrompt tpPassword = new TextPrompt("Password", tbPassword); TextPrompt tpPassword = new TextPrompt("Password", tbPassword);
TextPrompt tpIndexingServerHost = new TextPrompt("Hostname or IP Address", tbIndexingServerHost);
TextPrompt tpIndexingServerPort = new TextPrompt("Port Number", tbIndexingServerPort);
tpHostnameOrIp.setForeground(Color.LIGHT_GRAY); tpHostnameOrIp.setForeground(Color.LIGHT_GRAY);
tpPortNumber.setForeground(Color.LIGHT_GRAY); tpPortNumber.setForeground(Color.LIGHT_GRAY);
tpUsername.setForeground(Color.LIGHT_GRAY); tpUsername.setForeground(Color.LIGHT_GRAY);
tpPassword.setForeground(Color.LIGHT_GRAY); tpPassword.setForeground(Color.LIGHT_GRAY);
tpIndexingServerHost.setForeground(Color.LIGHT_GRAY);
tpIndexingServerPort.setForeground(Color.LIGHT_GRAY);
float alpha = 0.9f; // Mostly opaque float alpha = 0.9f; // Mostly opaque
tpHostnameOrIp.changeAlpha(alpha); tpHostnameOrIp.changeAlpha(alpha);
tpPortNumber.changeAlpha(alpha); tpPortNumber.changeAlpha(alpha);
tpUsername.changeAlpha(alpha); tpUsername.changeAlpha(alpha);
tpPassword.changeAlpha(alpha); tpPassword.changeAlpha(alpha);
tpIndexingServerHost.changeAlpha(alpha);
tpIndexingServerPort.changeAlpha(alpha);
setNetworkDbEnabled(cbEnableMultiUser.isSelected()); enableNetworkProperties(cbEnableMultiUser.isSelected());
/// Register for notifications when the text boxes get updated /// Register for notifications when the text boxes get updated
textBoxChangedListener = new TextBoxChangedListener(); textBoxChangedListener = new TextBoxChangedListener();
@ -48,6 +61,8 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
tbPortNumber.getDocument().addDocumentListener(textBoxChangedListener); tbPortNumber.getDocument().addDocumentListener(textBoxChangedListener);
tbUsername.getDocument().addDocumentListener(textBoxChangedListener); tbUsername.getDocument().addDocumentListener(textBoxChangedListener);
tbPassword.getDocument().addDocumentListener(textBoxChangedListener); tbPassword.getDocument().addDocumentListener(textBoxChangedListener);
tbIndexingServerHost.getDocument().addDocumentListener(textBoxChangedListener);
tbIndexingServerPort.getDocument().addDocumentListener(textBoxChangedListener);
} }
/** /**
@ -69,6 +84,9 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
lbDatabaseSettings = new javax.swing.JLabel(); lbDatabaseSettings = new javax.swing.JLabel();
pnSolrSettings = new javax.swing.JPanel(); pnSolrSettings = new javax.swing.JPanel();
lbSolrSettings = new javax.swing.JLabel(); lbSolrSettings = new javax.swing.JLabel();
tbIndexingServerHost = new javax.swing.JTextField();
tbIndexingServerPort = new javax.swing.JTextField();
lbSolrMsg = new javax.swing.JLabel();
pnMessagingSettings = new javax.swing.JPanel(); pnMessagingSettings = new javax.swing.JPanel();
lbMessagingSettings = new javax.swing.JLabel(); lbMessagingSettings = new javax.swing.JLabel();
cbEnableMultiUser = new javax.swing.JCheckBox(); cbEnableMultiUser = new javax.swing.JCheckBox();
@ -78,6 +96,11 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
tbHostnameOrIp.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N tbHostnameOrIp.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
tbHostnameOrIp.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.text")); // NOI18N tbHostnameOrIp.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.text")); // NOI18N
tbHostnameOrIp.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.toolTipText")); // NOI18N tbHostnameOrIp.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.toolTipText")); // NOI18N
tbHostnameOrIp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbHostnameOrIpActionPerformed(evt);
}
});
tbPortNumber.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N tbPortNumber.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
tbPortNumber.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbPortNumber.text")); // NOI18N tbPortNumber.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbPortNumber.text")); // NOI18N
@ -142,21 +165,56 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
lbSolrSettings.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lbSolrSettings.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrSettings.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrSettings.text")); // NOI18N
tbIndexingServerHost.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
tbIndexingServerHost.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerHost.text")); // NOI18N
tbIndexingServerHost.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerHost.toolTipText")); // NOI18N
tbIndexingServerHost.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbIndexingServerHostActionPerformed(evt);
}
});
tbIndexingServerPort.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
tbIndexingServerPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerPort.text")); // NOI18N
tbIndexingServerPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerPort.toolTipText")); // NOI18N
tbIndexingServerPort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbIndexingServerPortActionPerformed(evt);
}
});
lbSolrMsg.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
lbSolrMsg.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(lbSolrMsg, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrMsg.text")); // NOI18N
lbSolrMsg.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings); javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings);
pnSolrSettings.setLayout(pnSolrSettingsLayout); pnSolrSettings.setLayout(pnSolrSettingsLayout);
pnSolrSettingsLayout.setHorizontalGroup( pnSolrSettingsLayout.setHorizontalGroup(
pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnSolrSettingsLayout.createSequentialGroup() .addGroup(pnSolrSettingsLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(lbSolrSettings) .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(pnSolrSettingsLayout.createSequentialGroup()
.addComponent(lbSolrSettings)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbSolrMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(tbIndexingServerHost, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(tbIndexingServerPort, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
); );
pnSolrSettingsLayout.setVerticalGroup( pnSolrSettingsLayout.setVerticalGroup(
pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnSolrSettingsLayout.createSequentialGroup() .addGroup(pnSolrSettingsLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(lbSolrSettings) .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addContainerGap(75, Short.MAX_VALUE)) .addComponent(lbSolrSettings)
.addComponent(lbSolrMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tbIndexingServerHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tbIndexingServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45))
); );
pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder()); pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
@ -199,7 +257,7 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
.addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnMessagingSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(pnMessagingSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(21, Short.MAX_VALUE))
); );
pnOverallPanelLayout.setVerticalGroup( pnOverallPanelLayout.setVerticalGroup(
pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -209,17 +267,17 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(143, Short.MAX_VALUE)) .addContainerGap(137, Short.MAX_VALUE))
); );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnOverallPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 481, Short.MAX_VALUE) .addComponent(pnOverallPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -232,18 +290,33 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
* *
* @param enabled true means enable, false means disable * @param enabled true means enable, false means disable
*/ */
private void setNetworkDbEnabled(boolean enabled) { private void enableNetworkProperties(boolean enabled) {
tbHostnameOrIp.setEnabled(enabled); tbHostnameOrIp.setEnabled(enabled);
tbPortNumber.setEnabled(enabled); tbPortNumber.setEnabled(enabled);
tbUsername.setEnabled(enabled); tbUsername.setEnabled(enabled);
tbPassword.setEnabled(enabled); tbPassword.setEnabled(enabled);
tbIndexingServerHost.setEnabled(enabled);
tbIndexingServerPort.setEnabled(enabled);
} }
private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged
setNetworkDbEnabled(cbEnableMultiUser.isSelected()); enableNetworkProperties(cbEnableMultiUser.isSelected());
controller.changed(); controller.changed();
}//GEN-LAST:event_cbEnableMultiUserItemStateChanged }//GEN-LAST:event_cbEnableMultiUserItemStateChanged
private void tbHostnameOrIpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbHostnameOrIpActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tbHostnameOrIpActionPerformed
private void tbIndexingServerHostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbIndexingServerHostActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tbIndexingServerHostActionPerformed
private void tbIndexingServerPortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbIndexingServerPortActionPerformed
// TODO add your handling code here:
tbIndexingServerPort.dispatchEvent(evt);
}//GEN-LAST:event_tbIndexingServerPortActionPerformed
void load() { void load() {
CaseDbConnectionInfo info = UserPreferences.getDatabaseConnectionInfo(); CaseDbConnectionInfo info = UserPreferences.getDatabaseConnectionInfo();
tbHostnameOrIp.setText(info.getHost()); tbHostnameOrIp.setText(info.getHost());
@ -256,6 +329,11 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
cbEnableMultiUser.setSelected(true); cbEnableMultiUser.setSelected(true);
} }
tbIndexingServerHost.setText(UserPreferences.getIndexingServerHost());
int indexingServerPort = UserPreferences.getIndexingServerPort();
if (isPortValid(indexingServerPort)) {
tbIndexingServerPort.setText(Integer.toString(indexingServerPort));
}
} }
void store() { void store() {
@ -274,6 +352,8 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
dbType); dbType);
UserPreferences.setDatabaseConnectionInfo(info); UserPreferences.setDatabaseConnectionInfo(info);
UserPreferences.setIndexingServerHost(tbIndexingServerHost.getText());
UserPreferences.setIndexingServerPort(Integer.parseInt(tbIndexingServerPort.getText()));
} }
/** /**
@ -282,6 +362,10 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
* @return true if it's okay, false otherwise. * @return true if it's okay, false otherwise.
*/ */
boolean valid() { boolean valid() {
return validateDatabaseSettings() && validateSolrSettings();
}
private boolean validateDatabaseSettings() {
boolean result = false; boolean result = false;
String text = ""; String text = "";
if (cbEnableMultiUser.isSelected()) { if (cbEnableMultiUser.isSelected()) {
@ -291,38 +375,85 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
|| tbUsername.getText().isEmpty() || tbUsername.getText().isEmpty()
|| tbPassword.getPassword().length == 0) { || tbPassword.getPassword().length == 0) {
// We don't even have everything filled out // We don't even have everything filled out
result = false; text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingDatabaseSettingsError");
text = "Fill in all values";
} else { } else {
int value = Integer.parseInt(tbPortNumber.getText()); int value = Integer.parseInt(tbPortNumber.getText());
if (value < 0 || value > 65535) { // valid port numbers if (!isPortValid(value)) {
result = false; /// port number is invalid text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingSolrSettingsError");
text = "Invalid port number";
} else { } else {
result = true; result = true;
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
result = false; text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidDatabaseSettings");
text = "Invalid port number";
} }
} else { }
else{
result = true; result = true;
} }
lbOops.setText(text); lbOops.setText(text);
return result; return result;
} }
private boolean validateSolrSettings() {
if (cbEnableMultiUser.isSelected()) {
// If both Solr server settings are empty that's ok but if
// either one is set you must set the other one.
if (tbIndexingServerHost.getText().isEmpty() &&
tbIndexingServerPort.getText().isEmpty()) {
return true;
}
if (tbIndexingServerHost.getText().isEmpty() ||
tbIndexingServerPort.getText().isEmpty()) {
lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingSolrSettingsError"));
return false;
}
try {
int port = Integer.parseInt(tbIndexingServerPort.getText());
if (!isPortValid(port)) {
lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidPortNumber"));
}
}
catch (NumberFormatException ex) {
lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidPortNumber"));
return false;
}
}
lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrMsg.text"));
return true;
}
/**
* Checks the given port number against the range of valid values.
* @param port
* @return
*/
private boolean isPortValid(int port) {
if (port < 1 || port > 65535) {
return false;
}
return true;
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox cbEnableMultiUser; private javax.swing.JCheckBox cbEnableMultiUser;
private javax.swing.JLabel lbDatabaseSettings; private javax.swing.JLabel lbDatabaseSettings;
private javax.swing.JLabel lbMessagingSettings; private javax.swing.JLabel lbMessagingSettings;
private javax.swing.JLabel lbOops; private javax.swing.JLabel lbOops;
private javax.swing.JLabel lbSolrMsg;
private javax.swing.JLabel lbSolrSettings; private javax.swing.JLabel lbSolrSettings;
private javax.swing.JPanel pnDatabaseSettings; private javax.swing.JPanel pnDatabaseSettings;
private javax.swing.JPanel pnMessagingSettings; private javax.swing.JPanel pnMessagingSettings;
private javax.swing.JPanel pnOverallPanel; private javax.swing.JPanel pnOverallPanel;
private javax.swing.JPanel pnSolrSettings; private javax.swing.JPanel pnSolrSettings;
private javax.swing.JTextField tbHostnameOrIp; private javax.swing.JTextField tbHostnameOrIp;
private javax.swing.JTextField tbIndexingServerHost;
private javax.swing.JTextField tbIndexingServerPort;
private javax.swing.JPasswordField tbPassword; private javax.swing.JPasswordField tbPassword;
private javax.swing.JTextField tbPortNumber; private javax.swing.JTextField tbPortNumber;
private javax.swing.JTextField tbUsername; private javax.swing.JTextField tbUsername;
@ -348,6 +479,6 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel {
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
controller.changed(); controller.changed();
} }
} }
} }