Intellij IDEA plugin with markers - intellij-idea

We use framework where for some classes there is xml configuration file. I want to write plugin which adds icon near field declaration (in eclipse that icons are called markers). When click on this icon user navigate to xml configuration for the field. This is similar to spring or hibernate plugin with xml config. How can I add that markers? Is there some open source plugin that do similar things?

Grab IntelliJ IDEA Community Edition source code from GitHub if don't have it already.
Please see com.intellij.navigation.GotoRelatedProvider, sample implementation can be found in com.theoryinpractice.testng.TestNGRelatedFilesProvider.

Related

How to vizualize spring integration file in intellij idea 14?

On the page https://www.jetbrains.com/idea/whatsnew/ it is said that Intellij Idea 14 has got a visual diagrams for spring integration.
But I can't find how to visualize my integration xml file.
(right click on file)/Diagrams/Show Diagram... shows a diagram with links between the beans. It is not very usefull.
Spring Integration Patterns plugin is enabled
I have Intellij Idea installed on a computer without access to the internet. May it be the reason why the diagrams are not working properly?
What do you want to see there?
For example.
We have stomp-chat sample: https://github.com/spring-projects/spring-integration-samples/tree/master/applications/stomp-chat
And here is a diagram for this config: https://github.com/spring-projects/spring-integration-samples/blob/master/applications/stomp-chat/src/main/resources/org/springframework/integration/samples/chat/stomp/server/stomp-server.xml
I'd say that it is OK, however I agree that it would better if I'd provide id attribute for all components.
Of course, Spring Integration Patterns plugin has to be switched on.
This link helps - https://devnet.jetbrains.com/message/5529839#5529839
"Please make sure the XML file is correctly configured in Spring context setup via Spring facet.
It requires spring-integration-core to be in module dependency of selected XML file."
I had the same problem, and found that in addition to having the Spring facet enabled, and having the spring-integration-core dependency and having the relevant context file set as an application context under the facet, you also need to have just the containing module open. i.e. the stomp-chat spring-integration sample provides the "Spring Integration" diagram option if it is opened from its own pom.xml, however if you open the parent applications\pom.xml then the "Spring Integration" diagram option is not available, regardless of facets etc.
I have the same problem in a project where I use spring integration 2.1.4.
In a newer project I use 4.0.0 and there Intellij Idea offers the option to open the spring integration diagram.
Perhaps that is the reason and you "only" need a newer version of spring integration.
The issue is that the newer versions of Intellij create separate modules per source set by default which somehow ends up conflicting with earlier setups. Using Intellij 2016.1, I instead reimported my project with the following options checked:
Once I did that then (right click on file)/Diagrams/Show Diagram once again gave me the Spring Integration Option.
Yes, click on your Spring Integration context file > Diagrams > Show Diagram... > Spring Integration., but if you haven't this menu follow below:
You should have identified integration context as Spring XML based configurations. Instruction here : Create a Intellij file set
I don't know why, but I had a problem with Spring Integration Diagram when I installed Springirun plugin.

How to create a JAXB project in IntelliJ IDEA 13?

I am learning JAXB.
I need to know how should I create a simple java project for JAX-B in IntelliJ IDEA13. If anyone have idea, please update me and also update me with any plugin for IDEA
Thanks.
You don't need to do anything special when you create your project. Just a simple java project will do.
There are however some tricks that can help you. There are 2 built-in live templates for jaxb :
typing mjo + hit tab-key: will generate the code for a marshaller.
typing ujo + hit tab-key: will generate the code for an unmarshaller.
Intellij has built-in functionality for generating an xsd file for any xml file. Just right-click on any xsd file and you will see a button "Generate xsd schema from xml file".
JAXB also offers a tool (xjc.exe) to generate JAXB code stubs. There is a simple way to add this functionality to IntelliJ. I prefer to add a button for xsd to java source conversion, using the configuration in the "External Tools" menu.
After this configuration, you can right-click on an xsd file and there will be a button "JAXB (XSD->JAVA)".
Note: According to some websites, there is also a dialog/wizard for generating jaxb stubs. However, I haven't found this wizard yet. Maybe it's only available in more recent IntelliJ versions (14+), maybe only in the commercial edition, or it may require some plugins. My solution works fine in IntelliJ 13.0.3 - Community Edition.

How to import and run existing plugins from intellij community edition repo

I'm trying to import and run the IntelliJ git4idea (Git Integration) plugin in order to play around and contribute some of my own code.
I've pulled the Intellij community edition from the github repo, and imported the git4idea plugin as a project. I'm running the Intellij community edition
My main issue is this:
After importing all the modules, the git4idea module comes up as a general module type, and not a plugin module type.
This means that when trying to create a new run\debug configuration, I get [none] under "Use classpath of module", instead of of the ability to select the git4idea plugin. This obviously results in a "Run configuration error: no plugin module specified for configuration".
So the question is -
How can I change the general type of imported "git4idea" to plugin type?
Or better yet, what are the steps required in order to import and build/debug/run a plugin from the Intellij community edition repo?
I was able to solve this by manually reordering file directories, sorting out dependencies and editing the .iml file. The type of plugin is defined by changing type="JAVA_MODULE" to type="PLUGIN_MODULE".
...
This is the answer given by Dmitry Jemerov on the official Jetbrains plugin development forum:
The easiest answer to this is "don't". The IntelliJ IDEA Community
Edition project is set up to be developed as a whole, and the
dependencies are set up accordingly. If you want to hack on the Git
plugin, you simply run IDEA using the provided run configuration, it
runs with all plugins enabled, and you simply make whatever changes
you need and test them using the main run configuration.
If you really want, you can set up a new plugin module and point it to
the source code of the git4idea plugin inside the IntelliJ IDEA
Community Edition Git checkout. This is not too hard, but it's
something you'll need to do from scratch, and you can't use the
existing .iml file.
I had the same no plugin module specified for configuration issue. To work around it, instead of importing, I created a new plugin project and used the existing code directory.
when you import the intelij plugin projects
You should run the 'runIde' task in gradle.
Step-by-step instruction
Build your IDEA plugin (usually done with gradle build).
Start Intellij IDEA.
If you have any project opened, go to menu "File->Close all projects" to return to Intellij IDEA startup screen.
Install the plugin you've just built: on the left side of the "Welcome to Intellij IDEA" startup screen go to "Plugins", then click "gear" icon on the right side, it's located to the right of "Marketplace" and "Installed". From the pop-up menu select "Install Plugin from Disk...", navigate to plugin file (usually in build folder) and click "Ignore and continue" when you see the warning message saying something about signature.
Restart Intellij IDEA.
Open the folder with your IDEA plugin.
Wait until IDEA imported your Gradle project.
Put breakpoints inside your plugin code so you can debug it.
Go to menu "Run->Edit configurations".
In the "Run/Debug Configurations" window on the left side click "+".
Select "Gradle" from the pop-up menu.
On the right side change "Name" to "gradle-run-ide" (without quotes).
On the right side under "Run", inside "Tasks and arguments" field enter runIde ("i" must be capital, other letters small).
Click "OK" to save changes.
Go to menu "Run->Debug 'gradle-run-ide'".
A new, black-colored IDEA window should appear.
In this black-colored IDEA window do whatever you need to do in order to invoke methods of your plugin. When you invoke them, the first IDEA window should stop you on breakpoints you set previously.
Happy debugging.
After changing type="JAVA_MODULE" to type="PLUGIN_MODULE" in *.iml file I was getting following error -
Error running 'IdeaPlugin': Wrong SDK type for plugin module
To fix this go to -
Module Settings -> Platform settings -> SDKs.
Click on Add new SDK
Select Intellij Platform plugin SDK
For home directory select your Inetllij installation dir
Select JAVA SDK you want to use with it.
Once this is added got to Module Settings again
Module Settings -> Project settings -> project.
In Project SDK change the JAVA sdk to the SDK we just added in the above steps.
Run/Debug you plugin now.

IntelliJ2-IDEA get Maven-2 to download source and documentation

I have a spring mvc project setup using maven in IntelliJ.
While I was setting the project up, IntelliJ asked me if I wanted to download the source and documentation. In order to save time at that point I did not select this option. However now I would like to download some of the source if not all. Does any one know where how to accomplish this in IntelliJ for a project that has already been setup?
The question is specific to how to do this with intelliJ since I would like all the mouse over and documentation features in IntelliJ to show me the source / documentation when needed.
Thanks,
For automatic downloading: Go to File --> Settings --> Maven --> Importing. Then check the automatic download options.
To do so once only, open the Maven tab and click on the download icon and select "Download Sources and Documentation"

Where to find a more comprehensive tutorial on writing plugins for maven-checkstyle-plugin

I am looking for a tutorial on how to extend http://maven.apache.org/plugins/maven-checkstyle-plugin/ (run within hudson), in particular, I am looking for information if I can create -- for my customize checkstyle check -- an additionally html page with details of an error message in the generated project website. I would like to have a page on the error details with a large graph with highlighted incorrect nodes.
Here is a link to the Hudson checkstyle plugin.
There is an tutorial available for plugin development for Hudson.
Last but not least, have a look at a question regarding plugin development for Maven.
take a look at our project, we also extends Checkstyle to use in maven plugin - https://github.com/sevntu-checkstyle/sevntu.checkstyle (see project sevntu-checkstyle-maven-plugin)