// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/io/FileDocumentIO.java
// public class FileDocumentIO implements DocumentIO {
// 	static {
// 		RDFFormat.register(RDFFormat.RDFXML);
// 	}
// 
// 	// private final SBOLReader reader;
// 	// private final SBOLWriter writer;
// 
// 	public FileDocumentIO(boolean validate) {
// 		File file = SBOLUtils.setupFile();
// 		String fileName = file.getName();
// 		RDFFormat format = fileName.endsWith(".xml") ? RDFFormat.RDFXML
// 				: RDFFormat.forFileName(fileName, RDFFormat.RDFXML);
// 		// reader = SublimeSBOLFactory.createReader(format, validate);
// 		// writer = SublimeSBOLFactory.createWriter(format, validate);
// 	}
// 
// 	@Override
// 	public SBOLDocument read()
// 			throws SBOLValidationException, FileNotFoundException, IOException, SBOLConversionException {
// 		// return reader.read(new FileInputStream(file));
// 		File file = SBOLUtils.setupFile();
// 		SBOLReader.setURIPrefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
// 		SBOLReader.setCompliant(true);
// 		FileInputStream stream = new FileInputStream(file);
// 		SBOLDocument doc = SBOLReader.read(stream);
// 		stream.close();
// 		Preferences.userRoot().node("path").put("path", file.getPath());
// 		doc.setDefaultURIprefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
// 		return doc;
// 	}
// 
// 	@Override
// 	public void write(SBOLDocument doc) throws SBOLValidationException, SBOLConversionException, IOException {
// 		// writer.write(doc, new FileOutputStream(file));
// 		File file = SBOLUtils.setupFile();
// 		String fileName = file.getName();
// 		if (!fileName.contains(".")) {
// 			file = new File(file + ".xml");
// 			Preferences.userRoot().node("path").put("path", file.getPath());
// 		}
// 		SBOLWriter.write(doc, new FileOutputStream(file));
// 	}
// 
// 	@Override
// 	public String toString() {
// 		File file = SBOLUtils.setupFile();
// 		return file.getName();
// 	}
// 
// }


import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.sbolstandard.core2.SBOLValidationException;
import edu.utah.ece.async.sboldesigner.sbol.editor.io.FileDocumentIO;

		setSize(1280, 720);
		setIconImage(ImageIO.read(getClass().getResourceAsStream("/images/icon.png")));

		// set behavior for close operation
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				try {
					if (panel.confirmSave()) {
						System.exit(0);
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
	}

	public static void main(String[] args) throws SBOLValidationException, IOException {
		setup();

		final SBOLDesignerStandalone frame = new SBOLDesignerStandalone();
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);

		if (args.length > 0) {
			try {
				File file = new File(args[0]);
				Preferences.userRoot().node("path").put("path", file.getPath());

// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/io/FileDocumentIO.java
// public class FileDocumentIO implements DocumentIO {
// 	static {
// 		RDFFormat.register(RDFFormat.RDFXML);
// 	}
// 
// 	// private final SBOLReader reader;
// 	// private final SBOLWriter writer;
// 
// 	public FileDocumentIO(boolean validate) {
// 		File file = SBOLUtils.setupFile();
// 		String fileName = file.getName();
// 		RDFFormat format = fileName.endsWith(".xml") ? RDFFormat.RDFXML
// 				: RDFFormat.forFileName(fileName, RDFFormat.RDFXML);
// 		// reader = SublimeSBOLFactory.createReader(format, validate);
// 		// writer = SublimeSBOLFactory.createWriter(format, validate);
// 	}
// 
// 	@Override
// 	public SBOLDocument read()
// 			throws SBOLValidationException, FileNotFoundException, IOException, SBOLConversionException {
// 		// return reader.read(new FileInputStream(file));
// 		File file = SBOLUtils.setupFile();
// 		SBOLReader.setURIPrefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
// 		SBOLReader.setCompliant(true);
// 		FileInputStream stream = new FileInputStream(file);
// 		SBOLDocument doc = SBOLReader.read(stream);
// 		stream.close();
// 		Preferences.userRoot().node("path").put("path", file.getPath());
// 		doc.setDefaultURIprefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
// 		return doc;
// 	}
// 
// 	@Override
// 	public void write(SBOLDocument doc) throws SBOLValidationException, SBOLConversionException, IOException {
// 		// writer.write(doc, new FileOutputStream(file));
// 		File file = SBOLUtils.setupFile();
// 		String fileName = file.getName();
// 		if (!fileName.contains(".")) {
// 			file = new File(file + ".xml");
// 			Preferences.userRoot().node("path").put("path", file.getPath());
// 		}
// 		SBOLWriter.write(doc, new FileOutputStream(file));
// 	}
// 
// 	@Override
// 	public String toString() {
// 		File file = SBOLUtils.setupFile();
// 		return file.getName();
// 	}
// 
// }


// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/SBOLDesignerStandalone.java
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.sbolstandard.core2.SBOLValidationException;
import edu.utah.ece.async.sboldesigner.sbol.editor.io.FileDocumentIO;

		setSize(1280, 720);
		setIconImage(ImageIO.read(getClass().getResourceAsStream("/images/icon.png")));

		// set behavior for close operation
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				try {
					if (panel.confirmSave()) {
						System.exit(0);
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
	}

	public static void main(String[] args) throws SBOLValidationException, IOException {
		setup();

		final SBOLDesignerStandalone frame = new SBOLDesignerStandalone();
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);

		if (args.length > 0) {
			try {
				File file = new File(args[0]);
				Preferences.userRoot().node("path").put("path", file.getPath());

				frame.panel.openDocument(new FileDocumentIO(false));
