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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_external_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: 24211 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "A command that calls an external executable"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: "Xavier Rousselot"
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_EXTERNAL_COMMAND
11
12 inherit
13 EB_MENUABLE_COMMAND
14
15 EB_SHARED_WINDOW_MANAGER
16 export
17 {NONE} all
18 end
19
20 SHARED_EXEC_ENVIRONMENT
21 export
22 {NONE} all
23 end
24
25 EB_SHARED_INTERFACE_TOOLS
26 export
27 {NONE} all
28 end
29
30 EB_SHARED_PREFERENCES
31 export
32 {NONE} all
33 end
34
35 SHARED_PLATFORM_CONSTANTS
36 export
37 {NONE} all
38 end
39
40 EB_SHARED_MANAGERS
41
42 EB_SHARED_PIXMAPS
43
44 SHARED_WORKBENCH
45
46 create
47 make,
48 make_from_string,
49 make_from_new_command_line,
50 make_and_run_only
51
52 feature {NONE} -- Initialization
53
54 make (w: EV_WINDOW) is
55 -- Initialize `Current'.
56 -- Pop up a dialog modal to `w' to let the user initialize `Current'
57 require
58 valid_window: w /= Void
59 do
60 old_index := -1
61 create_dialog
62
63 -- Find first available index for new command.
64
65 from
66 index := 0
67 until
68 index > 9 or commands.item (index) = Void
69 loop
70 index := index + 1
71 end
72 index_field.set_value (index)
73 dialog.show_modal_to_window (w)
74
75 if is_valid then
76 -- Automatically add `Current' to the list of commands.
77 commands.put (Current, index)
78 end
79 enable_sensitive
80 external_output_manager.synchronize_command_list (Current)
81 end
82
83 make_from_new_command_line (w:EV_WINDOW; cmd_line: STRING) is
84 -- Use command line indicated by `cmd_line' to make a new
85 -- external command object.
86 require
87 w_not_null: w /= Void
88 cmd_line_not_null: cmd_line /= Void
89 do
90 old_index := -1
91 create_dialog
92
93 -- Find first available index for new command.
94 from
95 index := 0
96 until
97 index > 9 or commands.item (index) = Void
98 loop
99 index := index + 1
100 end
101 index_field.set_value (index)
102 command_field.set_text (cmd_line)
103 dialog.show_modal_to_window (w)
104
105 if is_valid then
106 -- Automatically add `Current' to the list of commands.
107 commands.put (Current, index)
108 end
109 enable_sensitive
110 write_to_preference
111 external_output_manager.synchronize_command_list (Current)
112 end
113
114 make_from_string (a_command: STRING) is
115 -- Create with `a_command'
116 require
117 command_not_void: a_command /= Void
118 local
119 tok: STRING
120 i, i1 ,i2: INTEGER
121 do
122 i := a_command.index_of (separator, 1)
123 name := a_command.substring (1, i - 1)
124 i1 := a_command.index_of (separator, i + 1)
125 tok := a_command.substring (i + 1, i1 - 1)
126 if tok.is_integer then
127 index := tok.to_integer
128 else
129 index := -1
130 end
131 i2 := a_command.index_of (separator, i1 + 1)
132
133 external_command := a_command.substring (i1 + 1, i2 - 1)--a_command.count)
134 if i2 = a_command.count then
135 working_directory := ""
136 else
137 working_directory := a_command.substring (i2 + 1, a_command.count)
138 end
139 -- Check validity before inserting.
140 -- This is a bit redundant with the precondition, but
141 -- you never know what a David Hollenberg is capable of ^.^;;
142 if
143 is_valid
144 then
145 commands.put (Current, index)
146 enable_sensitive
147 end
148 end
149
150 make_and_run_only (cmd: STRING; dir: STRING) is
151 -- Create for running `cmd' in directory `dir'.
152 -- Do not save external command and its working directory to preference.
153 require
154 cmd_not_void: cmd /= Void
155 cmd_not_empty: not cmd.is_empty
156 do
157 set_command (cmd)
158 set_working_directory (dir)
159 execute
160 end
161
162 feature -- Basic operations
163
164 write_to_preference is
165 -- Write `Current' external command to preference.
166 local
167 i: INTEGER
168 do
169 from
170 until
171 i > 9
172 loop
173 if commands @ i = Current then
174 preferences.external_command_data.i_th_external_preference (i).set_value ((commands @ i).resource)
175 -- else
176 -- -- We use an empty string as value, because this is how the
177 -- -- preferences are initialized. That way, the entry is actually
178 -- -- removed from the preferences.
179 -- preferences.external_command_data.i_th_external_preference (i).set_value ("")
180 end
181 i := i + 1
182 end
183 end
184
185 feature{NONE} -- Command substitution
186
187 substitute_command (cmd: STRING; sub_str: STRING; hdr: PROCEDURE [ANY, TUPLE]) is
188 -- if `cmd' has substring `sub_str', call agent handler `hdr'.
189 require
190 cmd_not_void: cmd /= Void
191 sub_str_not_void: sub_str /= Void
192 hdr_not_void: hdr /= Void
193 local
194 l_str: STRING
195 l_index: INTEGER
196 s_index: INTEGER
197 do
198 l_str := cmd.as_lower
199 s_index := 1
200 l_index := l_str.substring_index (sub_str, s_index)
201 if l_index > 0 then
202 from
203
204 until
205 l_index = 0
206 loop
207 l_str.replace_substring (sub_str, l_index, l_index + sub_str.count - 1)
208 cmd.replace_substring (sub_str, l_index, l_index + sub_str.count - 1)
209 s_index := l_index + sub_str.count
210 l_index := l_str.substring_index (sub_str, s_index)
211 end
212 hdr.call ([cmd, sub_str])
213 end
214 end
215
216 sub_string_list: ARRAYED_LIST [STRING] is
217 -- List of string used for command substitution.
218 once
219 create Result.make (7)
220 Result.extend ("$class_name")
221 Result.extend ("$file_name")
222 Result.extend ("$directory_name")
223 Result.extend ("$w_code")
224 Result.extend ("$f_code")
225 Result.extend ("$group_path")
226 Result.extend ("$line")
227 end
228
229 sub_action_list: ARRAYED_LIST [ PROCEDURE [ANY, TUPLE]] is
230 -- List of actions used for command substitution
231 once
232 create Result.make (7)
233 Result.extend (agent on_substitute_class_name)
234 Result.extend (agent on_substitute_file_name)
235 Result.extend (agent on_substitute_directory_name)
236 Result.extend (agent on_substitute_w_code)
237 Result.extend (agent on_substitute_f_code)
238 Result.extend (agent on_substitute_group_path)
239 Result.extend (agent on_substitute_line)
240 end
241
242 sub_class_name: INTEGER is 1
243 sub_file_name: INTEGER is 2
244 sub_directory_name: INTEGER is 3
245 sub_w_code: INTEGER is 4
246 sub_f_code: INTEGER is 5
247 sub_group_path: INTEGER is 6
248 sub_line: INTEGER is 7
249
250 show_warning_dialog (msg: STRING) is
251 -- Show a warning dialog to display `msg'.
252 local
253 wdlg: EV_WARNING_DIALOG
254 do
255 create wdlg.make_with_text (msg)
256 wdlg.show_modal_to_window (window_manager.last_focused_development_window.window)
257 end
258
259 on_substitute_group_path (cmd: STRING; sub_str: STRING) is
260 -- If `cmd' has substring (case insensitive' `sub_str',
261 -- call an agent to substitute it.
262 require
263 is_command_ok_is_true: is_command_ok = True
264 cmd_attached: cmd /= Void
265 sub_str_attached: sub_str /= Void
266 local
267 cv_cst: CLASSI_STONE
268 dev: EB_DEVELOPMENT_WINDOW
269 l_dir: STRING
270 do
271 dev := Window_manager.last_focused_development_window
272 if dev /= Void then
273 cv_cst ?= dev.stone
274 if cv_cst /= Void then
275 l_dir := cv_cst.class_i.group.location.evaluated_directory
276 cmd.replace_substring_all (sub_string_list.i_th (sub_group_path), l_dir)
277 else
278 set_is_command_ok (False)
279 show_warning_dialog (Warning_messages.w_Command_needs_directory)
280 end
281 else
282 set_is_command_ok (False)
283 end
284 end
285
286 on_substitute_class_name (cmd: STRING; sub_str: STRING) is
287 -- If `cmd' has substring (case insensitive) `sub_str',
288 -- call an agent to substitute it.
289 require
290 is_command_ok_is_true: is_command_ok = True
291 cmd_attached: cmd /= Void
292 sub_str_attached: sub_str /= Void
293 local
294 cn: STRING
295 dev: EB_DEVELOPMENT_WINDOW
296 do
297 dev := Window_manager.last_focused_development_window
298 if dev /= Void then
299 cn := dev.class_name
300 if cn = Void or else cn.is_empty then
301 set_is_command_ok (False)
302 show_warning_dialog (Warning_messages.w_Command_needs_class)
303 else
304 cmd.replace_substring_all (sub_string_list.i_th (sub_class_name), cn)
305 end
306 else
307 set_is_command_ok (False)
308 end
309 end
310
311 on_substitute_file_name (cmd: STRING; sub_str: STRING) is
312 -- If `cmd' has substring (case insensitive) `sub_str',
313 -- call an agent to substitute it.
314 require
315 is_command_ok_is_true: is_command_ok = True
316 cmd_attached: cmd /= Void
317 sub_str_attached: sub_str /= Void
318 local
319 cv_cst: CLASSI_STONE
320 dev: EB_DEVELOPMENT_WINDOW
321 do
322 dev := Window_manager.last_focused_development_window
323 if dev /= Void then
324 cv_cst ?= dev.stone
325 if cv_cst /= Void then
326 cmd.replace_substring_all (sub_string_list.i_th (sub_file_name), cv_cst.class_i.file_name)
327 else
328 set_is_command_ok (False)
329 show_warning_dialog (Warning_messages.w_Command_needs_file)
330 end
331 else
332 set_is_command_ok (False)
333 end
334 end
335
336 on_substitute_directory_name (cmd: STRING; sub_str: STRING) is
337 -- If `cmd' has substring (case insensitive) `sub_str',
338 -- call an agent to substitute it.
339 require
340 is_command_ok_is_true: is_command_ok = True
341 cmd_attached: cmd /= Void
342 sub_str_attached: sub_str /= Void
343 local
344 cv_cst: CLASSI_STONE
345 dev: EB_DEVELOPMENT_WINDOW
346 l_dir: STRING
347 l_path: STRING
348 do
349 dev := Window_manager.last_focused_development_window
350 if dev /= Void then
351 cv_cst ?= dev.stone
352 if cv_cst /= Void then
353 l_dir := cv_cst.class_i.group.location.evaluated_directory
354 l_path := cv_cst.class_i.config_class.path
355 l_path.replace_substring_all ("/", directory_separator.out)
356 l_dir.append (l_path)
357 cmd.replace_substring_all (sub_string_list.i_th (sub_directory_name), l_dir)
358 else
359 set_is_command_ok (False)
360 show_warning_dialog (Warning_messages.w_Command_needs_directory)
361 end
362 else
363 set_is_command_ok (False)
364 end
365 end
366
367 on_substitute_w_code (cmd: STRING; sub_str: STRING) is
368 -- If `cmd' has substring (case insensitive) `sub_str',
369 -- call an agent to substitute it.
370 require
371 is_command_ok_is_true: is_command_ok = True
372 cmd_attached: cmd /= Void
373 sub_str_attached: sub_str /= Void
374 do
375 if workbench.system_defined then
376 cmd.replace_substring_all (sub_string_list.i_th (sub_w_code), project_location.workbench_path)
377 else
378 show_warning_dialog (Warning_messages.w_no_system_defined)
379 set_is_command_ok (False)
380 end
381 end
382
383 on_substitute_f_code (cmd: STRING; sub_str: STRING) is
384 -- If `cmd' has substring (case insensitive) `sub_str',
385 -- call an agent to substitute it.
386 require
387 is_command_ok_is_true: is_command_ok = True
388 cmd_attached: cmd /= Void
389 sub_str_attached: sub_str /= Void
390 do
391 if workbench.system_defined then
392 cmd.replace_substring_all (sub_string_list.i_th (sub_f_code), project_location.final_path)
393 else
394 show_warning_dialog (Warning_messages.w_no_system_defined)
395 set_is_command_ok (False)
396 end
397 end
398
399 on_substitute_line (cmd: STRING; sub_str: STRING) is
400 -- If `cmd' has substring (case insensitive) `sub_str',
401 -- call an agent to substitute it.
402 require
403 is_command_ok_is_true: is_command_ok = True
404 cmd_attached: cmd /= Void
405 sub_str_attached: sub_str /= Void
406 local
407 dev: EB_DEVELOPMENT_WINDOW
408 l_text_area: EB_SMART_EDITOR
409 do
410 dev := Window_manager.last_focused_development_window
411 if dev /= Void then
412 l_text_area := dev.editors_manager.current_editor
413 if l_text_area /= Void and then not l_text_area.is_empty then
414 cmd.replace_substring_all (sub_string_list.i_th (sub_line), l_text_area.cursor_y_position.out)
415 end
416 else
417 set_is_command_ok (False)
418 end
419 end
420
421 is_command_ok: BOOLEAN is
422 -- Is command valid (when string substitution is needed)?
423 do
424 Result := command_ok_cell.item
425 end
426
427 set_is_command_ok (b: BOOLEAN) is
428 -- Set `is_command_ok' with `b'.
429 do
430 command_ok_cell.put (b)
431 end
432
433 feature{NONE}
434
435 command_ok_cell: CELL [BOOLEAN] is
436 -- Cell to store Value of `is_command_ok'
437 once
438 create Result.put (False)
439 end
440
441 prepare_command (cmd: STRING; dir: STRING) is
442 -- Prepare external command `cmd', do stirng substitution if needed.
443 do
444 from
445 set_is_command_ok (True)
446 sub_string_list.start
447 sub_action_list.start
448 until
449 sub_string_list.after or sub_action_list.after or not is_command_ok
450 loop
451 substitute_command (cmd, sub_string_list.item, sub_action_list.item)
452 if is_command_ok then
453 substitute_command (dir, sub_string_list.item, sub_action_list.item)
454 end
455 sub_string_list.forth
456 sub_action_list.forth
457 end
458 end
459
460 feature -- Execution
461
462 execute is
463 -- Launch the external command that is linked to `Current', if possible.
464 local
465 cl: STRING
466 od: STRING
467 exec: EXECUTION_ENVIRONMENT
468 cmdexe: STRING
469 wd: STRING
470 args: LIST [STRING]
471 use_argument: BOOLEAN
472 do
473 if external_launcher.launched and then not external_launcher.has_exited then
474 show_warning_dialog (interface_names.e_external_command_is_running)
475 else
476 create cl.make (external_command.count + 20)
477 if working_directory /= Void then
478 create wd.make (working_directory.count + 20)
479 wd.append (working_directory)
480 else
481 wd := ""
482 end
483 cl.append (external_command)
484 external_launcher.set_original_command_name (cl)
485
486 prepare_command (cl, wd)
487
488 if is_command_ok then
489 create exec
490 od := exec.current_working_directory
491
492 if platform_constants.is_windows then
493 cmdexe := Execution_environment.get ("COMSPEC")
494 if cmdexe /= Void then
495 -- This allows the use of `dir' etc.
496 create {ARRAYED_LIST [STRING]}args.make (1)
497 args.extend ("/c%""+cl+"%"")
498 external_launcher.prepare_command_line (cmdexe, args, wd)
499 use_argument := True
500 else
501 external_launcher.prepare_command_line (cl, Void, wd)
502 use_argument := False
503 end
504 else
505 create {ARRAYED_LIST [STRING]}args.make (2)
506 args.extend ("-c")
507 args.extend ("%'%'"+cl+"%'%'")
508 external_launcher.prepare_command_line ("/bin/sh", args, wd)
509 use_argument := True
510 end
511 external_launcher.set_hidden (True)
512 external_launcher.launch (True, use_argument)
513 exec.change_working_directory (od)
514 end
515 end
516 end
517
518 feature -- Properties
519
520 menu_name: STRING is
521 -- Representation of `Current' in menus.
522 do
523 create Result.make (name.count + 15)
524 Result.append_character ('&')
525 Result.append (index.out)
526 Result.append_character (' ')
527 Result.append (name)
528 Result.append (Tabulation)
529 Result.append ((create {EB_EXTERNAL_COMMANDS_EDITOR}.make).accelerators.item (index).out)
530 end
531
532 pixmap: EV_PIXMAP
533 -- Pixmap
534
535 name: STRING
536 -- Name that the user gave to this command.
537
538 index: INTEGER
539 -- Index of `Current' in the global list of known external commands.
540
541 external_command: STRING
542 -- Command line that is invoked when `Current' is executed.
543
544 working_directory: STRING
545 -- Working director where the corresponding external command is invoked.
546
547 last_call_output: STRING
548 -- Output of the last invocation of command.
549
550 feature -- Status setting
551
552 edit_properties (w: EV_WINDOW) is
553 -- Pop up a dialog, modal to `w', that lets the user
554 -- edit the properties of `Current' (menu name, called command and index)
555 require
556 w_not_void: w /= void
557 do
558 create_dialog
559 if name /= Void then
560 name_field.set_text (name)
561 end
562 index_field.set_value (index)
563 if external_command /= Void then
564 command_field.set_text (external_command)
565 end
566 if working_directory /= Void then
567 working_directory_field.set_text (working_directory)
568 end
569 old_index := index
570 dialog.show_modal_to_window (w)
571 if is_valid then
572 if old_index /= index then
573 commands.put (Void, old_index)
574 commands.put (Current, index)
575 end
576 end
577 old_index := -1
578 write_to_preference
579 external_output_manager.synchronize_command_list (Current)
580 end
581
582 feature{EB_EXTERNAL_OUTPUT_TOOL} -- Status setting
583
584 set_command (cmd: STRING) is
585 -- Set `external_command' with `cmd'.
586 require
587 cmd_not_void: cmd /= Void
588 cmd_not_empty: not cmd.is_empty
589 do
590 create external_command.make_from_string (cmd)
591 ensure
592 external_command_set: external_command.is_equal (cmd)
593 end
594
595 set_working_directory (dir: STRING) is
596 -- Set `working_directory' with `dir'.
597 do
598 if dir /= Void then
599 create working_directory.make_from_string (dir)
600 else
601 working_directory := Void
602 end
603 ensure
604 working_directory_set:
605 ((dir /= Void) implies working_directory.is_equal (dir)) and
606 ((dir = Void) implies working_directory = Void)
607 end
608
609 set_accelerator (accel: EV_ACCELERATOR) is
610 -- Set `accelerator' to `accel'.
611 do
612 accelerator := accel
613 end
614
615 feature -- Status report
616
617 resource: STRING is
618 -- Save `Current's information to a string representation.
619 do
620 create Result.make (menu_name.count + external_command.count + 10)
621 Result.append (name)
622 Result.append_character (separator)
623 Result.append (index.out)
624 Result.append_character (separator)
625 Result.append (external_command)
626 -- Store `working_directory' to preference.
627 Result.append_character (separator)
628 if working_directory /= Void then
629 Result.append (working_directory)
630 else
631 Result.append ("")
632 end
633 ensure
634 not_void: Result /= Void
635 valid: valid_resource (Result)
636 end
637
638 valid_resource (r: STRING): BOOLEAN is
639 -- Is `r' a valid resource representation of an external command?
640 require
641 not_void_resource: r /= Void
642 do
643 Result := r.occurrences (separator) = 3
644 end
645
646 is_valid: BOOLEAN is
647 -- Is `Current' a valid command?
648 do
649 Result := index >= 0 and
650 index < 10 and
651 name /= Void and
652 external_command /= Void and then
653 (not name.is_empty and not external_command.is_empty)
654 end
655
656 feature {NONE} -- Widgets
657
658 dialog: EV_DIALOG
659 -- Dialog that lets the user edit `Current's properties.
660
661 name_field: EV_TEXT_FIELD
662 -- Text field where the user can enter `name'.
663
664 index_field: EV_SPIN_BUTTON
665 -- Text field where the user can enter `index'.
666
667 command_field: EV_TEXT_FIELD
668 -- Text field where the user can enter `external_command'.
669
670 working_directory_field: EV_TEXT_FIELD
671 -- Text field where the user can enter `working_directory'
672
673 feature {NONE} -- Implementation
674
675 separator: CHARACTER is '['
676 -- Separator in resource representation.
677
678 commands: ARRAY [EB_EXTERNAL_COMMAND] is
679 -- Abstract representation of external commands.
680 do
681 Result := (create {EB_EXTERNAL_COMMANDS_EDITOR}.make).commands
682 end
683
684 dir_dlg: EV_DIRECTORY_DIALOG
685
686 create_directory_dialog is
687 --
688 do
689 create dir_dlg.make_with_title ("Select working directory")
690 dir_dlg.ok_actions.extend (agent on_directory_dialog_ok)
691 dir_dlg.show_modal_to_window (dialog)
692 end
693
694 on_directory_dialog_ok is
695 --
696 do
697 if dir_dlg /= Void then
698 working_directory := dir_dlg.directory
699 working_directory_field.set_text (working_directory)
700 dir_dlg.destroy
701 end
702
703 end
704
705 create_dialog is
706 -- Initialize `dialog' and all widgets.
707 local
708 hb, hb1: EV_HORIZONTAL_BOX
709 vb: EV_VERTICAL_BOX
710 f: EV_FRAME
711 okb, cb: EV_BUTTON
712 nl, il, cl, wd: EV_LABEL
713 sz: INTEGER
714 dir_btn: EV_BUTTON
715 do
716 -- Create widgets.
717 create dialog
718 create okb.make_with_text (Interface_names.B_ok)
719 create cb.make_with_text (Interface_names.B_cancel)
720 create nl.make_with_text (Interface_names.l_name_colon)
721 create il.make_with_text (Interface_names.l_index)
722 create cl.make_with_text (Interface_names.l_Command_line)
723 create name_field
724 create index_field.make_with_value_range (0 |..| 9)
725 create command_field
726
727 create hb1.default_create
728 create working_directory_field
729 create wd.make_with_text ("Working directory:")
730 wd.align_text_left
731 create dir_btn.default_create
732 dir_btn.set_pixmap (pixmaps.icon_pixmaps.general_open_icon)
733 dir_btn.select_actions.extend (agent create_directory_dialog)
734 hb1.extend (working_directory_field)
735 hb1.extend (dir_btn)
736 hb1.disable_item_expand (dir_btn)
737
738 -- Organize widgets.
739 sz := nl.minimum_width.max (il.minimum_width)
740 nl.set_minimum_width (sz)
741 il.set_minimum_width (sz)
742 create vb
743 vb.set_padding (Layout_constants.Small_padding_size)
744 vb.set_border_width (Layout_constants.Small_border_size)
745 create hb
746 hb.set_padding (Layout_constants.Small_padding_size)
747 hb.extend (nl)
748 hb.disable_item_expand (nl)
749 hb.extend (name_field)
750 vb.extend (hb)
751 create hb
752 hb.set_padding (Layout_constants.Small_padding_size)
753 hb.extend (il)
754 hb.disable_item_expand (il)
755 hb.extend (index_field)
756 vb.extend (hb)
757 vb.extend (cl)
758 vb.extend (command_field)
759 vb.extend (wd)
760 vb.extend (hb1)
761
762 create f
763 f.set_style ({EV_FRAME_CONSTANTS}.Ev_frame_etched_in)
764 f.extend (vb)
765
766 create hb
767 hb.set_padding (Layout_constants.Default_padding_size)
768 hb.extend (create {EV_CELL})
769 hb.extend (okb)
770 hb.disable_item_expand (okb)
771 hb.extend (cb)
772 hb.disable_item_expand (cb)
773 hb.extend (create {EV_CELL})
774
775 create vb
776 vb.set_padding (Layout_constants.Small_padding_size)
777 vb.set_border_width (Layout_constants.Small_border_size)
778 vb.extend (f)
779 vb.extend (hb)
780 dialog.extend (vb)
781
782 -- Set widget properties.
783 nl.align_text_left
784 il.align_text_left
785 cl.align_text_left
786 Layout_constants.set_default_size_for_button (okb)
787 Layout_constants.set_default_size_for_button (cb)
788 dialog.set_title (Interface_names.t_External_command)
789 dialog.set_icon_pixmap (pixmaps.icon_pixmaps.tool_external_commands_icon)
790 dialog.set_maximum_height (dialog.minimum_height)
791 dialog.set_default_push_button (okb)
792 dialog.set_default_cancel_button (cb)
793
794 -- Set up events.
795 okb.select_actions.extend (agent on_ok)
796 cb.select_actions.extend (agent destroy_dialog)
797
798 -- Ensure that `name_field' gets focus when dialog is displayed
799 dialog.show_actions.extend (agent name_field.set_focus)
800 end
801
802 on_ok is
803 -- User pressed OK in `dialog'.
804 -- Try to update `Current's status.
805 local
806 wd: EV_WARNING_DIALOG
807 ix: INTEGER
808 do
809 ix := index_field.value
810 if name_field.text.is_empty or command_field.text.is_empty or ix < 0 or ix > 9 then
811 create wd.make_with_text (Warning_messages.w_Invalid_options)
812 wd.show_modal_to_window (dialog)
813 else
814 if commands.item (ix) /= Void and then commands.item (ix) /= Current then
815 create wd.make_with_text (Warning_messages.w_Index_already_taken)
816 wd.show_modal_to_window (dialog)
817 else
818 name := name_field.text
819 external_command := command_field.text
820 working_directory := working_directory_field.text
821 index := index_field.value
822 destroy_dialog
823 end
824 end
825 end
826
827 destroy_dialog is
828 -- Destroy all widgets.
829 do
830 check
831 dialog /= Void
832 --| FIXME XR: We shouldn't be able to call destroy_dialog more than once, but it occurred...
833 end
834 if dialog /= Void then
835 dialog.destroy
836 end
837 dialog := Void
838 name_field := Void
839 index_field := Void
840 command_field := Void
841 end
842
843 old_index: INTEGER
844 -- Index of `Current' before we edited its properties.
845
846 directory_separator: CHARACTER is
847 -- Directory separator
848 local
849 l_obj: ANY
850 once
851 create l_obj
852 Result := l_obj.operating_environment.directory_separator
853 end
854
855 indexing
856 copyright: "Copyright (c) 1984-2006, Eiffel Software"
857 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
858 licensing_options: "http://www.eiffel.com/licensing"
859 copying: "[
860 This file is part of Eiffel Software's Eiffel Development Environment.
861
862 Eiffel Software's Eiffel Development Environment is free
863 software; you can redistribute it and/or modify it under
864 the terms of the GNU General Public License as published
865 by the Free Software Foundation, version 2 of the License
866 (available at the URL listed under "license" above).
867
868 Eiffel Software's Eiffel Development Environment is
869 distributed in the hope that it will be useful, but
870 WITHOUT ANY WARRANTY; without even the implied warranty
871 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
872 See the GNU General Public License for more details.
873
874 You should have received a copy of the GNU General Public
875 License along with Eiffel Software's Eiffel Development
876 Environment; if not, write to the Free Software Foundation,
877 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
878 ]"
879 source: "[
880 Eiffel Software
881 356 Storke Road, Goleta, CA 93117 USA
882 Telephone 805-685-1006, Fax 805-685-6869
883 Website http://www.eiffel.com
884 Customer support http://support.eiffel.com
885 ]"
886
887 end -- class EB_EXTERNAL_COMMAND

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23