changeset 33:2c1f4dc0513f

TabSimpleSearch: Use control + S keyboard shortcut to save changes to disk
author Fox
date Wed, 11 May 2022 02:43:31 +0200
parents 6cbb34600e38
children 06b4a235d4bc
files src/junotu/Database.java src/junotu/TabSimpleSearch.java
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/Database.java	Wed May 11 02:32:44 2022 +0200
+++ b/src/junotu/Database.java	Wed May 11 02:43:31 2022 +0200
@@ -72,6 +72,7 @@
 
     public void databaseCommit() throws Exception
     {
+	System.out.print( "Saving database to disk..\n" );
 	luceneWriter.commit();
     }
 
--- a/src/junotu/TabSimpleSearch.java	Wed May 11 02:32:44 2022 +0200
+++ b/src/junotu/TabSimpleSearch.java	Wed May 11 02:43:31 2022 +0200
@@ -4,9 +4,12 @@
 
 import java.awt.Dimension;
 import java.awt.Font;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
+import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.DocumentEvent;
@@ -94,6 +97,23 @@
 						    }
 						}
 						);
+
+	registerKeyboardAction(
+			       new ActionListener() {
+				   @Override
+				   public void actionPerformed( ActionEvent e )
+				   {
+				       try {
+					   Main.database.databaseCommit();
+				       } catch( Exception ex ) {
+					   System.out.print( "Failed to write database: "+ex.getMessage()+"\n" );
+				       }
+				   }
+			       },
+			       null,
+			       KeyStroke.getKeyStroke( KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK ),
+			       WHEN_IN_FOCUSED_WINDOW
+			       );
 	
     }