2197 fixed when edit and delete buttons are enabled

This commit is contained in:
William Schaefer 2017-02-07 11:56:25 -05:00
parent 751f717359
commit 95450f1478
2 changed files with 32 additions and 21 deletions

View File

@ -67,6 +67,7 @@ class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implements Opti
tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null, tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null,
profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), 2); profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), 2);
addIngestJobEventsListener(); addIngestJobEventsListener();
enableTabs();
} }
/** /**

View File

@ -262,9 +262,10 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
}//GEN-LAST:event_deleteProfileButtonActionPerformed }//GEN-LAST:event_deleteProfileButtonActionPerformed
/** /**
* Enable / disable buttons, so they can be disabled while ingest is running. * Enable / disable buttons, so they can be disabled while ingest is
* * running.
* @param isEnabled *
* @param isEnabled
*/ */
void enableButtons(boolean isEnabled) { void enableButtons(boolean isEnabled) {
newProfileButton.setEnabled(isEnabled); newProfileButton.setEnabled(isEnabled);
@ -286,7 +287,26 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
this.filterNameText.setText(""); this.filterNameText.setText("");
this.selectedModulesArea.setText(""); this.selectedModulesArea.setText("");
} }
refreshEditDeleteButtons();
} }
/**
* When Ingest is not running this will changed enabled status of the edit
* and delete buttons to reflect their current availability.
*/
private void refreshEditDeleteButtons() {
if (newProfileButton.isEnabled()) {
if (profilesListModel.isEmpty()) {
editProfileButton.setEnabled(false);
deleteProfileButton.setEnabled(false);
} else {
editProfileButton.setEnabled(true);
deleteProfileButton.setEnabled(true);
}
}
}
private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editProfileButtonActionPerformed private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editProfileButtonActionPerformed
IngestProfile selectedProfile = profileList.getSelectedValue(); IngestProfile selectedProfile = profileList.getSelectedValue();
doProfileDialog(selectedProfile); doProfileDialog(selectedProfile);
@ -294,9 +314,9 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
}//GEN-LAST:event_editProfileButtonActionPerformed }//GEN-LAST:event_editProfileButtonActionPerformed
/** /**
* Open a dialog for the the creation or modification of a profile. * Open a dialog for the the creation or modification of a profile.
* *
* @param selectedProfile * @param selectedProfile
*/ */
private void doProfileDialog(IngestProfile selectedProfile) { private void doProfileDialog(IngestProfile selectedProfile) {
// Create a files set defintion panle. // Create a files set defintion panle.
@ -315,14 +335,13 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
} while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition()); } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
TreeMap<String, IngestProfile> profileMap = new IngestProfileMap().getIngestProfileMap(); TreeMap<String, IngestProfile> profileMap = new IngestProfileMap().getIngestProfileMap();
if (profileMap.containsKey(panel.getProfileName()) && selectedProfile == null) { if (profileMap.containsKey(panel.getProfileName()) && selectedProfile == null) {
MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(), MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
"ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text", "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
panel.getProfileName())); panel.getProfileName()));
return; return;
} }
if (option == JOptionPane.OK_OPTION) { if (option == JOptionPane.OK_OPTION) {
panel.saveSettings(); panel.saveSettings();
load(); load();
@ -341,7 +360,7 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
} }
/** /**
* Load the stored profile information. * Load the stored profile information.
*/ */
@Override @Override
public void load() { public void load() {
@ -351,15 +370,10 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
for (IngestProfile profile : profileMap.getIngestProfileMap().values()) { for (IngestProfile profile : profileMap.getIngestProfileMap().values()) {
profilesListModel.addElement(profile); profilesListModel.addElement(profile);
} }
if (newProfileButton.isEnabled()) { if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
if (profilesListModel.isEmpty()) { currentIndex = 0;
editProfileButton.setEnabled(false);
deleteProfileButton.setEnabled(false);
} else {
editProfileButton.setEnabled(true);
deleteProfileButton.setEnabled(true);
}
} }
refreshEditDeleteButtons();
profileList.setSelectedIndex(currentIndex); profileList.setSelectedIndex(currentIndex);
} }
@ -370,7 +384,6 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
if (e.getValueIsAdjusting()) { if (e.getValueIsAdjusting()) {
return; return;
} }
// Get the selected interesting files set and populate the set // Get the selected interesting files set and populate the set
// components. // components.
IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue(); IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
@ -390,11 +403,8 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
for (String moduleName : selectedProfile.getModuleNames(IngestProfile.getEnabledModulesKey())) { for (String moduleName : selectedProfile.getModuleNames(IngestProfile.getEnabledModulesKey())) {
selectedModulesArea.append(moduleName + "\n"); selectedModulesArea.append(moduleName + "\n");
} }
} }
} }
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables