« lib/App/SeismicUnixGui/sunix/header/segyclean.pm
↑ Summary
lib/App/SeismicUnixGui/misc/developer.pm »
| 1 | package App::SeismicUnixGui::misc::file_dialog; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | PERL PERL PROGRAM NAME: file_dialog.pm | ||
| 7 | AUTHOR: Juan Lorenzo | ||
| 8 | DATE: May 16 2018 | ||
| 9 | |||
| 10 | DESCRIPTION | ||
| 11 | |||
| 12 | BASED ON: | ||
| 13 | |||
| 14 | previous version (V 0.0.1) of the main L_SU.pl (V 0.3) | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | =head2 USE | ||
| 19 | |||
| 20 | =head3 NOTES | ||
| 21 | |||
| 22 | =head4 Examples | ||
| 23 | |||
| 24 | |||
| 25 | =head2 CHANGES and their DATES | ||
| 26 | |||
| 27 | V 0.0.3refactoring of 2017 version of L_SU.pl | ||
| 28 | |||
| 29 | Feb 24 2020 | ||
| 30 | V 0.0.4 incldue PL_SEISMIC as a file_dialog_type | ||
| 31 | This new file dialog type automatically opens | ||
| 32 | PL_SEISMIC path. | ||
| 33 | |||
| 34 | August 2021 | ||
| 35 | initialize default values | ||
| 36 | |||
| 37 | V 0.0.5 | ||
| 38 | flow-selection is detectable with a subroutine | ||
| 39 | hool _SelHook | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | use Moose; | ||
| 44 | our $VERSION = '0.0.4'; | ||
| 45 | |||
| 46 | use Tk::JFileDialog; | ||
| 47 | |||
| 48 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 49 | use aliased 'App::SeismicUnixGui::misc::iFile'; | ||
| 50 | |||
| 51 | use App::SeismicUnixGui::misc::decisions '1.0.0'; | ||
| 52 | use aliased 'App::SeismicUnixGui::misc::decisions'; | ||
| 53 | |||
| 54 | use aliased 'App::SeismicUnixGui::messages::message_director'; | ||
| 55 | |||
| 56 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 57 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 58 | |||
| 59 | use aliased 'App::SeismicUnixGui::misc::param_widgets'; | ||
| 60 | use aliased 'App::SeismicUnixGui::misc::whereami'; | ||
| 61 | use aliased 'App::SeismicUnixGui::misc::whereami2'; | ||
| 62 | use aliased 'App::SeismicUnixGui::misc::param_widgets4pre_built_streams'; | ||
| 63 | use aliased 'App::SeismicUnixGui::misc::dirs'; | ||
| 64 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 65 | |||
| 66 | extends 'App::SeismicUnixGui::misc::gui_history' => { -version => 0.0.2 }; | ||
| 67 | use aliased 'App::SeismicUnixGui::misc::gui_history'; | ||
| 68 | |||
| 69 | my $decisions = decisions->new(); | ||
| 70 | my $L_SU_global_constants = L_SU_global_constants->new(); | ||
| 71 | my $gui_history = gui_history->new(); | ||
| 72 | my $iFile = iFile->new(); | ||
| 73 | my $control = control->new(); | ||
| 74 | |||
| 75 | my $file_dialog_type = $L_SU_global_constants->file_dialog_type_href(); | ||
| 76 | my $flow_type_h = $L_SU_global_constants->flow_type_href(); | ||
| 77 | my $var = $L_SU_global_constants->var(); | ||
| 78 | my $empty_string = $var->{_empty_string}; | ||
| 79 | my $on = $var->{_on}; | ||
| 80 | my $true = $var->{_true}; | ||
| 81 | my $false = $var->{_false}; | ||
| 82 | my $superflow_names = $L_SU_global_constants->superflow_names_h(); | ||
| 83 | |||
| 84 | =head2 Declare | ||
| 85 | local variables | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | my $file_dialog = $gui_history->get_defaults(); | ||
| 90 | |||
| 91 | # print("param_widgets_neutral, default_param_specs,first entry num=$default_param_specs->{_first_entry_num}\n"); | ||
| 92 | |||
| 93 | =head2 private hash | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | $file_dialog = { | ||
| 98 | |||
| 99 | _check_buttons_settings_aref => '', | ||
| 100 | _flow_name_in => '', | ||
| 101 | _is_file_selected => '', | ||
| 102 | _selected_file_name => '', | ||
| 103 | _last_path_touched => '', | ||
| 104 | |||
| 105 | }; | ||
| 106 | |||
| 107 | =head2 private variables | ||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | my $user_built_flow_open_data_widget_type; | ||
| 112 | my $user_built_flow_open_data_selected_Entry_widget; | ||
| 113 | my $user_built_flow_open_data_parameter_value_index; | ||
| 114 | |||
| 115 | =head2 sub _FileDialog | ||
| 116 | |||
| 117 | Collects name of file to be opened | ||
| 118 | Mega-widget | ||
| 119 | |||
| 120 | print ("my file is $file_dialog->{_selected_file_name}\n"); | ||
| 121 | will NOT: | ||
| 122 | print ("1. label is @{$file_dialog->{_ref_labels_w}}[$first]->cget('-text') \n"); | ||
| 123 | |||
| 124 | WILL print: | ||
| 125 | print ("2. label is $out\n"); | ||
| 126 | |||
| 127 | $who[$first] = $parameter_values_frame->focusCurrent; | ||
| 128 | print("who is $who[$first]\n"); | ||
| 129 | if ($who[$first] eq @{$file_dialog->{_ref_values_w}}[$first]) { | ||
| 130 | print("who is also @{$file_dialog->{_ref_values_w}}[$first]\n"); | ||
| 131 | print ("2. label is $out\n"); | ||
| 132 | } | ||
| 133 | |||
| 134 | Assume that file name in labels is always first | ||
| 135 | print ("1. Full path is $file_dialog->{_selected_file_name}\n"); | ||
| 136 | |||
| 137 | 'Cancel' returns undefined file name | ||
| 138 | |||
| 139 | =cut | ||
| 140 | |||
| 141 | sub _FileDialog { | ||
| 142 | |||
| 143 | my ($self) = @_; | ||
| 144 | my $my_title = | ||
| 145 | _get_dialog_type(); # e.g., 'SaveAs' or 'Save', 'Open' or 'Delete' | ||
| 146 | my $path_w_ticks = _get_path(); # $PL, $DATA_SEISMIC_SU or $HOME etc. | ||
| 147 | |||
| 148 | # JFileDialog does not tolerate ending '/' | ||
| 149 | # JFileDialog does not tolerate path names enclosed with ticks | ||
| 150 | $control->set_infection($path_w_ticks); | ||
| 151 | my $path_no_ticks = $control->get_ticksBgone(); | ||
| 152 | $control->set_path( $path_no_ticks); | ||
| 153 | my $FileDialog_path = $control->get_path_wo_last_slash(); | ||
| 154 | |||
| 155 | # Can be for a data or pl directory or for only a directory | ||
| 156 | # print("file_dialog,_FileDialog, path: $file_dialog->{_path}\n"); | ||
| 157 | # print("file_dialog,_FileDialog, path: $FileDialog_path\n"); | ||
| 158 | # print("file_dialog,_FileDialog, mytitle: $my_title\n"); | ||
| 159 | |||
| 160 | my $fileDialog_w = $file_dialog->{_mw}->JFileDialog( | ||
| 161 | -Title => $my_title, | ||
| 162 | -Path => $FileDialog_path, | ||
| 163 | -History => 12, | ||
| 164 | -HistDeleteOk => 1, | ||
| 165 | -HistUsePath => 1, | ||
| 166 | -SelDir => 2, # dir or files will be selected | ||
| 167 | -SelHook => \&_SelHook, | ||
| 168 | -HistFile => "./.FileHistory.txt", | ||
| 169 | -PathFile => "./.Bookmarks.txt", | ||
| 170 | -Create => 1, | ||
| 171 | -width => 60, | ||
| 172 | -maxwidth => 60, # characters | ||
| 173 | |||
| 174 | ); | ||
| 175 | |||
| 176 | # Results from interactive file selection | ||
| 177 | # If Cancel is selected, an undefined value for the file name is returned | ||
| 178 | $file_dialog->{_selected_file_name} = $fileDialog_w->Show(); | ||
| 179 | $file_dialog->{_last_path_touched} = $fileDialog_w->cget('-Path'); | ||
| 180 | |||
| 181 | =head2 sub _SelHook | ||
| 182 | |||
| 183 | confirm that a file was selected | ||
| 184 | print( | ||
| 185 | "file_dialog,_FileDialog,last path is | ||
| 186 | $file_dialog->{_last_path_touched} \n" | ||
| 187 | ); | ||
| 188 | |||
| 189 | =cut | ||
| 190 | |||
| 191 | sub _SelHook { | ||
| 192 | |||
| 193 | my ($pathNfile) = @_; | ||
| 194 | |||
| 195 | my $result; | ||
| 196 | |||
| 197 | if ( defined $pathNfile ) { | ||
| 198 | |||
| 199 | $result = $true; | ||
| 200 | # print("file_dialog,SelHook, pathNfile =$pathNfile \n"); | ||
| 201 | $file_dialog->{_is_file_selected} = $true; | ||
| 202 | |||
| 203 | } | ||
| 204 | else { | ||
| 205 | $file_dialog->{_is_file_selected} = $false; | ||
| 206 | $result = $false; | ||
| 207 | } | ||
| 208 | |||
| 209 | # print("file_dialog,SelHook, result=$result\n"); | ||
| 210 | return ($result); | ||
| 211 | } | ||
| 212 | |||
| 213 | if ( not( defined( $file_dialog->{_selected_file_name} ) ) ) { | ||
| 214 | |||
| 215 | # Case that the Dialog is cancelled by user | ||
| 216 | $file_dialog->{_is_file_selected} = $false; | ||
| 217 | } | ||
| 218 | |||
| 219 | return ($empty_string); | ||
| 220 | } | ||
| 221 | |||
| 222 | =head2 _big_stream_Home | ||
| 223 | |||
| 224 | =cut | ||
| 225 | |||
| 226 | sub _big_stream_Home { | ||
| 227 | |||
| 228 | my ($self) = @_; | ||
| 229 | |||
| 230 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 231 | my $whereami = whereami->new(); | ||
| 232 | |||
| 233 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 234 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 235 | my $length = $default_param_specs->{_length}; | ||
| 236 | |||
| 237 | $gui_history->set_hash_ref($file_dialog); | ||
| 238 | $gui_history->set4FileDialog_open_start(); | ||
| 239 | $gui_history->set4superflow_open_path_start(); | ||
| 240 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 241 | |||
| 242 | # If an appropriate Entry widget is first selected, | ||
| 243 | # Find out which entry button has been chosen (index) | ||
| 244 | # Confirm that it IS the file button | ||
| 245 | |||
| 246 | # print("file_dialog,_big_stream_Home,_FileDialog_button pressed, \n"); | ||
| 247 | # print("file_dialog, _big_stream_Home selected _values_aref=@{$file_dialog->{_values_aref}}\n"); | ||
| 248 | # print("file_dialog, _big_stream_Home selected _values_aref=@{$file_dialog->{_names_aref}}\n"); | ||
| 249 | # print("file_dialog _big_stream_Home selected parameter_values_frame = $file_dialog->{_parameter_values_frame} \n"); | ||
| 250 | |||
| 251 | my $widget_type = | ||
| 252 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 253 | |||
| 254 | # print("file_dialog _big_stream_Home selected widget type is = $widget_type \n"); | ||
| 255 | |||
| 256 | if ( $widget_type eq 'Entry' ) { | ||
| 257 | |||
| 258 | # print("1. file_dialog,_big_stream_Home, selected widget_type=$widget_type \n"); | ||
| 259 | |||
| 260 | my $selected_Entry_widget = | ||
| 261 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 262 | $param_widgets->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 263 | |||
| 264 | # Need to set the length and first_idx or, $param-widgets->set_length($file_dialog_length); | ||
| 265 | # print("file_dialog,_big_stream_Home,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 266 | # print("file_dialog,_big_stream_Home, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 267 | |||
| 268 | $param_widgets->set_first_idx($first_idx); | ||
| 269 | $param_widgets->set_length($length); | ||
| 270 | |||
| 271 | # print("2. file_dialog _big_stream_Home, selected_Entry_widget: $selected_Entry_widget\n"); | ||
| 272 | |||
| 273 | $file_dialog->{_parameter_value_index} = | ||
| 274 | $param_widgets->get_entry_button_chosen_index(); | ||
| 275 | |||
| 276 | # print("file_dialog,_big_stream_Home,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 277 | # print("file_dialog,_big_stream_Home, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 278 | |||
| 279 | if ( $file_dialog->{_parameter_value_index} >= 0 ) | ||
| 280 | { # for additional certainty; but is it needed? | ||
| 281 | # print("4. file_dialog,ig_stream_last_dir_in_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 282 | $file_dialog->{_entry_button_label} = | ||
| 283 | $param_widgets->get_label4entry_button_chosen(); | ||
| 284 | |||
| 285 | # print("5. file_dialog,_big_stream_Home,entry_button_label = $file_dialog->{_entry_button_label}\n"); | ||
| 286 | |||
| 287 | # use iFileuse aliased 'determine the Path stored in the current configuration file | ||
| 288 | $iFile->set_entry($file_dialog); # selected entry label | ||
| 289 | $iFile->set_flow_type_h($file_dialog); # a pre-built superflow | ||
| 290 | $iFile->set_parameter_value_index($file_dialog); # e.g., 0 | ||
| 291 | $iFile->set_values_aref($file_dialog); # e.g., /home/gom/ | ||
| 292 | $iFile->set_prog_name_sref($file_dialog); # e.g., Project_config | ||
| 293 | |||
| 294 | $file_dialog->{_path} = $iFile->get_Path(); | ||
| 295 | |||
| 296 | # print("1.file_dialog,_pre-built_superflow_path, PATH: $file_dialog->{_path} \n"); | ||
| 297 | |||
| 298 | # print("1.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 299 | |||
| 300 | _FileDialog(); # open file dialog mega-widget | ||
| 301 | |||
| 302 | # print("2.file_dialog,_pre-built_superflow_path, last_path_touched: $file_dialog->{_last_path_touched} \n"); | ||
| 303 | |||
| 304 | _big_stream_Home_close(); | ||
| 305 | |||
| 306 | # print("2.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 307 | # my $length= scalar @{$file_dialog->{_values_aref}}; # 61 values | ||
| 308 | # for (my $i=0; $i < $length; $i++) { | ||
| 309 | # print("3.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[$i]\n"); | ||
| 310 | # } | ||
| 311 | } | ||
| 312 | |||
| 313 | } | ||
| 314 | elsif ( $widget_type eq 'MainWindow' ) { # opening a random file | ||
| 315 | |||
| 316 | # print("file_dialog,_big_stream_Home widget type is 'MainWindow' \n"); | ||
| 317 | my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 318 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 319 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 320 | |||
| 321 | } | ||
| 322 | else { | ||
| 323 | print( | ||
| 324 | "file_dialog,big_stream_last_dir_in_path, no widget type selected \n" | ||
| 325 | ); | ||
| 326 | } | ||
| 327 | |||
| 328 | } | ||
| 329 | |||
| 330 | =head2 _big_stream_last_dir_in_path | ||
| 331 | |||
| 332 | =cut | ||
| 333 | |||
| 334 | sub _big_stream_last_dir_in_path { | ||
| 335 | |||
| 336 | my ($self) = @_; | ||
| 337 | |||
| 338 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 339 | my $whereami = whereami->new(); | ||
| 340 | |||
| 341 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 342 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 343 | my $length = $default_param_specs->{_length}; | ||
| 344 | |||
| 345 | $gui_history->set_hash_ref($file_dialog); | ||
| 346 | $gui_history->set4FileDialog_open_start(); | ||
| 347 | $gui_history->set4superflow_open_path_start(); | ||
| 348 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 349 | |||
| 350 | # If an appropriate Entry widget is first selected, | ||
| 351 | # Find out which entry button has been chosen (index) | ||
| 352 | # Confirm that it IS the file button | ||
| 353 | |||
| 354 | # print("file_dialog,_big_stream_last_dir_in_path,_FileDialog_button pressed, \n"); | ||
| 355 | # print("file_dialog, _big_stream_last_dir_in_path selected _values_aref=@{$file_dialog->{_values_aref}}\n"); | ||
| 356 | # print("file_dialog, _big_stream_last_dir_in_path selected _values_aref=@{$file_dialog->{_names_aref}}\n"); | ||
| 357 | # print("file_dialog _big_stream_last_dir_in_path selected parameter_values_frame = $file_dialog->{_parameter_values_frame} \n"); | ||
| 358 | |||
| 359 | my $widget_type = | ||
| 360 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 361 | |||
| 362 | # print("file_dialog _big_stream_last_dir_in_path selected widget type is = $widget_type \n"); | ||
| 363 | |||
| 364 | if ( $widget_type eq 'Entry' ) { | ||
| 365 | |||
| 366 | # print("1. file_dialog,_big_stream_last_dir_in_path, selected widget_type=$widget_type \n"); | ||
| 367 | |||
| 368 | my $selected_Entry_widget = | ||
| 369 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 370 | $param_widgets->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 371 | |||
| 372 | # Need to set the length and first_idx or, $param-widgets->set_length($file_dialog_length); | ||
| 373 | # print("file_dialog,_big_stream_last_dir_in_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 374 | # print("file_dialog,_big_stream_last_dir_in_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 375 | |||
| 376 | $param_widgets->set_first_idx($first_idx); | ||
| 377 | $param_widgets->set_length($length); | ||
| 378 | |||
| 379 | # print("2. file_dialog _big_stream_last_dir_in_path, selected_Entry_widget: $selected_Entry_widget\n"); | ||
| 380 | |||
| 381 | $file_dialog->{_parameter_value_index} = | ||
| 382 | $param_widgets->get_entry_button_chosen_index(); | ||
| 383 | |||
| 384 | # print("file_dialog,_big_stream_last_dir_in_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 385 | # print("file_dialog,_big_stream_last_dir_in_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 386 | |||
| 387 | if ( $file_dialog->{_parameter_value_index} >= 0 ) | ||
| 388 | { # for additional certainty; but is it needed? | ||
| 389 | # print("4. file_dialog,ig_stream_last_dir_in_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 390 | $file_dialog->{_entry_button_label} = | ||
| 391 | $param_widgets->get_label4entry_button_chosen(); | ||
| 392 | |||
| 393 | # print("5. file_dialog,_big_stream_last_dir_in_path,entry_button_label = $file_dialog->{_entry_button_label}\n"); | ||
| 394 | |||
| 395 | # use iFileuse aliased 'determine the Path stored in the current configuration file | ||
| 396 | $iFile->set_entry($file_dialog); # selected entry label | ||
| 397 | $iFile->set_flow_type_h($file_dialog); # a pre-built superflow | ||
| 398 | $iFile->set_parameter_value_index($file_dialog); # e.g., 0 | ||
| 399 | $iFile->set_values_aref($file_dialog); # e.g., /home/gom/ | ||
| 400 | $iFile->set_prog_name_sref($file_dialog); # e.g., Project_config | ||
| 401 | |||
| 402 | $file_dialog->{_path} = $iFile->get_Path(); | ||
| 403 | |||
| 404 | # print("1.file_dialog,_pre-built_superflow_path, PATH: $file_dialog->{_path} \n"); | ||
| 405 | |||
| 406 | # print("1.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 407 | |||
| 408 | _FileDialog(); # open file dialog mega-widget | ||
| 409 | |||
| 410 | # print("2.file_dialog,_pre-built_superflow_path, last_path_touched: $file_dialog->{_last_path_touched} \n"); | ||
| 411 | |||
| 412 | _big_stream_last_dir_in_path_close(); | ||
| 413 | |||
| 414 | # print("2.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 415 | # my $length= scalar @{$file_dialog->{_values_aref}}; # 61 values | ||
| 416 | # for (my $i=0; $i < $length; $i++) { | ||
| 417 | # print("3.file_dialog,ig_stream_last_dir_in_path, _values_aref: @{$file_dialog->{_values_aref}}[$i]\n"); | ||
| 418 | # } | ||
| 419 | } | ||
| 420 | |||
| 421 | } | ||
| 422 | elsif ( $widget_type eq 'MainWindow' ) { # opening a random file | ||
| 423 | |||
| 424 | # print("file_dialog,_big_stream_last_dir_in_path widget type is 'MainWindow' \n"); | ||
| 425 | my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 426 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 427 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 428 | |||
| 429 | } | ||
| 430 | else { | ||
| 431 | print( | ||
| 432 | "file_dialog,big_stream_last_dir_in_path, no widget type selected \n" | ||
| 433 | ); | ||
| 434 | } | ||
| 435 | } | ||
| 436 | |||
| 437 | =head2 sub _big_stream_Home_close | ||
| 438 | |||
| 439 | re-organizing the display after a directory (path) is selected | ||
| 440 | |||
| 441 | TODO: CASE of opening a pre-existing superflow configuration file | ||
| 442 | or previously scripted flow by this GUI | ||
| 443 | BEFORE or While the menubutton OR Frame are selected | ||
| 444 | |||
| 445 | |||
| 446 | =cut | ||
| 447 | |||
| 448 | sub _big_stream_Home_close { | ||
| 449 | my ($self) = @_; | ||
| 450 | |||
| 451 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 452 | |||
| 453 | my $topic = $file_dialog->{_dialog_type}; | ||
| 454 | my $last_path_touched = $file_dialog->{_last_path_touched}; | ||
| 455 | |||
| 456 | if ( length $last_path_touched ) { | ||
| 457 | |||
| 458 | $file_dialog->{_is_selected_path} = $true; | ||
| 459 | |||
| 460 | } | ||
| 461 | else { | ||
| 462 | $file_dialog->{_is_selected_path} = $false; | ||
| 463 | print("file_dialog, _big_stream_Home_close, Cancelled. No path\n"); | ||
| 464 | } | ||
| 465 | |||
| 466 | $decisions->set4FileDialog_select($file_dialog); | ||
| 467 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 468 | |||
| 469 | if ($pre_req_ok) { | ||
| 470 | |||
| 471 | my $result = 0; | ||
| 472 | |||
| 473 | if ( defined( $file_dialog->{_last_path_touched} ) | ||
| 474 | and $file_dialog->{_last_path_touched} ne $empty_string | ||
| 475 | and ${ $file_dialog->{_prog_name_sref} } ne $empty_string ) | ||
| 476 | { | ||
| 477 | my $dirs = dirs->new(); | ||
| 478 | $dirs->set_path( $file_dialog->{_last_path_touched} ); | ||
| 479 | $result = | ||
| 480 | dirs->get_last_dirInpath(); # only keep the last directory name | ||
| 481 | |||
| 482 | # print("file_dialog,_big_stream_Home_close, is $result \n"); | ||
| 483 | |||
| 484 | } | ||
| 485 | else { | ||
| 486 | print("file_dialog,_big_stream_Home_close No path was selected\n"); | ||
| 487 | } | ||
| 488 | |||
| 489 | my $current_index = $file_dialog->{_parameter_value_index}; | ||
| 490 | |||
| 491 | # both flows and big streams require the following entry updates | ||
| 492 | # collect parameter widget values | ||
| 493 | $file_dialog->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 494 | |||
| 495 | # assign new file name to the array of values | ||
| 496 | @{ $file_dialog->{_values_aref} }[$current_index] = $result; | ||
| 497 | @{ $file_dialog->{_check_buttons_settings_aref} }[$current_index] = $on; | ||
| 498 | |||
| 499 | # update the gui with the new path | ||
| 500 | $param_widgets->set_values( $file_dialog->{_values_aref} ); | ||
| 501 | |||
| 502 | $gui_history->set4superflow_close_path_end(); | ||
| 503 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 504 | |||
| 505 | } # if pre_req_OK | ||
| 506 | } | ||
| 507 | |||
| 508 | =head2 sub _big_stream_last_dir_in_path_close | ||
| 509 | |||
| 510 | re-organizing the display after a directory (path) is selected | ||
| 511 | |||
| 512 | TODO: CASE of opening a pre-existing superflow configuration file | ||
| 513 | or previously scripted flow by this GUI | ||
| 514 | BEFORE or While the menubutton OR Frame are selected | ||
| 515 | |||
| 516 | |||
| 517 | =cut | ||
| 518 | |||
| 519 | sub _big_stream_last_dir_in_path_close { | ||
| 520 | my ($self) = @_; | ||
| 521 | |||
| 522 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 523 | |||
| 524 | my $topic = $file_dialog->{_dialog_type}; | ||
| 525 | my $last_path_touched = $file_dialog->{_last_path_touched}; | ||
| 526 | |||
| 527 | if ( defined $last_path_touched | ||
| 528 | && $last_path_touched ne $empty_string ) | ||
| 529 | { | ||
| 530 | |||
| 531 | $file_dialog->{_is_selected_path} = $true; | ||
| 532 | |||
| 533 | } | ||
| 534 | else { | ||
| 535 | $file_dialog->{_is_selected_path} = $false; | ||
| 536 | print( | ||
| 537 | "file_dialog, _big_stream_last_dir_in_path_close, Cancelled. No path\n" | ||
| 538 | ); | ||
| 539 | } | ||
| 540 | |||
| 541 | $decisions->set4FileDialog_select($file_dialog); | ||
| 542 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 543 | |||
| 544 | # print("1. file_dialog,_big_stream_last_dir_in_path_close, pre_req_ok= $pre_req_ok \n"); | ||
| 545 | |||
| 546 | if ($pre_req_ok) { | ||
| 547 | |||
| 548 | my $result = 0; | ||
| 549 | |||
| 550 | # print("3. file_dialog,_big_stream_last_dir_in_path_close,last_path_touched= $file_dialog->{_last_path_touched}\n"); | ||
| 551 | # print("4. file_dialog,_big_stream_last_dir_in_path_close,prog_name:${$file_dialog->{_prog_name_sref}}\n"); | ||
| 552 | |||
| 553 | if ( defined( $file_dialog->{_last_path_touched} ) | ||
| 554 | and $file_dialog->{_last_path_touched} ne $empty_string | ||
| 555 | and ${ $file_dialog->{_prog_name_sref} } ne $empty_string ) | ||
| 556 | { | ||
| 557 | |||
| 558 | # print("file_dialog,_big_stream_last_dir_in_path_close, for $file_dialog->{_prog_name_sref} \n"); | ||
| 559 | my $dirs = dirs->new(); | ||
| 560 | $dirs->set_path( $file_dialog->{_last_path_touched} ); | ||
| 561 | $result = | ||
| 562 | dirs->get_last_dirInpath(); # only keep the last directory name | ||
| 563 | |||
| 564 | # print("file_dialog,_big_stream_last_dir_in_path_close, is $result \n"); | ||
| 565 | |||
| 566 | } | ||
| 567 | else { | ||
| 568 | print( | ||
| 569 | "file_dialog,_big_stream_last_dir_in_path_close No path was selected\n" | ||
| 570 | ); | ||
| 571 | |||
| 572 | # print("4. file_dialog,_big_stream_last_dir_in_path_close,last path touched was | ||
| 573 | # $file_dialog->{_last_path_touched}\n") ; | ||
| 574 | } | ||
| 575 | |||
| 576 | # print("7. file_dialog,_big_stream_last_dir_in_path_close prog_name=${$file_dialog->{_prog_name_sref}}\n"); | ||
| 577 | |||
| 578 | my $current_index = $file_dialog->{_parameter_value_index}; | ||
| 579 | |||
| 580 | # both flows and big streams require the following entry updates | ||
| 581 | # collect parameter widget values | ||
| 582 | $file_dialog->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 583 | |||
| 584 | # assign new file name to the array of values | ||
| 585 | @{ $file_dialog->{_values_aref} }[$current_index] = $result; | ||
| 586 | @{ $file_dialog->{_check_buttons_settings_aref} }[$current_index] = $on; | ||
| 587 | |||
| 588 | # update the gui with the new path | ||
| 589 | $param_widgets->set_values( $file_dialog->{_values_aref} ); | ||
| 590 | |||
| 591 | # print("10. file_dialog,_pre_built_superflow_close_path values are: @{$file_dialog->{_values_aref}} \n"); | ||
| 592 | # $param_widgets->redisplay_values(); | ||
| 593 | |||
| 594 | $gui_history->set4superflow_close_path_end(); | ||
| 595 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 596 | |||
| 597 | } # if pre_req_OK | ||
| 598 | } | ||
| 599 | |||
| 600 | =head2 sub _get_dialog_type | ||
| 601 | |||
| 602 | |||
| 603 | Open as Open ( in GUI (perl programs of user-built flows) | ||
| 604 | |||
| 605 | Save/seen as Save in GUI ((perl program of user-built flow and pre-built superflows) | ||
| 606 | |||
| 607 | SaveAs/seen as SaveAs in GUI ((perl program of pre-built superflows) | ||
| 608 | |||
| 609 | Delete/see as Delete in GUI (user-built flows or any file in $PL_SEISMIC) | ||
| 610 | |||
| 611 | |||
| 612 | =cut | ||
| 613 | |||
| 614 | sub _get_dialog_type { | ||
| 615 | my ($self) = @_; | ||
| 616 | |||
| 617 | if ( $file_dialog->{_dialog_type} ) { | ||
| 618 | |||
| 619 | my $topic = $file_dialog->{_dialog_type}; | ||
| 620 | |||
| 621 | # print("file_dialog, _get_dialog_type is $topic\n"); | ||
| 622 | return ($topic); | ||
| 623 | |||
| 624 | } | ||
| 625 | else { | ||
| 626 | print("file_dialog, _get_dialog_type , missing topic\n"); | ||
| 627 | return ($empty_string); | ||
| 628 | } | ||
| 629 | } | ||
| 630 | |||
| 631 | =head2 sub _get_path | ||
| 632 | |||
| 633 | _dialog_type can be seen in GUI as | ||
| 634 | 'Data'/open, | ||
| 635 | 'SaveAs' or | ||
| 636 | 'Save' | ||
| 637 | 'Open'/open | ||
| 638 | |||
| 639 | within program we also have 'Path' or directory | ||
| 640 | |||
| 641 | =cut | ||
| 642 | |||
| 643 | sub _get_path { | ||
| 644 | my ($self) = @_; | ||
| 645 | |||
| 646 | if ( length $file_dialog->{_path} ) { | ||
| 647 | |||
| 648 | my $path = $file_dialog->{_path}; | ||
| 649 | return ($path); | ||
| 650 | |||
| 651 | } | ||
| 652 | else { | ||
| 653 | print(" file_dialog,_get_path, missing file path\n"); | ||
| 654 | return ($empty_string); | ||
| 655 | } | ||
| 656 | } | ||
| 657 | |||
| 658 | =head2 sub _set_file_path | ||
| 659 | |||
| 660 | _dialog_type, which can be seen in GUI as | ||
| 661 | 'Data'/open, | ||
| 662 | 'SaveAs' or | ||
| 663 | 'Save' | ||
| 664 | 'Open'/open | ||
| 665 | Only used by _user_built_flow_SaveAs_perl_file | ||
| 666 | |||
| 667 | =cut | ||
| 668 | |||
| 669 | sub _set_file_path { | ||
| 670 | my ($self) = @_; | ||
| 671 | |||
| 672 | my $topic = _get_dialog_type(); | ||
| 673 | |||
| 674 | if ( length $topic ) { | ||
| 675 | |||
| 676 | my $Project = Project_config->new(); | ||
| 677 | |||
| 678 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); | ||
| 679 | my $PL_SEISMIC = $Project->PL_SEISMIC(); | ||
| 680 | |||
| 681 | my $dispatch = { | ||
| 682 | |||
| 683 | $file_dialog_type->{_Data} => $DATA_SEISMIC_SU, | ||
| 684 | |||
| 685 | # Delete pre-existing user-built flow | ||
| 686 | $file_dialog_type->{_Delete} => $PL_SEISMIC, | ||
| 687 | $file_dialog_type->{_Open} => $PL_SEISMIC, | ||
| 688 | |||
| 689 | # save a new user-built flow | ||
| 690 | $file_dialog_type->{_SaveAs} => $PL_SEISMIC, | ||
| 691 | $file_dialog_type->{_Save} => $PL_SEISMIC, | ||
| 692 | |||
| 693 | }; | ||
| 694 | |||
| 695 | $file_dialog->{_path} = $dispatch->{$topic}; | ||
| 696 | |||
| 697 | # if ( $topic eq $file_dialog_type->{_Data} ) { # for Data | ||
| 698 | # | ||
| 699 | # $file_dialog->{_path} = $DATA_SEISMIC_SU; | ||
| 700 | # | ||
| 701 | # # print("file_dialog, _set_file_path ,dialog type:$topic\n"); | ||
| 702 | # # print("file_dialog, _set_file_path ,path:$file_dialog->{_path}\n"); | ||
| 703 | # | ||
| 704 | # } | ||
| 705 | # els | ||
| 706 | if ( $topic eq $file_dialog_type->{_Delete} ) { | ||
| 707 | # | ||
| 708 | $file_dialog->{_path} = $PL_SEISMIC; | ||
| 709 | # | ||
| 710 | # # print("file_dialog, _set_file_path ,dialog type:$topic\n"); | ||
| 711 | # print("file_dialog, _set_file_path ,path:$file_dialog->{_path}\n"); | ||
| 712 | # | ||
| 713 | } | ||
| 714 | |||
| 715 | # elsif ( $topic eq $file_dialog_type->{_Open} ) | ||
| 716 | # { # Open pre-exiting user-built flow | ||
| 717 | # | ||
| 718 | # $file_dialog->{_path} = $PL_SEISMIC; | ||
| 719 | # | ||
| 720 | # # print("file_dialog, _set_file_path ,dialog type:$topic\n"); | ||
| 721 | # # print("file_dialog, _set_file_path ,path:$file_dialog->{_path}\n"); | ||
| 722 | # | ||
| 723 | # } | ||
| 724 | # elsif ( $topic eq $file_dialog_type->{_SaveAs} ) | ||
| 725 | # { | ||
| 726 | # | ||
| 727 | # $file_dialog->{_path} = $PL_SEISMIC; | ||
| 728 | # | ||
| 729 | # # print("file_dialog, _set_file_path ,dialog type:$topic\n"); | ||
| 730 | # # print("file_dialog, _set_file_path ,path:$file_dialog->{_path}\n"); | ||
| 731 | # | ||
| 732 | # } | ||
| 733 | # elsif ( $topic eq $file_dialog_type->{_Save} ) { | ||
| 734 | # | ||
| 735 | # $file_dialog->{_path} = $PL_SEISMIC; | ||
| 736 | # | ||
| 737 | # # print("file_dialog, _set_file_path ,dialog type:$topic\n"); | ||
| 738 | # # print("file_dialog, _set_file_path ,path:$file_dialog->{_path}\n"); | ||
| 739 | |||
| 740 | } | ||
| 741 | else { | ||
| 742 | print(" file_dialog,_set_file_path, missing dialog type\n"); | ||
| 743 | } | ||
| 744 | return ($empty_string); | ||
| 745 | |||
| 746 | } | ||
| 747 | |||
| 748 | =head2 sub _get_flow_type | ||
| 749 | |||
| 750 | user_built_flow | ||
| 751 | or | ||
| 752 | pre_built_superflow | ||
| 753 | |||
| 754 | |||
| 755 | =cut | ||
| 756 | |||
| 757 | sub _get_flow_type { | ||
| 758 | my ($self) = @_; | ||
| 759 | |||
| 760 | my $how_built = $file_dialog->{_flow_type}; | ||
| 761 | |||
| 762 | if ( $file_dialog->{_flow_type} ) { | ||
| 763 | return ($how_built); | ||
| 764 | |||
| 765 | } | ||
| 766 | else { | ||
| 767 | print("file_dialog, _get_flow_type , missing topic\n"); | ||
| 768 | return ($empty_string); | ||
| 769 | } | ||
| 770 | |||
| 771 | } | ||
| 772 | |||
| 773 | =head2 sub _pre_built_superflow_close_data_file | ||
| 774 | |||
| 775 | reorganizing the display after a file is selected | ||
| 776 | |||
| 777 | 'menubutton' is for our macro sunix tools | ||
| 778 | 'frame' is for the regular sunix programs | ||
| 779 | |||
| 780 | TODO: CASE of opening a pre-existing superflow configuration file | ||
| 781 | or previously scripted flow by this GUI | ||
| 782 | BEFORE or While the menubutton OR Frame are selected | ||
| 783 | |||
| 784 | # if(entry_button_chosen('file_name') != $failure) { | ||
| 785 | # if($file_dialog->{_current_widget} eq 'menubutton' || $file_dialog->{_current_widget} eq 'frame' ) { | ||
| 786 | print("file_dialog,_pre_built_superflow_close_data_file, is superflow? $file_dialog->{_is_superflow_select_button}\n"); | ||
| 787 | print("file_dialog,_pre_built_superflow_close_data_file, is flow? left lstbox:$file_dialog->{_is_flow_listbox_grey_w},right:$file_dialog->{_is_flow_listbox_green_w} \n"); | ||
| 788 | |||
| 789 | # Seen as DATA | ||
| 790 | Open/data is used to open a data file | ||
| 791 | |||
| 792 | =cut | ||
| 793 | |||
| 794 | sub _pre_built_superflow_close_data_file { | ||
| 795 | my ($self) = @_; | ||
| 796 | |||
| 797 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 798 | |||
| 799 | my @fields; | ||
| 800 | my $topic = $file_dialog->{_dialog_type}; | ||
| 801 | my $pathNfile = $file_dialog->{_selected_file_name}; | ||
| 802 | |||
| 803 | if ( defined $pathNfile | ||
| 804 | && $pathNfile ne $empty_string ) | ||
| 805 | { | ||
| 806 | |||
| 807 | @fields = split( /\//, $pathNfile ); | ||
| 808 | |||
| 809 | # print("file_dialog, _pre_built_superflow_close_data_file,fields are: @fields\n"); | ||
| 810 | $file_dialog->{_is_selected_file_name} = $true; | ||
| 811 | |||
| 812 | } | ||
| 813 | else { | ||
| 814 | print( | ||
| 815 | "file_dialog, _pre_built_superflow_close_data_file, Cancelled. No name selected\n" | ||
| 816 | ); | ||
| 817 | } | ||
| 818 | |||
| 819 | # TODO: check whether _is_superflow_select_button is needed inside decisions | ||
| 820 | $decisions->set4FileDialog_select($file_dialog); | ||
| 821 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 822 | |||
| 823 | # print("1. file_dialog,_pre_built_superflow_close_data_file, pre_req_ok= $pre_req_ok \n"); | ||
| 824 | |||
| 825 | if ($pre_req_ok) { | ||
| 826 | |||
| 827 | # both flows and superflows require the following | ||
| 828 | my $current_index = $file_dialog->{_parameter_value_index}; | ||
| 829 | |||
| 830 | # print("2. file_dialog,_pre_built_superflow_close_data_file, current parameter index $current_index\n") | ||
| 831 | # ; | ||
| 832 | |||
| 833 | @{ $file_dialog->{_check_buttons_settings_aref} }[$current_index] = $on; | ||
| 834 | |||
| 835 | if ( $file_dialog->{_selected_file_name} ) { | ||
| 836 | |||
| 837 | # print("3. file_dialog,_pre_built_superflow_close_data_file,, fields= $fields[-1]\n"); | ||
| 838 | |||
| 839 | # remove *.su suffix, get only first name, add single quotes | ||
| 840 | $control->set_file_name_sref( \$fields[-1] ); | ||
| 841 | $control->remove_su_suffix4sref(); | ||
| 842 | $file_dialog->{_selected_file_name} = | ||
| 843 | $control->get_w_single_quotes(); | ||
| 844 | |||
| 845 | # $file_dialog->{_selected_file_name} = $control->su_data_name(\$fields[-1]); | ||
| 846 | # print( | ||
| 847 | #"file_dialog,_pre_built_superflow_close_data_file selected_file_name: $file_dialog->{_selected_file_name} \n" | ||
| 848 | # ); | ||
| 849 | |||
| 850 | } | ||
| 851 | else { | ||
| 852 | print( | ||
| 853 | "file_dialog,_pre_built_superflow_close_data_file No file was selected\n" | ||
| 854 | ); | ||
| 855 | |||
| 856 | # print("4. file_dialog,_pre_built_superflow_close_data_file,last path touched was | ||
| 857 | # $file_dialog->{_last_path_touched}\n") ; | ||
| 858 | } | ||
| 859 | |||
| 860 | # print("7. file_dialog,_pre_built_superflow_close_data_fileprog_name= | ||
| 861 | # ${$file_dialog->{_prog_name_sref}}\n"); | ||
| 862 | |||
| 863 | # legacy code: only ProjectVariables (a superflow) which does | ||
| 864 | # not have files/only directories requires the following | ||
| 865 | if ( ${ $file_dialog->{_prog_name_sref} } eq | ||
| 866 | $superflow_names->{_ProjectVariables} ) | ||
| 867 | { | ||
| 868 | |||
| 869 | @{ $file_dialog->{_values_aref} }[$current_index] = | ||
| 870 | $file_dialog->{_last_path_touched}; | ||
| 871 | |||
| 872 | # print("8. file_dialog,_pre_built_superflow_close_data_file last path is $file_dialog->{_last_path_touched} \n"); | ||
| 873 | } | ||
| 874 | |||
| 875 | # print( | ||
| 876 | # "9. file_dialog,_pre_built_superflow_close_data_file selected_file_name=$file_dialog->{_selected_file_name}\n" | ||
| 877 | # ); | ||
| 878 | |||
| 879 | # both flows and superflows require the following entry updates | ||
| 880 | # collect parameter widget values | ||
| 881 | $file_dialog->{_values_aref} = $param_widgets->get_values_aref() | ||
| 882 | ; # gets 61 because 61 are initialized | ||
| 883 | # assign new file name to the array of values | ||
| 884 | |||
| 885 | # print("10. file_dialog,_pre_built_superflow_close_data_file values are: @{$file_dialog->{_values_aref}} \n"); | ||
| 886 | @{ $file_dialog->{_values_aref} }[$current_index] = | ||
| 887 | $file_dialog->{_selected_file_name}; | ||
| 888 | |||
| 889 | # update the gui with the new file name | ||
| 890 | $param_widgets->set_values( $file_dialog->{_values_aref} ); | ||
| 891 | |||
| 892 | # print("10. file_dialog,_pre_built_superflow_close_data_file values are: @{$file_dialog->{_values_aref}} \n"); | ||
| 893 | $param_widgets->redisplay_values(); | ||
| 894 | |||
| 895 | $gui_history->set4superflow_close_data_file_end(); | ||
| 896 | $file_dialog = $gui_history->get_hash_ref(); # retrieves 93 | ||
| 897 | |||
| 898 | } # if prereq_OK | ||
| 899 | } | ||
| 900 | |||
| 901 | =head2 sub _pre_built_superflow_close_path | ||
| 902 | |||
| 903 | re-organizing the display after a directory (path) is selected | ||
| 904 | |||
| 905 | TODO: CASE of opening a pre-existing superflow configuration file | ||
| 906 | or previously scripted flow by this GUI | ||
| 907 | BEFORE or While the menubutton OR Frame are selected | ||
| 908 | |||
| 909 | |||
| 910 | =cut | ||
| 911 | |||
| 912 | sub _pre_built_superflow_close_path { | ||
| 913 | my ($self) = @_; | ||
| 914 | |||
| 915 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 916 | |||
| 917 | my $topic = $file_dialog->{_dialog_type}; | ||
| 918 | my $last_path_touched = $file_dialog->{_last_path_touched}; | ||
| 919 | |||
| 920 | if ( defined $last_path_touched | ||
| 921 | && $last_path_touched ne $empty_string ) | ||
| 922 | { | ||
| 923 | |||
| 924 | $file_dialog->{_is_selected_path} = $true; | ||
| 925 | |||
| 926 | } | ||
| 927 | else { | ||
| 928 | $file_dialog->{_is_selected_path} = $false; | ||
| 929 | print( | ||
| 930 | "file_dialog, _pre_built_superflow_close_path, Cancelled. No path\n" | ||
| 931 | ); | ||
| 932 | } | ||
| 933 | |||
| 934 | $decisions->set4FileDialog_select($file_dialog); | ||
| 935 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 936 | |||
| 937 | # print("1. file_dialog,_pre_built_superflow_close_path, pre_req_ok= $pre_req_ok \n"); | ||
| 938 | |||
| 939 | if ($pre_req_ok) { | ||
| 940 | |||
| 941 | my $result; | ||
| 942 | |||
| 943 | # print("3. file_dialog,_pre_built_superflow_close_path,last_path_touched= $file_dialog->{_last_path_touched}\n"); | ||
| 944 | # print("4. file_dialog,_pre_built_superflow_close_path,prog_name:${$file_dialog->{_prog_name_sref}}\n"); | ||
| 945 | |||
| 946 | if ( defined( $file_dialog->{_last_path_touched} ) | ||
| 947 | and $file_dialog->{_last_path_touched} ne $empty_string | ||
| 948 | and ${ $file_dialog->{_prog_name_sref} } ne $empty_string ) | ||
| 949 | { | ||
| 950 | |||
| 951 | # print("file_dialog,_pre_built_superflow_close_path,CASE #1 Sucat\n"); | ||
| 952 | $result = $file_dialog->{_last_path_touched}; # no abbreviation | ||
| 953 | # print("4. file_dialog,_pre_built_superflow_close_path,value that will be saved: $result\n"); | ||
| 954 | |||
| 955 | } | ||
| 956 | else { | ||
| 957 | print( | ||
| 958 | "file_dialog,_pre_built_superflow_close_path No path was selected\n" | ||
| 959 | ); | ||
| 960 | |||
| 961 | # print("4. file_dialog,_pre_built_superflow_close_path,last path touched was | ||
| 962 | # $file_dialog->{_last_path_touched}\n") ; | ||
| 963 | } | ||
| 964 | |||
| 965 | # print("7. file_dialog,_pre_built_superflow_close_path prog_name=${$file_dialog->{_prog_name_sref}}\n"); | ||
| 966 | |||
| 967 | my $current_index = $file_dialog->{_parameter_value_index}; | ||
| 968 | |||
| 969 | # both flows and superflows require the following entry updates | ||
| 970 | # collect parameter widget values | ||
| 971 | $file_dialog->{_values_aref} = $param_widgets->get_values_aref() | ||
| 972 | ; # gets 61 because 61 are initialized | ||
| 973 | |||
| 974 | # assign new file name to the array of values | ||
| 975 | @{ $file_dialog->{_values_aref} }[$current_index] = $result; | ||
| 976 | @{ $file_dialog->{_check_buttons_settings_aref} }[$current_index] = $on; | ||
| 977 | |||
| 978 | # update the gui with the new path | ||
| 979 | $param_widgets->set_values( $file_dialog->{_values_aref} ); | ||
| 980 | |||
| 981 | # print("10. file_dialog,_pre_built_superflow_close_path values are: @{$file_dialog->{_values_aref}} \n"); | ||
| 982 | # $param_widgets->redisplay_values(); | ||
| 983 | |||
| 984 | $gui_history->set4superflow_close_path_end(); | ||
| 985 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 986 | |||
| 987 | } # if pre_req_OK | ||
| 988 | } | ||
| 989 | |||
| 990 | =head2 _pre_built_superflow_open_data_file | ||
| 991 | |||
| 992 | print("file_dialog, _pre_built_superflow_open_data_file, flow_item_up_arrow_button: $file_dialog->{_flow_item_up_arrow_button}\n"); | ||
| 993 | foreach my $key (sort keys %$file_dialog) { | ||
| 994 | print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); | ||
| 995 | } | ||
| 996 | =cut | ||
| 997 | |||
| 998 | sub _pre_built_superflow_open_data_file { | ||
| 999 | |||
| 1000 | my ($self) = @_; | ||
| 1001 | |||
| 1002 | # print("file_dialog, _pre_built_superflow_open_data_file\n "); | ||
| 1003 | |||
| 1004 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 1005 | my $whereami = whereami->new(); | ||
| 1006 | |||
| 1007 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1008 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1009 | my $length = $default_param_specs->{_length}; | ||
| 1010 | |||
| 1011 | # e.g., Data_Pl_SEISMIC, Data_SEISMIC_TXT, Data, Path, Open, Delete etc. | ||
| 1012 | my $topic = _get_dialog_type(); | ||
| 1013 | |||
| 1014 | $gui_history->set_hash_ref($file_dialog); | ||
| 1015 | $gui_history->set4FileDialog_open_start(); | ||
| 1016 | $gui_history->set4superflow_open_data_file_start(); | ||
| 1017 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1018 | |||
| 1019 | # Tests follow: | ||
| 1020 | # 1. if an appropriate entry widget is first selected, ie. Entry | ||
| 1021 | # 2. get index of entry button pressed | ||
| 1022 | # 3. find out which entry button has been chosen | ||
| 1023 | # 4. confirm that it IS the file button | ||
| 1024 | # TODO: determine the required file type and file path | ||
| 1025 | # TODO: from the *_spec.pm file for the particular program in the flow. | ||
| 1026 | # print("file_dialog,_pre_built_superflow_open_data_file,_FileDialog_button pressed, \n"); | ||
| 1027 | # print("file_dialog, _pre_built_superflow_open_data_file selected _values_aref=@{$file_dialog->{_values_aref}}\n"); | ||
| 1028 | # print("file_dialog _pre_built_superflow_open_data_file selected parameter_values_frame = $file_dialog->{_parameter_values_frame} \n"); | ||
| 1029 | my $widget_type = | ||
| 1030 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 1031 | |||
| 1032 | # print("file_dialog _pre_built_superflow_open_data_file selected widget type is = $widget_type \n"); | ||
| 1033 | |||
| 1034 | if ( $widget_type eq 'Entry' ) { | ||
| 1035 | |||
| 1036 | # print("1. file_dialog,_pre_built_superflow_open_data_file, selected widget_type=$widget_type \n"); | ||
| 1037 | |||
| 1038 | my $selected_Entry_widget = | ||
| 1039 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 1040 | $param_widgets->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 1041 | |||
| 1042 | # Need to set the length and first_idx or, $param-widgets->set_length($file_dialog_length); | ||
| 1043 | $param_widgets->set_first_idx($first_idx); | ||
| 1044 | $param_widgets->set_length($length); | ||
| 1045 | |||
| 1046 | # print("2. file_dialog, _pre_built_superflow_open_data_file, selected_Entry_widget: $selected_Entry_widget\n"); | ||
| 1047 | |||
| 1048 | $file_dialog->{_parameter_value_index} = | ||
| 1049 | $param_widgets->get_entry_button_chosen_index(); | ||
| 1050 | |||
| 1051 | # print("file_dialog,_pre_built_superflow_open_data_file,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 1052 | # print("file_dialog,_pre_built_superflow_open_data_file, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 1053 | |||
| 1054 | if ( $file_dialog->{_parameter_value_index} >= 0 ) | ||
| 1055 | { # for additional certainty; but is it needed? | ||
| 1056 | |||
| 1057 | # e.g. Data_Pl_SEISMIC, Data_SEISMIC_TXT, Data, Path, Open, Delete etc. | ||
| 1058 | my $topic = _get_dialog_type(); | ||
| 1059 | |||
| 1060 | # print( | ||
| 1061 | # "4. file_dialog,_pre_built_flow_open_data_file, parameter_value_index= $file_dialog->{_parameter_value_index}\n" | ||
| 1062 | # ); | ||
| 1063 | $file_dialog->{_entry_button_label} = | ||
| 1064 | $param_widgets->get_label4entry_button_chosen(); | ||
| 1065 | |||
| 1066 | # print( | ||
| 1067 | # "5. file_dialog,_pre_built_superflow_open_data_file,entry_button_label = $file_dialog->{_entry_button_label}\n" | ||
| 1068 | # ); | ||
| 1069 | |||
| 1070 | # use iFile to determine the correct data path (directory) | ||
| 1071 | $iFile->set_entry($file_dialog) | ||
| 1072 | ; # first entry label should be base_file_name | ||
| 1073 | $iFile->set_flow_type_h($file_dialog) | ||
| 1074 | ; # pre-built superflow will determine the DIR to find data | ||
| 1075 | $iFile->set_values_aref($file_dialog) | ||
| 1076 | ; # may not be needed ( only for user-built_flows) TODO | ||
| 1077 | $iFile->set_prog_name_sref($file_dialog); | ||
| 1078 | $iFile->set_dialog_type($topic); | ||
| 1079 | $iFile->set_parameter_value_index($file_dialog); | ||
| 1080 | |||
| 1081 | $file_dialog->{_path} = $iFile->get_Data_path(); | ||
| 1082 | |||
| 1083 | #print("1.file_dialog,_pre-built_superflow_open_data_file, PATH: $file_dialog->{_path} \n"); | ||
| 1084 | #print( | ||
| 1085 | # "1.file_dialog,_pre-built_superflow_open_data_file, _values_aref: @{$file_dialog->{_values_aref}}[0]\n" | ||
| 1086 | # ); | ||
| 1087 | |||
| 1088 | _FileDialog(); | ||
| 1089 | |||
| 1090 | # print("2.file_dialog,_pre-built_superflow_open_data_file, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 1091 | |||
| 1092 | _pre_built_superflow_close_data_file(); | ||
| 1093 | |||
| 1094 | # print("2.file_dialog,_pre-built_superflow_open_data_file, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 1095 | # my $length= scalar @{$file_dialog->{_values_aref}}; # 61 values | ||
| 1096 | # for (my $i=0; $i < $length; $i++) { | ||
| 1097 | # print("3.file_dialog,_pre-built_superflow_open_data_file, _values_aref: @{$file_dialog->{_values_aref}}[$i]\n"); | ||
| 1098 | # } | ||
| 1099 | } | ||
| 1100 | } | ||
| 1101 | elsif ( $widget_type eq 'MainWindow' ) { # opening a random file | ||
| 1102 | # print("file_dialog,_pre_built_superflow_open_data_file widget type is 'MainWindow' \n"); | ||
| 1103 | my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 1104 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 1105 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 1106 | |||
| 1107 | } | ||
| 1108 | else { | ||
| 1109 | print( | ||
| 1110 | "file_dialog,_pre-built_superflow_open_data_file no widget type selected \n" | ||
| 1111 | ); | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | $gui_history->set4superflow_open_data_file_end(); | ||
| 1115 | $gui_history->set4FileDialog_open_end(); | ||
| 1116 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1117 | |||
| 1118 | } | ||
| 1119 | |||
| 1120 | =head2 _pre_built_superflow_open_path | ||
| 1121 | |||
| 1122 | a directory path | ||
| 1123 | =cut | ||
| 1124 | |||
| 1125 | sub _pre_built_superflow_open_path { | ||
| 1126 | |||
| 1127 | my ($self) = @_; | ||
| 1128 | |||
| 1129 | # print ("file_dialog, _pre_built_superflow_open_path\n "); | ||
| 1130 | |||
| 1131 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 1132 | my $whereami = whereami->new(); | ||
| 1133 | |||
| 1134 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1135 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1136 | my $length = $default_param_specs->{_length}; | ||
| 1137 | |||
| 1138 | $gui_history->set_hash_ref($file_dialog); | ||
| 1139 | $gui_history->set4FileDialog_open_start(); | ||
| 1140 | $gui_history->set4superflow_open_path_start(); | ||
| 1141 | $file_dialog = $gui_history->get_hash_ref(); # gets 93 | ||
| 1142 | |||
| 1143 | # If an appropriate Entry widget is first selected, | ||
| 1144 | # Find out which entry button has been chosen (index) | ||
| 1145 | # Confirm that it IS the file button | ||
| 1146 | |||
| 1147 | # print("file_dialog,_pre_built_superflow_open_path,_FileDialog_button pressed, \n"); | ||
| 1148 | # print("file_dialog, _pre_built_superflow_open_path selected _values_aref=@{$file_dialog->{_values_aref}}\n"); | ||
| 1149 | # print("file_dialog, _pre_built_superflow_open_path selected _values_aref=@{$file_dialog->{_names_aref}}\n"); | ||
| 1150 | # print("file_dialog _pre_built_superflow_open_path selected parameter_values_frame = $file_dialog->{_parameter_values_frame} \n"); | ||
| 1151 | |||
| 1152 | my $widget_type = | ||
| 1153 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 1154 | |||
| 1155 | # print("file_dialog _pre_built_superflow_open_path selected widget type is = $widget_type \n"); | ||
| 1156 | |||
| 1157 | if ( $widget_type eq 'Entry' ) { | ||
| 1158 | |||
| 1159 | # print("1. file_dialog,_pre_built_superflow_open_path, selected widget_type=$widget_type \n"); | ||
| 1160 | |||
| 1161 | my $selected_Entry_widget = | ||
| 1162 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 1163 | $param_widgets->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 1164 | |||
| 1165 | # Need to set the length and first_idx or, $param-widgets->set_length($file_dialog_length); | ||
| 1166 | # print("file_dialog,_pre_built_superflow_open_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 1167 | # print("file_dialog,_pre_built_superflow_open_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 1168 | |||
| 1169 | $param_widgets->set_first_idx($first_idx); | ||
| 1170 | $param_widgets->set_length($length); | ||
| 1171 | |||
| 1172 | # print("2. file_dialog _pre_built_superflow_open_path, selected_Entry_widget: $selected_Entry_widget\n"); | ||
| 1173 | |||
| 1174 | $file_dialog->{_parameter_value_index} = | ||
| 1175 | $param_widgets->get_entry_button_chosen_index(); | ||
| 1176 | |||
| 1177 | # print("file_dialog,_pre_built_superflow_open_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 1178 | # print("file_dialog,_pre_built_superflow_open_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 1179 | |||
| 1180 | if ( $file_dialog->{_parameter_value_index} >= 0 ) | ||
| 1181 | { # for additional certainty; but is it needed? | ||
| 1182 | # print("4. file_dialog,_pre_built_flow_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 1183 | $file_dialog->{_entry_button_label} = | ||
| 1184 | $param_widgets->get_label4entry_button_chosen(); | ||
| 1185 | |||
| 1186 | # print("5. file_dialog,_pre_built_superflow_open_path,entry_button_label = $file_dialog->{_entry_button_label}\n"); | ||
| 1187 | |||
| 1188 | # use iFile to determine the stored Path in the current configuration file | ||
| 1189 | $iFile->set_entry($file_dialog); # selected entry label | ||
| 1190 | $iFile->set_flow_type_h($file_dialog); # a pre-built superflow | ||
| 1191 | $iFile->set_parameter_value_index($file_dialog); # e.g., 0 | ||
| 1192 | $iFile->set_values_aref($file_dialog); # e.g., /home/gom/ | ||
| 1193 | $iFile->set_prog_name_sref($file_dialog); # e.g., Project_config | ||
| 1194 | $file_dialog->{_path} = $iFile->get_Path(); | ||
| 1195 | $control->set_path( $file_dialog->{_path} ); | ||
| 1196 | $file_dialog->{_path} = $control->get_path_wo_last_slash(); | ||
| 1197 | |||
| 1198 | # print("2.file_dialog,_pre-built_superflow_path, PATH: $file_dialog->{_path} \n"); | ||
| 1199 | # print("1.file_dialog,_pre-built_superflow_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 1200 | |||
| 1201 | _FileDialog(); # open file dialog mega-widget | ||
| 1202 | |||
| 1203 | # print("2.file_dialog,_pre-built_superflow_path, last_path_touched: $file_dialog->{_last_path_touched} \n"); | ||
| 1204 | |||
| 1205 | _pre_built_superflow_close_path(); | ||
| 1206 | |||
| 1207 | # print("2.file_dialog,_pre-built_superflow_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 1208 | # my $length= scalar @{$file_dialog->{_values_aref}}; # 61 values | ||
| 1209 | # for (my $i=0; $i < $length; $i++) { | ||
| 1210 | # print("3.file_dialog,_pre-built_superflow_path, _values_aref: @{$file_dialog->{_values_aref}}[$i]\n"); | ||
| 1211 | # } | ||
| 1212 | } | ||
| 1213 | } | ||
| 1214 | elsif ( $widget_type eq 'MainWindow' ) { # opening a random file | ||
| 1215 | |||
| 1216 | # print("file_dialog,_pre_built_superflow_open_path widget type is 'MainWindow' \n"); | ||
| 1217 | my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 1218 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 1219 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 1220 | |||
| 1221 | } | ||
| 1222 | else { | ||
| 1223 | print( | ||
| 1224 | "file_dialog,_pre-built_superflow_path no widget type selected \n"); | ||
| 1225 | } | ||
| 1226 | |||
| 1227 | $gui_history->set4superflow_open_path_end(); | ||
| 1228 | $gui_history->set4FileDialog_open_end(); # 2 set | ||
| 1229 | $file_dialog = $gui_history->get_hash_ref(); # retrieves 93 | ||
| 1230 | } | ||
| 1231 | |||
| 1232 | =head2 sub _set_FileDialog2user_built_flow | ||
| 1233 | |||
| 1234 | {_Data} ... open pre-existing data file | ||
| 1235 | {_Open} ... open pre-existing user-built flow | ||
| 1236 | {_SaveAs} ... save a new user-built flow | ||
| 1237 | {_Save} ... re-save a user-built flow | ||
| 1238 | {_Delete} ... delete a user-built flow, but any file can be removed | ||
| 1239 | |||
| 1240 | =cut | ||
| 1241 | |||
| 1242 | sub _set_FileDialog2user_built_flow { | ||
| 1243 | my ($self) = @_; | ||
| 1244 | |||
| 1245 | my $topic = _get_dialog_type(); | ||
| 1246 | |||
| 1247 | # print("file_dialog, _set_FileDialog2user_built_flow, dialog type:$topic\n"); | ||
| 1248 | |||
| 1249 | if ( length $topic ) { | ||
| 1250 | |||
| 1251 | my $dispatch = { | ||
| 1252 | $file_dialog_type->{_Data} => \&_user_built_flow_open_data_file, | ||
| 1253 | $file_dialog_type->{_Data_PL_SEISMIC} => | ||
| 1254 | \&_user_built_flow_open_data_file, | ||
| 1255 | $file_dialog_type->{_Data_SEISMIC_TXT} => | ||
| 1256 | \&_user_built_flow_open_data_file, | ||
| 1257 | $file_dialog_type->{_Open} => \&_user_built_flow_open_perl_file, | ||
| 1258 | $file_dialog_type->{_Path} => \&_user_built_flow_open_path, | ||
| 1259 | $file_dialog_type->{_Delete} => \&_user_built_flow_Delete_perl_file, | ||
| 1260 | $file_dialog_type->{_SaveAs} => \&_user_built_flow_SaveAs_perl_file, | ||
| 1261 | }; | ||
| 1262 | |||
| 1263 | $dispatch->{$topic}->(); | ||
| 1264 | } | ||
| 1265 | else { | ||
| 1266 | print( | ||
| 1267 | "file_dialog,_set_FileDialog2user_built_flow, missing bindings\n"); | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | # print("file_dialog, End of _set_FileDialog2user_built_flow \n"); | ||
| 1271 | return ($empty_string); | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | sub _set_FileDialog2pre_built_superflow { | ||
| 1275 | my ($self) = @_; | ||
| 1276 | |||
| 1277 | my $topic = _get_dialog_type(); | ||
| 1278 | |||
| 1279 | if ( length $topic ) { | ||
| 1280 | |||
| 1281 | my $dispatch = { | ||
| 1282 | $file_dialog_type->{_Data_PL_SEISMIC} => | ||
| 1283 | \&_pre_built_superflow_open_data_file, | ||
| 1284 | $file_dialog_type->{_Data_SEISMIC_TXT} => | ||
| 1285 | \&_pre_built_superflow_open_data_file, | ||
| 1286 | $file_dialog_type->{_Home} => | ||
| 1287 | \&_pre_built_superflow_open_data_file, | ||
| 1288 | $file_dialog_type->{_Data} => \&_pre_built_superflow_open_data_file, | ||
| 1289 | |||
| 1290 | $file_dialog_type->{_Path} => \&_pre_built_superflow_open_path, | ||
| 1291 | |||
| 1292 | $file_dialog_type->{_last_dir_in_path} => | ||
| 1293 | \&_big_stream_last_dir_in_path, | ||
| 1294 | }; | ||
| 1295 | |||
| 1296 | $dispatch->{$topic}->(); | ||
| 1297 | |||
| 1298 | } | ||
| 1299 | else { | ||
| 1300 | print( | ||
| 1301 | "file_dialog,_set_FileDialog2pre_built_superflow, missing bindings\n" | ||
| 1302 | ); | ||
| 1303 | } | ||
| 1304 | # | ||
| 1305 | # if ( $topic eq $file_dialog_type->{_Data_PL_SEISMIC} ) { | ||
| 1306 | # | ||
| 1307 | # # print("file_dialog,_set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1308 | # _pre_built_superflow_open_data_file(); | ||
| 1309 | # | ||
| 1310 | # } | ||
| 1311 | # elsif ( $topic eq $file_dialog_type->{_Data_SEISMIC_TXT} ) { | ||
| 1312 | # | ||
| 1313 | # # print("file_dialog,_set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1314 | # _pre_built_superflow_open_data_file(); | ||
| 1315 | # | ||
| 1316 | # } | ||
| 1317 | # elsif ( $topic eq $file_dialog_type->{_Data} ) { | ||
| 1318 | # | ||
| 1319 | # # print("file_dialog,_set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1320 | # _pre_built_superflow_open_data_file(); | ||
| 1321 | # | ||
| 1322 | # } | ||
| 1323 | # elsif ( $topic eq $file_dialog_type->{_Home} ) { | ||
| 1324 | # | ||
| 1325 | # # print("2. file_dialog,set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1326 | # # _big_stream_last_dir_in_path(); | ||
| 1327 | # # _big_stream_Home(); | ||
| 1328 | # } | ||
| 1329 | # elsif ( $topic eq $file_dialog_type->{_Path} ) { | ||
| 1330 | # | ||
| 1331 | # # print("1. file_dialog,set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1332 | # _pre_built_superflow_open_path(); | ||
| 1333 | # | ||
| 1334 | # } | ||
| 1335 | # elsif ( $topic eq $file_dialog_type->{_last_dir_in_path} ) { | ||
| 1336 | # | ||
| 1337 | # # print("2. file_dialog,set_FileDialog2pre_built_superflow, topic= $topic\n"); | ||
| 1338 | # _big_stream_last_dir_in_path(); | ||
| 1339 | # | ||
| 1340 | # } | ||
| 1341 | # elsif ( $topic eq $file_dialog_type->{_Open} ) { | ||
| 1342 | # | ||
| 1343 | # # print("file_dialog,set_FileDialog2pre_built_superflow, not allowed \n"); | ||
| 1344 | # | ||
| 1345 | # # NADA | ||
| 1346 | # | ||
| 1347 | # } | ||
| 1348 | # elsif ( $topic eq $file_dialog_type->{_SaveAs} ) { | ||
| 1349 | # | ||
| 1350 | # print("file_dialog,set_FileDialog2pre_built_superflow, not allowed \n"); | ||
| 1351 | # _save_button('SaveAs'); superflow saves flow automatically and should not | ||
| 1352 | # require this option! #NADA | ||
| 1353 | # | ||
| 1354 | # } | ||
| 1355 | # else { | ||
| 1356 | # print( | ||
| 1357 | # "file_dialog,set_FileDialog2pre_built_superflow, problem! \n"); | ||
| 1358 | # } | ||
| 1359 | return ($empty_string); | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | =head2 sub _set_selected_file_name | ||
| 1363 | |||
| 1364 | =cut | ||
| 1365 | |||
| 1366 | sub _set_selected_file_name { | ||
| 1367 | |||
| 1368 | my ($selected_file_name) = @_; | ||
| 1369 | |||
| 1370 | if ( $selected_file_name ne $empty_string ) { | ||
| 1371 | |||
| 1372 | $file_dialog->{_selected_file_name} = $selected_file_name; | ||
| 1373 | |||
| 1374 | } | ||
| 1375 | else { | ||
| 1376 | print("file_dialog, _set_selected_file_name, empty string NADA\n"); | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | return ($empty_string); | ||
| 1380 | } | ||
| 1381 | |||
| 1382 | =head2 sub _user_built_flow_Delete_perl_file | ||
| 1383 | |||
| 1384 | foreach my $key (sort keys %$file_dialog) { | ||
| 1385 | print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); | ||
| 1386 | } | ||
| 1387 | =cut | ||
| 1388 | |||
| 1389 | sub _user_built_flow_Delete_perl_file { | ||
| 1390 | |||
| 1391 | my ($self) = @_; | ||
| 1392 | |||
| 1393 | # local location within GUI | ||
| 1394 | # and for file dialog | ||
| 1395 | # print("0. file_dialog, user_built_flow_Delete_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n"); | ||
| 1396 | |||
| 1397 | $gui_history->set_hash_ref($file_dialog); | ||
| 1398 | $gui_history->set4FileDialog_Delete_start(); | ||
| 1399 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1400 | |||
| 1401 | # print( | ||
| 1402 | #"1. file_dialog, user_built_flow_Delete_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n" | ||
| 1403 | # ); | ||
| 1404 | $decisions->set4FileDialog_Delete($file_dialog); | ||
| 1405 | my $pre_req_ok = $decisions->get4FileDialog_Delete(); | ||
| 1406 | |||
| 1407 | # print( | ||
| 1408 | #"3. file_dialog, _user_built_flow_Delete_perl_file,Delete, pre_req_set_file_patheq_ok= $pre_req_ok \n" | ||
| 1409 | # ); | ||
| 1410 | |||
| 1411 | if ($pre_req_ok) { | ||
| 1412 | |||
| 1413 | # print( | ||
| 1414 | #"2. file_dialog, _user_built_flow_Delete_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n" | ||
| 1415 | # ); | ||
| 1416 | |||
| 1417 | my $whereami = whereami->new(); | ||
| 1418 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1419 | |||
| 1420 | my @fields; | ||
| 1421 | my $full_path_name; | ||
| 1422 | |||
| 1423 | # print( | ||
| 1424 | #"file_dialog _user_built_flow_Delete_perl_file_user_built_flow_Delete_perl_file, _last_parameter_index_touched_color: $file_dialog->{_last_parameter_index_touched_color} \n" | ||
| 1425 | # ); | ||
| 1426 | |||
| 1427 | # make the file paths for the current file_dialog type (Save, SaveAs, Delete, Open, Data, etc.) | ||
| 1428 | _set_file_path(); | ||
| 1429 | |||
| 1430 | # collects the name of the data file to be deleted | ||
| 1431 | _FileDialog(); # file dialog mega-widget | ||
| 1432 | |||
| 1433 | my $topic = $file_dialog->{_dialog_type}; | ||
| 1434 | |||
| 1435 | # print( | ||
| 1436 | #"file-dialog _user_built_flow_Delete_perl_file, file_dialog->{_dialog_type}: $topic\n" | ||
| 1437 | # ); | ||
| 1438 | $full_path_name = $file_dialog->{_selected_file_name}; | ||
| 1439 | |||
| 1440 | # print( | ||
| 1441 | #"file-dialog _user_built_flow_Delete_perl_file, If not cancelled, full_path_w_name: $full_path_name\n" | ||
| 1442 | # ); | ||
| 1443 | |||
| 1444 | if ( length $full_path_name ) { | ||
| 1445 | |||
| 1446 | @fields = split( /\//, $full_path_name ); | ||
| 1447 | $file_dialog->{_is_selected_file_name} = $true; | ||
| 1448 | |||
| 1449 | # print( | ||
| 1450 | #"file-dialog _user_built_flow_Delete_perl_file,file_dialog->{_is_selected_file_name}=$file_dialog->{_is_selected_file_name} \n" | ||
| 1451 | # ); | ||
| 1452 | # | ||
| 1453 | } | ||
| 1454 | else { | ||
| 1455 | # print( | ||
| 1456 | #"file_dialog, _user_built_flow_Delete_perl_file,Cancelled. No output flow name selected.NADA\n" | ||
| 1457 | # ); | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1461 | my $length = $default_param_specs->{_length}; | ||
| 1462 | |||
| 1463 | # remove suffix (pl, su, txt ) from selected file name | ||
| 1464 | if ( defined $fields[-1] && $fields[-1] ne $empty_string ) { | ||
| 1465 | |||
| 1466 | $control->set_file_name( \$fields[-1] ); | ||
| 1467 | $control->set_suffix(); | ||
| 1468 | $control->set_first_name(); | ||
| 1469 | my $suffix = $control->get_suffix(); | ||
| 1470 | my $first_name = $control->get_first_name(); | ||
| 1471 | $file_dialog->{_flow_name_in} = $fields[-1]; | ||
| 1472 | |||
| 1473 | # print("file_dialog,_user_built_flow_Delete_perl_file, Delete,suffix: $suffix\n"); | ||
| 1474 | # print("file_dialog,,_user_built_flow_Delete_perl_file, Delete,first_name: $first_name\n"); | ||
| 1475 | # print("1. file_dialog,_user_built_flow_Delete_perl_file, flow_name_out: $file_dialog->{_flow_name_in}\n"); | ||
| 1476 | # print ("file-dialog _user_built_flow_Delete_perl_file, _last_parameter_index_touched_color: $file_dialog->{_last_parameter_index_touched_color} \n"); | ||
| 1477 | |||
| 1478 | } | ||
| 1479 | else { | ||
| 1480 | # print( | ||
| 1481 | #"file_dialog,_user_built_flow_Delete_perl_file, No file name selected NADA\n" | ||
| 1482 | # ); | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | $gui_history->set4FileDialog_Delete_end(); # ?? purpose? needed? | ||
| 1486 | |||
| 1487 | } # end pre_OK | ||
| 1488 | |||
| 1489 | return ($empty_string); | ||
| 1490 | |||
| 1491 | } | ||
| 1492 | |||
| 1493 | =head2 sub _user_built_flow_SaveAs_perl_file | ||
| 1494 | |||
| 1495 | foreach my $key (sort keys %$file_dialog) { | ||
| 1496 | print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); | ||
| 1497 | } | ||
| 1498 | =cut | ||
| 1499 | |||
| 1500 | sub _user_built_flow_SaveAs_perl_file { | ||
| 1501 | |||
| 1502 | my ($self) = @_; | ||
| 1503 | |||
| 1504 | # local location within GUI | ||
| 1505 | # and for file dialog | ||
| 1506 | # print("0. file_dialog, user_built_flow_SaveAs_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n"); | ||
| 1507 | |||
| 1508 | $gui_history->set_hash_ref($file_dialog); | ||
| 1509 | $gui_history->set4FileDialog_SaveAs_start(); | ||
| 1510 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1511 | |||
| 1512 | # print("1. file_dialog, user_built_flow_SaveAs_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n"); | ||
| 1513 | $decisions->set4FileDialog_SaveAs($file_dialog); | ||
| 1514 | my $pre_req_ok = $decisions->get4FileDialog_SaveAs(); | ||
| 1515 | |||
| 1516 | if ($pre_req_ok) { | ||
| 1517 | |||
| 1518 | # print("3. file_dialog, _user_built_flow_SaveAs_perl_file ,SaveAs, pre_r_set_file_patheq_ok= $pre_req_ok \n"); | ||
| 1519 | # print("2. file_dialog, _user_built_flow_SaveAs_perl_file _is_user_built_flow: $file_dialog->{_is_user_built_flow}\n"); | ||
| 1520 | |||
| 1521 | my $whereami = whereami->new(); | ||
| 1522 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1523 | |||
| 1524 | my @fields; | ||
| 1525 | my $full_path_name; | ||
| 1526 | |||
| 1527 | # print ("file_dialog _user_built_flow_SaveAs_perl_file_user_built_flow_SaveAs_perl_file, _last_parameter_index_touched_color: $file_dialog->{_last_parameter_index_touched_color} \n"); | ||
| 1528 | |||
| 1529 | # make the file paths for the current file_dialog type ( Save, SaveAs, Open, Data etc.)} | ||
| 1530 | _set_file_path(); | ||
| 1531 | |||
| 1532 | # collects the name of the data file to be opened | ||
| 1533 | _FileDialog(); # file dialog mega-widget | ||
| 1534 | |||
| 1535 | my $topic = $file_dialog->{_dialog_type}; | ||
| 1536 | |||
| 1537 | # print("file-dialog _user_built_flow_SaveAs_perl_file, file_dialog->{_dialog_type}: $topic\n"); | ||
| 1538 | $full_path_name = $file_dialog->{_selected_file_name}; | ||
| 1539 | |||
| 1540 | # print("file-dialog _user_built_flow_SaveAs_perl_file, If not cancelled, full_path_name: $full_path_name\n"); | ||
| 1541 | |||
| 1542 | if ( length $full_path_name ) { | ||
| 1543 | |||
| 1544 | @fields = split( /\//, $full_path_name ); | ||
| 1545 | $file_dialog->{_is_selected_file_name} = $true; | ||
| 1546 | |||
| 1547 | # print("file-dialog _user_built_flow_SaveAs_perl_file,file_dialog->{_is_selected_file_name}=$file_dialog->{_is_selected_file_name} \n"); | ||
| 1548 | |||
| 1549 | } | ||
| 1550 | else { | ||
| 1551 | |||
| 1552 | # print("file_dialog, _user_built_flow_SaveAs_perl_file,Cancelled. No output flow name selected NADA\n"); | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1556 | my $length = $default_param_specs->{_length}; | ||
| 1557 | |||
| 1558 | # remove suffix (pl, su, txt ) from selected file name | ||
| 1559 | if ( defined $fields[-1] | ||
| 1560 | && $fields[-1] ne $empty_string ) | ||
| 1561 | { | ||
| 1562 | |||
| 1563 | $control->set_file_name( \$fields[-1] ); | ||
| 1564 | $control->set_suffix(); | ||
| 1565 | $control->set_first_name(); | ||
| 1566 | my $suffix = $control->get_suffix(); | ||
| 1567 | my $first_name = $control->get_first_name(); | ||
| 1568 | $file_dialog->{_flow_name_out} = $fields[-1]; | ||
| 1569 | |||
| 1570 | # print("file_dialog,_user_built_flow_SaveAs_perl_file, SaveAs,suffix: $suffix\n"); | ||
| 1571 | # print("file_dialog,,_user_built_flow_SaveAs_perl_file, SaveAs,first_name: $first_name\n"); | ||
| 1572 | # print("1. file_dialog,_user_built_flow_SaveAs_perl_file, flow_name_out: $file_dialog->{_flow_name_out}\n"); | ||
| 1573 | # print ("file-dialog _user_built_flow_SaveAs_perl_file, _last_parameter_index_touched_color: $file_dialog->{_last_parameter_index_touched_color} \n"); | ||
| 1574 | |||
| 1575 | } | ||
| 1576 | else { | ||
| 1577 | |||
| 1578 | # print("file_dialog,_user_built_flow_SaveAs_perl_file, No file name selected NADA\n"); | ||
| 1579 | } | ||
| 1580 | |||
| 1581 | $gui_history->set4FileDialog_SaveAs_end(); # ?? purpose? needed? | ||
| 1582 | } | ||
| 1583 | return ($empty_string); | ||
| 1584 | } | ||
| 1585 | |||
| 1586 | =head2 sub _user_built_flow_close_data_file | ||
| 1587 | |||
| 1588 | if ($topic eq 'Data') { # Seen as DATA | ||
| 1589 | Select was used to open a data file | ||
| 1590 | But now the _FileDialog is closing | ||
| 1591 | If we are in here it is because we are adding | ||
| 1592 | a data-file name to the entry widget under a parameter value | ||
| 1593 | |||
| 1594 | We are already inside an Entry Widget!! | ||
| 1595 | |||
| 1596 | foreach my $key (sort keys %$gui_history) { | ||
| 1597 | print (" file_dialog key is $key, value is $file_dialog->{$key}\n"); | ||
| 1598 | } | ||
| 1599 | |||
| 1600 | =cut | ||
| 1601 | |||
| 1602 | sub _user_built_flow_close_data_file { | ||
| 1603 | my ($self) = @_; | ||
| 1604 | |||
| 1605 | my $param_widgets = param_widgets->new(); | ||
| 1606 | |||
| 1607 | my @fields; | ||
| 1608 | my $full_path_name; | ||
| 1609 | my $topic = $file_dialog->{_dialog_type}; | ||
| 1610 | $full_path_name = $file_dialog->{_selected_file_name}; | ||
| 1611 | |||
| 1612 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1613 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1614 | my $length = $default_param_specs->{_length}; | ||
| 1615 | |||
| 1616 | if ($full_path_name) { | ||
| 1617 | |||
| 1618 | @fields = split( /\//, $full_path_name ); | ||
| 1619 | $file_dialog->{_is_selected_file_name} = $true; | ||
| 1620 | |||
| 1621 | } | ||
| 1622 | else { | ||
| 1623 | |||
| 1624 | # print("file_dialog,_user_built_flow_close_data_file, Cancelled. No output flow name selected NADA\n"); | ||
| 1625 | } | ||
| 1626 | |||
| 1627 | # Open was used to open a data file | ||
| 1628 | # But now the _FileDialog is closing | ||
| 1629 | $decisions->set4FileDialog_select($file_dialog); | ||
| 1630 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 1631 | |||
| 1632 | # print("1. file_dialog,_user_built_flow_close_data_file,pre_req_ok= $pre_req_ok \n"); | ||
| 1633 | |||
| 1634 | if ($pre_req_ok) { | ||
| 1635 | |||
| 1636 | if ( $user_built_flow_open_data_widget_type eq 'Entry' ) { | ||
| 1637 | |||
| 1638 | $param_widgets->set_entry_button_chosen_widget( | ||
| 1639 | $user_built_flow_open_data_selected_Entry_widget); | ||
| 1640 | |||
| 1641 | # Need to set the length and first_idx either with the following | ||
| 1642 | # belos, or $param-widgets->set_length($file_dialog_length) | ||
| 1643 | $param_widgets->set_first_idx($first_idx); | ||
| 1644 | $param_widgets->set_length($length); | ||
| 1645 | |||
| 1646 | # print("2. file_dialog _user_built_flow_close_data_file, selected_Entry_widget: $user_built_flow_open_data_selected_Entry_widget\n"); | ||
| 1647 | |||
| 1648 | $file_dialog->{_parameter_value_index} = | ||
| 1649 | $user_built_flow_open_data_parameter_value_index; | ||
| 1650 | |||
| 1651 | #$param_widgets->get_entry_button_chosen_index(); | ||
| 1652 | # print( | ||
| 1653 | # "3. file_dialog,_user_built_flow_close_data_file, parameter_value_index= $user_built_flow_open_data_parameter_value_index\n"); | ||
| 1654 | |||
| 1655 | $file_dialog->{_entry_button_label} = | ||
| 1656 | $param_widgets->get_label4entry_button_chosen(); | ||
| 1657 | |||
| 1658 | # print( | ||
| 1659 | # "5. file_dialog,_user_built_flow_close_data_file,entry_button_label = $file_dialog->{_entry_button_label}\n" | ||
| 1660 | # ); | ||
| 1661 | |||
| 1662 | # print("file_dialog,_user_built_flow_close_data_file, both flows and superflows require the following\n"); | ||
| 1663 | my $current_index = | ||
| 1664 | $user_built_flow_open_data_parameter_value_index; | ||
| 1665 | |||
| 1666 | # $file_dialog->{_parameter_value_index}; | ||
| 1667 | |||
| 1668 | # set index touched so that iFile can highlight the correct index | ||
| 1669 | # Also update the index touched so that the main program can update it later via _check4changes | ||
| 1670 | |||
| 1671 | $file_dialog->{_last_parameter_index_touched_color} = | ||
| 1672 | $current_index; | ||
| 1673 | |||
| 1674 | # print("file_dialog,_user_built_flow_close_data_file,Select,current parameter index $current_index\n"); | ||
| 1675 | |||
| 1676 | @{ $file_dialog->{_check_buttons_settings_aref} }[$current_index] = | ||
| 1677 | $on; | ||
| 1678 | |||
| 1679 | if ( $file_dialog->{_selected_file_name} ) { | ||
| 1680 | |||
| 1681 | # print("1. file_dialog,_user_built_flow_close_data_file, full name with suffix= $fields[-1]\n"); | ||
| 1682 | |||
| 1683 | # remove *.su suffix, get only first name, add single quotes | ||
| 1684 | $control->set_file_name_sref( \$fields[-1] ); | ||
| 1685 | $control->remove_su_suffix4sref(); | ||
| 1686 | $file_dialog->{_selected_file_name} = | ||
| 1687 | $control->get_w_single_quotes(); | ||
| 1688 | _set_selected_file_name( $file_dialog->{_selected_file_name} ); | ||
| 1689 | |||
| 1690 | # print("2. file_dialog,_user_built_flow_close_data_file, name after control = $file_dialog->{_selected_file_name}\n"); | ||
| 1691 | |||
| 1692 | } | ||
| 1693 | else { | ||
| 1694 | |||
| 1695 | # print("file_dialog,user_built_flow_close_data_file No file was selected\n"); | ||
| 1696 | # print("file_dialog,user_built_flow_close_data_file ,last path touched was | ||
| 1697 | # $file_dialog->{_last_path_touched}\n") ; | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | # only user-built flows require the following | ||
| 1701 | if ( $file_dialog->{_is_flow_listbox_grey_w} | ||
| 1702 | || $file_dialog->{_is_flow_listbox_pink_w} | ||
| 1703 | || $file_dialog->{_is_flow_listbox_green_w} | ||
| 1704 | || $file_dialog->{_is_flow_listbox_blue_w} | ||
| 1705 | || $file_dialog->{_is_flow_listbox_color_w} ) | ||
| 1706 | { | ||
| 1707 | |||
| 1708 | # print("2. file_dialog, _user_built_flow_close_data_file,suffixless selected_file_name: $file_dialog->{_selected_file_name}\n"); | ||
| 1709 | |||
| 1710 | # $file_dialog->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 1711 | |||
| 1712 | # print("2. file_dialog, _user_built_flow_open_data_file @{$file_dialog->{_values_aref}}\n"); | ||
| 1713 | |||
| 1714 | # flows will be updated via flow_select, which is activated | ||
| 1715 | # in iFile->close() - todo? | ||
| 1716 | # reset focus on item last touched in flow - todo? | ||
| 1717 | # find which listbox and which listbox_item | ||
| 1718 | # change the Entry Value in param widgets | ||
| 1719 | # update Entry Value | ||
| 1720 | # | ||
| 1721 | |||
| 1722 | # Here we update the value of the Entry widget (in GUI) with the selected file name | ||
| 1723 | # Now might be a good moment to update the parameter_widgets with the updated value | ||
| 1724 | # update endtry those parameters | ||
| 1725 | # my $selected_Entry_widget = $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 1726 | # param_widgets ->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 1727 | # $file_dialog->{_parameter_value_index} = $param_widgets->get_entry_button_chosen_index(); | ||
| 1728 | # $file_dialog->{_entry_button_label} = $param_widgets->get_label4entry_button_chosen(); | ||
| 1729 | # my $current_index = $file_dialog->{_parameter_value_index}; | ||
| 1730 | # $param_widgets ->redisplay_values(); | ||
| 1731 | # | ||
| 1732 | # Make sure to place focus again on the updated widget so other modules can find the selection | ||
| 1733 | # $selected_Entry_widget ->focus; # from above | ||
| 1734 | |||
| 1735 | # $file_dialog->{_values_aref} = $param_widgets ->get_values_aref(); | ||
| 1736 | # print("file_dialog, _user_built_flow_close_data_file @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 1737 | # print("file_dialog, last_flow_listbox_touched_w: $file_dialog->{_last_flow_listbox_touched_w} \n"); | ||
| 1738 | |||
| 1739 | # highlight the last flow index touched | ||
| 1740 | # requires that we define the last_lisbtox_color_w in color_flow every time we call this Data | ||
| 1741 | # for now is too complitacted | ||
| 1742 | # $iFile->close($file_dialog); | ||
| 1743 | |||
| 1744 | } | ||
| 1745 | |||
| 1746 | } | ||
| 1747 | else { | ||
| 1748 | print( | ||
| 1749 | "file_dialog,_pre-built_superflow_path no widget type selected \n" | ||
| 1750 | ); | ||
| 1751 | |||
| 1752 | } # widget of type = 'Entry' | ||
| 1753 | |||
| 1754 | #$file_dialog->set4FileDialog_select_start(); #needed? | ||
| 1755 | } # if prereq_OK | ||
| 1756 | |||
| 1757 | } | ||
| 1758 | |||
| 1759 | =head2 sub _user_built_flow_close_path | ||
| 1760 | |||
| 1761 | if ($topic eq 'Path') { | ||
| 1762 | Select was used to open a diretory path | ||
| 1763 | But now the _FileDialog is closing | ||
| 1764 | |||
| 1765 | =cut | ||
| 1766 | |||
| 1767 | sub _user_built_flow_close_path { | ||
| 1768 | my ($self) = @_; | ||
| 1769 | |||
| 1770 | # my $control = control->new(); | ||
| 1771 | my $whereami = whereami2->new(); | ||
| 1772 | |||
| 1773 | my @fields; | ||
| 1774 | my ( $full_path_name, $result ); | ||
| 1775 | my $topic = $file_dialog->{_dialog_type}; | ||
| 1776 | my $last_path_touched = $file_dialog->{_last_path_touched}; | ||
| 1777 | |||
| 1778 | if ( defined $last_path_touched | ||
| 1779 | && $last_path_touched ne $empty_string ) | ||
| 1780 | { | ||
| 1781 | |||
| 1782 | $file_dialog->{_is_selected_path} = $true; | ||
| 1783 | |||
| 1784 | } | ||
| 1785 | else { | ||
| 1786 | $file_dialog->{_is_selected_path} = $false; | ||
| 1787 | print("file_dialog, _user_built_flow_close_path, Cancelled. No path\n"); | ||
| 1788 | } | ||
| 1789 | |||
| 1790 | # open was used to open a path | ||
| 1791 | # But now the _FileDialog is closing | ||
| 1792 | $decisions->set4FileDialog_select($file_dialog); | ||
| 1793 | my $pre_req_ok = $decisions->get4FileDialog_select(); | ||
| 1794 | |||
| 1795 | # print("1. file_dialog,_user_built_flow_close_path,pre_req_ok= $pre_req_ok \n"); | ||
| 1796 | |||
| 1797 | if ($pre_req_ok) { | ||
| 1798 | |||
| 1799 | my $widget_type = | ||
| 1800 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 1801 | |||
| 1802 | # print("file_dialog _user_built_flow_close_path selected widget type is = $widget_type \n"); | ||
| 1803 | |||
| 1804 | if ( defined( $file_dialog->{_last_path_touched} ) | ||
| 1805 | and $file_dialog->{_last_path_touched} ne $empty_string ) | ||
| 1806 | { | ||
| 1807 | |||
| 1808 | $result = $file_dialog->{_last_path_touched}; # no abbreviation | ||
| 1809 | |||
| 1810 | # print("4. file_dialog,_user_built_flow_close_path,value that will be saved: $result\n"); | ||
| 1811 | |||
| 1812 | } | ||
| 1813 | else { | ||
| 1814 | print( | ||
| 1815 | "file_dialog,_user_built_flow_close_path No path was selected\n" | ||
| 1816 | ); | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | # update the gui with the new PATH | ||
| 1820 | _set_selected_file_name($result); | ||
| 1821 | |||
| 1822 | $gui_history->set4user_built_flow_close_path_end(); | ||
| 1823 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1824 | |||
| 1825 | } # if prereq_OK | ||
| 1826 | |||
| 1827 | return ($empty_string); | ||
| 1828 | } | ||
| 1829 | |||
| 1830 | =head2 sub _user_built_flow_close_perl_file | ||
| 1831 | |||
| 1832 | =cut | ||
| 1833 | |||
| 1834 | sub _user_built_flow_close_perl_file { | ||
| 1835 | my ($self) = @_; | ||
| 1836 | |||
| 1837 | my $file_dialog_messages = message_director->new(); | ||
| 1838 | |||
| 1839 | my @fields; | ||
| 1840 | my $full_path_name; | ||
| 1841 | |||
| 1842 | # Should be Flow: Possibles are Data, Open (a flow), SaveAs, Delete | ||
| 1843 | my $topic = $file_dialog->{_dialog_type}; | ||
| 1844 | |||
| 1845 | $full_path_name = $file_dialog->{_selected_file_name}; | ||
| 1846 | |||
| 1847 | # print("file_dialog,_user_built_flow_close_perl_file, full_path_name: $full_path_name\n"); | ||
| 1848 | |||
| 1849 | if ( length $full_path_name ) { | ||
| 1850 | |||
| 1851 | my $last_path_touched = $file_dialog->{_last_path_touched}; | ||
| 1852 | |||
| 1853 | # print("file_dialog,_user_built_flow_close_perl_file, last_path_touched: $last_path_touched\n"); | ||
| 1854 | |||
| 1855 | @fields = split( /\//, $full_path_name ); | ||
| 1856 | $file_dialog->{_is_selected_file_name} = $true; | ||
| 1857 | $file_dialog->{_flow_name_in} = $fields[-1]; | ||
| 1858 | |||
| 1859 | if ( length $last_path_touched ) { | ||
| 1860 | |||
| 1861 | # = false for perl flow paths | ||
| 1862 | $file_dialog->{_is_selected_path} = $false; | ||
| 1863 | |||
| 1864 | } | ||
| 1865 | else { | ||
| 1866 | # =true for data paths | ||
| 1867 | $file_dialog->{_is_selected_path} = $true; | ||
| 1868 | print("file_dialog, No last path touched\n"); | ||
| 1869 | } | ||
| 1870 | |||
| 1871 | # print("file_dialog,_user_built_flow_close_perl_file,fields= $fields[-1]\n"); | ||
| 1872 | # print("file_dialog,_user_built_flow_close_perl_file, flow_name_in: $file_dialog->{_flow_name_in}\n"); | ||
| 1873 | |||
| 1874 | $decisions->set4FileDialog_open_perl($file_dialog); | ||
| 1875 | my $pre_req_ok = $decisions->get4FileDialog_open_perl(); | ||
| 1876 | |||
| 1877 | if ($pre_req_ok) { | ||
| 1878 | |||
| 1879 | # print("2. file_dialog,_user_built_flow_close_perl_file,Open,pre_req_ok= $pre_req_ok \n"); | ||
| 1880 | $file_dialog->{_path} = $iFile->get_Open_perl_flow_path(); | ||
| 1881 | |||
| 1882 | return ($true); | ||
| 1883 | |||
| 1884 | } | ||
| 1885 | else { | ||
| 1886 | # print( | ||
| 1887 | # "file_dialog,_user_built_flow_close_perl_file, User selected Cancel | ||
| 1888 | # No output flow name selected NADA\n" | ||
| 1889 | # ); | ||
| 1890 | return ($false); | ||
| 1891 | } | ||
| 1892 | |||
| 1893 | } | ||
| 1894 | else { | ||
| 1895 | # print("file_dialog,_user_built_flow_close_perl_file, flow_name_in: full path name missing\n"); | ||
| 1896 | return ($empty_string); | ||
| 1897 | } | ||
| 1898 | } | ||
| 1899 | |||
| 1900 | =head2 sub _user_built_flow_open_data_file | ||
| 1901 | |||
| 1902 | seen in the GUI as "File/Data" | ||
| 1903 | opens data sets for a user_built_flow | ||
| 1904 | aka Data | ||
| 1905 | Select is for pre-existing Data Sets | ||
| 1906 | Then updates the GUI param widgets | ||
| 1907 | The updated param values should be saved the next time that the flow is selected | ||
| 1908 | |||
| 1909 | TODO make sure that when a differently-colored flow is selected the updated widgets | ||
| 1910 | are stored | ||
| 1911 | |||
| 1912 | foreach my $key (sort keys %$file_dialog) { | ||
| 1913 | print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); | ||
| 1914 | } | ||
| 1915 | |||
| 1916 | =cut | ||
| 1917 | |||
| 1918 | sub _user_built_flow_open_data_file { | ||
| 1919 | my ($self) = @_; | ||
| 1920 | |||
| 1921 | my $param_widgets = param_widgets->new(); | ||
| 1922 | my $whereami = whereami->new(); | ||
| 1923 | |||
| 1924 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 1925 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 1926 | my $length = $default_param_specs->{_length}; | ||
| 1927 | |||
| 1928 | # print ("1. file_dialog,_user_built_flow_open_data_file, is_last_parameter_index_touched_color: $file_dialog->{_is_last_parameter_index_touched_color} \n"); | ||
| 1929 | # print ("1. file_dialog,_user_built_flow_open_data_file, is_last_flow_index_touched: $file_dialog->{_is_last_flow_index_touched} \n"); | ||
| 1930 | # print (" 2. file_dialog,_user_built_flow_open_data_file->{_is_parameter_listbox_grey_w}: $file_dialog->{_is_parameter_listbox_grey_w}\n"); | ||
| 1931 | # print (" 2. file_dialog,_user_built_flow_open_data_file->{_last_parameter_index_touched_color}: $file_dialog->{_last_parameter_index_touched_color}\n"); | ||
| 1932 | |||
| 1933 | $gui_history->set_hash_ref($file_dialog); | ||
| 1934 | $gui_history->set4FileDialog_open_start(); | ||
| 1935 | |||
| 1936 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 1937 | |||
| 1938 | # if an appropriate entry widget is first selected, i.e., Entry | ||
| 1939 | # get index of entry button pressed | ||
| 1940 | # find out which entry button has been chosen | ||
| 1941 | # confirm that it IS the file button | ||
| 1942 | # TODO determine the required file type and file path | ||
| 1943 | # TODO from the *_spec.pm file for the particular program in the flow. | ||
| 1944 | |||
| 1945 | $user_built_flow_open_data_widget_type = | ||
| 1946 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 1947 | |||
| 1948 | if ( $user_built_flow_open_data_widget_type eq 'Entry' ) | ||
| 1949 | { # for extra certainty | ||
| 1950 | |||
| 1951 | # print("1. file_dialog,_user_built_flow_open_data_file, selected widget_type=$user_built_flow_open_data_widget_type \n"); | ||
| 1952 | |||
| 1953 | $user_built_flow_open_data_selected_Entry_widget = | ||
| 1954 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 1955 | $param_widgets->set_entry_button_chosen_widget( | ||
| 1956 | $user_built_flow_open_data_selected_Entry_widget); | ||
| 1957 | |||
| 1958 | # Need to set the length and first_idx | ||
| 1959 | $param_widgets->set_first_idx($first_idx); | ||
| 1960 | $param_widgets->set_length($length); | ||
| 1961 | |||
| 1962 | # print("2. file_dialog _user_built_flow_open_data_file, selected_Entry_widget: $user_built_flow_open_data_selected_Entry_widget\n"); | ||
| 1963 | $user_built_flow_open_data_parameter_value_index = | ||
| 1964 | $param_widgets->get_entry_button_chosen_index(); | ||
| 1965 | $file_dialog->{_parameter_value_index} = | ||
| 1966 | $user_built_flow_open_data_parameter_value_index; | ||
| 1967 | my $index = $user_built_flow_open_data_parameter_value_index; | ||
| 1968 | |||
| 1969 | # print("file_dialog,_user_built_flow_open_data_file,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 1970 | # print("file_dialog,_user_built_flow_open_data_file, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 1971 | |||
| 1972 | if ( $index >= 0 ) { # also for additional certainty | ||
| 1973 | |||
| 1974 | # e.g. Data_Pl_SEISMIC, Data, Path, Open, Delete, etc. | ||
| 1975 | my $topic = _get_dialog_type(); | ||
| 1976 | |||
| 1977 | # print( | ||
| 1978 | # "4. file_dialog,_user_built_flow_open_data_file, parameter_value_index= $index\n" | ||
| 1979 | # ); | ||
| 1980 | |||
| 1981 | $file_dialog->{_entry_button_label} = | ||
| 1982 | $param_widgets->get_label4entry_button_chosen(); | ||
| 1983 | |||
| 1984 | # print("5. file_dialog,_user_built_flow_open_data_file,entry_button_label = $file_dialog->{_entry_button_label}\n"); | ||
| 1985 | |||
| 1986 | # use iFile to determine the correct data path (directory ) | ||
| 1987 | $iFile->set_entry($file_dialog); | ||
| 1988 | $iFile->set_parameter_value_index($file_dialog); | ||
| 1989 | $iFile->set_flow_type_h($file_dialog); # user_built | ||
| 1990 | $iFile->set_dialog_type($topic); | ||
| 1991 | $iFile->set_values_aref($file_dialog) | ||
| 1992 | ; # will determine the DIR based on type of data set | ||
| 1993 | $iFile->set_prog_name_sref($file_dialog); | ||
| 1994 | |||
| 1995 | $file_dialog->{_path} = $iFile->get_Data_path(); | ||
| 1996 | |||
| 1997 | # print("5A. file_dialog,_user_built_flow_open_data_file $file_dialog->{_path}\n"); | ||
| 1998 | |||
| 1999 | # collects the name of the data file to be opened | ||
| 2000 | _FileDialog(); | ||
| 2001 | _user_built_flow_close_data_file(); | ||
| 2002 | |||
| 2003 | # print("6. file_dialog,_user_built_flow_open_data_file End\n"); | ||
| 2004 | |||
| 2005 | } | ||
| 2006 | } | ||
| 2007 | elsif ( $user_built_flow_open_data_widget_type eq 'MainWindow' ) | ||
| 2008 | { # opening a random file | ||
| 2009 | # print("file_dialog,_user_built_flow_open_data_file widget type is 'MainWindow' \n"); | ||
| 2010 | my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 2011 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 2012 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 2013 | |||
| 2014 | } | ||
| 2015 | else { | ||
| 2016 | print( | ||
| 2017 | "file_dialog,_user_built_flow_open_data_file no widget type selected \n" | ||
| 2018 | ); | ||
| 2019 | } | ||
| 2020 | |||
| 2021 | $gui_history->set4FileDialog_open_end(); | ||
| 2022 | |||
| 2023 | } | ||
| 2024 | |||
| 2025 | =head2 sub _user_built_flow_open_path | ||
| 2026 | find and get a directory path | ||
| 2027 | |||
| 2028 | =cut | ||
| 2029 | |||
| 2030 | sub _user_built_flow_open_path { | ||
| 2031 | |||
| 2032 | my ($self) = @_; | ||
| 2033 | |||
| 2034 | my $param_widgets = param_widgets->new(); | ||
| 2035 | my $whereami = whereami->new(); | ||
| 2036 | |||
| 2037 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 2038 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 2039 | my $length = $default_param_specs->{_length}; | ||
| 2040 | |||
| 2041 | $gui_history->set_hash_ref($file_dialog); | ||
| 2042 | $gui_history->set4FileDialog_open_start(); | ||
| 2043 | |||
| 2044 | # $gui_history->set4superflow_open_path_start(); | ||
| 2045 | $file_dialog = $gui_history->get_hash_ref(); # gets 93 | ||
| 2046 | |||
| 2047 | # If an appropriate Entry widget is first selected, | ||
| 2048 | # Find out which entry button has been chosen (index) | ||
| 2049 | # Confirm that it IS the file button | ||
| 2050 | |||
| 2051 | # print("file_dialog,_user_built_flow_open_path,_FileDialog_button pressed, \n"); | ||
| 2052 | # print("file_dialog, _user_built_flow_open_path selected _values_aref=@{$file_dialog->{_values_aref}}\n"); | ||
| 2053 | |||
| 2054 | # print("file_dialog, _user_built_flow_open_path selected _values_aref=@{$file_dialog->{_names_aref}}\n"); | ||
| 2055 | # print("file_dialog _user_built_flow_open_path selected parameter_values_frame = $file_dialog->{_parameter_values_frame} \n"); | ||
| 2056 | |||
| 2057 | my $widget_type = | ||
| 2058 | $whereami->widget_type( $file_dialog->{_parameter_values_frame} ); | ||
| 2059 | |||
| 2060 | # print("file_dialog _user_built_flow_open_path selected widget type is = $widget_type \n"); | ||
| 2061 | |||
| 2062 | if ( $widget_type eq 'Entry' ) { | ||
| 2063 | |||
| 2064 | # print("1. file_dialog,_user_built_flow_open_path, selected widget_type=$widget_type \n"); | ||
| 2065 | |||
| 2066 | my $selected_Entry_widget = | ||
| 2067 | $file_dialog->{_parameter_values_frame}->focusCurrent; | ||
| 2068 | $param_widgets->set_entry_button_chosen_widget($selected_Entry_widget); | ||
| 2069 | |||
| 2070 | # Need to set the length and first_idx or, $param-widgets->set_length($file_dialog_length); | ||
| 2071 | # print("file_dialog,_user_built_flow_open_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 2072 | # print("file_dialog,_user_built_flow_open_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 2073 | |||
| 2074 | $param_widgets->set_first_idx($first_idx); | ||
| 2075 | $param_widgets->set_length($length); | ||
| 2076 | |||
| 2077 | # print("2. file_dialog _user_built_flow_open_path, selected_Entry_widget: $selected_Entry_widget\n"); | ||
| 2078 | |||
| 2079 | $file_dialog->{_parameter_value_index} = | ||
| 2080 | $param_widgets->get_entry_button_chosen_index(); | ||
| 2081 | |||
| 2082 | # print("file_dialog,_user_built_flow_open_path,selection_Entry_widget HASH = $selected_Entry_widget\n"); | ||
| 2083 | # print("file_dialog,_user_built_flow_open_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n"); | ||
| 2084 | |||
| 2085 | if ( $file_dialog->{_parameter_value_index} >= 0 ) | ||
| 2086 | { # for additional certainty; but is it needed? | ||
| 2087 | |||
| 2088 | # e.g. Data_Pl_SEISMIC, Data, Path, Open, Delete, etc. | ||
| 2089 | my $topic = _get_dialog_type(); | ||
| 2090 | |||
| 2091 | # print( | ||
| 2092 | # "4. file_dialog,_user_built_flow_open_path, parameter_value_index= $file_dialog->{_parameter_value_index}\n" | ||
| 2093 | # ); | ||
| 2094 | $file_dialog->{_entry_button_label} = | ||
| 2095 | $param_widgets->get_label4entry_button_chosen(); | ||
| 2096 | |||
| 2097 | # print( | ||
| 2098 | # "5. file_dialog,_user_built_flow_open_path,entry_button_label = $file_dialog->{_entry_button_label}\n"); | ||
| 2099 | |||
| 2100 | # use iFile to determine the stored Path in the current configuration file | ||
| 2101 | $iFile->set_entry($file_dialog); # selected entry label | ||
| 2102 | $iFile->set_flow_type_h($file_dialog); # user_built | ||
| 2103 | |||
| 2104 | $iFile->set_values_aref($file_dialog) | ||
| 2105 | ; # will determine the DIR based on type of data set e.g., /home/gom/ | ||
| 2106 | $iFile->set_prog_name_sref($file_dialog); # e.g., Project_config | ||
| 2107 | $iFile->set_dialog_type($topic); # e.g. Data_Pl_SEISMIC, _Data | ||
| 2108 | |||
| 2109 | $file_dialog->{_path} = $iFile->get_Path(); | ||
| 2110 | |||
| 2111 | # print("1.file_dialog,_user_built_open_flow_path, PATH: $file_dialog->{_path} \n"); | ||
| 2112 | # print("1.file_dialog,_user_built_open_flow_path, _values_aref: @{$file_dialog->{_values_aref}}[0]\n"); | ||
| 2113 | |||
| 2114 | # open file dialog mega-widget | ||
| 2115 | _FileDialog(); | ||
| 2116 | |||
| 2117 | # updates the gui | ||
| 2118 | _user_built_flow_close_path(); | ||
| 2119 | |||
| 2120 | } | ||
| 2121 | } | ||
| 2122 | elsif ( $widget_type eq 'MainWindow' ) { # opening a random file | ||
| 2123 | # | ||
| 2124 | # print("file_dialog,_user_built_flow_open_path widget type is 'MainWindow' \n"); | ||
| 2125 | # my $message = $file_dialog->{_message_w}->FileDialog_button(0); | ||
| 2126 | # $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 2127 | # $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 2128 | # | ||
| 2129 | } | ||
| 2130 | else { | ||
| 2131 | print( | ||
| 2132 | "file_dialog,_pre-built_superflow_path no widget type selected \n"); | ||
| 2133 | } | ||
| 2134 | |||
| 2135 | } | ||
| 2136 | |||
| 2137 | =head2 sub _user_built_flow_open_perl_file | ||
| 2138 | Open flows written in Perl | ||
| 2139 | |||
| 2140 | foreach my $key (sort keys %$file_dialog) { | ||
| 2141 | print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); | ||
| 2142 | } | ||
| 2143 | |||
| 2144 | =cut | ||
| 2145 | |||
| 2146 | sub _user_built_flow_open_perl_file { | ||
| 2147 | my ($self) = @_; | ||
| 2148 | |||
| 2149 | # print("file_dialog,_user_built_flow_open_perl_file\n "); | ||
| 2150 | |||
| 2151 | my $param_widgets = param_widgets->new(); | ||
| 2152 | my $whereami = whereami->new(); | ||
| 2153 | |||
| 2154 | # my $iFile = iFile->new(); | ||
| 2155 | my $open_perl_file_messages = message_director->new(); | ||
| 2156 | |||
| 2157 | my $default_param_specs = $L_SU_global_constants->param(); | ||
| 2158 | my $first_idx = $default_param_specs->{_first_entry_idx}; | ||
| 2159 | my $length = $default_param_specs->{_length}; | ||
| 2160 | |||
| 2161 | $gui_history->set_hash_ref($file_dialog); | ||
| 2162 | $gui_history->set4FileDialog_open_perl_file_start(); | ||
| 2163 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 2164 | |||
| 2165 | # print("1. file_dialog,_user_built_flow_open_perl_file,_flowNsuperflow_name_w:$file_dialog->{_flowNsuperflow_name_w} \n"); | ||
| 2166 | # print("1. file_dialog,_user_built_flow_open_perl_file,_message_w:$file_dialog->{_message_w} \n"); | ||
| 2167 | # if an appropriate entry widget is first selected, ie., Entry | ||
| 2168 | # get index of entry button pressed | ||
| 2169 | # find out which entry button has been chosen | ||
| 2170 | # confirm that it IS the file button | ||
| 2171 | # TODO determine the required file type and file path | ||
| 2172 | # TODO from the *_spec.pm file for the particular program in the flow. | ||
| 2173 | # print("file_dialog,FileDialog_button pressed\n"); | ||
| 2174 | |||
| 2175 | # a blank message | ||
| 2176 | my $message = $open_perl_file_messages->null_button(0); | ||
| 2177 | $file_dialog->{_message_w}->delete( "1.0", 'end' ); | ||
| 2178 | $file_dialog->{_message_w}->insert( 'end', $message ); | ||
| 2179 | |||
| 2180 | # set path to flows | ||
| 2181 | $file_dialog->{_path} = $iFile->get_Open_perl_flow_path(); | ||
| 2182 | |||
| 2183 | # print("file_dialog,_user_built_flow_open_perl_file, path = $file_dialog->{_path}\n"); | ||
| 2184 | |||
| 2185 | # collects the name of the perl file to be opened | ||
| 2186 | _FileDialog(); # directory mega-widget | ||
| 2187 | |||
| 2188 | my $successful = _user_built_flow_close_perl_file(); | ||
| 2189 | |||
| 2190 | # print("file_dialog,_user_built_flow_open_perl_file, success= $successful \n"); | ||
| 2191 | |||
| 2192 | if ( $successful eq $true ) { | ||
| 2193 | |||
| 2194 | # print("file_dialog,_user_built_flow_open_perl_file, success\n"); | ||
| 2195 | $gui_history->set_hash_ref($file_dialog); | ||
| 2196 | $gui_history->set4FileDialog_open_perl_file_end(); | ||
| 2197 | |||
| 2198 | } | ||
| 2199 | elsif ( $successful eq $false ) { | ||
| 2200 | |||
| 2201 | # print("file_dialog,_user_built_flow_open_perl_file, unsuccessful\n"); | ||
| 2202 | $gui_history->set_hash_ref($file_dialog); | ||
| 2203 | $gui_history->set4FileDialog_open_perl_file_fail(); | ||
| 2204 | |||
| 2205 | } | ||
| 2206 | elsif ( $successful eq $empty_string ) { | ||
| 2207 | |||
| 2208 | # print("file_dialog,_user_built_flow_open_perl_file, no file name is available\n"); | ||
| 2209 | $gui_history->set_hash_ref($file_dialog); | ||
| 2210 | $gui_history->set4FileDialog_open_perl_file_fail(); | ||
| 2211 | |||
| 2212 | } | ||
| 2213 | else { | ||
| 2214 | print("file_dialog,_user_built_flow_open_perl_file, unexpected\n"); | ||
| 2215 | } | ||
| 2216 | |||
| 2217 | $file_dialog = $gui_history->get_hash_ref(); | ||
| 2218 | |||
| 2219 | # print (" file_dialog,_user_built_flow_open_perl_file, print gui_history.txt\n"); | ||
| 2220 | # $gui_history->view(); | ||
| 2221 | # print("1. file_dialog,_user_built_flow_open_perl_file,_flowNsuperflow_name_w:$file_dialog->{_flowNsuperflow_name_w} \n"); | ||
| 2222 | |||
| 2223 | } | ||
| 2224 | |||
| 2225 | =head2 get_selected_Entry_widget | ||
| 2226 | |||
| 2227 | =cut | ||
| 2228 | |||
| 2229 | sub get_selected_Entry_widget { | ||
| 2230 | |||
| 2231 | my ($self) = @_; | ||
| 2232 | my $result; | ||
| 2233 | |||
| 2234 | if ( length $user_built_flow_open_data_selected_Entry_widget ) { | ||
| 2235 | |||
| 2236 | $result = $user_built_flow_open_data_selected_Entry_widget; | ||
| 2237 | |||
| 2238 | } | ||
| 2239 | else { | ||
| 2240 | print("file_dialog, get_selected_Entry_widget, unexpected value\n"); | ||
| 2241 | } | ||
| 2242 | |||
| 2243 | return ($result); | ||
| 2244 | } | ||
| 2245 | |||
| 2246 | =head2 get_current_index | ||
| 2247 | |||
| 2248 | =cut | ||
| 2249 | |||
| 2250 | sub get_current_index { | ||
| 2251 | |||
| 2252 | my ($self) = @_; | ||
| 2253 | my $result; | ||
| 2254 | |||
| 2255 | if ( length $user_built_flow_open_data_parameter_value_index ) { | ||
| 2256 | |||
| 2257 | $result = $user_built_flow_open_data_parameter_value_index; | ||
| 2258 | |||
| 2259 | } | ||
| 2260 | else { | ||
| 2261 | print("file_dialog, get_current_index, unexpected value\n"); | ||
| 2262 | } | ||
| 2263 | |||
| 2264 | return ($result); | ||
| 2265 | } | ||
| 2266 | |||
| 2267 | =head2 sub get_file_path | ||
| 2268 | |||
| 2269 | obtain the full PATH needed to read and write Perl files | ||
| 2270 | |||
| 2271 | |||
| 2272 | =cut | ||
| 2273 | |||
| 2274 | sub get_file_path { | ||
| 2275 | my ($self) = @_; | ||
| 2276 | |||
| 2277 | if ( $file_dialog->{_path} ) { | ||
| 2278 | |||
| 2279 | my $perl_path = $file_dialog->{_path}; | ||
| 2280 | |||
| 2281 | # print("file_dialog,get_file_path, _path: $file_dialog->{_path}\n"); | ||
| 2282 | return ($perl_path); | ||
| 2283 | |||
| 2284 | } | ||
| 2285 | else { | ||
| 2286 | print("file_dialog,get_file_path, path is missing \n"); | ||
| 2287 | return ($empty_string); | ||
| 2288 | } | ||
| 2289 | } | ||
| 2290 | |||
| 2291 | =head2 sub get_hash_ref | ||
| 2292 | |||
| 2293 | bring gui history parameters in to share | ||
| 2294 | and update | ||
| 2295 | initialize default parameter values from gui_history | ||
| 2296 | needed herein | ||
| 2297 | |||
| 2298 | |||
| 2299 | =cut | ||
| 2300 | |||
| 2301 | sub get_hash_ref { | ||
| 2302 | my ($self) = @_; | ||
| 2303 | |||
| 2304 | if ($file_dialog) { | ||
| 2305 | |||
| 2306 | my $result = $file_dialog; | ||
| 2307 | return ($result); | ||
| 2308 | |||
| 2309 | } | ||
| 2310 | else { | ||
| 2311 | print("file_dialog,get_hash_ref, missing hash ref\n"); | ||
| 2312 | } | ||
| 2313 | |||
| 2314 | # print("file_dialog,_update_hash_ref: $gui_history->get_defaults()\n"); | ||
| 2315 | } | ||
| 2316 | |||
| 2317 | =head2 sub get_is_file_selected | ||
| 2318 | |||
| 2319 | return whether a file was selected | ||
| 2320 | by FileDialog | ||
| 2321 | |||
| 2322 | =cut | ||
| 2323 | |||
| 2324 | sub get_is_file_selected { | ||
| 2325 | |||
| 2326 | my ($self) = @_; | ||
| 2327 | |||
| 2328 | if ( length $file_dialog->{_is_file_selected} ) { | ||
| 2329 | |||
| 2330 | my $result = $file_dialog->{_is_file_selected}; | ||
| 2331 | |||
| 2332 | # print("file_dialog,get_is_file_selected, values_aref: @{$file_dialog->{_is_file_selected}}\n"); | ||
| 2333 | return ($result); | ||
| 2334 | |||
| 2335 | } | ||
| 2336 | else { | ||
| 2337 | # print("file_dialog, get_is_file_selected missing\n"); | ||
| 2338 | my $result = $false; | ||
| 2339 | return ($result); | ||
| 2340 | } | ||
| 2341 | } | ||
| 2342 | |||
| 2343 | =head2 sub _clear_perl_flow_name_in | ||
| 2344 | |||
| 2345 | =cut | ||
| 2346 | |||
| 2347 | sub _clear_perl_flow_name_in { | ||
| 2348 | my ($self) = @_; | ||
| 2349 | |||
| 2350 | $file_dialog->{_flow_name_in} = $empty_string; | ||
| 2351 | return (); | ||
| 2352 | } | ||
| 2353 | |||
| 2354 | =head2 sub get_perl_flow_name_in | ||
| 2355 | |||
| 2356 | =cut | ||
| 2357 | |||
| 2358 | sub get_perl_flow_name_in { | ||
| 2359 | my ($self) = @_; | ||
| 2360 | |||
| 2361 | if ( length $file_dialog->{_flow_name_in} ) { | ||
| 2362 | |||
| 2363 | my $perl_flow_name_in = $file_dialog->{_flow_name_in}; | ||
| 2364 | |||
| 2365 | # print( | ||
| 2366 | #"file_dialog,get_flow_name_in, _flow_name_in: $file_dialog->{_flow_name_in}\n" | ||
| 2367 | # ); | ||
| 2368 | return ($perl_flow_name_in); | ||
| 2369 | |||
| 2370 | } | ||
| 2371 | else { | ||
| 2372 | # print("file_dialog,get_flow_name_in, _flow_name_in = -1 \n"); | ||
| 2373 | my $perl_flow_name_in = $file_dialog->{_flow_name_in}; | ||
| 2374 | return ($perl_flow_name_in); | ||
| 2375 | } | ||
| 2376 | } | ||
| 2377 | |||
| 2378 | =head2 sub get_perl_flow_name_out | ||
| 2379 | |||
| 2380 | =cut | ||
| 2381 | |||
| 2382 | sub get_perl_flow_name_out { | ||
| 2383 | my ($self) = @_; | ||
| 2384 | |||
| 2385 | if ( $file_dialog->{_flow_name_out} ) { | ||
| 2386 | |||
| 2387 | my $perl_flow_name_out = $file_dialog->{_flow_name_out}; | ||
| 2388 | |||
| 2389 | # print("file_dialog,get_flow_name_out, _flow_name_out: $file_dialog->{_flow_name_out}\n"); | ||
| 2390 | return ($perl_flow_name_out); | ||
| 2391 | |||
| 2392 | } | ||
| 2393 | else { | ||
| 2394 | |||
| 2395 | # print("file_dialog,get_flow_name_out, _flow_name_out = -1 \n"); | ||
| 2396 | my $perl_flow_name_out = $file_dialog->{_flow_name_out}; | ||
| 2397 | return ($perl_flow_name_out); | ||
| 2398 | } | ||
| 2399 | } | ||
| 2400 | |||
| 2401 | =head2 sub get_last_parameter_index_touched_color | ||
| 2402 | |||
| 2403 | |||
| 2404 | =cut | ||
| 2405 | |||
| 2406 | sub get_last_parameter_index_touched_color { | ||
| 2407 | my ($self) = @_; | ||
| 2408 | |||
| 2409 | if ( $file_dialog->{_last_parameter_index_touched_color} >= 0 ) { | ||
| 2410 | |||
| 2411 | my $change = $file_dialog->{_last_parameter_index_touched_color}; | ||
| 2412 | |||
| 2413 | # print("file_dialog,get_last_parameter_index_touched_color, _last_parameter_index_touched: $file_dialog->{_last_parameter_index_touched_color}\n"); | ||
| 2414 | return ($change); | ||
| 2415 | |||
| 2416 | } | ||
| 2417 | else { | ||
| 2418 | |||
| 2419 | # print("file_dialog,get_last_parameter_index_touched_color, _last_parameter_index_touched_color = -1 NADA\n"); | ||
| 2420 | my $change = $file_dialog->{_last_parameter_index_touched_color}; | ||
| 2421 | return ($change); | ||
| 2422 | } | ||
| 2423 | } | ||
| 2424 | |||
| 2425 | =head2 sub get_selected_file_name | ||
| 2426 | |||
| 2427 | =cut | ||
| 2428 | |||
| 2429 | sub get_selected_file_name { | ||
| 2430 | |||
| 2431 | my ($self) = @_; | ||
| 2432 | |||
| 2433 | if ( defined $file_dialog->{_selected_file_name} | ||
| 2434 | && $file_dialog->{_selected_file_name} ne $empty_string ) | ||
| 2435 | { | ||
| 2436 | |||
| 2437 | my $result = $file_dialog->{_selected_file_name}; | ||
| 2438 | return ($result); | ||
| 2439 | |||
| 2440 | } | ||
| 2441 | else { | ||
| 2442 | |||
| 2443 | # print("file_dialog, get_selected_file_name, empty string\n"); | ||
| 2444 | return ($empty_string); | ||
| 2445 | } | ||
| 2446 | |||
| 2447 | } | ||
| 2448 | |||
| 2449 | =head2 sub get_values_aref | ||
| 2450 | |||
| 2451 | return reference to array of values | ||
| 2452 | belonging to one program | ||
| 2453 | (parameter values in Entry widgets within GUI) | ||
| 2454 | |||
| 2455 | =cut | ||
| 2456 | |||
| 2457 | sub get_values_aref { | ||
| 2458 | my ($self) = @_; | ||
| 2459 | |||
| 2460 | if ( $file_dialog->{_values_aref} ) { | ||
| 2461 | |||
| 2462 | my $values_aref = $file_dialog->{_values_aref}; | ||
| 2463 | |||
| 2464 | # print("file_dialog,,get_values_aref, values_aref: @{$file_dialog->{_values_aref}}\n"); | ||
| 2465 | return ($values_aref); | ||
| 2466 | |||
| 2467 | } | ||
| 2468 | else { | ||
| 2469 | print("file_dialog,get_values_aref missing\n"); | ||
| 2470 | } | ||
| 2471 | } | ||
| 2472 | |||
| 2473 | =head2 sub set_dialog_type | ||
| 2474 | |||
| 2475 | open (data for user-built and pre-built superflows) | ||
| 2476 | |||
| 2477 | open (perl programs of user-built flows) | ||
| 2478 | |||
| 2479 | save (perl program of user-built flow) | ||
| 2480 | |||
| 2481 | |||
| 2482 | =cut | ||
| 2483 | |||
| 2484 | sub set_dialog_type { | ||
| 2485 | my ( $self, $topic ) = @_; | ||
| 2486 | |||
| 2487 | if ($topic) { | ||
| 2488 | |||
| 2489 | $file_dialog->{_dialog_type} = $topic; | ||
| 2490 | |||
| 2491 | # print("file_dialog, set_dialog_type is $file_dialog->{_dialog_type}\n"); | ||
| 2492 | |||
| 2493 | } | ||
| 2494 | else { | ||
| 2495 | print("file_dialog, set_dialog_type , missing topic\n"); | ||
| 2496 | } | ||
| 2497 | return ($empty_string); | ||
| 2498 | } | ||
| 2499 | |||
| 2500 | =head2 sub set_prog_name_sref | ||
| 2501 | |||
| 2502 | in order to know what | ||
| 2503 | _spec file to read for | ||
| 2504 | behaviors | ||
| 2505 | |||
| 2506 | =cut | ||
| 2507 | |||
| 2508 | sub set_prog_name_sref { | ||
| 2509 | my ( $self, $name_sref ) = @_; | ||
| 2510 | |||
| 2511 | if ($name_sref) { | ||
| 2512 | |||
| 2513 | $file_dialog->{_prog_name_sref} = $name_sref; | ||
| 2514 | |||
| 2515 | # print("file_dialog, set_prog_name_sref , $file_dialog->{_prog_name_sref}\n"); | ||
| 2516 | |||
| 2517 | } | ||
| 2518 | else { | ||
| 2519 | print("file_dialog, set_prog_name_sref , missing name\n"); | ||
| 2520 | } | ||
| 2521 | return ($empty_string); | ||
| 2522 | } | ||
| 2523 | |||
| 2524 | =head2 sub set_flow_color | ||
| 2525 | |||
| 2526 | |||
| 2527 | =cut | ||
| 2528 | |||
| 2529 | sub set_flow_color { | ||
| 2530 | my ( $self, $flow_color ) = @_; | ||
| 2531 | |||
| 2532 | if ($flow_color) { | ||
| 2533 | |||
| 2534 | my $is_flow_listbox_color_w_text = | ||
| 2535 | '_is_flow_listbox_' . $flow_color . '_w'; | ||
| 2536 | $file_dialog->{_flow_color} = $flow_color; | ||
| 2537 | |||
| 2538 | # print("file_dialog, set_flow_color:$file_dialog->{_flow_color}\n"); | ||
| 2539 | $file_dialog->{$is_flow_listbox_color_w_text} = $true; | ||
| 2540 | |||
| 2541 | } | ||
| 2542 | elsif ( $flow_color eq $empty_string ) { | ||
| 2543 | |||
| 2544 | print("file_dialog, set_flow_color:no flow color; OK???\n"); | ||
| 2545 | |||
| 2546 | } | ||
| 2547 | else { | ||
| 2548 | print("file_dialog, set_flow_color, missing color\n"); | ||
| 2549 | } | ||
| 2550 | return ($empty_string); | ||
| 2551 | } | ||
| 2552 | |||
| 2553 | =head2 sub set_flow_type | ||
| 2554 | |||
| 2555 | user_built_flow | ||
| 2556 | or | ||
| 2557 | pre_built_superflow | ||
| 2558 | |||
| 2559 | =cut | ||
| 2560 | |||
| 2561 | sub set_flow_type { | ||
| 2562 | my ( $self, $how_built ) = @_; | ||
| 2563 | |||
| 2564 | if ($how_built) { | ||
| 2565 | |||
| 2566 | $file_dialog->{_flow_type} = $how_built; | ||
| 2567 | |||
| 2568 | } | ||
| 2569 | else { | ||
| 2570 | print("file_dialog, set_flow_type , missing how_built\n"); | ||
| 2571 | } | ||
| 2572 | return ($empty_string); | ||
| 2573 | } | ||
| 2574 | |||
| 2575 | =head2 sub set_hash_ref | ||
| 2576 | |||
| 2577 | bring in important values and their keys | ||
| 2578 | |||
| 2579 | =cut | ||
| 2580 | |||
| 2581 | sub set_hash_ref { | ||
| 2582 | my ( $self, $hash_ref ) = @_; | ||
| 2583 | |||
| 2584 | if ($hash_ref) { | ||
| 2585 | $gui_history->set_defaults($hash_ref); | ||
| 2586 | $file_dialog = $gui_history->get_defaults(); | ||
| 2587 | |||
| 2588 | # print("1. file_dialog, set_hash_ref,output gui history\n"); | ||
| 2589 | } | ||
| 2590 | |||
| 2591 | return ($empty_string); | ||
| 2592 | } | ||
| 2593 | |||
| 2594 | =head2 sub FileDialog_director | ||
| 2595 | |||
| 2596 | Associates the type of file-opening process | ||
| 2597 | with the correct module | ||
| 2598 | |||
| 2599 | Cleans previously used variables such as file names | ||
| 2600 | and file paths | ||
| 2601 | |||
| 2602 | =cut | ||
| 2603 | |||
| 2604 | sub FileDialog_director { | ||
| 2605 | my ($self) = @_; | ||
| 2606 | |||
| 2607 | # clear prior stored file names | ||
| 2608 | _clear_perl_flow_name_in(); | ||
| 2609 | |||
| 2610 | my $file_dialog_flow_type = _get_flow_type(); | ||
| 2611 | |||
| 2612 | if ( length $file_dialog_flow_type ) { | ||
| 2613 | |||
| 2614 | my $dispatch = { | ||
| 2615 | $flow_type_h->{_user_built} => \&_set_FileDialog2user_built_flow, | ||
| 2616 | $flow_type_h->{_pre_built_superflow} => | ||
| 2617 | \&_set_FileDialog2pre_built_superflow, | ||
| 2618 | }; | ||
| 2619 | $dispatch->{$file_dialog_flow_type}->(); | ||
| 2620 | |||
| 2621 | } | ||
| 2622 | else { | ||
| 2623 | print("file_dialog, FileDialog_director is missing flow type\n"); | ||
| 2624 | } | ||
| 2625 | return ($empty_string); | ||
| 2626 | } | ||
| 2627 | |||
| 2628 | =head2 sub set_file_dialog_sub_ref | ||
| 2629 | |||
| 2630 | =cut | ||
| 2631 | |||
| 2632 | sub set_file_dialog_sub_ref { | ||
| 2633 | my ( $self, $sub_ref ) = @_; | ||
| 2634 | |||
| 2635 | if ($sub_ref) { | ||
| 2636 | print("binding set_file_dialog_sub_ref, $sub_ref\n"); | ||
| 2637 | $file_dialog->{_sub_ref} = $sub_ref; | ||
| 2638 | |||
| 2639 | } | ||
| 2640 | else { | ||
| 2641 | print("file_dialog, set_FileDialog_button_sub_ref, missing sub ref\n"); | ||
| 2642 | } | ||
| 2643 | |||
| 2644 | return ($empty_string); | ||
| 2645 | } | ||
| 2646 | |||
| 2647 | 1; |