Create user variable in Intellij File Template - java

I am trying to use Intellij's file templates (not live templates) to help mitigate how much boilerplate code I use when making Services, daos, and their interfaces.
I am able to use all the system defined variables just fine, such as
${PACKAGE_NAME}
What I want though, is to be able to use my own variable names, like
${MY_USER_INPUT}
however, when i do this like above, I get an error
The documentation says :
It is also possible to specify arbitrary number of custom variables in format ${<VARIABLE_NAME>}.
and then Intellij is supposed to prompt the user for the value.
However, this just plain doesn't work for me. What am I missing?

Looks like a bug, submitted as IDEA-63628. Please watch/vote.

I use the custom variabeles in alot of template and ${MY_USER_INPUT} should work.
What error do you get ? what vesion of IntelliJ Do you use ?
In general stating "however, when i do this like above, I get an error" really isent helpfull people cannot guess whats wrong if you dont tell us, you should at least post a clear example of you file template and the exact error.

Related

JSCIPOpt set objective

I am trying to use JSCIPOpt to solve a maximization problem but I couldn't find a way to set the problem objective. The scip document says
The default objective sense for SCIP problems is minimizing. Since we have a
maximization problem we have to change this:
SCIP_CALL_EXC(SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE));
But I was not able to find any API call in the JSCIPOpt to set objective. I was, however, able to find setMaximize in PySCIPOpt. Am I missing something? What is the correct way to set the objective using JSCIPOpt?
It doesn't seem to be supported yet. You should just create an issue on the github page and submit a feature request: https://github.com/SCIP-Interfaces/JSCIPOpt
Even better, though: Implement the feature yourself (see https://github.com/SCIP-Interfaces/JSCIPOpt#how-to-extend-the-interface) by introducing the necessary interface function in the same way it's done in PySCIPOpt and submit a merge request! This way you learn something on the way and everyone's happy :-)

Java: Simple Validation API Validation Strategy Change

This is in reference to the question posted at org.netbeans.validation.api.ui.ValidationGroup.add() - How to specify ValidationStrategy?
I am trying to do something similar. Please guide me on what needs to be changed and where. I went through the given links but couldn't find the relevant info.
P.S.: Asking in a separate question because I can't comment on the original one due to lack of reputation points.
Regards
Uday
I found out what was required.
Check out the code from their repository (https://svn.kenai.com/svn/simplevalidation~src) and open ValidationAPI as a project in Netbeans (or whatever IDE you're using).
To change the default validation strategy you'll need to make the changes in ValidationGroup and SwingValidationGroup classes under org.netbeans.validation.api.ui and org.netbeans.validation.api.ui.swing respectively.
In these classes find ValidationStrategy.DEFAULT and replace it with the strategy you want (INPUT_VERIFIER, ON_FOCUS_LOSS, ON_CHANGE_OR_ACTION).
Build the project to generate a new jar and incorporate that jar in your own project.
That's it.

Any way to enforce naming standards in android?

I am aware of http://omnidroid.googlecode.com/svn/tools/Eclipse_Formatter-ITP_Conventions.xml that can be imported into my Android projects Formatter , but it doesn't enforce naming convention standards. I know there are many standards available per project but I'd rather if there were rules set to ensure it. Is there another XML file I can import into my formatter to ensure such? Something like the Resource Style Rules at the end of the page at https://github.com/iamshanedoyle/Android-CodingConvention would be great to have, but I don't really know how to code this into the XML file?
Formatter can only help you to maintain formatting.
Also check the Code Style part of the project configuration, like variable prefixes and suffixes; those help to use Content Assist for example with getters: if you have a member named m_x and prefix is set to m_ you get a suggestion for getX()/setX(T) upon pressing Ctrl+Space; without it, you'd get a funny getM_x() suggestion.
The best solution to your problem may be setting up PMD/Checkstyle for your project and failing build in CI if invalid code is submitted.
I sometimes set all these up together, so Formatter/Code Style helps to write code which adheres to PMD/Checkstyle rules. Also I set up Save Actions in Eclipse so that I don't have to press Ctrl+Shift+F and Ctrl+Shift+O, etc. repeatedly, just a simple Ctrl+S does the work.

Getting better syntax highlighting with ctags and vim

I'm trying to set up vim to work nicely with Java. I've set up eclim, which seems to work great for letting me know when something is wrong, but I'd really like to get vim to do two things to make my code easier to read.
Have brackets and braces show up with a different colour from the main font.
Get classes to highlight as a different colour.
I haven't come up with anything good for the first point, but it seems like the second should be doable with ctags. I found a plugin called TagHilight that should do this but I can't seem to get it to work.
I also found a file called javaid.vim that is supposed to do this, but again I've had no luck with that.
For your first requirement of highlighting braces and brackets, there is no default highlight group for braces. You need to create one for yourself. Here is how you do it!
For your second requirement of how to highlight classes, you should be using this TagHighlight plugin. And this page explains in detail about the plugin and how to get it working. It also shows you snapshots where your exact requirement is met! :)

"The value for the useBean class attribute user.UserData is invalid" - why?

Attempting to create a selection of webpages that take some information, and then display it on a later page, Works up to the retrieving and displaying stage, where I get the following error,
The value for the useBean class attribute user.UserData is invalid
I am using the following tutorial: http://www.jsptut.com/Forms.jsp
I know there is probably 40 billion different questions aanswering this, but I literally picked up JSP at 9.13am this morning. So I need a tailormade answer!
I'm using Eclipse IDE and Tomcat 6.0.33
Thanks
P.S. Some google research keeps mentioning compile.class. Some mention they compiled the bean, but it thought JavaScript was a script meaning it didn't need to be compiled?
Rev: Right, so apparently, i need to compile the bean and then use JSP to execute it? Can anybody advise me on how to compile my Bean?
http://download.oracle.com/javase/tutorial/ is a good place to start. You might want to jump into http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html. It's a step-by-step on how to write, compile and run using command-line tools and then work your way down the tutorial list.
When you're a little familiar with that, you can set yourself up with a good development environment, like netbeans or eclipse

Categories

Resources