package routage.action;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import routage.fenetre.InterfaceGUI;

public class DisplayGraphButton extends AbstractAction {
    private final InterfaceGUI interfaceGUI;

    public DisplayGraphButton(InterfaceGUI interfaceGUI) {
        super("Afficher");
        this.interfaceGUI = interfaceGUI;
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        if (interfaceGUI.getGraph().getNodeCount() == 0) {
            JOptionPane.showMessageDialog(null, "Aucun graphe chargé.", "Erreur", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            // ---> MODIFICATION ICI : false au lieu de true <---
            interfaceGUI.getGraph().display(false); 
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erreur lors de l'affichage du graphe.", "Erreur", JOptionPane.ERROR_MESSAGE);
        }
    }
}
