Improved JDT Filtered PackageExplorer (for Eclipse 4.2.1)

I updated my JDT Filtered Package Explorer. It should now also work with ‘Top Level Elements > Working Sets’ as top level and should also the native “Cancel” button of the platform.

Just for reference to use the native cancel you can implement your text fields with the following flags.


filtertext= new Text(newParent, SWT.SEARCH | SWT.ICON_CANCEL);
		filtertext.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true,
				false));

filtertext.addSelectionListener(new SelectionAdapter() {
	public void widgetDefaultSelected(SelectionEvent e) {
				filtertext.setText("");
				fProjectFilter.setSearchText(filtertext.getText());
				fViewer.refresh();
			}
		});

I basically re-wrote the whole code to use a ViewerFilter, so you may want to de-install the old one before installing the new one.

p2 Update Site:

http://www.vogella.com/updatesite/jdt

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse and tagged . Bookmark the permalink.

9 Responses to Improved JDT Filtered PackageExplorer (for Eclipse 4.2.1)

  1. Anders Hessellund says:

    Nice! Is the source code available somewhere? I’d like to fork this?

  2. Lars Vogel says:

    The project source is available here: https://github.com/vogella/jdt-package-explorer. It is basically the JDT code and a little bit modified.

  3. Eric Rizzo says:

    I had an earlier version installed into 3.8, but the newest version from the update site doesn’t install. I get “”JDT Filtered Package Explorer” is not applicable to the current configuration and will not be installed.”

  4. Eric Rizzo says:

    OK, after uninstalling the earlier version I was able to install 1.0.5. However, I don’t see the native “cancel” button at all in Windows XP (see http://ScrnSht.com/fecndj ). It does show up on Mac OSX, so I wonder if the ICON_CANCEL hint just doesn’t work on XP.
    Also, on OS X the cancel button is present and works, but the cursor does not change when it’s over the button; it still looks like the text entry cursor (vertical bar). It probably should be a pointer or other cursor that indicates “clickability,” but I’m not sure if SWT Text gives you that much control.

  5. Lars Vogel says:

    @Eric: Great that installation works for you. Maybe Windows XP has no cancel. I don’t have a Windows system anymore. If you find a setting which works under Windows, let me know I fix the code then. Currently I use:

    filtertext= new Text(newParent, SWT.SEARCH | SWT.ICON_CANCEL);
    filtertext.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true,
    false));

  6. Tobias Breßler says:

    Very nice! Thanks for that.

  7. Christian Schwarz says:

    I think i found a little Bug. The Filter has sometimes false positives. I can see files that doesn’t contain the filter text, see: Screenshot

  8. Luis Carlos Moreira da Costa says:

    Great friend!

  9. Lars Vogel says:

    Christian: I have problems reproducing that.

Comments are closed.