3

I would like the Package Explorer view, if possible, just to show the order in which things are defined in the source file.

I know that, in the Java-->Appearance-->Member Sort Order preferences, you can set what order categories of definitions appear (fields, methods, inner classes, etc.), but not the order within these categories. (Well, you can order by visibility within these but nothing else.) It appears to only do alphabetical order within this categorisation.

The Quick Outline view (Ctrl-O) does this as-in-the-source ordering, and I could also collapse all code blocks to get a similar outline in the editor, but I prefer using the Package Explorer for navigation.

For example, for a class implementing multiple interfaces, I group the methods by interface, and keep the method order as defined in the interface. Plus I separate off private utility methods, etc. As I'm sure most people do, I'd also default to ordering by visibility when there aren't any well-defined 'logical areas' of the class, and would tend to have 'sub-methods' below their callers.

(It would be even better if it were possible to drag and drop definitions to reorder them in the file, although the collapsed editor view is pretty good for this.)

What, if anything, would get me closer to this view? (Or, if you like, are there any reasons why this desire is stupid?)

Community
  • 1
  • 1
Stuart Rossiter
  • 2,432
  • 1
  • 17
  • 20
  • 2
    Regarding your 'most people do' comment I am not with you. I give up sorting things in my Java file "logically". If you work in teams it is hard to keep this order. Instead I sort my class members "alphabetically" - this is supported by the IDE and reproducible for everybody. I also break the habit of scrolling around and searching for something. Instead I use `Strg-o` to quick navigate to my searched member. This is much more efficient for me. Nevertheless I can understand your approach - goog luck in finding an answer to your question. – FrVaBe Jan 26 '12 at 12:10
  • @K.Claszen Fair enough view (esp. for large distributed teams). However, for interface implementation and overridden superclass methods, it just seems crazily illogical for me not to group the methods related to these other classes/interfaces. In this context, alphabetical feels a bit too much like pandering to (potentially temporary) weaknesses of the tool (like this question!) or to weak/sloppy team members. However, having been a veteran of several painful coding standards debates in companies, I have some sympathy for your view :-) – Stuart Rossiter Jan 27 '12 at 10:08

1 Answers1

4

It does seem like a strange omission to not be able to disable the alphabetic sorting. A little investigation turns up some bug reports that are marked as WONT-FIX (basically because the people who proposed them didn't follow up):

As a work-around, you can consider using the Members view, which does allow you to toggle alphabetic sorting. I actually use it all the time because it's part of the Java Browsing perspective, which I much prefer over the Java perspective. Even if you don't want to use Java Browsing, you can open the Members view in your perspective of choice. For example, open it and drag it to place below your Package Explorer view.

E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • Ah, nice workaround. For anyone else trying this, the Members view is within the Window-->Show View-->Other..-->Java Browsing if you're not in the Java Browsing perspective. Drag below a left-hand pane view by dragging until you get the black down arrow. Will accept this in a bit if nothing else comes in. – Stuart Rossiter Jan 27 '12 at 10:00
  • Acceptance is given (since appears to be no way to actually get Package Explorer to do it directly). Let your appreciation commence :-) – Stuart Rossiter Jan 30 '12 at 10:47
  • Requested a reopen for Eclipse bug 51611 (see my comment therein), so let's see if anything happens... – Stuart Rossiter Jan 30 '12 at 11:02