Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Nebula Tiles

< Back to Nebula Main Page

Introduction

Tiles is a widget for the Standard Widget Toolkit (SWT) that displays elements as a set of tiles. Elements can be filtered, sorted and decorated. When decorators, the filter or the sort order are changed, the widget shows a smooth transition between the previous and the current state.

Overview

Assume you want to display an overview of a set of items to the user. Additionally, the user should be able to sort or filter items and some properties should be presented to the user in an intuitive manner. This can be implemented with SWT Tiles. The following screen cast shows an example in which the numbers 0 - 120 are displayed. The order of items is indicated by applying a gradient to their background color. Even numbers have a thick blue line while prime numbers have a black dotted line around them. The view either shows the numbers 0 to 80 or the numbers 40 to 120 from the overall range. The filter is changed when the user selects the item 80:

Example.gif

Feature

  • Generic component: Tiles<T> can display any element of type T.
  • Decorators: Subclasses of Decorator<T> for background colors (supports gradients), line colors, border widths, border styles and labels.
  • Filters: Filter<T> can be used to select arbitrary subsets to display with the widget.
  • Order: Comparator<T> can be used to impose an arbitrary order on the items displayed.

Examples

This basic example displays the first 80 elements from the set of numbers in range 0 to 499 in their natural order:

// Create tiles
Tiles<Integer> tiles = new Tiles<Integer>(shell, SWT.NONE);

// Add items
List<Integer> items = new ArrayList<Integer>();
for (int i=0; i < 500; i++){ 
    items.add(i);
}
tiles.setItems(items);
		
// Set layout
tiles.setTileLayout(new TileLayoutDynamic(10, 10, 5, 5));

// Set filter
tiles.setFilter(new Filter<Integer>(){
    public boolean accepts(Integer t) {return t < 80; }
});
 
// Set comparator
tiles.setComparator(new Comparator<Integer>(){
    public int compare(Integer t1, Integer t2) { return t1.compareTo(t2); }
});

Other examples are located in the plugin org.eclipse.nebula.widgets.title.snippets.

These examples are also available here : Examples

SWT Tiles in action

Too see SWT Tiles in action, take a look at ARX.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.