indexing description: "Hauptfenster der Anwendung, Dialog zum Wählen der Datei, Eingeben des Musters und zum Suchen" class MAIN_DIALOG inherit WEL_FRAME_WINDOW redefine on_menu_command, on_control_command end creation make feature -- Controls editFileName: WEL_SINGLE_LINE_EDIT editPattern: WEL_SINGLE_LINE_EDIT buttonSelectFile: WEL_PUSH_BUTTON buttonFind: WEL_PUSH_BUTTON buttonExit: WEL_PUSH_BUTTON staticFileName: WEL_STATIC staticPattern: WEL_STATIC staticResults: WEL_STATIC staticText1: WEL_STATIC staticText2: WEL_STATIC staticText3: WEL_STATIC staticResult1: WEL_STATIC staticResult2: WEL_STATIC staticResult3: WEL_STATIC feature {NONE} -- Initialization make is -- Create the main window. do make_top (Title) resize (450, 300) set_menu (main_menu) -- Controls erstellen !! editFileName.make (Current, "", 100,10, 200, 22, -1) !! editPattern.make (Current, "", 100,50, 200, 22, -1) !! buttonSelectFile.make (Current, "Browse", 310, 5, 100, 30, -1) !! buttonFind.make (Current, "Suche Starten", 310, 45, 100, 30, -1) !! buttonExit.make (Current, "Beenden", 310, 190, 100, 30, -1) !! staticFileName.make (Current, "Dateiname", 10, 10, 80, 17, -1) !! staticPattern.make (Current, "Suche nach", 10, 50, 80, 17, -1) !! staticResults.make (Current, "Ergebnis: Algorithmus Textstelle", 10, 100, 300, 17, -1) !! staticText1.make (Current, "Interner Suchalgorithmus: ", 10, 140, 170, 17, -1) !! staticText2.make (Current, "Brute-Force-Algorithmus: ", 10, 170, 170, 17, -1) !! staticText3.make (Current, "Shift-Or-Algorithmus: ", 10, 200, 170, 17, -1) !! staticResult1.make (Current, "(n/a)", 185, 140, 100, 17, -1) !! staticResult2.make (Current, "(n/a)", 185, 170, 100, 17, -1) !! staticResult3.make (Current, "(n/a)", 185, 200, 100, 17, -1) end feature {NONE} -- Implementation find is -- Lesen der Datei, deren Name im Editfeld steht, Erzeugen der Text- und Sucher- -- Objekte, durchsuchen mit den versch. Algorithmen require fileName_not_empty: not editFileName.Text.empty pattern_not_empty: not editPattern.Text.empty filename_exists: -- file_exists (editFileName.Text) local textFile: Plain_Text_File meintext: Text meinSucher: TextSucher Ergebnis: Integer do !! textFile.make_open_read (editFileName.Text) textFile.readStream(1000000) -- Intern staticResult1.set_text("Searching..."); ! InternTextSucher !meinSucher; !!meintext.make (textFile.last_string, meinSucher); ergebnis:= meintext.suche(editPattern.Text); staticResult1.set_text(ergebnis.out); -- ShiftOr staticResult2.set_text("Searching..."); ! ShiftOrTextSucher !meinSucher; meintext.setSucher (meinSucher); ergebnis:= meintext.suche(editPattern.Text); staticResult2.set_text(ergebnis.out); -- BruteForce staticResult3.set_text("Searching..."); ! BruteForceTextSucher !meinSucher; meintext.setSucher (meinSucher); ergebnis:= meintext.suche(editPattern.Text); staticResult3.set_text(ergebnis.out); end on_menu_command (menu_id: INTEGER) is -- Menübehandlung do inspect menu_id when Exit_id then destroy when Find_id then find when Open_id then choose_file.activate (Current) if choose_file.selected then editFileName.set_text(choose_file.file_name) end end end on_control_command (control: WEL_CONTROL) is -- Tastenbehandlung do if control= ButtonSelectFile then choose_file.activate (Current) if choose_file.selected then editFileName.set_text(choose_file.file_name) end end if control= ButtonFind then find end if control= ButtonExit then destroy end end choose_file: WEL_OPEN_FILE_DIALOG is -- Dialog box to choose a file. once !! Result.make ensure result_not_void: Result /= Void end main_menu: WEL_MENU is -- Window's menu once !! Result.make Result.append_popup (file_menu, "&Datei") ensure result_not_void: Result /= Void end file_menu: WEL_MENU is -- The file menu once !! Result.make Result.append_string ("&Öffnen... ", Open_id) Result.append_string ("&Suchen", Find_id) Result.append_separator Result.append_string ("E&xit", Exit_id) ensure result_not_void: Result /= Void end Open_id, Find_id, Exit_id: INTEGER is unique Title: STRING is "Demo für Pattern STRATEGY: Volltextsuche in Textdokumenten" -- Window's title end -- class MAIN_DIALOG