Updated to suppot later Java versions

This commit is contained in:
Chris Myers 2024-11-26 20:27:58 -07:00
parent 040aa01d2f
commit b11268ec9c
13 changed files with 198 additions and 161 deletions

View file

@ -30,7 +30,7 @@
</configuration>
<phase>package</phase>
<goals>
<goal>assembly</goal>
<goal>single</goal>
</goals>
</execution>
</executions>
@ -38,31 +38,16 @@
</plugins>
</build>
<repositories>
<repository>
<id>staging</id>
<name>staging</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<repository>
<id>ossrh</id>
<name>ossrh</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>ebi</id>
<name>ebi</name>
<url>https://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/</url>
</repository>
<repository>
<id>jboss</id>
<name>jboss</name>
<url>https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/</url>
</repository>
<repository>
<id>netbeans</id>
<name>netbeans</name>
<url>https://bits.netbeans.org/maven2/</url>
</repository>
<repository>
<id>osgeo</id>
<name>osgeo</name>
@ -92,6 +77,20 @@
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.14</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View file

@ -36,6 +36,8 @@ import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
@ -210,7 +212,6 @@ import edu.utah.ece.async.ibiosim.gui.synthesisView.SynthesisView;
import edu.utah.ece.async.ibiosim.gui.synthesisView.SynthesisViewATACS;
import edu.utah.ece.async.ibiosim.gui.util.FileTree;
import edu.utah.ece.async.ibiosim.gui.util.Log;
import edu.utah.ece.async.ibiosim.gui.util.OSXHandlers;
import edu.utah.ece.async.ibiosim.gui.util.Utility;
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog;
@ -334,7 +335,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
public static Object ICON_COLLAPSE = UIManager.get("Tree.collapsedIcon");
protected static final String iBioSimVersion = "3.1.0";
protected static final String iBioSimVersion = "3.2.0";
protected SEDMLDocument sedmlDocument = null;
@ -882,9 +883,31 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
help.add(manual);
help.add(bugReport);
if (System.getProperty("os.name").toLowerCase().startsWith("mac os")) {
OSXHandlers osxHandlers = new OSXHandlers(this);
osxHandlers.addEventHandlers();
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
// Set the "About" menu handler
desktop.setAboutHandler(e -> {
about();
});
// Set the "Preferences" menu handler
desktop.setPreferencesHandler(e -> {
PreferencesDialog.showPreferences(Gui.frame);
getFileTree().setExpandibleIcons(!IBioSimPreferences.INSTANCE.isPlusMinusIconsEnabled());
if (getSBOLDocument() != null) {
getSBOLDocument().setDefaultURIprefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
}
});
// Set the "Quit" menu handler
desktop.setQuitHandler((e, response) -> {
exit();
// If we have returned from the above call the user has decided not to quit
response.cancelQuit();
// Perform cleanup before exiting
//response.performQuit(); // or response.cancelQuit();
});
} else {
edit.addSeparator();
edit.add(pref);
@ -1040,7 +1063,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
final String developers;
name = new JLabel("iBioSim", SwingConstants.CENTER);
version = new JLabel("Version " + iBioSimVersion, SwingConstants.CENTER);
developers = "Nathan Barker\nScott Glass\nKevin Jones\nHiroyuki Kuwahara\n"
developers = "Nathan Barker\nLukas Buecherl\nPedro Fontanarrosa\nScott Glass\nKevin Jones\nHiroyuki Kuwahara\n"
+ "Curtis Madsen\nChris Myers\nNam Nguyen\nTramy Nguyen\nTyler Patterson\nNicholas Roehner\nJason Stevens\nLeandro Watanabe\nMichael Zhang\nZhen Zhang\nZach Zundel";
Font font = name.getFont();
font = font.deriveFont(Font.BOLD, 36.0f);
@ -2407,7 +2430,12 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
} else if (e.getSource().equals(importArchive)) {
importArchive();
} else if (e.getSource().equals(downloadSynBioHub)) {
downloadSynBioHub();
try {
downloadSynBioHub();
} catch (SBOLValidationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else if (e.getSource() == downloadBioModel) {
downloadBioModel();
} else if (e.getSource() == downloadVirtualPart) {
@ -4524,7 +4552,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
}
}
public void createCombineArchive(File archiveFile, String filename) throws IOException, JDOMException, ParseException, CombineArchiveException, TransformerException {
public void createCombineArchive(File archiveFile, String filename) throws IOException, JDOMException, ParseException, CombineArchiveException {
CombineArchive archive = new CombineArchive(archiveFile);
File baseDir = new File(root);
if (filename == null) {
@ -4534,7 +4562,11 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
} else {
addFileToCombineArchive(archive,baseDir,filename);
}
archive.pack();
try {
archive.pack();
} catch (Exception e) {
e.printStackTrace();
}
archive.close();
}
@ -4569,8 +4601,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
try {
createCombineArchive(file,null);
}
catch (IOException | JDOMException | ParseException | CombineArchiveException
| TransformerException e) {
catch (IOException | JDOMException | ParseException | CombineArchiveException e) {
JOptionPane.showMessageDialog(frame, "Unable to export COMBINE Archive file.", "Error",
JOptionPane.ERROR_MESSAGE);
}
@ -4605,7 +4636,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
return null;
}
public void downloadSynBioHub() {
public void downloadSynBioHub() throws SBOLValidationException {
RegistryInputDialog registryInputDialog = new RegistryInputDialog(Gui.frame, RegistryInputDialog.ALL_PARTS,
edu.utah.ece.async.sboldesigner.sbol.SBOLUtils.Types.All_types, null, sbolDocument);
registryInputDialog.allowCollectionSelection();
@ -4638,7 +4669,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
getSBOLDocument().createCopy(selection);
writeSBOLDocument();
}
catch (SBOLValidationException | SynBioHubException | IOException e) {
catch (SynBioHubException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(frame, "Unable to download from SynBioHub.", "Error Exporting to SynBioHub",

View file

@ -1,104 +0,0 @@
package edu.utah.ece.async.ibiosim.gui.util;
import java.io.File;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import javax.swing.JFrame;
import org.apache.commons.lang3.JavaVersion;
import com.apple.eawt.AboutHandler;
import com.apple.eawt.Application;
import com.apple.eawt.PreferencesHandler;
import com.apple.eawt.QuitHandler;
import com.apple.eawt.QuitResponse;
import com.apple.eawt.AppEvent.AboutEvent;
import com.apple.eawt.AppEvent.PreferencesEvent;
import com.apple.eawt.AppEvent.QuitEvent;
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog;
import edu.utah.ece.async.sboldesigner.sbol.editor.SBOLEditorPreferences;
public class OSXHandlers implements InvocationHandler {
Gui gui;
public OSXHandlers(Gui gui) {
this.gui = gui;
}
public void addEventHandlers() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException, InstantiationException {
// using reflection to avoid Mac specific classes being required for compiling KSE on other platforms
Class<?> applicationClass = Class.forName("com.apple.eawt.Application");
Class<?> quitHandlerClass;
Class<?> aboutHandlerClass;
Class<?> openFilesHandlerClass;
Class<?> preferencesHandlerClass;
String version = System.getProperty("java.version");
String[] versionElements = version.split("\\.|_|-b");
if (Double.parseDouble(versionElements[0]) >= 9) {
quitHandlerClass = Class.forName("java.awt.desktop.QuitHandler");
aboutHandlerClass = Class.forName("java.awt.desktop.AboutHandler");
openFilesHandlerClass = Class.forName("java.awt.desktop.OpenFilesHandler");
preferencesHandlerClass = Class.forName("java.awt.desktop.PreferencesHandler");
} else {
quitHandlerClass = Class.forName("com.apple.eawt.QuitHandler");
aboutHandlerClass = Class.forName("com.apple.eawt.AboutHandler");
openFilesHandlerClass = Class.forName("com.apple.eawt.OpenFilesHandler");
preferencesHandlerClass = Class.forName("com.apple.eawt.PreferencesHandler");
}
Object application = applicationClass.getConstructor((Class[]) null).newInstance((Object[]) null);
Object proxy = Proxy.newProxyInstance(OSXHandlers.class.getClassLoader(), new Class<?>[]{
quitHandlerClass, aboutHandlerClass, openFilesHandlerClass, preferencesHandlerClass}, this);
applicationClass.getDeclaredMethod("setQuitHandler", quitHandlerClass).invoke(application, proxy);
applicationClass.getDeclaredMethod("setAboutHandler", aboutHandlerClass).invoke(application, proxy);
applicationClass.getDeclaredMethod("setOpenFileHandler", openFilesHandlerClass).invoke(application, proxy);
applicationClass.getDeclaredMethod("setPreferencesHandler", preferencesHandlerClass).invoke(application,
proxy);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
/*if ("openFiles".equals(method.getName())) {
if (args[0] != null) {
Object files = args[0].getClass().getMethod("getFiles").invoke(args[0]);
if (files instanceof List) {
OpenAction openAction = new OpenAction(kseFrame);
for (File file : (List<File>) files) {
openAction.openKeyStore(file);
}
}
}
} else */if ("handleQuitRequestWith".equals(method.getName())) {
gui.exit();
// If we have returned from the above call the user has decied not to quit
if (args[1] != null) {
args[1].getClass().getDeclaredMethod("cancelQuit").invoke(args[1]);
}
} else if ("handleAbout".equals(method.getName())) {
gui.about();
} else if ("handlePreferences".equals(method.getName())) {
PreferencesDialog.showPreferences(Gui.frame);
//EditPreferences editPreferences = new EditPreferences(frame, async);
//editPreferences.preferences();
gui.getFileTree().setExpandibleIcons(!IBioSimPreferences.INSTANCE.isPlusMinusIconsEnabled());
if (gui.getSBOLDocument() != null) {
gui.getSBOLDocument().setDefaultURIprefix(SBOLEditorPreferences.INSTANCE.getUserInfo().getURI().toString());
}
}
return null;
}
}