Anyone knows how to save a JavaFX scene into FXML file that can be loaded by the JavaFX FXMLLoader?
The SceneBuilder allows to do it, but if I build the scene manually, how I can save it into FXML file?
If you mean build a fxml file from a running screen built in Java, the short answer is that you can't.
The fxmlLoader is designed to work only to load files, it references the class XMLInputFactory but not the XMLOutputFactory.
If you would like to do it by yourself, it is not only rewrite the classes read by the FXMLLoader, because there is a lot of reflection (java.lang.reflect) in that class.
So the long answer could be: you can do it by yourself using a lot of reflection and writing dynamic tags from class names, but there will be no guarantee that your fxml gives the expected results.
There is no such library, AFAIK, and I'm not sure if it's possible to create a generic one. It might be possible for simple cases, but even then it's a lot of work, I guess.
Here is the FXML format explained, if you want to give it a try: http://docs.oracle.com/javase/8/javafx/api/javafx/fxml/doc-files/introduction_to_fxml.html
You could traverse your scene graph/ node and generate an FXML file.
But why do you need the FXML format? It might be easier just to rewrite the layout in FXML instead of writing a library like this.
If you manage to write such a library - let us know! :-)
.fxml is just file extension,you can create it with any text file editor , i recommend you to use SceneBuilder either way, since you can create your UI and CTRL+C on root component , CTRL+V to notepad++ or other editor , and get source straight from there , edit to your liking.
To make it short, FXML is an XML based declaration format for JavaFX. JavaFX provides an FXML loader which will parse FXML files and from that construct a graph of Java object. It may sound complex when stated like that but it is actually quite simple. Here is an example of FXML file, which instantiate a StackPane and puts a Button inside it:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<StackPane prefHeight="150.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml">
<children>
<Button mnemonicParsing="false" text="Button" />
</children>
</StackPane>
You want to specify controller as well with fx:controller=""
Or set controller in your code, whatever fits your needs.
if your question is more towards what pdem wrote , i suggest you to take a look at scenic View , you can get a lot of infomation from running application and recreate it based of it.If that aint sufficient , there is not much you can do.
Related
I have a carousel component for which there is a touch UI dialog naming '''cq:dialog''' .I need to increase size of all the fields of AEM dialog. Can anybody help me with this?
You can extend the aem style sheets by creating a clientLib:
Create a folder on file system. In this folder put a file with name content.xml.
The content of this must be
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="[coralui3]" />
The most important thing is categories=[...]. The name of categoriy must be "coralui3".
During deployment your own css styles will be virtuelly added to your enviroment.
Then put two files into the folder. One file must be named with css.txt. The name for your other one can be named by your own. In example 'myown.css'. Open css.txtand put the name of your css file into it. See also this video on youtube.
If you want to apply your style on all dialog widgets, you style classes must be named like the classes from AEM itself.
In case you want to apply partially, you have create your own css class. Then open your dialogs xmls and add the keyword "granitCss=" to you prefered widget. See also here.
In my app, I would like to access delegate methods from a View Controller, but when I try to access it this way :
let appDelegate = NSApplication.sharedApplication().delegate
I am getting nil, what could cause this ?
EDIT WITH ADDITIONAL INFO :
When I created the app, I did an error as I didn't choose to use storyboards, but when I needed them, I just added a storyboard file and defined it as the main interface, like this :
I believe my issue could come from here, could it be possible for the interface to be shown but not linked properly to the NSApplication (and so to the delegate) ?
If yes, how could I solve it ?
Thank you.
In your storyboard, make sure that App Delegate's custom class (in the Identity Inspector) is set to your delegate class.
Update
If you have just created a new storyboard, it will be empty. AFAIK there are no "standard" ways of creating the application scene. You have to copy it from another storyboard (they are just XMLs after all).
The simplest way would be creating a new project with Use Storyboard enabled, then right-click on your auto generated Main.storyboard, choose Open As ➔ Source Code. After that, copy the <!--Application--> part to your empty Storyboard.storyboard. Don't for get to grab the header and footer part of it, too. Below is just an example.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<scenes>
<!--Application-->
<!-- your copied content -->
</scenes>
</document>
Finally, right-click on your Storyboard.storyboard and choose Open As ➔ Interface Builder - Storyboard to resume the normal design view.
I'm curious if anyone knows how to have a parsys load w/ default components already in it.
What I'd like to accomplish is the following:
Form Component
- form-parsys
- input component
- input component
For the most part this was pretty straight forward. I created a "form" component that has a parsys in it. What I would like is for this form component to load with a few default input components already set. These input components would need to be a part of the form-parsys node, so that they can be reorganized amongst user added input components.
Not sure if there is any documentation out on this as I couldn't find any, but I'm sure it's not entirely impossible and wanted to see if anyone has done anything like this before, before I go ahead and start hacking away.
thank you
Brodie
I think what you are looking for are templates.
In CQ5, templates can be used to create pages with a predefined content, this can be a parsys (with components) or any other node you might want in your page when it is created.
In your case, you can define a template that includes a parsys component and whatever you want inside that parsys. You can also set rules for where a page can be created using that template.
After you have created (or edited, since you might already have one) the template, you can use the siteadmin to create a new page using your template. The page will be created and all the content below the jcr:content of the template will be copied into the new page. You can even have several templates for the same kind of page, if you need different types of 'initial contents'
An example of a template that includes a parsys with some content might look like this (I'm writing this mostly from memory, might have errors):
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="A form"
jcr:primaryType="cq:Template"
jcr:title="A form"
allowedChildren="/apps/app1/templates/home_page"
allowedParents="/apps/app1/templates/form_page"
allowedPaths="[/content(/.*)*]"
ranking="{Long}100">
<jcr:content
jcr:primaryType="cq:PageContent"
sling:resourceType="app1/pages/form_page">
<parsys
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys" >
<component
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/text"
text="here is some text"/>
<!-- more components here-->
</parsys>
</jcr:content>
</jcr:root>
i installed netbeans with java se7, and javafx samples are running fine. In scenebuilder, i can select an ID for each control defined and annotated with #FXML in my controller. however, i like my project organised. when i create a new package, and move my FXML file there, (myapp/views) and the controller stays in the root where it was -> myapp, then in scenebuilder does not seem to find the id.
I know about the 'controller class' in the FXML, but since i didn't move my controller, that should not be changed.
More specific, when both my controller and fxml are in the package 'holidayapp', it works. moving the fxml to a subpackage holidayapp/views', doesn't work. The controller class remains
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="holidayapp.HolidayViewController">
as the HolidayViewController remains in the root package. I do nothing else but moving the fxml file from the main package into a subpackage.
I would like to see the id's from the holidayViewController in my scenebuilder. Compoling and running with the fxml in a subpackage, was never any problem.
Thanks
I think you might be suffering from the following issue:
https://bugs.openjdk.java.net/browse/JDK-8091793
If you think you do, please consider to vote for and/or comment on this issue.
The way I worked with this was placing my Main class into the view (the one that extends Application). This gave me access to my Controller classes, their variables, and methods. This works for SceneBuilder 1.1.
I can only speak for when using Eclipse and not NetBeans so doing this may still result in nothing.
i'm trying to create a node in the Zend_Navigation tree that is just used for organizing the links within it. therefore it would NOT require an anchor tag when rendered and not show up in the breadcrumb. anyone know how to make this happen?
Not really sure what your're after. I assume that you use navigation.xml in application/config folder to organize your navigation. Then you could provide a dummy navigation element and disable it using css:
<all>
<label>Home</label>
<resource>default:Home</resource>
<module>default</module>
<class>dummy</class>
</all>