This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 227003 - Sensible default Import Layout should be provided out of the box
Summary: Sensible default Import Layout should be provided out of the box
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-04 20:36 UTC by carniz
Modified: 2013-03-15 08:28 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description carniz 2013-03-04 20:36:07 UTC
Finally giving the built-in formatting support for Java imports a try after having relied on the old "Organize Imports" (http://plugins.netbeans.org/plugin/27296/organize-imports) plugin for a long time, I came to the conclusion that one thing that the old plugin did better was to provide out-of-the box support for grouping imports.

For example, if a class has the following (very un-organized) list of imports:

import org.apache.log4j.Logger;
import java.io.BufferedInputStream;
import net.sf.json.JSONException;
import java.sql.SQLException;
import org.apache.commons.lang.exception.ExceptionUtils;
import java.util.ArrayList;
import javax.annotation.security.RolesAllowed;
import net.sourceforge.stripes.validation.*;
import javax.xml.parsers.DocumentBuilder;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import javax.servlet.http.HttpServletResponse;
import net.sourceforge.stripes.action.*;
import net.sourceforge.stripes.util.CryptoUtil;
import java.text.DateFormat;
import net.sourceforge.stripes.util.HtmlUtil;
import org.apache.commons.lang.ObjectUtils;

...then the result of the default (mint install) "Organize Imports" is the following:

import java.io.BufferedInputStream;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import net.sourceforge.stripes.action.*;
import net.sourceforge.stripes.util.CryptoUtil;
import net.sourceforge.stripes.util.HtmlUtil;
import net.sourceforge.stripes.validation.*;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.log4j.Logger;

Not entirely bad, but the main complaint is that it is still a "wall of text" (there is no spacing between the groups), making it more difficult to locate a specific import - even more so as the list grows.

What the old "Organize Imports" plugin did (out of the box) was to add space between the groups, like so:

import java.io.BufferedInputStream;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;

import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;

import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import net.sourceforge.stripes.action.*;
import net.sourceforge.stripes.util.CryptoUtil;
import net.sourceforge.stripes.util.HtmlUtil;
import net.sourceforge.stripes.validation.*;

import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.log4j.Logger;

With the built-in formatter / imports organizer, this can only be achieved after  navigating to

Tools > Options > Editor > Formatting > Language:Java, Category:Imports

and under "Import Layout" adding the packages java, javax, net, org (in this order) followed by "<all other imports>", and checking "Separate Groups".

Most users probably won't find this very intuitive, and/or will end up thinking "what a lousy built-in import statement organizer this NB thing has, who can read such a wall of text"

My suggestion is that NB should come with "Separate Groups" pre-checked, and the following default Import Layout:

java
javax
net
org
<all other imports>