public void saveGraph(Graph graph, Component c) {
        this.graph = graph;
        XMLPetriManager newXML = new XMLPetriManager();
        if (getSelectedFile() == null) {
            jFileChooser = new JFileChooser();
            
            if (graph instanceof PetriNet) {
                jFileChooser.setAcceptAllFileFilterUsed(false);
                jFileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Danes PetriNet files", "dpn"));
                jFileChooser.addChoosableFileFilter(new FileNameExtensionFilter("CoBA PetriNet files", "pn2"));
                jFileChooser.addChoosableFileFilter(new FileNameExtensionFilter("CPN Tools PetriNet files", "cpn"));
            } else {
                jFileChooser.addChoosableFileFilter(new FileNameExtensionFilter("PrecedenceGraph", "dpg"));
            }
            int showOpenDialog = jFileChooser.showSaveDialog(c);
            setSelectedFile(jFileChooser.getSelectedFile());
            if (selectedFile == null) {
                return;
            }
            if (!selectedFile.exists()) {
                setSelectedFile(new File(getSelectedFile().getAbsolutePath()));
                try {
                    getSelectedFile().createNewFile();
                } catch (IOException e) {
                    System.out.print("Chyba pri praci so suborom");
                }
            } else {
            }
            if (showOpenDialog != JFileChooser.APPROVE_OPTION) {
                return;
            }
            checkAndSave(getSelectedFile(), jFileChooser.getFileFilter());
        } else {
            System.out.println("ukladam subor");
            checkAndSave(getSelectedFile(), null);
        }
        getInfoAboutFile(getSelectedFile());
    }