diff --git a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/DroidMainFrame.java b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/DroidMainFrame.java index 3fada30a3..15ef8e7c0 100644 --- a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/DroidMainFrame.java +++ b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/DroidMainFrame.java @@ -170,15 +170,11 @@ public static void main(String[] args) { // { // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // } - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { e.printStackTrace(); throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (UnsupportedLookAndFeelException e) { - throw new RuntimeException(e); } EventQueue.invokeLater(new Runnable() { @@ -274,12 +270,9 @@ private List promptForUpdate(final Collection { + if (STATE.equals(evt.getPropertyName()) && evt.getNewValue().equals(SwingWorker.StateValue.DONE)) { + exitListeners.remove(newProfileAction); } }); exitListeners.add(newProfileAction); @@ -528,11 +521,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) { jButtonNewProfile.setFocusable(false); jButtonNewProfile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonNewProfile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonNewProfile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonNewProfileActionPerformed(evt); - } - }); + jButtonNewProfile.addActionListener(evt -> jButtonNewProfileActionPerformed(evt)); droidToolBar.add(jButtonNewProfile); jButtonOpenProfile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Open file.png"))); // NOI18N @@ -541,11 +530,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOpenProfile.setFocusable(false); jButtonOpenProfile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonOpenProfile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonOpenProfile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonOpenProfileActionPerformed(evt); - } - }); + jButtonOpenProfile.addActionListener(evt -> jButtonOpenProfileActionPerformed(evt)); droidToolBar.add(jButtonOpenProfile); jButtonSaveProfile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Save.png"))); // NOI18N @@ -556,11 +541,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSaveProfile.setFocusable(false); jButtonSaveProfile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonSaveProfile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonSaveProfile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonSaveProfileActionPerformed(evt); - } - }); + jButtonSaveProfile.addActionListener(evt -> jButtonSaveProfileActionPerformed(evt)); droidToolBar.add(jButtonSaveProfile); jButtonExport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Export.png"))); // NOI18N @@ -569,11 +550,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonExport.setFocusable(false); jButtonExport.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonExport.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonExport.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonExportActionPerformed(evt); - } - }); + jButtonExport.addActionListener(evt -> jButtonExportActionPerformed(evt)); droidToolBar.add(jButtonExport); jSeparator13.setSeparatorSize(new java.awt.Dimension(20, 40)); @@ -587,11 +564,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAddFile.setFocusable(false); jButtonAddFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonAddFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonAddFile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonAddFileActionPerformed(evt); - } - }); + jButtonAddFile.addActionListener(evt -> jButtonAddFileActionPerformed(evt)); droidToolBar.add(jButtonAddFile); jButtonRemoveFilesAndFolder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Remove.png"))); // NOI18N @@ -602,11 +575,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonRemoveFilesAndFolder.setFocusable(false); jButtonRemoveFilesAndFolder.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonRemoveFilesAndFolder.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonRemoveFilesAndFolder.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonRemoveFilesAndFolderActionPerformed(evt); - } - }); + jButtonRemoveFilesAndFolder.addActionListener(evt -> jButtonRemoveFilesAndFolderActionPerformed(evt)); droidToolBar.add(jButtonRemoveFilesAndFolder); jSeparator12.setSeparatorSize(new java.awt.Dimension(20, 40)); @@ -620,11 +589,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonStart.setFocusable(false); jButtonStart.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonStart.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonStart.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonStartActionPerformed(evt); - } - }); + jButtonStart.addActionListener(evt -> jButtonStartActionPerformed(evt)); droidToolBar.add(jButtonStart); jButtonStop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Pause.png"))); // NOI18N @@ -635,11 +600,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonStop.setFocusable(false); jButtonStop.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonStop.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonStop.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonStopActionPerformed(evt); - } - }); + jButtonStop.addActionListener(evt -> jButtonStopActionPerformed(evt)); droidToolBar.add(jButtonStop); jSeparator11.setSeparatorSize(new java.awt.Dimension(20, 40)); @@ -651,11 +612,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonFilter.setFocusable(false); jButtonFilter.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonFilter.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonFilter.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonFilterActionPerformed(evt); - } - }); + jButtonFilter.addActionListener(evt -> jButtonFilterActionPerformed(evt)); droidToolBar.add(jButtonFilter); jPanel1.setMaximumSize(new java.awt.Dimension(30, 60)); @@ -672,11 +629,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jFilterOnCheckBox.setPreferredSize(new java.awt.Dimension(30, 55)); jFilterOnCheckBox.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); jFilterOnCheckBox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jFilterOnCheckBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jFilterOnCheckBoxActionPerformed(evt); - } - }); + jFilterOnCheckBox.addActionListener(evt -> jFilterOnCheckBoxActionPerformed(evt)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); @@ -704,11 +657,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonReport.setFocusable(false); jButtonReport.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonReport.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButtonReport.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonReportActionPerformed(evt); - } - }); + jButtonReport.addActionListener(evt -> jButtonReportActionPerformed(evt)); droidToolBar.add(jButtonReport); jMenuBar1.setPreferredSize(new java.awt.Dimension(100, 25)); @@ -716,32 +665,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuFile.setMnemonic('F'); jMenuFile.setText("File"); jMenuFile.setActionCommand("file"); - jMenuFile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuFileActionPerformed(evt); - } - }); + jMenuFile.addActionListener(evt -> jMenuFileActionPerformed(evt)); jMenuItemNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_DOWN_MASK)); jMenuItemNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/New small.png"))); // NOI18N jMenuItemNew.setText("New"); jMenuItemNew.setToolTipText("New profile"); - jMenuItemNew.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemNewActionPerformed(evt); - } - }); + jMenuItemNew.addActionListener(evt -> jMenuItemNewActionPerformed(evt)); jMenuFile.add(jMenuItemNew); jMenuItemOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_DOWN_MASK)); jMenuItemOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Open file small.png"))); // NOI18N jMenuItemOpen.setText("Open"); jMenuItemOpen.setToolTipText("Open a profile"); - jMenuItemOpen.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemOpenActionPerformed(evt); - } - }); + jMenuItemOpen.addActionListener(evt -> jMenuItemOpenActionPerformed(evt)); jMenuFile.add(jMenuItemOpen); jMenuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_DOWN_MASK)); @@ -751,11 +688,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuSave.setActionCommand("save"); jMenuSave.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/icons/Save Blue 16 d g.gif"))); // NOI18N jMenuSave.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/icons/Save Blue 16 d g.gif"))); // NOI18N - jMenuSave.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuSaveActionPerformed(evt); - } - }); + jMenuSave.addActionListener(evt -> jMenuSaveActionPerformed(evt)); jMenuFile.add(jMenuSave); jMenuSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_DOWN_MASK | java.awt.event.InputEvent.CTRL_DOWN_MASK)); @@ -765,11 +698,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuSaveAs.setActionCommand("save"); jMenuSaveAs.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Save As small disabled.png"))); // NOI18N jMenuSaveAs.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Save As small disabled.png"))); // NOI18N - jMenuSaveAs.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuSaveAsActionPerformed(evt); - } - }); + jMenuSaveAs.addActionListener(evt -> jMenuSaveAsActionPerformed(evt)); jMenuFile.add(jMenuSaveAs); jMenuItemExport.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_DOWN_MASK)); @@ -777,21 +706,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemExport.setText("Export all..."); jMenuItemExport.setToolTipText("Export profiles"); jMenuItemExport.setActionCommand("export"); - jMenuItemExport.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemExportActionPerformed(evt); - } - }); + jMenuItemExport.addActionListener(evt -> jMenuItemExportActionPerformed(evt)); jMenuFile.add(jMenuItemExport); jMenuQuit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_DOWN_MASK)); jMenuQuit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Quit Small.png"))); // NOI18N jMenuQuit.setText("Quit"); - jMenuQuit.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuQuitActionPerformed(evt); - } - }); + jMenuQuit.addActionListener(evt -> jMenuQuitActionPerformed(evt)); jMenuFile.add(jMenuQuit); jMenuFile.add(jSeparator4); @@ -816,11 +737,7 @@ public void menuCanceled(javax.swing.event.MenuEvent evt) { jMenuItemAddFileOrFolders.setToolTipText("Add files or folders to a profile"); jMenuItemAddFileOrFolders.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Add small disabled.png"))); // NOI18N jMenuItemAddFileOrFolders.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Add small disabled.png"))); // NOI18N - jMenuItemAddFileOrFolders.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemAddFileOrFoldersActionPerformed(evt); - } - }); + jMenuItemAddFileOrFolders.addActionListener(evt -> jMenuItemAddFileOrFoldersActionPerformed(evt)); jMenuEdit.add(jMenuItemAddFileOrFolders); jMenuItemRemoveFolder.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, java.awt.event.InputEvent.CTRL_DOWN_MASK)); @@ -829,49 +746,29 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemRemoveFolder.setToolTipText("Remove files or folders from a profile"); jMenuItemRemoveFolder.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Remove small disabled.png"))); // NOI18N jMenuItemRemoveFolder.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Remove small disabled.png"))); // NOI18N - jMenuItemRemoveFolder.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemRemoveFolderActionPerformed(evt); - } - }); + jMenuItemRemoveFolder.addActionListener(evt -> jMenuItemRemoveFolderActionPerformed(evt)); jMenuEdit.add(jMenuItemRemoveFolder); jMenuEdit.add(jSeparator1); jMenuItemOpenFolder.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, java.awt.event.InputEvent.CTRL_DOWN_MASK)); jMenuItemOpenFolder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/icons/Icon_External_Link.png"))); // NOI18N jMenuItemOpenFolder.setText("Open containing folder..."); - jMenuItemOpenFolder.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - OpenContainingFolder(evt); - } - }); + jMenuItemOpenFolder.addActionListener(evt -> OpenContainingFolder(evt)); jMenuEdit.add(jMenuItemOpenFolder); jMenuItemCopyToClipboard.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_DOWN_MASK)); jMenuItemCopyToClipboard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Clipboard small.png"))); // NOI18N jMenuItemCopyToClipboard.setText("Copy to clipboard"); - jMenuItemCopyToClipboard.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemCopyToClipboardActionPerformed(evt); - } - }); + jMenuItemCopyToClipboard.addActionListener(evt -> jMenuItemCopyToClipboardActionPerformed(evt)); jMenuEdit.add(jMenuItemCopyToClipboard); jMenuEdit.add(jSeparator2); jMenuItemExpandChildren.setText("Expand"); - jMenuItemExpandChildren.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemExpandChildrenActionPerformed(evt); - } - }); + jMenuItemExpandChildren.addActionListener(evt -> jMenuItemExpandChildrenActionPerformed(evt)); jMenuEdit.add(jMenuItemExpandChildren); jMenuItemExpandNextThree.setText("Expand next three levels"); - jMenuItemExpandNextThree.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemExpandNextThreeActionPerformed(evt); - } - }); + jMenuItemExpandNextThree.addActionListener(evt -> jMenuItemExpandNextThreeActionPerformed(evt)); jMenuEdit.add(jMenuItemExpandNextThree); jMenuBar1.add(jMenuEdit); @@ -886,11 +783,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemStart.setToolTipText("Start identifying files in the profile"); jMenuItemStart.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Play small disabled.png"))); // NOI18N jMenuItemStart.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Play small disabled.png"))); // NOI18N - jMenuItemStart.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemStartActionPerformed(evt); - } - }); + jMenuItemStart.addActionListener(evt -> jMenuItemStartActionPerformed(evt)); jMenuRun.add(jMenuItemStart); jMenuItemStop.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_DOWN_MASK)); @@ -899,11 +792,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemStop.setToolTipText("Pause identification in the profile"); jMenuItemStop.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Pause small disabled.png"))); // NOI18N jMenuItemStop.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Pause small disabled.png"))); // NOI18N - jMenuItemStop.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemStopActionPerformed(evt); - } - }); + jMenuItemStop.addActionListener(evt -> jMenuItemStopActionPerformed(evt)); jMenuRun.add(jMenuItemStop); jMenuBar1.add(jMenuRun); @@ -923,11 +812,7 @@ public void menuCanceled(javax.swing.event.MenuEvent evt) { filterEnabledMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_DOWN_MASK)); filterEnabledMenuItem.setText("Filter on"); filterEnabledMenuItem.setToolTipText("Toggles filtering on or off in the profile"); - filterEnabledMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - filterEnabledMenuItemActionPerformed(evt); - } - }); + filterEnabledMenuItem.addActionListener(evt -> filterEnabledMenuItemActionPerformed(evt)); jMenuFilter.add(filterEnabledMenuItem); jMenuFilter.add(jSeparator8); @@ -936,20 +821,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuEditFilter.setText("Edit filter..."); jMenuEditFilter.setToolTipText("Edit the filter for a profile"); jMenuEditFilter.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Filter small disabled.png"))); // NOI18N - jMenuEditFilter.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuEditFilterActionPerformed(evt); - } - }); + jMenuEditFilter.addActionListener(evt -> jMenuEditFilterActionPerformed(evt)); jMenuFilter.add(jMenuEditFilter); jMenuItemCopyFilterToAll.setText("Copy filter to all profiles..."); jMenuItemCopyFilterToAll.setToolTipText("Copies the filter in the current profile to all open profiles"); - jMenuItemCopyFilterToAll.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItemCopyFilterToAllActionPerformed(evt); - } - }); + jMenuItemCopyFilterToAll.addActionListener(evt -> jMenuItemCopyFilterToAllActionPerformed(evt)); jMenuFilter.add(jMenuItemCopyFilterToAll); jMenuBar1.add(jMenuFilter); @@ -963,53 +840,33 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { generateReportMenuItem.setText("Generate Report..."); generateReportMenuItem.setToolTipText("Generates a report in DROID XML format"); generateReportMenuItem.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/gov/nationalarchives/droid/OldIcons/Report small disabled.png"))); // NOI18N - generateReportMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - generateReportMenuItemActionPerformed(evt); - } - }); + generateReportMenuItem.addActionListener(evt -> generateReportMenuItemActionPerformed(evt)); jMenuReport.add(generateReportMenuItem); jMenuBar1.add(jMenuReport); jMenuTools.setMnemonic('T'); jMenuTools.setText("Tools"); - jMenuTools.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuToolsActionPerformed(evt); - } - }); + jMenuTools.addActionListener(evt -> jMenuToolsActionPerformed(evt)); jMenuTools.add(jSeparator7); updateNowMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.CTRL_DOWN_MASK)); updateNowMenuItem.setText("Check for signature updates..."); updateNowMenuItem.setToolTipText("Checks to see if there are updated signatures"); - updateNowMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - updateNowMenuItemActionPerformed(evt); - } - }); + updateNowMenuItem.addActionListener(evt -> updateNowMenuItemActionPerformed(evt)); jMenuTools.add(updateNowMenuItem); signatureInstallMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.SHIFT_DOWN_MASK | java.awt.event.InputEvent.CTRL_DOWN_MASK)); signatureInstallMenuItem.setText("Install signature file..."); signatureInstallMenuItem.setToolTipText("Installs a signature file from your local file system"); - signatureInstallMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - signatureInstallMenuItemActionPerformed(evt); - } - }); + signatureInstallMenuItem.addActionListener(evt -> signatureInstallMenuItemActionPerformed(evt)); jMenuTools.add(signatureInstallMenuItem); jMenuTools.add(jSeparator6); settingsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_DOWN_MASK | java.awt.event.InputEvent.CTRL_DOWN_MASK)); settingsMenuItem.setText("Preferences..."); settingsMenuItem.setToolTipText("Set the DROID preferences"); - settingsMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - settingsMenuItemActionPerformed(evt); - } - }); + settingsMenuItem.addActionListener(evt -> settingsMenuItemActionPerformed(evt)); jMenuTools.add(settingsMenuItem); jMenuBar1.add(jMenuTools); @@ -1023,11 +880,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jhelp.add(helpMenuItem); aboutMenuItem.setText("About"); - aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - aboutMenuItemActionPerformed(evt); - } - }); + aboutMenuItem.addActionListener(evt -> aboutMenuItemActionPerformed(evt)); jhelp.add(aboutMenuItem); jMenuBar1.add(jhelp); @@ -1335,6 +1188,10 @@ private void settingsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// } } + + if (configDialog.getCreateNewProfile()) { + createAndInitNewProfile(); + } }// GEN-LAST:event_settingsMenuItemActionPerformed private void jMenuToolsActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jMenuToolsActionPerformed @@ -1407,6 +1264,11 @@ private void jMenuPlanetsXMLActionPerformed(java.awt.event.ActionEvent evt) {// private void jButtonNewProfileActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonNewProfileActionPerformed + createAndInitNewProfile(); + + }// GEN-LAST:event_jButtonNewProfileActionPerformed + + private void createAndInitNewProfile() { final NewProfileAction newProfileAction = new NewProfileAction(droidContext, profileManager, jProfilesTabbedPane); newProfileAction.addPropertyChangeListener(new PropertyChangeListener() { @Override @@ -1424,8 +1286,7 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (ProfileManagerException e) { DialogUtils.showGeneralErrorDialog(this, ERROR_TITLE, e.getMessage()); } - - }// GEN-LAST:event_jButtonNewProfileActionPerformed + } public void jButtonAddFileActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonAddFileActionPerformed diff --git a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/config/ConfigDialog.java b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/config/ConfigDialog.java index 85be040e9..aa70cd24e 100644 --- a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/config/ConfigDialog.java +++ b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/config/ConfigDialog.java @@ -31,59 +31,58 @@ */ package uk.gov.nationalarchives.droid.gui.config; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; +import org.apache.commons.collections4.list.SetUniqueList; +import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy; +import org.jdesktop.beansbinding.BeanProperty; +import org.jdesktop.beansbinding.Binding; +import org.jdesktop.beansbinding.BindingGroup; +import org.jdesktop.beansbinding.Bindings; +import org.jdesktop.beansbinding.ELProperty; +import org.jdesktop.observablecollections.ObservableCollections; +import org.jdesktop.observablecollections.ObservableList; +import org.jdesktop.observablecollections.ObservableMap; +import org.jdesktop.swingbinding.JComboBoxBinding; +import org.jdesktop.swingbinding.SwingBindings; +import org.openide.util.NbBundle; +import uk.gov.nationalarchives.droid.core.interfaces.config.DroidGlobalProperty; +import uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo; +import uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureType; +import uk.gov.nationalarchives.droid.gui.GlobalContext; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.GroupLayout; +import javax.swing.GroupLayout.Alignment; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFormattedTextField; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import javax.swing.GroupLayout.Alignment; -import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; - -import org.apache.commons.collections4.list.SetUniqueList; -import org.jdesktop.beansbinding.BeanProperty; -import org.jdesktop.beansbinding.Binding; -import org.jdesktop.beansbinding.BindingGroup; -import org.jdesktop.beansbinding.Bindings; -import org.jdesktop.beansbinding.ELProperty; -import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy; -import org.jdesktop.observablecollections.ObservableCollections; -import org.jdesktop.observablecollections.ObservableList; -import org.jdesktop.observablecollections.ObservableMap; -import org.jdesktop.swingbinding.JComboBoxBinding; -import org.jdesktop.swingbinding.SwingBindings; -import org.openide.util.NbBundle; - -import uk.gov.nationalarchives.droid.core.interfaces.config.DroidGlobalProperty; -import uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo; -import uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureType; -import uk.gov.nationalarchives.droid.gui.GlobalContext; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ItemEvent; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.SortedMap; /** * @@ -100,9 +99,11 @@ public class ConfigDialog extends JDialog { private static final String PRONOM_SIGNATURE_URL_KEY = "pronom.update.url"; private static final String PRONOM_CONTAINER_URL_KEY = "container.update.url"; - + private final List propertiesAffectingNewProfile = new ArrayList<>(); + private boolean automaticallyCreateNewProfile; private int response; - private Map props = new HashMap(); + private final Map props = new HashMap(); + private final Map propsOnLaunch = new HashMap(); private GlobalContext context; private ObservableMap globalConfig = ObservableCollections.observableMap(props); @@ -129,21 +130,37 @@ public class ConfigDialog extends JDialog { public ConfigDialog(Frame owner, GlobalContext context) { super(owner, true); this.context = context; + populatePropertyListNeedingNewProfile(); init(context.getGlobalConfig().getPropertiesMap()); initComponents(); setPanelComponents(autoUpdatePanel, autoUpdateCheckbox.isSelected()); updateFrequencyTextBox.setEnabled(updateScheduleRadioButton.isSelected() && autoUpdateCheckbox.isSelected()); setLocationRelativeTo(owner); } - + + private void populatePropertyListNeedingNewProfile() { + propertiesAffectingNewProfile.addAll( + Arrays.asList(DroidGlobalProperty.BINARY_UPDATE_URL.getName(), DroidGlobalProperty.CONTAINER_UPDATE_URL.getName(), + DroidGlobalProperty.PROCESS_ZIP.getName(), DroidGlobalProperty.PROCESS_TAR.getName(), + DroidGlobalProperty.PROCESS_GZIP.getName(), DroidGlobalProperty.PROCESS_RAR.getName(), + DroidGlobalProperty.PROCESS_7ZIP.getName(), DroidGlobalProperty.PROCESS_ISO.getName(), + DroidGlobalProperty.PROCESS_BZIP2.getName(), DroidGlobalProperty.PROCESS_ARC.getName(), + DroidGlobalProperty.PROCESS_WARC.getName(), DroidGlobalProperty.GENERATE_HASH.getName(), + DroidGlobalProperty.HASH_ALGORITHM.getName(), DroidGlobalProperty.MAX_BYTES_TO_SCAN.getName(), + DroidGlobalProperty.EXTENSION_ALL.getName(), DroidGlobalProperty.DEFAULT_THROTTLE.getName() + ) + ); + } + /** * Initialises the dialog with all the settings. * @param properties the settings */ public void init(Map properties) { response = CANCEL; - + props.putAll(properties); + propsOnLaunch.putAll(properties); //copy of initial state to detect dirty later final Map> allSignatureFiles = context.getActionFactory().newListSignatureFilesAction().list(); @@ -295,11 +312,7 @@ private void initComponents() { generateHashCheckBox, BeanProperty.create("selected")); bindingGroup.addBinding(binding); - generateHashCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - generateHashCheckBoxActionPerformed(evt); - } - }); + generateHashCheckBox.addActionListener(evt -> generateHashCheckBoxActionPerformed(evt)); eLProperty = ELProperty.create("${allContainerSigFiles}"); jComboBoxBinding = SwingBindings.createJComboBoxBinding(UpdateStrategy.READ, this, eLProperty, containerSigCombo); @@ -309,11 +322,7 @@ public void actionPerformed(ActionEvent evt) { containerSigCombo, BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); - containerSigCombo.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - containerSigComboActionPerformed(evt); - } - }); + containerSigCombo.addActionListener(evt -> containerSigComboActionPerformed(evt)); containerSigFileLabel.setLabelFor(containerSigCombo); containerSigFileLabel.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.containerSigFileLabel.text_1")); // NOI18N @@ -328,7 +337,7 @@ public void actionPerformed(ActionEvent evt) { jLabel9.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.jLabel9.text")); // NOI18N buttonGroupExtension.add(rowPerFileButton2); - rowPerFileButton2.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.rowPerFileButton2.text")); // NOI18N + rowPerFileButton2.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.matchAllExtensions.text")); // NOI18N binding = Bindings.createAutoBinding(UpdateStrategy.READ, this, ELProperty.create("${!globalConfig[\"profile.matchAllExtensions\"]}"), @@ -336,7 +345,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); buttonGroupExtension.add(rowPerFormatButton2); - rowPerFormatButton2.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.rowPerFormatButton2.text")); // NOI18N + rowPerFormatButton2.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.matchExtensionNoSig.text")); // NOI18N binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.matchAllExtensions\"]}"), @@ -351,20 +360,12 @@ public void actionPerformed(ActionEvent evt) { hashAlgorithmCombo, BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); - hashAlgorithmCombo.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - hashAlgorithmComboActionPerformed(evt); - } - }); + hashAlgorithmCombo.addActionListener(evt -> hashAlgorithmComboActionPerformed(evt)); jLabel10.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.jLabel10.text_1")); // NOI18N processZipCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processZipCheckBox.text")); // NOI18N - processZipCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processZipCheckBoxActionPerformed(evt); - } - }); + processZipCheckBox.addActionListener(evt -> processZipCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processZip\"]}"), @@ -374,11 +375,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); processTarCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processTarCheckBox.text")); // NOI18N - processTarCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processTarCheckBoxActionPerformed(evt); - } - }); + processTarCheckBox.addActionListener(evt -> processTarCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processTar\"]}"), @@ -389,11 +386,7 @@ public void actionPerformed(ActionEvent evt) { processGzipCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processGzipCheckBox.text")); // NOI18N - processGzipCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processGzipCheckBoxActionPerformed(evt); - } - }); + processGzipCheckBox.addActionListener(evt -> processGzipCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processGzip\"]}"), @@ -403,11 +396,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); processRarCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processRarCheckBox.text")); // NOI18N - processRarCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processRarCheckBoxActionPerformed(evt); - } - }); + processRarCheckBox.addActionListener(evt -> processRarCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processRar\"]}"), @@ -417,11 +406,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); process7zipCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.process7zipCheckBox.text")); // NOI18N - process7zipCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - process7zipCheckBoxActionPerformed(evt); - } - }); + process7zipCheckBox.addActionListener(evt -> process7zipCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.process7zip\"]}"), @@ -431,11 +416,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); processIsoCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processIsoCheckBox.text")); // NOI18N - processIsoCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processIsoCheckBoxActionPerformed(evt); - } - }); + processIsoCheckBox.addActionListener(evt -> processIsoCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processIso\"]}"), @@ -445,11 +426,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); processBzip2CheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processBzip2CheckBox.text")); // NOI18N - processBzip2CheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processBzip2CheckBoxActionPerformed(evt); - } - }); + processBzip2CheckBox.addActionListener(evt -> processBzip2CheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processBzip2\"]}"), @@ -459,11 +436,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); toggleArchivesButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.toggleArchivesButton.text")); // NOI18N - toggleArchivesButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - toggleArchivesButtonActionPerformed(evt); - } - }); + toggleArchivesButton.addActionListener(evt -> toggleArchivesButtonActionPerformed(evt)); archivesLabel.setLabelFor(containerSigCombo); archivesLabel.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.archivesLabel.text")); // NOI18N @@ -516,11 +489,7 @@ public void actionPerformed(ActionEvent evt) { webArchivesLabel.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.webArchivesLabel.text")); // NOI18N processArcCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processArcCheckBox.text")); // NOI18N - processArcCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processArcCheckBoxActionPerformed(evt); - } - }); + processArcCheckBox.addActionListener(evt -> processArcCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processArc\"]}"), @@ -530,11 +499,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); processWarcCheckBox.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.processWarcCheckBox.text")); // NOI18N - processWarcCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - processWarcCheckBoxActionPerformed(evt); - } - }); + processWarcCheckBox.addActionListener(evt -> processWarcCheckBoxActionPerformed(evt)); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${globalConfig[\"profile.processWarc\"]}"), @@ -544,11 +509,7 @@ public void actionPerformed(ActionEvent evt) { bindingGroup.addBinding(binding); toggleWebArchivesButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.toggleWebArchivesButton.text")); // NOI18N - toggleWebArchivesButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - toggleWebArchivesButtonActionPerformed(evt); - } - }); + toggleWebArchivesButton.addActionListener(evt -> toggleWebArchivesButtonActionPerformed(evt)); GroupLayout jPanel6Layout = new GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); @@ -678,11 +639,7 @@ public void actionPerformed(ActionEvent evt) { rowPerFormatButton1, BeanProperty.create("selected")); bindingGroup.addBinding(binding); - rowPerFormatButton1.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - rowPerFormatButton1ActionPerformed(evt); - } - }); + rowPerFormatButton1.addActionListener(evt -> rowPerFormatButton1ActionPerformed(evt)); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); @@ -734,11 +691,7 @@ public void actionPerformed(ActionEvent evt) { updateUrlTextBox, BeanProperty.create("text")); bindingGroup.addBinding(binding); - updateUrlTextBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - updateUrlTextBoxActionPerformed(evt); - } - }); + updateUrlTextBox.addActionListener(evt -> updateUrlTextBoxActionPerformed(evt)); autoUpdatePanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(""), @@ -763,11 +716,7 @@ public void actionPerformed(ActionEvent evt) { updateOnStartupRadioButton, BeanProperty.create("selected")); bindingGroup.addBinding(binding); - updateOnStartupRadioButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - updateOnStartupRadioButtonActionPerformed(evt); - } - }); + updateOnStartupRadioButton.addActionListener(evt -> updateOnStartupRadioButtonActionPerformed(evt)); updateFrequencyButtonGroup.add(updateScheduleRadioButton); updateScheduleRadioButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.updateScheduleRadioButton.text")); // NOI18N @@ -810,20 +759,12 @@ public void actionPerformed(ActionEvent evt) { autoUpdateCheckbox, BeanProperty.create("selected")); bindingGroup.addBinding(binding); - autoUpdateCheckbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent evt) { - autoUpdateItemStateChanged(evt); - } - }); + autoUpdateCheckbox.addItemListener(evt -> autoUpdateItemStateChanged(evt)); jLabel7.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.jLabel6.text")); // NOI18N proxySettingsButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.proxySettingsButton.text")); // NOI18N - proxySettingsButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - proxySettingsButtonActionPerformed(evt); - } - }); + proxySettingsButton.addActionListener(evt -> proxySettingsButtonActionPerformed(evt)); containerSigUrl.setToolTipText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.containerSigUrl.toolTipText")); // NOI18N @@ -860,18 +801,10 @@ public void actionPerformed(ActionEvent evt) { autoSetDefaultSignatureFileCheckBox, BeanProperty.create("selected")); bindingGroup.addBinding(binding); - autoSetDefaultSignatureFileCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - autoSetDefaultSignatureFileCheckBoxActionPerformed(evt); - } - }); + autoSetDefaultSignatureFileCheckBox.addActionListener(evt -> autoSetDefaultSignatureFileCheckBoxActionPerformed(evt)); pronomUrlResetButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.pronomUrlResetButton.text")); // NOI18N - pronomUrlResetButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - pronomUrlResetButtonActionPerformed(evt); - } - }); + pronomUrlResetButton.addActionListener(evt -> pronomUrlResetButtonActionPerformed(evt)); GroupLayout jPanel5Layout = new GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); @@ -942,18 +875,10 @@ public void actionPerformed(ActionEvent evt) { generalTabbedPane1.addTab(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.jPanel3.TabConstraints.tabTitle"), jPanel5); // NOI18N cancelButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.cancelButton.text")); // NOI18N - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelButtonActionPerformed(evt); - } - }); + cancelButton.addActionListener(evt -> cancelButtonActionPerformed(evt)); okButton.setText(NbBundle.getMessage(ConfigDialog.class, "ConfigDialog.okButton.text")); // NOI18N - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okButtonActionPerformed(evt); - } - }); + okButton.addActionListener(evt -> okButtonActionPerformed(evt)); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -992,9 +917,40 @@ public void actionPerformed(ActionEvent evt) { private void okButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed response = OK; + if (isDirtyForNewProfile()) { + int optionResponse = JOptionPane.showOptionDialog( + this, + NbBundle.getMessage(ConfigDialog.class, "CreateNewProfileQuestionDialog.body.text"), + NbBundle.getMessage(ConfigDialog.class, "CreateNewProfileQuestionDialog.title.text"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + null, + null + ); + switch (optionResponse) { + case JOptionPane.YES_OPTION: + automaticallyCreateNewProfile = true; + break; + case JOptionPane.NO_OPTION: + automaticallyCreateNewProfile = false; + break; + case JOptionPane.CANCEL_OPTION: + return; + } + } dispose(); }//GEN-LAST:event_okButtonActionPerformed + private boolean isDirtyForNewProfile() { + for (String propertyName : propertiesAffectingNewProfile) { + if (!Objects.equals(props.get(propertyName), propsOnLaunch.get(propertyName))) { + return true; + } + } + return false; + } + private void cancelButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed dispose(); }//GEN-LAST:event_cancelButtonActionPerformed @@ -1191,6 +1147,10 @@ private void autoUpdateItemStateChanged(ItemEvent evt) { private BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables + /** + * @return boolean indicating whether the user opted to create a new profile when this dialog closes + */ + public boolean getCreateNewProfile() { return automaticallyCreateNewProfile; } /** * @return the dialog response */ @@ -1254,14 +1214,4 @@ public List getAllHashAlgorithms() { public List getAllContainerSigFiles() { return allContainerSigFiles; } - - /** - * @return the allTextSigFiles - */ - /* - public List getAllTextSigFiles() { - return allTextSigFiles; - } - */ - } diff --git a/droid-swing-ui/src/main/resources/uk/gov/nationalarchives/droid/gui/config/Bundle.properties b/droid-swing-ui/src/main/resources/uk/gov/nationalarchives/droid/gui/config/Bundle.properties index b5211b41c..694dd92ef 100644 --- a/droid-swing-ui/src/main/resources/uk/gov/nationalarchives/droid/gui/config/Bundle.properties +++ b/droid-swing-ui/src/main/resources/uk/gov/nationalarchives/droid/gui/config/Bundle.properties @@ -36,7 +36,7 @@ ConfigDialog.title=Preferences ConfigDialog.cancelButton.text=Cancel ConfigDialog.okButton.text=OK -ConfigDialog.error.text=Error +ConfigDialog.error.title=Error ConfigDialog.error.text=Error updating settings ConfigDialog.proxyPortTextBox.text=jFormattedTextField1 ConfigDialog.proxyPortTextBox.text_1=8888 @@ -105,11 +105,13 @@ ConfigDialog.process7zipCheckBox.text=7zip ConfigDialog.processIsoCheckBox.text=iso ConfigDialog.processBzip2CheckBox.text=bzip2 ConfigDialog.jLabel10.text_1=Changes will only take effect after a new profile is created -ConfigDialog.rowPerFormatButton2.text=Match extensions against all known extensions. -ConfigDialog.rowPerFileButton2.text=Match extensions if no other signatures defined. +ConfigDialog.matchExtensionNoSig.text=Match extensions against all known extensions. +ConfigDialog.matchAllExtensions.text=Match extensions if no other signatures defined. ConfigDialog.jLabel9.text=

Maximum bytes to scan at the start and end of files.

A negative value means unlimited scanning. ConfigDialog.containerSigFileLabel.text_1=Container Signature File ConfigDialog.processArcCheckBox.text=arc ConfigDialog.processWarcCheckBox.text=warc ConfigDialog.toggleWebArchivesButton.text=Check / Uncheck all ConfigDialog.webArchivesLabel.text=Analyse contents of web archive files +CreateNewProfileQuestionDialog.title.text=Create New Profile +CreateNewProfileQuestionDialog.body.text=

You have made changes that will only take effect after a new profile is created.

Do you wish to create a new profile?