FlashCardsProject/build/build/src/jf/flashcards/address/view/FlashCardOverviewController.java
/**
     * 
     * adds functionality to the delete button
     * deletes the current card the user is on
     * 
     */
adds functionality to the delete button
deletes the current card the user is on
adds functionality to the delete button deletes the current card the user is on
@FXML
    private void deleteCard() {
    	if(!currentFlashCardStack.isEmpty())
    	{
    		Alert alert = new Alert(AlertType.CONFIRMATION);
    		alert.setTitle("Confirmation");
    		alert.setHeaderText("Are you sure you want to delete this card");
    		alert.setContentText("Once you delete this card, this action cannot be undone");
    		Optional<ButtonType> result = alert.showAndWait();
    		if(result.get() == ButtonType.OK)
    		{
    			FlashCardDatabase.removeCardFromStack(currentFlashCardStack.get(listIndex).getId(), currentSelectedString);
    			currentFlashCardStack = FlashCardDatabase.getFlashCardStack(currentSelectedString);
    			if(!currentFlashCardStack.isEmpty())
    			{
        			listIndex = 0;
            		frontCardLabel.setText(currentFlashCardStack.get(listIndex).getFront());
            		frontShowing = true;
    			}
    			else
    			{
    				listIndex =0;
    				frontShowing = true;
    				frontCardLabel.setText("");
    				backCardLabel.setText("");
    			}
    		}
    	}
    	else
    	{
       		Alert alert = new Alert(AlertType.WARNING);
    		alert.initOwner(mainApp.getPrimaryStage());
    		alert.setTitle("No Selection");
    		alert.setHeaderText("No cards are in the stack");
    		alert.setContentText("Cannot remove any cards");
    		alert.showAndWait();
    	}
    }
@ FXML private void deleteCard ( ) { if ( ! currentFlashCardStack . isEmpty ( ) ) { Alert alert = new Alert ( AlertType . CONFIRMATION ) ; alert . setTitle ( "Confirmation" ) ; alert . setHeaderText ( "Are you sure you want to delete this card" ) ; alert . setContentText ( "Once you delete this card, this action cannot be undone" ) ; Optional < ButtonType > result = alert . showAndWait ( ) ; if ( result . get ( ) == ButtonType . OK ) { FlashCardDatabase . removeCardFromStack ( currentFlashCardStack . get ( listIndex ) . getId ( ) , currentSelectedString ) ; currentFlashCardStack = FlashCardDatabase . getFlashCardStack ( currentSelectedString ) ; if ( ! currentFlashCardStack . isEmpty ( ) ) { listIndex = 0 ; frontCardLabel . setText ( currentFlashCardStack . get ( listIndex ) . getFront ( ) ) ; frontShowing = true ; } else { listIndex = 0 ; frontShowing = true ; frontCardLabel . setText ( "" ) ; backCardLabel . setText ( "" ) ; } } } else { Alert alert = new Alert ( AlertType . WARNING ) ; alert . initOwner ( mainApp . getPrimaryStage ( ) ) ; alert . setTitle ( "No Selection" ) ; alert . setHeaderText ( "No cards are in the stack" ) ; alert . setContentText ( "Cannot remove any cards" ) ; alert . showAndWait ( ) ; } }
adds functionality to the delete button
 deletes the current card the user is on
adds functionality to the delete button deletes the current card the user is on
//before deleting, an confirmation alert is set to confirm the action //if the stack still has cards after removing one //if the stack is empty after removing the card 