View unanswered posts | View active topics It is currently Wed Jul 30, 2014 10:00 am



Reply to topic  [ 14 posts ] 
 Using part of MigLayout in an IntelliJ plug-in - license ? 
Author Message

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Using part of MigLayout in an IntelliJ plug-in - license ?
I love MigLayout and we use the heck out of it but since it can only validate constraints at run time and it will only report back one issue at a time we can eat up precious development time compiling, logging in to our server, navigating to new screen, have it tell us what we screwed up and repeating the process. I have a bad habit of forgetting spaces so I get "ins5" instead of "ins 5" or I use "sb btn" instead of "sg btn" because I think "size button" instead of "size group".

To solve this issue I have created a small executable JAR file that allows you to copy in your code that uses MigLayout and verify it showing all the issues before you even run your program. I am using net.miginfocom.layout.ConstraintParser to pull this off so I know I verify constraints exactly as MigLayout will at run time.

The program has a JTextArea with a line number row header, a splitter and a JList with the issues found when you press Verify. You can adjust the font size and use Next and Previous to move through the warnings or double click on one to put you on the line with the error and highlight the term that annoyed it. Works very well for my needs.

I would love to convert this to an IntelliJ plug-in allowing you to highlight your code in its editor, press Ctrl+Alt+M (or whatever key combo I can find not used) and have it verify your issues right in the IDE. Saves the whole copy / paste / verify / fix / copy / paste loop using my current program.

I really don't want to include all of MigLayout just to use a few classes. I have the source code for MigLayout and I am willing to trim down the ConstraintParser to not required much beyond its basics. I really don't need it to build LC etc, I just want to verify the constraints. What I don't want to do is run astray of the license agreement especially since I would love to post this for free out in the IntelliJ plug-in area as I feel a number of people could make good use of it.

I am more than happy to send you the current code if you want to look it over. I am open to suggestions on how best to approach the next step of using this in as small a footprint as possible in an IntelliJ plug-in while staying license legal.

Also others feel free to reply if you think you would find the program useful as it exists today, would love the IntelliJ plug-in or have other suggestions on how something like it could make your life easier.


Tue Nov 30, 2010 12:51 am
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Hello MKevin3,

You have my permission to create the things you mention in the post. You may use the name MiGLayout as part of the plugin name as well. BSD might be a good license for your creations since that's what MiGLayout is shared under.

If you create an IDEA plugin I would be very glad since that's the IDE I'm using almost exclusively.

When you feel there's something for others to try please send the plugin and/or code to me and I'll put it up on the miglayout.com site.

Cheers,
Mikael


Tue Nov 30, 2010 1:01 am
Profile WWW

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Great, I am working on downloading the IntelliJ branch so I have access to the plug-in SDK and I will begin the conversion when that is all in place. I will keep you up to date on my progress and I think a lot of people will find this very useful as they code via MigLayout.

I believe BSD will work out great for this project, I want to share it for as many to use and learn from as possible.

Kevin


Tue Nov 30, 2010 2:17 am
Profile

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Initial version of MigLayout verifier as an IntelliJ plug-in is ready.

Put the Jar from the ZIP in C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 9.0.3\plugins\MigVerifier\lib (where ever you installed IntelliJ)

You will have to create the MigVerifier\lib directory under your version of IntelliJ and place the attached file there.

Restart IntelliJ for it to pick up the plug-in.

Select your MigLayout code block in the editor and do "Verify MigLayout" from the "Code" top level menu (next to last menu item).

A console window will appear with any code issues found.

What does not work:
Hot Key is not working (seems defined and shows in menu, trying to figure it out)
Can't double click on error and have it take you to spot in code (researching this too, lots asking about it on forums)

Things I will do for next cut if possible
Date / Time stamp to output window so you know it ran again or can see when you ran it last
Fix the issues listed above if possible
Fix any issues reported to me while you give this a work out

Give a shot and see what you think. It should be pretty useful even in its current state and beats getting run time errors.


Attachments:
MigVerifier.zip [110.38 KiB]
Downloaded 279 times
Tue Nov 30, 2010 8:06 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Thanks. I will give it a try.
I don't know much about plugin development, but is it at all possible to have it somehow pick up the constraints automatically so that you don't have to press a key? Sort of how the normal Java syntax parser works in IDEA?

Cheers,
Mikael


Wed Dec 01, 2010 12:17 am
Profile WWW

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
I believe I know what you are asking, you want the strings to be checked live while you are typing. I am sure there is a way to do that but I have one big issue. I am already making a whole lot of guesses to determine if you are using MigLayout by doing Regular Expression checking for [.]add( {whatever} " "); since .add is a pretty generic method name I already decided to have you highlight the MigLayout code so I don't get false positives when you are adding to collections etc.

The MigLayout constructor where I check layout, column and row constraints is much easier as pretty much only you use MigLayout for the constructor name.

I would love it if it could pull off what you are asking, I just don't think I can do it unless you tag each line with a // MIG comment or something like that which would partially defeated the purpose of making this easy on the developer and I don't want to clutter your code with tags.


Wed Dec 01, 2010 12:54 am
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
IDEA has an internal AST tree if I remember correctly. I think the types are available in that AST tree, with the whole class name even. That way you should be able to safely find MigLayout classes.

Note that this was just a suggestion and not a request of any kind. I'm sure the plugin is very time saving as it is. :)

Cheers,
Mikael


Wed Dec 01, 2010 12:59 am
Profile WWW
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Hello again,

I have now tried it and it works great!

Let me know when you want it on miglayout.com. Please provide me with the files that should be linked, including any text.

Thanks,
Mikael


Wed Dec 01, 2010 9:57 pm
Profile WWW

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Excellent, I am glad is it working well for you. I want to try and figure out a few more things before we post it for the world to use. I will also send you the full source code so others can learn from it and maybe improve things past where I leave it off.

We are nearing the end of a release at work so I might not get back to this plug-in until next week.

Kevin


Wed Dec 01, 2010 10:12 pm
Profile

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
Here is the new version that supports Alt+Shift+Y as a hot-key to run the plug-in. This works in both the default and Eclipse key mappings.

It shows a date / time stamp in the console window for the run.

You can now click on the hyperlink lines in the console window and pop to the issue at hand. If you make massive changes to the code I am sure this will not be in sync but since you are generally just fixing a string and not adding / removing lines in this phase it should work pretty darn good.

Took a bit of time to figure all of this out. There is not much in the way of a community to help you when working on IntelliJ plug-ins.


Attachments:
MigVerifier.zip [112.06 KiB]
Downloaded 275 times
Tue Dec 07, 2010 5:57 pm
Profile

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
I made some extra tweaks to the plug-in. Now shows the name of the file in the editor you last processed. Also shows just the Error:(line, col) information as a hyperlink giving a better overall look to the console window. I removed all deprecation warnings from the code too.


Attachments:
MigVerifier.zip [112.49 KiB]
Downloaded 261 times
Thu Dec 09, 2010 5:37 pm
Profile

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
I believe the plug-in attached to the previous reply is ready for general consumption. Please post it on your main page using the following text as a guide. Feel free to change the text to suit your needs. I just want the plug-in to be shared with as many folks as possible.

MigLayout Verifier for IntelliJ plug-in

Now you can verify all your MigLayout row, column, component and layout constraints in the IntelliJ IDE without even running your program. Never see an exception again from a mistyped constraint string at run time. Find all issues in your layout instead of one at a time.

Download the plug-in jar file and create two new directories under you IntelliJ installation.

Example installation directory:

C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 9.0.3\plugins\

Add the directories MigVerifier\lib so you have the following path:

C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 9.0.3\plugins\MigVerifier\lib

Copy the MigVerifier.JAR into the newly created lib directory.

Restart IntelliJ if it is already running or start it now. The plug-in will be picked up automatically. You can tell it is running by looking under the main Code menu, the last item should be "Verify MigLayout Alt+Shift+Y"

Simple select the text in you Java code that uses MigLayout and press Alt+Shift+Y or select the menu item to verify it. You will see the MigLayout Verification Console with any issues it found in the code. If issues have been found you can click on the Error:({row},{col})) hyperlinks to jump right to the code with the issue.
The plug-in uses the MigLayout parsing engine so you get the exact same errors you would get at run time but without the hassle of building your code, running it and navigating to the panel using the new code. Now you will know your constraints are accurate before you have ever run the code saving valuable time.


Fri Dec 10, 2010 5:34 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
I update the web site. I didn't put the text directly at the site though but in a forum post here: viewtopic.php?f=8&t=3417

That way there's a place for bug reports and other questions as well. You might want to monitor it.

Hope that was OK.

Do you want your name mentioned in that post? "MKevin3" feels kind of anonymous so I didn't mention it...

Cheers,
Mikael


Tue Dec 14, 2010 11:29 pm
Profile WWW

Joined: Tue Nov 30, 2010 12:27 am
Posts: 10
Post Re: Using part of MigLayout in an IntelliJ plug-in - license
You can use my full name, I did when I posted this on the IntelliJ plug-in site. Thanks for creating a post for it and I will monitor feedback there and on the IntelliJ site. I have been using the plug-in and it sure makes my MigLayout life easier.


Tue Dec 14, 2010 11:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.