This commit is contained in:
Jocelyn Fiat
2024-06-17 09:09:33 +02:00
commit 6dde6425c2
560 changed files with 81728 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
note
description: "[
{COMMAND} to add a field to a {SCHEMA}
]"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/add_field_command.e $"
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
revision: "$Revision: 7 $"
class
ADD_FIELD_COMMAND
inherit
EDIT_COMMAND
create
make
end

View File

@@ -0,0 +1,153 @@
note
description: "[
Used by {EDIT_TOOL} to add or remove a {FIELD} in a {SCHEMA}.
Note: this is not to be confused with {EDIT_COMMAND} which is used
to change the "data" in a record or to change the positioning of a
{FIELD}; this changes the {SCHEMA} itself.
]"
date: "6 Oct 07"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/change_fields_command.e $"
date: "$Date: 2013-04-25 18:11:22 -0400 (Thu, 25 Apr 2013) $"
revision: "$Revision: 14 $"
class
CHANGE_FIELDS_COMMAND
inherit
JJ_COMMAND
redefine
text,
affected_objects,
execute,
undo,
is_executable,
is_undoable
end
create
make
feature {NONE} -- Initialization
make (a_schema: like schema; a_field: like field)
-- Create an instance
do
default_create
schema := a_schema
field := a_field
end
feature -- Access
text: STRING
-- Name of this command
do
Result := "Change schema"
end
schema: SCHEMA
-- The SCHEMA being changed
field: FIELD
-- FIELD which identifies the "item" to be changed
affected_objects: LINKED_SET [ANY]
-- Set of objects changable by this command
do
Result := Precursor {JJ_COMMAND}
Result.extend (schema)
Result.extend (field)
end
feature -- Element change
set_schema (a_schema: like schema)
-- Change `schema'
require
schema_exists: a_schema /= Void
do
schema := a_schema
ensure
schema_assigned: schema = a_schema
end
set_field (a_field: FIELD)
-- Change `field'
require
field_exists: a_field /= Void
do
field := a_field
ensure
field_assigned: field = a_field
end
feature -- Basic operations
execute
-- Perform the command
do
Precursor {JJ_COMMAND}
schema.time_modified.set_now_utc_fine
if is_delete_command then
schema.start
schema.prune (field)
else
schema.extend (field)
end
end
undo
-- Undo the command
do
Precursor {JJ_COMMAND}
schema.time_modified.set_now_utc_fine
if is_delete_command then
schema.extend (field)
else
schema.start
schema.prune (field)
end
end
feature -- Status report
is_executable: BOOLEAN
-- Can the command be executed?
do
Result := Precursor {JJ_COMMAND} and then
(schema /= Void and field /= Void) and then
(is_delete_command implies schema.has (field))
end
is_undoable: BOOLEAN
-- Can the command be undone?
do
Result := PRECURSOR {JJ_COMMAND} and then
(schema /= Void and then field /= Void) and then
(is_delete_command implies not schema.has (field))
end
feature -- Status setting
set_delete_action
-- Make this command delete `field' from `schema' when `execute' is called.
do
is_delete_command := True
end
set_add_action
-- Make this command add `field' to `schema' when `execute' is called.
do
is_delete_command := False
end
feature {NONE} -- Implementation
is_delete_command: BOOLEAN
-- Is this command to be used to delete `field' from `schema'?
end

View File

@@ -0,0 +1,217 @@
note
description: "[
Objects used by {JJ_APPLICATION} to allow commands to be
undone and redone.
]"
date: "2 Oct 03"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/command_manager.e $"
date: "$Date: 2012-07-01 01:30:44 -0400 (Sun, 01 Jul 2012) $"
revision: "$Revision: 12 $"
class
COMMAND_MANAGER
inherit
SHARED
export
{NONE} all
undefine
default_create,
copy,
is_equal
end
LINKED_LIST [JJ_COMMAND]
export
{LINKED_LIST}
all
-- {NONE}
-- all
-- {LINKED_LIST}
-- start,
-- forth,
-- first_element,
-- last_element,
-- count,
-- object_comparison,
-- cursor,
-- go_to,
-- index
{ANY}
wipe_out,
prunable,
-- item,
is_empty,
-- readable,
-- off,
has,
is_equal
-- standard_is_equal,
-- copy,
-- same_type
redefine
default_create,
wipe_out
end
create
default_create, make
feature {NONE} -- Initialization
default_create
-- Initialize `Current'.
do
make
end
feature -- Access
marked_index: INTEGER
-- Mark the command at current `last_executed_index'
last_executed_index: INTEGER
-- Index of last executed (and next undoable) command.
command: JJ_COMMAND
-- Last inserted command.
require
not_empty: not is_empty
do
Result := i_th (last_executed_index)
end
feature -- Element change
add_command (a_command: JJ_COMMAND)
-- Remove any commands which have been undone (they will not be
-- executable after `a_command' is added), then add `a command'
-- to the list and execute it.
require
not_has_command: not has (a_command)
do
from go_i_th (last_executed_index + 1)
until after or else is_empty
loop
remove
end
extend (a_command)
execute
check
last_executed_index = index_of (a_command, 1)
end
ensure
command_added: has (a_command)
command_executed: last_executed_index = count
end
set_mark
-- Save a reference to the currently undoable command.
-- Useful for marking the command state at which a
-- system was saved.
do
marked_index := last_executed_index
end
feature -- Status report
is_undoable: BOOLEAN
-- Can a command be undone?
do
Result := last_executed_index > 0
end
is_executable: BOOLEAN
-- Is there a command which can be executed?
-- That is, was one previousely undone or added?
do
Result := last_executed_index + 1 <= count
end
is_at_marked_state: BOOLEAN
-- Is the cursor at item which was marked_index.
-- Useful for marking and checking if / when a system was saved.
do
Result := last_executed_index = marked_index
end
feature -- Basic operations
wipe_out
-- Remove all commands from Current, erasing history.
do
Precursor
last_executed_index := 0
marked_index := 0
end
execute
-- Execute the command at `last_executed_index'.
require
can_execute_a_command: is_executable
local
v: VIEW
c: JJ_COMMAND
do
last_executed_index := last_executed_index + 1
c := i_th (last_executed_index)
c.execute
-- Persistence_manager.extend_objects (c.affected_objects)
-- Get a view so the views with the objects changed
-- by executing the command can be updated.
v := main_windows.first
-- v.notify_views_with_set (c.affected_objects)
v.draw_views_with_set (c.affected_objects)
-- Call `set_widget_states' to update the undo, redo, and save, etc. buttons.
main_windows.do_all (agent {JJ_MAIN_WINDOW}.set_widget_states)
ensure
last_executed_index_incremented: last_executed_index = old last_executed_index + 1
end
undo
-- Reverse execute the last command.
require
can_undo_a_command: is_undoable
local
v: VIEW
c: JJ_COMMAND
do
-- Get the command at the current index and undo it.
c := i_th (last_executed_index)
c.undo
last_executed_index := last_executed_index - 1
-- persistence_manager.extend_objects (c.affected_objects)
-- Need to get a view so the views with the objects changed
-- by undoing the command can be updated.
v := main_windows.first
-- v.notify_views_with_set (c.affected_objects)
v.draw_views_with_set (c.affected_objects)
-- Call `set_widget_states' to update the undo, redo, and save, etc. buttons.
main_windows.do_all (agent {JJ_MAIN_WINDOW}.set_widget_states)
ensure
last_executed_index_decremented: last_executed_index = old last_executed_index - 1
end
feature {NONE} -- Implementation (Handles to "global" application objects)
-- Persistence_manager: PERSISTENCE_MANAGER is
-- -- Handle (for convinience) to the JJ_APPLICATION's `persistence_manager'.
-- local
-- app: JJ_APPLICATION
-- once
-- app ?= (create {EV_ENVIRONMENT}).application
-- check
-- app /= Void
-- -- Because this class if for use by a JJ_APPLICATION
-- end
-- Result := app.persistence_manager
-- ensure
-- result_exists: Result /= Void
-- end
end

View File

@@ -0,0 +1,149 @@
note
description: "[
Command used to change a field of an {EDITABLE}.
]"
date: "27 Jan 05"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/edit_command.e $"
date: "$Date: 2013-04-25 18:11:22 -0400 (Thu, 25 Apr 2013) $"
revision: "$Revision: 14 $"
class
EDIT_COMMAND
inherit
JJ_COMMAND
redefine
text,
affected_objects,
execute,
undo,
is_executable,
is_undoable
end
create
make
feature {NONE} -- Initialization
make (a_record: like record; a_field: like field; a_value: like value)
-- Initialize Current
do
default_create
record := a_record
field := a_field
value := a_value
end
feature -- Access
text: STRING
-- Name of this command
do
Result := "Edit record"
end
record: EDITABLE
-- Object to be changed.
field: FIELD
-- FIELD which identifies the "item" to be changed
value: ANY
-- New value
affected_objects: LINKED_SET [ANY]
-- Set of objects changable by this command
do
create Result.make
Result.extend (record)
end
feature -- Element change
set_record (a_record: like record)
-- Change `record'
require
record_exists: a_record /= Void
do
record := a_record
ensure
record_assigned: record = a_record
end
set_field (a_field: FIELD)
-- Change `field'
require
field_exists: a_field /= Void
do
field := a_field
ensure
field_assigned: field = a_field
end
set_value (a_value: ANY)
-- Change `value'.
require
value_exists: a_value /= Void
do
value := a_value
ensure
value_assigned: value = a_value
end
feature -- Basic operations
execute
-- Perform the command
do
if record.has_value (field.label) then
old_field := field
old_value := record.value (field.label)
end
record.extend_value (value, field.label)
Precursor {JJ_COMMAND}
end
undo
-- Undo the command
do
if attached old_field as of then
record.extend_value (of, field.label)
else
record.remove_value (field.label)
end
Precursor {JJ_COMMAND}
end
feature -- Status report
is_executable: BOOLEAN
-- Can the command be executed?
do
Result := Precursor {JJ_COMMAND} and then
record /= Void and field /= Void and value /= Void
end
is_undoable: BOOLEAN
-- Can the command be undone?
do
Result := Precursor {JJ_COMMAND} and then
(record /= Void and (old_field /= Void implies old_value /= Void)) and
record.has_value (field.label)
end
feature {NONE} -- Implementation
old_value: detachable ANY
-- Hold on to the old value in case of `undo'
old_field: detachable FIELD
-- Hold the old field. If Void we know that the record previously
-- did not have a field for the one just added by `execute', so
-- `undo' will remove `field'.
end

View File

@@ -0,0 +1,126 @@
note
description: "[
Used by {EDIT_TOOL} to change a {FIELD} in a {SCHEMA}.
Note: this is not to be confused with {EDIT_COMMAND} which is used
to change the "data" in a record or to change the positioning of a
{FIELD}; this changes the {SCHEMA} itself.
]"
date: "16 Mar 06"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/edit_schema_command.e $"
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
revision: "$Revision: 7 $"
class
EDIT_SCHEMA_COMMAND
inherit
EDIT_COMMAND
redefine
make,
text,
affected_objects,
execute,
undo,
is_executable,
is_undoable
end
create
make
feature {NONE} -- Initialization
make (a_record: like record; a_field: like field; a_value: like value)
-- Initialize Current
do
Precursor (a_record, a_field, a_value)
create schema
end
feature -- Access
text: STRING
-- Name of this command
do
Result := "Edit schema"
end
schema: SCHEMA
-- The SCHEMA being changed
affected_objects: LINKED_SET [ANY]
-- Set of objects changable by this command
do
Result := Precursor {EDIT_COMMAND}
Result.extend (schema)
Result.extend (field)
end
feature -- Element change
set_schema (a_schema: like schema)
-- Change `schema'
require
schema_exists: a_schema /= Void
do
schema := a_schema
ensure
schema_assigned: schema = a_schema
end
feature -- Basic operations
execute
-- Perform the command
do
schema.time_modified.set_now_utc_fine
Precursor {EDIT_COMMAND}
end
undo
-- Undo the command
do
schema.time_modified.set_now_utc_fine
Precursor {EDIT_COMMAND}
end
feature -- Status report
is_executable: BOOLEAN
-- Can the command be executed?
do
Result := Precursor {EDIT_COMMAND} and then
(schema /= Void and field /= Void)
end
is_undoable: BOOLEAN
-- Can the command be undone?
do
Result := PRECURSOR {EDIT_COMMAND} and then
(schema /= Void and field /= Void)
end
feature -- Status setting
set_delete_action
-- Make this command delete `field' from `schema' when `execute' is called.
do
is_delete_command := True
end
set_add_action
-- Make this command add `field' to `schema' when `execute' is called.
do
is_delete_command := False
end
feature {NONE} -- Implementation
is_delete_command: BOOLEAN
-- Is this command to be used to delete `field' from `schema'?
end

View File

@@ -0,0 +1,102 @@
note
description: "[
Root class for commands, allowing undo and redo, and to
facilitate history functions.
]"
author: "Jimmy J. Johnson"
copyright: "Copyright 2012, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/jj_command.e $"
date: "$Date: 2014-06-15 09:17:19 -0400 (Sun, 15 Jun 2014) $"
revision: "$Revision: 18 $"
class
JJ_COMMAND
inherit
ANY
redefine
default_create
end
create
default_create
feature {NONE} -- Initialization
default_create
-- Set up the command
do
create explanation.make
create affected_objects_imp.make
end
feature -- Access
text: STRING
-- Texual representation of what the command does.
do
Result := "do nothing"
end
explanation: LINKED_LIST [STRING]
-- List of reasons why a command was not executed or undone
-- Can be queried after a call to `is_executable' or `is_undoable'
feature -- Basic operations
execute
-- Execute the action represented by the command.
require
executable: is_executable
do
was_executed := True
end
undo
-- Reverse the action performed in `execute'.
require
undoable: is_undoable
do
was_executed := False
end
affected_objects: LINKED_SET [ANY]
-- List of object whose views must be updated
do
Result := affected_objects_imp
end
feature -- Status report
is_executable: BOOLEAN
-- Can the command be executed?
do
explanation.wipe_out
Result := not was_executed
if not Result then
explanation.extend ("Command already executed")
end
end
is_undoable: BOOLEAN
-- Can the command be undone?
do
explanation.wipe_out
Result := was_executed
if not Result then
explanation.extend ("Command not yet executed")
end
end
was_executed: BOOLEAN
-- Has the command been executed?
feature {NONE} -- Implementation
affected_objects_imp: like affected_objects
-- List of objects affected by Current
end