Added more comments and assertions to all classes; clean up

This commit is contained in:
severin
2014-03-19 16:49:24 +01:00
parent c5363c948c
commit 4e7e1e9c45
25 changed files with 223 additions and 83 deletions

View File

@@ -0,0 +1,8 @@
# Eiffel Web Framework
## Overview
## Dependencies
*

View File

@@ -29,10 +29,12 @@ feature {NONE} -- Initialization
make_with_tag_name (title, "div") make_with_tag_name (title, "div")
end end
make_with_tag_name (title, t: STRING_32) make_with_tag_name (title, tag: STRING_32)
-- Make a dropdown control with specified tag name (such as li) and menu title -- Make a dropdown control with specified tag name (such as li) and menu title
require
tag_not_empty: not tag.is_empty
do do
make_multi_control_with_tag_name (t) make_multi_control_with_tag_name (tag)
add_class ("dropdown") add_class ("dropdown")
create {WSF_BASIC_CONTROL} dropdown_toggle.make_with_body_class ("a", "data-toggle=%"dropdown%" href=%"#%" type=%"button%" id=%"" + control_name + "_toggle%"", "dropdown-toggle", title + " <strong class=%"caret%"></strong>") create {WSF_BASIC_CONTROL} dropdown_toggle.make_with_body_class ("a", "data-toggle=%"dropdown%" href=%"#%" type=%"button%" id=%"" + control_name + "_toggle%"", "dropdown-toggle", title + " <strong class=%"caret%"></strong>")
create dropdown_menu.make_with_tag_name ("ul") create dropdown_menu.make_with_tag_name ("ul")
@@ -45,6 +47,7 @@ feature {NONE} -- Initialization
feature -- Change feature -- Change
add_item (c: WSF_STATELESS_CONTROL) add_item (c: WSF_STATELESS_CONTROL)
-- Wrap the specified control into a <li> tag and add it to the menu
local local
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL] li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do do
@@ -56,6 +59,7 @@ feature -- Change
end end
add_link_item (label, link: STRING_32) add_link_item (label, link: STRING_32)
-- Add an item to the menu which redirects to the specified link
local local
c: WSF_BASIC_CONTROL c: WSF_BASIC_CONTROL
do do
@@ -64,6 +68,7 @@ feature -- Change
end end
add_divider add_divider
-- Append a horizontal divider to the menu
do do
dropdown_menu.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "role=%"menuitem%"", "divider", "")) dropdown_menu.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "role=%"menuitem%"", "divider", ""))
end end
@@ -71,7 +76,9 @@ feature -- Change
feature -- Properties feature -- Properties
dropdown_toggle: WSF_STATELESS_CONTROL dropdown_toggle: WSF_STATELESS_CONTROL
-- The dropdown toggle which causes the menu to pop up or dispose
dropdown_menu: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] dropdown_menu: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- The dropdown menu which holds the single entries (controls and dividers)
end end

View File

@@ -1,5 +1,9 @@
note note
description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}." description: "[
A control that can be used for autocompletion. A customizable
template can be passed to this class in a WSF_AUTOCOMPLETION
instance.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -23,18 +27,18 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (c: WSF_AUTOCOMPLETION) make (c: WSF_AUTOCOMPLETION)
-- Initialize with specified name and autocompletion -- Initialize with specified autocompletion
do do
make_with_agent ( agent c.autocompletion) make_with_agent (agent c.autocompletion)
if attached c.template as t then if attached c.template as t then
template := t template := t
end end
end end
make_with_agent (c: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY]) make_with_agent (c: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY])
-- Initialize with specified name and autocompletion function -- Initialize with autocompletion function
do do
make_input ( "") make_input ("")
create_json_list := c create_json_list := c
template := "{{=value}}" template := "{{=value}}"
end end
@@ -49,10 +53,10 @@ feature -- State
feature -- Callback feature -- Callback
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY) handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
do do
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter) Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
if cname[1].same_string (control_name) and event.same_string ("autocomplete") then if cname [1].same_string (control_name) and event.same_string ("autocomplete") then
state_changes.put (create_json_list.item ([text]), "suggestions") state_changes.put (create_json_list.item ([text]), "suggestions")
end end
end end
@@ -60,7 +64,9 @@ feature -- Callback
feature -- Properties feature -- Properties
create_json_list: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY] create_json_list: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY]
-- The function which is called to give a list of suggestions to a given user input
template: STRING_32 template: STRING_32
-- The template
end end

View File

@@ -1,5 +1,7 @@
note note
description: "Summary description for {WSF_CHECKBOX_CONTROL}." description: "[
Representation of an HTML checkbox.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -11,7 +13,9 @@ inherit
WSF_VALUE_CONTROL [BOOLEAN] WSF_VALUE_CONTROL [BOOLEAN]
rename rename
make as make_value_control make as make_value_control,
value as checked,
set_value as set_checked
end end
create create
@@ -19,12 +23,14 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (l, c: STRING_32) make (l, value: STRING_32)
-- Initialize with specified control name, -- Initialize with specified label and value
require
value_not_empty: not value.is_empty
do do
make_value_control ("input") make_value_control ("input")
label := l label := l
checked_value := c checked_value := value
end end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
@@ -76,12 +82,8 @@ feature -- Implementation
Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attrs) + " " + label, "", ""), "", "checkbox") Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attrs) + " " + label, "", ""), "", "checkbox")
end end
value: BOOLEAN set_checked (v: BOOLEAN)
do -- Set if the checkbox is checked
Result := checked
end
set_value (v: BOOLEAN)
do do
checked := v checked := v
end end
@@ -95,7 +97,7 @@ feature -- Properties
-- The checked value of the checkbox control -- The checked value of the checkbox control
checked_value: STRING_32 checked_value: STRING_32
-- String checked value -- The value of this checkbox
change_event: detachable PROCEDURE [ANY, TUPLE] change_event: detachable PROCEDURE [ANY, TUPLE]
-- Function to be executed on change -- Function to be executed on change

View File

@@ -1,5 +1,7 @@
note note
description: "Summary description for {WSF_CHECKBOX_LIST_CONTROL}." description: "[
Representation of a list of HTML checkboxes.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -37,23 +39,26 @@ feature {NONE} -- Initializaton
feature -- Implementation feature -- Implementation
value: LIST [STRING_32] value: LIST [STRING_32]
-- Returns the values of all selected checkboxes in this list
do do
create {ARRAYED_LIST [STRING_32]} Result.make (0) create {ARRAYED_LIST [STRING_32]} Result.make (0)
across across
controls as c controls as c
loop loop
if c.item.value then if c.item.checked then
Result.extend (c.item.checked_value) Result.extend (c.item.checked_value)
end end
end end
end end
set_value (v: LIST [STRING_32]) set_value (v: LIST [STRING_32])
-- Sets the checked state of each of the checkboxes in this list according to whether the value
-- of a checkbox occurs in the specified list or not
do do
across across
controls as c controls as c
loop loop
c.item.set_value (v.has (c.item.checked_value)) c.item.set_checked (v.has (c.item.checked_value))
end end
end end

View File

@@ -1,5 +1,9 @@
note note
description: "Summary description for {WSF_CODEVIEW_CONTROL}." description:"[
This class is only used because the code viewer has a specific
mapping in javascript. The Eiffel class does not provide
special functionality itself.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"

View File

@@ -1,5 +1,7 @@
note note
description: "Summary description for {WSF_FILE_CONTROL}." description: "[
A control that represents a file upload.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -20,11 +22,13 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
-- Initialize
do do
make_value_control ("input") make_value_control ("input")
end end
make_with_image_preview make_with_image_preview
-- Initialize with image_preview set to true
do do
make make
image_preview := True image_preview := True
@@ -102,6 +106,7 @@ feature -- Event handling
feature -- Upload feature -- Upload
start_upload start_upload
-- Add start upload command to action list which then executes the javascript function to start upload on client side
local local
upload: WSF_JSON_OBJECT upload: WSF_JSON_OBJECT
do do
@@ -137,39 +142,56 @@ feature -- Change
-- Set text change event handle -- Set text change event handle
do do
change_event := e change_event := e
ensure
change_event_set: change_event = e
end end
set_upload_done_event (e: attached like upload_done_event) set_upload_done_event (e: attached like upload_done_event)
-- Set text change event handle -- Set text change event handle
do do
upload_done_event := e upload_done_event := e
ensure
upload_done_event_set: upload_done_event = e
end end
set_upload_function (e: attached like upload_function) set_upload_function (e: attached like upload_function)
-- Set button click event handle -- Set button click event handle
do do
upload_function := e upload_function := e
ensure
upload_function_set: upload_function = e
end end
set_disabled (b: BOOLEAN) set_disabled (b: BOOLEAN)
-- Set the disabled state of this file control
do do
if disabled /= b then if disabled /= b then
disabled := b disabled := b
state_changes.replace_with_boolean (disabled, "disabled") state_changes.replace_with_boolean (disabled, "disabled")
end end
ensure
disabled_set: disabled = b
state_changes_registered: old disabled /= disabled implies state_changes.has_key ("disabled")
end end
set_value (v: detachable WSF_FILE_DEFINITION) set_value (v: detachable WSF_FILE_DEFINITION)
-- Set the file definition of this file control
do do
file := v file := v
ensure then
file_set: file = v
end end
set_image_preview (b: BOOLEAN) set_image_preview (b: BOOLEAN)
-- Set if the image should be previewed in the control
do do
if image_preview /= b then if image_preview /= b then
image_preview := b image_preview := b
state_changes.replace_with_boolean (image_preview, "image_preview") state_changes.replace_with_boolean (image_preview, "image_preview")
end end
ensure
image_preview_set: image_preview = b
state_changes_registered: old image_preview /= image_preview implies state_changes.has_key ("image_preview")
end end
feature -- Properties feature -- Properties

View File

@@ -1,5 +1,8 @@
note note
description: "Summary description for {WSF_FILE_DEFINITION}." description: "[
A container to encapsulate file information which is used by
WSF_FILE_CONTROL, such as name or type of the file.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -20,9 +23,10 @@ feature {NONE}
id := a_id id := a_id
end end
feature feature -- Change
set_id (a_id: detachable STRING_32) set_id (a_id: detachable STRING_32)
-- Set the id of this abstract file.
do do
id := a_id id := a_id
end end
@@ -30,6 +34,7 @@ feature
feature --Properties feature --Properties
is_uploaded: BOOLEAN is_uploaded: BOOLEAN
-- Whether the file denoted by this abstract file has been uploaded.
do do
Result := attached id Result := attached id
end end

View File

@@ -1,5 +1,9 @@
note note
description: "Summary description for {WSF_TEXT_CONTROL}." description: "[
The basic <input> HTML element is represented by this control.
All controls that are used to gather some input from the user
basically can inherit from this class.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -25,6 +29,8 @@ feature {NONE} -- Initialization
make_value_control ("input") make_value_control ("input")
type := "text" type := "text"
text := v text := v
ensure
text_set: text = v
end end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
@@ -52,6 +58,8 @@ feature --Event handling
-- Set text change event handle -- Set text change event handle
do do
change_event := e change_event := e
ensure
change_event_set: change_event = e
end end
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY) handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
@@ -88,31 +96,45 @@ feature -- Change
text := t text := t
state_changes.replace (create {JSON_STRING}.make_json (text), "text") state_changes.replace (create {JSON_STRING}.make_json (text), "text")
end end
ensure
text_same_string_as_t: text.same_string (t)
state_changes_registered: old text /= text implies state_changes.has_key ("text")
end end
set_disabled (b: BOOLEAN) set_disabled (b: BOOLEAN)
-- Set the disabled state of this control
do do
if disabled /= b then if disabled /= b then
disabled := b disabled := b
state_changes.replace_with_boolean (disabled, "disabled") state_changes.replace_with_boolean (disabled, "disabled")
end end
ensure
disabled_set: disabled = b
state_changes_registered: old b /= b implies state_changes.has_key ("disabled")
end end
set_type (t: STRING_32) set_type (t: STRING_32)
-- Set the type of this input control (HTML 'type' attribute)
do do
type := t type := t
ensure
type_set: type = t
end end
feature -- Implementation feature -- Implementation
value: STRING_32 value: STRING_32
-- The value of this input control
do do
Result := text Result := text
end end
set_value (v: STRING_32) set_value (v: STRING_32)
-- Set the value of this input control
do do
text := v text := v
ensure then
value_set: text = v
end end
feature -- Properties feature -- Properties

View File

@@ -1,5 +1,8 @@
note note
description: "Summary description for {WSF_PASSWORD_CONTROL}." description: "[
This control represents an HTML input control with the 'type'
attribute set to 'password'.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"

View File

@@ -1,5 +1,9 @@
note note
description: "Summary description for {WSF_TEXT_CONTROL}." description: "[
This control represents a textarea (the HTML 'textarea' tag).
It basically just inherits the functionality of an input
control.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"

View File

@@ -1,8 +1,9 @@
note note
description: "[ description: "[
WSF_NAVBAR_CONTROL encapsulates the navbar provided by bootstrap. WSF_NAVBAR_CONTROL encapsulates the navbar provided by
Simple menu items as well as dropdown lists and panels can be added to this control bootstrap. Simple menu items as well as dropdown lists and
http://getbootstrap.com/components/#navbar panels can be added to this control.
See http://getbootstrap.com/components/#navbar
]" ]"
author: "" author: ""
date: "$Date$" date: "$Date$"
@@ -44,6 +45,8 @@ feature {NONE} -- Initialization
do do
make make
brand := b brand := b
ensure
brand_set: brand = b
end end
feature -- Rendering feature -- Rendering
@@ -72,7 +75,7 @@ feature -- Rendering
feature -- Change feature -- Change
set_active (tab: INTEGER) set_active (tab: INTEGER)
-- Sets the given tab as current active tab -- Sets the given tab as current active tab. This procedure must not be called more than once.
require require
tab >= 1 and tab <= tab_count and not active_set tab >= 1 and tab <= tab_count and not active_set
do do
@@ -82,6 +85,8 @@ feature -- Change
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active") nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
end end
active_set := true active_set := true
ensure
active_set_set: active_set
end end
add_list_element_right (l: WSF_STATELESS_CONTROL) add_list_element_right (l: WSF_STATELESS_CONTROL)

View File

@@ -1,7 +1,7 @@
note note
description: "[ description: "[
WSF_NAVLIST_CONTROL encapsulates the linked items provided by bootstrap. This class encapsulates the linked items provided by bootstrap.
http://getbootstrap.com/components/#list-group-linked See http://getbootstrap.com/components/#list-group-linked
]" ]"
author: "" author: ""
date: "$Date$" date: "$Date$"
@@ -23,6 +23,7 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
-- Initialize
do do
make_multi_control make_multi_control
add_class ("list-group") add_class ("list-group")

View File

@@ -1,6 +1,6 @@
note note
description: "[ description: "[
WSF_NAVLIST_ITEM_CONTROL represents a menu item in WSF_NAVLIST_CONTROL This class represents a menu item in WSF_NAVLIST_CONTROL.
]" ]"
author: "" author: ""
date: "$Date$" date: "$Date$"
@@ -25,11 +25,14 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (link, t: STRING_32) make (link, t: STRING_32)
-- Initialize with the given link and text
do do
make_control ("a") make_control ("a")
text := t text := t
attributes := "href=%"" + link + "%""; attributes := "href=%"" + link + "%"";
add_class ("list-group-item") add_class ("list-group-item")
ensure
text_set: text = t
end end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
@@ -53,7 +56,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
feature -- Change feature -- Change
set_active (a: BOOLEAN) set_active (a: BOOLEAN)
-- Set text of that button -- Set whether this item should be displayed as active or not
do do
if active /= a then if active /= a then
active := a active := a
@@ -64,10 +67,14 @@ feature -- Change
end end
state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active") state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active")
end end
ensure
active_set: active = a
state_changes_registered: old active /= active implies state_changes.has_key ("active")
end end
feature -- Properties feature -- Properties
active: BOOLEAN active: BOOLEAN
-- The active state of this item
end end

View File

@@ -1,8 +1,8 @@
note note
description: "[ description: "[
WSF_PROGRESS_CONTROL encapsulates the progress bar provided by bootstrap. WSF_PROGRESS_CONTROL encapsulates the progress bar provided by bootstrap.
The value of the progress bar can either be set directly using set_progress The value of the progress bar can either be set directly using set_progress
or it can be fetched from a progress source. or it can be fetched from a progress source.
]" ]"
author: "" author: ""
date: "$Date$" date: "$Date$"
@@ -24,23 +24,27 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
-- Initialize with specified control name -- Initialize
do do
make_control ("div") make_control ("div")
add_class ("progress") add_class ("progress")
progress := 0 progress := 0
end end
make_with_source ( p: WSF_PROGRESS_SOURCE) make_with_source (p: WSF_PROGRESS_SOURCE)
-- Initialize with specified control name and progresssource -- Initialize with specified progresssource
do do
make make
progress_source := p progress_source := p
ensure
progress_source_set: progress_source = p
end end
feature -- State handling feature -- State handling
set_state (new_state: JSON_OBJECT) set_state (new_state: JSON_OBJECT)
require else
progress_in_range: attached {JSON_NUMBER} new_state.item ("progress") as new_progress implies new_progress.item.to_integer >= 0 and new_progress.item.to_integer <= 100
do do
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
progress := new_progress.item.to_integer progress := new_progress.item.to_integer
@@ -55,9 +59,9 @@ feature -- State handling
feature -- Event handling feature -- Event handling
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY) handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
do do
if cname[1].same_string (control_name) and event.same_string ("progress_fetch") then if cname [1].same_string (control_name) and event.same_string ("progress_fetch") then
state_changes.put_integer (progress_value, "progress") state_changes.put_integer (progress_value, "progress")
end end
end end
@@ -83,22 +87,33 @@ feature -- Change
do do
progress := p progress := p
state_changes.put_integer (progress, "progress") state_changes.put_integer (progress, "progress")
ensure
progress_set: progress = p
state_changes_registered: state_changes.has_key ("progress")
end end
feature -- Implementation feature -- Implementation
progress_value: INTEGER progress_value: INTEGER
-- The progress value of this progress control
do do
Result := progress Result := progress
if attached progress_source as ps then if attached progress_source as ps then
Result := ps.progress Result := ps.progress
end end
ensure
result_in_range: Result >= 0 and Result <= 100
end end
feature -- Properties feature -- Properties
progress_source: detachable WSF_PROGRESS_SOURCE progress_source: detachable WSF_PROGRESS_SOURCE
-- The source which provides this progress control the progress value
progress: INTEGER progress: INTEGER
-- The progress value of this progress control
invariant
progress_in_range: progress >= 0 and progress <= 100
end end

View File

@@ -1,5 +1,7 @@
note note
description: "Summary description for {WSF_IMAGE_SLIDER_CONTROL}." description: "[
Represents the bootstraps's 'carousel'.
]"
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -20,11 +22,11 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
-- Initialize with specified name -- Initialize
do do
make_control ( "div") make_control ("div")
add_class ("carousel slide") add_class ("carousel slide")
create list.make_with_tag_name ( "ol") create list.make_with_tag_name ("ol")
list.add_class ("carousel-indicators") list.add_class ("carousel-indicators")
create slide_wrapper.make_with_tag_name ("div") create slide_wrapper.make_with_tag_name ("div")
slide_wrapper.add_class ("carousel-inner") slide_wrapper.add_class ("carousel-inner")
@@ -33,19 +35,21 @@ feature {NONE} -- Initialization
feature -- State handling feature -- State handling
set_state (new_state: JSON_OBJECT) set_state (new_state: JSON_OBJECT)
-- Just implementation, nothing special to do here
do do
end end
state: WSF_JSON_OBJECT state: WSF_JSON_OBJECT
-- Just implementation, nothing special to do here
do do
create Result.make create Result.make
end end
feature -- Callback feature -- Callback
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY) handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
-- Just implementation, nothing special to do here
do do
-- Do nothing here
end end
feature -- Rendering feature -- Rendering
@@ -64,6 +68,7 @@ feature -- Rendering
feature -- Change feature -- Change
add_image_with_caption (src, alt, caption: STRING_32) add_image_with_caption (src, alt, caption: STRING_32)
-- Add a new image to the slider with specified url, alternative text and caption
local local
caption_control: detachable WSF_STATELESS_CONTROL caption_control: detachable WSF_STATELESS_CONTROL
do do

View File

@@ -22,18 +22,25 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (h: like handler; e: STRING_32) make (h: like handler; e: STRING_32)
-- Initialize with given validation function and error message
do do
make_validator (e) make_validator (e)
handler := h handler := h
ensure
handler_set: handler = h
end end
feature feature -- Implementation
is_valid (input: G): BOOLEAN is_valid (input: G): BOOLEAN
-- Tests if given input is valid
do do
Result := handler.item ([input]) Result := handler.item ([input])
end end
feature -- Properties
handler: FUNCTION [ANY, TUPLE [G], BOOLEAN] handler: FUNCTION [ANY, TUPLE [G], BOOLEAN]
-- The function which is used to validate inputs
end end

View File

@@ -1,6 +1,9 @@
note note
description: "[ description: "[
Validator implementation which make sure that the input has a the format of an valid email address Validator implementation which make sure that the input has
the format of an valid email address. This is just a very
basic implementation that tests if the given input contains
a '@'.
]" ]"
author: "" author: ""
date: "$Date$" date: "$Date$"
@@ -22,7 +25,7 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (e: STRING_32) make (e: STRING_32)
-- Initialize with specified error message which will be displayed on validation failure -- Initialize with specified error message
do do
make_regexp_validator ("^.*@.*$", e) make_regexp_validator ("^.*@.*$", e)
end end

View File

@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
make_validator (e) make_validator (e)
regexp_string := r regexp_string := r
create regexp create regexp
ensure regexp_string_set: regexp_string = r
end end
feature -- Implementation feature -- Implementation
@@ -39,7 +40,6 @@ feature -- Implementation
if not regexp.is_compiled then if not regexp.is_compiled then
regexp.compile (regexp_string) regexp.compile (regexp_string)
end end
Result := (not input.is_empty) and regexp.matches (input) Result := (not input.is_empty) and regexp.matches (input)
end end
@@ -56,7 +56,9 @@ feature -- State
feature -- Properties feature -- Properties
regexp_string: STRING_32 regexp_string: STRING_32
-- The regexp in string representation
regexp: REGULAR_EXPRESSION regexp: REGULAR_EXPRESSION
-- The regexp of this validator
end end

View File

@@ -15,6 +15,8 @@ feature {NONE} -- Initialization
-- Initialize with specified error message to be displayed on validation failure -- Initialize with specified error message to be displayed on validation failure
do do
error := e error := e
ensure
error_set: error = e
end end
feature -- Access feature -- Access
@@ -35,5 +37,6 @@ feature -- Access
feature -- Properties feature -- Properties
error: STRING_32 error: STRING_32
-- The error message if validation fails
end end

View File

@@ -186,6 +186,18 @@ feature -- Change
isolate := p isolate := p
end end
set_control_name_prefix (p: STRING_32)
-- Set the control name prefix
do
control_name_prefix := p
end
set_control_id (d: INTEGER)
-- Set the id of this control
do
control_id := d
end
feature -- Properties feature -- Properties
isolate: BOOLEAN isolate: BOOLEAN
@@ -197,12 +209,6 @@ feature -- Properties
control_id: INTEGER assign set_control_id control_id: INTEGER assign set_control_id
-- The id of this control -- The id of this control
set_control_id (d: INTEGER)
-- Set the id of this control
do
control_id := d
end
control_name: STRING_32 control_name: STRING_32
-- The name of this control which is composed of the control name prefix and the id of the control -- The name of this control which is composed of the control name prefix and the id of the control
do do
@@ -213,10 +219,4 @@ feature -- Properties
-- Used to avoid name conflicts since the children stateful controls of stateless controls are appended to the parent -- Used to avoid name conflicts since the children stateful controls of stateless controls are appended to the parent
-- control state and therefore could have the same name (Stateless multi controls do not add a hierarchy level) -- control state and therefore could have the same name (Stateless multi controls do not add a hierarchy level)
set_control_name_prefix (p: STRING_32)
-- Set the control name prefix
do
control_name_prefix := p
end
end end

View File

@@ -194,8 +194,6 @@ feature
feature -- Properties feature -- Properties
stateless: BOOLEAN
controls: ARRAYED_LIST [G] controls: ARRAYED_LIST [G]
-- List of current controls in this multi control -- List of current controls in this multi control

View File

@@ -21,19 +21,10 @@ feature {NONE} -- Initialization
do do
tag_name := a_tag_name tag_name := a_tag_name
create css_classes.make (0) create css_classes.make (0)
ensure
tag_name_set: tag_name = a_tag_name
end end
feature -- Access
tag_name: STRING_32
-- The tag name
css_classes: ARRAYED_LIST [STRING_32]
-- List of classes (appear in the "class" attribute)
attributes: detachable STRING_32
-- Attributes string (without classes)
feature -- Change feature -- Change
add_class (c: STRING_32) add_class (c: STRING_32)
@@ -121,6 +112,17 @@ feature -- Rendering
deferred deferred
end end
feature -- Properties
tag_name: STRING_32
-- The tag name
css_classes: ARRAYED_LIST [STRING_32]
-- List of classes (appear in the "class" attribute)
attributes: detachable STRING_32
-- Attributes string (without classes)
invariant invariant
tag_name_not_empty: not tag_name.is_empty tag_name_not_empty: not tag_name.is_empty

View File

@@ -32,7 +32,6 @@ feature {NONE} -- Initialization
-- Initialize -- Initialize
do do
make_with_tag_name ("") make_with_tag_name ("")
stateless := True
end end
feature feature

View File

@@ -53,17 +53,22 @@ feature {NONE} -- Initialization
feature -- Implementation feature -- Implementation
value: STRING_32 value: STRING_32
-- The current value
do do
Result := input.value Result := input.value
end end
set_value (v: STRING_32) set_value (v: STRING_32)
-- Set the current date (has to be in format dd-mm-yyyy)
do do
input.set_value (v) input.set_value (v)
ensure then
value_set: input.value = v
end end
feature -- Properties feature -- Properties
input: WSF_INPUT_CONTROL input: WSF_INPUT_CONTROL
-- The input control which is used to display the selected date
end end