Skip to content

Commit

Permalink
- BUG: JRE11 had stopped supporting the osxadapter code. This meant A…
Browse files Browse the repository at this point in the history
…bout/Prefs/etc options on macOS were no longer working.
  • Loading branch information
imilne committed Sep 3, 2019
1 parent 5650466 commit 1c7cc70
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 42 deletions.
1 change: 0 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<attribute name="Main-Class" value="tablet.gui.Tablet"/>
<attribute name="Class-Path"
value="flamingo.jar
osxadapter.jar
scri-commons.jar
htsjdk-2.11.0.jar
samtools-all.jar
Expand Down
6 changes: 2 additions & 4 deletions installer/Tablet.install4j
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<install4j version="7.0.11" transformSequenceNumber="7">
<install4j version="7.0.12" transformSequenceNumber="7">
<directoryPresets config="../keys/icsmacbookpro-application-id.p12" />
<application name="Tablet" distributionSourceDir="" applicationId="9483-2571-4596-9336" mediaDir="." mediaFilePattern="${compiler:sys.shortName}_${compiler:sys.platform}_${compiler:sys.version}" compression="6" lzmaCompression="false" pack200Compression="false" excludeSignedFromPacking="true" commonExternalFiles="false" createMd5Sums="true" shrinkRuntime="false" shortName="tablet" publisher="The James Hutton Institute" publisherWeb="https://www.hutton.ac.uk" version="x.xx.xx.xx" allPathsRelative="true" backupOnSave="false" autoSave="false" convertDotsToUnderscores="true" macSignature="????" macVolumeId="c8bcb8b04df17304" javaMinVersion="1.11" javaMaxVersion="" allowBetaVM="false" jdkMode="runtimeJre" jdkName="">
<languages skipLanguageSelection="false" languageSelectionInPrincipalLanguage="false">
Expand Down Expand Up @@ -33,9 +33,7 @@
<entries>
<dirEntry mountPoint="19" file="../lib" overwriteMode="4" shared="false" fileMode="644" uninstallMode="0" overrideFileMode="false" overrideOverwriteMode="false" overrideUninstallMode="false" entryMode="direct" subDirectory="lib" excludeSuffixes="*.txt" dirMode="755" overrideDirMode="false">
<exclude>
<entry location="i4jruntime.jar" fileType="regular" />
<entry location="samtools-all.jar" fileType="regular" />
<entry location="sqlite-jdbc-3.6.19.jar" fileType="regular" />
</exclude>
</dirEntry>
<dirEntry mountPoint="342" file="./licence" overwriteMode="4" shared="false" fileMode="644" uninstallMode="0" overrideFileMode="false" overrideOverwriteMode="false" overrideUninstallMode="false" entryMode="direct" subDirectory="" excludeSuffixes="" dirMode="755" overrideDirMode="false">
Expand Down Expand Up @@ -2562,7 +2560,7 @@ context.goForward(1, true, true);
</autoUpdate>
<topLevelFiles />
</macos>
<unixInstaller name="Linux x64" id="433" customizedId="" mediaFileName="${compiler:sys.shortName}_linux_x64_${compiler:sys.version}" installDir="Tablet" overridePrincipalLanguage="false" jreBitType="all" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" downloadURL="" includeAllDownloadableComponents="false" includedJRE="linux-x86-11.0.3" manualJREEntry="false" bundleType="1" jreURL="" jreShared="false" directDownload="false" installOnlyIfNecessary="false" customInstallBaseDir="" contentFilesType="1">
<unixInstaller name="Linux x64" id="433" customizedId="" mediaFileName="${compiler:sys.shortName}_linux_x64_${compiler:sys.version}" installDir="Tablet" overridePrincipalLanguage="false" jreBitType="all" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" downloadURL="" includeAllDownloadableComponents="false" includedJRE="linux-amd64-11.0.3" manualJREEntry="false" bundleType="1" jreURL="" jreShared="false" directDownload="false" installOnlyIfNecessary="false" customInstallBaseDir="" contentFilesType="1">
<excludedComponents />
<includedDownloadableComponents />
<excludedLaunchers />
Expand Down
Binary file removed lib/osxadapter.jar
Binary file not shown.
68 changes: 31 additions & 37 deletions src/tablet/gui/Tablet.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package tablet.gui;

import java.awt.*;
import java.awt.desktop.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
Expand All @@ -18,9 +19,7 @@
import scri.commons.gui.*;
import scri.commons.io.*;

import apple.dts.samplecode.osxadapter.*;

public class Tablet implements Thread.UncaughtExceptionHandler
public class Tablet implements Thread.UncaughtExceptionHandler, OpenFilesHandler
{
private static File prefsFile = getPrefsFile();
private static File mruFile;
Expand All @@ -41,8 +40,6 @@ public class Tablet implements Thread.UncaughtExceptionHandler
public static void main(String[] args)
throws Exception
{
// OS X: This has to be set before anything else
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Tablet");
// This disables the API preferences, which can cause problems on Linux
// - see: http://www.allaboutbalance.com/articles/disableprefs
// System.setProperty("java.util.prefs.PreferencesFactory", "scri.commons.gui.DisabledPreferencesFactory");
Expand Down Expand Up @@ -297,27 +294,32 @@ private static File getPrefsFile()
return file;
}

public static File getLogFile()
{
try
{
File root = new File(System.getProperty("user.home"));
File folder = new File(root, ".scri-bioinf");
File logFile = new File(folder, "tablet.log");

return logFile;
}
catch (Throwable e) { return new File(""); }
}


// --------------------------------------------------
// Methods required for better native support on OS X

private void handleOSXStupidities()
{
try
{
// Register handlers to deal with the System menu about/quit options
OSXAdapter.setPreferencesHandler(this,
getClass().getDeclaredMethod("osxPreferences", (Class[])null));
OSXAdapter.setAboutHandler(this,
getClass().getDeclaredMethod("osxAbout", (Class[])null));
OSXAdapter.setQuitHandler(this,
getClass().getDeclaredMethod("osxShutdown", (Class[])null));
OSXAdapter.setFileHandler(this,
getClass().getDeclaredMethod("osxOpen", new Class[] { String.class }));

// Dock the menu bar at the top of the screen
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
catch (Exception e) {}
Desktop desktop = Desktop.getDesktop();

// Register handlers to deal with the System menu about/quit options
desktop.setAboutHandler(e -> osxAbout());
desktop.setPreferencesHandler(e -> osxPreferences());
desktop.setQuitHandler((e,r) -> osxShutdown());
desktop.setOpenFileHandler(this);
}

/** "Preferences" on the OS X system menu. */
Expand All @@ -342,35 +344,27 @@ public boolean osxShutdown()
return true;
}

public void osxOpen(String path)
/** Deal with desktop-double clicking of registered files */
public void openFiles(OpenFilesEvent e)
{
String[] paths = new String[e.getFiles().size()];
for (int i = 0; i < paths.length; i++)
paths[i] = e.getFiles().get(i).toString();

// If Tablet is already open, then open the file straight away
if (winMain != null && winMain.isVisible())
{
// TODO: If we have project modified checks, do them here too
TabletFile tabletFile =
TabletFileHandler.createFromFileList(new String[] { path });
TabletFileHandler.createFromFileList(paths);
winMain.getCommands().fileOpen(tabletFile);
}

// Otherwise, mark it for opening once Tablet is ready
else
{
initialFiles = new String[1];
initialFiles[0] = path;
initialFiles[0] = paths[0];
}
}

public static File getLogFile()
{
try
{
File root = new File(System.getProperty("user.home"));
File folder = new File(root, ".scri-bioinf");
File logFile = new File(folder, "tablet.log");

return logFile;
}
catch (Throwable e) { return new File(""); }
}
}

0 comments on commit 1c7cc70

Please sign in to comment.