-
Notifications
You must be signed in to change notification settings - Fork 221
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
MacOS: avoid hiding SceneBuilder menu bar with FXML menu bar when useSystemMenuBar property is enabled #405
Conversation
… expression which checks if the WYSIWYG adjustment for preview function shall be used or not.
3b2e343
to
c2e75cd
Compare
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMLoader.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Show resolved
Hide resolved
Hi @Oliver-Loeffler , Do you plan to work on this PR and resolve Jose's comments? |
Yes for sure - will see to make some progress here during next days. |
b532602
to
bc22b83
Compare
Hi @abhinayagarwal & @jperedadnr, |
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Outdated
Show resolved
Hide resolved
perform the replacement. Added a parameterized test accordingly.
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/EditorPlatform.java
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
.../test/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisablerVariationsTest.java
Outdated
Show resolved
Hide resolved
...esources/com/oracle/javafx/scenebuilder/kit/fxom/ContainerWithMenu_SystemMenuBarEnabled.fxml
Outdated
Show resolved
Hide resolved
renamed property meta data instance accordingly
@jperedadnr Many thanks for your patience in this! |
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXMLPropertiesDisabler.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMDocument.java
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMIntrinsic.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMNodes.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/fxom/FXOMObject.java
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/metadata/Metadata.java
Show resolved
Hide resolved
kit/src/test/resources/com/oracle/javafx/scenebuilder/kit/fxom/NonNormalized_Accordion.fxml
Outdated
Show resolved
Hide resolved
kit/src/test/resources/com/oracle/javafx/scenebuilder/kit/fxom/Normalized_Accordion.fxml
Outdated
Show resolved
Hide resolved
kit/src/main/java/com/oracle/javafx/scenebuilder/kit/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2019, Gluon and/or its affiliates. | |||
* Copyright (c) 2022, Gluon and/or its affiliates. |
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.
2019, 2022,
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.
Updated
@@ -1,4 +1,5 @@ | |||
/* | |||
/* | |||
* Copyright (c) 2017, 2022, Gluon and/or its affiliates. |
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.
Copyright (c) 2022, ...
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.
Corrected
this.glue = new GlueDocument(fxmlText); | ||
this.location = location; | ||
this.classLoader = classLoader; | ||
this.resources = resources; | ||
initialDeclaredClasses = new ArrayList<>(); | ||
if (this.glue.getRootElement() != null) { | ||
String fxmlTextToLoad = fxmlText; | ||
if (!Set.of(switches).contains(FXOMDocumentSwitch.FOR_PREVIEW)) { |
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.
Extract Set.of(switches)
to a variable, so you don't create the set twice?
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.
There is now on set used for both places where it is required.
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.
Looks good, great job!
…SystemMenuBar property is enabled (gluonhq#405) Co-authored-by: Oliver-Loeffler <Oliver-Loeffler@users.noreply.github.com>
For MacOS, when Scene Builder opens a FXML file with a MenuBar with property
useSystemMenuBar="true"
,then the SceneBuilder menu bar is replaced with the menu bar defined in FXML. Hence SceneBuilder becomes impossible to use.
This PR introduces code which conditionally disables the
useSystemMenuBar="true"
in the constructor ofcom.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument
. As there was already a boolean parameternormalized
, the boolean arguments have been replaced with an enum typeFXOMDocumentSwitch
which provides the valuesNON_NORMALIZED
andFOR_PREVIEW
. The change of internal API is minimal and there is no change in default behavior of theFXOMDocument
constructor.Default behavior
For normal loading of an FXML file using the
FXOMDocument
constructor, the FXML text which is supplied to the FXMLLoader is modified, so that value ofuseSystemMenuBar
is turned tofalse
. This change is not reflected in the FXOM so that the original setting is preserved and can be saved to an FXML file again.Thus, when loading an accordingly modified FXML file, the SceneBuilder menu will remain the one displayed in MacOS menu bar.
An prepared example is provided within the test resources.
kit/src/test/resources/com/oracle/javafx/scenebuilder/kit/fxom/ContainerWithMenu_SystemMenuBarEnabled.fxml
Preview behavior
For previews instead, it migh be desirable to have exactly the behavior that the menu from a given FXML is displayed in MacOS menu bar. Therefore, the argument
FXOMDocumentSwitch.FOR_PREVIEW
is added to the call of theFXOMDocument
constructor incom.oracle.javafx.scenebuilder.kit.preview.PreviewWindowController
. In that case, the FXML text which is supplied to the FXMLLoader is not modified at all and if the propertyuseSystemMenuBar="true"
exists, then the menubar defined in preview will be displayed in MacOS menu bar.Issue
Fixes #404
Progress