For some additional/custom attributes, like tab indices or tool tip texts, it would be nice to annotate the FXML with custom annotations. I have three proposals for it:
XML-Comment:
<!-- #TabIndex(index=1) -->
<Button fx:id="test_audio" text="Test" />
fx attribute:
<Button fx:id="test_audio" fx:tab_index="1" text="Test" />
Custom XML namespace attribute :
<Button fx:id="test_audio" custom:tab_index="1" text="Test" />
Is there a way to do this and get the attribute values on runtime?
Related
in our project we have a custom annotation #DeprecationReason which should be used to document why a member/method/class is deprecated (and thus annotated with #Deprecated)
So to have an IntelliJ warning when #Deprecated is used but #DeprecationReason is missing, I want to check if #Deprecated is present but not #DeprecatedReason.
In general, I find it difficult to find documentation about structural search, but I haven't found anything about analysing "sibling annotations".
Could anyone give me a hint about this?
You could try a template like this:
<searchConfiguration name="Not annotated methods" text="#Deprecated #$Annotation$
$MethodType$ $Method$($ParameterType$ $Parameter$);" recursive="true" type="JAVA" pattern_context="member" search_injected="false">
<constraint name="__context__" within="" contains="" />
<constraint name="Annotation" regexp="DeprecatedReason" minCount="0" maxCount="0" within="" contains="" />
<constraint name="MethodType" within="" contains="" />
<constraint name="Method" within="" contains="" />
<constraint name="ParameterType" within="" contains="" />
<constraint name="Parameter" minCount="0" maxCount="2147483647" within="" contains="" />
</searchConfiguration>
Which I based on the built-in/existing template "Not annotated methods". You can import this in the Structural Search dialog using the "Import Template from Clipboard" action under the tool button in the upper right.
Fields and classes will need a separate template.
I have a custom content model I created for Alfresco that has type with a d:date property. I am able to build the repository and share projects with seemingly no errors. However, I am unable to search by the properties using the data type d:date or d:int. I resolved the d:int problem by changing the data type to d:text and adding a regex constraint, but I'm not sure if that would be prudent for the d:date property.
Is there some additional configuration that I need to supply or create in order to search by properties that are not d:text?
Here is a snippet showing the type declaration:
<types>
<!-- Enterprise-wide generic document type -->
<type name="gl:x">
<title>Document</title>
<parent>cm:content</parent>
<properties>
<property name="gl:period">
<type>d:text</type>
</property>
<property name="gl:year">
<type>d:text</type>
<constraints>
<constraint ref="gl:documentYears" />
</constraints>
</property>
<property name="gl:docType">
<type>d:text</type>
<constraints>
<constraint ref="gl:documentTypeList" />
</constraints>
</property>
<property name="gl:date">
<type>d:date</type>
</property>
</properties>
</type>
</types>
The share search forms and properties forms seem to be rendering correctly, so I don't think that there is any problem within those.
The advanced search page accepts two types of parameters.
One is simply the "keywords" field. This performs a full text search, i.e. it looks for the provided keywords in ANY text property. There is no need to configure the full text search for custom types (e.g. your gl:x) - it automatically picks up any text property in any model in the system.
The other is the group of single parameters: name, title, description, mime-type, modified-date, modifier. These properties can be of any type. A d:date property would be perfectly acceptable here, as the modified-date parameter testifies.
But here custom properties are not picked-up automatically. They need to be configured explicitly.
Notice that in the upper part of the advanced search page is a drop-down called "Look for" with two options: content and folders. The best approach would be to add an option for your content type gl:x and to configure a search form for it.
You can find the definition of the two standard search forms in tomcat/webapps/share/WEB-INF/classes/alfresco/share-form-config.xml. The file is rather long so here are the two sections to look for:
<config evaluator="model-type" condition="cm:content">
<forms>
<!-- Default Create Content form -->
<form>
</form>
<!-- Document Library Create Google Doc form -->
<form id="doclib-create-googledoc">
</form>
<!-- Search form -->
<form id="search">
</form>
</forms>
</config>
<!-- cm:folder type (creating nodes) -->
<config evaluator="model-type" condition="cm:folder">
<forms>
<!-- Document Library Common form -->
<form id="doclib-common">
</form>
<!-- Search form -->
<form id="search">
</form>
</forms>
</config>
I've skipped the details, but what is important is that "cm:content" and "cm:folder" each defines a <form id="search"> with the desired search properties/parameters.
As an experiment you could modify share-form-config.xml directly and add your own definition:
<config evaluator="model-type" condition="gl:x">
<forms>
<!-- Search form -->
<form id="search">
<field-visibility>
<show id="gl:date" />
</field-visibility>
<appearance>
<field id="gl:date">
<control template="/org/alfresco/components/form/controls/daterange.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
Also you have to add the new search form to the AdvancedSearch configuration found in tomcat/webapps/share/WEB-INF/classes/alfresco/share-config.xml:
<config evaluator="string-compare" condition="AdvancedSearch">
<advanced-search>
<forms>
<form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
<form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>
<form labelId="search.form.label.gl_x" descriptionId="search.form.desc.gl_x">gl:x</form>
</forms>
</advanced-search>
</config>
Remember to restart alfresco after every change.
When you're satisfied with the results, it would be better to move your custom definitions to a separate share-config-custom.xml in your project (share-config.xml and share-form-config.xml should never be modified directly).
For more details: https://wiki.alfresco.com/wiki/Share_Advanced_Search
I have this code in ZK, with a menu to navigate:
<zk apply="org.zkoss.bind.BindComposer"
viewModel="#id('vm') #init('menu')">
<tabbox width="100%" sclass="nav_tabs">
<tabs id="tabs">
<tab label="Admin" onSelect="updateCategory(self.label)"/>
<tab label="User" onSelect="updateCategory(self.label)"/>
</tabs>
<tabpanels>
<tabpanel>
<toolbar hflex="true">
<toolbarbutton label="CreateUser" onClick="#Command('load',label=self.label)" />
<toolbarbutton label="CreateMno" onClick="#Command('load',label=self.label)" />
</toolbar>
</tabpanel>
<tabpanel>
<toolbar hflex="true">
<toolbarbutton label="LoadData" onClick="#Command('load',label=self.label)" />
<toolbarbutton label="DownloadData" onClick="#Command('load',label=self.label)" />
</toolbar>
</tabpanel>
</tabpanels>
</tabbox>
<separator height="30px"></separator>
<zscript><![CDATA[
void updateCategory(String category) {
current_category.setValue(category);
current_subpage.setValue("Index");
}
]]></zscript>
<hlayout>
<label id="current_category" sclass="nav_text nav_category" onClick="#command('submit')">Our Product</label>
<label sclass="nav_text">-</label>
<label id="current_subpage" sclass="nav_text">Index</label>
</hlayout>
</zk>
Then i have two roles Admin, and User, and i need load the pages of each user, and i am trying that when a user click in the toolbarbutton, for example CreateUser, then call a method that load in the space of my toolbar button the page, but i do not how can i do it.
Something like:
http://www.zkoss.org/zkdemo/tabbox/navigation_tabs
but i not need a string in Our product -> Product 1 - > Our Product-Product 1, i need load a page, and i am calling the page with the same name to the label.
And a page from a java class
Somebody can help me?
Please add the following to your tabpanel:
<include id="includeID" mode="instant" src="page.zul" />
Later on, you may load another page by adding the following to a zscript:
includeID.setSrc("another_page.zul");
How can I set a default value in a ComboBox using FXML?
<ComboBox fx:id="cbo_Bacteriologie_Aesculine" prefHeight="21.0" prefWidth="105.0" GridPane.columnIndex="1" GridPane.rowIndex="0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="NVT" />
<String fx:value="Bezig" />
<String fx:value="Positief" />
<String fx:value="Negatief" />
</FXCollections>
</items>
</ComboBox>
I want NVT to be selected by default. I tried adding selected="selected" and such but don't seem to find the right syntax.
Is it possible to edit the listed items using Scene Builder? I can't seem to find it.
Use this:
<ComboBox>
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="NVT" />
<String fx:value="Bezig" />
<String fx:value="Positief" />
<String fx:value="Negatief" />
</FXCollections>
</items>
<value>
<String fx:value="NVT" />
</value>
</ComboBox>
I don't think it's possible in the FXML. You will need to do it in the initialization of the component, in the controller, for example using the following line cbo_Bacteriologie_Aesculine.getSelectionModel().setSelectedIndex(1); for selecting the element Bezig.
But if you find a way to do it in FXML, I am interested.
EDIT : It is possible in FXML. You can see it in Guedolino's answer (https://stackoverflow.com/a/14436371/1344424), which should become the right answer to this question.
I got a strange error with the first suggested method
setSelectedItem(T) has protected access in SelectionModel
where T is a type-variable:
T extends Object declared in class SelectionModel
For me
getSelectionModel().select("NVT");
worked like a charm.
IzPack TargetPanel lets one select one target directory. However I need to allow users to choose two (one for apps, one for data). How to do that?
You can create a UserInputPanel and get the path as a variable from the user. Then you can use variable substitution anywhere you want. You'll have to add a userInputSpec.xml file and define your own panels (as many as you want). To get a directory, use <field type="dir" ... >
Example userInputSpec.xml from an application of mine. I include mongoDB with the installer and use this to get some settings.
<userInput>
<panel order="0">
<createForPack name="MongoDB" />
<!-- Other settings like port, ip, username, password-->
<field type="staticText" align="left" txt="Select the catalogue where data will be stored." id="staticText.registry.db.data.text" />
<field type="dir" align="left" variable="mongo.data.dir">
<spec txt="Data directory" size="25" set="$INSTALL_PATH\data" mustExist="false" create="true" />
</field>
</panel>
<panel order="1">
<!-- definition of a second panel -->
</panel>
</userInput>
You also need to include the userInputSpec.xml as a resource in your main installation file and add a UserInputPanel element for each panel that you define in userInputSpec.xml
Like this (in the <installation> element:
<resources>
<!-- other resources -->
<res id="userInputSpec.xml" src="userInputSpec.xml" />
</resources>
<panels>
<panel classname="HelloPanel"/>
<panel classname="InfoPanel"/>
<panel classname="LicencePanel"/>
<panel classname="TargetPanel"/>
<panel classname="TreePacksPanel"/>
<panel classname="UserInputPanel"/>
<panel classname="UserInputPanel"/>
<panel classname="InstallPanel"/>
<panel classname="ShortcutPanel"/>
<panel classname="FinishPanel"/>
</panels>
notice the double occurence of
I have two panels defined in my userInputSpec
Make sure that your UserInputPanels appear before InstallPanel because you have to get the variables from the user before copying your files.
This is just an example from my app. See the official documentation to get the idea of what the elements and attributes I used mean. There are many features connected with user input.