Eclipse file template plugin doesn't use my template file - eclipse

I am not really familliar with this topic but I want to create a plugin described at this page:
HowTo extend CDT with custom file templates.
So far as described in the Link I got it working. But in the example the template format is directly described in the <template>...</template>-Node:
// ${file_name}
// Test Source
But what I want to do is not to write my file template format into the XML-File of the plugin. Instead I want to have a file that is used with the file temlate, in my example H_Template.h. But I don't know how to include that file. Does anyone know?
I tried to use the attribute <include file="H_Template.h"/> with an relative path to the file from my plugin location. Or is it the relative path to my eclipse folder?
template.xml:
<templates>
<template name="Source template"
id="test.codetemplates.csourcefile"
description=" "
context="org.eclipse.cdt.core.cSource.contenttype_context"
enabled="true">
// ${file_name}
// Test Source
</template>
<template name="Header template"
id="test.codetemplates.headerfile"
description=" "
context="org.eclipse.cdt.core.cHeader.contenttype_context"
enabled="true">
<include file="H_Template.h"/> <!-- <<<<<<<< ??? -->
</template>
</templates>
H_Template.h:
// ${file_name}
// Test Header

There is no support for this. The template code must be included as part of the template.xml file.
The Eclipse code which reads the template is org.eclipse.jface.text.templates.persistence.TemplateReaderWriter.

Related

Checkstyle Error in eclipse: cannot initialize module FilesFilter - Unable to instantiate FilesFilter

I am using checkstyle 5.7
I have written a custom FilesFilter as explained in the checkstyle documentation below,
http://checkstyle.sourceforge.net/writingfilters.html
As suggested in the documentation, I have written a java file and added an entry for it under "Checker" module in my config xml file.
So, this custom filter is supposed to ignore all files containing string "Test" in it's file name.
<module name="com.mycompany.myproject.filters.FilesFilter">
<property name="files" value="Test" />
</module>
Due to this entry in the config file, the check style is not loading in eclipse and gives following error,
cannot initialize module FilesFilter - Unable to instantiate
FilesFilter
Please help.
I think there is no straight solution for this yet. Or may be there is, if you are prepared to invest hours of your time.
Here's what I did as a workaround.
In eclipse, to disable checkstyles for a package (e.g. Test package in my case),
Go to, Project -> Properties -> Checkstyle
On Checkstyle Main tab, there is section "Exclude from checking.." with a set of check boxes.
Select the check box "files from packages:".
Click the "Change.." button in the right hand corner or just double click on "files from packages:"
Select the package you want Checkstyle to ignore. In my case I selected com/myproject/test/ package, and that was it. Checkstyle ignores all files in the test package.
If you are using Checkstyle as an ANT task, you may use excludes option as explained in the following code,
<target name="applyCheckStyle" depends="build" description="--> apply check style to all java files, excluding test package.">
<checkstyle config="${checkstyle.config}">
<fileset dir="${src.dir}" includes="**/*.java" excludes="**/test/**" />
<formatter type="plain" />
<formatter type="xml" toFile="${build.dir}/checkstyle_errors.xml" />
</checkstyle>
</target>
This worked for me :)

GWT Main.gwt.xml file

I have a gwt project with the following directories:
-com.project
-com.project.client
-com.project.shared
-com.project.server
The gwt.xml config file is located in the com.project directory. What value should be in the
<source> tag for path?
Do you mean the tag for source with attribute path in the gwt.xml file? If that's the case, you use those paths for the translatable code (i.e., the code you want compiled from Java to JavaScript). Typically it's just the client and shared code that you want the GWT compiler to handle so you would set the following:
<source path='client' />
<source path='shared' />
If you were referring to another tag, please forgive me. :)

Joomla 3.1.4 ,JInstaller: :Install: Cannot find Joomla XML setup file,error

I have setup already joomla 3.1.4 and I tried to install a plugin,But Im getting this error:
JInstaller: :Install: Cannot find Joomla XML setup file
This is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.5/template-install.dtd">
<extension version="3.1" type="plugin" group="content" client="myjoomlasite">
<name>plg_content_helloworld</name>
<author>Tahsin Çetin</author>
<creationDate>July 27th,2013</creationDate>
<copyright>Tahsin Çetin</copyright>
<licence>GNU General Public License</licence>
<authorEmail>tcetin#yandex.com</authorEmail>
<authorUrl>http://tahsincetin.com</authorUrl>
<version>1.1.0</version>
<description>Simple Hello World plugin</description>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
<filename>helloworld.xml</filename>
</files>
</extension>
You do not need to specify "helloworld.xml" in your xml file.Remove file and install again.This will be your final xml file-
<?xml version="1.0" encoding="UTF-8"?>
<extension version="3.1" type="plugin" group="content" client="myjoomlasite">
<name>plg_content_helloworld</name>
<author>Tahsin Çetin</author>
<creationDate>July 27th,2013</creationDate>
<copyright>Tahsin Çetin</copyright>
<licence>GNU General Public License</licence>
<authorEmail>tcetin#yandex.com</authorEmail>
<authorUrl>http://tahsincetin.com</authorUrl>
<version>1.1.0</version>
<description>Simple Hello World plugin</description>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
</files>
</extension>
Hope this will help.
The "Cannot find Joomla XML setup file" usually means you are trying to install an extension that wasn't designed for the version of Joomla you are installing to.
Read more here
In your opening <extension> tag, you do not need to specify a client attribute.
Where is the XML file in relation to your ZIP package? If it isn't at the top level of the ZIP, it won't be found.
Generally when this happens something is wrong with the XML file. If you have made any changes, try to think where those changes were and find a problem with the XML file.
Problems could be:
No opening or closing tag. Closing tags are easy to miss. Count them, make sure there's an opening and a closing tag.
Duplicated tags. It's easy to add two labels or showons for example, especially if you are copying and pasting.
Space before the opening XML tag
No closing fieldset tag
No closing extension or config tag. Easily deleted if you are replacing the file
You can easily use a tool like this:
https://www.w3schools.com/xml/xml_validator.asp
Which will help you to find issues such as missing opening and closing tags.

What should the contents of emma_ant.properties be?

I've been following this tutorial on 3. Getting Started (ANT), and it says <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> but does not give any reference to the contents of emma_ant.properties. Any ideas?
Other websites such as 3.4. How do I change an EMMA property default setting? also leave things to be desired (and is based on the command prompt and not a digital file). I've found another website Using EMMA with ANT for JUnit test coverage reporting, but again it leaves the properties file to the imagination (doesn't even provide an example file).
Any ideas on how to manipulate the emma_ant.properties to Load and custom tasks for ANT?
but does not give any reference to the contents of emma_ant.properties. Any ideas?
Check for emma.jar & emma_ant.jar which you have placed in the path specified you will find emma_ant.properties
Any ideas on how to manipulate the emma_ant.properties to Load and custom tasks for ANT?
You need not to manipulate the properties file to use the tasks.
To use emma tasks you should
<!-- directory that contains emma.jar and emma_ant.jar -->
<property name="emma.dir" value="${YOUR_BASE_DIR}/lib/emma" />
<!-- Set emma.lib to refer to the list of EMMA jar files -->
<path id="emma.lib">
<fileset dir="${emma.dir}">
<include name="*.jar" />
</fileset>
</path>
and
<!-- Load <emma> custom tasks so that they can be used in ANT -->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
and you should be able to use emma tasks.
Here are the contents of emma_ant.properties inside emma.jar
# -------------------------------------------------------------
emma: com.vladium.emma.emmaTask
emmajava: com.vladium.emma.emmajavaTask
# -------------------------------------------------------------
# end of file
Also Check out Emma Property Summary if it helps you...

Eclipse won't reckognize and validate JSP tag dir attributes

I'm currently using Spring Source Tools 2.9.1 - but I had the same issue with standard Eclipse J2EE distribution.
I'm writing java web application with jsp views.
To better reuse code I have created some tags - *.tag files in WEB-INF\tags folder
Example of enum.tag file:
<jsp:root version="2.0"
xmlns:form="http://www.springframework.org/tags/form"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:spring="http://www.springframework.org/tags"
xmlns:tags="urn:jsptagdir:/WEB-INF/tags"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<jsp:directive.tag pageEncoding="UTF-8" />
<jsp:directive.attribute name="value" required="true" rtexprvalue="true" type="Object" />
<jsp:directive.attribute name="cssClass" required="false" rtexprvalue="true" />
<span class="enum ${value.cssClass} ${cssClass}">
<span class="message">
<spring:message code="${value.name}" />
</span>
</span>
</jsp:root>
If I use this tag in my jsp the tag is reckognized by validator, but the tag attributes are not.
so I get warning for this line of jsp
<tags:enum value="${t.state}" />
warning:
Undefined attribute name "value"
tag nemaspace is initialized with:
xmlns:tags="urn:jsptagdir:/WEB-INF/tags
How to setup eclipse to properly validate tagdir's tags?
I use XML version of jsps (and tags) - all teh fiels are valid XML documents, it uses syntax like
<jsp:directive.tag pageEncoding="UTF-8" body-content="scriptless" />
<jsp:directive.attribute name="caption" required="false" rtexprvalue="true" />
<jsp:directive.attribute name="labelInfix" required="false" rtexprvalue="true" />
I now realized and checked that I need to use tagx extension (alongside jspx). With this change Eclispe validation works well.
Yes, as of the time of this writing, using Eclipse Luna, Eclipse's JSP tag validation for custom tags in JARs (called 'packaged tag files' by Oracle) is still horrible. I have two Java projects, one which contains the JAR which has my .tags and TLD (the TLD has elements). I managed to get the JSP tag validation e.g. <t:customTag /> working but Eclipse still marks all attributes in yellow as "undefined attribute name".
I was able to get the tag validation working in my dependent project by:
Adding the tag project to Build path->Projects->"Required projects
on the build path"
In my JAR/tag project itself, under Java build path->Order and
export, I marked the JAR file itself as exported.