Display name of component when editing - aem

How do I display the name/title of the component to the editor/author, so they can see which component they're editing?

Ensure your component has a "_cq_editConfig.xml" file, which contains the following:
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:actions="[text:Your Component Name,-,edit,delete,copymove,-,insert]"
cq:dialogMode="floating"
jcr:primaryType="cq:EditConfig">
</jcr:root>
Notice in the cq:actions property, you can enter a name for your component.

In _cq_editConfig.xml file, cq:actions property can be used to give component name and other buttons options.
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:actions="[text:[Component Name],editannonate,-,copymove,delete,-,insert]"
cq:dialogMode="floating"
cq:disableTargeting="{Boolean}true"
cq:inherit="{Boolean}true"
cq:layout="editbar"
jcr:primaryType="cq:EditConfig"/>
Also, If you want to disable right click behavior on component and show an edit bar, use property cq:layout="editbar"
Actions sequence can be changed. Actions are separated by comma (,). For a separator between actions use "-".

Related

How to automatically update fields in Office.js add-in for Word?

I have an Office.js add-in that uses custom document properties. To update them i have to use deleteAll() because setting the value or a properties object gives weird generalexceptions and access denieds.
but deleting them all and adding them one by one works fine. But after the properties have been added, I have to press ctlr-A and F9 to update all the changed fields. Some are in headers footers so I have to select those and press ctrl-A/F9 there too.
In my VSTO i needed to call Word.application.activeDocument.fields.update() but is there something similar in Office.js? I scanned the API docs up and down but can't find a call that works. How do I update the fields in the document after I changed them?
In a docx we have a docProps/custom.xml which has something like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="schemas.openxmlformats.org/officeDocument/2006/…" xmlns:vt="schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Categorie">
<vt:lpwstr>My category</vt:lpwstr>
</property>
</Properties>
If we can bind those to content controls, that would be great. If that can be a 2way binding it would be awesome ;)

How to override apply and restore defaults

I want to configure some appearance settings for a type of file. So I created a new entry in the General->Appearance->Colors and Fonts.
My plugin.xml looks like this:
<extension point="org.eclipse.ui.themes">
<themeElementCategory
id="com.example.themeElementCategory"
label="My specific settings">
<description>
Control the appearance of .example files
</description>
</themeElementCategory>
<colorDefinition
categoryId="com.example.themeElementCategory"
id="com.example.colorDefinition"
label="Some Color"
value="COLOR_DARK_BLUE">
<description>
Your description goes here
</description>
</colorDefinition>
<fontDefinition
categoryId="com.example.themeElementCategory"
id="com.example.fontDefinition"
label="Some Font"
value="Lucida Sans-italic-18">
<description>
Description for this font
</description>
</fontDefinition>
</extension>
Now in the Colors and Fonts I have a new entry were I can set the color and the font.
How can I extend the preferences window so I can override the Restore defaults, Apply and Apply and Close buttons?
In my <themeElementCategory> I will have to add a class=MyHandlingClasswhich would override the performApply(), but what should that class extend/implement?
Same as 1, but add a PropertyChangeEvent, still don't know what should extend/implement
Less likely, create a new preference page which extends the PreferencePage and implements IWorkbenchPreferencePage
How can I achieve one of the first two options?
UPDATE FOR CLARIFICATION
Currently the color and the font for a specific file extension are hardcoded in a class( I KNOW).
When the file is opened in the editor, the informations are read from that static class and visible in the editor.
What I wanted to do:
In a static{} block, read the settings configured in the preferences and update the static fields from my class.
If the user changes those settings from the preferences, on apply I wanted to update the static fields from the class and "repaint" the editor.
If you just want to know when theme items change value use the addPropertyChangeListener method of IThemeManager to add a listener for changes:
IThemeManager manager = PlatformUI.getWorkbench().getThemeManager();
manager.addPropertyChangeListener(listener);
The PropertyChangeEvent passed to the propertyChanged method of IPropertyChangeListener contains the id, old and new value of the changed theme item.

how can I manage a scatterChar in the javaFX from scene builder?

I know how to manage the scatter chart inside the start method, but I want to use a fxml file containing a scatter chart and then I want to use a controller to control that. I used Scenebuilder for this purpose, but I don't know how I can add category axis to the scatterChar, I found the numeric Axis, but I didn't see any category axis to add.There is a horizontal category axis in the scene builder that is with the scatter chart, but I don't know, how I can add some values to it. Is that possible inside the scene builder, or I must do it in the controller?
Code based solution
Select your scatter chart in SceneBuilder.
In the Code panel for the scatter chart, type the fx:id you want to assign (e.g. scatterChart).
In your controller inject the scatter chart reference:
#FXML ScatterChart scatterChart;
In the initialize() method for your controller add your categories.
CategoryAxis xAxis = (CategoryAxis) scatterChart.getXAxis();
xAxis.getCategories().setAll(
"UFO sightings",
"Paranormal Events",
"Inexplicable Tweets"
);
If you need to pass data into your controller to plot inside your chart, select a method from:
Passing Parameters JavaFX FXML
Alternate partial FXML based solution
Although you cannot add the categories to the chart via the SceneBuilder UI, you can hand edit the FXML file load the edited file up in SceneBuilder (which will parse the file fine and display the categories and will preserve your hand-edits when you save the file in SceneBuilder).
Instead of adding the categories in code in the initialize() as defined in step 4, edit your FXML file manually and add the categories. Here is a sample:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.chart.ScatterChart?>
<ScatterChart fx:id="scatterChart" title="Concerning Events" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<xAxis>
<CategoryAxis side="BOTTOM">
<categories>
<FXCollections fx:factory="observableArrayList">
<String fx:value="UFO Sightings" />
<String fx:value="Paranormal Activity" />
<String fx:value="Inexplicable Tweets" />
</FXCollections>
</categories>
</CategoryAxis>
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</ScatterChart>
You can't repopulate the chart with actual data using FXML (but it is highly unlikely that would want to do that anyway).

Creating a working copy for Plone 4 custom content types

I have created a custom Plone content type in my package i.e. my.product.
I am in need of integrating a working copy support: so that a "published" document (in my case, a published content type) stays online while it is being edited. Basically, I want to take advantage of 'Working Copy Support (Iterate)' provided by plone.app.iterate to achieve what is explained here. This will provide me with ability to check-in/check-out my changes.
Is this possible in Plone 4 with custom content types using Archetypes? How would one go about it if yes?
I added the following two files inside my.product/my/product/profiles/default folder and it appears to work:
diff_tool.xml
<?xml version="1.0"?>
<object>
<difftypes>
<type portal_type="MyCustomType">
<field name="any" difftype="Compound Diff for AT types"/>
</type>
</difftypes>
</object>
repositorytool.xml
<?xml version="1.0"?>
<repositorytool>
<policymap>
<type name="MyCustomType">
<policy name="at_edit_autoversion"/>
<policy name="version_on_revert"/>
</type>
</policymap>
</repositorytool>
I have never used plone.app.iterate, but this is the generic approach how to solve the problem.
Actions are installed by plone.app.iterate GenericSetup profile. You can see actions here:
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/profiles/default/actions.xml
Pay note to the line *available_expr* which tells when to show the action or not. It points to helper view with the conditition.
The view is defined here
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/configure.zcml#L7
The checks that are performed for the content item if it's archiveable
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/control.py#L47
Most likely the failure comes from if not interfaces.IIterateAware.providedBy condition. Your custom contennt must declare this interface. However, you can confirm this putting a pdb breakpoint in checkin_allowed(self) and step it though line-by-line and see what happens with your content type.

Eclipse Code Assist with Composite Component and Custom Namespace fails

I made a composite component and declared a custom namespace in my taglib like this:
[...]
<namespace>http://www.#####.info/components</namespace>
<composite-library-name>composites</composite-library-name>
[...]
Now when I use that namespace:
xmlns:wb="http://www.#####.info/components"
Everything 'works Runtime' but Eclipse wont show any Code assist like when I use the 'default' namespace:
xmlns:wbcomposites="http://java.sun.com/jsf/composite/composites"
Is this a normal Eclipse behaviour or did I do something wrong ?
Edit:
For example when i write:
<wb:
And then press [STRG] + [SPACE] the code assist shows me that there are no components.
I think this behaviour would make the "user" think that he has done something wrong ...
I hope there is a way to fix this from my side..
The problem was that i mixed a normal component and a composite in the taglib:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://abc/components</namespace>
<composite-library-name>composites</composite-library-name>
<tag>
<tag-name>something</tag-name>
<component>
[...]
Now i splitted them into to taglibs and two namespaces ...
This solved also bugs were the normal component was looked up as composite ...