Skip to content

Commit ec66a62

Browse files
committed
dasdf
1 parent ad99d69 commit ec66a62

File tree

2 files changed

+3
-103
lines changed

2 files changed

+3
-103
lines changed

src/main/java/GUI.java

Lines changed: 3 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import java.io.IOException;
22

3-
import Infrastructure.Filesystem;
43
import javafx.application.Application;
54
import javafx.event.ActionEvent;
6-
import javafx.event.Event;
7-
import javafx.event.EventHandler;
85
import javafx.scene.Scene;
96
import javafx.scene.control.Button;
107
import javafx.scene.control.Label;
@@ -20,16 +17,13 @@
2017
import javafx.stage.Stage;
2118

2219
import java.util.LinkedHashMap;
23-
import java.util.HashSet;
2420

25-
import Crawler.Crawler;
2621

2722
public class GUI extends Application {
2823

2924
TextField SearchTextField;
3025
TextField UrlTextField;
3126
TextField PagesTextField;
32-
LinkedHashMap hashMap = Setup.getInstance();
3327
TextArea resultText;
3428

3529

@@ -53,104 +47,11 @@ public void start(Stage primaryStage) {
5347
PagesTextField = new TextField("# of pages");
5448
btnCrawler.setPrefWidth(170);
5549

50+
5651
btnCrawler.setOnAction(new SearchHandler<ActionEvent>(SearchTextField, resultText, UrlTextField, PagesTextField));
57-
// // @Override
58-
// public void handle(ActionEvent event) {
59-
// Filesystem.deleteFile("scrape");
60-
//
61-
// String url = UrlTextField.getText();
62-
// int numberOfPages = Integer.parseInt(PagesTextField.getText());
63-
//
64-
// Crawler crawler = new Crawler(url, numberOfPages);
65-
// crawler.crawl();
66-
//
67-
// LinkedHashMap hashMap2 = Setup.initialise("files/scrape");
68-
//
69-
//
70-
// System.out.println("created hashmap");
71-
//
72-
// String userInput = SearchTextField.getText(); //Collect input from textField
73-
// System.out.println(userInput);
74-
//
75-
// if (userInput.length() == 0) resultText.setText("Please enter a search query");
76-
//
77-
// else {
78-
//
79-
// long start = System.currentTimeMillis(); // Search time count start
80-
//
81-
// HashSet<String> results = Searcher.search(userInput, hashMap2);
82-
//
83-
// if (results == null) resultText.setText("The search did not find any results for " +userInput);
84-
//
85-
// else {
86-
// resultText.setText("Search Results for " +userInput +": \n"); //Resets the textArea for new results to be shown
87-
//
88-
// int count = 0;
89-
//
90-
// for(String result: results) {
91-
// resultText.appendText(result +"\n");
92-
// count++;
93-
// }
94-
//
95-
// long end = System.currentTimeMillis();
96-
//
97-
// float time = (float) ((end - start) / 1000); // Search time total ms
98-
//
99-
// resultText.appendText(results.size() +" results in " + time + " second(s).");
100-
// }
101-
//
102-
// }
103-
//
104-
// }
105-
// });
106-
107-
108-
// TODO: Turn these things into lambdas
109-
110-
//Add handle to btn (Search:)
52+
11153
btn.setOnAction(new SearchHandler<ActionEvent>(SearchTextField, resultText));
112-
// //* // @Override
113-
// public void handle(ActionEvent event) {
114-
// String userInput = SearchTextField.getText(); //Collect input from textField
115-
//
116-
// if (userInput.length() != 0) { // textField does not handle (userInput != null)
117-
// long start = System.currentTimeMillis(); // Search time count start
118-
//
119-
// HashSet<String> results = Searcher.search(userInput, hashMap);
120-
//
121-
// long end = System.currentTimeMillis(); // Search time count end
122-
//
123-
// long time = ((end - start)); // Search time total ms
124-
//
125-
// if (results == null) {
126-
// resultText.setText("The search did not find any results for '" +userInput+ "'");
127-
//
128-
// HashSet<String> similarWords = SimilarWords.retrieveSimilarWords(hashMap, userInput);
129-
// if (!similarWords.isEmpty()) { // If there are no similar words, don't try to display them
130-
// resultText.appendText("\n ...but, I found these similar words: ");
131-
// for (String similarWord: similarWords) {
132-
// resultText.appendText(similarWord + ", ");
133-
// }
134-
// }
135-
// //Maybe this should more correctly be handled somewhere else, like the searcher?
136-
// //TODO: Handle boolean searches, could be just not do similar words when boolean search.
137-
// } else {
138-
//
139-
// resultText.setText("Search Results for " +userInput +": \n"); //Resets the textArea for new results to be shown
140-
//
141-
// int count = 0;
142-
//
143-
// for(String result: results) { // for-each loop through the result and append
144-
// resultText.appendText(result +"\n");
145-
// count++;
146-
// }
147-
// resultText.appendText(count +" results in " +time +" milisecond(s).");
148-
// }
149-
// } else {
150-
// resultText.setText("Please enter a search query");
151-
// }
152-
// }
153-
// });
54+
15455

15556
//GridPane (grid - top)
15657
GridPane pane = new GridPane();

src/main/java/SearchHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
public class SearchHandler<T> implements EventHandler<ActionEvent> {
1414

15-
private String searchQuery;
1615
private LinkedHashMap<String, HashSet> hashMap = Setup.getInstance();
1716
private TextArea resultText;
1817
private TextField searchTextField;

0 commit comments

Comments
 (0)