Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
New upstream version 0.1+git20180106.740247a+dfsg
· 1b9e90d6
Andreas Tille
authored
Jan 08, 2019
1b9e90d6
New upstream version 0.1.git20180106.740247a+dfsg
· f485e0ec
Andreas Tille
authored
Jan 08, 2019
f485e0ec
Show whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
f485e0ec
# Created by .ignore support plugin (hsz.mobi)
.gitignore
JAM.iml
JAM.ipr
JAM.iws
build.xml
View file @
f485e0ec
...
...
@@ -8,6 +8,7 @@
<property
name=
"src"
location=
"src"
/>
<property
name=
"build"
location=
"build"
/>
<property
name=
"build-mac-only"
location=
"build-mac-only"
/>
<property
name=
"build-java9-only"
location=
"build-java9-only"
/>
<property
name=
"lib"
location=
"lib"
/>
<property
name=
"dist"
location=
"dist"
/>
...
...
@@ -19,6 +20,7 @@
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir
dir=
"${build}"
/>
<mkdir
dir=
"${build-java9-only}"
/>
<mkdir
dir=
"${build-mac-only}"
/>
<mkdir
dir=
"${dist}"
/>
</target>
...
...
@@ -29,9 +31,10 @@
<condition
property=
"isMac"
>
<os
family=
"mac"
/>
</condition>
<javac
source=
"1.
5
"
target=
"1.
5
"
srcdir=
"${src}"
destdir=
"${build}"
>
<javac
source=
"1.
6
"
target=
"1.
6
"
srcdir=
"${src}"
destdir=
"${build}"
>
<include
name=
"jam/**/*"
/>
<exclude
name=
"jam/**/maconly/*"
/>
<exclude
name=
"jam/**/java9only/*"
/>
<!--<exclude name="org/**/maconly/*" unless = "isMac"/>-->
</javac>
<copy
todir=
"${build}"
verbose=
"true"
>
...
...
@@ -39,12 +42,32 @@
</copy>
</target>
<target
name=
"compile-java9-only"
depends=
"init"
>
<!-- Compile the java code from ${jamsrc} into ${build} -->
<condition
property=
"isMac"
>
<os
family=
"mac"
/>
</condition>
<javac
source=
"1.9"
target=
"1.9"
srcdir=
"${src}"
destdir=
"${build-java9-only}"
>
<include
name=
"jam/**/java9only/*"
/>
</javac>
</target>
<target
name=
"dist-java9-only"
depends=
"compile-java9-only"
description=
"generate the -java9-only distribution"
>
<!-- Create the distribution directory -->
<mkdir
dir=
"${dist}"
/>
<!-- create the mac-only jar file -->
<jar
jarfile=
"${lib}/jam-java9-only.jar"
>
<fileset
dir=
"${build-java9-only}"
includes=
"**/mac*/**/*.class,*.properties"
/>
</jar>
</target>
<target
name=
"compile-mac-only"
depends=
"init"
>
<!-- Compile the java code from ${jamsrc} into ${build} -->
<condition
property=
"isMac"
>
<os
family=
"mac"
/>
</condition>
<javac
source=
"1.
5
"
target=
"1.
5
"
srcdir=
"${src}"
destdir=
"${build-mac-only}"
>
<javac
source=
"1.
6
"
target=
"1.
6
"
srcdir=
"${src}"
destdir=
"${build-mac-only}"
>
<include
name=
"jam/**/maconly/*"
/>
</javac>
</target>
...
...
@@ -59,8 +82,10 @@
</jar>
</target>
<!-- jam-mac-only.jar should be compiled using Java 6 and then is linked in here -->
<!-- jam-java9-only.jar should be compiled using Java 9 and then is linked in here -->
<target
name=
"dist"
depends=
"compile"
description=
"generate the distribution"
>
<target
name=
"dist"
depends=
"compile
, dist-java9-only, dist-mac-only
"
description=
"generate the distribution"
>
<!-- Create the distribution directory -->
<mkdir
dir=
"${dist}"
/>
<delete
file=
"${dist}/jam.jar"
/>
...
...
@@ -68,6 +93,7 @@
<jar
jarfile=
"${dist}/jam.jar"
>
<fileset
dir=
"${build}"
includes=
"**/*.class,**/*.properties,**/*.png"
/>
<zipgroupfileset
dir=
"${lib}"
includes=
"jam-mac-only.jar"
/>
<zipgroupfileset
dir=
"${lib}"
includes=
"jam-java9-only.jar"
/>
</jar>
</target>
...
...
src/jam/console/ConsoleApplication.java
View file @
f485e0ec
...
...
@@ -55,12 +55,11 @@ public class ConsoleApplication extends Application {
}
public
void
initialize
()
{
if
(
jam
.
mac
.
Utils
.
isMacOSX
())
{
// If this is a Mac application then register it at this point.
// Register the application with the OK. Prior to Java 1.9 this was just
// for Mac OS X. Now it uses java.desktop.Desktop to be cross platform
// This will result in any events such as open file being executed
// due to files being double-clicked or dragged on to the application.
jam
.
mac
.
Utils
.
macOSXRegistration
(
this
);
}
jam
.
mac
.
Utils
.
registerDesktopApplication
(
this
);
}
protected
JFrame
getDefaultFrame
()
{
return
consoleFrame
;
}
...
...
src/jam/framework/MultiDocApplication.java
View file @
f485e0ec
...
...
@@ -14,7 +14,6 @@
package
jam.framework
;
import
jam.mac.Utils
;
import
jam.maconly.OSXAdapter
;
import
javax.swing.*
;
import
java.io.File
;
...
...
@@ -58,15 +57,11 @@ public class MultiDocApplication extends Application {
}
public
final
void
initialize
()
{
// The frameless default menubar is now handled by the OSXAdapter
// setupFramelessMenuBar();
if
(
jam
.
mac
.
Utils
.
isMacOSX
())
{
// If this is a Mac application then register it at this point.
// Register the application with the OK. Prior to Java 1.9 this was just
// for Mac OS X. Now it uses java.desktop.Desktop to be cross platform
// This will result in any events such as open file being executed
// due to files being double-clicked or dragged on to the application.
jam
.
mac
.
Utils
.
macOSXRegistration
(
this
);
}
jam
.
mac
.
Utils
.
registerDesktopApplication
(
this
);
}
public
void
setDocumentFrameFactory
(
DocumentFrameFactory
documentFrameFactory
)
{
...
...
src/jam/framework/SingleDocApplication.java
View file @
f485e0ec
...
...
@@ -43,12 +43,11 @@ public class SingleDocApplication extends Application {
}
public
final
void
initialize
()
{
if
(
jam
.
mac
.
Utils
.
isMacOSX
())
{
// If this is a Mac application then register it at this point.
// Register the application with the OK. Prior to Java 1.9 this was just
// for Mac OS X. Now it uses java.desktop.Desktop to be cross platform
// This will result in any events such as open file being executed
// due to files being double-clicked or dragged on to the application.
jam
.
mac
.
Utils
.
macOSXRegistration
(
this
);
}
jam
.
mac
.
Utils
.
registerDesktopApplication
(
this
);
}
public
void
setDocumentFrame
(
DocumentFrame
documentFrame
)
{
...
...
src/jam/java9only/ApplicationAdapter.java
0 → 100644
View file @
f485e0ec
package
jam.java9only
;
import
jam.framework.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.desktop.*
;
import
java.io.File
;
public
class
ApplicationAdapter
implements
AboutHandler
,
PreferencesHandler
,
OpenFilesHandler
,
PrintFilesHandler
,
QuitHandler
{
private
static
ApplicationAdapter
theAdapter
;
// reference to the app where the existing quit, about, prefs code is
private
jam
.
framework
.
Application
application
;
private
ApplicationAdapter
(
jam
.
framework
.
Application
application
)
{
this
.
application
=
application
;
}
// The main entry-point for this functionality. This is the only method
// that needs to be called at runtime, and it can easily be done using
// reflection.
public
static
void
registerApplication
(
jam
.
framework
.
Application
application
)
{
// if (theApplication == null) {
// theApplication = Application.getApplication();
// }
if
(
theAdapter
==
null
)
{
theAdapter
=
new
ApplicationAdapter
(
application
);
}
Desktop
.
getDesktop
().
setAboutHandler
(
theAdapter
);
Desktop
.
getDesktop
().
setOpenFileHandler
(
theAdapter
);
Desktop
.
getDesktop
().
setPreferencesHandler
(
theAdapter
);
Desktop
.
getDesktop
().
setPrintFileHandler
(
theAdapter
);
Desktop
.
getDesktop
().
setQuitHandler
(
theAdapter
);
// Create a default menu bar that is shown when all windows are closed
JMenuBar
defaultMenuBar
=
new
JMenuBar
();
if
(
jam
.
framework
.
Application
.
getMenuBarFactory
()
!=
null
)
{
jam
.
framework
.
Application
.
getMenuBarFactory
().
populateMenuBar
(
defaultMenuBar
,
null
);
Desktop
.
getDesktop
().
setDefaultMenuBar
(
defaultMenuBar
);
}
}
@Override
public
void
handleAbout
(
AboutEvent
e
)
{
if
(
application
!=
null
)
{
application
.
doAbout
();
}
else
{
throw
new
IllegalStateException
(
"handleAbout: Application instance detached from listener"
);
}
}
@Override
public
void
openFiles
(
OpenFilesEvent
openFilesEvent
)
{
for
(
File
file
:
openFilesEvent
.
getFiles
())
{
application
.
doOpenFile
(
file
);
}
}
@Override
public
void
handlePreferences
(
PreferencesEvent
e
)
{
if
(
application
!=
null
)
{
application
.
doPreferences
();
}
else
{
throw
new
IllegalStateException
(
"handlePreferences: Application instance detached from listener"
);
}
}
@Override
public
void
printFiles
(
PrintFilesEvent
printFilesEvent
)
{
for
(
File
file
:
printFilesEvent
.
getFiles
())
{
DocumentFrame
frame
=
application
.
doOpenFile
(
file
);
if
(
frame
!=
null
)
{
frame
.
doPrint
();
}
}
}
@Override
public
void
handleQuitRequestWith
(
QuitEvent
e
,
QuitResponse
response
)
{
if
(
application
!=
null
)
{
application
.
doQuit
();
}
else
{
throw
new
IllegalStateException
(
"handleQuit: Application instance detached from listener"
);
}
}
}
\ No newline at end of file
src/jam/mac/Utils.java
View file @
f485e0ec
...
...
@@ -15,8 +15,8 @@ import java.lang.reflect.Method;
public
class
Utils
{
pr
otec
te
d
static
boolean
MAC_OS_X
;
pr
otec
te
d
static
String
MAC_OS_X_VERSION
;
pr
iva
te
static
boolean
MAC_OS_X
;
pr
iva
te
static
String
MAC_OS_X_VERSION
;
public
static
boolean
isMacOSX
()
{
return
MAC_OS_X
;
...
...
@@ -35,45 +35,43 @@ public class Utils {
}
public
static
void
macOSXRegistr
ation
(
jam
.
framework
.
Application
application
)
{
if
(
MAC_OS_X
)
{
public
static
void
registerDesktopApplic
ation
(
jam
.
framework
.
Application
application
)
{
Class
adapter
=
null
;
Class
osxAdapter
=
null
;
try
{
adapter
=
Class
.
forName
(
"jam.java9only.ApplicationAdapter"
);
}
catch
(
Exception
e
)
{
// do nothing...
}
if
(
adapter
==
null
&&
MAC_OS_X
)
{
try
{
osxAdapter
=
Class
.
forName
(
"jam.maconly.NewOSXAdapter"
);
// test if com.apple.eawt is present...
Class
.
forName
(
"com.apple.eawt.AboutHandler"
);
adapter
=
Class
.
forName
(
"jam.maconly.NewOSXAdapter"
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"This version of Mac OS X does not support the Apple EAWT."
);
// do nothing...
}
}
if
(
adapter
!=
null
)
{
try
{
if
(
osxAdapter
!=
null
)
{
// Invoke this by reflection to avoid linking errors on other platforms...
Class
[]
defArgs
=
{
jam
.
framework
.
Application
.
class
};
Method
registerMethod
=
osxA
dapter
.
getDeclaredMethod
(
"register
MacOSX
Application"
,
defArgs
);
Method
registerMethod
=
a
dapter
.
getDeclaredMethod
(
"registerApplication"
,
defArgs
);
if
(
registerMethod
!=
null
)
{
Object
[]
args
=
{
application
};
registerMethod
.
invoke
(
osxA
dapter
,
args
);
registerMethod
.
invoke
(
a
dapter
,
args
);
}
// This is slightly gross. to reflectively access methods with boolean args,
// use "boolean.class", then pass a Boolean object in as the arg, which apparently
// gets converted for you by the reflection system.
// defArgs[0] = boolean.class;
// Method prefsEnableMethod = osxAdapter.getDeclaredMethod("enablePrefs", defArgs);
// if (prefsEnableMethod != null) {
// Object args[] = {Boolean.TRUE};
// prefsEnableMethod.invoke(osxAdapter, args);
// }
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Exception while loading the
OSX
Adapter:"
);
System
.
err
.
println
(
"Exception while loading the
Application
Adapter:"
);
e
.
printStackTrace
();
}
}
}
// if there is no adapter then just continue without registering...
}
static
{
...
...