changeset 114:14506c250461

TabOptions: Made action options work
author Fox
date Tue, 29 Aug 2023 21:05:48 +0200
parents 5c74293fb41a
children d63c1d41f364
files src/junotu/OptionTree.java src/junotu/TabOptions.java
diffstat 2 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/OptionTree.java	Tue Aug 29 20:51:51 2023 +0200
+++ b/src/junotu/OptionTree.java	Tue Aug 29 21:05:48 2023 +0200
@@ -107,7 +107,7 @@
 			hint = hint_;
 		}
 		
-		void onClick() {}
+		public void onClick() {}
 		
 	}
 	
--- a/src/junotu/TabOptions.java	Tue Aug 29 20:51:51 2023 +0200
+++ b/src/junotu/TabOptions.java	Tue Aug 29 21:05:48 2023 +0200
@@ -169,12 +169,19 @@
 		
 		developer.add( new OptionTree.OptionCategory( "Actions", "" ) );
 		
-		developer.add( new OptionTree.OptionAction(
-			"Resave all cards",
-			"Go over the whole card database, load each card and save each card. "+
-			"Does not update user edit timestamp, meaning card ordering should not change on the search page. "+
-			"This might be a useful thing to run after changing "+Main.PROGRAM_NAME+" version (updating or downgrading)."
-		) );
+		developer.add(
+			new OptionTree.OptionAction(
+				"Resave all cards",
+				"Go over the whole card database, load each card and save each card. "+
+				"Does not update user edit timestamp, meaning card ordering should not change on the search page. "+
+				"This might be a useful thing to run after changing "+Main.PROGRAM_NAME+" version (updating or downgrading)."
+			) {
+				@Override
+				public void onClick() {
+					Main.database.databaseResaveAll();
+				}
+			}
+		);
 		
 	}
 
@@ -249,7 +256,7 @@
 	{
 		Object source = e.getSource();
 		String command = e.getActionCommand();
-
+		
 		switch( command ) {
 			case ACTION_PATH_BUTTON: {
 				Component[] buttons = pathBox.getComponents();
@@ -262,11 +269,14 @@
 				}
 			}
 		}
-
+		
 		if( source instanceof OptionFolder ) {
 			OptionFolder clicked = (OptionFolder)source;
 			path.add( clicked.option );
 			generate();
+		} else if( source instanceof OptionAction ) {
+			OptionAction clicked = (OptionAction)source;
+			clicked.option.onClick();
 		}
 	}