Netbeans code templates with changing value - templates

Is it possible to create code template that will use written value?
simple example:
firstly: while + tab gives standard while code.
I would like to create something where while 100 + tab would give:
while (i<100) {
}
Where 100 is given value and can be different. Also would be nice to have more than one custom value.

Go to Tools -> Options.
Then click on Editor and go to Code Templates tab.
Click New, give and abbreviation and the code template.
Look at the existing templates, like whilexp - it shows how
to prompt for input on the code template.

Related

Is it possible to use templates when creating a scratch file in PyCharm?

I created a custom template file and I can use it from the "File"->"New..." menu option.
But I was expecting to see it also when creating a new scratch file using
"File"->"New Scratch File"
Is this even possible?
(I am using PyCharm 2017.1.2)
I think it's not possible: each time you create a scratch file, it's created from scratch.
Though, what's possible in order to simplify your life, is using Live Templates: you can create your own abbreviation, which can be expanded automatically to some portion of code. There are many examples in Settings -> Editor -> Live Templates so you can use them as an example.

Webstorm helper for requiring module

I'm looking for a way to require module easily with Webstorm (shortcut, plugin, intention, ...). Here is my use case :
Given my cursor located at the end of a unknown variable myVar somewhere in my JS file.
When I press a shortcut, I jump at the top of the file and var myVar = require('') is inserted with the cursor inside the empty string.
Then I type the name of the module and I press enter.
Then the cursor go back at the end of the variable.
Is there a way to do that ?
Please vote for WEB-14430.
You can try developing a custom intention - code intentions use the regular API for intentions. The intention classes need to implement the IntentionAction interface and to be registered using the bean in the plugin.xml (http://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA)
See https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/SplitIfIntention.java - intention sample for Groovi.
See also http://confluence.jetbrains.com/display/IDEADEV/PluginDevelopment, http://devnet.jetbrains.com/message/5298765.
Live Templates is another option, but it just allows expanding certain abbreviation into a code snippet - no jumping, etc. - snippet will be expanded 'in-place'

How to customize Sitecore workflow Comment box

I am working in Sitecore 7 and want to customise the comments textbox. I need following functionality:
Instead of Single line, I want to replace it with multiline.
Is it possible to have rich text box instead of single line to allow users to put more meaningful comments and those are visible in History too.
You have to modify a lot to do it. When you approve button is called this command :
<command name="item:workflow" type="Sitecore.Shell.Framework.Commands.Workflow,Sitecore.Kernel"/>
with some parameters
Inside this class you have next method :
protected void Run(ClientPipelineArgs args)
{
...
where you find next lines of code that is called to show single line input :
...
if (!flag1 && flag2 && !flag3)
{
SheerResponse.Input("Enter a comment:", "");
args.WaitForPostBack();
}
Yes, this is possible, but you'll have to essentially recreate and replace some basic functionality to do it. And worse... it will require use of SheerUI, which is not documented anywhere from Sitecore that I know of. You have to figure it out by disassembling existing code. If you look at Sitecore's implementation of say, the Approve action, you'll see there is a SheerUI call to get the comment text. (not looking at it right now, so I don't know exactly where this is) You'll need to replace this with a SheerUI call to load your own custom dialog. How do you do this? Well... man, wouldn't documentation on this be nice?

woocommerce advanced templating

i´m developing a theme and for some reason i need to move the default position for breadcrubms (also for many other things) over woocommerce themes. Then i realised to do something like this on my functions.php:
function woocommerce_remove_breadcrumb(){
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
}
add_action('woocommerce_before_main_content', 'woocommerce_remove_breadcrumb');
function woocommerce_custom_breadcrumb(){
woocommerce_breadcrumb();
}
add_action( 'woo_custom_breadcrumb', 'woocommerce_custom_breadcrumb' );
And then on any template file, output the breadcrumb just with:
<? do_action('woo_custom_breadcrumb'); ?>
And works. My question is more than that. Is this the correct approach for something like this? I mean for anything over woocommerce, not just breadcrumb, for any pice, ratings, titles, buttons, sidebar, and so on.
What i´m thinking on is why woocommerce templates don´t come with more deep code. I mean, why there´s no such a single-content-loop.php template where you can just change the order of things, title, category, content, images, etc. in an easy way rather that hooking into functions?
I think that is an acceptable way to call the breadcrumbs explicitly. Sometimes it is easier to call a specific function than remove everything around it!
As for changing the order of things and getting into advanced customization; there isn't a single file, but a number of files working together. Create a folder in your themes root called 'woocommerce' and copy the following files for a safe override:
woocommerce/woocommerce-hooks.php:
Here are your hooks, including the ones you are overriding in your themes functions.php. Here is where you can experiment with removing and repositioning certain elements on your product page. Search for 'Sidebar' and you will see where the 'woocommerce_sidebar' action is added with the function it references in...
woocommerce/woocommerce-template.php:
Here are the functions used in template files to output content based on conditional statements. For instance, search for the 'Single Product' series and you can see which template files are used for which functions. For instance 'woocommerce_template_single_title' uses 'single-product/title.php' - if you copy over this folder and file you can make very specific edits to just the title section
Between these two files and their accompanying references (like title.php) I believe you can do the things you described. Let me know how it works out! I'm new to woocommerce too!

NetBeans template prompts user for variables

I am taking a programming class in college where my professor requires me to include information on the assignment withing a JavaDoc comment block in a specific format. I'm wanting to create a java class template so that when I create my file, I just type in the assignment specific information, and it places it in the template. Is this possible, or do the variables used in netbeans templates have to be pre-defined?
"I'm wanting comments that are generated when the user creates a .java file in netbeans."
Then your best solution is modifying the templates and defining custom User.properties when needed.
In NetBeans 7.2 (latest I think), go to [Tools] -> [Templates], and in the Template Manager window you can expand whatever template for whatever language you like and customize it.
For example, if you expand Java, you can then change the Java Class by highlighting it and selecting [Open in Editor]. At that point, you can easily see the normal javadoc comment block at the top.
/**
*
* #author ${user}
* #professor Mr. LordZardeck's Professor
*/
public class ${name} {
}
If you want to add custom properties, like the above uses the user property, in the Template Manager window, select [Settings]. That will open the User.properties file where you can add properties of your own. If you look at the bottom of the file, the last line is commented out, but it is an example of a custom property, uncommented it is:
user=Your Name <your.name at your.org>
So, with this you can specify static tags that can be auto-created without any work by simply changing the templates (like the professor tag added to the java class template). For a tag whose variable might change from assignment to assignment, you can use the custom user properties to assign those at the start of each assignment, then the templates will auto-fill your assignment information into the auto-generated custom javadoc tags when your template is opened.