/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_undo_redo_command.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_undo_redo_command.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 3976 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description : "Command to perform an undo/redo operation"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date : "$Date$"
6 revision : "$Revision $"
7
8 deferred class
9 EB_UNDO_REDO_COMMAND
10
11 inherit
12 EB_DEVELOPMENT_WINDOW_COMMAND
13 redefine
14 recycle
15 end
16
17 EB_TOOLBARABLE_AND_MENUABLE_COMMAND
18 redefine
19 new_toolbar_item,
20 new_menu_item
21 end
22
23 UNDO_REDO_OBSERVER
24 redefine
25 on_changed
26 end
27
28 feature {NONE} -- initialization
29
30 feature -- Execution
31
32 accelerator_execute is
33 -- Execute command if neccessary when called via an accelerator
34 do
35 if editor /= Void and then editor.has_focus and then is_sensitive then
36 execute
37 end
38 end
39
40 feature -- Basic operations
41
42 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
43 -- Create a new toolbar button for this command.
44 do
45 start_observer
46
47 Result := Precursor (display_text)
48 end
49
50 new_menu_item: EB_COMMAND_MENU_ITEM is
51 -- Create a new menu entry for this command.
52 do
53 start_observer
54 Result := Precursor {EB_TOOLBARABLE_AND_MENUABLE_COMMAND}
55 end
56
57 feature -- recycle
58
59 recycle is
60 -- Recycle Current
61 local
62 l_editors: ARRAYED_LIST [EB_SMART_EDITOR]
63 do
64 if observer_started and target /= Void then
65 l_editors := target.editors_manager.editors
66 from
67 l_editors.start
68 until
69 l_editors.after
70 loop
71 l_editors.item.remove_history_observer (Current)
72 l_editors.forth
73 end
74 end
75 Precursor {EB_DEVELOPMENT_WINDOW_COMMAND}
76 end
77
78 feature {NONE} -- Implementation / Observer pattern
79
80 observer_started: BOOLEAN
81 -- The observer has been set up.
82
83 start_observer is
84 -- Start observing the stack
85 do
86 if not observer_started then
87 target.editors_manager.add_history_observer (Current)
88 observer_started := True
89 -- Why should we destroy the command when destroying the window???
90 -- It is enough to destroy it when destroying the stack?!
91 -- target.add_recyclable (Current)
92 end
93 end
94
95 feature {NONE} -- Implementation
96
97 editor: EB_EDITOR is
98 -- Editor corresponding to Current
99 do
100 Result := target.editors_manager.current_editor
101 end
102
103 -- undo_redo_stack: UNDO_REDO_STACK is
104 -- -- Undo-redo stack.
105 -- do
106 -- Result := editor.history
107 -- end
108
109 on_changed is
110 -- The undo/redo stack has changed.
111 local
112 sensitive: BOOLEAN
113 operation_possible: BOOLEAN
114 do
115 sensitive := is_sensitive
116 operation_possible := executable
117
118 if sensitive and (not operation_possible) then
119 disable_sensitive
120 elseif (not sensitive) and (operation_possible) then
121 enable_sensitive
122 end
123 end
124
125 indexing
126 copyright: "Copyright (c) 1984-2006, Eiffel Software"
127 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
128 licensing_options: "http://www.eiffel.com/licensing"
129 copying: "[
130 This file is part of Eiffel Software's Eiffel Development Environment.
131
132 Eiffel Software's Eiffel Development Environment is free
133 software; you can redistribute it and/or modify it under
134 the terms of the GNU General Public License as published
135 by the Free Software Foundation, version 2 of the License
136 (available at the URL listed under "license" above).
137
138 Eiffel Software's Eiffel Development Environment is
139 distributed in the hope that it will be useful, but
140 WITHOUT ANY WARRANTY; without even the implied warranty
141 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
142 See the GNU General Public License for more details.
143
144 You should have received a copy of the GNU General Public
145 License along with Eiffel Software's Eiffel Development
146 Environment; if not, write to the Free Software Foundation,
147 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
148 ]"
149 source: "[
150 Eiffel Software
151 356 Storke Road, Goleta, CA 93117 USA
152 Telephone 805-685-1006, Fax 805-685-6869
153 Website http://www.eiffel.com
154 Customer support http://support.eiffel.com
155 ]"
156
157 end -- class EB_UNDO_REDO_COMMAND

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23