-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from itsallcode/adapt-to-macos
Adapt to macOS
- Loading branch information
Showing
32 changed files
with
586 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/OsCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.itsallcode.whiterabbit.jfxui; | ||
|
||
|
||
import java.awt.Desktop; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Helper class to check the operating system this Java VM runs in. | ||
* | ||
* please keep the notes below as a pseudo-license: | ||
* | ||
* http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java | ||
* compare to | ||
* http://svn.terracotta.org/svn/tc/dso/tags/2.6.4/code/base/common/src/com/tc/util/runtime/Os.java | ||
* http://www.docjar.com/html/api/org/apache/commons/lang/SystemUtils.java.html | ||
*/ | ||
public class OsCheck | ||
{ | ||
/** | ||
* Types of Operating Systems | ||
*/ | ||
public enum OSType | ||
{ | ||
WINDOWS, MACOS, LINUX, OTHER | ||
} | ||
|
||
/** | ||
* Detect the operating system from the {@code os.name} System property and | ||
* cache the result. | ||
* | ||
* @returns the operating system detected | ||
*/ | ||
public OSType getOperatingSystemType() | ||
{ | ||
return detectOperatingSystemType(); | ||
} | ||
|
||
private static OSType detectOperatingSystemType() | ||
{ | ||
final String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); | ||
if ((os.indexOf("mac") >= 0) || (os.indexOf("darwin") >= 0)) | ||
{ | ||
return OSType.MACOS; | ||
} | ||
else if (os.indexOf("win") >= 0) | ||
{ | ||
return OSType.WINDOWS; | ||
} | ||
else if (os.indexOf("linux") >= 0) | ||
{ | ||
return OSType.LINUX; | ||
} | ||
return OSType.OTHER; | ||
} | ||
|
||
public boolean isDesktopSupported() | ||
{ | ||
return Desktop.isDesktopSupported(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/systemmenu/DesktopIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.itsallcode.whiterabbit.jfxui.systemmenu; | ||
|
||
import org.itsallcode.whiterabbit.jfxui.UiActions; | ||
|
||
public interface DesktopIntegration | ||
{ | ||
public static DesktopIntegration getInstance() | ||
{ | ||
return StaticInstanceHolder.getInstance(); | ||
} | ||
|
||
void register(); | ||
|
||
void setUiActions(UiActions actions); | ||
} |
54 changes: 54 additions & 0 deletions
54
jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/systemmenu/DesktopIntegrationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.itsallcode.whiterabbit.jfxui.systemmenu; | ||
|
||
import java.awt.Desktop; | ||
import java.awt.Desktop.Action; | ||
import java.awt.desktop.AboutEvent; | ||
import java.util.Objects; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.itsallcode.whiterabbit.jfxui.UiActions; | ||
|
||
class DesktopIntegrationImpl implements DesktopIntegration | ||
{ | ||
private static final Logger LOG = LogManager.getLogger(DesktopIntegrationImpl.class); | ||
|
||
private final Desktop desktop; | ||
|
||
private UiActions actions; | ||
|
||
DesktopIntegrationImpl(Desktop desktop) | ||
{ | ||
this.desktop = desktop; | ||
} | ||
|
||
@Override | ||
public void register() | ||
{ | ||
LOG.debug("Registering desktop integration"); | ||
if (desktop.isSupported(Action.APP_ABOUT)) | ||
{ | ||
desktop.setAboutHandler(this::showAboutDialog); | ||
} | ||
} | ||
|
||
@Override | ||
public void setUiActions(UiActions actions) | ||
{ | ||
this.actions = Objects.requireNonNull(actions); | ||
} | ||
|
||
private void showAboutDialog(AboutEvent e) | ||
{ | ||
getActions().showAboutDialog(); | ||
} | ||
|
||
private UiActions getActions() | ||
{ | ||
if (actions == null) | ||
{ | ||
throw new IllegalStateException("UI Actions not registered"); | ||
} | ||
return actions; | ||
} | ||
} |
Oops, something went wrong.