diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.classpath b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.classpath index 6bdcd6a..5017609 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.classpath +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.classpath @@ -1,14 +1,29 @@ - - + + + + + + + + + + + + - + - + - + + + + + + diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.gitignore b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.project b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.project index 2a91ea7..711260e 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.project +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.project @@ -10,8 +10,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.settings/org.eclipse.jdt.core.prefs b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.settings/org.eclipse.jdt.core.prefs index d17b672..6b5aebc 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.settings/org.eclipse.jdt.core.prefs +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/.settings/org.eclipse.jdt.core.prefs @@ -9,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html index 092ca8c..9f7b478 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html @@ -19,22 +19,50 @@
  • Rusty Fonky
  • Share a Line
  • Mysterious Ways
  • +
  • Killing Hallelujah
  • +
    +
    +
      +
    • Smells Like Teen Spirit +
    • +
    +
    +
      +
    • The Geeks And The Jerkin' Socks +
    • +
    +
    +
      +
    • The Black Pixel Ape (Drinking Cigarettes to Take a Break) [Deezer Edition] +
    • +
    +
    +
      +
    • Monkeys in Bercy +
    • The White Pixel Ape (Smoking Isolate to Keep in Shape)
    • -
    • The White Pixel Ape (Smoking Isolate to Keep in Shape)
    • -
    • Lucky G1rl
    • -
    • Wanna Get Free
    • -
    • M0nkey On The Wall
    • -
    • Scarify
    • -
    • Black Listed
    • -
    • An Eloquent
    • -
    • W0tz Goin'ON
    • -
    • Story O' my LF
    • -
    • Gimme Guitarrrrra
    • -
    • Last Alone
    • -
    • Altered Native Soul
    • -
    • Heal Me Kill Me
    • +
    +
    +
      +
    • Loco Con Da Frenchy Talkin' (Recycled version 2009) +
    • +
    +
    +
      +
    • Bad Porn Movie Trax +
    • +
    +
    +
      +
    • ApeTizer - EP +
    • +
    +
    +
      +
    • Wanna Get Free - Single +
    \ No newline at end of file diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore index e9e8828..ae1bf42 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore @@ -1,2 +1,3 @@ -/.DS_Store +/MainWindow.class /fr/ +/MainWindow.fxml diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/MainWindow.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/MainWindow.java deleted file mode 100644 index 82d8311..0000000 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/MainWindow.java +++ /dev/null @@ -1,110 +0,0 @@ -package fr.ensim.xml.deezer; - -import java.awt.EventQueue; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -public class MainWindow { - - private JFrame frame; - - /** - * Launch the application. - */ - public static void main(String[] args) { - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - MainWindow window = new MainWindow(); - window.frame.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - /** - * Create the application. - */ - public MainWindow() { - initialize(); - } - - /** - * Initialize the contents of the frame. - */ - private void initialize() { - frame = new JFrame(); - frame.setBounds(100, 100, 450, 75); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setResizable(false); - - JPanel pnMainPanel; - final JTextField tfSearchTextBox; - JLabel lbSearchLabel; - JButton btSearchButton; - - pnMainPanel = new JPanel(); - GridBagLayout gbMainPanel = new GridBagLayout(); - GridBagConstraints gbcMainPanel = new GridBagConstraints(); - pnMainPanel.setLayout( gbMainPanel ); - - tfSearchTextBox = new JTextField( ); - gbcMainPanel.gridx = 3; - gbcMainPanel.gridy = 1; - gbcMainPanel.gridwidth = 7; - gbcMainPanel.gridheight = 2; - gbcMainPanel.fill = GridBagConstraints.BOTH; - gbcMainPanel.weightx = 1; - gbcMainPanel.weighty = 0; - gbcMainPanel.anchor = GridBagConstraints.NORTH; - gbMainPanel.setConstraints( tfSearchTextBox, gbcMainPanel ); - pnMainPanel.add( tfSearchTextBox ); - - lbSearchLabel = new JLabel( "Search :" ); - gbcMainPanel.gridx = 0; - gbcMainPanel.gridy = 1; - gbcMainPanel.gridwidth = 3; - gbcMainPanel.gridheight = 2; - gbcMainPanel.fill = GridBagConstraints.BOTH; - gbcMainPanel.weightx = 1; - gbcMainPanel.weighty = 1; - gbcMainPanel.anchor = GridBagConstraints.NORTH; - gbMainPanel.setConstraints( lbSearchLabel, gbcMainPanel ); - pnMainPanel.add( lbSearchLabel ); - - btSearchButton = new JButton( "Search" ); - gbcMainPanel.gridx = 11; - gbcMainPanel.gridy = 1; - gbcMainPanel.gridwidth = 5; - gbcMainPanel.gridheight = 2; - gbcMainPanel.fill = GridBagConstraints.BOTH; - gbcMainPanel.weightx = 1; - gbcMainPanel.weighty = 0; - gbcMainPanel.anchor = GridBagConstraints.NORTH; - gbMainPanel.setConstraints( btSearchButton, gbcMainPanel ); - pnMainPanel.add( btSearchButton ); - - frame.add(pnMainPanel); - - btSearchButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent arg0) { - String str = tfSearchTextBox.getText(); - str = str.replaceAll("\\s", "%20"); - new Main(str); - } - }); - } - -} diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Main.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java similarity index 51% rename from ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Main.java rename to ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java index 4c37c7d..64c443c 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Main.java +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java @@ -12,10 +12,12 @@ import java.util.List; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; +import fr.ensim.json.JSONSearchAlbum; +import fr.ensim.json.JSONSearchAlbumTracks; import fr.ensim.xml.deezer.data.Album; import fr.ensim.xml.deezer.data.Track; import fr.ensim.xml.deezer.dom.DOMSearchAlbums; -import fr.ensim.xml.deezer.dom.SearchAlbumTracks; +import fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks; import fr.ensim.xml.deezer.sax.SAXSearchAlbums; import fr.ensim.xml.deezer.stax.HtmlAlbum; @@ -24,44 +26,36 @@ import fr.ensim.xml.deezer.stax.HtmlAlbum; * @author Denis Apparicio * */ -public class Main { +public class Runner { - /** - * @param args - */ - public Main(String args) { + public Runner() { // configuration du proxy et des logs DOMConfigurator.configure("log4J.xml"); ProxyConfiguration.configure(); - - Logger log = Logger.getLogger(Main.class); - + } + + public File start(String searchString) + { + Logger log = Logger.getLogger(Runner.class); + FileOutputStream out = null; - try { - List listAlbum; + try { + List listAlbum = new JSONSearchAlbum().find(searchString, false); - //listAlbum = new SAXSearchAlbums().find(args); - listAlbum = new DOMSearchAlbums().find(args); - - // recuperation des titres de l album - for(int i = 0; i < listAlbum.size(); i++) + for(int i = 0; i < 1; i++) { - listAlbum.get(i).setTracks(SearchAlbumTracks.find(listAlbum.get(i).getId())); + listAlbum.get(i).setTracks(JSONSearchAlbumTracks.find(listAlbum.get(i).getId())); } - - // Ecriture de la page html + File fileHtml = new File(listAlbum.get(0).getArtist().getName() + ".html"); out = new FileOutputStream(fileHtml); HtmlAlbum.write(listAlbum, out); out.close(); - - // Ouverture de la page - if (fileHtml.isFile()) { - if (Desktop.isDesktopSupported() - && Desktop.getDesktop().isSupported(Action.BROWSE)) { - Desktop.getDesktop().browse(fileHtml.toURI()); - } + + if(fileHtml.isFile()) + { + return fileHtml; } } catch (Exception e) { @@ -80,6 +74,61 @@ public class Main { } log.debug("< listAlbum; + + //listAlbum = new SAXSearchAlbums().find(args); + listAlbum = new DOMSearchAlbums().find(searchString, true); + + // recuperation des titres de l album + for(int i = 0; i < 1; i++) + { + listAlbum.get(i).setTracks(DOMSearchAlbumTracks.find(listAlbum.get(i).getId())); + } + + // Ecriture de la page html + File fileHtml = new File(listAlbum.get(0).getArtist().getName() + ".html"); + out = new FileOutputStream(fileHtml); + HtmlAlbum.write(listAlbum, out); + out.close(); + + // Ouverture de la page + if (fileHtml.isFile()) { + return fileHtml; + /*if (Desktop.isDesktopSupported() + && Desktop.getDesktop().isSupported(Action.BROWSE)) { + Desktop.getDesktop().browse(fileHtml.toURI()); + }*/ + } + } + catch (Exception e) { + log.error("", e); + fail(e.getMessage()); + } + finally { + try { + if (out != null) { + out.close(); + } + } + catch (IOException e) { + log.error("", e); + } + } + + log.debug("<>find"); return listTracks; diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java index c4f462d..d41b63d 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java @@ -26,7 +26,7 @@ import fr.ensim.xml.deezer.data.Track; * */ public class DOMSearchAlbums extends AbstractSearchAlbum { - private static final Logger LOG = Logger.getLogger(DOMSearchAlbumsTest.class); + private static final Logger LOG = Logger.getLogger(DOMSearchAlbums.class); /* * (non-Javadoc) diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/ui/MainWindow.fxml b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/ui/MainWindow.fxml new file mode 100644 index 0000000..ab72d86 --- /dev/null +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/ui/MainWindow.fxml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +