add view album/artist buttons

This commit is contained in:
aj 2019-05-07 11:00:43 +01:00
parent fdac060b98
commit 56436c8cca
4 changed files with 163 additions and 40 deletions

View File

@ -1,25 +1,31 @@
package sarsoo.fmframework.fx.controller.borderpane;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javafx.application.Platform;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import sarsoo.fmframework.fm.FmUserNetwork;
import sarsoo.fmframework.fx.chart.GenrePieChartTitledPane;
import sarsoo.fmframework.fx.FmFramework;
import sarsoo.fmframework.fx.controller.info.AlbumPaneController;
import sarsoo.fmframework.fx.controller.info.ArtistPaneController;
import sarsoo.fmframework.fx.tab.ArtistTab;
import sarsoo.fmframework.log.Logger;
import sarsoo.fmframework.log.entry.ErrorEntry;
import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.music.Artist;
import sarsoo.fmframework.net.Key;
import sarsoo.fmframework.net.Network;
import sarsoo.fmframework.util.Reference;
public class AlbumBorderPaneController extends FMObjBorderPaneController{
public class AlbumBorderPaneController extends FMObjBorderPaneController {
AlbumPaneController infoPaneController;
Album album;
@ -42,6 +48,39 @@ public class AlbumBorderPaneController extends FMObjBorderPaneController{
e.printStackTrace();
}
setInfoView();
Button openRym = new Button("view rym");
Button viewArtist = new Button("view artist");
openRym.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
Network.openURL(album.getRymURL());
}
});
if (album.getArtist() != null) {
viewArtist.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
try {
FmFramework.getController().addTab(new ArtistTab(album.getArtist()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
} else {
viewArtist.setDisable(true);
}
toolBar.getItems().add(openRym);
toolBar.getItems().add(viewArtist);
// if(album.getUrl() == null) {
buttonViewOnline.setDisable(true);
// }
}
@Override
@ -63,11 +102,21 @@ public class AlbumBorderPaneController extends FMObjBorderPaneController{
}
@Override
@FXML
protected void handleViewOnline(ActionEvent event) {
Network.openURL(album.getUrl());
System.out.println(album.getUrl());
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI(album.getUrl()));
} catch (Exception e) {
Logger.getLog().logError(new ErrorEntry("Can't Open"));
}
}
// Network.openURL(album.getUrl());
}
@Override
@FXML
protected void handleRefresh(ActionEvent event) {
Service<Void> service = new Service<Void>() {

View File

@ -1,6 +1,9 @@
package sarsoo.fmframework.fx.controller.borderpane;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javafx.application.Platform;
import javafx.concurrent.Service;
@ -10,7 +13,6 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.AnchorPane;
import sarsoo.fmframework.fm.FmUserNetwork;
import sarsoo.fmframework.fx.chart.GenrePieChartTitledPane;
import sarsoo.fmframework.fx.controller.info.ArtistPaneController;
import sarsoo.fmframework.music.Artist;
import sarsoo.fmframework.net.Key;
@ -40,6 +42,10 @@ public class ArtistBorderPaneController extends FMObjBorderPaneController{
e.printStackTrace();
}
setInfoView();
// if(artist.getUrl() == null) {
buttonViewOnline.setDisable(true);
// }
}
@Override
@ -61,11 +67,21 @@ public class ArtistBorderPaneController extends FMObjBorderPaneController{
}
@Override
@FXML
protected void handleViewOnline(ActionEvent event) {
Network.openURL(artist.getUrl());
System.out.println(artist.getUrl());
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI(artist.getUrl()));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
// Network.openURL(artist.getUrl());
}
@Override
@FXML
protected void handleRefresh(ActionEvent event) {
Service<Void> service = new Service<Void>() {

View File

@ -31,6 +31,9 @@ public abstract class FMObjBorderPaneController {
@FXML
protected Button buttonViewInfo;
@FXML
protected Button buttonViewOnline;
@FXML
protected BorderPane borderPane;

View File

@ -1,25 +1,30 @@
package sarsoo.fmframework.fx.controller.borderpane;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javafx.application.Platform;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import sarsoo.fmframework.fm.FmUserNetwork;
import sarsoo.fmframework.fx.chart.GenrePieChartTitledPane;
import sarsoo.fmframework.fx.controller.info.ArtistPaneController;
import sarsoo.fmframework.fx.FmFramework;
import sarsoo.fmframework.fx.controller.info.TrackPaneController;
import sarsoo.fmframework.music.Artist;
import sarsoo.fmframework.fx.tab.AlbumTab;
import sarsoo.fmframework.fx.tab.ArtistTab;
import sarsoo.fmframework.music.Track;
import sarsoo.fmframework.net.Key;
import sarsoo.fmframework.net.Network;
import sarsoo.fmframework.util.Reference;
public class TrackBorderPaneController extends FMObjBorderPaneController{
public class TrackBorderPaneController extends FMObjBorderPaneController {
TrackPaneController infoPaneController;
Track track;
@ -42,6 +47,46 @@ public class TrackBorderPaneController extends FMObjBorderPaneController{
e.printStackTrace();
}
setInfoView();
Button viewAlbum = new Button("view album");
Button viewArtist = new Button("view artist");
if (track.getAlbum() != null) {
viewAlbum.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
try {
FmFramework.getController().addTab(new AlbumTab(track.getAlbum()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
}else {
viewAlbum.setDisable(true);
}
if (track.getArtist() != null) {
viewArtist.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
try {
FmFramework.getController().addTab(new ArtistTab(track.getArtist()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
}else {
viewArtist.setDisable(true);
}
toolBar.getItems().add(viewAlbum);
toolBar.getItems().add(viewArtist);
// if(track.getUrl() == null) {
buttonViewOnline.setDisable(true);
// }
}
@Override
@ -63,11 +108,21 @@ public class TrackBorderPaneController extends FMObjBorderPaneController{
}
@Override
@FXML
protected void handleViewOnline(ActionEvent event) {
Network.openURL(track.getUrl());
System.out.println(track.getUrl());
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI(track.getUrl()));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
// Network.openURL(track.getUrl());
}
@Override
@FXML
protected void handleRefresh(ActionEvent event) {
Service<Void> service = new Service<Void>() {