Updated the ewf estudio wizard to have a console and a graphical wizard.
Usage: wizard -callback file.cb path-to-rootdir folder.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
EWF_CONSOLE_WIZARD_APPLICATION
|
||||
|
||||
inherit
|
||||
CONSOLE_WIZARD_APPLICATION
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
initialize
|
||||
on_start
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
new_wizard: EWF_WIZARD
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,55 +0,0 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
EWF_CUSTOM_WIZARD
|
||||
|
||||
inherit
|
||||
EWF_WIZARD
|
||||
redefine
|
||||
get_information,
|
||||
generate_project
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Form
|
||||
|
||||
get_information
|
||||
do
|
||||
if attached string_question ("Location of EWF source code (by default $EWF_DIR)?", Void, Void, False) as pn then
|
||||
ewf_dir := pn.string
|
||||
else
|
||||
ewf_dir := "$EWF_DIR"
|
||||
end
|
||||
Precursor
|
||||
end
|
||||
|
||||
feature -- Generation
|
||||
|
||||
generate_project (a_layout: WIZARD_LAYOUT)
|
||||
do
|
||||
if attached ewf_dir as d then
|
||||
variables.force (d, "EWF_DIR")
|
||||
Precursor (a_layout)
|
||||
else
|
||||
die (-1)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
ewf_dir: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Change
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
invariant
|
||||
-- invariant_clause: True
|
||||
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
description: "Summary description for {EWF_WIZARD}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_WIZARD
|
||||
@@ -13,150 +13,198 @@ inherit
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
initialize
|
||||
get_information
|
||||
if is_valid and attached layout as lay then
|
||||
generate_project (lay)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
project_directory_name: detachable READABLE_STRING_8
|
||||
title: STRING_32 = "Web Application Wizard"
|
||||
|
||||
projet_name: detachable READABLE_STRING_8
|
||||
feature -- Factory
|
||||
|
||||
use_router: BOOLEAN
|
||||
|
||||
router_type: detachable READABLE_STRING_8
|
||||
|
||||
connector: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Form
|
||||
|
||||
get_information
|
||||
local
|
||||
e: EXECUTION_ENVIRONMENT
|
||||
wizard_generator : EWF_WIZARD_GENERATOR
|
||||
do
|
||||
create e
|
||||
project_directory_name := e.get ("ISE_PROJECTS")
|
||||
if
|
||||
attached project_directory_name as pdn and then
|
||||
attached string_question ("Project directory (default=" + pdn + ")? ", <<["q", Void]>>, pdn, False) as r_pdn
|
||||
then
|
||||
project_directory_name := r_pdn.string
|
||||
elseif attached string_question ("Project directory ? ", <<["q", Void]>>, Void, False) as r_pdn then
|
||||
project_directory_name := r_pdn.string
|
||||
end
|
||||
if project_directory_name = Void then
|
||||
die (-1)
|
||||
end
|
||||
|
||||
if attached string_question ("Project name ? ", Void, Void, False) as pn then
|
||||
projet_name := pn.string
|
||||
else
|
||||
projet_name := "ewf"
|
||||
end
|
||||
|
||||
if boolean_question ("Do you want to use WSF_ROUTER (Y|n) ? ", <<["y", True], ["Y", True]>>, "Y") then
|
||||
use_router := True
|
||||
router_type := "uri-template"
|
||||
else
|
||||
use_router := False
|
||||
end
|
||||
|
||||
if attached string_question ("[
|
||||
Default connector ?
|
||||
1 - Eiffel Web Nino (standalone web server)
|
||||
2 - CGI application (requires to setup httpd server)
|
||||
3 - libFCGI application (requires to setup httpd server)
|
||||
Your choice:
|
||||
]", <<["1", "nino"], ["2", "cgi"], ["3", "libfcgi"]>>, "1", True) as conn
|
||||
then
|
||||
connector := conn
|
||||
else
|
||||
connector := "nino"
|
||||
end
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
is_valid: BOOLEAN
|
||||
do
|
||||
Result := project_directory_name /= Void and projet_name /= Void
|
||||
feature -- Pages
|
||||
|
||||
first_page: WIZARD_PAGE
|
||||
once
|
||||
Result := new_page ("first")
|
||||
Result.set_title ("Web Application Wizard")
|
||||
Result.set_subtitle ("Based on the EWF libraries...")
|
||||
Result.add_section_text ("Create Web server application with EWF.")
|
||||
Result.add_text ("[
|
||||
|
||||
Using the Eiffel Web Framework (EWF), the generated application
|
||||
will run on any platforms.
|
||||
Depending on the connector(s), you may need to use a
|
||||
third-party httpd server (such as apache, nginx, ...)
|
||||
|
||||
]")
|
||||
end
|
||||
|
||||
generate_project (a_layout: WIZARD_LAYOUT)
|
||||
require
|
||||
is_valid
|
||||
project_page: WIZARD_PAGE
|
||||
once
|
||||
Result := new_page ("project")
|
||||
Result.set_title ("Project Name and Project Location")
|
||||
Result.set_subtitle ("You can choose the name of the project and%Nthe directory where the project will be generated.")
|
||||
Result.add_text ("[
|
||||
Please fill in:
|
||||
The name of the project (without space).
|
||||
The directory where you want the eiffel classes to be generated.
|
||||
]")
|
||||
Result.extend (Result.new_string_question ("Project name:", "name", "ASCII name, without space"))
|
||||
Result.add_directory_question ("Project location:", "location", "Valid directory path, it will be created if missing")
|
||||
|
||||
Result.data.force ("ewf_app", "name")
|
||||
Result.data.force (application.available_directory_path ("ewf_app", application.layout.default_projects_location.extended ("ewf")).name, "location")
|
||||
|
||||
Result.set_validation (agent (a_page: WIZARD_PAGE)
|
||||
do
|
||||
if
|
||||
not attached a_page.data.item ("name") as l_name
|
||||
or else l_name.is_whitespace
|
||||
then
|
||||
a_page.report_error ("Invalid value for `name'!")
|
||||
end
|
||||
if not a_page.data.has ("location") then
|
||||
a_page.report_error ("Missing value for `location'!")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
connectors_page: WIZARD_PAGE
|
||||
once
|
||||
Result := new_page ("connectors")
|
||||
Result.set_title ("Connectors selection")
|
||||
Result.set_subtitle ("You can choose one or multiple connectors%Nto use as the same time.")
|
||||
Result.add_text ("[
|
||||
Web application runs on top of connectors
|
||||
(i.e layer handling httpd incoming connections)
|
||||
|
||||
Select connectors you want to support:
|
||||
]")
|
||||
Result.add_boolean_question ("Standalone", "use_standalone", "Using the Eiffel Web nino server")
|
||||
Result.add_boolean_question ("CGI", "use_cgi", "Require a httpd server")
|
||||
Result.add_boolean_question ("libFCGI", "use_libfcgi", "Require a httpd server")
|
||||
|
||||
Result.data.force ("yes", "use_standalone")
|
||||
Result.data.force ("yes", "use_cgi")
|
||||
Result.data.force ("yes", "use_libfcgi")
|
||||
end
|
||||
|
||||
standalone_connector_page: WIZARD_PAGE
|
||||
once
|
||||
Result := new_page ("standalone_connector")
|
||||
Result.set_title ("Standalone (nino) connector")
|
||||
Result.set_subtitle ("Set options .")
|
||||
Result.add_integer_question ("Port number", "port", "It happens port 80 is already taken, thus choose another one.")
|
||||
Result.add_boolean_question ("Verbose", "verbose", "Verbose output")
|
||||
|
||||
Result.data.force ("80", "port")
|
||||
Result.data.force ("no", "verbose")
|
||||
end
|
||||
|
||||
routers_page: WIZARD_PAGE
|
||||
once
|
||||
Result := new_page ("routers")
|
||||
Result.set_title ("Use Router (URL dispatching)")
|
||||
Result.set_subtitle ("Use the router component to easily map url patterns to handlers.")
|
||||
Result.add_text ("[
|
||||
Use the router component to easily map URL patterns to handlers:
|
||||
]")
|
||||
Result.add_boolean_question ("use the router component", "use_router", "Check generated code to see how to configure it.")
|
||||
|
||||
Result.data.force ("yes", "use_router")
|
||||
end
|
||||
|
||||
final_page: WIZARD_PAGE
|
||||
local
|
||||
d: DIRECTORY
|
||||
dn: DIRECTORY_NAME
|
||||
tfn: FILE_NAME
|
||||
res: WIZARD_SUCCEED_RESPONSE
|
||||
-- s,sv: STRING_32
|
||||
-- l_settings: ARRAYED_LIST [TUPLE [title: READABLE_STRING_GENERAL; value: READABLE_STRING_GENERAL]]
|
||||
-- l_project_settings: STRING_32
|
||||
-- l_ewf_settings: STRING_32
|
||||
txt1, txt2: WIZARD_PAGE_TEXT_ITEM
|
||||
once
|
||||
Result := new_page ("final")
|
||||
Result.set_title ("Completing the New Web Application Wizard")
|
||||
Result.add_text ("You have specified the following settings:%N%N")
|
||||
txt1 := Result.new_fixed_size_text_item ("...")
|
||||
-- Result.add_fixed_size_text ("...", "projects_settings")
|
||||
Result.extend (txt1)
|
||||
|
||||
txt2 := Result.new_fixed_size_text_item ("...")
|
||||
-- Result.add_fixed_size_text ("...", "ewf_settings")
|
||||
Result.extend (txt2)
|
||||
|
||||
Result.update_actions.extend (agent (a_page: WIZARD_PAGE; a_txt1, a_txt2: WIZARD_PAGE_TEXT_ITEM)
|
||||
local
|
||||
sv: STRING_32
|
||||
l_settings: ARRAYED_LIST [TUPLE [title: READABLE_STRING_GENERAL; value: READABLE_STRING_GENERAL]]
|
||||
do
|
||||
-- Project
|
||||
create l_settings.make (10)
|
||||
if attached project_page.field_value ("name") as l_project_name then
|
||||
l_settings.force (["Project name", l_project_name])
|
||||
end
|
||||
if attached project_page.field_value ("location") as l_project_location then
|
||||
l_settings.force (["Location", l_project_location])
|
||||
end
|
||||
a_txt1.set_text (formatted_title_value_items (l_settings))
|
||||
|
||||
-- EWF
|
||||
create l_settings.make (5)
|
||||
create sv.make_empty
|
||||
if connectors_page.boolean_field_value ("use_standalone") then
|
||||
if not sv.is_empty then
|
||||
sv.append (", ")
|
||||
end
|
||||
sv.append ("standalone")
|
||||
end
|
||||
if connectors_page.boolean_field_value ("use_cgi") then
|
||||
if not sv.is_empty then
|
||||
sv.append (", ")
|
||||
end
|
||||
sv.append ("cgi")
|
||||
end
|
||||
if connectors_page.boolean_field_value ("use_libfcgi") then
|
||||
if not sv.is_empty then
|
||||
sv.append (", ")
|
||||
end
|
||||
sv.append ("libfcgi")
|
||||
end
|
||||
|
||||
l_settings.force (["Connectors", sv])
|
||||
|
||||
if routers_page.boolean_field_value ("use_router") then
|
||||
l_settings.force (["Use Router", "yes"])
|
||||
end
|
||||
|
||||
a_txt2.set_text (formatted_title_value_items (l_settings))
|
||||
end(Result, txt1, txt2))
|
||||
end
|
||||
|
||||
feature -- Events
|
||||
|
||||
next_page (a_current_page: detachable WIZARD_PAGE): WIZARD_PAGE
|
||||
do
|
||||
if attached project_directory_name as pdn then
|
||||
if attached projet_name as pn then
|
||||
variables.force (pn, "TARGET_NAME")
|
||||
variables.force (new_uuid, "UUID")
|
||||
variables.force ("none", "CONCURRENCY")
|
||||
if attached connector as conn then
|
||||
variables.force (conn, "EWF_CONNECTOR")
|
||||
end
|
||||
variables.force ("9999", "EWF_NINO_PORT")
|
||||
|
||||
create dn.make_from_string (pdn)
|
||||
dn.extend (pn)
|
||||
create d.make (dn.string)
|
||||
if not d.exists then
|
||||
d.recursive_create_dir
|
||||
end
|
||||
create tfn.make_from_string (dn.string)
|
||||
tfn.set_file_name (pn)
|
||||
tfn.add_extension ("ecf")
|
||||
copy_resource_template ("template.ecf", tfn.string)
|
||||
|
||||
create res.make (tfn.string, d.name)
|
||||
|
||||
create tfn.make_from_string (dn.string)
|
||||
|
||||
tfn.set_file_name ("ewf")
|
||||
tfn.add_extension ("ini")
|
||||
copy_resource_template ("ewf.ini", tfn.string)
|
||||
|
||||
create dn.make_from_string (pdn)
|
||||
dn.extend (pn)
|
||||
dn.extend ("src")
|
||||
create d.make (dn.string)
|
||||
if not d.exists then
|
||||
d.recursive_create_dir
|
||||
end
|
||||
create tfn.make_from_string (dn.string)
|
||||
tfn.set_file_name ("ewf_application")
|
||||
tfn.add_extension ("e")
|
||||
if attached router_type as rt then
|
||||
check rt.same_string ("uri-template") end
|
||||
copy_resource_template ("ewf_application-"+ rt +".e", tfn.string)
|
||||
else
|
||||
copy_resource_template ("ewf_application.e", tfn.string)
|
||||
end
|
||||
|
||||
|
||||
send_response (res)
|
||||
Result := notfound_page
|
||||
if a_current_page = Void then
|
||||
Result := first_page
|
||||
elseif a_current_page = first_page then
|
||||
Result := project_page
|
||||
elseif a_current_page = project_page then
|
||||
Result := connectors_page
|
||||
elseif a_current_page = connectors_page then
|
||||
if connectors_page.boolean_field_value ("use_standalone") then
|
||||
Result := standalone_connector_page
|
||||
else
|
||||
Result := routers_page
|
||||
end
|
||||
elseif a_current_page = standalone_connector_page then
|
||||
Result := routers_page
|
||||
elseif a_current_page = routers_page then
|
||||
Result := final_page
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Output
|
||||
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
invariant
|
||||
-- invariant_clause: True
|
||||
|
||||
end
|
||||
|
||||
136
tools/ise_wizard/src/ewf_wizard_generator.e
Normal file
136
tools/ise_wizard/src/ewf_wizard_generator.e
Normal file
@@ -0,0 +1,136 @@
|
||||
note
|
||||
description: "Summary description for {EWF_WIZARD_GENERATOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_WIZARD_GENERATOR
|
||||
|
||||
inherit
|
||||
WIZARD_GENERATOR
|
||||
redefine
|
||||
copy_template
|
||||
end
|
||||
|
||||
SHARED_TEMPLATE_CONTEXT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Query
|
||||
|
||||
collection: detachable WIZARD_DATA
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (a_collection: WIZARD_DATA)
|
||||
local
|
||||
d: DIRECTORY
|
||||
pdn, dn: PATH
|
||||
tfn: PATH
|
||||
res: WIZARD_SUCCEED_RESPONSE
|
||||
-- k: STRING_32
|
||||
do
|
||||
collection := a_collection
|
||||
if
|
||||
attached a_collection.item ("project:name") as pn and
|
||||
attached a_collection.item ("project:location") as l_loc
|
||||
then
|
||||
create pdn.make_from_string (l_loc)
|
||||
|
||||
variables.force (pn.as_lower, "APP_NAME")
|
||||
variables.force (pn.as_upper, "APP_ROOT")
|
||||
variables.force (new_uuid, "UUID")
|
||||
variables.force ("none", "CONCURRENCY")
|
||||
|
||||
variables.force ("yes", "WIZ_YES")
|
||||
variables.force ("no", "WIZ_NO")
|
||||
|
||||
dn := pdn
|
||||
create d.make_with_path (dn)
|
||||
if not d.exists then
|
||||
d.recursive_create_dir
|
||||
end
|
||||
|
||||
recursive_copy_templates (application.layout.resources_location, dn)
|
||||
|
||||
tfn := dn.extended (pn).appended_with_extension ("ecf")
|
||||
create res.make (tfn, d.path)
|
||||
|
||||
send_response (res)
|
||||
else
|
||||
send_response (create {WIZARD_FAILED_RESPONSE})
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Templates
|
||||
|
||||
smarty_template_extensions: ARRAY [READABLE_STRING_32]
|
||||
once
|
||||
Result := <<"e", "ecf", "ini">>
|
||||
end
|
||||
|
||||
is_smarty_template_file (f: PATH): BOOLEAN
|
||||
do
|
||||
if attached f.extension as ext then
|
||||
Result := across smarty_template_extensions as ext_ic some ext_ic.item.is_case_insensitive_equal_general (ext) end
|
||||
end
|
||||
end
|
||||
|
||||
is_template_file (f: PATH): BOOLEAN
|
||||
do
|
||||
Result := is_smarty_template_file (f)
|
||||
end
|
||||
|
||||
copy_template (a_src: PATH; a_target: PATH)
|
||||
do
|
||||
if is_smarty_template_file (a_src) then
|
||||
copy_smarty_template (a_src, a_target)
|
||||
else
|
||||
Precursor (a_src, a_target)
|
||||
end
|
||||
end
|
||||
|
||||
copy_smarty_template (a_res: PATH; a_target: PATH)
|
||||
local
|
||||
tpl: TEMPLATE_FILE
|
||||
f,t: PLAIN_TEXT_FILE
|
||||
inspectors: ARRAYED_LIST [TEMPLATE_INSPECTOR]
|
||||
do
|
||||
create f.make_with_path (a_res)
|
||||
if f.exists and f.is_readable then
|
||||
create tpl.make_from_file (f.path.name)
|
||||
if attached collection as l_collection then
|
||||
tpl.add_value (l_collection, "WIZ")
|
||||
end
|
||||
across
|
||||
variables as ic
|
||||
loop
|
||||
tpl.add_value (ic.item, ic.key)
|
||||
end
|
||||
template_context.set_template_folder (application.layout.templates_location)
|
||||
create inspectors.make (2)
|
||||
inspectors.force (create {WIZARD_DATA_TEMPLATE_INSPECTOR}.register ({detachable WIZARD_DATA}))
|
||||
inspectors.force (create {WIZARD_PAGE_DATA_TEMPLATE_INSPECTOR}.register ({detachable WIZARD_PAGE_DATA}))
|
||||
tpl.analyze
|
||||
tpl.get_output
|
||||
across
|
||||
inspectors as ic
|
||||
loop
|
||||
ic.item.unregister
|
||||
end
|
||||
if attached tpl.output as l_output then
|
||||
create t.make_with_path (a_target)
|
||||
if not t.exists or else t.is_writable then
|
||||
t.create_read_write
|
||||
t.put_string (l_output)
|
||||
t.close
|
||||
end
|
||||
else
|
||||
copy_file (a_res, a_target)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
46
tools/ise_wizard/src/gui/ewf_graphical_wizard.e
Normal file
46
tools/ise_wizard/src/gui/ewf_graphical_wizard.e
Normal file
@@ -0,0 +1,46 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_GRAPHICAL_WIZARD
|
||||
|
||||
inherit
|
||||
EV_APPLICATION
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
undefine
|
||||
default_create, copy
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_and_launch
|
||||
local
|
||||
w: like main_window
|
||||
cons: EWF_CONSOLE_WIZARD_APPLICATION
|
||||
do
|
||||
default_create
|
||||
if execution_environment.arguments.index_of_word_option ("-console") > 0 then
|
||||
create cons.make
|
||||
else
|
||||
create w
|
||||
main_window := w
|
||||
|
||||
w.show
|
||||
launch
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
main_window: detachable EWF_WIZARD_WINDOW
|
||||
|
||||
end
|
||||
38
tools/ise_wizard/src/gui/ewf_wizard_window.e
Normal file
38
tools/ise_wizard/src/gui/ewf_wizard_window.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {EWF_WIZARD_WINDOW}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_WIZARD_WINDOW
|
||||
|
||||
inherit
|
||||
GRAPHICAL_WIZARD_WINDOW
|
||||
redefine
|
||||
side_bar_items
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
new_wizard: EWF_WIZARD
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
side_bar_items (a_page: WIZARD_PAGE): ARRAYED_LIST [WIZARD_PAGE_ITEM]
|
||||
local
|
||||
lab: EV_LABEL
|
||||
do
|
||||
Result := Precursor (a_page)
|
||||
if a_page.page_id.is_case_insensitive_equal_general ("first")
|
||||
or a_page.page_id.is_case_insensitive_equal_general ("final")
|
||||
then
|
||||
create lab.make_with_text ("EWF")
|
||||
lab.set_foreground_color (colors.white)
|
||||
Result.extend (create {GRAPHICAL_WIZARD_PAGE_WIDGET}.make_with_widget (lab))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,265 +0,0 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
deferred class
|
||||
WIZARD
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Initialize `Current'.
|
||||
local
|
||||
i,n: INTEGER
|
||||
s: READABLE_STRING_8
|
||||
wizard_directory_name: detachable READABLE_STRING_8
|
||||
callback_file_name: detachable READABLE_STRING_8
|
||||
do
|
||||
create variables.make (5)
|
||||
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
|
||||
callback_file_name := argument (i)
|
||||
end
|
||||
elseif wizard_directory_name = Void then
|
||||
wizard_directory_name := s
|
||||
else
|
||||
debug
|
||||
io.error.put_string ("Ignoring argument %"" + s + "%"%N")
|
||||
end
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
if wizard_directory_name = Void then
|
||||
display_usage (io.error)
|
||||
quit ("ERROR: Missing wizard directory name.")
|
||||
elseif callback_file_name = Void then
|
||||
display_usage (io.error)
|
||||
quit ("ERROR: Missing Eiffel Studio callback file name.")
|
||||
else
|
||||
create layout.make (wizard_directory_name, callback_file_name)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
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 (m: detachable READABLE_STRING_8)
|
||||
do
|
||||
if m /= Void then
|
||||
io.error.put_string (m)
|
||||
end
|
||||
send_response (create {WIZARD_FAILED_RESPONSE})
|
||||
ensure
|
||||
False -- never reached
|
||||
end
|
||||
|
||||
die (code: INTEGER)
|
||||
do
|
||||
(create {EXCEPTIONS}).die (code)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
variables: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
|
||||
|
||||
layout: detachable WIZARD_LAYOUT
|
||||
|
||||
feature -- Response
|
||||
|
||||
send_response (res: WIZARD_RESPONSE)
|
||||
local
|
||||
f: RAW_FILE
|
||||
do
|
||||
if attached layout as lay then
|
||||
create f.make (lay.callback_file_name)
|
||||
if not f.exists or else f.is_writable then
|
||||
f.open_write
|
||||
res.send (f)
|
||||
f.close
|
||||
else
|
||||
die (0)
|
||||
end
|
||||
else
|
||||
die (0)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
boolean_question (m: READABLE_STRING_8; a_options: detachable ITERABLE [TUPLE [key: READABLE_STRING_8; value: BOOLEAN]]; def: detachable STRING_8): BOOLEAN
|
||||
local
|
||||
s: STRING_8
|
||||
l_answered: BOOLEAN
|
||||
l_options: detachable ITERABLE [TUPLE [key: READABLE_STRING_8; value: BOOLEAN]]
|
||||
do
|
||||
from
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
io.put_string (m)
|
||||
if l_options = Void then
|
||||
l_options := a_options
|
||||
end
|
||||
if l_options = Void then
|
||||
l_options := <<["y", True], ["Y", True]>>
|
||||
end
|
||||
io.read_line
|
||||
s := io.last_string
|
||||
s.left_adjust
|
||||
s.right_adjust
|
||||
if s.is_empty and def /= Void then
|
||||
s := def
|
||||
end
|
||||
if not s.is_empty then
|
||||
across
|
||||
l_options as o
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
if o.item.key.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_8; a_options: detachable ITERABLE [TUPLE [key: READABLE_STRING_8; value: detachable READABLE_STRING_8]]; def: detachable READABLE_STRING_8; a_required_valid_option: BOOLEAN): detachable READABLE_STRING_8
|
||||
local
|
||||
s: STRING_8
|
||||
l_answered: BOOLEAN
|
||||
do
|
||||
from
|
||||
until
|
||||
l_answered
|
||||
loop
|
||||
io.put_string (m)
|
||||
io.read_line
|
||||
s := io.last_string
|
||||
s.left_adjust
|
||||
s.right_adjust
|
||||
if s.is_empty and def /= Void then
|
||||
s := 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.key.same_string (s) then
|
||||
l_answered := True
|
||||
Result := o.item.value
|
||||
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
|
||||
|
||||
copy_file (a_src, a_target: READABLE_STRING_8)
|
||||
local
|
||||
f,t: RAW_FILE
|
||||
do
|
||||
create f.make (a_src)
|
||||
if f.exists and f.is_readable then
|
||||
create t.make (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
|
||||
|
||||
new_uuid: STRING_8
|
||||
local
|
||||
gen: UUID_GENERATOR
|
||||
do
|
||||
create gen
|
||||
Result := gen.generate_uuid.out
|
||||
end
|
||||
|
||||
feature -- Resources
|
||||
|
||||
copy_resource (a_res: READABLE_STRING_8; a_target: READABLE_STRING_8)
|
||||
do
|
||||
if attached layout as lay then
|
||||
copy_file (lay.resource (a_res), a_target)
|
||||
end
|
||||
end
|
||||
|
||||
copy_resource_template (a_res: READABLE_STRING_8; a_target: READABLE_STRING_8)
|
||||
local
|
||||
f,t: RAW_FILE
|
||||
do
|
||||
if attached layout as lay then
|
||||
create f.make (lay.resource (a_res))
|
||||
if f.exists and f.is_readable then
|
||||
create t.make (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
|
||||
across
|
||||
variables as v
|
||||
loop
|
||||
f.last_string.replace_substring_all ("${WIZ:" + v.key + "}", v.item)
|
||||
end
|
||||
t.put_string (f.last_string)
|
||||
t.put_new_line
|
||||
f.read_line
|
||||
end
|
||||
t.close
|
||||
f.close
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
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
|
||||
@@ -1,49 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {WIZARD_LAYOUT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WIZARD_LAYOUT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (d: like wizard_directory_name; cb: like callback_file_name)
|
||||
do
|
||||
wizard_directory_name := d
|
||||
callback_file_name := cb
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
wizard_directory_name: READABLE_STRING_8
|
||||
|
||||
resource (a_name: READABLE_STRING_8): STRING_8
|
||||
local
|
||||
fn: FILE_NAME
|
||||
do
|
||||
create fn.make_from_string (wizard_directory_name)
|
||||
fn.extend ("resources")
|
||||
fn.set_file_name (a_name)
|
||||
Result := fn.string
|
||||
end
|
||||
|
||||
pixmap_png_filename (a_name: READABLE_STRING_8): STRING_8
|
||||
local
|
||||
fn: FILE_NAME
|
||||
do
|
||||
create fn.make_from_string (wizard_directory_name)
|
||||
fn.extend ("pixmaps")
|
||||
fn.set_file_name (a_name)
|
||||
fn.add_extension ("png")
|
||||
Result := fn.string
|
||||
end
|
||||
|
||||
callback_file_name: READABLE_STRING_8
|
||||
|
||||
invariant
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {WIZARD_RESPONSE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WIZARD_RESPONSE
|
||||
|
||||
feature -- Output
|
||||
|
||||
send (f: FILE)
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,68 +0,0 @@
|
||||
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: READABLE_STRING_8
|
||||
directory_name: READABLE_STRING_8
|
||||
|
||||
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 + "%"%N")
|
||||
f.put_string ("Directory=%"" + directory_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
|
||||
@@ -0,0 +1,46 @@
|
||||
note
|
||||
description: "Summary description for {WIZARD_DATA_TEMPLATE_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WIZARD_DATA_TEMPLATE_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached {WIZARD_DATA} obj as wiz then
|
||||
l_fn := field_name.as_lower
|
||||
if attached wiz.page_data (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
@@ -0,0 +1,45 @@
|
||||
note
|
||||
description: "Summary description for {WIZARD_PAGE_DATA_TEMPLATE_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WIZARD_PAGE_DATA_TEMPLATE_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {WIZARD_PAGE_DATA} obj as pg then
|
||||
l_fn := field_name.as_lower
|
||||
if attached pg.item (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
Reference in New Issue
Block a user