// 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;

		try {
			BufferedInputStream is = new BufferedInputStream(
					SBOLDesignerStandalone.class.getResourceAsStream("/letsEncryptCert.cer"));

			X509Certificate ca = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(is);

			KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
			ks.load(null, null);
			ks.setCertificateEntry(Integer.toString(1), ca);

			TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
			tmf.init(ks);

			SSLContext context = SSLContext.getInstance("TLS");
			context.init(null, tmf.getTrustManagers(), null);
		} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException
				| IOException e) {
			e.printStackTrace();
		}
	}

	private static void setupLookAndFeel() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void setupLogging() {

// 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;

		try {
			BufferedInputStream is = new BufferedInputStream(
					SBOLDesignerStandalone.class.getResourceAsStream("/letsEncryptCert.cer"));

			X509Certificate ca = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(is);

			KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
			ks.load(null, null);
			ks.setCertificateEntry(Integer.toString(1), ca);

			TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
			tmf.init(ks);

			SSLContext context = SSLContext.getInstance("TLS");
			context.init(null, tmf.getTrustManagers(), null);
		} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException
				| IOException e) {
			e.printStackTrace();
		}
	}

	private static void setupLookAndFeel() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void setupLogging() {

		final InputStream inputStream = SBOLDesignerStandalone.class.getResourceAsStream("/logging.properties");
