Skip to content

Commit

Permalink
Fixed bug current menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernesto-Rapisarda committed Jul 20, 2022
1 parent 3498f70 commit 7c76e56
Show file tree
Hide file tree
Showing 39 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .idea/dataSources.local.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added MediaPlayerDb.db
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
textField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if(tabSelezionata=="MusicLibrary")
if(tabSelezionata.equals("MusicLibrary"))
tableViewSelection.setItems(SearchForFile.getInstance().getSearch(newValue, MusicLibrary.getInstance().getMusicLibrary()));
else
tableViewSelection.setItems(SearchForFile.getInstance().getSearch(newValue, VideoLibrary.getInstance().getVideoLibrary()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void error(){
}

private boolean findName(String name){
if(name=="")
if(name.equals(""))
return false;
for(int pos=0;pos<PlaylistCollection.getInstance().getPlayListsCollections().size();pos++){
if(PlaylistCollection.getInstance().getPlayListsCollections().get(pos).getName().equals(name)&&!previousName.equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,49 @@ private void activeVideo(boolean status){
}

private void buttonVideoTab(boolean status){
btnVideoView.setVisible(status);
/*btnVideoView.setVisible(status);
if(status)
resetAllStyles();
btnVideoView.getStyleClass().removeAll("button","toolBarButton");
btnVideoView.getStyleClass().add("focusedToolBarButton");
btnVideoView.getStyleClass().add("focusedToolBarButton");*/
if(Player.getInstance().getIsAVideo()){
btnVideoView.setVisible(status);
resetAllStyles();
btnVideoView.getStyleClass().removeAll("button","toolBarButton");
btnVideoView.getStyleClass().add("focusedToolBarButton");
}
else if (btnVideoView.isVisible()){
btnVideoView.getStyleClass().removeAll("focusedToolBarButton");
btnVideoView.getStyleClass().add( "toolBarButton");
btnVideoView.setVisible(status);
String current = SceneHandler.getInstance().getCurrentMidPane();
if(current.equals("home-view.fxml")) {
btnHome.getStyleClass().removeAll("button", "toolBarButton");
btnHome.getStyleClass().add("focusedToolBarButton");
}
else if(current.equals("music-library-view.fxml")) {
btnMusicLibrary.getStyleClass().removeAll("button", "toolBarButton");
btnMusicLibrary.getStyleClass().add("focusedToolBarButton");
}
else if(current.equals("video-library-view.fxml")) {
btnVideoLibrary.getStyleClass().removeAll("button", "toolBarButton");
btnVideoLibrary.getStyleClass().add("focusedToolBarButton");
}
else if(current.equals("play-queue-view.fxml")) {
btnPlayQueue.getStyleClass().removeAll("button", "toolBarButton");
btnPlayQueue.getStyleClass().add("focusedToolBarButton");
}
else if(current.equals("playlist-view.fxml")) {
btnPlaylists.getStyleClass().removeAll("button", "toolBarButton");
btnPlaylists.getStyleClass().add("focusedToolBarButton");
}
else if(current.equals("settings-view.fxml")) {
btnSettings.getStyleClass().removeAll("button", "toolBarButton");
btnSettings.getStyleClass().add("focusedToolBarButton");
}
}


}

private void toolbarButtonDisable(boolean status){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void changed(ObservableValue<? extends String> observable, String oldValu
});

SceneHandler.getInstance().updateViewRequiredProperty().addListener(observable -> {
if (SceneHandler.getInstance().isUpdateViewRequired() && SceneHandler.getInstance().getCurrentMidPane()=="music-library-view.fxml"){
if (SceneHandler.getInstance().isUpdateViewRequired() && SceneHandler.getInstance().getCurrentMidPane().equals("music-library-view.fxml")){
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void init(MyMedia myMedia, String source){
imageView.setImage(new Image("file:"+"src/main/resources/it/unical/sadstudents/mediaplayeruid/image/iconaMusica.png"));
labelDuration.setText(myMedia.getLength());
btnPlay.setTooltip(new Tooltip("Play this media (a new queue will be created)"));
if(source=="home"){
if(source.equals("home") ){
btnDelete.setTooltip(new Tooltip("Delete media from recent media"));
}
else{
Expand Down Expand Up @@ -114,9 +114,9 @@ public void playMedia(){
}

public void deleteMedia(){
if (source == "home" && SceneHandler.getInstance().showConfirmationAlert("Do you want to remove from Recent Media?")) {
if (source.equals("home") && SceneHandler.getInstance().showConfirmationAlert("Do you want to remove from Recent Media?")) {
Home.getInstance().removeItem(myMedia);
} else if (source!="home" && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Video?")){
} else if (!source.equals("home") && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Video?")){
VideoLibrary.getInstance().removeSafe(myMedia);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void handle(KeyEvent keyEvent) {
});

SceneHandler.getInstance().updateViewRequiredProperty().addListener(observable -> {
if (SceneHandler.getInstance().isUpdateViewRequired() && SceneHandler.getInstance().getCurrentMidPane()=="play-queue-view.fxml"){
if (SceneHandler.getInstance().isUpdateViewRequired() && SceneHandler.getInstance().getCurrentMidPane().equals("play-queue-view.fxml") ){
tableViewQueue.refresh();
tableViewQueue.getSelectionModel().select(PlayQueue.getInstance().getCurrentMedia()) ;
SceneHandler.getInstance().setUpdateViewRequired(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
mediaSlider.valueChangingProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean t1) {
//System.out.println(mediaSlider.getValue());
Player.getInstance().changePosition(mediaSlider.getValue());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void handle(ContextMenuEvent contextMenuEvent) {
if (event.getButton().equals(MouseButton.SECONDARY)) {
if (!row.isEmpty()) {
MyMedia myMedia = row.getItem();
contextMenuHandler = new ContextMenuHandler(myMedia, playlist.getName(), "playlist", row.getIndex());
contextMenuHandler = new ContextMenuHandler(myMedia, playlist.getName(),"playlist", row.getIndex());
row.setContextMenu(contextMenuHandler);
row.getContextMenu();
}
Expand Down Expand Up @@ -223,7 +223,7 @@ private void setLabel(){



private boolean exist(MyMedia myMedia){
/* private boolean exist(MyMedia myMedia){
for(int i=0;i<playlist.getMyList().size();i++){
if(playlist.getMyList().get(i)==myMedia)
return true;
Expand All @@ -237,7 +237,7 @@ private int findPlaylist(){
return pos;
}
return -1;
}
}*/

public void setDim(double size){
anchorPanePlaylist.setPrefWidth(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static DatabaseManager getInstance(){
//FUNCTION
// function private
private boolean checkLibrary(String name){
if(name=="MusicLibrary" || name =="VideoLibrary"||name=="empty") return true;
if(name.equals("MusicLibrary") || name.equals("VideoLibrary") ||name.equals("empty") ) return true;
return false;
}
private boolean isPresent(String object,String key, String tab){
Expand Down Expand Up @@ -66,8 +66,8 @@ private boolean isPresentInt(String object,Integer key, String tab){
return false;
}
private boolean checkTable(String table){
if(table=="MyMedia"||table=="Playlist"||table=="Settings"||
table=="RecentMedia"||table=="Playqueue"||table=="MyMediaPlaylist"||table=="Equalizer")
if(table.equals("MyMedia") ||table.equals("Playlist") ||table.equals("Settings") ||
table.equals("RecentMedia") ||table.equals("Playqueue") ||table.equals("MyMediaPlaylist") ||table.equals("Equalizer"))
return true;
else return false;
}
Expand Down Expand Up @@ -187,10 +187,10 @@ public boolean setLibrary(String pathMedia,String nameLibrary){
try {
if(connection != null && pathMedia!=null &&checkLibrary(nameLibrary) &&!connection.isClosed()&&isPresent("Path",pathMedia,"MyMedia")) {
PreparedStatement stmt = connection.prepareStatement("UPDATE MyMedia SET MusicLibrary=?, VideoLibrary=? WHERE Path=?;");
if(nameLibrary=="MusicLibrary"){
if(nameLibrary.equals("MusicLibrary")){
stmt.setInt(1,1);
stmt.setInt(2,0);
}else if(nameLibrary=="VideoLibrary"){
}else if(nameLibrary.equals("VideoLibrary")){
stmt.setInt(1,0);
stmt.setInt(2,1);
}else{
Expand Down Expand Up @@ -279,12 +279,12 @@ public void receiveMyMedia(String filter){
PreparedStatement stmt = connection.prepareStatement(query);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
if(filter=="MusicLibrary") {
if(filter.equals("MusicLibrary")) {
MusicLibrary.getInstance().getMusicLibrary().add(new MyMedia(rs.getString("Title"), rs.getString("Artist"),
rs.getString("Album"), rs.getString("Genre"), rs.getString("Path")
, rs.getString("Length"), rs.getString("Year"), rs.getString("Image")));
}
else if(filter=="VideoLibrary"){
else if(filter.equals("VideoLibrary")){
VideoLibrary.getInstance().getVideoLibrary().add(new MyMedia(rs.getString("Title"), rs.getString("Artist"),
rs.getString("Album"), rs.getString("Genre"), rs.getString("Path")
, rs.getString("Length"), rs.getString("Year"), rs.getString("Image")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Playlist(){

private void listenerRefresh(){
PlaylistCollection.getInstance().updatePlayQueueProperty().addListener(observable -> {
if(PlaylistCollection.getInstance().getTypePlaylist()== getName() && PlaylistCollection.getInstance().getUpdatePlayQueue()) {
if(PlaylistCollection.getInstance().getTypePlaylist().equals(getName()) && PlaylistCollection.getInstance().getUpdatePlayQueue()) {
if(getMyList().size()>0) {
refreshPlayQueue();
}
Expand Down Expand Up @@ -212,7 +212,7 @@ private void refreshPlayQueue(){
for(int i=0;i<getMyList().size();i++){
boolean e=false;
for(int j=0;j<PlayQueue.getInstance().getQueue().size();j++)
if(getMyList().get(i)==PlayQueue.getInstance().getQueue().get(j))
if(getMyList().get(i).equals(PlayQueue.getInstance().getQueue().get(j)) )
e=true;
if(!e)
PlayQueue.getInstance().addFileToListFromOtherModel(getMyList().get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ public void progressBarUpdate(ProgressBar progressBar,String type) {
Task task = new Task<Void>() {
@Override
public Void call() {
if(type=="media"){
if(type.equals("media")){
while(mediaFinded>mediaProcessed) {
if(isCancelled())
break;
updateProgress(mediaProcessed,mediaFinded);
}
}else if(type=="meta"){
}else if(type.equals("meta")){
while(metaDataFinded>metaDataProcessed) {
if(isCancelled())
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public ContextMenuHandler(MyMedia myMedia,String playlistName,String source,int
MenuItem menuItem2 = new MenuItem();
MenuItem menuItem3 = new MenuItem();

if(source!="playlist"){
if(!source.equals("playlist")){
menuItem.setText("Play");
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if(source != "playqueue")
if(!source.equals("playqueue"))
PlayQueue.getInstance().generateNewQueue(myMedia);
else{
PlayQueue.getInstance().setCurrentMedia(row);
Expand All @@ -41,20 +41,20 @@ public void handle(ActionEvent actionEvent) {
@Override
public void handle(ActionEvent actionEvent) {

if (source == "home" && SceneHandler.getInstance().showConfirmationAlert("Do you want to remove from Recent Media?")) {
if (source.equals("home") && SceneHandler.getInstance().showConfirmationAlert("Do you want to remove from Recent Media?")) {
Home.getInstance().removeItem(myMedia);

} else if(source == "video" && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Video?")){
} else if(source.equals("video") && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Video?")){
VideoLibrary.getInstance().removeSafe(myMedia);
SceneHandler.getInstance().setUpdateViewRequired(true);

}
else if(source == "musicLibrary" && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Song?") ){
else if(source.equals("musicLibrary") && SceneHandler.getInstance().showConfirmationAlert("Do you really want to delete this Song?") ){
MusicLibrary.getInstance().deleteStandard(myMedia);
SceneHandler.getInstance().setUpdateViewRequired(true);

}
else if(source == "playqueue" && SceneHandler.getInstance().showConfirmationAlert("Do you really want to remove from queue?")){
else if(source.equals("playqueue") && SceneHandler.getInstance().showConfirmationAlert("Do you really want to remove from queue?")){
PlayQueue.getInstance().removeMedia(row);
}
}
Expand All @@ -71,8 +71,7 @@ public void handle(ActionEvent actionEvent) {
menuItem3.setText("Add To Playlist");
menuItem3.setDisable(true);
}
else if(source == "playlist"){

else if(source.equals("playlist")){
if(myMedia==null){
menuItem.setText("Play All");
menuItem.setOnAction(new EventHandler<ActionEvent>() {
Expand Down Expand Up @@ -151,11 +150,11 @@ public void handle(ActionEvent actionEvent) {

this.getItems().add(menuItem);
this.getItems().add(menuItem1);
if(source!="playqueue")
if(!source.equals("playqueue"))
this.getItems().add(menuItem2);
this.getItems().add(menuItem3);

if(source!="playlist"){
if(!source.equals("playlist")){
this.getItems().add(new SeparatorMenuItem());

for(int i = 0; i< PlaylistCollection.getInstance().getPlayListsCollections().size(); i++){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void init(String source, double width, double height, String title, boole
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent windowEvent) {
if(source=="new-playlist-view.fxml" ){
if(source.equals("new-playlist-view.fxml") ){
int index = PlaylistCollection.getInstance().getPlaylistWidthName(playlistName);
if(PlaylistCollection.getInstance().getPlayListsCollections().get(index).isInitialized()){
if(!SceneHandler.getInstance().showConfirmationAlert("Discard changes?")) {
Expand All @@ -94,7 +94,7 @@ public void handle(WindowEvent windowEvent) {
}

}
else if(source=="addMediaToPlaylist-view.fxml" && updated){
else if(source.equals("addMediaToPlaylist-view.fxml") && updated){
if(!SceneHandler.getInstance().showConfirmationAlert("Discard changes?")) {
windowEvent.consume();
stage.show();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 7c76e56

Please sign in to comment.