@@ -38,32 +38,39 @@ public static void main(String[] args) {
38
38
MarsTerminal terminal = new MarsTerminal ();
39
39
terminal .init ();
40
40
TextIO textIO = new TextIO (terminal );
41
+ terminal .setBookmark ("start" );
41
42
42
- Product product = new Product ();
43
- SwingHandler handler = new SwingHandler (textIO , product );
43
+ while (true ) {
44
+ Product product = new Product ();
45
+ SwingHandler handler = new SwingHandler (textIO , "mars-demo" , product );
44
46
45
- terminal .println ("----------------------------------------------------------------" );
46
- terminal .println ("| Use the up and down arrow keys to scroll through choices. |" );
47
- terminal .println ("| Press '" + handler .getBackKeyStroke () + "' to go back to the previous field. |" );
48
- terminal .println ("----------------------------------------------------------------\n " );
47
+ terminal .println ("---------------------------------------------------------------------------------------------------------" );
48
+ terminal .println ("| Use the Up and Down arrow keys to scroll through choices. |" );
49
+ terminal .println ("| Use the Ctrl-Shift-Left and Ctrl-Shift-Right arrow keys to scroll through previous entered values. |" );
50
+ terminal .println ("| Press '" + handler .getBackKeyStroke () + "' to go back to the previous field. |" );
51
+ terminal .println ("---------------------------------------------------------------------------------------------------------\n " );
49
52
50
- handler .addStringTask ("name" , "Product name" )
51
- .addChoices ("air conditioner" , "air ioniser" , "air purifier" , "appliance plug" , "aroma lamp" , "attic fan" , "bachelor griller" , "back boiler" , "beverage opener" , "blender" , "box mangle" , "can opener" , "ceiling fan" , "central vacuum cleaner" , "clothes dryer" , "clothes iron" , "cold-pressed juicer" , "combo washer dryer" , "dish draining closet" , "dishwasher" , "domestic robot" , "drawer dishwasher" , "electric water boiler" , "exhaust hood" , "fan heater" , "flame supervision device" , "forced-air" , "futon dryer" , "garbage disposal unit" , "gas appliance" , "go-to-bed matchbox" , "hair dryer" , "hair iron" , "hob (hearth)" , "home server" , "humidifier" , "hvac" , "icebox" , "kimchi refrigerator" , "light fixture" , "light" , "mangle (machine)" , "micathermic heater" , "microwave oven" , "mobile charger" , "mousetrap" , "oil heater" , "oven" , "patio heater" , "paper shredder" , "radiator (heating)" , "refrigerator" , "sewing machine" , "space heater" , "steam mop" , "stove" , "sump pump" , "television" , "tie press" , "toaster and toaster ovens" , "trouser press" , "vacuum cleaner" , "washing machine" , "water cooker" , "water purifier" , "water heater" , "window fan" , "waffle iron" )
52
- .constrainInputToChoices ();
53
- handler .addIntTask ("quantity" , "Quantity" )
54
- .withInputReaderConfigurator (r -> r .withMinVal (1 ).withMaxVal (50 ))
55
- .addChoices (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 );
56
- handler .addDoubleTask ("unitPrice" , "Unit price" )
57
- .withInputReaderConfigurator (r -> r .withMinVal (0.01 ).withMaxVal (99.99 ))
58
- .addChoices (0.59 , 0.86 , 0.99 , 1.14 , 1.55 , 1.63 , 1.74 , 1.99 , 2.55 , 2.88 , 2.99 );
59
- handler .addStringTask ("color" , "Color" )
60
- .withInputReaderConfigurator (r -> r .withPropertiesPrefix ("highlight" ))
61
- .addChoices ("amaranth" , "amber" , "amethyst" , "apricot" , "aquamarine" , "azure" , "baby blue" , "beige" , "black" , "blue" , "blue-green" , "blue-violet" , "blush" , "bronze" , "brown" , "burgundy" , "byzantium" , "carmine" , "cerise" , "cerulean" , "champagne" , "chartreuse" , "chocolate" , "cobalt blue" , "coffee" , "copper" , "coral" , "crimson" , "cyan" , "desert sand" , "electric blue" , "emerald" , "erin" , "gold" , "gray" , "green" , "harlequin" , "indigo" , "ivory" , "jade" , "jungle green" , "lavender" , "lemon" , "lilac" , "lime" , "magenta" , "magenta rose" , "maroon" , "mauve" , "navy blue" , "ocher" , "olive" , "orange" , "orange-red" , "orchid" , "peach" , "pear" , "periwinkle" , "persian blue" , "pink" , "plum" , "prussian blue" , "puce" , "purple" , "raspberry" , "red" , "red-violet" , "rose" , "ruby" , "salmon" , "sangria" , "sapphire" , "scarlet" , "silver" , "slate gray" , "spring bud" , "spring green" , "tan" , "taupe" , "teal" , "turquoise" , "violet" , "viridian" , "white" , "yellow" );
62
- handler .execute ();
53
+ handler .addStringTask ("name" , "Product name" )
54
+ .addChoices ("air conditioner" , "air ioniser" , "air purifier" , "appliance plug" , "aroma lamp" , "attic fan" , "bachelor griller" , "back boiler" , "beverage opener" , "blender" , "box mangle" , "can opener" , "ceiling fan" , "central vacuum cleaner" , "clothes dryer" , "clothes iron" , "cold-pressed juicer" , "combo washer dryer" , "dish draining closet" , "dishwasher" , "domestic robot" , "drawer dishwasher" , "electric water boiler" , "exhaust hood" , "fan heater" , "flame supervision device" , "forced-air" , "futon dryer" , "garbage disposal unit" , "gas appliance" , "go-to-bed matchbox" , "hair dryer" , "hair iron" , "hob (hearth)" , "home server" , "humidifier" , "hvac" , "icebox" , "kimchi refrigerator" , "light fixture" , "light" , "mangle (machine)" , "micathermic heater" , "microwave oven" , "mobile charger" , "mousetrap" , "oil heater" , "oven" , "patio heater" , "paper shredder" , "radiator (heating)" , "refrigerator" , "sewing machine" , "space heater" , "steam mop" , "stove" , "sump pump" , "television" , "tie press" , "toaster and toaster ovens" , "trouser press" , "vacuum cleaner" , "washing machine" , "water cooker" , "water purifier" , "water heater" , "window fan" , "waffle iron" )
55
+ .constrainInputToChoices ();
56
+ handler .addIntTask ("quantity" , "Quantity" )
57
+ .withInputReaderConfigurator (r -> r .withMinVal (1 ).withMaxVal (50 ))
58
+ .addChoices (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 );
59
+ handler .addDoubleTask ("unitPrice" , "Unit price" )
60
+ .withInputReaderConfigurator (r -> r .withMinVal (0.01 ).withMaxVal (99.99 ))
61
+ .addChoices (0.59 , 0.86 , 0.99 , 1.14 , 1.55 , 1.63 , 1.74 , 1.99 , 2.55 , 2.88 , 2.99 );
62
+ handler .addStringTask ("color" , "Color" )
63
+ .withInputReaderConfigurator (r -> r .withPropertiesPrefix ("highlight" ))
64
+ .addChoices ("amaranth" , "amber" , "amethyst" , "apricot" , "aquamarine" , "azure" , "baby blue" , "beige" , "black" , "blue" , "blue-green" , "blue-violet" , "blush" , "bronze" , "brown" , "burgundy" , "byzantium" , "carmine" , "cerise" , "cerulean" , "champagne" , "chartreuse" , "chocolate" , "cobalt blue" , "coffee" , "copper" , "coral" , "crimson" , "cyan" , "desert sand" , "electric blue" , "emerald" , "erin" , "gold" , "gray" , "green" , "harlequin" , "indigo" , "ivory" , "jade" , "jungle green" , "lavender" , "lemon" , "lilac" , "lime" , "magenta" , "magenta rose" , "maroon" , "mauve" , "navy blue" , "ocher" , "olive" , "orange" , "orange-red" , "orchid" , "peach" , "pear" , "periwinkle" , "persian blue" , "pink" , "plum" , "prussian blue" , "puce" , "purple" , "raspberry" , "red" , "red-violet" , "rose" , "ruby" , "salmon" , "sangria" , "sapphire" , "scarlet" , "silver" , "slate gray" , "spring bud" , "spring green" , "tan" , "taupe" , "teal" , "turquoise" , "violet" , "viridian" , "white" , "yellow" );
65
+ handler .execute ();
63
66
64
- terminal .println ("\n Product info: " + product );
67
+ terminal .println ("\n Product info: " + product );
68
+
69
+ if (!textIO .newBooleanInputReader ().withDefaultValue (true ).read ("Run again?" )) break ;
70
+
71
+ terminal .resetToBookmark ("start" );
72
+ }
65
73
66
- textIO .newStringInputReader ().withMinLength (0 ).read ("\n Press enter to terminate..." );
67
74
textIO .dispose ();
68
75
}
69
76
}
0 commit comments