Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 10961

Summary: Ability to add a separator/newline in organize imports preferences
Product: [Eclipse Project] JDT Reporter: Randy Hudson <hudsonr>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: erich_gamma
Version: 2.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Randy Hudson CLA 2002-03-07 11:01:15 EST
I would like to be able to add a newline between certain groups of imports.  
For example, between imports from the JDK, imports from pre-reqqed plugins, and 
imports from within the plugin itself.
Comment 1 Erich Gamma CLA 2002-03-08 06:31:02 EST
Martin you have done some investigations on this, was the outcome not for 2.0?
If yes pls defer the bug
Comment 2 Martin Aeschlimann CLA 2002-03-08 08:52:41 EST
Currently an empty line is added after every group. I wanted to show the 
newline explicitly in the prefpage.
Infrastructure is there, and I had the UI, but never released it. In the pref 
page, the order import table then gets twice as many entries (a spacer after 
every block), which makes the table huge and ugly. 

Randy, do you ask for an additional spacer (2 empty lines)?. I could do this, 
that would not blow up the size of the list.
Comment 3 Randy Hudson CLA 2002-03-08 09:09:48 EST
I currently have my groups defined as:
1) java
2) com.ibm.etools.common
3) com

Yet, my import list looks like this:

import com.ibm.etools.common.command.Command;
import com.ibm.etools.draw2d.Label;
import com.ibm.etools.gef.editpolicies.DirectEditPolicy;
import com.ibm.etools.gef.requests.DirectEditRequest;

If what you are saying is true, there is a missing new line after the first 
import.  The algorithm must be finding "com" before "com.ibm.etools.common", 
and thus making the mistake.

The newline by default between groups is probably a good idea.  For users with 
a small number of groups, it makes sense.  If I want really fine control of the 
ordering, I want to insert newlines only between certain groups.  For users 
like me, showing the --Separator-- in the Table would be required.  For users 
with small numbers of groups (such as the default 2), showing the --Separator-- 
would not take up too much space.  That table is big enough to display about 8 
groups with 7 separators between them (at least on my computer), assuming that 
you add separators by default.

Organize imports is really great, but I think I'll only be able to use it when 
it matches imports to the most specific group to which they belong, and I can 
control newlines.  Thanks a lot.
Comment 4 Martin Aeschlimann CLA 2002-03-08 09:21:05 EST
it should look like
import com.ibm.etools.common.command.Command;

import com.ibm.etools.draw2d.Label;
import com.ibm.etools.gef.editpolicies.DirectEditPolicy;
import com.ibm.etools.gef.requests.DirectEditRequest;

There must be a bug in the algorithm. com should be the best match for the last 
3 entries.

Our (ZRH and MIN) default import organize file has 17 entries, so it would blow 
up to 34. What hurts me is that the table look stange as it would be very 
sparsly filled. Only every second line is information.

I will look into it again, as I said I originally also wanted this but could 
not find a nice UI.

Comment 5 Randy Hudson CLA 2002-03-08 10:00:29 EST
I have the answer:
Don't display it as a TableItem.  Instead, make it a property of each TableItem 
group entry.  The property would be rather to insert a newline after the 
group.  You could indicate the properties state using a different Icon or some 
change in the way you display the Text.

Or, you could not display it at all and have a Checkbox at the bottom 
labeled "Insert newline below group".  The checkbox would show you the value of 
the currently selected group, or be disabled.
Comment 6 Martin Aeschlimann CLA 2002-05-10 06:47:53 EDT
fixed the problem in the algoritm (com matches to com.ibm.etools.draw2d.Label 
more than com.ibm.etools.common)

> 20020508

Have to move the separator issue to later.
Comment 7 Eclipse Webmaster CLA 2009-08-30 02:41:40 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.