NetBeans: How to simplify copy/paste Java code from online tutorials

Some months ago I created a small useful NetBeans plugin, which allows to you to save time when pasting code samples from online tutorials. Today I used it again and I still find it very useful in this specific context. And it saves you time. That is why I want to report about it.

What is the feature? You can copy the Java source code of whole classes from a tutorial and paste it via Menu|Edit|Paste to new file. Either the package declaration of the Java class is taken in account or the Java class is placed in the correct package. This depends on the selected node and it is documented included screencasts at https://github.com/markiewb/nb-paste-to-new-file.

That sounds familiar? Yes, this feature already exists natively in Eclipse JDT and Intellij IDEA.

Give it a try, when using NetBeans! Happy coding.

BTW: I am still looking for maintainers for my plugins! Because of time issues, I will not bugfix nor implement features anymore. Support your favorite IDE and by contribution to your favorite plugin!

PasteToNewJavaFile

NBP: How to brand a Maven-based NB platform application using resource-filtering

Based on a discussion in the mailing list the following FAQ entry has been created. 

http://wiki.netbeans.org/DevFaqVersionNumber#How_do_I_set_the_version_number_automatically_in_maven-based_applications.3F
It explains how use the maven-resource-plugin to replace content in the bundles. The example there shows you how to set the title of your NB platform application based on the version in the pom.xml. 

Missing plugins for your NetBeans nightly builds?

Do you use a Nightly-/Dev-Build of NetBeans or even a release candidate of 8.2 within the NetCAT-program and you are missing some of your favorite plugins?

First there is no plugin center for Dev-Builds. Also most plugins from the 8.1 plugin center are not verified for the new 8.2 build yet – including my plugins.

Nevertheless in the meantime you can still use the plugins and give the plugin authors feedback of the compatiblity to 8.2. Some plugins won’t work, because of using non-public API, but that is the point to find out!

How to do that?

At Tools|Plugins|Settings add the plugin center URL for 8.1 [1] and then at Tools|Plugins|Available Plugins click at “Check for Newest

Additional

If you are interested in testing non-verified plugins see the article [2]

[1] http://plugins.netbeans.org/nbpluginportal/updates/8.1/catalog.xml.gz
[2] https://benkiew.wordpress.com/2013/02/03/netbeans-ide-verification-of-plugins-and-update-center-urls-for-non-verified-plugins/

NB: How do I create an action which can be invoked by a macro?

Use @EditorActionRegistration!

@NbBundle.Messages({ "CTL_MyAction=Let's go", "macro-name=Let's go" })
@EditorActionRegistration(
	name = "macro-name", 
	mimeType = "text/x-java", 
	menuPath = "Source", menuPosition = 0, menuText = "#CTL_MyAction")
public class MyAction extends org.netbeans.editor.BaseAction {
 //...
}

Now your action can be invoked by a macro using its macroname (the name attribute in the @EditorActionRegistration-Annotation) and even recorded by the macro recorder.

[1] http://wiki.netbeans.org/DevFaqAddMacroableAction

Quicktips: Nice little features in NetBeans’ JS-Editor

Currently there is a MOOC on Oracle JET (https://blogs.oracle.com/geertjan/entry/sign_up_free_today_oracle), which I am attending. I am not a JS developer for my daily living, so there was no need for me to use the JS editor of NetBeans until now. So I was surprised by some cool features in NetBeans 8.1:

  • Drag & Drop of js files into HTML generates script tags
    2016-08-28 13h49_57.gif
  • Pressing ‘ or ” or ( or { on a selected text encloses the text
    2016-08-28 13h56_18.gif
    2016-08-28_14h14_04.png

Quicktip: How to customize the names of Maven project nodes

Since NetBeans 7.4 you can configure the name of Maven-based project via options at “Tools|Options|Java|Maven|Appearance”. No additional plugin is required.

Mavenprojectnodenamecustomization

For other useful features have a look at the “New and Noteworthy” pages at http://wiki.netbeans.org/NewAndNoteWorthy