Registering a Template within an intellij Plugin - intellij-idea

I have created my Apache Velocity template under /resources/fileTemplates/internal/myTemplateClass.vm and would like to use it through:
final JavaDirectoryServiceImpl javaDirectoryService = new JavaDirectoryServiceImpl();
javaDirectoryService.createClass(myPsiDirectory,
"MyClassname",
"myTemplateClass");
So I added the following in my plugin.xml:
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<internalFileTemplate name="myTemplateClass"/>
</extensions>
However when I run my plugin it claims that it did not find a template with the name "myTemplateClass". I assume it is cause I haven't linked to the file perse. Where should I link this?
Thanks

If you have an <internalFileTemplate> with the name of "myTemplateClass" and you want to use it to create a Java class, the template needs to be stored as fileTemplates/internal/myTemplateClass.java.ft. So you need to change the extension of your file.

Related

JSF2 custom component, parameter autocompletion with a local file path

My First Question, after years, thank you all and stackoverflow ;-)
I code a new Component for JSF2 and use it to include other templates.
It works perfectly for me.
<cc:interface>
<cc:attribute name="src" type="java.lang.String" required="true"/>
<cc:attribute name="addOption" type="java.util.List"/>
</cc:interface>
<cc:implementation>
<cc:insertChildren />
<ui:include src="#{BeanAnything.convert(cc.attrs.src, cc.attrs.addOption)}" />
</cc:implementation>
But i cant complete the Parameter src via auto completion in intellij or netbeans with "strg + space" or whatever other will use.
It should be used like the ui:include on src parameter.
Any Ideas ?
That's what I want to achieve only with my own componente gg:include
See Example

Apache camel how insert property in SetBody

I am creating a message in my route, using:
<setBody id="_setBody1">
<constant>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?&>
..........
<mes:CalendarView MaxEntriesReturned="5" StartDate="(property.DateStart)" EndDate="(property.EndDate)"/>
But property doesn't work. In log I see:
<mes:CalendarView MaxEntriesReturned="5" StartDate="(property.DateStart)" EndDate="(property.EndDate)"/>
How I can insert property in message?
It looks like you want to set some properties inside a static content of XML. I suggest using one of the templates.. such as velocity. It will allow you to do property replacement and manage the static content outside of the route (which is handy for testing and other maintenance)
Yes, i created property before:
<setProperty id="_setProperty1" propertyName="DateStart">
<groovy>new java.text.SimpleDateFormat('yyyy-MM-dd').format(request.body.getStartDate())</groovy>
</setProperty>
But i want to insert this property in content of xml, inside Apache Camel route.

Custom Code Templates for SuiteCloud IDE

I'm planning on making my own Code Templates for when I generate my new scripts. Since SuiteCloud IDE is only configured for SuiteScript 1.0, I was hoping to create new templates for SuiteScript 2.0.
That said, I've got to the part where I can specify the directory for my custom templates, and I've gone ahead and created my templates, however, since I'm lacking the templates.xml, SuiteCloud IDE doesn't recognise my custom templates.
NetSuite Help doesn't really help that much except state that that file exists. But it doesn't say what it should contain, or even the structure of the data.
If anyone can help out here, it'd be much appreciated. TIA.
We've done the same exercise long ago for SuiteScript 1.0, and I've just recently done it for our SuiteScript 2.0 set.
You can find the default templates inside of P2_POOL_HOME/plugins/com.netsuite.ide.core_2016.2.0.e4.jar/templates/ where P2_POOL_HOME is usually ~/.p2/pool/
The general format of templates.xml is:
<configuration>
<templates>
<template label="TEXT YOU WANT IN DROPDOWN"
defaultFilename="DEFAULT NAME FOR FILE"
typesControl="radio|checkbox"
headerFilename="PATH/TO/FILE/HEADER"
startFilename="PATH/TO/START/FILE"
endFilename="PATH/TO/END/FILE"
rename="false">
<types>
<files label="TEXT LABEL FOR CHECKBOX" bodyFilename="PATH/TO/FILE/WHEN/SELECTED" />
</types>
</template>
</templates>
</configuration>
Here are two examples from our templates:
<configuration>
<templates>
<template label="2.0 Portlet"
defaultFilename="360CUSTOMER_PROJECT_PL_DESCRIPTION.js"
typesControl="radio"
headerFilename="header.ss2.js"
startFilename="portlet_start.ss2.js"
endFilename="portlet_end.ss2.js"
rename="false">
<types>
<files label="Render" bodyFilename="portlet.ss2.js" />
</types>
</template>
<template label="2.0 RESTlet"
defaultFilename="360CUSTOMER_PROJECT_RECORDTYPE_RL_DESCRIPTION.js"
typesControl="checkbox" headerFilename="header.ss2.js"
startFilename="RESTlet_start.ss2.js"
endFilename="RESTlet_end.ss2.js"
rename="true">
<types>
<files label="GET" bodyFilename="RESTlet_get.ss2.js" />
<files label="POST" bodyFilename="RESTlet_post.ss2.js" />
<files label="PUT" bodyFilename="RESTlet_put.ss2.js" />
<files label="DELETE" bodyFilename="RESTlet_delete.ss2.js" />
</types>
</template>
</templates>
</configuration>
For scripts that only have one entry point method (e.g. Suitelet, Portlet, Scheduled), you use radio for the typesControl setting and just have a single <file> tag under <types>. For those that have multiple entry points to choose from (e.g. Client, Map/Reduce, User Event), you use checkbox for the typesControl and then list each option that you want using <file> tags under <types>.
I do not actually know what the rename setting does.
The basic file structure of the generated file will be:
/* CONTENTS OF HEADER FILE */
/* CONTENTS OF START FILE */
/* CONTENTS OF ENTRY POINT 1 FILE */
/* CONTENTS OF ENTRY POINT 2 FILE */
/* ... */
/* CONTENTS OF ENTRY POINT N FILE */
/* CONTENTS OF END FILE */
I have tried the same thing using 2017. You will find some js and template files inside the jar file. I have modified the ss_2.0_suitelet.js and ss_header.js file.
Just pick those file from the jar and place in your own local library. Then modify. Dont forget to point the template directory in the preference->netsuite (eclipse ide).
You can also add Author and the Date. But not sure how to add the $filename in the comment as variable. Here is some sample.
Version Date Author Remarks
1.00 ${date} ${author} Initial version

how to add working sets to eclipse common navigator?

I would love to add support for Working Sets for my Eclipse plugin that used the Common Navigator framework.
In Eclipse bugzilla there is mention that this is supported
None of the online manuals for the Common Navigator explain how to do it
I do not know where to start even since there is no extension point for it, and the Working Set implementation classes are all "internal". I have a very basic navigator setup showing default project resources and some additional IFileSystem stuff implementing ITreeContentProvider.
You can get the working set manager using:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
and from that get the visible working sets with:
IWorkingSet [] workingSets = manager.getWorkingSets();
the members of a working set can be accessed with:
IAdaptable [] elements = workingSet.getElements();
so you could use the working sets list as the input for the tree viewer and adjust your tree content provider to deal with this.
In retrospect the following is a better solution. Instead of implementing ITreeContentProvider and traversing the working sets ourselves, we can reuse existing standard providers for the same content, which might work better.
You can use them like so:
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
viewerId="rascal.navigator">
<includes>
<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" />
<contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.workingSets"/>
</includes>
</viewerContentBinding>
In particular the org.eclipse.ui.navigator.resources.workingSets is what adds working sets capabilities to your navigator.
Adding your own content then becomes an issue of adding another content provider which ignores workingsets and projects and other kinds of resources which are already taken care of, e.g. like so:
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
activeByDefault="true"
contentProvider="org.rascalmpl.eclipse.navigator.NavigatorContentProvider"
id="org.rascalmpl.navigator.searchPathContent"
labelProvider="org.rascalmpl.eclipse.navigator.NavigatorContentLabelProvider"
name="Rascal search path"
priority="normal">
<triggerPoints>
<or>
<instanceof value="org.eclipse.core.resources.IResource"/>
</or>
</triggerPoints>
<possibleChildren>
<or>
<instanceof value="java.lang.Object"/>
</or>
</possibleChildren>
<actionProvider
class="org.rascalmpl.eclipse.navigator.NavigatorActionProvider"
id="org.rascalmpl.navigator.actions">
</actionProvider>
<commonSorter
class="org.rascalmpl.eclipse.navigator.Sorter">
</commonSorter>
</navigatorContent>
<commonWizard
type="new"
wizardId="rascal_eclipse.wizards.NewRascalFile">
<enablement></enablement>
</commonWizard>
<commonWizard
type="new"
wizardId="rascal_eclipse.projectwizard">
<enablement></enablement>
</commonWizard>
</extension>
and in the NavigatorContentProvider class we implement getElements and getChildren but only for our own additional content.

CruiseControl.net dynamicValue for sourcecontrol branch

maybe i'm just not seeing it, but i'd like a way to "inject" the value for branch (externally somehow) for a set of predefined build projects.
we have builds configured for Project1, Project2 and Project3. But at any time, the projects may take from a different branch, based on merge schedules. i'd like to store the Project=>branch mapping in either an external file or database, then dynamically inject it into the config file when we do a ForceBuild.
The following block is used in all 3 project config files, which are referenced at the bottom (end) of the cnet.config file.
<cb:define name="cvs-block">
<sourcecontrol type="cvs">
<cvsroot>:sspi;username=johnDoe;password=passTheSalt;hostname=127.0.0.1;port=1776:/$(repository)</cvsroot>
<module>"$(module)"</module>
<executable>c:\Program Files (x86)\cvsnt\cvs.exe</executable>
<workingDirectory>D:\CruiseBuild\$(workingDir)</workingDirectory>
<branch>[SOME EXTERNALLY DYNAMIC VALUE]</branch>
<autoGetSource>true</autoGetSource>
<timeout units="minutes">20</timeout>
</sourcecontrol>
</cb:define>
<cb:include href="D:\CruiseBuild\ACME-project1.xml" xmlns:cb="urn:ccnet.config.builder" />
<cb:include href="D:\CruiseBuild\ACME-project2.xml" xmlns:cb="urn:ccnet.config.builder" />
<cb:include href="D:\CruiseBuild\ACME-project3.xml" xmlns:cb="urn:ccnet.config.builder" />
Just generate a file (injectpath.config) with a defined value:
<cb:define branchpath="yourpath"/>
...and then include it into your config file shown above at the top.
Change your [SOME DYNAMIC VALUE] to $(branchpath).