add view album/artist buttons
This commit is contained in:
parent
fdac060b98
commit
56436c8cca
@ -1,40 +1,46 @@
|
||||
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;
|
||||
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
||||
|
||||
borderPane.setTop(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void populate(Album album) {
|
||||
|
||||
|
||||
this.album = album;
|
||||
|
||||
|
||||
try {
|
||||
loadInfoPane();
|
||||
loadScrobblePane();
|
||||
@ -42,11 +48,44 @@ 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
|
||||
public void loadInfoPane() throws IOException {
|
||||
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("../../ui/AlbumPane.fxml"));
|
||||
|
||||
this.infoAnchorPane = (AnchorPane) loader.load();
|
||||
@ -57,17 +96,27 @@ public class AlbumBorderPaneController extends FMObjBorderPaneController{
|
||||
AnchorPane.setBottomAnchor(infoAnchorPane, 0.0);
|
||||
|
||||
infoPaneController = (AlbumPaneController) loader.getController();
|
||||
|
||||
|
||||
infoPaneController.refresh(album);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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>() {
|
||||
@ -76,15 +125,15 @@ public class AlbumBorderPaneController extends FMObjBorderPaneController{
|
||||
return new Task<Void>() {
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
|
||||
|
||||
album = new FmUserNetwork(Key.getKey(), Reference.getUserName()).refresh(album);
|
||||
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
infoPaneController.refresh(album);
|
||||
|
||||
|
||||
infoPaneController.refresh(album);
|
||||
|
||||
}
|
||||
});
|
||||
return null;
|
||||
@ -94,5 +143,5 @@ public class AlbumBorderPaneController extends FMObjBorderPaneController{
|
||||
};
|
||||
service.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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>() {
|
||||
|
@ -31,6 +31,9 @@ public abstract class FMObjBorderPaneController {
|
||||
@FXML
|
||||
protected Button buttonViewInfo;
|
||||
|
||||
@FXML
|
||||
protected Button buttonViewOnline;
|
||||
|
||||
@FXML
|
||||
protected BorderPane borderPane;
|
||||
|
||||
|
@ -1,40 +1,45 @@
|
||||
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;
|
||||
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
||||
|
||||
borderPane.setTop(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void populate(Track track) {
|
||||
|
||||
|
||||
this.track = track;
|
||||
|
||||
|
||||
try {
|
||||
loadInfoPane();
|
||||
loadScrobblePane();
|
||||
@ -42,11 +47,51 @@ 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
|
||||
public void loadInfoPane() throws IOException {
|
||||
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("../../ui/TrackPane.fxml"));
|
||||
|
||||
this.infoAnchorPane = (AnchorPane) loader.load();
|
||||
@ -57,17 +102,27 @@ public class TrackBorderPaneController extends FMObjBorderPaneController{
|
||||
AnchorPane.setBottomAnchor(infoAnchorPane, 0.0);
|
||||
|
||||
infoPaneController = (TrackPaneController) loader.getController();
|
||||
|
||||
|
||||
infoPaneController.refresh(track);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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>() {
|
||||
@ -76,15 +131,15 @@ public class TrackBorderPaneController extends FMObjBorderPaneController{
|
||||
return new Task<Void>() {
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
|
||||
|
||||
track = new FmUserNetwork(Key.getKey(), Reference.getUserName()).refresh(track);
|
||||
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
infoPaneController.refresh(track);
|
||||
|
||||
|
||||
infoPaneController.refresh(track);
|
||||
|
||||
}
|
||||
});
|
||||
return null;
|
||||
@ -94,5 +149,5 @@ public class TrackBorderPaneController extends FMObjBorderPaneController{
|
||||
};
|
||||
service.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user