-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop integration for macos #288
Conversation
Start scripts tries to open jnlp-url without explicit reference to openwebstart.
App-bundle is created in ~/.cache/applications. Corresponding symbolic link is created in ~/Applications
Will this fix #256 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reformate the code? Will do a more detailed review later.
public void testCreateDesktopLink() | ||
throws Exception | ||
{ | ||
if ( !OperationSystem.getLocalSystem().equals(OperationSystem.MAC64) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check https://www.baeldung.com/junit-5-conditional-test-execution#operating-system-conditions for OS specific tests with JUnit 5
} | ||
|
||
FileUtils.recursiveDelete(new File(userHome), new File("/tmp")); | ||
assert new File(userHome).exists()==false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Junit Assert
System.setProperty(JavaSystemPropertiesConstants.USER_HOME, userHome); | ||
assert userHome.equals(JavaSystemProperties.getUserHome()); | ||
updateCacheHome(userCache); | ||
assert userCache.equals(FilesystemConfiguration.getCacheHome()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Junit Assert
openwebstart/src/main/java/com/openwebstart/os/mac/MacEntryFactory.java
Outdated
Show resolved
Hide resolved
@vnashkev are you familiar with Pull Requests? |
sorry, not at all |
No problem :) If you have any questions just ask them and we will try to help you ;) |
ok, do you have any guideline for source code format? |
I have seen that you did the Pull Request based on a master branch of your fork. While this is ok for us it will be much easier for you to create a branch in your fork and create the Pull request based on that branch instead of the master branch. |
Anything that you change in your branch (currently the master branch) before this PR is closed will be reflected in this PR. You can do improvements based on discussions on the master branch of you fork, commit and push it. Once this is done the change should be in this PR, too. |
I would say that we are using the default format that comes with IntelliJ / Eclipse. Maybe you can just check to auto format the new and mutated classes by your IDE? |
I have just applied default Eclipse format for AppFactoryTest. Is it ok? |
YES :) Let's do it for all the files |
formatting & assert done |
ok, as a next step we should refactor the tests:
|
Files.delete(link); | ||
} | ||
} finally { | ||
restoreOrigins(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add restoreOrigins(); in a method that is called before each test. See https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/BeforeEach.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each test i change user.home system property & update FilesystemConfiguration.cacheHome via reflection. This could be moved into @beforeeach. This change may have an effect of other tests outside of AppFactoryTests. I would suggest to annotate restoreOrigins with @afterall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional changes
final URL srcUrl = jnlpFile.getSourceLocation(); | ||
final String schema = srcUrl.getProtocol(); | ||
final String url; | ||
if ("http".equalsIgnoreCase(schema) || "https".equalsIgnoreCase(schema)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please externalise "http", "https" and "jnlp" as constants. I assume that we already have defined them in a global constant class / interface but can not check at the moment.
private final static Path ensureUserApplicationFolder() | ||
{ | ||
final String userHome = JavaSystemProperties.getUserHome(); | ||
final File appFolder = new File( new File(userHome), "Applications"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Applications" <- CONST
} | ||
|
||
private final static Path ensureUserApplicationCacheFolder() { | ||
final Path appcache = Paths.get(FilesystemConfiguration.getCacheHome(), "applications"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Applications" <- CONST
final Path linkRealPath = link.toRealPath(); | ||
return cache.toRealPath().equals(linkRealPath); | ||
} catch (final Exception e) { | ||
/* ignore this error */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at least log this?
|
||
private final static Path getDesktopLink(final String appname) | ||
{ | ||
return Paths.get(JavaSystemProperties.getUserHome(), "Desktop", appname + APP_EXTENSION ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Desktop" <- Const
return false; | ||
public boolean supportsDesktopEntry() | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's switch this back to false. By doing so we can test the behaviour internally and activate the support with a Pull Request in near future :)
@vnashkev we are on a very good way here :) I really like this PR and it will provide much better native support for MacOS. Great work! I would love to deactivate the feature by default with this PR. By doing so we can test it internally and activate it once we have checked that everything is working. |
@@ -25,29 +25,38 @@ | |||
public class MacEntryFactory implements MenuAndDesktopEntriesFactory { | |||
|
|||
@Override | |||
public boolean supportsDesktopEntry() { | |||
public boolean supportsDesktopEntry() | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vnashkev Looks like the format is broken again ;)
@vnashkev this PR looks very good now :) Only the format in 1 file is broken again. Can you fix this? Once this is done I will be more than happy to merge this PR in OpenWebStart. Thank you very much for this good work! |
@vnashkev merged :) Thank you very much for your participation. The fix will be part of the next OWS release |
Thank you.16 июл. 2020 г. 9:37 пользователь Hendrik Ebbers <[email protected]> написал:
@vnashkev merged :) Thank you very much for your participation. The fix will be part of the next OWS release
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
|
open
with jnlp-url allowing operating system to decide how to open given url. This keeps app-bundle working even if OpenWebStart installation folder has changed. It will work with any available jnlp-url-handler for example with oracle webstart.