Skip to content

Commit

Permalink
Ensure all default_widget functions have a display parameter.
Browse files Browse the repository at this point in the history
Favour the type checked signature and remove the other typedef line for these.
  • Loading branch information
jdunkerley committed Nov 14, 2024
1 parent 26a057d commit 2b5b5c1
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ type Filter_Condition

## PRIVATE
Creates a Single_Choice Widget for delimiters.
default_widget : Boolean -> Boolean -> Boolean -> Boolean -> Boolean -> Boolean -> Boolean -> Boolean -> Widget
default_widget include_comparable=True include_text=True include_boolean=True include_nullable=True include_numeric=True include_date=True include_time=True include_date_time=True =
default_widget include_comparable:Boolean=True include_text:Boolean=True include_boolean:Boolean=True include_nullable:Boolean=True include_numeric:Boolean=True include_date:Boolean=True include_time:Boolean=True include_date_time:Boolean=True display:Display=..When_Modified -> Widget =
options = Vector.build builder->
equatable_types = make_any_selector add_text=include_text add_boolean=include_boolean add_number=include_numeric add_date=include_date add_time=include_time add_date_time=include_date_time
builder.append (Option "Equals" "..Equal" [["to", equatable_types]])
Expand Down Expand Up @@ -297,7 +296,7 @@ type Filter_Condition
value_editor = Widget.Vector_Editor item_editor=equatable_types display=Display.Always item_default='""'
builder.append (Option "Is In" "..Is_In" [["values", value_editor]])

make_single_choice options
make_single_choice options display=display

## Specifies the action of a Filter_Condition.
type Filter_Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ type Index_Sub_Range
[o1, o2, o4, o5, o6, o7, o3]

## PRIVATE
default_widget : (Integer|Nothing) -> Widget
default_widget count:(Integer|Nothing)=Nothing =
Single_Choice display=Display.Always (Index_Sub_Range.default_options count)
default_widget count:(Integer|Nothing)=Nothing display:Display=..Always -> Widget =
Single_Choice display=display (Index_Sub_Range.default_options count)

## PRIVATE
Resolves a vector of ranges or indices into a vector of ranges that fit
Expand Down
4 changes: 2 additions & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Locale.enso
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ type Locale

## PRIVATE
Gets the default drop down option for Locale.
default_widget : Widget
default_widget = Widget.Single_Choice values=Locale.widget_options display=Display.When_Modified
default_widget display:Display=..When_Modified -> Widget =
Widget.Single_Choice values=Locale.widget_options display=display

## PRIVATE
predefined_locale_fields : Vector Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ type Return_As
_ -> Panic.throw (Type_Error.Error Return_As value "Expected `return` to be a Return_As type, but got {got}.")

## PRIVATE
default_widget : Widget
default_widget =
default_widget display:Display=..When_Modified -> Widget =
options = _get_known_return_classes.map .get_dropdown_options
Single_Choice display=Display.Always values=options
Single_Choice display=display values=options

## PRIVATE
type Return_As_Base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ polyglot java import org.enso.base.Text_Utils
## Represents a character encoding.
type Encoding
## PRIVATE
Gets the default drop down option for this encoding.
default_widget : Widget
default_widget =
Gets the default drop down option for Encoding.
default_widget display:Display=..When_Modified -> Widget =
fqn = Meta.get_qualified_type_name Encoding
values = [Option "UTF-8" fqn+".utf_8", Option "ASCII" fqn+".ascii", Option "UTF-16LE" fqn+".utf_16_le", Option "UTF-16BE" fqn+".utf_16_be", Option "UTF-32LE" fqn+".utf_32_le", Option "UTF-32BE" fqn+".utf_32_be", Option "Windows-1250" fqn+".windows_1250", Option "Windows-1251" fqn+".windows_1251", Option "Windows-1252" fqn+".windows_1252", Option "Windows-1253" fqn+".windows_1253", Option "Windows-1254" fqn+".windows_1254", Option "Windows-1255" fqn+".windows_1255", Option "Windows-1256" fqn+".windows_1256", Option "Windows-1257" fqn+".windows_1257", Option "Windows-1258" fqn+".windows_1258"]
Single_Choice values=values display=Display.When_Modified
Single_Choice values=values display=display

## PRIVATE
ADVANCED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ type Text_Sub_Range
The widget for `Text_Sub_Range` also displays options for
`Index_Sub_Range` since the former is supposed to 'expand' the latter and
is always used together with it.
default_widget : Widget
default_widget =
default_widget display:Display=..When_Modified -> Widget =
options = Index_Sub_Range.default_options + Text_Sub_Range.default_options
Single_Choice display=Display.Always options
Single_Choice display=display options

type Codepoint_Ranges
## PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,9 @@ type Date

## PRIVATE
Gets the default drop down option for Date.
default_widget : Boolean -> Widget
default_widget (include_today:Boolean=False) =
default_widget (include_today:Boolean=False) display:Display=..When_Modified -> Widget =
options = [Option "<Fixed Date>" "Date.new"] + (if include_today then [Option "<Today>" "Date.today"] else [])
Widget.Single_Choice values=options display=Display.When_Modified
Widget.Single_Choice values=options display=display

## PRIVATE
week_days_between start end =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,9 @@ type Time_Of_Day

## PRIVATE
Gets the default drop down option for Time_Of_Day.
default_widget : Boolean -> Widget
default_widget (include_now:Boolean=False) =
default_widget (include_now:Boolean=False) display:Display=..When_Modified -> Widget =
options = [Option "<Fixed Time>" "Time_Of_Day.new"] + (if include_now then [Option "<Now>" "Time_Of_Day.now"] else [])
Widget.Single_Choice values=options display=Display.When_Modified
Widget.Single_Choice values=options display=display

## PRIVATE
Time_Of_Day.from (that:JS_Object) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,9 @@ type Time_Zone

## PRIVATE
Gets the default drop down option for Time_Zone.
default_widget : Widget
default_widget =
default_widget display:Display=..When_Modified -> Widget =
options = [Option "System" "Time_Zone.system", Option "Local" "Time_Zone.local", Option "UTC" "Time_Zone.utc", Option "Named" "(Time_Zone.parse 'UTC')", Option "custom" "(Time_Zone.new 1 0 0)"]
Widget.Single_Choice values=options display=Display.When_Modified
Widget.Single_Choice values=options display=display

## ICON time
Gets a list of all the time zone names that are predefined.
Expand Down
3 changes: 1 addition & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Metadata.enso
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ type Widget
JS_Object.from_pairs (type_pair + cons_pair + field_pairs)

## PRIVATE
make_single_choice : Vector -> Display -> Widget
make_single_choice values display:Display=..Always =
make_single_choice values:Vector display:Display=..Always -> Widget =
make_option value = case value of
_ : Vector -> Choice.Option value.first value.second
_ : Text -> Choice.Option value value.pretty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ type File_Format
format_types.flat_map .get_name_patterns . flat_map .patterns . distinct

## PRIVATE
default_widget : Widget
default_widget =
default_widget display:Display=..When_Modified -> Widget =
options = ([Auto_Detect]+format_types).flat_map .get_dropdown_options
Single_Choice display=Display.Always values=options
Single_Choice display=display values=options

## PRIVATE
Builds a widget intended to be used for `name_filter` of `File.list` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ from project.Metadata.Choice import Option

## PRIVATE
Creates a Single_Choice Widget for text or secret value.
make_text_secret_selector : Widget
make_text_secret_selector =
make_text_secret_selector display:Display=..When_Modified -> Widget =
fqn = Meta.get_qualified_type_name Enso_Secret
make_single_choice [['<Text Value>', '""'], ['<Secret Value>', fqn+".get"]]
make_single_choice [['<Text Value>', '""'], ['<Secret Value>', fqn+".get"]] display=display

## PRIVATE
Creates a Regex / Text Widget for search and replace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ type Connection_Options

## PRIVATE
Widget to design connection options.
default_widget : Widget
default_widget =
default_widget display:Display=..Always -> Widget =
fqn = Meta.get_qualified_type_name Pair . take (..Before_Last '.')
default = 'pair "key" "value"'
pair = Option "Pair" fqn+".pair" [["first", Text_Input], ["second", make_text_secret_selector]]
item_editor = Single_Choice display=..Always values=[pair]
Vector_Editor item_editor=item_editor display=..Always item_default=default
Vector_Editor item_editor=item_editor display=display item_default=default

## PRIVATE
Connection_Options.from (that:Vector) = Connection_Options.Value that
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Credentials
to_display_text self -> Text = self.to_text.to_display_text

## PRIVATE
default_widget (include_nothing : Boolean = True) -> Widget =
default_widget (include_nothing : Boolean = True) display:Display=..When_Modified -> Widget =
fqn = Meta.get_qualified_type_name Credentials
values = [Option "Username_And_Password" fqn+".Username_And_Password"] + if include_nothing then [Option "No credentials" "Nothing"] else []
Single_Choice values=values display=Display.When_Modified
Single_Choice values=values display=display
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Standard.Base import all
from Standard.Base.Metadata import make_single_choice, Widget
from Standard.Base.Metadata import Display, make_single_choice, Widget
from Standard.Base.Metadata.Choice import Option
from Standard.Base.Metadata.Widget import Text_Input, Vector_Editor

Expand Down Expand Up @@ -70,14 +70,13 @@ type Google_Analytics_Account_Filter
Accounts accounts:Vector

## PRIVATE
default_widget : Any -> Any -> Widget
default_widget self_arg cache =
default_widget self_arg cache display:Display=..Always -> Widget =
_ = self_arg
default = [Option "<All>" "..All_Accounts", Option "<Account>" "..Account", Option "<Multiple Accounts>" "..Accounts"]
Panic.catch Any handler=_->(make_single_choice default) <|
credentials = cache.if_not_nothing <| cache "credentials"
options = Google_Analytics.list_accounts credentials=(credentials.if_nothing Google_Credential.Default) limit=(..First 10) . map p->(Option (p.name + " (" + p.id + ")") "..Account "+p.id.pretty)
make_single_choice default+options display=..Always
make_single_choice default+options display=display

## PRIVATE
private as_java self -> Array | Nothing = case self of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Standard.Base import all
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Base.Metadata import make_single_choice, Widget
from Standard.Base.Metadata import Display, make_single_choice, Widget
from Standard.Base.Metadata.Choice import Option

import project.Google_Analytics.Google_Analytics
Expand Down Expand Up @@ -65,13 +65,12 @@ type Google_Analytics_Property
Google_Analytics.list_dimensions self credentials

## PRIVATE
default_widget : Any -> Any -> Widget
default_widget self_arg cache =
default_widget self_arg cache display:Display=..Always -> Widget =
_ = self_arg
Panic.catch Any handler=_->(Widget.Text_Input display=..Always) <|
Panic.catch Any handler=_->(Widget.Text_Input display=display) <|
credentials = cache.if_not_nothing <| cache "credentials"
options = Google_Analytics.list_properties account=..All_Accounts credentials=(credentials.if_nothing Google_Credential.Default) limit=(..First 10) . map p->(Option (p.name + " (" + p.id + ")") p.id.pretty)
make_single_choice options display=..Always
make_single_choice options display=display

## PRIVATE
Google_Analytics_Property.from (that:Text) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Standard.Base import all
import Standard.Base.Errors.Common.Missing_Argument
from Standard.Base.Metadata import Choice, make_single_choice, Widget
from Standard.Base.Metadata import Choice, Display, make_single_choice, Widget
from Standard.Base.Metadata.Choice import Option

polyglot java import com.google.api.gax.core.CredentialsProvider
Expand Down Expand Up @@ -45,9 +45,8 @@ type Google_Credential
Google_Credential.Default -> Nothing

## PRIVATE
default_widget : Widget
default_widget =
make_single_choice [Option "File" "..From_File", Option "Default" "..Default"]
default_widget display:Display=..When_Modified -> Widget =
make_single_choice [Option "File" "..From_File", Option "Default" "..Default"] display=display

## PRIVATE
Google_Credential.from (that:File) = Google_Credential.From_File that
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Standard.Base import all
from Standard.Base.Metadata import make_single_choice, Widget
from Standard.Base.Metadata import Display, make_single_choice, Widget

## PRIVATE
type Columns_To_Add
Expand All @@ -10,8 +10,8 @@ type Columns_To_Add
First columns:Integer=1

## PRIVATE
default_widget -> Widget =
make_single_choice [["All_Columns", "..All_Columns"], ["First", "..First"]]
default_widget display:Display=..When_Modified -> Widget =
make_single_choice [["All_Columns", "..All_Columns"], ["First", "..First"]] display=display

## PRIVATE
Gets the number of columns to add (or Nothing if all columns).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Standard.Base import Text, Vector
from Standard.Base.Metadata import make_single_choice, Widget
from Standard.Base.Metadata import Display, make_single_choice, Widget

## Specifies which columns to keep in a union operation.
type Columns_To_Keep
Expand Down Expand Up @@ -30,6 +30,6 @@ type Columns_To_Keep
The default widget for `Columns_To_Keep`.
It does not display the internal `In_Any_Warn_On_Missing` variant, since
that variant is only meant to be used as the default value.
default_widget -> Widget =
make_single_choice <|
default_widget display:Display=..When_Modified -> Widget =
make_single_choice display=display <|
["In_Any", "In_All", "In_List"].map c-> [c, ".."+c]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Standard.Base import all
from Standard.Base.Metadata import make_single_choice, Widget
from Standard.Base.Metadata import Display, make_single_choice, Widget

import project.Errors.Not_All_Rows_Downloaded
import project.Table.Table
Expand All @@ -18,8 +18,8 @@ type Rows_To_Read
First_With_Warning rows:Integer=1000

## PRIVATE
default_widget -> Widget =
make_single_choice [["All_Rows", "..All_Rows"], ["First", "..First"]]
default_widget display:Display=..When_Modified -> Widget =
make_single_choice [["All_Rows", "..All_Rows"], ["First", "..First"]] display=display

## PRIVATE
Gets the number of rows to read (or Nothing if all rows).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ type Simple_Expression

## PRIVATE
Create a widget for operation
default_widget : Table_Ref -> Display -> Widget
default_widget table:Table_Ref display=Display.Always =
default_widget table:Table_Ref display:Display=..Always -> Widget =
with_everything = Widget_Helpers.make_column_ref_by_name_selector table add_text=True add_number=True add_boolean=True add_date=True add_time=True add_date_time=True add_nothing=True
with_all_types = Widget_Helpers.make_column_ref_by_name_selector table add_text=True add_number=True add_boolean=True add_date=True add_time=True add_date_time=True
with_number_text = Widget_Helpers.make_column_ref_by_name_selector table add_text=True add_number=True
Expand Down

0 comments on commit 2b5b5c1

Please sign in to comment.