<commit_before>package de.uni.freiburg.iig.telematik.swat.workbench.action;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.KeyStroke;

import de.invation.code.toval.file.FileUtils;
import de.uni.freiburg.iig.telematik.swat.logs.LogModel;
import de.uni.freiburg.iig.telematik.swat.workbench.components.SwatComponents;
import de.uni.freiburg.iig.telematik.swat.workbench.SwatTabView;
import de.uni.freiburg.iig.telematik.swat.workbench.Workbench;
import de.uni.freiburg.iig.telematik.wolfgang.editor.component.PNEditorComponent;

public class ExportAction extends AbstractWorkbenchAction {

	int commandKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
	
	public ExportAction(String name) {
		super(name);
		setAcceleratorKey(KeyStroke.getKeyStroke('E', commandKey));
	}

	private static final long serialVersionUID = -6290002178847609267L;

	@Override
	protected void doFancyStuff(ActionEvent e) throws Exception {
		// Export current active tab
		Object current = SwatTabView.getInstance().getSelectedComponent();
		File file = null;
		if (current instanceof PNEditorComponent) {
                    //file = SwatComponents.getInstance().getContainerPetriNets().getComponent(((PNEditorComponent) current).getNetContainer().getPetriNet().getName());
                    file = new File (SwatComponents.getInstance().getContainerPetriNets().getBasePath(),"((PNEditorComponent) current).getNetContainer().getPetriNet().getName()"+".pnml");
			//file = SwatComponents.getInstance().getPetriNetFile(((PNEditorComponent) current).getNetContainer().getPetriNet().getName());
		} else if (current instanceof LogModel) {
			file = ((LogModel) current).getFileReference();
		}

		if (file != null) {
			JFileChooser dialog = new JFileChooser();
			int returnValue = dialog.showSaveDialog(Workbench.getInstance());
			if (returnValue == JFileChooser.APPROVE_OPTION) {
				try {
					FileUtils.copy(file, dialog.getSelectedFile());
				} catch (Exception e1) {
					Workbench.errorMessage("Could not copy " + file + " to " + dialog.getSelectedFile(), e1, true);
					e1.printStackTrace();
				}
			}
		}

	}

}<commit_msg>fixed bug 38 (export active tab action while a net is active causes an error) by setting the proper file destination, also reworked how the file is named<commit_after>package de.uni.freiburg.iig.telematik.swat.workbench.action;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.io.File;


import javax.swing.JFileChooser;
import javax.swing.KeyStroke;
import javax.swing.filechooser.FileNameExtensionFilter;

import de.invation.code.toval.file.FileUtils;
import de.uni.freiburg.iig.telematik.swat.logs.LogModel;
import de.uni.freiburg.iig.telematik.swat.workbench.components.SwatComponents;
import de.uni.freiburg.iig.telematik.swat.workbench.SwatTabView;
import de.uni.freiburg.iig.telematik.swat.workbench.Workbench;
import de.uni.freiburg.iig.telematik.wolfgang.editor.component.PNEditorComponent;

public class ExportAction extends AbstractWorkbenchAction {

	int commandKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
	
	public ExportAction(String name) {
		super(name);
		setAcceleratorKey(KeyStroke.getKeyStroke('E', commandKey));
	}

	private static final long serialVersionUID = -6290002178847609267L;

	@Override
	protected void doFancyStuff(ActionEvent e) throws Exception {
		// Export current active tab
		Object current = SwatTabView.getInstance().getSelectedComponent();
		File file = null;
		JFileChooser dialog = new JFileChooser();
		dialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		
		if (current instanceof PNEditorComponent) {
            //file = SwatComponents.getInstance().getContainerPetriNets().getComponent(((PNEditorComponent) current).getNetContainer().getPetriNet().getName());
			String name = (((PNEditorComponent) current).getNetContainer().getPetriNet().getName()+".pnml");
            file = new File (SwatComponents.getInstance().getContainerPetriNets().getBasePath() + ((PNEditorComponent) current).getNetContainer().getPetriNet().getName() + "/", name);
            //file = SwatComponents.getInstance().getPetriNetFile(((PNEditorComponent) current).getNetContainer().getPetriNet().getName());
            
            int returnValue = dialog.showSaveDialog(Workbench.getInstance());
			if (returnValue == JFileChooser.APPROVE_OPTION) {
				try {
					String filename = dialog.getSelectedFile().toString() + "/" + name;
					File save = new File(filename);
					FileUtils.copy(file, save);
				} catch (Exception e1) {
					Workbench.errorMessage("Could not copy " + file + " to " + dialog.getSelectedFile(), e1, true);
					e1.printStackTrace();
				}
			}
		} else if (current instanceof LogModel) {
			file = ((LogModel) current).getFileReference();
            int returnValue = dialog.showSaveDialog(Workbench.getInstance());
			if (returnValue == JFileChooser.APPROVE_OPTION) {
				try {
					FileUtils.copy(file, dialog.getSelectedFile());
				} catch (Exception e1) {
					Workbench.errorMessage("Could not copy " + file + " to " + dialog.getSelectedFile(), e1, true);
					e1.printStackTrace();
				}
			}
		}


			
			
			


	}

}
{'fraction_non_alphanumeric': 0.1235676088617265, 'fraction_numerical': 0.009358288770053475, 'mean_word_length': 4.619098712446352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2894740', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1588, 'n_words': 286}