Some topics to discussion

Answered

Hello,

I use NetBeans and decided to try IntelliJ IDEA community edition.
Below are some notes that I found. I decided to write them all because sometimes they are small and some times may be I just did not find the right way how to do it.

1. Run project.
NetBeans always has Run Project button enabled. When I press it and the main class is not selected it brings the dialog with a list of suggested classes to run.
IDEA has the Run Project button initially disabled. It is necessary to press  Run Menu -> Run... menu items to select the main class. So it takes one more action.
This is not a big dial because there is the shortcut Alt+Shift+F10 and it is always possible to press the Run ClassName.main() triangle on the editor.

2. Refactor Rename.
When I use the Refactor->Rename of a class field IDEA also suggests to rename constructors parameters. This is really useful. This one is missed in NetBeans.

Just a small note. The  Rename Constructor Parameters dialog contains the Select all/Unselect all buttons. But my first action was to found a tick under the suggested check boxes to select/unselect all. May be it would be useful to have one more check box on top of the given which allows to select/deselect all items or be in undefined state if a user selected only some choices.

3. Debugger.
It is impressive that the debugger shows known the fields/variables values on the right side. NetBeans misses this feature.

There is a difference between showing the breakpoints window in NetBeans and IDEA. It is just a dialog in IDEA. Selecting a breakpoint shows the code with breakpoint in the text dialog. To go from a break point to a code I need to use the following actions: Call the Breakpoints dialog, select double click the breakpoint, dismiss the dialog. The NetBeans just shows the breakpoint view as ordinary tab on the bottom of the IDE. It needs only to select the tab and double click the breakpoint and the editor just shows the code.

There is a known enhancement on it IDEA-118510. I have voted for this.

4. Create new class.

To create a new interface in IDEA I need to choose New->Java Class which brings Create New Class dialog where it is necessary to select the interface item in Kind combobox. Selecting an item in combox requires two actions: pressing on the combox and selecting an item.
It would be faster if for small number of kind items they were shown as radio buttons.
Or, may be, the used Java class kind can be added directly after the class item in the menu. For example, creating an Enum first time, now it is possible to select a folder and call New->Java Class->Enum in the popup menu.

5. Fields validation.

On Create New Class dialog if I type incorrect name like My-Class I need to press the OK button to find the message that the name is not valid.
Or create a plugin, call New -> Action and type a class name with a space at the end in the New Action dialog. The OK button is disabled in this case but there is no a message that describes where is the mistake.
It would be good to have the unified way for dialogs validation which shows a warning message when a wrong name is typed.


6. To clear the output I can call Clear All from the popup menu. Is there a shortcut for it? NetBeans uses Ctrl+L to clear the ouput log.

7. Project with existing sources.
Some times I want to create a project and attach just a particular folder with sources. For example there could be a lot of tests and I need to  edit only one test which is placed in its own folder.
In NetBeans I just create new Java Project with Existing sources which suggests me to add folders with sources in the project creation dialog.
In IDEA there is Project from Existing Sources which means something different. It converts existing project from other tools.
For now I just need to create a Java Project, include to the module the necessary directory and exclude the default generated src directory.
Is there an easy way to do it?

I also found that in this case (only one source folder which is not root of a repository is added to the project) the version control changes (in my case it is mercurial) are not shown in the editor. NetBeans shows them in this case.
I checked that the version control changes are shown in IDEA if I add as a new directory the whole project there the added directory is the root of the mercurial repository.

8.Select methods in a class to implement. The methods are generated with default return values. Just a question. Is providing default return values are better than throwing the UnsupportedOperationException in this case?

9. Code completion.
The code completion suggests methods to generate but I if type the class name it does not suggest to generate a constructor (with possible parameters). May be it would be useful to have.


10. One feature which NetBeans has is that the code completion inserts the selected method with arguments. Now it is possible to iterate over method arguments by tab (similar to arguments traversal in live templates). NetBeans can also try to guess which variable can be used as a method argument. In some cases where are obvious choice because the method argument and a variable just have the same name and type. In other case the choice is wrong but you just start to type right expression.

Is there something similar in IDEA?

0
6 comments

1. Once you have a configuration selected, Run button is always available.

4. It's possible to create your own templates: http://stackoverflow.com/a/3386565/104891.

6. You can assign one, there is no default: http://i.imgur.com/ssqdb2l.png.

7. There is an option to import from other build tools, but it can also detect sources and libraries in a tree even if no build tools are used. VCS roots need to be configured correctly in IDE settings.

8. https://youtrack.jetbrains.com/issue/IDEABKL-7054

9. There is intention action to create the constructor from usage: http://i.imgur.com/Acx0HbZ.png.

10. See the following requests:

https://youtrack.jetbrains.com/issue/IDEABKL-6690
https://youtrack.jetbrains.com/issue/IDEABKL-5496

There is an experimental feature you can enable by adding java.completion.argument.live.template=true into Help | Edit Custom Properties.

0
Avatar
Permanently deleted user

> 6. You can assign one, there is no default: http://i.imgur.com/ssqdb2l.png.

Yes, it works.

> 7. There is an option to import from other build tools, but it can also detect sources and libraries in a tree even if no build tools are used.

Yes, this was the question. How to create a Java project (may be from sources) and attach a folder with java sources to it in an easy way?
 
>  VCS roots need to be configured correctly in IDE settings.
Thanks. I found it in the Version Control settings.

> 9. There is intention action to create the constructor from usage: http://i.imgur.com/Acx0HbZ.png.

I meant something different here.
Suppose there is a class:
{code}
public class SampleClass {

    final String name;
    final int age;

    Sampl // call Code Completion
    
}
{code}

Type the constructor name and press Ctrl+Space. The constructors for generation are not suggested.
 
Here is how it looks in NetBeans: http://imgur.com/a/ii5Eo

> 10. See the following requests:

This is awesome. I will try it.

0

> How to create a Java project (may be from sources) and attach a folder with java sources to it in an easy way?

Create a new Java project, point to the existing directory when specifying module roots.

> I meant something different here.

Alt+Insert (Generate), Constructor is much easier and provides more options.

0
Avatar
Permanently deleted user

> Create a new Java project, point to the existing directory when specifying module roots.

When I create a new project the default first module is always created. Is it possible to avoid its creation because I do not need it?
When I add a module and specify the content root it creates the src directory in the provided folder which I also do not need.

> Alt+Insert (Generate), Constructor is much easier and provides more options.

Alt+Insert (Generate) requires the following actions: Press Alt+Insert->Select Constructor->Select Arguments-> Press OK
Selecting a suggested generated constructor in the Code Completions is just faster.

0

You can create an Empty Project, then add Java module and manually specify all the paths (content and source roots).

0

As for the constructor, the dialog is much more flexible, imagine a class with 10 fields, you want to generate a constructor with 2nd, 5th and 10th fields. How would you do it it NetBeans?

For basic cases like all arguments and no arguments it pretty fast (Alt+Insert, Enter, Alt+N => No arguments or Alt+Insert, Enter, Ctrl+A, Enter => All arguments).

We don't want to pollute code completion popup with all the possible combinations that are hard to distinguish.

0

Please sign in to leave a comment.