moved wizard under tools/estudio_wizard
This commit is contained in:
@@ -0,0 +1,319 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
deferred class
|
||||
CONSOLE_WIZARD_APPLICATION
|
||||
|
||||
inherit
|
||||
WIZARD_APPLICATION
|
||||
redefine
|
||||
set_page,
|
||||
on_start,
|
||||
on_finish,
|
||||
on_next,
|
||||
on_refresh,
|
||||
on_back
|
||||
end
|
||||
|
||||
LOCALIZED_PRINTER
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_page (a_page_id: READABLE_STRING_8): CONSOLE_WIZARD_PAGE
|
||||
do
|
||||
create Result.make (a_page_id)
|
||||
end
|
||||
|
||||
set_page (a_page: WIZARD_PAGE)
|
||||
do
|
||||
Precursor (a_page)
|
||||
|
||||
process_page (a_page)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
on_start
|
||||
do
|
||||
Precursor
|
||||
on_navigation
|
||||
end
|
||||
|
||||
on_finish
|
||||
do
|
||||
Precursor
|
||||
end
|
||||
|
||||
on_next
|
||||
do
|
||||
Precursor
|
||||
on_navigation
|
||||
end
|
||||
|
||||
on_refresh
|
||||
do
|
||||
Precursor
|
||||
on_navigation
|
||||
end
|
||||
|
||||
on_back
|
||||
do
|
||||
Precursor
|
||||
on_navigation
|
||||
end
|
||||
|
||||
on_navigation
|
||||
do
|
||||
if attached current_page as pg then
|
||||
if pg = wizard.notfound_page then
|
||||
on_cancel
|
||||
elseif pg = wizard.final_page then
|
||||
on_finish
|
||||
else
|
||||
localized_print ("%N")
|
||||
if attached string_question ("Continue", <<["c", "Continue"], ["r", "Refresh"], ["b", "Back"], ["q", "Cancel"]>>, "c", True) as s then
|
||||
if s.is_case_insensitive_equal_general ("Cancel") then
|
||||
on_cancel
|
||||
elseif s.is_case_insensitive_equal_general ("Refresh") then
|
||||
on_refresh
|
||||
elseif s.is_case_insensitive_equal_general ("Back") then
|
||||
on_back
|
||||
elseif s.is_case_insensitive_equal_general ("Continue") then
|
||||
on_next
|
||||
else
|
||||
on_next
|
||||
end
|
||||
else
|
||||
on_next
|
||||
end
|
||||
end
|
||||
else
|
||||
on_cancel
|
||||
end
|
||||
end
|
||||
|
||||
process_page (a_page: WIZARD_PAGE)
|
||||
do
|
||||
a_page.apply_data
|
||||
localized_print ("%N")
|
||||
|
||||
if attached a_page.title as l_title then
|
||||
localized_print (l_title)
|
||||
localized_print ("%N")
|
||||
localized_print (create {STRING}.make_filled ('=', l_title.count))
|
||||
localized_print ("%N")
|
||||
|
||||
if attached a_page.subtitle as l_subtitle then
|
||||
localized_print (" -- ")
|
||||
localized_print (l_subtitle)
|
||||
localized_print ("%N")
|
||||
end
|
||||
end
|
||||
|
||||
if attached a_page.reports as lst and then not lst.is_empty then
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
localized_print (" : ")
|
||||
if ic.item.type = {WIZARD_PAGE}.error_report_type then
|
||||
localized_print ("Error:")
|
||||
elseif ic.item.type = {WIZARD_PAGE}.warning_report_type then
|
||||
localized_print ("Warning:")
|
||||
else
|
||||
localized_print ("Info:")
|
||||
end
|
||||
localized_print (ic.item.message)
|
||||
localized_print ("%N")
|
||||
end
|
||||
end
|
||||
|
||||
a_page.reset_reports
|
||||
|
||||
across
|
||||
a_page.items as ic
|
||||
loop
|
||||
output_page_item (ic.item)
|
||||
end
|
||||
end
|
||||
|
||||
output_page_item (a_item: WIZARD_PAGE_ITEM)
|
||||
local
|
||||
b: BOOLEAN
|
||||
s: detachable READABLE_STRING_32
|
||||
do
|
||||
if attached {WIZARD_PAGE_TEXT_ITEM} a_item as txt then
|
||||
localized_print (txt.text)
|
||||
localized_print ("%N")
|
||||
elseif attached {WIZARD_QUESTION} a_item then
|
||||
localized_print (" -> ")
|
||||
if attached {WIZARD_BOOLEAN_QUESTION} a_item as l_bool_question then
|
||||
l_bool_question.set_value (boolean_question (l_bool_question.title, <<["y", True], ["n", False]>>, l_bool_question.value))
|
||||
elseif attached {WIZARD_INTEGER_QUESTION} a_item as l_integer_question then
|
||||
l_integer_question.set_text (string_question (l_integer_question.title, Void, l_integer_question.text, False))
|
||||
elseif attached {WIZARD_STRING_QUESTION} a_item as l_string_question then
|
||||
l_string_question.set_value (string_question (l_string_question.title, Void, l_string_question.text, False))
|
||||
elseif attached {WIZARD_DIRECTORY_QUESTION} a_item as l_directory_question then
|
||||
l_directory_question.set_text (string_question (l_directory_question.title, Void, l_directory_question.text, False))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
boolean_question (m: READABLE_STRING_GENERAL; a_options: detachable ITERABLE [TUPLE [name: READABLE_STRING_8; value: BOOLEAN]]; a_default: BOOLEAN): BOOLEAN
|
||||
local
|
||||
s: STRING_32
|
||||
def: detachable STRING_32
|
||||
l_answered: BOOLEAN
|
||||
l_options: detachable ITERABLE [TUPLE [name: READABLE_STRING_8; value: BOOLEAN]]
|
||||
do
|
||||
if l_options = Void then
|
||||
l_options := a_options
|
||||
end
|
||||
if l_options = Void then
|
||||
l_options := <<["y", True], ["Y", True]>>
|
||||
end
|
||||
across
|
||||
l_options as ic
|
||||
until
|
||||
def /= Void
|
||||
loop
|
||||
if a_default = ic.item.value then
|
||||
def := ic.item.name
|
||||
end
|
||||
end
|
||||
|
||||
from
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
localized_print (m)
|
||||
localized_print (" ")
|
||||
|
||||
create s.make_empty
|
||||
across
|
||||
l_options as ic
|
||||
loop
|
||||
if not s.is_empty then
|
||||
s.append_character (',')
|
||||
end
|
||||
s.append_string_general (ic.item.name)
|
||||
end
|
||||
localized_print (" (")
|
||||
localized_print (s)
|
||||
localized_print (") ")
|
||||
|
||||
if def /= Void then
|
||||
localized_print ("[default=")
|
||||
localized_print (def)
|
||||
localized_print ("] ")
|
||||
end
|
||||
|
||||
localized_print ("?")
|
||||
io.read_line
|
||||
s := io.last_string
|
||||
s.left_adjust
|
||||
s.right_adjust
|
||||
if s.is_empty and def /= Void then
|
||||
create s.make_from_string_general (def)
|
||||
end
|
||||
if not s.is_empty then
|
||||
across
|
||||
l_options as o
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
if o.item.name.same_string (s) then
|
||||
l_answered := True
|
||||
Result := o.item.value
|
||||
end
|
||||
end
|
||||
if not l_answered then
|
||||
l_answered := True
|
||||
Result := False
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
string_question (m: READABLE_STRING_GENERAL; a_options: detachable ITERABLE [TUPLE [name: READABLE_STRING_8; value: detachable READABLE_STRING_8]]; def: detachable READABLE_STRING_GENERAL; a_required_valid_option: BOOLEAN): detachable STRING_32
|
||||
local
|
||||
s: STRING_32
|
||||
l_answered: BOOLEAN
|
||||
do
|
||||
from
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
localized_print (m)
|
||||
localized_print (" ")
|
||||
create s.make_empty
|
||||
if a_options /= Void then
|
||||
across
|
||||
a_options as ic
|
||||
loop
|
||||
if not s.is_empty then
|
||||
s.append_character (',')
|
||||
end
|
||||
s.append_string_general (ic.item.name)
|
||||
if attached ic.item.value as v then
|
||||
s.append_character ('=')
|
||||
s.append_string_general (v)
|
||||
end
|
||||
end
|
||||
localized_print ("(")
|
||||
localized_print (s)
|
||||
localized_print (") ")
|
||||
end
|
||||
if def /= Void then
|
||||
localized_print ("[default=")
|
||||
localized_print (def)
|
||||
localized_print ("] ")
|
||||
end
|
||||
|
||||
localized_print ("?")
|
||||
io.read_line
|
||||
create s.make_from_string_general (io.last_string)
|
||||
s.left_adjust
|
||||
s.right_adjust
|
||||
if s.is_empty and def /= Void then
|
||||
create s.make_from_string_general (def)
|
||||
end
|
||||
if not s.is_empty then
|
||||
if a_options /= Void then
|
||||
across
|
||||
a_options as o
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
if o.item.name.same_string (s) then
|
||||
l_answered := True
|
||||
if attached o.item.value as l_value then
|
||||
create Result.make_from_string_general (l_value)
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not l_answered then
|
||||
l_answered := True
|
||||
Result := s
|
||||
if
|
||||
a_required_valid_option and then
|
||||
a_options /= Void and then
|
||||
not across a_options as o some attached o.item.value as v and then Result.same_string (v) end
|
||||
then
|
||||
l_answered := False
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CONSOLE_WIZARD_PAGE
|
||||
|
||||
inherit
|
||||
WIZARD_PAGE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {WIZARD, WIZARD_ENGINE, WIZARD_PAGE} -- Implementation
|
||||
|
||||
reuse
|
||||
do
|
||||
-- across
|
||||
-- items as ic
|
||||
-- loop
|
||||
-- unparent (ic.item)
|
||||
-- end
|
||||
end
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
new_string_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): CONSOLE_WIZARD_STRING_QUESTION
|
||||
do
|
||||
create Result.make (a_field_id, a_prompt, a_description)
|
||||
end
|
||||
|
||||
new_directory_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): CONSOLE_WIZARD_DIRECTORY_QUESTION
|
||||
do
|
||||
create Result.make (a_field_id, a_prompt, a_description)
|
||||
end
|
||||
|
||||
new_boolean_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): CONSOLE_WIZARD_BOOLEAN_QUESTION
|
||||
do
|
||||
create Result.make (a_field_id, a_prompt, a_description)
|
||||
end
|
||||
|
||||
new_integer_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): CONSOLE_WIZARD_INTEGER_QUESTION
|
||||
do
|
||||
create Result.make (a_field_id, a_prompt, a_description)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_BOOLEAN_QUESTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CONSOLE_WIZARD_BOOLEAN_QUESTION
|
||||
|
||||
inherit
|
||||
WIZARD_BOOLEAN_QUESTION
|
||||
undefine
|
||||
make
|
||||
end
|
||||
|
||||
CONSOLE_WIZARD_QUESTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
text: {STRING_32}
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
text: STRING_32
|
||||
do
|
||||
if value then
|
||||
Result := "yes"
|
||||
else
|
||||
Result := "no"
|
||||
end
|
||||
end
|
||||
|
||||
value: BOOLEAN
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (t: READABLE_STRING_GENERAL)
|
||||
do
|
||||
create title.make_from_string_general (t)
|
||||
end
|
||||
|
||||
set_text (t: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if t = Void then
|
||||
set_value (False)
|
||||
else
|
||||
set_value (t.is_case_insensitive_equal ("yes"))
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: BOOLEAN)
|
||||
do
|
||||
value := v
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_DIRECTORY_QUESTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CONSOLE_WIZARD_DIRECTORY_QUESTION
|
||||
|
||||
inherit
|
||||
WIZARD_DIRECTORY_QUESTION
|
||||
undefine
|
||||
make
|
||||
end
|
||||
|
||||
CONSOLE_WIZARD_QUESTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
text: {STRING_32}
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
text: STRING_32
|
||||
do
|
||||
if attached value as v then
|
||||
Result := v.name
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
value: detachable PATH
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (t: READABLE_STRING_GENERAL)
|
||||
do
|
||||
create title.make_from_string_general (t)
|
||||
end
|
||||
|
||||
set_text (t: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if t = Void then
|
||||
set_value (Void)
|
||||
else
|
||||
set_value (create {PATH}.make_from_string (t))
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable PATH)
|
||||
do
|
||||
value := v
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_INPUT_FIELD}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CONSOLE_WIZARD_INPUT_FIELD
|
||||
|
||||
inherit
|
||||
WIZARD_INPUT_FIELD
|
||||
|
||||
WIZARD_PAGE_ITEM
|
||||
|
||||
feature -- Access
|
||||
|
||||
item_id: detachable READABLE_STRING_8
|
||||
-- Optional id to identify related page item.
|
||||
do
|
||||
Result := id
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
data: detachable ANY
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_data (d: like data)
|
||||
do
|
||||
data := d
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,58 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_INTEGER_QUESTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CONSOLE_WIZARD_INTEGER_QUESTION
|
||||
|
||||
inherit
|
||||
WIZARD_INTEGER_QUESTION
|
||||
undefine
|
||||
make
|
||||
end
|
||||
|
||||
CONSOLE_WIZARD_QUESTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
text: {STRING_32}
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
text: STRING_32
|
||||
do
|
||||
create Result.make_empty
|
||||
Result.append_integer (value)
|
||||
end
|
||||
|
||||
value: INTEGER
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (t: READABLE_STRING_GENERAL)
|
||||
do
|
||||
create title.make_from_string_general (t)
|
||||
end
|
||||
|
||||
set_text (t: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if t = Void then
|
||||
set_value (0)
|
||||
elseif t.is_integer then
|
||||
set_value (t.to_integer)
|
||||
else
|
||||
-- Ignore !
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: INTEGER)
|
||||
do
|
||||
value := v
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_QUESTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CONSOLE_WIZARD_QUESTION
|
||||
|
||||
inherit
|
||||
WIZARD_QUESTION
|
||||
redefine
|
||||
make
|
||||
end
|
||||
|
||||
CONSOLE_WIZARD_INPUT_FIELD
|
||||
rename
|
||||
make as make_field
|
||||
undefine
|
||||
make_field
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_id: like id; a_title: READABLE_STRING_GENERAL; a_optional_description: detachable READABLE_STRING_GENERAL)
|
||||
-- Create field identified by `a_id', with title `a_title'
|
||||
-- and optional description `a_optional_description'.
|
||||
do
|
||||
Precursor (a_id, a_title, a_optional_description)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "Summary description for {CONSOLE_WIZARD_STRING_QUESTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CONSOLE_WIZARD_STRING_QUESTION
|
||||
|
||||
inherit
|
||||
WIZARD_STRING_QUESTION
|
||||
undefine
|
||||
make
|
||||
end
|
||||
|
||||
CONSOLE_WIZARD_QUESTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
text: {STRING_32}
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
text: STRING_32
|
||||
do
|
||||
if attached value as v then
|
||||
Result := v
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
value: detachable STRING_32
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (t: READABLE_STRING_GENERAL)
|
||||
do
|
||||
create title.make_from_string_general (t)
|
||||
end
|
||||
|
||||
set_text (t: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if t = Void then
|
||||
set_value (Void)
|
||||
else
|
||||
set_value (create {STRING_32}.make_from_string_general (t))
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if v = Void then
|
||||
value := Void
|
||||
else
|
||||
create value.make_from_string_general (v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user