merging from upstream - stage 1
This commit is contained in:
@@ -54,7 +54,7 @@ feature -- Input
|
||||
do
|
||||
src := source
|
||||
last_string.wipe_out
|
||||
if src.socket_ok then
|
||||
if src.readable then
|
||||
src.read_stream_thread_aware (nb)
|
||||
last_string.append_string (src.last_string)
|
||||
end
|
||||
|
||||
@@ -11,10 +11,10 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
|
||||
push
|
||||
-- Commit and push response
|
||||
do
|
||||
commit
|
||||
if attached post_commit_action as act then
|
||||
act.call (Void)
|
||||
end
|
||||
commit
|
||||
end
|
||||
|
||||
commit
|
||||
@@ -22,6 +22,7 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
|
||||
deferred
|
||||
ensure
|
||||
status_is_set: status_is_set
|
||||
status_committed: status_committed
|
||||
header_committed: header_committed
|
||||
message_committed: message_committed
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ feature {NONE} -- Initialization
|
||||
make (m: like mapping)
|
||||
do
|
||||
mapping := m
|
||||
create {STRING_32} description.make_empty
|
||||
create descriptions.make (0)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
@@ -27,7 +27,7 @@ feature -- Status report
|
||||
-- Is Current empty?
|
||||
-- i.e: does not carry any information.
|
||||
do
|
||||
Result := description.is_empty
|
||||
Result := descriptions.is_empty
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -35,7 +35,18 @@ feature -- Access
|
||||
mapping: WSF_ROUTER_MAPPING
|
||||
-- Associated mapping
|
||||
|
||||
descriptions: ARRAYED_LIST [READABLE_STRING_GENERAL]
|
||||
|
||||
description: STRING_32
|
||||
do
|
||||
create Result.make_empty
|
||||
across
|
||||
descriptions as c
|
||||
loop
|
||||
Result.append_string_general (c.item)
|
||||
Result.append ("%N")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
@@ -46,7 +57,17 @@ feature -- Change
|
||||
|
||||
add_description (d: READABLE_STRING_GENERAL)
|
||||
do
|
||||
description.append_string_general (d)
|
||||
descriptions.force (d)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
@@ -204,6 +204,7 @@ feature {WSF_RESPONSE} -- Output
|
||||
l_url: detachable STRING_8
|
||||
l_base_url: detachable READABLE_STRING_8
|
||||
l_doc: detachable WSF_ROUTER_MAPPING_DOCUMENTATION
|
||||
l_first: BOOLEAN
|
||||
do
|
||||
if attached {WSF_SELF_DOCUMENTED_ROUTER_MAPPING} m as l_doc_mapping then
|
||||
l_doc := l_doc_mapping.documentation (meths)
|
||||
@@ -256,7 +257,17 @@ feature {WSF_RESPONSE} -- Output
|
||||
|
||||
if l_doc /= Void and then not l_doc.is_empty then
|
||||
s.append ("%N<ul class=%"handlerdoc%">")
|
||||
s.append (html_encoder.encoded_string (l_doc.description))
|
||||
l_first := True
|
||||
across
|
||||
l_doc.descriptions as c
|
||||
loop
|
||||
if not l_first then
|
||||
s.append ("<br/>")
|
||||
else
|
||||
l_first := False
|
||||
end
|
||||
s.append (html_encoder.general_encoded_string (c.item))
|
||||
end
|
||||
s.append ("%N</ul>%N")
|
||||
else
|
||||
debug
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STARTS_WITH_AGENT_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STARTS_WITH_AGENT_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_STARTS_WITH_HANDLER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_action: like action)
|
||||
do
|
||||
action := a_action
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; request: WSF_REQUEST; response: WSF_RESPONSE]]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
action.call ([a_start_path, req, res])
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -13,8 +13,11 @@ inherit
|
||||
execute as execute_starts_with
|
||||
end
|
||||
|
||||
WSF_SELF_DOCUMENTED_HANDLER
|
||||
|
||||
create
|
||||
make
|
||||
make,
|
||||
make_hidden
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
@@ -34,6 +37,29 @@ feature {NONE} -- Initialization
|
||||
not document_root.is_empty and then not document_root.ends_with (operating_environment.directory_separator.out)
|
||||
end
|
||||
|
||||
make_hidden (d: like document_root)
|
||||
require
|
||||
valid_d: (d /= Void and then not d.is_empty) implies not d.ends_with (operating_environment.directory_separator.out)
|
||||
do
|
||||
make (d)
|
||||
is_hidden := True
|
||||
ensure
|
||||
hidden: is_hidden
|
||||
end
|
||||
|
||||
is_hidden: BOOLEAN
|
||||
-- Current mapped handler should be hidden from self documentation
|
||||
|
||||
feature -- Documentation
|
||||
|
||||
mapping_documentation (m: WSF_ROUTER_MAPPING; a_request_methods: detachable WSF_REQUEST_METHODS): WSF_ROUTER_MAPPING_DOCUMENTATION
|
||||
-- <Precursor>
|
||||
do
|
||||
create Result.make (m)
|
||||
Result.set_is_hidden (is_hidden)
|
||||
Result.add_description ("File service")
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
document_root: STRING
|
||||
|
||||
@@ -14,7 +14,8 @@ inherit
|
||||
put_string,
|
||||
put_substring,
|
||||
flush,
|
||||
message_writable
|
||||
message_writable,
|
||||
message_committed
|
||||
end
|
||||
|
||||
WSF_RESPONSE_EXPORTER
|
||||
@@ -36,10 +37,10 @@ feature {NONE} -- Implementation
|
||||
|
||||
commit
|
||||
do
|
||||
Precursor
|
||||
if not header_committed then
|
||||
process_header
|
||||
end
|
||||
Precursor
|
||||
end
|
||||
|
||||
process_header
|
||||
@@ -65,6 +66,12 @@ feature -- Status report
|
||||
message_writable: BOOLEAN = True
|
||||
-- Can message be written?
|
||||
|
||||
message_committed: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := header_committed
|
||||
end
|
||||
|
||||
feature -- Output operation
|
||||
|
||||
put_character (c: CHARACTER_8)
|
||||
|
||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
url_location := a_url_location
|
||||
delay := a_delay_in_seconds
|
||||
make_html
|
||||
set_status_code ({HTTP_STATUS_CODE}.found)
|
||||
status_code := {HTTP_STATUS_CODE}.found
|
||||
end
|
||||
|
||||
feature -- Header
|
||||
@@ -65,7 +65,7 @@ feature {NONE} -- Output
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -197,7 +197,7 @@ feature {NONE} -- HTML Generation
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
make (a_url_location: like url_location)
|
||||
do
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
status_code := {HTTP_STATUS_CODE}.found
|
||||
url_location := a_url_location
|
||||
create header.make
|
||||
end
|
||||
@@ -100,7 +100,7 @@ feature {WSF_RESPONSE} -- Output
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -252,23 +252,23 @@ feature -- Header output operation: helpers
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
put_header_lines (a_lines: ITERABLE [READABLE_STRING_8])
|
||||
-- Put headers from `a_lines'
|
||||
require
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
across a_lines as c loop
|
||||
put_header_line (c.item.name + ": " + c.item.value)
|
||||
put_header_line (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
add_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
add_header_lines (a_lines: ITERABLE [READABLE_STRING_8])
|
||||
-- Add headers from `a_lines'
|
||||
require
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
across a_lines as c loop
|
||||
add_header_line (c.item.name + ": " + c.item.value)
|
||||
add_header_line (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -409,8 +409,7 @@ feature -- Response object
|
||||
do
|
||||
a_message.send_to (Current)
|
||||
ensure
|
||||
status_committed: status_committed
|
||||
header_committed: header_committed
|
||||
status_committed: status_is_set
|
||||
end
|
||||
|
||||
feature -- Redirect
|
||||
|
||||
@@ -26,11 +26,10 @@ feature {WSF_RESPONSE} -- Output
|
||||
deferred
|
||||
ensure
|
||||
res_status_set: res.status_is_set
|
||||
res_header_committed: res.header_committed
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="wsf" uuid="A37CE5AA-4D2A-4441-BC6A-0A1D7EC49647" library_target="wsf">
|
||||
<target name="wsf">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="ewsgi" location="..\ewsgi\ewsgi-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="error" location="../../utility/general/error/error-safe.ecf"/>
|
||||
<library name="http" location="../../network/protocol/http/http-safe.ecf"/>
|
||||
<library name="uri_template" location="../../text/parser/uri_template/uri_template-safe.ecf"/>
|
||||
<library name="encoder"
|
||||
location="..\..\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri-safe.ecf" readonly="true"/>
|
||||
<cluster name="src" location=".\src" recursive="true"/>
|
||||
<cluster name="router" location=".\router" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
98
library/server/wsf_html/api/wsf_api_options.e
Normal file
98
library/server/wsf_html/api/wsf_api_options.e
Normal file
@@ -0,0 +1,98 @@
|
||||
note
|
||||
description: "Summary description for {WSF_API_OPTIONS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_API_OPTIONS
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable ANY, STRING]
|
||||
|
||||
create
|
||||
make,
|
||||
make_from_manifest
|
||||
|
||||
convert
|
||||
make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]]
|
||||
})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: INTEGER)
|
||||
do
|
||||
create table.make (n)
|
||||
end
|
||||
|
||||
make_from_manifest (lst: ARRAY [TUPLE [key: STRING; value: detachable ANY]])
|
||||
do
|
||||
make (lst.count)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
force (c.item.value, c.item.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: STRING): detachable ANY
|
||||
do
|
||||
Result := table.item (k)
|
||||
end
|
||||
|
||||
force (v: detachable ANY; k: STRING)
|
||||
do
|
||||
table.force (v, k)
|
||||
end
|
||||
|
||||
boolean_item (k: STRING; dft: BOOLEAN): BOOLEAN
|
||||
do
|
||||
if attached {BOOLEAN} item (k) as b then
|
||||
Result := b
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
string_general_item (k: STRING): detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
if attached {READABLE_STRING_GENERAL} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
string_item, string_8_item (k: STRING): detachable READABLE_STRING_8
|
||||
do
|
||||
if attached {READABLE_STRING_8} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
table: HASH_TABLE [detachable ANY, STRING]
|
||||
|
||||
feature -- Change
|
||||
|
||||
import (a_opts: WSF_API_OPTIONS)
|
||||
do
|
||||
across
|
||||
a_opts as c
|
||||
loop
|
||||
force (c.item, c.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, STRING]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := table.new_cursor
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
208
library/server/wsf_html/api/wsf_api_utilities.e
Normal file
208
library/server/wsf_html/api/wsf_api_utilities.e
Normal file
@@ -0,0 +1,208 @@
|
||||
note
|
||||
description: "Summary description for {WSF_API_UTILITIES}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_API_UTILITIES
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
deferred
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
based_path (p: STRING): STRING
|
||||
-- Path `p' in the context of the `base_url'
|
||||
do
|
||||
if attached base_url as l_base_url then
|
||||
create Result.make_from_string (l_base_url)
|
||||
if p.is_empty then
|
||||
else
|
||||
if p[1] = '/' then
|
||||
Result.append (p.substring (2, p.count))
|
||||
else
|
||||
Result.append (p)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := p
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
link (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
do
|
||||
create Result.make (32)
|
||||
append_link_to_html (a_text, a_path, opts, Result)
|
||||
end
|
||||
|
||||
link_with_raw_text (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
do
|
||||
create Result.make (32)
|
||||
append_link_with_raw_text_to_html (a_raw_text, a_path, opts, Result)
|
||||
end
|
||||
|
||||
append_link_to_html (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8)
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_GENERAL
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
a_html.append ("<a href=%"" + checked_url (url (a_path, opts)) + "%">")
|
||||
if a_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_text
|
||||
end
|
||||
if l_html then
|
||||
a_html.append (html_encoded (t))
|
||||
else
|
||||
a_html.append (checked_plain (t))
|
||||
end
|
||||
a_html.append ("</a>")
|
||||
end
|
||||
|
||||
append_link_with_raw_text_to_html (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8)
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_8
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
a_html.append ("<a href=%"" + checked_url (url (a_path, opts)) + "%">")
|
||||
if a_raw_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_raw_text
|
||||
end
|
||||
a_html.append (t)
|
||||
a_html.append ("</a>")
|
||||
end
|
||||
|
||||
absolute_url (a_path: STRING; opts: detachable WSF_API_OPTIONS): STRING
|
||||
local
|
||||
l_opts: detachable WSF_API_OPTIONS
|
||||
do
|
||||
l_opts := opts
|
||||
if l_opts = Void then
|
||||
create l_opts.make (1)
|
||||
end
|
||||
l_opts.force (True, "absolute")
|
||||
Result := url (a_path, l_opts)
|
||||
end
|
||||
|
||||
url (a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
local
|
||||
q,f: detachable STRING_8
|
||||
l_abs: BOOLEAN
|
||||
do
|
||||
l_abs := False
|
||||
|
||||
if opts /= Void then
|
||||
l_abs := opts.boolean_item ("absolute", l_abs)
|
||||
if attached opts.item ("query") as l_query then
|
||||
if attached {READABLE_STRING_8} l_query as s_value then
|
||||
q := s_value
|
||||
elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then
|
||||
create q.make_empty
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if q.is_empty then
|
||||
else
|
||||
q.append_character ('&')
|
||||
end
|
||||
q.append (url_encoded (c.item.key))
|
||||
q.append_character ('=')
|
||||
q.append (url_encoded (c.item.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached opts.string_item ("fragment") as s_frag then
|
||||
f := s_frag
|
||||
end
|
||||
end
|
||||
if l_abs then
|
||||
if a_path.substring_index ("://", 1) = 0 then
|
||||
create Result.make_from_string (site_url)
|
||||
if a_path.is_empty then
|
||||
elseif Result.ends_with ("/") then
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path.substring (2, a_path.count))
|
||||
else
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
else
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path)
|
||||
else
|
||||
Result.append_character ('/')
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := a_path
|
||||
end
|
||||
else
|
||||
Result := based_path (a_path)
|
||||
end
|
||||
if q /= Void then
|
||||
Result.append ("?" + q)
|
||||
end
|
||||
if f /= Void then
|
||||
Result.append ("#" + f)
|
||||
end
|
||||
end
|
||||
|
||||
checked_url (a_url: READABLE_STRING_8): READABLE_STRING_8
|
||||
do
|
||||
Result := a_url
|
||||
end
|
||||
|
||||
checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8
|
||||
do
|
||||
Result := html_encoded (a_text)
|
||||
end
|
||||
|
||||
feature -- Encoding
|
||||
|
||||
url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: URL_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: HTML_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
40
library/server/wsf_html/api/wsf_request_theme.e
Normal file
40
library/server/wsf_html/api/wsf_request_theme.e
Normal file
@@ -0,0 +1,40 @@
|
||||
note
|
||||
description: "[
|
||||
WF_THEME associated with a request
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_REQUEST_THEME
|
||||
|
||||
inherit
|
||||
WSF_THEME
|
||||
|
||||
create
|
||||
make_with_request
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_request (req: WSF_REQUEST)
|
||||
do
|
||||
request := req
|
||||
end
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- Associated request
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := request.absolute_script_url ("")
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
Result := request.script_url ("")
|
||||
end
|
||||
|
||||
end
|
||||
14
library/server/wsf_html/api/wsf_theme.e
Normal file
14
library/server/wsf_html/api/wsf_theme.e
Normal file
@@ -0,0 +1,14 @@
|
||||
note
|
||||
description: "Summary description for {WSF_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_THEME
|
||||
|
||||
inherit
|
||||
WSF_API_UTILITIES
|
||||
|
||||
|
||||
end
|
||||
25
library/server/wsf_html/api/wsf_url_api_options.e
Normal file
25
library/server/wsf_html/api/wsf_url_api_options.e
Normal file
@@ -0,0 +1,25 @@
|
||||
note
|
||||
description: "Summary description for {WSF_URL_API_OPTIONS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_URL_API_OPTIONS
|
||||
|
||||
inherit
|
||||
WSF_API_OPTIONS
|
||||
|
||||
create
|
||||
make,
|
||||
make_absolute
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_absolute
|
||||
do
|
||||
make (1)
|
||||
force (True, "absolute")
|
||||
end
|
||||
|
||||
end
|
||||
27
library/server/wsf_html/css/css_selector.e
Normal file
27
library/server/wsf_html/css/css_selector.e
Normal file
@@ -0,0 +1,27 @@
|
||||
note
|
||||
description: "Summary description for {CSS_SELECTOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CSS_SELECTOR
|
||||
|
||||
create
|
||||
make_from_string
|
||||
|
||||
convert
|
||||
make_from_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_from_string (s: READABLE_STRING_8)
|
||||
do
|
||||
string := s
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
string: READABLE_STRING_8
|
||||
|
||||
end
|
||||
451
library/server/wsf_html/css/css_style.e
Normal file
451
library/server/wsf_html/css/css_style.e
Normal file
@@ -0,0 +1,451 @@
|
||||
note
|
||||
description: "Summary description for {CSS_STYLE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
EIS: "name=CSS reference", "protocol=URI", "src=http://www.w3schools.com/cssref/"
|
||||
|
||||
class
|
||||
CSS_STYLE
|
||||
|
||||
inherit
|
||||
ITERABLE [READABLE_STRING_8]
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_string,
|
||||
make_with_items
|
||||
|
||||
convert
|
||||
make_with_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
make_with_items (create {like items}.make (3))
|
||||
end
|
||||
|
||||
make_with_string (s: READABLE_STRING_8)
|
||||
do
|
||||
make_with_items (s.split (';'))
|
||||
end
|
||||
|
||||
make_with_items (lst: ITERABLE [READABLE_STRING_8])
|
||||
do
|
||||
create items.make (5)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if attached {IMMUTABLE_STRING_8} c.item as imm then
|
||||
items.force (imm)
|
||||
else
|
||||
items.force (create {IMMUTABLE_STRING_8}.make_from_string (c.item))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
items: ARRAYED_LIST [IMMUTABLE_STRING_8]
|
||||
|
||||
feature -- Access
|
||||
|
||||
count: INTEGER
|
||||
-- Count of style entities.
|
||||
|
||||
new_cursor: ITERATION_CURSOR [READABLE_STRING_8]
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
plus alias "+" (a_other: CSS_STYLE): like Current
|
||||
-- <Precursor>
|
||||
local
|
||||
lst: ARRAYED_LIST [READABLE_STRING_8]
|
||||
do
|
||||
create lst.make (count + a_other.count)
|
||||
lst.append (items)
|
||||
across
|
||||
a_other as c
|
||||
loop
|
||||
lst.force (c.item)
|
||||
end
|
||||
create Result.make_with_items (lst)
|
||||
end
|
||||
|
||||
append (a_other: CSS_STYLE)
|
||||
-- Append style from `a_other' into Current
|
||||
do
|
||||
across
|
||||
a_other as c
|
||||
loop
|
||||
items.force (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
put_key_value (k,v: READABLE_STRING_8)
|
||||
do
|
||||
items.force (k + ": " + v)
|
||||
end
|
||||
|
||||
feature -- Property: colors
|
||||
|
||||
put_color (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("color", v)
|
||||
end
|
||||
|
||||
put_background (v: READABLE_STRING_8)
|
||||
--| ex: #00ff00 url('smiley.gif') no-repeat fixed center;
|
||||
do
|
||||
put_key_value ("background", v)
|
||||
end
|
||||
|
||||
put_background_color (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("background-color", v)
|
||||
end
|
||||
|
||||
feature -- Property: fonts
|
||||
|
||||
put_font (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("font", v)
|
||||
end
|
||||
|
||||
put_font_family (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("font-family", v)
|
||||
end
|
||||
|
||||
put_font_size (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("font-size", v)
|
||||
end
|
||||
|
||||
put_font_style (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("font-style", v)
|
||||
end
|
||||
|
||||
put_font_weight (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("font-weight", v)
|
||||
end
|
||||
|
||||
put_font_bold
|
||||
do
|
||||
put_font_weight ("bold")
|
||||
end
|
||||
|
||||
put_font_italic
|
||||
do
|
||||
put_font_style ("italic")
|
||||
end
|
||||
|
||||
put_text_decoration (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("text-decoration", v)
|
||||
end
|
||||
|
||||
put_text_decoration_none
|
||||
do
|
||||
put_text_decoration ("none")
|
||||
end
|
||||
|
||||
put_text_decoration_underline
|
||||
do
|
||||
put_text_decoration ("underline")
|
||||
end
|
||||
|
||||
put_text_decoration_strike
|
||||
do
|
||||
put_text_decoration ("strike")
|
||||
end
|
||||
|
||||
put_text_align (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("text-align", v)
|
||||
end
|
||||
|
||||
put_white_space (v: READABLE_STRING_8)
|
||||
--| normal Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default
|
||||
--| nowrap Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br /> tag is encountered
|
||||
--| pre Whitespace is preserved by the browser. Text will only wrap on line breaks Acts like the <pre> tag in HTML
|
||||
--| pre-line Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks
|
||||
--| pre-wrap Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks
|
||||
--| inherit Specifies that the value of the white-space property should be inherited from the parent element
|
||||
do
|
||||
put_key_value ("white-space", v)
|
||||
end
|
||||
|
||||
put_white_space_nowrap
|
||||
do
|
||||
put_white_space ("nowrap")
|
||||
end
|
||||
|
||||
put_white_space_pre
|
||||
do
|
||||
put_white_space ("pre")
|
||||
end
|
||||
|
||||
|
||||
feature -- Property: margin
|
||||
|
||||
put_margin (a_top, a_right, a_bottom, a_left: detachable READABLE_STRING_8)
|
||||
local
|
||||
v: STRING
|
||||
do
|
||||
create v.make (10)
|
||||
if a_left /= Void then
|
||||
v.append (a_left)
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_bottom /= Void then
|
||||
v.prepend (a_bottom)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_right /= Void then
|
||||
v.prepend (a_right)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_top /= Void then
|
||||
v.prepend (a_top)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
put_key_value ("margin", v)
|
||||
end
|
||||
|
||||
put_margin_top (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("margin-top", v)
|
||||
end
|
||||
|
||||
put_margin_right (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("margin-right", v)
|
||||
end
|
||||
|
||||
put_margin_bottom (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("margin-bottom", v)
|
||||
end
|
||||
|
||||
put_margin_left (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("margin-left", v)
|
||||
end
|
||||
|
||||
feature -- Property: padding
|
||||
|
||||
put_padding (a_top, a_right, a_bottom, a_left: detachable READABLE_STRING_8)
|
||||
local
|
||||
v: STRING
|
||||
do
|
||||
create v.make (10)
|
||||
if a_left /= Void then
|
||||
v.append (a_left)
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_bottom /= Void then
|
||||
v.prepend (a_bottom)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_right /= Void then
|
||||
v.prepend (a_right)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
if not v.is_empty then
|
||||
v.prepend_character (' ')
|
||||
end
|
||||
if a_top /= Void then
|
||||
v.prepend (a_top)
|
||||
else
|
||||
v.prepend_character ('0')
|
||||
end
|
||||
put_key_value ("padding", v)
|
||||
end
|
||||
|
||||
put_padding_top (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("padding-top", v)
|
||||
end
|
||||
|
||||
put_padding_right (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("padding-right", v)
|
||||
end
|
||||
|
||||
put_padding_bottom (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("padding-bottom", v)
|
||||
end
|
||||
|
||||
put_padding_left (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("padding-left", v)
|
||||
end
|
||||
|
||||
feature -- Properties: layout
|
||||
|
||||
put_width (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("width", v)
|
||||
end
|
||||
|
||||
put_height (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("height", v)
|
||||
end
|
||||
|
||||
put_z_index (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("z-index", v)
|
||||
end
|
||||
|
||||
feature -- Property: border
|
||||
|
||||
put_border (a_border: detachable READABLE_STRING_8; a_style: READABLE_STRING_8; a_size: READABLE_STRING_8; a_color: READABLE_STRING_8)
|
||||
-- "solid 1px color"
|
||||
require
|
||||
a_border /= Void implies (a_border.same_string ("top") or a_border.same_string ("right") or a_border.same_string ("bottom") or a_border.same_string ("left"))
|
||||
local
|
||||
k: STRING
|
||||
do
|
||||
k := "border"
|
||||
if a_border /= Void then
|
||||
k.append_character ('-')
|
||||
k.append (a_border)
|
||||
end
|
||||
put_key_value (k, a_style + " " + a_size + " " + a_color)
|
||||
end
|
||||
|
||||
put_border_style (a_style: READABLE_STRING_8)
|
||||
-- "solid 1px color"
|
||||
do
|
||||
put_key_value ("border-style", a_style)
|
||||
end
|
||||
|
||||
put_border_style_none (a_style: READABLE_STRING_8)
|
||||
-- "solid 1px color"
|
||||
do
|
||||
put_border_style ("none")
|
||||
end
|
||||
|
||||
feature -- Property: display
|
||||
|
||||
put_display (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("display", v)
|
||||
end
|
||||
|
||||
put_display_none
|
||||
do
|
||||
put_display ("none")
|
||||
end
|
||||
|
||||
put_display_block
|
||||
do
|
||||
put_display ("block")
|
||||
end
|
||||
|
||||
put_display_inline
|
||||
do
|
||||
put_display ("inline")
|
||||
end
|
||||
|
||||
put_display_inline_block
|
||||
do
|
||||
put_display ("inline-block")
|
||||
end
|
||||
|
||||
put_list_style (v: READABLE_STRING_8)
|
||||
--| ex: list-style:square url("sqpurple.gif");
|
||||
do
|
||||
put_key_value ("list-style", v)
|
||||
end
|
||||
|
||||
put_list_style_type (v: READABLE_STRING_8)
|
||||
--circle The marker is a circle
|
||||
--decimal The marker is a number. This is default for <ol>
|
||||
--decimal-leading-zero The marker is a number with leading zeros (01, 02, 03, etc.)
|
||||
--disc The marker is a filled circle. This is default for <ul>
|
||||
--lower-alpha The marker is lower-alpha (a, b, c, d, e, etc.)
|
||||
--lower-greek The marker is lower-greek
|
||||
--lower-latin The marker is lower-latin (a, b, c, d, e, etc.)
|
||||
--lower-roman The marker is lower-roman (i, ii, iii, iv, v, etc.)
|
||||
--none No marker is shown
|
||||
--square The marker is a square
|
||||
--upper-alpha The marker is upper-alpha (A, B, C, D, E, etc.)
|
||||
--upper-latin The marker is upper-latin (A, B, C, D, E, etc.)
|
||||
--upper-roman The marker is upper-roman (I, II, III, IV, V, etc.)
|
||||
do
|
||||
put_key_value ("list-style-type", v)
|
||||
end
|
||||
|
||||
feature -- Property: float ...
|
||||
|
||||
put_float (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("float", v)
|
||||
end
|
||||
|
||||
put_clear (v: READABLE_STRING_8)
|
||||
do
|
||||
put_key_value ("clear", v)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_inline_to (s: STRING_8)
|
||||
do
|
||||
append_to (s, False)
|
||||
end
|
||||
|
||||
append_text_to (s: STRING_8)
|
||||
do
|
||||
append_to (s, True)
|
||||
end
|
||||
|
||||
append_to (s: STRING_8; a_multiline: BOOLEAN)
|
||||
local
|
||||
n: INTEGER
|
||||
do
|
||||
n := 0
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
if n > 0 then
|
||||
if a_multiline then
|
||||
s.append_character ('%N')
|
||||
else
|
||||
s.append_character (' ')
|
||||
end
|
||||
end
|
||||
s.append (c.item)
|
||||
s.append_character (';')
|
||||
n := n + 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
75
library/server/wsf_html/css/css_text.e
Normal file
75
library/server/wsf_html/css/css_text.e
Normal file
@@ -0,0 +1,75 @@
|
||||
note
|
||||
description: "Summary description for {CSS_TEXT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CSS_TEXT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create items.make (3)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
items: ARRAYED_LIST [TUPLE [selectors: ITERABLE [CSS_SELECTOR]; style: CSS_STYLE]]
|
||||
|
||||
add_selector_style (a_selector: CSS_SELECTOR; a_style: CSS_STYLE)
|
||||
do
|
||||
items.force ([<<a_selector>>, a_style])
|
||||
end
|
||||
|
||||
add_selectors_style (a_selectors: ITERABLE [CSS_SELECTOR]; a_style: CSS_STYLE)
|
||||
do
|
||||
items.force ([a_selectors, a_style])
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
string: STRING_8
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
create s.make (64)
|
||||
append_to (s)
|
||||
Result := s
|
||||
end
|
||||
|
||||
append_to (a_target: STRING_8)
|
||||
local
|
||||
s: STRING_8
|
||||
s_selectors: STRING_8
|
||||
do
|
||||
create s.make (64)
|
||||
create s_selectors.make (10)
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
s_selectors.wipe_out
|
||||
across
|
||||
c.item.selectors as cs
|
||||
loop
|
||||
if not s_selectors.is_empty then
|
||||
s_selectors.append_character (',')
|
||||
end
|
||||
s_selectors.append (cs.item.string)
|
||||
end
|
||||
if not s_selectors.is_empty then
|
||||
a_target.append (s_selectors)
|
||||
a_target.append_character (' ')
|
||||
a_target.append_character ('{')
|
||||
c.item.style.append_text_to (a_target)
|
||||
a_target.append_character ('}')
|
||||
a_target.append_character ('%N')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
154
library/server/wsf_html/form/wsf_form.e
Normal file
154
library/server/wsf_html/form/wsf_form.e
Normal file
@@ -0,0 +1,154 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM
|
||||
|
||||
inherit
|
||||
WSF_FORM_COMPOSITE
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_action: READABLE_STRING_8; a_id: READABLE_STRING_8)
|
||||
do
|
||||
action := a_action
|
||||
id := a_id
|
||||
initialize_with_count (10)
|
||||
create html_classes.make (2)
|
||||
set_method_post
|
||||
create validation_actions
|
||||
create submit_actions
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
action: READABLE_STRING_8
|
||||
-- URL for the web form
|
||||
|
||||
id: READABLE_STRING_8
|
||||
-- Id of the form
|
||||
|
||||
is_get_method: BOOLEAN
|
||||
do
|
||||
Result := method.same_string ("GET")
|
||||
end
|
||||
|
||||
is_post_method: BOOLEAN
|
||||
do
|
||||
Result := not is_get_method
|
||||
end
|
||||
|
||||
method: READABLE_STRING_8
|
||||
-- Form's method
|
||||
--| GET or POST
|
||||
|
||||
encoding_type: detachable READABLE_STRING_8
|
||||
-- Encoding type
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
process (req: WSF_REQUEST; a_before_callback, a_after_callback: detachable PROCEDURE [ANY, TUPLE [WSF_FORM_DATA]])
|
||||
-- Process Current form with request `req'
|
||||
-- agent `a_before_callback' is called before the validation
|
||||
-- agent `a_after_callback' is called after the validation
|
||||
local
|
||||
fd: WSF_FORM_DATA
|
||||
do
|
||||
create fd.make (req, Current)
|
||||
last_data := fd
|
||||
if a_before_callback /= Void then
|
||||
a_before_callback.call ([fd])
|
||||
end
|
||||
fd.validate
|
||||
fd.apply_to_associated_form -- Maybe only when has error?
|
||||
if fd.is_valid then
|
||||
fd.submit
|
||||
end
|
||||
if a_after_callback /= Void then
|
||||
a_after_callback.call ([fd])
|
||||
end
|
||||
end
|
||||
|
||||
last_data: detachable WSF_FORM_DATA
|
||||
|
||||
feature -- Validation
|
||||
|
||||
validation_actions: ACTION_SEQUENCE [TUPLE [WSF_FORM_DATA]]
|
||||
-- Procedure to validate the data
|
||||
-- report error if not valid
|
||||
|
||||
submit_actions: ACTION_SEQUENCE [TUPLE [WSF_FORM_DATA]]
|
||||
-- Submit actions
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_method_get
|
||||
do
|
||||
method := "GET"
|
||||
end
|
||||
|
||||
set_method_post
|
||||
do
|
||||
method := "POST"
|
||||
end
|
||||
|
||||
set_encoding_type (s: like encoding_type)
|
||||
do
|
||||
encoding_type := s
|
||||
end
|
||||
|
||||
set_multipart_form_data_encoding_type
|
||||
do
|
||||
encoding_type := "multipart/form-data"
|
||||
end
|
||||
|
||||
feature -- Optional
|
||||
|
||||
html_classes: ARRAYED_LIST [STRING_8]
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
a_html.append ("<form action=%""+ action +"%" id=%""+ id +"%" method=%""+ method +"%"")
|
||||
if attached encoding_type as enctype then
|
||||
a_html.append (" enctype=%""+ enctype +"%"")
|
||||
end
|
||||
if not html_classes.is_empty then
|
||||
create s.make_empty
|
||||
across
|
||||
html_classes as cl
|
||||
loop
|
||||
if not s.is_empty then
|
||||
s.extend (' ')
|
||||
end
|
||||
s.append (cl.item)
|
||||
end
|
||||
a_html.append (" class=%"" + s + "%" ")
|
||||
end
|
||||
a_html.append (">%N")
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
c.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</form>%N")
|
||||
end
|
||||
|
||||
to_html (a_theme: WSF_THEME): STRING_8
|
||||
do
|
||||
create Result.make_empty
|
||||
append_to_html (a_theme, Result)
|
||||
end
|
||||
|
||||
end
|
||||
20
library/server/wsf_html/form/wsf_form_button_input.e
Normal file
20
library/server/wsf_html/form/wsf_form_button_input.e
Normal file
@@ -0,0 +1,20 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_BUTTON_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_BUTTON_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "button"
|
||||
|
||||
end
|
||||
23
library/server/wsf_html/form/wsf_form_checkbox_input.e
Normal file
23
library/server/wsf_html/form/wsf_form_checkbox_input.e
Normal file
@@ -0,0 +1,23 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_CHECKBOX_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_CHECKBOX_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_SELECTABLE_INPUT
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_value
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "checkbox"
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
89
library/server/wsf_html/form/wsf_form_composite.e
Normal file
89
library/server/wsf_html/form/wsf_form_composite.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_COMPOSITE
|
||||
|
||||
inherit
|
||||
WSF_WIDGET_COMPOSITE
|
||||
redefine
|
||||
extend
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
has_field (a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
Result := container_has_field (Current, a_name)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
fields_by_name (a_name: READABLE_STRING_GENERAL): detachable LIST [WSF_FORM_FIELD]
|
||||
do
|
||||
Result := fields_by_name_from (Current, a_name)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
extend (i: WSF_WIDGET)
|
||||
local
|
||||
n: READABLE_STRING_8
|
||||
do
|
||||
if attached {WSF_FORM_FIELD} i as l_field then
|
||||
n := l_field.name
|
||||
if n.is_empty then
|
||||
n := (items.count + 1).out
|
||||
l_field.update_name (n)
|
||||
end
|
||||
end
|
||||
Precursor (i)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Items
|
||||
|
||||
container_has_field (a_container: ITERABLE [WSF_WIDGET]; a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
until
|
||||
Result
|
||||
loop
|
||||
if attached {WSF_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
Result := True
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then
|
||||
Result := container_has_field (l_cont, a_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fields_by_name_from (a_container: ITERABLE [WSF_WIDGET]; a_name: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [WSF_FORM_FIELD]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [WSF_FORM_FIELD]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if attached {WSF_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (l_field)
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then
|
||||
if attached fields_by_name_from (l_cont, a_name) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
334
library/server/wsf_html/form/wsf_form_data.e
Normal file
334
library/server/wsf_html/form/wsf_form_data.e
Normal file
@@ -0,0 +1,334 @@
|
||||
note
|
||||
description : "Objects that represent a form filled with data from request."
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_DATA
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable WSF_VALUE, READABLE_STRING_8]
|
||||
|
||||
create {WSF_FORM}
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; a_form: WSF_FORM)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
form := a_form
|
||||
create items.make (a_form.count)
|
||||
get_items (req)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
form: WSF_FORM
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_valid: BOOLEAN
|
||||
do
|
||||
Result := errors = Void
|
||||
end
|
||||
|
||||
is_applied_to_associated_form: BOOLEAN
|
||||
-- Data already applied to `form'?
|
||||
|
||||
feature -- Access
|
||||
|
||||
item_same_string (a_name: READABLE_STRING_GENERAL; s: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Is there any item named `a_name' with a value `v'?
|
||||
do
|
||||
if attached item (a_name) as l_value then
|
||||
Result := l_value.same_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
Result := items.item (a_name.as_string_8)
|
||||
end
|
||||
|
||||
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
if attached {WSF_STRING} item (a_name) as s then
|
||||
Result := s.value
|
||||
end
|
||||
end
|
||||
|
||||
table_item (a_name: READABLE_STRING_GENERAL): detachable WSF_TABLE
|
||||
local
|
||||
s,k: READABLE_STRING_GENERAL
|
||||
p,q: INTEGER
|
||||
do
|
||||
if attached {WSF_TABLE} item (a_name) as tb then
|
||||
Result := tb
|
||||
else
|
||||
s := a_name + "["
|
||||
create Result.make (a_name.to_string_8) -- FIXME
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
if attached c.item as v then
|
||||
k := c.key
|
||||
if k.starts_with (s) then
|
||||
if attached {WSF_TABLE} v as tb then
|
||||
across
|
||||
tb as t
|
||||
loop
|
||||
Result.add_value (t.item, t.item.name)
|
||||
end
|
||||
else
|
||||
p := k.index_of_code (91, 1) -- 91 '['
|
||||
if p > 0 then
|
||||
q := k.index_of_code (93, p + 1) -- 93 ']'
|
||||
if q > p then
|
||||
if q = p + 1 then
|
||||
-- []
|
||||
Result.add_value (v, (Result.count+1).out)
|
||||
else
|
||||
Result.add_value (v, k.substring (p + 1, q - 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- skip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
integer_item (a_name: READABLE_STRING_GENERAL): INTEGER
|
||||
do
|
||||
if attached {WSF_STRING} item (a_name) as s and then s.is_integer then
|
||||
Result := s.integer_value
|
||||
end
|
||||
end
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable WSF_VALUE, READABLE_STRING_8]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
submit
|
||||
require
|
||||
is_valid: is_valid
|
||||
do
|
||||
form.submit_actions.call ([Current])
|
||||
end
|
||||
|
||||
validate
|
||||
do
|
||||
across
|
||||
form as f
|
||||
loop
|
||||
validate_item (f.item)
|
||||
end
|
||||
form.validation_actions.call ([Current])
|
||||
end
|
||||
|
||||
validate_item (w: WSF_WIDGET)
|
||||
do
|
||||
if attached {WSF_FORM_FIELD} w as l_field then
|
||||
l_field.validate (Current)
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} w as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
validate_item (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_fields_invalid (b: BOOLEAN; a_name: READABLE_STRING_GENERAL)
|
||||
do
|
||||
if attached form.fields_by_name (a_name) as lst then
|
||||
across
|
||||
lst as i
|
||||
loop
|
||||
i.item.set_is_invalid (b)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
apply_to_associated_form
|
||||
do
|
||||
if not is_applied_to_associated_form then
|
||||
if attached errors as errs then
|
||||
across
|
||||
errs as e
|
||||
loop
|
||||
if attached e.item as err then
|
||||
if attached err.field as e_field then
|
||||
set_fields_invalid (True, e_field.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
across
|
||||
form as i
|
||||
loop
|
||||
apply_to_associated_form_item (c.key, c.item, i.item)
|
||||
end
|
||||
end
|
||||
is_applied_to_associated_form := True
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: apply
|
||||
|
||||
apply_to_associated_form_item (a_name: READABLE_STRING_8; a_value: detachable WSF_VALUE; i: WSF_WIDGET)
|
||||
local
|
||||
do
|
||||
if attached {WSF_FORM_FIELD} i as l_field then
|
||||
if not attached {WSF_FORM_SUBMIT_INPUT} l_field then
|
||||
if l_field.name.same_string (a_name) then
|
||||
l_field.set_value (a_value)
|
||||
end
|
||||
end
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} i as l_set then
|
||||
across
|
||||
l_set as c
|
||||
loop
|
||||
apply_to_associated_form_item (a_name, a_value, c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
report_error (a_msg: READABLE_STRING_8)
|
||||
do
|
||||
add_error (Void, a_msg)
|
||||
ensure
|
||||
is_invalid: not is_valid
|
||||
end
|
||||
|
||||
report_invalid_field (a_field_name: READABLE_STRING_8; a_msg: READABLE_STRING_8)
|
||||
require
|
||||
has_field: form.has_field (a_field_name)
|
||||
do
|
||||
if attached form.fields_by_name (a_field_name) as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
add_error (c.item, a_msg)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
is_invalid: not is_valid
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
get_items (req: WSF_REQUEST)
|
||||
do
|
||||
get_form_items (req, form)
|
||||
end
|
||||
|
||||
get_form_items (req: WSF_REQUEST; lst: ITERABLE [WSF_WIDGET])
|
||||
do
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if attached {WSF_FORM_FIELD} c.item as l_field then
|
||||
get_form_field_item (req, l_field, l_field.name)
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} c.item as l_set then
|
||||
get_form_items (req, l_set)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
get_form_field_item (req: WSF_REQUEST; i: WSF_FORM_FIELD; n: READABLE_STRING_8)
|
||||
local
|
||||
v: detachable WSF_VALUE
|
||||
do
|
||||
if form.is_post_method then
|
||||
v := req.table_item (n, agent req.form_parameter)
|
||||
else
|
||||
v := req.table_item (n, agent req.query_parameter)
|
||||
end
|
||||
if v = Void then
|
||||
if n.ends_with_general ("[]") then
|
||||
if form.is_post_method then
|
||||
v := req.form_parameter (n.substring (1, n.count - 2))
|
||||
else
|
||||
v := req.query_parameter (n.substring (1, n.count - 2))
|
||||
end
|
||||
end
|
||||
end
|
||||
if i.is_required and (v = Void or else v.is_empty) then
|
||||
add_error (i, "Field %"<em>" + n + "</em>%" is required")
|
||||
else
|
||||
items.force (v, n)
|
||||
end
|
||||
end
|
||||
|
||||
add_error (a_field: detachable WSF_FORM_FIELD; a_msg: detachable READABLE_STRING_8)
|
||||
local
|
||||
err: like errors
|
||||
do
|
||||
err := errors
|
||||
if err = Void then
|
||||
create err.make (1)
|
||||
errors := err
|
||||
end
|
||||
err.force ([a_field, a_msg])
|
||||
end
|
||||
|
||||
items: HASH_TABLE [detachable WSF_VALUE, READABLE_STRING_8]
|
||||
|
||||
feature -- Cached values
|
||||
|
||||
cached_value (k: READABLE_STRING_8): detachable ANY
|
||||
do
|
||||
if attached cached_values as tb then
|
||||
Result := tb.item (k)
|
||||
end
|
||||
end
|
||||
|
||||
add_cached_value (k: READABLE_STRING_8; v: detachable ANY)
|
||||
local
|
||||
tb: like cached_values
|
||||
do
|
||||
tb := cached_values
|
||||
if tb = Void then
|
||||
create tb.make (1)
|
||||
cached_values := tb
|
||||
end
|
||||
tb.force (v, k)
|
||||
end
|
||||
|
||||
remove_cached_value (k: READABLE_STRING_8; v: detachable ANY)
|
||||
do
|
||||
if attached cached_values as tb then
|
||||
tb.remove (k)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: cached values
|
||||
|
||||
cached_values: detachable HASH_TABLE [detachable ANY, READABLE_STRING_8]
|
||||
|
||||
feature -- Reports
|
||||
|
||||
has_error: BOOLEAN
|
||||
do
|
||||
Result := attached errors as err and then not err.is_empty
|
||||
end
|
||||
|
||||
errors: detachable ARRAYED_LIST [TUPLE [field: detachable WSF_FORM_FIELD; message: detachable READABLE_STRING_8]]
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
84
library/server/wsf_html/form/wsf_form_div.e
Normal file
84
library/server/wsf_html/form/wsf_form_div.e
Normal file
@@ -0,0 +1,84 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_DIV
|
||||
|
||||
inherit
|
||||
WSF_FORM_ITEM
|
||||
|
||||
WSF_FORM_COMPOSITE
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_item,
|
||||
make_with_items,
|
||||
make_with_text,
|
||||
make_with_text_and_css_id,
|
||||
make_with_item_and_css_id
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
initialize_with_count (0)
|
||||
end
|
||||
|
||||
make_with_text (s: READABLE_STRING_8)
|
||||
do
|
||||
make_with_item (create {WSF_FORM_RAW_TEXT}.make (s))
|
||||
end
|
||||
|
||||
make_with_item (i: WSF_WIDGET)
|
||||
do
|
||||
initialize_with_count (1)
|
||||
extend (i)
|
||||
end
|
||||
|
||||
make_with_items (it: ITERABLE [WSF_WIDGET])
|
||||
do
|
||||
initialize_with_count (2)
|
||||
across
|
||||
it as c
|
||||
loop
|
||||
extend (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
make_with_item_and_css_id (i: WSF_WIDGET; a_css_id: READABLE_STRING_8)
|
||||
do
|
||||
make_with_item (i)
|
||||
set_css_id (a_css_id)
|
||||
end
|
||||
|
||||
make_with_text_and_css_id (s: READABLE_STRING_8; a_css_id: READABLE_STRING_8)
|
||||
do
|
||||
make_with_text (s)
|
||||
set_css_id (a_css_id)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<div")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
|
||||
a_html.append (">%N")
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
c.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("%N</div>%N")
|
||||
end
|
||||
|
||||
end
|
||||
146
library/server/wsf_html/form/wsf_form_field.e
Normal file
146
library/server/wsf_html/form/wsf_form_field.e
Normal file
@@ -0,0 +1,146 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_ITEM}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_FIELD
|
||||
|
||||
inherit
|
||||
WSF_FORM_ITEM
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
label: detachable READABLE_STRING_8
|
||||
|
||||
description: detachable READABLE_STRING_8
|
||||
|
||||
is_required: BOOLEAN
|
||||
|
||||
is_invalid: BOOLEAN
|
||||
|
||||
is_readonly: BOOLEAN
|
||||
|
||||
is_description_collapsible: BOOLEAN
|
||||
|
||||
feature -- Status report
|
||||
|
||||
debug_output: STRING
|
||||
-- String that should be displayed in debugger to represent `Current'.
|
||||
do
|
||||
Result := name + " {" + generator + "}"
|
||||
end
|
||||
|
||||
feature -- Validation
|
||||
|
||||
validation_action: detachable PROCEDURE [ANY, TUPLE [WSF_FORM_DATA]]
|
||||
-- Function returning True if valid, otherwise False
|
||||
|
||||
validate (fd: WSF_FORM_DATA)
|
||||
do
|
||||
if attached validation_action as act then
|
||||
act.call ([fd])
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
update_name (a_name: like name)
|
||||
require
|
||||
name.is_empty
|
||||
do
|
||||
name := a_name
|
||||
end
|
||||
|
||||
set_is_required (b: BOOLEAN)
|
||||
do
|
||||
is_required := b
|
||||
end
|
||||
|
||||
set_is_readonly (b: BOOLEAN)
|
||||
do
|
||||
is_readonly := b
|
||||
end
|
||||
|
||||
set_label (lab: like label)
|
||||
do
|
||||
label := lab
|
||||
end
|
||||
|
||||
set_description (t: like description)
|
||||
do
|
||||
description := t
|
||||
end
|
||||
|
||||
set_validation_action (act: like validation_action)
|
||||
do
|
||||
validation_action := act
|
||||
end
|
||||
|
||||
set_is_invalid (b: BOOLEAN)
|
||||
do
|
||||
is_invalid := b
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
-- Set value `v' if applicable to Current
|
||||
deferred
|
||||
end
|
||||
|
||||
set_description_collapsible (b: BOOLEAN)
|
||||
-- Set `is_description_collapsible' to `b'
|
||||
do
|
||||
is_description_collapsible := b
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_class_items: detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
do
|
||||
create l_class_items.make (2)
|
||||
if is_required then
|
||||
l_class_items.extend ("required")
|
||||
end
|
||||
if is_invalid then
|
||||
l_class_items.extend ("error")
|
||||
end
|
||||
if l_class_items.is_empty then
|
||||
l_class_items := Void
|
||||
end
|
||||
|
||||
a_html.append ("<div")
|
||||
append_css_class_to (a_html, l_class_items)
|
||||
a_html.append_character ('>')
|
||||
if attached label as lab then
|
||||
a_html.append ("<strong><label for=%"" + name + "%">" + lab + "</label></strong>")
|
||||
if is_required then
|
||||
a_html.append (" (<em>required</em>)")
|
||||
end
|
||||
a_html.append ("<br/>%N")
|
||||
end
|
||||
append_item_to_html (a_theme, a_html)
|
||||
if attached description as desc then
|
||||
if is_description_collapsible then
|
||||
a_html.append ("<div class=%"description collapsible%"><div>Description ...</div><div>" + desc + "</div></div>")
|
||||
else
|
||||
a_html.append ("<div class=%"description%">" + desc + "</div>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</div>")
|
||||
end
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
81
library/server/wsf_html/form/wsf_form_field_set.e
Normal file
81
library/server/wsf_html/form/wsf_form_field_set.e
Normal file
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_FIELD_SET
|
||||
|
||||
inherit
|
||||
WSF_FORM_ITEM
|
||||
|
||||
WSF_FORM_COMPOSITE
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
initialize_with_count (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
legend: detachable READABLE_STRING_8
|
||||
|
||||
is_collapsible: BOOLEAN
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_legend (v: like legend)
|
||||
do
|
||||
legend := v
|
||||
end
|
||||
|
||||
set_collapsible (b: BOOLEAN)
|
||||
do
|
||||
is_collapsible := b
|
||||
if b then
|
||||
add_css_class ("collapsible")
|
||||
else
|
||||
remove_css_class ("collapsible")
|
||||
end
|
||||
end
|
||||
|
||||
set_collapsed (b: BOOLEAN)
|
||||
do
|
||||
if b then
|
||||
add_css_class ("collapsed")
|
||||
else
|
||||
remove_css_class ("collapsed")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<fieldset")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
|
||||
a_html.append (">%N")
|
||||
if attached legend as leg then
|
||||
a_html.append ("<legend>" + leg + "</legend>%N")
|
||||
end
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
c.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("%N</fieldset>%N")
|
||||
end
|
||||
|
||||
end
|
||||
46
library/server/wsf_html/form/wsf_form_file_input.e
Normal file
46
library/server/wsf_html/form/wsf_form_file_input.e
Normal file
@@ -0,0 +1,46 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_FILE_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_FILE_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
redefine
|
||||
specific_input_attributes_string
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "file"
|
||||
|
||||
accepted_types: detachable READABLE_STRING_8
|
||||
-- Types of files that the server accepts
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_accepted_types (v: like accepted_types)
|
||||
do
|
||||
accepted_types := v
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
specific_input_attributes_string: detachable STRING_8
|
||||
-- Specific input attributes if any.
|
||||
-- To redefine if needed
|
||||
do
|
||||
if attached accepted_types as l_accepted_types then
|
||||
Result := " accept=%"" + l_accepted_types + "%""
|
||||
end
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
37
library/server/wsf_html/form/wsf_form_hidden_input.e
Normal file
37
library/server/wsf_html/form/wsf_form_hidden_input.e
Normal file
@@ -0,0 +1,37 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_HIDDEN_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
redefine
|
||||
input_type,
|
||||
append_item_to_html
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_text
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING
|
||||
once
|
||||
Result := "hidden"
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<div style=%"display:none%">")
|
||||
Precursor (a_theme, a_html)
|
||||
a_html.append ("</div>")
|
||||
end
|
||||
|
||||
end
|
||||
58
library/server/wsf_html/form/wsf_form_image_input.e
Normal file
58
library/server/wsf_html/form/wsf_form_image_input.e
Normal file
@@ -0,0 +1,58 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_IMAGE_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_IMAGE_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
redefine
|
||||
specific_input_attributes_string
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "image"
|
||||
|
||||
src: detachable READABLE_STRING_8
|
||||
-- Specifies the URL of the image to use as a submit button
|
||||
|
||||
alt: detachable READABLE_STRING_8
|
||||
-- Alternate text for an image.
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_src (v: like src)
|
||||
do
|
||||
src := v
|
||||
end
|
||||
|
||||
set_alt (v: like alt)
|
||||
do
|
||||
alt := v
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
specific_input_attributes_string: detachable STRING_8
|
||||
-- Specific input attributes if any.
|
||||
-- To redefine if needed
|
||||
do
|
||||
create Result.make_empty
|
||||
if attached src as l_src then
|
||||
Result.append (" src=%"" + l_src + "%"")
|
||||
end
|
||||
if attached alt as l_alt then
|
||||
Result.append (" alt=%"" + l_alt + "%"")
|
||||
end
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
136
library/server/wsf_html/form/wsf_form_input.e
Normal file
136
library/server/wsf_html/form/wsf_form_input.e
Normal file
@@ -0,0 +1,136 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_FIELD
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
end
|
||||
|
||||
make_with_text (a_name: like name; a_text: READABLE_STRING_32)
|
||||
do
|
||||
make (a_name)
|
||||
set_text_value (a_text)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
default_value: detachable READABLE_STRING_32
|
||||
|
||||
size: INTEGER
|
||||
-- Width, in characters, of an <input> element.
|
||||
|
||||
maxlength: INTEGER
|
||||
-- Maximum number of characters allowed in an <input> element.
|
||||
|
||||
disabled: BOOLEAN
|
||||
-- Current <input> element should be disabled?
|
||||
|
||||
input_type: STRING
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_text_value (s: detachable READABLE_STRING_32)
|
||||
do
|
||||
set_default_value (s)
|
||||
end
|
||||
|
||||
set_size (i: like size)
|
||||
do
|
||||
size := i
|
||||
end
|
||||
|
||||
set_maxlength (i: like maxlength)
|
||||
do
|
||||
maxlength := i
|
||||
end
|
||||
|
||||
set_disabled (b: like disabled)
|
||||
do
|
||||
disabled := b
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
set_text_value (s.value)
|
||||
else
|
||||
set_text_value (Void)
|
||||
end
|
||||
end
|
||||
|
||||
set_default_value (v: like default_value)
|
||||
do
|
||||
default_value := v
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
old_count: INTEGER
|
||||
do
|
||||
a_html.append ("<input type=%""+ input_type +"%" name=%""+ name +"%"")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
|
||||
if is_readonly then
|
||||
a_html.append (" readonly=%"readonly%"")
|
||||
end
|
||||
if attached default_value as dft then
|
||||
a_html.append (" value=%"" + a_theme.html_encoded (dft) + "%"")
|
||||
end
|
||||
if disabled then
|
||||
a_html.append (" disabled=%"disabled%"")
|
||||
end
|
||||
if size > 0 then
|
||||
a_html.append (" size=%"" + size.out + "%"")
|
||||
end
|
||||
if maxlength > 0 then
|
||||
a_html.append (" maxlength=%"" + maxlength.out + "%"")
|
||||
end
|
||||
|
||||
if attached specific_input_attributes_string as s then
|
||||
a_html.append_character (' ')
|
||||
a_html.append (s)
|
||||
end
|
||||
a_html.append (">")
|
||||
old_count := a_html.count
|
||||
append_child_to_html (a_theme, a_html)
|
||||
if a_html.count > old_count then
|
||||
a_html.append ("</input>")
|
||||
else
|
||||
check a_html.item (a_html.count) = '>' end
|
||||
a_html.put ('/', a_html.count) -- replace previous '>'
|
||||
a_html.append (">")
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
append_child_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
-- Specific child element if any.
|
||||
--| To redefine if needed
|
||||
do
|
||||
end
|
||||
|
||||
specific_input_attributes_string: detachable STRING_8
|
||||
-- Specific input attributes if any.
|
||||
--| To redefine if needed
|
||||
do
|
||||
end
|
||||
|
||||
end
|
||||
17
library/server/wsf_html/form/wsf_form_item.e
Normal file
17
library/server/wsf_html/form/wsf_form_item.e
Normal file
@@ -0,0 +1,17 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_ITEM}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_ITEM
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
end
|
||||
27
library/server/wsf_html/form/wsf_form_password_input.e
Normal file
27
library/server/wsf_html/form/wsf_form_password_input.e
Normal file
@@ -0,0 +1,27 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_PASSWORD_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_PASSWORD_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
redefine
|
||||
input_type
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_text
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING
|
||||
once
|
||||
Result := "password"
|
||||
end
|
||||
|
||||
end
|
||||
23
library/server/wsf_html/form/wsf_form_radio_input.e
Normal file
23
library/server/wsf_html/form/wsf_form_radio_input.e
Normal file
@@ -0,0 +1,23 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_RADIO_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_RADIO_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_SELECTABLE_INPUT
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_value
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "radio"
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
34
library/server/wsf_html/form/wsf_form_raw_text.e
Normal file
34
library/server/wsf_html/form/wsf_form_raw_text.e
Normal file
@@ -0,0 +1,34 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_RAW_TEXT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_RAW_TEXT
|
||||
|
||||
inherit
|
||||
WSF_WIDGET_TEXT
|
||||
rename
|
||||
set_text as set_value,
|
||||
make_with_text as make
|
||||
redefine
|
||||
append_to_html
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
append_item_html_to (a_theme, a_html)
|
||||
end
|
||||
|
||||
append_item_html_to (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append (text)
|
||||
end
|
||||
|
||||
end
|
||||
20
library/server/wsf_html/form/wsf_form_reset_input.e
Normal file
20
library/server/wsf_html/form/wsf_form_reset_input.e
Normal file
@@ -0,0 +1,20 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_RESET_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_RESET_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "reset"
|
||||
|
||||
end
|
||||
154
library/server/wsf_html/form/wsf_form_select.e
Normal file
154
library/server/wsf_html/form/wsf_form_select.e
Normal file
@@ -0,0 +1,154 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_SELECT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_SELECT
|
||||
|
||||
inherit
|
||||
WSF_FORM_FIELD
|
||||
|
||||
WSF_FORM_UTILITY
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
create options.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
options: ARRAYED_LIST [WSF_FORM_SELECT_OPTION]
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_text_by_value (a_text: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
opt: WSF_FORM_SELECT_OPTION
|
||||
l_found: BOOLEAN
|
||||
v: READABLE_STRING_8
|
||||
do
|
||||
if a_text /= Void then
|
||||
v := html_encoded_string (a_text.to_string_32)
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
if o.item.is_same_value (v) then
|
||||
l_found := True
|
||||
o.item.set_is_selected (True)
|
||||
else
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
if not l_found then
|
||||
create opt.make (v, Void)
|
||||
opt.set_is_selected (True)
|
||||
add_option (opt)
|
||||
end
|
||||
else
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
select_value_by_text (a_text: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
l_found: BOOLEAN
|
||||
v: READABLE_STRING_8
|
||||
do
|
||||
if a_text /= Void then
|
||||
v := html_encoded_string (a_text.to_string_32)
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
if o.item.is_same_text (v) then
|
||||
l_found := True
|
||||
o.item.set_is_selected (True)
|
||||
else
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
else
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
set_text_by_value (s.value)
|
||||
else
|
||||
set_text_by_value (Void)
|
||||
end
|
||||
end
|
||||
|
||||
add_option (opt: WSF_FORM_SELECT_OPTION)
|
||||
do
|
||||
options.force (opt)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_is_already_selected: BOOLEAN
|
||||
h: detachable STRING_8
|
||||
do
|
||||
a_html.append ("<select name=%""+ name +"%" ")
|
||||
if css_id = Void then
|
||||
set_css_id (name + "-select")
|
||||
end
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
append_html_attributes_to (a_html)
|
||||
|
||||
if is_readonly then
|
||||
a_html.append (" readonly=%"readonly%" />")
|
||||
else
|
||||
a_html.append ("/>")
|
||||
end
|
||||
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
a_html.append ("<option value=%"" + o.item.value + "%" ")
|
||||
-- if not l_is_already_selected then
|
||||
if
|
||||
o.item.is_selected
|
||||
then
|
||||
l_is_already_selected := True
|
||||
a_html.append (" selected=%"selected%"")
|
||||
end
|
||||
-- end
|
||||
a_html.append (">" + o.item.text + "</option>%N")
|
||||
if attached o.item.description as d then
|
||||
if h = Void then
|
||||
create h.make_empty
|
||||
end
|
||||
h.append ("<div id=%"" + name + "-" + o.item.value + "%" class=%"option%"><strong>"+ o.item.text +"</strong>:"+ d + "</div>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</select>%N")
|
||||
if h /= Void then
|
||||
a_html.append ("<div class=%"select help collapsible%" id=%"" + name + "-help%">" + h + "</div>%N")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
63
library/server/wsf_html/form/wsf_form_select_option.e
Normal file
63
library/server/wsf_html/form/wsf_form_select_option.e
Normal file
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_SELECT_OPTION
|
||||
|
||||
inherit
|
||||
WSF_FORM_SELECTABLE_ITEM
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_value: like value; a_text: detachable like text)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
value := a_value
|
||||
if a_text = Void then
|
||||
text := a_value
|
||||
else
|
||||
text := a_text
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_selected: BOOLEAN
|
||||
|
||||
is_same_value (v: READABLE_STRING_32): BOOLEAN
|
||||
do
|
||||
Result := value.same_string (v)
|
||||
end
|
||||
|
||||
is_same_text (v: like text): BOOLEAN
|
||||
do
|
||||
Result := text.same_string (v)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: READABLE_STRING_32
|
||||
|
||||
text: READABLE_STRING_8
|
||||
|
||||
description: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_is_selected (b: like is_selected)
|
||||
do
|
||||
is_selected := b
|
||||
end
|
||||
|
||||
set_description (d: like description)
|
||||
do
|
||||
description := d
|
||||
end
|
||||
|
||||
end
|
||||
112
library/server/wsf_html/form/wsf_form_selectable_input.e
Normal file
112
library/server/wsf_html/form/wsf_form_selectable_input.e
Normal file
@@ -0,0 +1,112 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_SELECTABLE_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_SELECTABLE_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
rename
|
||||
default_value as value,
|
||||
make_with_text as make_with_value
|
||||
redefine
|
||||
set_value,
|
||||
specific_input_attributes_string,
|
||||
append_child_to_html
|
||||
end
|
||||
|
||||
WSF_FORM_SELECTABLE_ITEM
|
||||
rename
|
||||
is_selected as checked,
|
||||
set_is_selected as set_checked
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
checked: BOOLEAN
|
||||
-- Current <input> element should be preselected when the page loads
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
raw_title: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_same_value (v: READABLE_STRING_32): BOOLEAN
|
||||
do
|
||||
Result := attached value as l_value and then v.same_string (l_value)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_title (t: detachable READABLE_STRING_32)
|
||||
do
|
||||
title := t
|
||||
end
|
||||
|
||||
set_raw_title (t: detachable READABLE_STRING_8)
|
||||
do
|
||||
raw_title := t
|
||||
end
|
||||
|
||||
set_checked (b: like checked)
|
||||
do
|
||||
checked := b
|
||||
end
|
||||
|
||||
set_checked_by_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
if value /= Void then
|
||||
set_checked (is_same_value (s.value))
|
||||
else
|
||||
set_checked (s.value.same_string ("on") or s.value.same_string ("true") or s.value.same_string ("yes") or s.value.same_string ("enabled"))
|
||||
end
|
||||
else
|
||||
set_checked (False)
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
-- Set value `v' if applicable to Current
|
||||
do
|
||||
if attached {ITERABLE [WSF_VALUE]} v as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
set_checked_by_value (c.item)
|
||||
end
|
||||
else
|
||||
set_checked_by_value (v)
|
||||
Precursor (v)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
append_child_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
-- Specific child element if any.
|
||||
--| To redefine if needed
|
||||
do
|
||||
if attached raw_title as t then
|
||||
a_html.append (t)
|
||||
elseif attached title as t then
|
||||
a_html.append (a_theme.html_encoded (t))
|
||||
end
|
||||
end
|
||||
|
||||
specific_input_attributes_string: detachable STRING_8
|
||||
-- Specific input attributes if any.
|
||||
-- To redefine if needed
|
||||
do
|
||||
if checked then
|
||||
Result := "checked=%"checked%""
|
||||
end
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
25
library/server/wsf_html/form/wsf_form_selectable_item.e
Normal file
25
library/server/wsf_html/form/wsf_form_selectable_item.e
Normal file
@@ -0,0 +1,25 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_SELECTABLE_ITEM}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_SELECTABLE_ITEM
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_selected : BOOLEAN
|
||||
deferred
|
||||
end
|
||||
|
||||
is_same_value (v: READABLE_STRING_32): BOOLEAN
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_is_selected (b: like is_selected)
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
21
library/server/wsf_html/form/wsf_form_submit_input.e
Normal file
21
library/server/wsf_html/form/wsf_form_submit_input.e
Normal file
@@ -0,0 +1,21 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_SUBMIT_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_text
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "submit"
|
||||
|
||||
end
|
||||
21
library/server/wsf_html/form/wsf_form_text_input.e
Normal file
21
library/server/wsf_html/form/wsf_form_text_input.e
Normal file
@@ -0,0 +1,21 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_TEXT_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_TEXT_INPUT
|
||||
|
||||
inherit
|
||||
WSF_FORM_INPUT
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_text
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_type: STRING = "text"
|
||||
|
||||
end
|
||||
89
library/server/wsf_html/form/wsf_form_textarea.e
Normal file
89
library/server/wsf_html/form/wsf_form_textarea.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_INPUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_TEXTAREA
|
||||
|
||||
inherit
|
||||
WSF_FORM_FIELD
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
default_value: detachable READABLE_STRING_GENERAL
|
||||
|
||||
rows: INTEGER
|
||||
|
||||
cols: INTEGER
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_rows (i: like rows)
|
||||
do
|
||||
rows := i
|
||||
end
|
||||
|
||||
set_cols (i: like cols)
|
||||
do
|
||||
cols := i
|
||||
end
|
||||
|
||||
set_text_value (s: like default_value)
|
||||
do
|
||||
set_default_value (s)
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
set_text_value (s.value)
|
||||
else
|
||||
set_text_value (Void)
|
||||
end
|
||||
end
|
||||
|
||||
set_default_value (v: like default_value)
|
||||
do
|
||||
default_value := v
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<textarea name=%""+ name +"%"")
|
||||
if rows > 0 then
|
||||
a_html.append (" rows=%"" + rows.out + "%"")
|
||||
end
|
||||
if cols > 0 then
|
||||
a_html.append (" cols=%"" + cols.out + "%"")
|
||||
end
|
||||
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
|
||||
if is_readonly then
|
||||
a_html.append (" readonly=%"readonly%">")
|
||||
else
|
||||
a_html.append (">")
|
||||
end
|
||||
if attached default_value as dft then
|
||||
a_html.append (a_theme.html_encoded (dft))
|
||||
end
|
||||
a_html.append ("</textarea>")
|
||||
end
|
||||
|
||||
end
|
||||
22
library/server/wsf_html/form/wsf_form_utility.e
Normal file
22
library/server/wsf_html/form/wsf_form_utility.e
Normal file
@@ -0,0 +1,22 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_UTILITY}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_UTILITY
|
||||
|
||||
feature -- Converter
|
||||
|
||||
html_encoded_string (s: READABLE_STRING_32): READABLE_STRING_8
|
||||
do
|
||||
Result := html_encoder.encoded_string (s)
|
||||
end
|
||||
|
||||
html_encoder: HTML_ENCODER
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
end
|
||||
22
library/server/wsf_html/widget/wsf_widget.e
Normal file
22
library/server/wsf_html/widget/wsf_widget.e
Normal file
@@ -0,0 +1,22 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WIDGET
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
deferred
|
||||
end
|
||||
|
||||
to_html (a_theme: WSF_THEME): STRING_8
|
||||
do
|
||||
create Result.make_empty
|
||||
append_to_html (a_theme, Result)
|
||||
end
|
||||
|
||||
end
|
||||
225
library/server/wsf_html/widget/wsf_widget_agent_table.e
Normal file
225
library/server/wsf_html/widget/wsf_widget_agent_table.e
Normal file
@@ -0,0 +1,225 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_AGENT_TABLE [G]
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
to_computed_table: {WSF_WIDGET_TABLE}
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create columns.make_empty
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
column_count: INTEGER
|
||||
do
|
||||
Result := columns.count
|
||||
end
|
||||
|
||||
columns: ARRAY [WSF_WIDGET_TABLE_COLUMN]
|
||||
|
||||
column (c: INTEGER): WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
Result := columns[c]
|
||||
end
|
||||
|
||||
has_title: BOOLEAN
|
||||
do
|
||||
Result := across columns as c some c.item.title /= Void end
|
||||
end
|
||||
|
||||
head_data: detachable ITERABLE [G]
|
||||
-- thead
|
||||
|
||||
foot_data: detachable ITERABLE [G]
|
||||
-- tfoot
|
||||
|
||||
data: detachable ITERABLE [G]
|
||||
-- tbody
|
||||
|
||||
compute_item_function: detachable FUNCTION [ANY, TUPLE [data: G], WSF_WIDGET_TABLE_ROW]
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_head_data (d: like head_data)
|
||||
do
|
||||
head_data := d
|
||||
end
|
||||
|
||||
set_foot_data (d: like foot_data)
|
||||
do
|
||||
foot_data := d
|
||||
end
|
||||
|
||||
set_data (d: like data)
|
||||
do
|
||||
data := d
|
||||
end
|
||||
|
||||
set_compute_item_function (fct: like compute_item_function)
|
||||
do
|
||||
compute_item_function := fct
|
||||
end
|
||||
|
||||
set_column_count (nb: INTEGER)
|
||||
do
|
||||
if nb > columns.count then
|
||||
-- columns.conservative_resize_with_default (create {WSF_WIDGET_TABLE_COLUMN}, 1, nb)
|
||||
from
|
||||
until
|
||||
columns.count = nb
|
||||
loop
|
||||
columns.force (create {WSF_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
|
||||
end
|
||||
else
|
||||
columns.remove_tail (columns.count - nb)
|
||||
end
|
||||
end
|
||||
|
||||
set_column_title (c: INTEGER; t: READABLE_STRING_32)
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
if attached column (c) as col then
|
||||
col.set_title (t)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_computed_table: WSF_WIDGET_TABLE
|
||||
local
|
||||
col: WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
create Result.make
|
||||
Result.set_column_count (column_count)
|
||||
-- css classes
|
||||
Result.add_css_classes (css_classes)
|
||||
-- css id
|
||||
Result.set_css_id (css_id)
|
||||
-- css style
|
||||
Result.add_css_style (css_style)
|
||||
|
||||
-- columns
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
col := Result.column (c.item.index)
|
||||
col.set_title (c.item.title)
|
||||
col.add_css_style (c.item.css_style)
|
||||
col.add_css_classes (c.item.css_classes)
|
||||
end
|
||||
|
||||
-- rows
|
||||
if attached compute_item_function as fct then
|
||||
if attached head_data as lst then
|
||||
across lst as d loop
|
||||
Result.add_head_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached data as lst then
|
||||
across lst as d loop
|
||||
Result.add_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached foot_data as lst then
|
||||
across lst as d loop
|
||||
Result.add_foot_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion: HTML
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_use_tbody: BOOLEAN
|
||||
do
|
||||
a_html.append ("<table")
|
||||
append_css_id_to (a_html)
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append (">")
|
||||
|
||||
if has_title then
|
||||
a_html.append ("<tr>")
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
c.item.append_table_header_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
if attached head_data as l_head_data then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<thead>")
|
||||
append_data_to_html (l_head_data, a_theme, a_html)
|
||||
a_html.append ("</thead>")
|
||||
end
|
||||
if attached foot_data as l_foot_data then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<tfoot>")
|
||||
append_data_to_html (l_foot_data, a_theme, a_html)
|
||||
a_html.append ("</tfoot>")
|
||||
end
|
||||
|
||||
if attached data as l_data then
|
||||
if l_use_tbody then
|
||||
a_html.append ("<tbody>")
|
||||
end
|
||||
append_data_to_html (l_data, a_theme, a_html)
|
||||
if l_use_tbody then
|
||||
a_html.append ("</tbody>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</table>")
|
||||
end
|
||||
|
||||
append_data_to_html (lst: ITERABLE [G]; a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
fct: like compute_item_function
|
||||
do
|
||||
fct := compute_item_function
|
||||
across
|
||||
lst as d
|
||||
loop
|
||||
if fct /= Void and then attached fct.item ([d.item]) as r then
|
||||
r.append_to_html (a_theme, a_html)
|
||||
else
|
||||
a_html.append ("<tr>")
|
||||
a_html.append ("<td>")
|
||||
if attached d.item as g then
|
||||
a_html.append (g.out)
|
||||
end
|
||||
a_html.append ("</td>")
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
250
library/server/wsf_html/widget/wsf_widget_composite.e
Normal file
250
library/server/wsf_html/widget/wsf_widget_composite.e
Normal file
@@ -0,0 +1,250 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WIDGET_COMPOSITE
|
||||
|
||||
inherit
|
||||
ITERABLE [WSF_WIDGET]
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize_with_count (n: INTEGER)
|
||||
do
|
||||
create items.make (n)
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_empty: BOOLEAN
|
||||
do
|
||||
Result := count = 0
|
||||
end
|
||||
|
||||
has_item (i: WSF_WIDGET): BOOLEAN
|
||||
do
|
||||
if has_immediate_item (i) then
|
||||
Result := True
|
||||
else
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
if attached {WSF_WIDGET_COMPOSITE} c.item as comp then
|
||||
Result := comp.has_item (i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
has_immediate_item (i: WSF_WIDGET): BOOLEAN
|
||||
do
|
||||
Result := items.has (i)
|
||||
end
|
||||
|
||||
feature -- Access: cursor
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_WIDGET]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
count: INTEGER
|
||||
do
|
||||
Result := immediate_count
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
if attached {WSF_WIDGET_COMPOSITE} c.item as comp then
|
||||
Result := Result + comp.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
immediate_count: INTEGER
|
||||
do
|
||||
Result := items.count
|
||||
end
|
||||
|
||||
items_by_type (a_type: TYPE [detachable ANY]): detachable LIST [WSF_WIDGET]
|
||||
-- All WSF_WIDGET items conforming to a_type.
|
||||
-- Warning: you should pass {detachable WSF_FORM_SUBMIT_INPUT} rather than just {WSF_FORM_SUBMIT_INPUT}
|
||||
local
|
||||
int: INTERNAL
|
||||
tid: INTEGER
|
||||
t: TYPE [detachable ANY]
|
||||
do
|
||||
tid := a_type.type_id
|
||||
create int
|
||||
tid := int.detachable_type (tid)
|
||||
if tid > 0 then
|
||||
t := int.type_of_type (tid)
|
||||
if not a_type.conforms_to (t) then
|
||||
t := a_type
|
||||
end
|
||||
else
|
||||
t := a_type
|
||||
end
|
||||
Result := items_by_type_from (Current, t)
|
||||
end
|
||||
|
||||
items_by_css_id (a_id: READABLE_STRING_GENERAL): detachable LIST [WSF_WIDGET]
|
||||
do
|
||||
Result := items_by_css_id_from (Current, a_id)
|
||||
end
|
||||
|
||||
first_item_by_css_id (a_id: READABLE_STRING_GENERAL): detachable WSF_WIDGET
|
||||
do
|
||||
if attached items_by_css_id_from (Current, a_id) as lst then
|
||||
if not lst.is_empty then
|
||||
Result := lst.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
insert_before (i: WSF_WIDGET; a_item: WSF_WIDGET)
|
||||
-- Insert `i' before `a_item'
|
||||
require
|
||||
has_item (a_item)
|
||||
local
|
||||
done: BOOLEAN
|
||||
do
|
||||
if has_immediate_item (a_item) then
|
||||
items.start
|
||||
items.search (a_item)
|
||||
if items.exhausted then
|
||||
items.put_front (i)
|
||||
else
|
||||
items.put_left (i)
|
||||
end
|
||||
else
|
||||
across
|
||||
items as c
|
||||
until
|
||||
done
|
||||
loop
|
||||
if attached {WSF_WIDGET_COMPOSITE} c.item as comp and then comp.has_item (a_item) then
|
||||
comp.insert_before (i, a_item)
|
||||
done := True
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
insert_after (i: WSF_WIDGET; a_item: WSF_WIDGET)
|
||||
-- Insert `i' after `a_item'
|
||||
require
|
||||
has_item (a_item)
|
||||
local
|
||||
done: BOOLEAN
|
||||
do
|
||||
if has_immediate_item (a_item) then
|
||||
items.start
|
||||
items.search (a_item)
|
||||
if items.exhausted then
|
||||
items.force (i)
|
||||
else
|
||||
items.put_right (i)
|
||||
end
|
||||
else
|
||||
across
|
||||
items as c
|
||||
until
|
||||
done
|
||||
loop
|
||||
if attached {WSF_WIDGET_COMPOSITE} c.item as comp and then comp.has_item (a_item) then
|
||||
comp.insert_after (i, a_item)
|
||||
done := True
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
extend (i: WSF_WIDGET)
|
||||
do
|
||||
items.force (i)
|
||||
end
|
||||
|
||||
prepend (i: WSF_WIDGET)
|
||||
do
|
||||
items.put_front (i)
|
||||
end
|
||||
|
||||
extend_text (t: READABLE_STRING_8)
|
||||
do
|
||||
extend (create {WSF_WIDGET_TEXT}.make_with_text (t))
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Items
|
||||
|
||||
items_by_type_from (a_container: ITERABLE [WSF_WIDGET]; a_type: TYPE [detachable ANY]): detachable ARRAYED_LIST [WSF_WIDGET]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [WSF_WIDGET]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if i.item.generating_type.conforms_to (a_type) then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (i.item)
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then
|
||||
if attached items_by_type_from (l_cont, a_type) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
items_by_css_id_from (a_container: ITERABLE [WSF_WIDGET]; a_id: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [WSF_WIDGET]
|
||||
local
|
||||
res: detachable ARRAYED_LIST [WSF_WIDGET]
|
||||
do
|
||||
across
|
||||
a_container as i
|
||||
loop
|
||||
if
|
||||
attached {WSF_WITH_CSS_ID} i.item as l_with_css_id and then
|
||||
attached l_with_css_id.css_id as l_css_id and then
|
||||
l_css_id.same_string_general (a_id)
|
||||
then
|
||||
if res = Void then
|
||||
create res.make (1)
|
||||
end
|
||||
res.force (i.item)
|
||||
elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then
|
||||
if attached items_by_css_id_from (l_cont, a_id) as lst then
|
||||
if res = Void then
|
||||
res := lst
|
||||
else
|
||||
res.append (lst)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: ARRAYED_LIST [WSF_WIDGET]
|
||||
-- name => item
|
||||
|
||||
invariant
|
||||
items /= Void
|
||||
|
||||
|
||||
end
|
||||
161
library/server/wsf_html/widget/wsf_widget_pager.e
Normal file
161
library/server/wsf_html/widget/wsf_widget_pager.e
Normal file
@@ -0,0 +1,161 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_PAGER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_PAGER
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tpl: READABLE_STRING_8; a_lower, a_upper: NATURAL_64; a_step: NATURAL_64)
|
||||
do
|
||||
create template.make (tpl)
|
||||
lower := a_lower
|
||||
upper := a_upper
|
||||
step := a_step
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_active_range (a_lower, a_upper: NATURAL_64)
|
||||
do
|
||||
if a_upper = 0 then
|
||||
active_range := [{NATURAL_64} 1, {NATURAL_64} 0]
|
||||
elseif a_lower > 0 and a_lower <= a_upper then
|
||||
active_range := [a_lower, a_upper]
|
||||
else
|
||||
active_range := Void
|
||||
end
|
||||
ensure
|
||||
valid_range: attached active_range as rg implies (rg.upper = 0 or else rg.lower <= rg.upper)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
template: URI_TEMPLATE
|
||||
|
||||
lower: NATURAL_64
|
||||
|
||||
upper: NATURAL_64
|
||||
|
||||
step: NATURAL_64
|
||||
|
||||
active_range: detachable TUPLE [lower_index, upper_index: NATURAL_64]
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_step: INTEGER
|
||||
nb: INTEGER
|
||||
curr: INTEGER
|
||||
n, i: INTEGER
|
||||
tb: HASH_TABLE [detachable ANY, STRING_8]
|
||||
do
|
||||
a_html.append ("<div")
|
||||
a_html.append_character ('>')
|
||||
nb := ((upper - lower) // step).to_integer_32 + 1
|
||||
if nb > 1 then
|
||||
if attached active_range as rg then
|
||||
if rg.upper_index = 0 then
|
||||
-- all
|
||||
else
|
||||
curr := ((rg.lower_index - lower) // step).to_integer_32
|
||||
if step * curr.to_natural_64 < rg.lower_index then
|
||||
curr := curr + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
l_step := step.to_integer_32
|
||||
create tb.make (2)
|
||||
tb.force (1, "lower")
|
||||
tb.force (step, "upper")
|
||||
if curr > 1 then
|
||||
if curr > 2 then
|
||||
tb.force (1, "lower")
|
||||
tb.force (l_step, "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, "<<", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
tb.force ((curr - 1) * l_step + 1, "lower")
|
||||
tb.force ((curr ) * l_step , "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, "<", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
from
|
||||
i := (curr - 1).max (1)
|
||||
n := 5
|
||||
until
|
||||
n = 0 or i > nb
|
||||
loop
|
||||
a_html.append_character (' ')
|
||||
|
||||
tb.force ((i - 1) * l_step + 1, "lower")
|
||||
tb.force ((i ) * l_step , "upper")
|
||||
|
||||
if i = curr then
|
||||
a_html.append ("<strong>")
|
||||
end
|
||||
append_link_to_html (a_theme, i.out, template.expanded_string (tb), a_html)
|
||||
if i = curr then
|
||||
a_html.append ("</strong>")
|
||||
end
|
||||
|
||||
a_html.append_character (' ')
|
||||
|
||||
i := i + 1
|
||||
n := n - 1
|
||||
end
|
||||
|
||||
if curr < nb then
|
||||
a_html.append_character (' ')
|
||||
tb.force ((curr ) * l_step + 1, "lower")
|
||||
tb.force ((curr + 1) * l_step , "upper")
|
||||
append_link_to_html (a_theme, ">", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
|
||||
if curr + 1 < nb then
|
||||
tb.force ((nb - 1) * l_step + 1, "lower")
|
||||
tb.force ( upper , "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, ">>", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
end
|
||||
a_html.append_character (' ')
|
||||
tb.force (1, "lower")
|
||||
tb.force (upper , "upper")
|
||||
append_link_to_html (a_theme, "all", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
a_html.append ("</div>")
|
||||
debug
|
||||
a_html.append ("curr=" + curr.out +" step=" + step.out + " nb=" + nb.out)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
append_link_to_html (a_theme: WSF_THEME; a_text: detachable READABLE_STRING_GENERAL; a_path: STRING; a_html: STRING_8)
|
||||
do
|
||||
a_theme.append_link_to_html (a_text, a_path, Void, a_html)
|
||||
end
|
||||
|
||||
end
|
||||
281
library/server/wsf_html/widget/wsf_widget_table.e
Normal file
281
library/server/wsf_html/widget/wsf_widget_table.e
Normal file
@@ -0,0 +1,281 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_FILLED_TABLE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
ITERABLE [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create columns.make_empty
|
||||
end
|
||||
|
||||
make_from_table (tb: WSF_WIDGET_AGENT_TABLE [detachable ANY])
|
||||
local
|
||||
fct: like {WSF_WIDGET_AGENT_TABLE [detachable ANY]}.compute_item_function
|
||||
do
|
||||
make
|
||||
set_column_count (tb.column_count)
|
||||
-- css classes
|
||||
if attached tb.css_classes as lst then
|
||||
across lst as c loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
-- css id
|
||||
set_css_id (tb.css_id)
|
||||
|
||||
-- css style
|
||||
add_css_style (tb.css_style)
|
||||
|
||||
-- columns
|
||||
across
|
||||
tb.columns as c
|
||||
loop
|
||||
columns [c.item.index] := c.item.twin
|
||||
end
|
||||
|
||||
-- rows
|
||||
fct := tb.compute_item_function
|
||||
if fct /= Void then
|
||||
if attached tb.head_data as lst then
|
||||
across lst as d loop
|
||||
add_head_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached tb.data as lst then
|
||||
across lst as d loop
|
||||
add_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached tb.foot_data as lst then
|
||||
across lst as d loop
|
||||
add_foot_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: WSF_WIDGET_TABLE_ITERATION_CURSOR
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
column_count: INTEGER
|
||||
do
|
||||
Result := columns.count
|
||||
end
|
||||
|
||||
head_row_count: INTEGER
|
||||
do
|
||||
if attached head_rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
body_row_count: INTEGER
|
||||
do
|
||||
if attached rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
foot_row_count: INTEGER
|
||||
do
|
||||
if attached foot_rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
row_count: INTEGER
|
||||
do
|
||||
Result := head_row_count + body_row_count + foot_row_count
|
||||
end
|
||||
|
||||
columns: ARRAY [WSF_WIDGET_TABLE_COLUMN]
|
||||
|
||||
|
||||
column (c: INTEGER): WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
Result := columns[c]
|
||||
end
|
||||
|
||||
row (r: INTEGER): detachable WSF_WIDGET_TABLE_ROW
|
||||
do
|
||||
if r <= head_row_count then
|
||||
if attached head_rows as lst then
|
||||
Result := lst [r]
|
||||
end
|
||||
elseif r <= head_row_count + body_row_count then
|
||||
if attached rows as lst then
|
||||
Result := lst [r - head_row_count]
|
||||
end
|
||||
elseif r <= row_count then
|
||||
if attached foot_rows as lst then
|
||||
Result := lst [r - head_row_count - body_row_count]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
has_title: BOOLEAN
|
||||
do
|
||||
Result := across columns as c some c.item.title /= Void end
|
||||
end
|
||||
|
||||
head_rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- thead
|
||||
|
||||
foot_rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- tfoot
|
||||
|
||||
rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- tbody
|
||||
|
||||
feature -- Change
|
||||
|
||||
clear_rows
|
||||
do
|
||||
head_rows := Void
|
||||
foot_rows := Void
|
||||
rows := Void
|
||||
end
|
||||
|
||||
add_head_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like head_rows
|
||||
do
|
||||
lst := head_rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
head_rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
add_foot_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like foot_rows
|
||||
do
|
||||
lst := foot_rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
foot_rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
add_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like rows
|
||||
do
|
||||
lst := rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
set_column_count (nb: INTEGER)
|
||||
do
|
||||
if nb > columns.count then
|
||||
from
|
||||
until
|
||||
columns.count = nb
|
||||
loop
|
||||
columns.force (create {WSF_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
|
||||
end
|
||||
else
|
||||
columns.remove_tail (columns.count - nb)
|
||||
end
|
||||
end
|
||||
|
||||
set_column_title (c: INTEGER; t: READABLE_STRING_32)
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
if attached column (c) as col then
|
||||
col.set_title (t)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_use_tbody: BOOLEAN
|
||||
do
|
||||
a_html.append ("<table")
|
||||
append_css_id_to (a_html)
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append (">")
|
||||
|
||||
if has_title then
|
||||
a_html.append ("<tr>")
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
c.item.append_table_header_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
if attached head_rows as l_head_rows then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<thead>")
|
||||
append_rows_to_html (l_head_rows, a_theme, a_html)
|
||||
a_html.append ("</thead>")
|
||||
end
|
||||
if attached foot_rows as l_foot_rows then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<tfoot>")
|
||||
append_rows_to_html (l_foot_rows, a_theme, a_html)
|
||||
a_html.append ("</tfoot>")
|
||||
end
|
||||
|
||||
if attached rows as l_rows then
|
||||
if l_use_tbody then
|
||||
a_html.append ("<tbody>")
|
||||
end
|
||||
append_rows_to_html (l_rows, a_theme, a_html)
|
||||
if l_use_tbody then
|
||||
a_html.append ("</tbody>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</table>")
|
||||
end
|
||||
|
||||
append_rows_to_html (lst: ITERABLE [WSF_WIDGET_TABLE_ROW]; a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
across
|
||||
lst as r
|
||||
loop
|
||||
r.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
52
library/server/wsf_html/widget/wsf_widget_table_column.e
Normal file
52
library/server/wsf_html/widget/wsf_widget_table_column.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_COLUMN}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_COLUMN
|
||||
|
||||
inherit
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (i: like index)
|
||||
do
|
||||
index := i
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
index: INTEGER
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_title (t: like title)
|
||||
do
|
||||
title := t
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_table_header_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<th")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
if attached title as l_title then
|
||||
a_html.append (a_theme.html_encoded (l_title))
|
||||
end
|
||||
a_html.append ("</th>")
|
||||
end
|
||||
|
||||
end
|
||||
78
library/server/wsf_html/widget/wsf_widget_table_item.e
Normal file
78
library/server/wsf_html/widget/wsf_widget_table_item.e
Normal file
@@ -0,0 +1,78 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ITEM}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ITEM
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
ITERABLE [WSF_WIDGET]
|
||||
|
||||
create
|
||||
make_with_text,
|
||||
make_with_text_and_css,
|
||||
make_with_content
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_text (a_text: READABLE_STRING_8)
|
||||
do
|
||||
make_with_content (create {WSF_WIDGET_TEXT}.make_with_text (a_text))
|
||||
end
|
||||
|
||||
make_with_text_and_css (a_text: READABLE_STRING_8; a_css_classes: detachable ITERABLE [READABLE_STRING_8])
|
||||
do
|
||||
make_with_text (a_text)
|
||||
if a_css_classes /= Void then
|
||||
across
|
||||
a_css_classes as c
|
||||
loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
make_with_content (a_widget: WSF_WIDGET)
|
||||
do
|
||||
content := a_widget
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content: WSF_WIDGET
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_WIDGET]
|
||||
-- Fresh cursor associated with current structure
|
||||
local
|
||||
lst: ARRAYED_LIST [WSF_WIDGET]
|
||||
do
|
||||
create lst.make (1)
|
||||
lst.extend (content)
|
||||
Result := lst.new_cursor
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<td")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
content.append_to_html (a_theme, a_html)
|
||||
a_html.append ("</td>")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,96 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ITERATION_CURSOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ITERATION_CURSOR
|
||||
|
||||
inherit
|
||||
ITERATION_CURSOR [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_table: WSF_WIDGET_TABLE)
|
||||
do
|
||||
table := a_table
|
||||
start
|
||||
end
|
||||
|
||||
table: WSF_WIDGET_TABLE
|
||||
|
||||
row_index: INTEGER
|
||||
column_index: INTEGER
|
||||
|
||||
feature -- Access
|
||||
|
||||
start
|
||||
do
|
||||
row_index := 1
|
||||
column_index := 0
|
||||
forth
|
||||
end
|
||||
|
||||
item: WSF_WIDGET_TABLE_ITEM
|
||||
-- Item at current cursor position.
|
||||
do
|
||||
if attached table.row (row_index) as r then
|
||||
if attached r.item (column_index) as w then
|
||||
Result := w
|
||||
else
|
||||
create Result.make_with_text ("")
|
||||
end
|
||||
else
|
||||
create Result.make_with_text ("")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
after: BOOLEAN
|
||||
-- Are there no more items to iterate over?
|
||||
do
|
||||
if row_index > table.row_count then
|
||||
Result := True
|
||||
elseif row_index = table.row_count then
|
||||
if attached table.row (row_index) as l_row then
|
||||
if column_index > l_row.count then
|
||||
Result := True
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
else
|
||||
Result := True
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Cursor movement
|
||||
|
||||
forth
|
||||
-- Move to next position.
|
||||
do
|
||||
if row_index <= table.row_count then
|
||||
if attached table.row (row_index) as l_row then
|
||||
if column_index < l_row.count then
|
||||
column_index := column_index + 1
|
||||
else
|
||||
from
|
||||
row_index := row_index + 1
|
||||
column_index := 1
|
||||
until
|
||||
row_index > table.row_count or
|
||||
attached table.row (row_index) as r and then r.count > 0
|
||||
loop
|
||||
row_index := row_index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
106
library/server/wsf_html/widget/wsf_widget_table_row.e
Normal file
106
library/server/wsf_html/widget/wsf_widget_table_row.e
Normal file
@@ -0,0 +1,106 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ROW}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ROW
|
||||
|
||||
inherit
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
ITERABLE [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_items
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: INTEGER)
|
||||
do
|
||||
create items.make (n)
|
||||
end
|
||||
|
||||
make_with_items (lst: ITERABLE [WSF_WIDGET_TABLE_ITEM])
|
||||
local
|
||||
n: INTEGER
|
||||
do
|
||||
across lst as c loop
|
||||
n := n + 1
|
||||
end
|
||||
make (n)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
add_item (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
items: ARRAYED_LIST [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_WIDGET_TABLE_ITEM]
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
do
|
||||
Result := items.count
|
||||
end
|
||||
|
||||
item (c: INTEGER): WSF_WIDGET_TABLE_ITEM
|
||||
do
|
||||
Result := items [c]
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_item (w: WSF_WIDGET_TABLE_ITEM; col: INTEGER)
|
||||
do
|
||||
if col > items.count then
|
||||
items.grow (col)
|
||||
from
|
||||
until
|
||||
items.count >= col - 1
|
||||
loop
|
||||
items.force (create {WSF_WIDGET_TABLE_ITEM}.make_with_text (""))
|
||||
end
|
||||
items.force (w)
|
||||
else
|
||||
items.put_i_th (w, col)
|
||||
end
|
||||
end
|
||||
|
||||
add_widget (w: WSF_WIDGET)
|
||||
do
|
||||
add_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w))
|
||||
end
|
||||
|
||||
force, add_item (w: WSF_WIDGET_TABLE_ITEM)
|
||||
do
|
||||
items.force (w)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<tr")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
c.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
|
||||
end
|
||||
41
library/server/wsf_html/widget/wsf_widget_text.e
Normal file
41
library/server/wsf_html/widget/wsf_widget_text.e
Normal file
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TEXT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TEXT
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
create
|
||||
make_with_text
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_text (a_text: READABLE_STRING_8)
|
||||
do
|
||||
text := a_text
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: READABLE_STRING_8
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_text (a_text: like text)
|
||||
do
|
||||
text := a_text
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append (text)
|
||||
end
|
||||
|
||||
end
|
||||
109
library/server/wsf_html/widget/wsf_with_css_class.e
Normal file
109
library/server/wsf_html/widget/wsf_with_css_class.e
Normal file
@@ -0,0 +1,109 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WITH_CSS_CLASS}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
feature -- Status report
|
||||
|
||||
css_classes: detachable LIST [READABLE_STRING_8]
|
||||
|
||||
feature -- Change
|
||||
|
||||
reset_css_classes
|
||||
do
|
||||
css_classes := Void
|
||||
end
|
||||
|
||||
add_css_classes (a_classes: detachable ITERABLE [READABLE_STRING_8])
|
||||
do
|
||||
if a_classes /= Void then
|
||||
across
|
||||
a_classes as c
|
||||
loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_css_class (a_class: READABLE_STRING_8)
|
||||
require
|
||||
is_valid_css_class: is_valid_css_class (a_class)
|
||||
local
|
||||
lst: like css_classes
|
||||
do
|
||||
lst := css_classes
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [READABLE_STRING_8]} lst.make (1)
|
||||
lst.compare_objects
|
||||
css_classes := lst
|
||||
end
|
||||
lst.force (a_class)
|
||||
end
|
||||
|
||||
remove_css_class (a_class: READABLE_STRING_8)
|
||||
require
|
||||
is_valid_css_class: is_valid_css_class (a_class)
|
||||
local
|
||||
lst: like css_classes
|
||||
do
|
||||
lst := css_classes
|
||||
if lst /= Void then
|
||||
lst.prune_all (a_class)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_valid_css_class (s: detachable READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := s /= Void implies (not s.is_empty)
|
||||
-- To complete
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_css_class_to (a_target: STRING; a_additional_classes: detachable ITERABLE [READABLE_STRING_8])
|
||||
local
|
||||
f: BOOLEAN
|
||||
cl: READABLE_STRING_8
|
||||
do
|
||||
if css_classes /= Void or a_additional_classes /= Void then
|
||||
a_target.append (" class=%"")
|
||||
f := True -- is first
|
||||
|
||||
if attached css_classes as l_classes then
|
||||
across
|
||||
l_classes as c
|
||||
loop
|
||||
cl := c.item
|
||||
if not cl.is_empty then
|
||||
if f then
|
||||
f := False
|
||||
else
|
||||
a_target.append_character (' ')
|
||||
end
|
||||
a_target.append (cl)
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached a_additional_classes as l_classes then
|
||||
across
|
||||
l_classes as c
|
||||
loop
|
||||
cl := c.item
|
||||
if not cl.is_empty then
|
||||
if not f then
|
||||
a_target.append_character (' ')
|
||||
end
|
||||
a_target.append (cl)
|
||||
end
|
||||
end
|
||||
end
|
||||
a_target.append_character ('%"')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
41
library/server/wsf_html/widget/wsf_with_css_id.e
Normal file
41
library/server/wsf_html/widget/wsf_with_css_id.e
Normal file
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WITH_CSS_ID}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
feature -- Status report
|
||||
|
||||
css_id: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_css_id (a_id: like css_id)
|
||||
require
|
||||
is_valid_css_id: is_valid_css_id (a_id)
|
||||
do
|
||||
css_id := a_id
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_valid_css_id (s: detachable READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := s /= Void implies (not s.is_empty)
|
||||
-- To complete
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_css_id_to (a_target: STRING)
|
||||
do
|
||||
if attached css_id as l_id then
|
||||
a_target.append (" id=%"")
|
||||
a_target.append (l_id)
|
||||
a_target.append_character ('%"')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
43
library/server/wsf_html/widget/wsf_with_css_style.e
Normal file
43
library/server/wsf_html/widget/wsf_with_css_style.e
Normal file
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WITH_CSS_STYLE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
feature -- Status report
|
||||
|
||||
css_style: detachable CSS_STYLE
|
||||
|
||||
feature -- Change
|
||||
|
||||
reset_css_style
|
||||
do
|
||||
css_style := Void
|
||||
end
|
||||
|
||||
add_css_style (a_style: like css_style)
|
||||
local
|
||||
s: like css_style
|
||||
do
|
||||
s := css_style
|
||||
if s = Void then
|
||||
css_style := a_style
|
||||
elseif a_style /= Void then
|
||||
css_style := s + a_style
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_css_style_to (a_target: STRING)
|
||||
do
|
||||
if attached css_style as l_css_style then
|
||||
a_target.append (" style=%"")
|
||||
l_css_style.append_inline_to (a_target)
|
||||
a_target.append_character ('%"')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
81
library/server/wsf_html/widget/wsf_with_html_attribute.e
Normal file
81
library/server/wsf_html/widget/wsf_with_html_attribute.e
Normal file
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WITH_HTML_ATTRIBUTE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
feature -- Status report
|
||||
|
||||
html_attributes: detachable HASH_TABLE [detachable READABLE_STRING_8, STRING_8]
|
||||
|
||||
feature -- Change
|
||||
|
||||
reset_html_attributes
|
||||
do
|
||||
html_attributes := Void
|
||||
end
|
||||
|
||||
add_html_attribute (a_name: READABLE_STRING_8; a_value: detachable READABLE_STRING_8)
|
||||
require
|
||||
is_valid_attribute_name: is_valid_attribute_name (a_name)
|
||||
is_valid_attribute_value: is_valid_attribute_value (a_value)
|
||||
local
|
||||
lst: like html_attributes
|
||||
do
|
||||
lst := html_attributes
|
||||
if lst = Void then
|
||||
create lst.make (1)
|
||||
lst.compare_objects
|
||||
html_attributes := lst
|
||||
end
|
||||
lst.force (a_value, a_name)
|
||||
end
|
||||
|
||||
remove_html_attribute (a_name: READABLE_STRING_8)
|
||||
require
|
||||
is_valid_attribute_name: is_valid_attribute_name (a_name)
|
||||
local
|
||||
lst: like html_attributes
|
||||
do
|
||||
lst := html_attributes
|
||||
if lst /= Void then
|
||||
lst.remove (a_name)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_valid_attribute_name (s: detachable READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := s /= Void implies (not s.is_empty)
|
||||
-- To complete
|
||||
end
|
||||
|
||||
is_valid_attribute_value (s: detachable READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := s /= Void implies (not s.has ('%"'))
|
||||
-- To complete
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_html_attributes_to (a_target: STRING)
|
||||
do
|
||||
if attached html_attributes as attribs then
|
||||
across
|
||||
attribs as c
|
||||
loop
|
||||
a_target.append (" " + c.key)
|
||||
if attached c.item as v then
|
||||
a_target.append_character ('=')
|
||||
a_target.append_character ('%"')
|
||||
a_target.append (v)
|
||||
a_target.append_character ('%"')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
21
library/server/wsf_html/wsf_html-safe.ecf
Normal file
21
library/server/wsf_html/wsf_html-safe.ecf
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="wsf_html" uuid="6AAAE037-7E66-4F5D-BED0-0042245C26BC" library_target="wsf_html">
|
||||
<target name="wsf_html">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
|
||||
<library name="encoder" location="../../text/encoder/encoder-safe.ecf"/>
|
||||
<library name="uri_template" location="../../text/parser/uri_template/uri_template-safe.ecf"/>
|
||||
<library name="wsf" location="../wsf/wsf-safe.ecf"/>
|
||||
<cluster name="form" location="./form" recursive="true"/>
|
||||
<cluster name="widget" location="./widget" recursive="true"/>
|
||||
<cluster name="css" location="./css" recursive="true"/>
|
||||
<cluster name="api" location="./api" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
21
library/server/wsf_html/wsf_html.ecf
Normal file
21
library/server/wsf_html/wsf_html.ecf
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="wsf_html" uuid="6AAAE037-7E66-4F5D-BED0-0042245C26BC" library_target="wsf_html">
|
||||
<target name="wsf_html">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||
<library name="encoder" location="../../text/encoder/encoder.ecf"/>
|
||||
<library name="uri_template" location="../../text/parser/uri_template/uri_template.ecf"/>
|
||||
<library name="wsf" location="../wsf/wsf.ecf"/>
|
||||
<cluster name="form" location="./form" recursive="true"/>
|
||||
<cluster name="widget" location="./widget" recursive="true"/>
|
||||
<cluster name="css" location="./css" recursive="true"/>
|
||||
<cluster name="api" location="./api" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
Reference in New Issue
Block a user