moved wizard under tools/estudio_wizard

This commit is contained in:
2015-03-05 16:01:45 +01:00
parent b26504b4a1
commit f81e5251e8
64 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
note
description: "Summary description for {WIZARD_BOOLEAN_QUESTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_BOOLEAN_QUESTION
inherit
WIZARD_QUESTION
feature -- Access
value: BOOLEAN
deferred
end
feature -- Element change
set_value (v: like value)
deferred
end
end

View File

@@ -0,0 +1,26 @@
note
description: "Summary description for {WIZARD_DIRECTORY_QUESTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_DIRECTORY_QUESTION
inherit
WIZARD_QUESTION
feature -- Access
value: detachable PATH
deferred
end
feature -- Element change
set_value (v: detachable PATH)
deferred
end
end

View File

@@ -0,0 +1,61 @@
note
description: "Summary description for {WIZARD_INPUT_FIELD}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_INPUT_FIELD
inherit
WIZARD_PAGE_ITEM
feature {NONE} -- Initialization
make (a_id: READABLE_STRING_8)
-- Create field identified by `a_id'.
do
id := a_id
end
feature -- Access
id: READABLE_STRING_8
validation: detachable PROCEDURE [ANY, TUPLE [WIZARD_PAGE]]
feature -- Validation
validate (a_page: WIZARD_PAGE)
do
if attached validation as act then
act.call ([a_page])
end
end
feature -- Conversion
data: detachable ANY
deferred
end
text: STRING_32
deferred
end
feature -- Element change
set_text (t: detachable READABLE_STRING_GENERAL)
deferred
end
set_data (d: like data)
deferred
end
set_validation (act: like validation)
do
validation := act
end
end

View File

@@ -0,0 +1,25 @@
note
description: "Summary description for {WIZARD_INTEGER_QUESTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_INTEGER_QUESTION
inherit
WIZARD_QUESTION
feature -- Access
value: INTEGER
deferred
end
feature -- Element change
set_value (v: like value)
deferred
end
end

View File

@@ -0,0 +1,42 @@
note
description: "Summary description for {WIZARD_PAGE_SECTION_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_PAGE_SECTION_ITEM
inherit
WIZARD_PAGE_ITEM
create
make
feature {NONE} -- Initialization
make (a_text: READABLE_STRING_GENERAL)
do
set_text (a_text)
end
feature -- Access
text: IMMUTABLE_STRING_32
item_id: detachable READABLE_STRING_8
-- Optional id to identify related page item.
feature -- Element change
set_text (a_text: READABLE_STRING_GENERAL)
do
create text.make_from_string_general (a_text)
end
set_item_id (a_id: like item_id)
do
item_id := a_id
end
end

View File

@@ -0,0 +1,49 @@
note
description: "Summary description for {WIZARD_PAGE_TEXT_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_PAGE_TEXT_ITEM
inherit
WIZARD_PAGE_ITEM
create
make
feature {NONE} -- Initialization
make (a_text: READABLE_STRING_GENERAL)
do
set_text (a_text)
end
feature -- Access
is_fixed_size: BOOLEAN
text: IMMUTABLE_STRING_32
item_id: detachable READABLE_STRING_8
-- Optional id to identify related page item.
feature -- Element change
set_text (a_text: READABLE_STRING_GENERAL)
do
create text.make_from_string_general (a_text)
end
set_is_fixed_size (v: BOOLEAN)
do
is_fixed_size := v
end
set_item_id (a_id: like item_id)
do
item_id := a_id
end
end

View File

@@ -0,0 +1,39 @@
note
description: "Summary description for {WIZARD_QUESTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_QUESTION
inherit
WIZARD_INPUT_FIELD
rename
make as 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
create title.make_from_string_general (a_title)
if a_optional_description /= Void then
create description.make_from_string_general (a_optional_description)
else
description := Void
end
make_field (a_id)
end
feature -- Access
title: IMMUTABLE_STRING_32
-- Title associated with input field.
description: detachable IMMUTABLE_STRING_32
-- Optional description.
end

View File

@@ -0,0 +1,25 @@
note
description: "Summary description for {WIZARD_STRING_QUESTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_STRING_QUESTION
inherit
WIZARD_QUESTION
feature -- Access
value: detachable STRING_32
deferred
end
feature -- Element change
set_value (v: detachable READABLE_STRING_GENERAL)
deferred
end
end

View File

@@ -0,0 +1,87 @@
note
description: "Summary description for {WIZARD_DATA}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_DATA
inherit
TABLE_ITERABLE [WIZARD_PAGE_DATA, READABLE_STRING_GENERAL]
create
make
feature {NONE} -- Initialization
make (nb: INTEGER)
do
create page_data_items.make_caseless (nb)
end
feature -- Access
page_data (k: READABLE_STRING_GENERAL): detachable WIZARD_PAGE_DATA
do
Result := page_data_items.item (k)
end
item (a_nested_identifier: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- Data related to `a_nested_identifier'
-- following convention "$page_id:$field_id"
local
p: INTEGER
pid,fid: READABLE_STRING_GENERAL
s: STRING_32
do
p := a_nested_identifier.index_of (':', 1)
if p > 0 then
pid := a_nested_identifier.head (p - 1)
fid := a_nested_identifier.substring (p + 1, a_nested_identifier.count)
if attached page_data (pid) as d then
Result := d.item (fid)
end
else
-- Search in all records
across
page_data_items as ic
until
Result /= Void
loop
create s.make_from_string_general (ic.key)
s.append_character (':')
s.append_string_general (a_nested_identifier)
Result := item (s)
end
end
end
boolean_item (a_nested_identifier: READABLE_STRING_GENERAL): BOOLEAN
do
if attached item (a_nested_identifier) as v then
Result := v.is_case_insensitive_equal_general ("yes") or
v.is_case_insensitive_equal_general ("true") or
v.is_case_insensitive_equal_general ("on")
end
end
new_cursor: HASH_TABLE_ITERATION_CURSOR [WIZARD_PAGE_DATA, READABLE_STRING_GENERAL]
-- <Precursor>
do
Result := page_data_items.new_cursor
end
feature -- Change
record_page_data (v: WIZARD_PAGE_DATA; k: READABLE_STRING_GENERAL)
do
page_data_items.force (v, k)
end
feature {NONE} -- Implementation
page_data_items: STRING_TABLE [WIZARD_PAGE_DATA]
end

View File

@@ -0,0 +1,303 @@
note
description: "Summary description for {WIZARD_PAGE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_PAGE
inherit
DEBUG_OUTPUT
feature {NONE} -- Initialization
make (a_id: READABLE_STRING_8)
do
create items.make (0)
create data.make (a_id)
create fields.make_caseless (0)
create page_id.make_from_string (a_id)
create update_actions
end
feature -- Access
page_id: IMMUTABLE_STRING_8
title: detachable IMMUTABLE_STRING_32
subtitle: detachable IMMUTABLE_STRING_32
previous_page: detachable WIZARD_PAGE
validation: detachable PROCEDURE [ANY, TUPLE [WIZARD_PAGE]]
update_actions: ACTION_SEQUENCE [TUPLE]
feature -- Access: data
items: ARRAYED_LIST [WIZARD_PAGE_ITEM]
fields: STRING_TABLE [WIZARD_INPUT_FIELD]
data: WIZARD_PAGE_DATA
field_value alias "[]" (a_field_id: READABLE_STRING_8): detachable READABLE_STRING_32
-- Data related to existing field `a_field_id'.
require
associated_field_exists: fields.has (a_field_id)
do
Result := data.item (a_field_id)
end
boolean_field_value alias "&" (a_field_id: READABLE_STRING_8): BOOLEAN
-- Boolean data related to existing field `a_field_id'.
require
associated_field_exists: fields.has (a_field_id)
do
Result := data.boolean_item (a_field_id)
end
feature -- Status report
has_header: BOOLEAN
do
Result := title /= Void or subtitle /= Void or (attached reports as lst and then not lst.is_empty)
end
has_reports: BOOLEAN
do
Result := attached reports as lst and then not lst.is_empty
end
has_error: BOOLEAN
do
Result := attached reports as lst and then across lst as ic some ic.item.type = error_report_type end
end
has_warning: BOOLEAN
do
Result := attached reports as lst and then across lst as ic some ic.item.type = warning_report_type end
end
feature -- Debug report
debug_output: STRING_32
-- String that should be displayed in debugger to represent `Current'.
do
create Result.make_from_string_general (page_id)
end
feature -- Element change
set_data (a_data: like data)
do
data := a_data
apply_data
end
set_title (t: detachable READABLE_STRING_GENERAL)
do
if t = Void then
title := Void
else
create title.make_from_string_general (t)
end
end
set_subtitle (t: detachable READABLE_STRING_GENERAL)
do
if t = Void then
subtitle := Void
else
create subtitle.make_from_string_general (t)
end
end
set_previous_page (a_prev: detachable WIZARD_PAGE)
do
previous_page := a_prev
end
feature -- Element change
set_validation (act: like validation)
do
validation := act
end
feature -- UI fields building
extend (a_item: WIZARD_PAGE_ITEM)
do
items.extend (a_item)
if attached {WIZARD_INPUT_FIELD} a_item as f then
fields.force (f, f.id)
end
end
feature -- UI building
frozen add_section_text (a_text: READABLE_STRING_GENERAL)
do
extend (new_section_item (a_text))
end
frozen add_text (a_text: READABLE_STRING_GENERAL)
do
extend (new_text_item (a_text))
end
frozen add_fixed_size_text (a_text: READABLE_STRING_GENERAL)
do
extend (new_fixed_size_text_item (a_text))
end
feature -- Helpers
frozen add_string_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL)
do
extend (new_string_question (a_prompt, a_field_id, a_description))
end
frozen add_directory_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL)
do
extend (new_directory_question (a_prompt, a_field_id, a_description))
end
frozen add_boolean_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL)
do
extend (new_boolean_question (a_prompt, a_field_id, a_description))
end
frozen add_integer_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL)
do
extend (new_integer_question (a_prompt, a_field_id, a_description))
end
feature -- Helper Factory
new_section_item (a_text: READABLE_STRING_GENERAL): WIZARD_PAGE_SECTION_ITEM
do
create Result.make (a_text)
end
new_text_item (a_text: READABLE_STRING_GENERAL): WIZARD_PAGE_TEXT_ITEM
do
create Result.make (a_text)
end
new_fixed_size_text_item (a_text: READABLE_STRING_GENERAL): WIZARD_PAGE_TEXT_ITEM
do
create Result.make (a_text)
Result.set_is_fixed_size (True)
end
new_string_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): WIZARD_STRING_QUESTION
deferred
end
new_directory_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): WIZARD_DIRECTORY_QUESTION
deferred
end
new_boolean_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): WIZARD_BOOLEAN_QUESTION
deferred
end
new_integer_question (a_prompt: READABLE_STRING_GENERAL; a_field_id: READABLE_STRING_8; a_description: detachable READABLE_STRING_GENERAL): WIZARD_INTEGER_QUESTION
deferred
end
feature -- Basic operations
validate
-- Validate input field value.
local
l_field: WIZARD_INPUT_FIELD
do
reset_reports
across
fields as ic
loop
l_field := ic.item
l_field.validate (Current)
data.force (l_field.text, l_field.id)
end
if attached validation as act then
act.call ([Current])
end
end
feature {WIZARD, WIZARD_APPLICATION, WIZARD_PAGE} -- Implementation
reuse
deferred
end
apply_data
local
l_field: WIZARD_INPUT_FIELD
do
update_actions.call (Void)
across
fields as ic
loop
l_field := ic.item
if attached data.item (l_field.id) as v then
l_field.set_text (v)
end
end
end
feature -- Reporting
reset_reports
do
reports := Void
end
reports: detachable ARRAYED_LIST [TUPLE [message: IMMUTABLE_STRING_32; type: INTEGER]]
report (m: READABLE_STRING_GENERAL; a_type: INTEGER)
local
lst: like reports
l_message: IMMUTABLE_STRING_32
do
lst := reports
if lst = Void then
create lst.make (1)
reports := lst
end
if attached {IMMUTABLE_STRING_32} m as imm32 then
l_message := imm32
else
create l_message.make_from_string_general (m)
end
lst.force ([l_message, a_type])
end
report_information (m: READABLE_STRING_GENERAL)
do
report (m, information_report_type)
end
report_warning (m: READABLE_STRING_GENERAL)
do
report (m, warning_report_type)
end
report_error (m: READABLE_STRING_GENERAL)
do
report (m, error_report_type)
end
information_report_type: INTEGER = 1
warning_report_type: INTEGER = 2
error_report_type: INTEGER = 3
end

View File

@@ -0,0 +1,91 @@
note
description: "Summary description for {WIZARD_PAGE_DATA}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_PAGE_DATA
inherit
TABLE_ITERABLE [READABLE_STRING_32, READABLE_STRING_GENERAL]
DEBUG_OUTPUT
create
make
feature {NONE} -- Initialization
make (a_page_id: READABLE_STRING_8)
do
page_id := a_page_id
create items.make_caseless (0)
end
feature -- Access
page_id: READABLE_STRING_8
-- Associated page id.
item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
do
Result := items.item (k)
end
boolean_item (k: READABLE_STRING_GENERAL): BOOLEAN
do
if attached item (k) as v then
Result := v.is_case_insensitive_equal_general ("yes") or
v.is_case_insensitive_equal_general ("true") or
v.is_case_insensitive_equal_general ("on")
end
end
items: STRING_TABLE [READABLE_STRING_32]
count: INTEGER
do
Result := items.count
end
new_cursor: HASH_TABLE_ITERATION_CURSOR [READABLE_STRING_32, READABLE_STRING_GENERAL]
-- <Precursor>
do
Result := items.new_cursor
end
feature -- Status report
has (k: READABLE_STRING_GENERAL): BOOLEAN
-- Has item indexed by `k'?
do
Result := items.has (k)
end
debug_output: STRING_32
-- String that should be displayed in debugger to represent `Current'.
do
create Result.make_from_string_general (page_id)
Result.append (" count=")
Result.append_integer (count)
end
feature -- Change
put (v: READABLE_STRING_32; k: READABLE_STRING_GENERAL)
do
items.put (v, k)
end
force (v: READABLE_STRING_32; k: READABLE_STRING_GENERAL)
do
items.force (v, k)
end
remove (k: READABLE_STRING_GENERAL)
do
items.remove (k)
end
end

View File

@@ -0,0 +1,17 @@
note
description: "Summary description for {WIZARD_PAGE_ITEM}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_PAGE_ITEM
feature -- Access
item_id: detachable READABLE_STRING_8
-- Optional id to identify related page item.
deferred
end
end

View File

@@ -0,0 +1,20 @@
note
description: "Summary description for {WIZARD_FAILED_RESPONSE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_FAILED_RESPONSE
inherit
WIZARD_RESPONSE
feature -- Output
send (f: FILE)
do
f.put_string ("Success=%"no%"%N")
end
end

View File

@@ -0,0 +1,16 @@
note
description: "Summary description for {WIZARD_RESPONSE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_RESPONSE
feature -- Output
send (f: FILE)
deferred
end
end

View File

@@ -0,0 +1,68 @@
note
description: "Summary description for {WIZARD_SUCCEED_RESPONSE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_SUCCEED_RESPONSE
inherit
WIZARD_RESPONSE
create
make
feature {NONE} -- Initialization
make (a_conf_fn: like configuration_file_name; a_dir: like directory_name)
do
configuration_file_name := a_conf_fn
directory_name := a_dir
end
feature -- Access
configuration_file_name: PATH
directory_name: PATH
compile_enabled: BOOLEAN
freeze_required: BOOLEAN
feature -- Element Change
set_compile_enabled (b: BOOLEAN)
do
compile_enabled := b
end
set_freeze_required (b: BOOLEAN)
do
freeze_required := b
end
feature -- Constants
melt_compilation: INTEGER = 0
freeze_compilation: INTEGER = 1
feature -- Output
send (f: FILE)
do
f.put_string ("Success=%"yes%"%N")
f.put_string ("Ace=%"" + configuration_file_name.utf_8_name + "%"%N")
f.put_string ("Directory=%"" + directory_name.utf_8_name + "%"%N")
if compile_enabled then
f.put_string ("Compilation=%"yes%"%N")
else
f.put_string ("Compilation=%"no%"%N")
end
if freeze_required then
f.put_string ("Compilation_type=%"freeze%"%N")
elseif compile_enabled then
f.put_string ("Compilation_type=%"melt%"%N")
end
end
end

View File

@@ -0,0 +1,115 @@
note
description: "Summary description for {WIZARD}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD
feature {NONE} -- Initialization
make (app: WIZARD_APPLICATION)
do
application := app
end
feature {WIZARD_GENERATOR} -- Access
application: WIZARD_APPLICATION
feature -- Access
title: STRING_32
deferred
end
feature -- Factory
wizard_generator : WIZARD_GENERATOR
deferred
end
new_page (a_page_id: READABLE_STRING_8): WIZARD_PAGE
do
Result := application.new_page (a_page_id)
end
next_page (a_current_page: detachable WIZARD_PAGE): WIZARD_PAGE
deferred
end
notfound_page: WIZARD_PAGE
once
Result := new_page ("notfound")
Result.set_title ("Page Not Found")
Result.set_subtitle ("Internal error in the wizard state machine.")
-- if Result.previous_page /= Void then
-- Result.set_back_action (agent on_back)
-- end
-- Result.set_cancel_action (agent on_cancel)
end
feature -- Pages
first_page: WIZARD_PAGE
deferred
end
final_page: WIZARD_PAGE
deferred
end
feature -- Events
on_back
do
application.on_back
end
on_cancel
do
application.on_cancel
end
on_next
do
application.on_next
end
on_finish
do
application.on_finish
end
feature {NONE} -- Initialization
formatted_title_value_items (lst: ITERABLE [TUPLE [title: READABLE_STRING_GENERAL; value: READABLE_STRING_GENERAL]]): STRING_32
local
t: STRING_32
m: INTEGER
do
across
lst as ic
loop
m := m.max (ic.item.title.count)
end
m := m + 1
create Result.make_empty
across
lst as ic
loop
create t.make_from_string_general (ic.item.title)
t.append (create {STRING_32}.make_filled (' ', m - t.count))
t.append_character (':')
t.append_character (' ')
t.append_string_general (ic.item.value)
t.append_character ('%N')
Result.append (t)
end
end
end

View File

@@ -0,0 +1,268 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
deferred class
WIZARD_APPLICATION
inherit
ARGUMENTS
SHARED_EXECUTION_ENVIRONMENT
feature {NONE} -- Initialization
initialize
-- Initialize `Current'.
local
i,n: INTEGER
s: READABLE_STRING_8
wizard_directory_name: detachable PATH
callback_file_name: detachable PATH
do
-- Usage
n := argument_count
if n > 0 then
from
i := 1
until
i > n
loop
s := argument (i)
if s.same_string ("-callback") or s.same_string ("--callback") then
i := i + 1
if i <= n then
create callback_file_name.make_from_string (argument (i))
end
elseif wizard_directory_name = Void then
create wizard_directory_name.make_from_string (s)
else
debug
io.error.put_string ("Ignoring argument %"" + s + "%"%N")
end
end
i := i + 1
end
end
if wizard_directory_name = Void then
create layout.make (execution_environment.current_working_path, execution_environment.current_working_path.extended ("wizard.cb"))
display_usage (io.error)
quit ("ERROR: Missing wizard directory name.")
elseif callback_file_name = Void then
create layout.make (execution_environment.current_working_path, execution_environment.current_working_path.extended ("wizard.cb"))
display_usage (io.error)
quit ("ERROR: Missing Eiffel Studio callback file name.")
else
create layout.make (wizard_directory_name, callback_file_name)
end
-- Values
create data.make (10)
create variables.make (5)
create page_history.make (10)
-- Wizard
wizard := new_wizard
end
new_wizard: WIZARD
-- Build new wizard.
-- To be redefined.
deferred
end
wizard: like new_wizard
-- Associated Wizard.
feature -- Helpers
display_usage (f: FILE)
do
f.put_string ("Usage: wizard {dirname} -callback {filename}%N")
f.put_string (" -callback filename: file used to communicate back with Eiffel Studio%N")
f.put_string (" dirname: folder containing the wizard resources, pixmaps, ...%N")
end
quit (a_failure_message: detachable READABLE_STRING_8)
do
if a_failure_message /= Void then
io.error.put_string (a_failure_message)
end
send_response (create {WIZARD_FAILED_RESPONSE})
die (-1)
ensure
False -- never reached
end
die (code: INTEGER)
do
(create {EXCEPTIONS}).die (code)
end
available_directory_path (a_name: READABLE_STRING_GENERAL; a_folder: PATH): PATH
local
ut: FILE_UTILITIES
ok: BOOLEAN
p: PATH
l_name: STRING_32
l_ext: detachable READABLE_STRING_32
i: INTEGER
do
from
Result := a_folder.extended (a_name)
ok := not ut.directory_path_exists (Result)
p := Result
if not ok then
if attached p.extension as ext then
l_ext := ext
l_name := p.name
l_name.remove_head (ext.count + 1)
create p.make_from_string (l_name)
end
end
until
ok
loop
i := i + 1
Result := p.appended ("_" + i.out)
if l_ext /= Void then
Result := Result.appended_with_extension (l_ext)
end
ok := not ut.directory_path_exists (Result)
end
end
feature -- Access
variables: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
layout: WIZARD_LAYOUT
data: WIZARD_DATA
feature -- State
current_page: detachable WIZARD_PAGE
do
if not page_history.is_empty then
Result := page_history.item
end
end
next_page (a_current_page: detachable WIZARD_PAGE): WIZARD_PAGE
do
Result := wizard.next_page (a_current_page)
if Result /= a_current_page then
Result.set_previous_page (a_current_page)
end
end
page_history: ARRAYED_STACK [WIZARD_PAGE]
feature -- Factory
new_page (a_page_id: READABLE_STRING_8): WIZARD_PAGE
deferred
end
feature -- Events
set_page (a_page: WIZARD_PAGE)
do
a_page.reuse
if attached data.page_data (a_page.page_id) as l_page_data then
a_page.set_data (l_page_data)
end
page_history.force (a_page)
ensure
current_page_set: current_page = a_page
end
on_start
do
set_page (next_page (Void))
end
on_refresh
do
if attached current_page as pg then
pg.validate
data.record_page_data (pg.data, pg.page_id)
set_page (pg)
else
check refresh_expected: False end
end
end
on_back
do
if
attached current_page as pg and then
attached pg.previous_page as l_prev
then
pg.validate
data.record_page_data (pg.data, pg.page_id)
page_history.remove
page_history.remove
set_page (l_prev)
end
end
on_next
do
if attached current_page as pg then
pg.validate
if pg.has_error then
on_refresh
else
data.record_page_data (pg.data, pg.page_id)
set_page (next_page (pg))
end
else
set_page (next_page (Void))
end
end
on_cancel
do
quit (Void) --"Cancelled")
end
on_generate
do
wizard.wizard_generator.execute (data)
end
on_finish
do
if attached current_page as pg then
if pg.has_error then
on_refresh
else
on_generate
end
else
on_refresh
end
end
feature -- Response
send_response (res: WIZARD_RESPONSE)
local
f: RAW_FILE
do
create f.make_with_path (layout.callback_file_location)
if not f.exists or else f.is_writable then
f.open_write
res.send (f)
f.close
else
die (-1)
end
end
end

View File

@@ -0,0 +1,235 @@
note
description: "Summary description for {WIZARD_GENERATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WIZARD_GENERATOR
feature {NONE} -- Initialization
make (a_wizard: WIZARD)
do
wizard := a_wizard
initialize
end
initialize
do
create variables.make_caseless (0)
end
feature -- Access
wizard: WIZARD
application: WIZARD_APPLICATION
do
Result := wizard.application
end
feature -- Access
variables: STRING_TABLE [READABLE_STRING_8]
-- Variables used for template and file name resolved string.
--| i.e to expand ${varname} in file name or file content.
--| could be used for other purpose.
feature -- Execution
execute (a_collection: WIZARD_DATA)
deferred
end
feature -- Response
send_response (res: WIZARD_RESPONSE)
do
application.send_response (res)
end
feature -- Factory
new_uuid: STRING_8
local
gen: UUID_GENERATOR
do
create gen
Result := gen.generate_uuid.out
end
feature -- Operations
copy_file (a_src, a_target: PATH)
local
f,t: RAW_FILE
do
create f.make_with_path (a_src)
if f.exists and f.is_readable then
create t.make_with_path (a_target)
if not t.exists or else t.is_writable then
f.open_read
t.open_write
f.copy_to (t)
t.close
f.close
end
end
end
feature -- Resources
copy_resource (a_res: READABLE_STRING_8; a_target: PATH)
do
copy_file (application.layout.resource_location (a_res), a_target)
end
copy_resource_template (a_res: READABLE_STRING_GENERAL; a_target: PATH)
do
copy_template (application.layout.resource_location (a_res), a_target)
end
feature -- Templates
is_template_file (f: PATH): BOOLEAN
-- Is file at location `p' potentially a template?
deferred
end
recursive_copy_templates (a_src: PATH; a_target: PATH)
local
d,td, subdir: DIRECTORY
p, ip, tp: PATH
do
create d.make_with_path (a_src)
if d.exists and then d.is_readable then
create td.make_with_path (a_target)
td.recursive_create_dir
across
d.entries as ic
loop
p := ic.item
if p.is_parent_symbol or p.is_current_symbol then
else
ip := a_src.extended_path (p)
create subdir.make_with_path (ip)
tp := a_target.extended_path (resolved_path_name (p))
if subdir.exists then
recursive_copy_templates (ip, tp)
else
if is_template_file (ip) then
copy_template (ip, tp)
else
copy_file (ip, tp)
end
end
end
end
end
end
copy_template (a_src: PATH; a_target: PATH)
require
a_src_is_a_template_file: is_template_file (a_src)
local
f,t: PLAIN_TEXT_FILE
line: READABLE_STRING_8
do
create f.make_with_path (a_src)
if f.exists and f.is_readable then
create t.make_with_path (a_target)
if not t.exists or else t.is_writable then
f.open_read
t.create_read_write
from
f.read_line
until
f.exhausted
loop
line := f.last_string
t.put_string (resolved_string_8 (line))
t.put_new_line
f.read_line
end
t.close
f.close
end
end
end
feature -- Resolvers
resolved_string_8 (a_text: READABLE_STRING_8): READABLE_STRING_8
local
s: detachable STRING_8
do
create s.make (a_text.count)
append_resolved_string_to (a_text, s)
Result := s
end
append_resolved_string_to (s: READABLE_STRING_GENERAL; a_output: STRING_GENERAL)
-- Resolved name for `a_path'.
local
i,n,p,q: INTEGER
k: READABLE_STRING_GENERAL
do
from
i := 1
n := s.count
q := 0
until
i > n
loop
p := s.substring_index ("${", i)
if p > 0 and (p > 1 implies s [p - 1] /= '$') then -- not escaped
if p > i then
a_output.append (s.substring (i, p - 1))
end
i := p
q := s.index_of ('}', i + 2)
if q > 0 then
k := s.substring (p + 2, q - 1)
if attached variables.item (k) as v then
a_output.append (v.as_lower)
else
a_output.append (s.substring (p, q))
end
i := q + 1
else
a_output.append (s.substring (i, n))
i := n + 1
end
else
a_output.append (s.substring (i, n))
i := n + 1
end
end
end
resolved_string (s: READABLE_STRING_32): READABLE_STRING_32
-- Resolved string for `s'.
local
t: STRING_32
do
create t.make (s.count)
append_resolved_string_to (s, t)
Result := t
end
resolved_path_name (a_path: PATH): PATH
-- Resolved name for `a_path'.
local
n,s: READABLE_STRING_32
do
n := a_path.name
s := resolved_string (n)
if s.same_string (n) then
Result := a_path
else
create Result.make_from_string (s)
end
end
end

View File

@@ -0,0 +1,64 @@
note
description: "Summary description for {WIZARD_LAYOUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WIZARD_LAYOUT
inherit
SHARED_EXECUTION_ENVIRONMENT
create
make
feature {NONE} -- Initialization
make (d: like wizard_location; cb: like callback_file_location)
do
wizard_location := d.absolute_path
callback_file_location := cb.absolute_path
end
feature -- Access
wizard_location: PATH
resources_location: PATH
do
Result := wizard_location.extended ("resources")
end
pixmaps_location: PATH
do
Result := wizard_location.extended ("pixmaps")
end
templates_location: PATH
do
Result := wizard_location.extended ("templates")
end
resource_location (a_name: READABLE_STRING_GENERAL): PATH
do
Result := resources_location.extended (a_name)
end
pixmap_png_location (a_name: READABLE_STRING_GENERAL): PATH
do
Result := pixmaps_location.extended (a_name).appended_with_extension ("png")
end
callback_file_location: PATH
default_projects_location: PATH
do
if attached execution_environment.item ("ISE_PROJECTS") as dn then
create Result.make_from_string (dn)
else
Result := execution_environment.current_working_path
end
end
end