changeset 116:85d38a6a2349

Card: Started on option functions
author Fox
date Tue, 29 Aug 2023 21:53:05 +0200
parents d63c1d41f364
children 652027516bd6
files src/junotu/Card.java src/junotu/TabCalendarBoard.java
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/Card.java	Tue Aug 29 21:32:37 2023 +0200
+++ b/src/junotu/Card.java	Tue Aug 29 21:53:05 2023 +0200
@@ -181,6 +181,20 @@
 		return tags.containsKey(tag);
 	}
 	
+	public void optionSetBool( String option, boolean value )
+	{
+		tagValueSetOnly( option, Boolean.toString(value) );
+	}
+	
+	public boolean optionGetBool( String option, boolean or )
+	{
+		if( tagHas(option) ) {
+			return Boolean.parseBoolean( tagGetAs(option) );
+		} else {
+			return or;
+		}
+	}
+	
 	public boolean isBoard()
 	{
 		return tags.containsKey(TAG_BOARD);
--- a/src/junotu/TabCalendarBoard.java	Tue Aug 29 21:32:37 2023 +0200
+++ b/src/junotu/TabCalendarBoard.java	Tue Aug 29 21:53:05 2023 +0200
@@ -529,7 +529,7 @@
 			throw new RuntimeException();
 		}
 		
-		optionOnlyFilledColumns = card.tagHas( Card.TAG_CALENDAR_BOARD_OPTION_ONLY_FILLED );
+		optionOnlyFilledColumns = card.optionGetBool( Card.TAG_CALENDAR_BOARD_OPTION_ONLY_FILLED, false );
 		menu_onlyFilled.setSelected(optionOnlyFilledColumns);
 		
 		populateColumns();
@@ -550,12 +550,7 @@
 		card.titleSet( "JUnotu calendar board" );
 		card.tagValueSetOnly( Card.TAG_CALENDAR_BOARD, null );
 		
-		// TODO: Maybe card should have convenience functions for reading and writing options?
-		if( optionOnlyFilledColumns ) {
-			card.tagValueSetOnly( Card.TAG_CALENDAR_BOARD_OPTION_ONLY_FILLED, null );
-		} else {
-			card.tagRemove( Card.TAG_CALENDAR_BOARD_OPTION_ONLY_FILLED );
-		}
+		card.optionSetBool( Card.TAG_CALENDAR_BOARD_OPTION_ONLY_FILLED, optionOnlyFilledColumns );
 		
 		Component[] columnsList = columns.getComponents();
 		for( int i = 0; i < columnsList.length; i++ ) {