Bug 141640 - Class fields should use content assist
Summary: Class fields should use content assist
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 3.3 M1   Edit
Assignee: Mike Pawlowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-12 18:15 EDT by Peter Friese CLA
Modified: 2007-01-20 23:27 EST (History)
3 users (show)

See Also:


Attachments
Patch that adds CA to "class" fields (3.12 KB, patch)
2006-05-12 18:19 EDT, Peter Friese CLA
no flags Details | Diff
Patch #1 (31.02 KB, patch)
2006-05-30 18:01 EDT, Mike Pawlowski CLA
no flags Details | Diff
Patch #2 (18.80 KB, patch)
2006-06-06 14:55 EDT, Mike Pawlowski CLA
no flags Details | Diff
Patch #3 (30.16 KB, patch)
2006-06-09 11:02 EDT, Mike Pawlowski CLA
no flags Details | Diff
Icon #1 (574 bytes, image/gif)
2006-06-09 11:03 EDT, Mike Pawlowski CLA
no flags Details
Screenshot showing mandatory and translatable fields (6.42 KB, image/png)
2006-06-11 01:05 EDT, Brock Janiczak CLA
no flags Details
Patch #4 (28.81 KB, patch)
2006-06-12 11:14 EDT, Mike Pawlowski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Friese CLA 2006-05-12 18:15:21 EDT
Many extension points define fields that require the user to specify a class name. Although fields that are named "class" do have a browse button beneath them, people have got used to the fact that content assists is availablealmost anywhere.

I suggest that "class" fields should have content assist support.
Comment 1 Peter Friese CLA 2006-05-12 18:19:15 EDT
Created attachment 41385 [details]
Patch that adds CA to "class" fields

This patch adds CA to class fields. There are two issues I didn't know how to cope with: 
a) Eclipse complains about discouraged accesses to the JDT UI libraries
b) CA can only be invoked if you enter at least one character into the respective field. This very behaviour can be found in the "New Class Wizard" where I copied the CA code from.
Comment 2 Wassim Melhem CLA 2006-05-26 21:49:43 EDT
Thanks Peter, but we would prefer an approach that does not make use of JDT internals.

Mike to implement this feature.  Brian to review Mike's patch.
Comment 3 Mike Pawlowski CLA 2006-05-30 18:01:25 EDT
Created attachment 43032 [details]
Patch #1

This is an interim patch posted for back-up purposes only.

I completedly removed all references to internal JDT classes and redeployed
code as necessary into PDE with the exception of the following:

import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;

These classes are only used to access the class and interface images from
within JDT for proposals.
The necessary images will be copied from JDT into PDE when the functionality
is completely finished

TODO:

* Use new CompletionProposal as a base class

* Investigate alternatives and update references to deprecated content 
  assist APIs
  -> org.eclipse.ui.contentassist.ContentAssistHandler;
  -> org.eclipse.jface.contentassist.SubjectControlContentAssistant;

* Make proposals scope more configurable
  -> current JDT implementation proposes all classes on the classpath and
     no interfaces

* Copy interface and class icon images into PDE from JDT where necessary

* Improve code style and add comments

* Investigate and further trim down unnecessary code deployed from JDT code
Comment 4 Mike Pawlowski CLA 2006-06-06 14:55:11 EDT
Created attachment 43624 [details]
Patch #2

This is an interim patch posted for back-up purposes only.

A thorough investigation of the alternative to the deprecated content assist
APIs has led me to the very new and sufficiently different field assist APIs.  

I decided to try to create a bridge to the old APIs by using the new APIs
with this new patch.

Due to the newness of the field assist APIs, I discovered a variety of 
problems that need correcting before we can move off the deprecated APIs:

* Field Assist Bug:  Empty content proposals (whether IContentProposal[] 
  is null or instantiated and empty) produces an empty proposal drop menu 
  list when content assist is invoked
  -> expected no list to be generated and an audible sound to be emitted 
     indicating no proposals available

* Field Assist Bug:  The content assist field length and alignment is 
  improper on the form because the decorated field that utilizes the text
  field ignores or overrides the GridData specified

* Field Assist Bug:  The content assist field insists on instantiating / 
  creating the text control when it itself is created causing integration of
  content assist fields to be messy and difficult
  -> the previous content assist API only required a reference to the 
     underlying Text control in order to decorate / augment it with content
     assist functionality

* Field Assist Bug:  No way to associate and display images with proposals
  displayed in the proposal drop menu list using field assist APIs
  -> previous content assist API allowed this functionality
    
* Restricting proposal scope to just Interfaces is extremely expensive
  performance-wise using IType.isInterface() method (and IType.isClass() 
  method)
  -> bloats proposal generation time from under 1 second to 9 seconds
  -> assuming invokation of those methods are actually trying to read the
     underlying resources to cause such a degradation

Moving forward, I will finalize the patch for the deprecated APIs and open 
the necessary bugs against the field assist APIs.
Comment 5 Mike Pawlowski CLA 2006-06-09 11:00:17 EDT
Attached Patch #3 ready for review.
Attached Icon #1 needs to be copied into the following location:
/org.eclipse.pde.ui/icons/elcl16/generate_interface.gif

Patch Highlights

* Added content assist functionality to the Activator field within the 
  General Information section of the Overview tab on the plug-in manifest 
  editor

  - Scope:  non-JRE Classes currently on CLASSPATH

* Added content assist functionality to the Class field within the 
  Extension Element Details section of the Extensions tab on the plug-in 
  manifest editor

  - Scope:  non-JRE Classes and Interfaces currently on CLASSPATH

* Fully commented

* Completely eliminated all unnecessary code from JDT

* Fixed search performance problems

  - Utilize JDT SearchEngine facility to compute initial proposals
  - Use SearchEngine's searchAllTypes() method over search() method to 
    improve performance
  - Avoid use of expensive IType.isInterface() method

* Implemented performance optimization

  - Filter initial proposal list based on additional user input rather than
    reperforming full JDT search

* Implemented feature to widen initial proposal list if user inputs 
  backspace

Outstanding bugs affecting the use of field assist APIs

   https://bugs.eclipse.org/bugs/show_bug.cgi?id=145622
   https://bugs.eclipse.org/bugs/show_bug.cgi?id=144522
   https://bugs.eclipse.org/bugs/show_bug.cgi?id=144703
     
TODOs

* Update deprecated content assist APIs to field assist APIs

  - org.eclipse.ui.contentassist.ContentAssistHandler;
  - org.eclipse.jface.contentassist.SubjectControlContentAssistant;
Comment 6 Mike Pawlowski CLA 2006-06-09 11:02:46 EDT
Created attachment 43991 [details]
Patch #3
Comment 7 Mike Pawlowski CLA 2006-06-09 11:03:12 EDT
Created attachment 43992 [details]
Icon #1
Comment 8 Brian Bauman CLA 2006-06-09 15:31:37 EDT
Overall, I like the patch.  There are some minor things we can do to make this code a little more elegant.

- In TypeCompletionSearchRequestor, lets try to use only 1 list to track the results from the last search (instead of fInitialResult and fCurrentResult).  

- Try to use a ListIterator when iterating through a list as in TypeCompletionSearchRequestor.filterCompletionProposals.  (You will run into problems if you use the current method on 1 list since when you remove elements, your size() will change and you will exit the loop prematurely).

- Try to take out the boolean fInitialSearch in TypeCompletionProcessor.  See if we can listen for the "assist complete" event.

- Since the Comparator is a small class, try rolling that up into an anonymous class.

Some little things

- Remember to externalize Strings (everyone forgets on their first couple patches).

- Remove debug/performance information from comments.  You can add them back later if you wish to check performance on your machine.

Go ahead and post a patch with those changes and we should be in good shape.  
Comment 9 Wassim Melhem CLA 2006-06-10 10:28:35 EDT
With the new field assist support, do we even need the Browse... button anymore?  If it goes away, we will gain more real estate for the text field.
Comment 10 Wassim Melhem CLA 2006-06-10 13:38:21 EDT
Mike,
Field assist seems to be available even when the editor is non-editable (i.e. when you open the editor on a blue plug-in from the Plug-ins view).  This should not happen.
Comment 11 Brock Janiczak CLA 2006-06-11 01:02:13 EDT
If this field level content assist were done using the platform DecoratedField or ContentAssistField class it would make implementing the UI portion of Bug 84420 easier (the translatable and error/deprecated indicator would become a decorator).

Also, during 3.2, some of the platform dialogs moved to using a background colour to indicate mandatory fields.  I will attach a screenshot that shows the extensions page with background colour on mandatory fields and a pencil beside translatable fields.  It would be nice for the hover on the pencil to reveal the translated text.
Comment 12 Brock Janiczak CLA 2006-06-11 01:05:16 EDT
Created attachment 44082 [details]
Screenshot showing mandatory and translatable fields

The background appears to eb too much on this screen, but the translatable decorator isn't too obtrusive (if the right hand sides all lined up)
Comment 13 Wassim Melhem CLA 2006-06-11 10:08:22 EDT
The yellow is indeed too much, particularly that form editors are known to use white and system colours.  I am not sure we need a background colour for the text field at all though.  I find that usage of the * to be consistent with required fields in all forms on the web.
Comment 14 Mike Pawlowski CLA 2006-06-12 11:12:35 EDT
See attached Patch #4 and Icon #1

RE:  Comment #8

Thanks Brian for the recommendations.

Did the following:

* Use only one list to track the initial search results
  - use another list to generate filtered search results and then discard it
  
* Use a ListIterator when generating filtered search results

* Use an assist completion event to discard initial search results and to 
  track when to perform a full search versus a filtered search
  - eliminated use of boolean variable
  
* Removed commented debugging code and externalized strings

RE:  Comment #9

I prefer to leave the browse button.  Although I like the content assist
feature I just coded ;), I think most users are accustomed to using the
browse button and expect it to be there.

RE:  Comment #10

Did the following:

* Disable content assist feature on fields if the editor is not editable

Comment 15 Mike Pawlowski CLA 2006-06-12 11:14:47 EDT
Created attachment 44151 [details]
Patch #4
Comment 16 Brian Bauman CLA 2006-06-12 14:12:32 EDT
patch released.  Targeted for 3.3
Comment 17 Wassim Melhem CLA 2006-06-12 15:00:48 EDT
Brian, they just added new target milestones, so I'm retargetting to 3.3 M1 as it is more precise.
Comment 18 Peter Friese CLA 2007-01-20 15:04:17 EST
Thanks for implementing this feature!
Comment 19 Wassim Melhem CLA 2007-01-20 23:27:45 EST
you're welcome, Peter.