Last fixs

- Add all albums to the loading process
- Add loading label
- Pressing enter while having the focus on the search bar now starts the search
This commit is contained in:
Tanguy Herbron 2018-10-14 23:22:01 +02:00
parent 7ed991435c
commit 6dce1c0820
7 changed files with 182 additions and 493 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -44,7 +44,7 @@ public class Runner {
try {
List<Album> listAlbum = new JSONSearchAlbum().find(searchString, false);
for(int i = 0; i < 1; i++)
for(int i = 0; i < listAlbum.size(); i++)
{
listAlbum.get(i).setTracks(JSONSearchAlbumTracks.find(listAlbum.get(i).getId()));
}
@ -103,7 +103,7 @@ public class Runner {
listAlbum = new DOMSearchAlbums().find(searchString, true);
// recuperation des titres de l album
for(int i = 0; i < 1; i++)
for(int i = 0; i < listAlbum.size(); i++)
{
listAlbum.get(i).setTracks(DOMSearchAlbumTracks.find(listAlbum.get(i).getId()));
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.MenuButton?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TextField?>
@ -10,7 +11,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.web.WebView?>
<VBox maxHeight="Infinity" maxWidth="Infinity" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
<VBox maxHeight="Infinity" maxWidth="Infinity" xmlns="http://javafx.com/javafx/8.0.181" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane maxHeight="Infinity" maxWidth="Infinity" prefHeight="460.0" prefWidth="640.0">
<columnConstraints>
@ -57,6 +58,7 @@
</MenuButton>
</children>
</GridPane>
<Label fx:id="loadingLabel" visible="false" alignment="CENTER" contentDisplay="CENTER" maxWidth="1.7976931348623157E308" text="Loading..." textAlignment="CENTER" GridPane.rowSpan="2" />
</children>
</GridPane>
</children>

View File

@ -9,14 +9,18 @@ import fr.ensim.xml.deezer.Runner;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
@ -53,55 +57,25 @@ public class MainWindow extends Application {
final MenuButton htmlButton = (MenuButton) scene.lookup("#htmlGeneratorSelector");
final MenuItem customOption = htmlButton.getItems().get(0);
final MenuItem staxOption = htmlButton.getItems().get(1);
final Label loadingLabel = (Label) scene.lookup("#loadingLabel");
final Thread uiThread = Thread.currentThread();
searchTextField.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode() == KeyCode.ENTER)
{
startSearch(menuButton.getText(), searchTextField.getText(), engine, loadingLabel);
}
}
});
searchButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if(menuButton.getText().equals(jsonOption.getText()))
{
Thread thread = new Thread()
{
public void run()
{
Runner runner = new Runner();
final File htmlFile = runner.start(searchTextField.getText().replaceAll("\\s", "%20"), useCustom);
Platform.runLater(new Runnable(){
@Override
public void run() {
engine.load(htmlFile.toURI().toString());
}
});
}
};
thread.start();
}
else
{
Thread thread = new Thread()
{
public void run()
{
Runner runner = new Runner();
final File htmlFile = runner.start(searchTextField.getText().replaceAll("\\s", "%20"), useDom, useCustom);
Platform.runLater(new Runnable(){
@Override
public void run() {
engine.load(htmlFile.toURI().toString());
}
});
}
};
thread.start();
}
startSearch(menuButton.getText(), searchTextField.getText(), engine, loadingLabel);
}
});
@ -160,6 +134,57 @@ public class MainWindow extends Application {
});
}
public void startSearch(String menuButtonStr, final String searchStr, final WebEngine engine, final Label loadingLabel)
{
loadingLabel.setVisible(true);
engine.loadContent("");
if(menuButtonStr.equals("JSON"))
{
Thread thread = new Thread()
{
public void run()
{
Runner runner = new Runner();
final File htmlFile = runner.start(searchStr.replaceAll("\\s", "%20"), useCustom);
Platform.runLater(new Runnable(){
@Override
public void run() {
engine.load(htmlFile.toURI().toString());
loadingLabel.setVisible(false);
}
});
}
};
thread.start();
}
else
{
Thread thread = new Thread()
{
public void run()
{
Runner runner = new Runner();
final File htmlFile = runner.start(searchStr.replaceAll("\\s", "%20"), useDom, useCustom);
Platform.runLater(new Runnable(){
@Override
public void run() {
engine.load(htmlFile.toURI().toString());
loadingLabel.setVisible(false);
}
});
}
};
thread.start();
}
}
public static void main(String[] args) {
launch(args);
}

View File

@ -1,10 +1,106 @@
22:41:09,806 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - >>find author=Shaka%20ponk
22:41:09,808 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - http://api.deezer.com/2.0/search/album?q=Shaka%20ponk&output=xml
22:41:15,186 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbums - >>readAlbums
22:41:15,223 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbums - <<readAlbums
22:41:15,223 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - <<find
22:41:15,225 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
22:41:15,225 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/47685332?output=xml
22:41:20,340 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
22:41:20,369 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
22:41:20,369 DEBUG fr.ensim.xml.deezer.stax.StAXHtmlAlbum - >>write
23:17:30,573 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - >>find author=Metallica
23:17:30,574 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - http://api.deezer.com/2.0/search/album?q=Metallica&output=xml
23:17:36,086 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbums - >>readAlbums
23:17:37,082 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbums - <<readAlbums
23:17:37,083 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - <<find
23:17:37,083 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:17:37,083 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581202?output=xml
23:17:42,332 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:42,835 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:42,835 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:17:42,835 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212377?output=xml
23:17:48,133 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:48,199 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:48,204 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:17:48,204 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/51001312?output=xml
23:17:53,528 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:54,014 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:54,014 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:17:54,015 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581762?output=xml
23:17:59,322 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:59,341 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:17:59,341 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:17:59,341 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212396?output=xml
23:18:04,634 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:04,737 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:04,737 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:04,737 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581972?output=xml
23:18:10,040 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:11,118 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:11,118 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:11,118 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/6941025?output=xml
23:18:16,413 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:16,459 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:16,459 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:16,459 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581218?output=xml
23:18:21,961 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:22,336 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:22,336 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:22,336 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/49896702?output=xml
23:18:27,615 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:27,623 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:27,623 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:27,623 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581190?output=xml
23:18:32,910 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:32,939 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:32,939 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:32,939 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212357?output=xml
23:18:38,241 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:38,331 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:38,331 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:38,331 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212391?output=xml
23:18:43,659 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:43,723 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:43,723 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:43,724 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/215356?output=xml
23:18:48,969 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:49,061 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:49,062 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:49,062 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/14581288?output=xml
23:18:54,351 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:54,371 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:54,371 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:54,371 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212328?output=xml
23:18:59,674 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:59,686 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:18:59,686 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:18:59,686 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212332?output=xml
23:19:04,811 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:04,821 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:04,821 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:04,821 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/13014422?output=xml
23:19:10,034 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:10,117 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:10,118 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:10,118 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212388?output=xml
23:19:15,359 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:15,433 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:15,433 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:15,433 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/60688382?output=xml
23:19:20,625 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:20,632 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:20,632 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:20,632 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/6836685?output=xml
23:19:25,960 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:26,038 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:26,038 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:26,038 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/51001232?output=xml
23:19:31,935 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:33,111 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:33,112 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:33,112 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/73849832?output=xml
23:19:38,395 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:38,398 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:38,399 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:38,399 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/6265748?output=xml
23:19:43,745 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:44,241 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:44,241 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:44,241 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/1425488?output=xml
23:19:49,516 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:49,521 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:49,522 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>albums
23:19:49,522 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - http://api.deezer.com/2.0/album/212369?output=xml
23:19:54,760 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:54,764 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find
23:19:54,764 DEBUG fr.ensim.xml.deezer.stax.StAXHtmlAlbum - >>write