package osa.attribute.atgrammar.gui.actions;

import java.io.*;

import javax.swing.AbstractAction;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.filechooser.*;

import osa.attribute.atgrammar.grammar.*;
import osa.attribute.atgrammar.grammar.symbols.*;

import osa.attribute.atgrammar.gui.panels.atgrammar_panels.ATGrammarTabPane;
import osa.attribute.atgrammar.gui.images.*;
import osa.attribute.atgrammar.gui.file_choosers.*;

import osa.attribute.atgrammar.xml.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: </p>
 * <p>Company: </p>
 * @author not attributable
 * @version
 */

public class SaveGrammarAsAction
  extends AbstractAction
  {
  public SaveGrammarAsAction()
    {
    this.putValue(AbstractAction.SMALL_ICON,ImageLoader.loadImage("saveas.gif"));
    this.putValue(AbstractAction.SHORT_DESCRIPTION,"Сохранить как...");
    }

  public void actionPerformed(ActionEvent e)
    {
    JFileChooser project_file_chooser=FileChoosersFactory.getProjectFileChooser();
    project_file_chooser.showSaveDialog(ATGrammarTabPane.getInstance());

    File project_file=project_file_chooser.getSelectedFile();

    XMLWriter project_writer=new XMLWriter(Grammar.getInstance());
    project_writer.writeGrammarToXML(project_file);
    }
  }