How do I update an Eclipse template variable on the fly? - eclipse

I've added the following new Eclipse template via extension point. It simply adds a template for a sample testTag tag.
<!-- Add code template -->
<extension point="org.eclipse.ui.editors.templates">
<template autoinsert="true"
contextTypeId="html_tag"
description="[Description] Template populated by Snippet values ***"
id="org.eclipse.jst.jsf.ui.newHtmltag"
name="testTag">
<pattern>
<![CDATA[
<testTag style="background: ${color}"></testTag>
]]>
</pattern>
</template>
<resolver
contextTypeId="html_tag"
type="src"
class="TestTagTemplateVariableResolver">
</resolver>
</extension>
What I'd cannot figure out is how to change the value of the $(color) variable at runtime. More specifically, when the user presses Ctrl + Space (or the equivalent for content-assist) and types in "testTag" and presses Enter -- instead of the "color" placeholder text, I'd like it replaced by some other text value I have in another class. How do I do this?

This email chain from 2004 says it might not be possible:
the Java editor chooses not to respect resolvers contributed to its two context types ('java' and 'javadoc'), but only recognizes the built-in resolvers.
The html editor you are working with may have a similar restriction.

Related

tinymce <span> gets removed when containing <br />

I'm using Tiny 4.9.10 to dynamically generate reports based on templates. Users can create templates which contain placeholders. These placeholders then get swapped out for their actual values when generating the actual report. The placeholders get their style (including font, which is the main issue here) from their enclosing <span>-tag.
When replacing the placeholder with their actual value, we use <br />-tags to insert new lines, since some of the placeholders are almost full reports on their own which need to be structured.
After the placeholders have all been replaced, we inject this dynamically generated content back into a Tiny editor, so as to allow users to make ad hoc changes to the content.
At this point however we noticed that the <span>-tag around a piece of generated content containing <br />-tags gets removed. This is a problem, because the style info that was enclosed in this tag gets removed as well, resulting in problems further down the line when generating a PDF.
What I've tried to work around this:
setting verify_html to false
adding +span[br]/+span[br /] to valid_children
setting forced_root_bloc to div
The first two options did nothing to help me, and while the last one looked promising, it didn't help, because even when using <div>, font info gets enclosed into a child <span>.
I know this is expected behavior, because <span> is an inline tag and so it shouldn't have <br /> tags as children, but I'm currently at a loss for a workaround which allows me to include <br /> tags into my dynamically generated content without losing the style (most importantly the font) of the parent tag.
So I solved this by replacing the <span> tags by <div> tags when we swap out the placeholders by using some regex looking for spans that enclose a <p>...<\p> or a <b />. This stops Tiny from throwing away the <span> tags when they contain either of these enclosed tags
TinyMCE considers the <span> <br /> </span> construct an empty space and deletes it in favor of optimization.
I may be late, but you can also try using this callback in the setup option to stop the editor from removing empty spans:
setup: function(editor) {
editor.on('PreInit', function() {
editor.schema.getElementRule('span').removeEmpty = false;
});
}

TYPO3: Rename flux fields and keep the values?

Usually when renaming a flux field, the old values are not transfered and have to be entered again. Is there a way to keep the values after renaming a flux field?
Let's look at this simple flux configuration for example:
<f:section name="Configuration">
<flux:form id="article" icon="{f:uri.resource(path: 'Icons/Content/Example.svg')}" options="{group: 'FCE'}">
<flux:field.text name="text" rows="1"/>
</flux:form>
</f:section>
If I now rename the field text to title all previously entered values for text are lost:
<f:section name="Configuration">
<flux:form id="article" icon="{f:uri.resource(path: 'Icons/Content/Example.svg')}" options="{group: 'FCE'}">
<flux:field.text name="title" rows="1"/>
</flux:form>
</f:section>
Is it possible to somehow let flux know, that the field title is supposed to have the values of the former field text?
Short answer: no.
If I now rename the field text to title all previously entered values for text are lost
Long answer: in fact, they are still present in stored XML from FlexForm, but with old name. There are two reasons for this:
This is not technically possible to determine, that the field was
renamed. Because the end result is same, as field was deleted and a new was created.
Imagine a situation, that you have two page templates, where first one contains field of name text and second - title. You set first template as page template and fill text with something. Then you change template to second one - should now title contain previously filled value? Then you switch back to the first template - should the text be restored (in fact it is restored, because Flux doesn't delete it)? And now combine it with inheritance of templates and see, which mess can happen.

Typo3: Create translations of Extension Builder elements

I used extension builder to set up my frist extension. Except for the translation and everything works very well.
You can bind an element to an language but not the other way round. What I would like to do is, to create all needed elements in the default language and then create translations based on (some) of these elements, like you do in Typo3 Web-View. It's important that there is some kind of connection/relation between the defaulr element and its translations to make a fallback to the default language possible.
Is this possible? Or do I need to create multiple fields for all element properties (for all langs expected so far) in each element?
Update/Solution
It seems as if the desired function is already implemented (just a bit hidden).
First you need to create a new Element in default language. Next you create a second new Element and save it as the desired language in which you need to extend the first Element. If you reopen the second one a new select field shows up, where you can choose the lang-parent. Save it again an you'll have the connection.
Do we talk about Fluid extensions?
If so you have a translation tool:
<f:translate key="list_nonewsfound" />
And to translate this u have to create a file in /Resources/Private/Language/locallang.xml
<T3locallang>
<meta type="array">
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'news'</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="list_nonewsfound">No news available.</label>
</languageKey>
<languageKey index="da" type="array">
<label index="list_nonewsfound">Ingen tilgængelige nyheder.</label>
</languageKey>
</data>
</T3locallang>
(Example taken from tx_news)
More information (german link): http://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Translate.html
(english link): http://wiki.typo3.org/Fluid#f:translate

Xforms checkbox - replacing True / False with Y / N

I am writing a form (betterFORMs/Xforms) to be displayed to the user with a selection of checkboxes.
If a checkbox is empty the form should bind an "N" into the element. When ticked, a "Y".
I realise there are answers to this question already but I have tried all answered solutions with no luck.
The first solution I attempted to use is here - stackoverflow link
(the first solution looks good, but I have had more success with solution 2 as I am not using Orbeon)
The answer given is what I am looking for, but I am having trouble implementing this into my form. I am not using Xhtml or Orbeon and so the binding I use seems to be different to that used in the solution.) I have tried tweaking this code to fit into my form but I get a repetitive error from the xml parser every time I load the page - but it doesn't point me to anywhere related to the new code.
The next solution I have tried is found here - stackoverflow link
This answer has had the best results in my code because the checkbox values change to N when not used and when they are deselected. The problem I have with this solution is that the Y set in the form element is contained in braces - [].
output example:
<addressProof>N</addressProof><other>[Y]</other><otherText>_text_</otherText>
Here is a snippet of my form:
model:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsl:output method="xml" />
<xsl:template match="/">
<xforms:model id="documentsChecklist">
<xforms:instance>
<actionform xmlns="">
<xforms:model id="documentsChecklist">
<xforms:instance>
<actionform xmlns="">
<detail>
<other></other>
<otherText></otherText>
</detail>
</actionform>
</xforms:instance>
<xforms:bind id="other" nodeset="/actionform/detail/other" calculate="choose(. = 'Y', ., 'N')"/>
<xforms:bind nodeset="/actionform/detail/otherBox" relevant="/actionform/detail/other ='Y'" />
</xforms:model>
form:
<div id="formBody"><br />
<xforms:select bind="other" appearance="full" align="right">
<xforms:item>
<xforms:label>Other</xforms:label>
<xforms:value>Y</xforms:value>
</xforms:item>
</xforms:select>
<xforms:input ref="/actionform/detail/otherText">
<xforms:label>Please specify:*</xforms:label>
</xforms:input>
</div>
</xsl:template>
</xsl:stylesheet>
Why does the checkbox value now get set to "[Y]" instead of "Y"? (Could it be something to do with an Array?) Thanks.
PS. I know I could do this using a boolean for each checkbox, with the checkbox value corresponding to the boolean, which in turn updates the bind value. I would rather not have to have a big block of boolean elements and binds as I have a large amount of check boxes. this solution has an example here - stackoverflow link
A select control allows you to select more than one item and I wonder if it is why the XForms implementation you are using is adding square brackets (according to specifications selected values have to be separated by a space character, which is not always very convenient by the way).
I am afraid that XForms 1.1 and XForms 2.0 require to use extra intermediate nodes and bindings. It would be useful to be able to add 2 XPath expressions for bindings: one to convert node value to control value and the other one back from control value to node value.
As a workaround, I use another extension in XSLTForms: XSLT stylesheets for converting instances.
-Alain

Sharepoint 2007 - Custom List provisioning - are List Forms needed at deployment?

I have a feature which is provisioning 1 document library and 2 custom lists. A folder is included for each list containing the schema.xml for that list. Each folder also contains the associated forms (AllItems, DispForm, EditForm, NewForm, etc.). Everything deploys/works correctly but it seems a little redundant having the same forms copied into each list's folder. There is nothing special about these lists - the are basically a default doc library/generic list with additional fields provided through new content types (derived from Item/Document).
As far as I can tell these forms are pretty generic. Are there pre-installed forms that I can reference from my list so I don't have to deploy all of these extra files? Is there any reason I would not want to do this?
Update - moving xml in comment to original question for readability:
<Forms>
<Form Type="DisplayForm" Url="Forms/DispForm.aspx" WebPartZoneID="Main"/>
<Form Type="EditForm" Url="Forms/EditForm.aspx" WebPartZoneID="Main"/>
<Form Type="NewForm" Url="Forms/Upload.aspx" WebPartZoneID="Main"/>
<Form Type="NewFormDialog" Path="EditDlg.htm">
....
There are virtual defaults that are used if you don't specify a concrete page.
All lists use these template defaults unless you use a tool like SharePoint designer to customize the page. Then the template is used to create the concrete page and you can customize the look for a particular list without affecting others.
For my custom definitions, I use
<List>
...
<MetaData>
...
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
If you have no reason to customize the out of the box version of these forms, you can use the virtual form and not deploy copies.