Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Posts Tagged ‘eclipse ui’

on Jun 23rd, 2010Tip: How to detect that a View was Detached

Here is a question that I got on a post about detached views:

“How can I detect that a View has been detached from the main window? I would like to adjust the view’s behavior in that case.”

There is no API to obtain that information directly. However it is possible to do this with a few tricks:

  1. detached views have an empty window title (i.e. shell.getText().length() == 0)
  2. when a view is detached resize events are fired

Armed with that knowledge we can detect that a view is detached / reattached. The snippet below shows how (tested on windows).

PS: Our eclipse support helps developers use their time efficiently by providing prompt answers to questions like this one.

detached view Tip: How to detect that a View was Detached

on Apr 26th, 2010Sketch your UI

From time to time, I’m in the situation when I want to suggest a UI change or even try to come up with a completely new UI. While I love programming, it may be easier in these situations to just “sketch” the idea instead of really getting your feet wet. As many people asked me what I use for UI sketches, I thought I should share it with you – the tool is called WireframeSketcher. It’s “just” an Eclipse plugin to create sketches pretty easily. As most of the UIs in my life are SWT-based, WireframeSketcher comes with one absolutely cool feature – turn an existing dialog into a sketch. Fire up any dialog, hit the magic “Alt+Shift+F5″ and you’re done. Is it that easy? Yes – I really love it. Here is an example of the Import Wizard which I also used in my latest blog post to further modify it with my ideas.

import Sketch your UI

Not only is it easy to operate, it also has pretty good Eclipse integration and you always find the things where you expect them (eg. select and button and you can modify everything in the Properties View).

button props Sketch your UI

As Eclipse commiter, you can get a free licence of the plugin or you can buy the plugin from the author if you want to use it commercially. Either way, give it a try the next time you want to mock a new UI prototype.

on Mar 4th, 2010Error marker for SWT table rows – easy as pie

Here’s a nice addition to Riena’s TableRidget: you can now mark a table-row as incorrect.

This is done with an RowErrorMessageMarker. When hovering over the marked row, the corresponding error message will be shown in a tooltip.

IMarker marker = new RowErrorMessageMarker("An error message...", zorro);
tableRidget.addMarker(marker);
// to remove:
tableRidget.removeMarker(marker);

Full snippet here. This is shipping with the upcoming Riena 2.0 M6.

row marker 1 Error marker for SWT table rows   easy as pie

row marker 2 Error marker for SWT table rows   easy as pie

on Oct 26th, 2009Riena at the Eclipse Summit Europe

If you are at the Eclipse Summit Europe this week, here are some interesting talks about the work going on in and around Eclipse Riena:

riena 120m2 Riena at the Eclipse Summit Europe

* Eclipse RunTime Tutorial, Tue 9:00-12:00, Seminarräume 2-4 – This tutorial connects the dots between different runtime technologies, such as Equinox, Riena, RAP and EclipseLink

* Eclipse Riena Project – Overview and a new UI concept for RCP applications, Wed 11:20-12:00, Seminarräume 2-4 – This overview of Riena focuses on the framework’s UI concepts. Learn how to use navigation, styling and filtering to build better RCP applications.

* SWT Platform on QT – Overview and Demo, Thu 16:00-16:20, Seminarräume 2-4 – I’m very curious about this session. The screenshots I have seen looked very exciting. And the promise of taking advantage of QT’s extensive customization capabilities and build-in CSS support is appealing. Personally I’ve found SWT to be quite restrictive when it comes to styling and theming, so I am interested in all approaches that expand what you can do.

Kind regards,
Elias.

PS: I’m not attending this year, but several of my Riena colleagues will be there.

on Oct 14th, 2009Eclipse Riena 1.2.0.M2 released

The Riena committers have just done it again: Riena 1.2.0.M2 is now out the door (download). Here’s the New & Noteworthy and the issues fixed in this milestone. Read on for my personal favorites:

  • New ridgets: ILinkRidget, IBrowserRidget, ITraverseRidget (for SWT’s Slider, Scale and Spinner widgets). Thanks to Florian from Redview for these contributions (snippets)riena new ridgets Eclipse Riena 1.2.0.M2 released
  • IComboRidget now supports  CCombo: the CCombo widget works much better with our marker framework, since it supports different background colors (the regular combo does not!). Markers use background colors to point out required or incorrect data. Check out the new CCombo demo in the playground.
    riena ccombo Eclipse Riena 1.2.0.M2 released
  • MasterDetails improvements: (a) the MasterDetails widget now has an ‘auto apply’ mode, meaning that any changes done in the details area in the bottom will instantly be applied back to the original model in the table (snippet)
    riena master details auto apply Eclipse Riena 1.2.0.M2 released(b) if you’ve edited the details and navigate away or hit the ‘New’ button, you’ll be warned that you’re about to discard your changes. If you find it annoying, you can also turn it off.riena master details confirm Eclipse Riena 1.2.0.M2 released
  • Automatically synchronize enablement state of a label and another widget: Riena now has a mechanism that keeps the enabled-state of a label and another widget in lock-step. Example: you have a Label with the id “labelName” and a Text widget with the id “name”. If the text field is disabled, the label will be disabled too. The default strategy looks for the “label” prefix to associate two widgets with each other (i.e. labelXYZ <-> XYZ). However you can use the labelfinderstrategy extension point to provide a different strategy, if desired.
  • riena labelfinderstrategy Eclipse Riena 1.2.0.M2 released

Kind regards,
Elias.

on Aug 24th, 2009Eclipse Riena 1.2.0.M1 released

The Fellowship of Riena just released 1.2.0.M1. (download). We committers have fixed 40+ issues and added a couple of new features. Below are my personal favorites.

Improved support for message markers. Multiple validation rules and validation messages are now shown correctly (snippet):

riena message viewer Eclipse Riena 1.2.0.M1 released

The new IListRidget simplifies binding to  lists of elements with one column. This is a bit simpler than using a ITableRidget (snippet).

Easier listening for selection changes using an ISelectionListener on ITableRidget, IListRidget, ITreeRidget, ITreeTableRidget, ISingleChoiceRidget, IMultipleChoiceRidget.

Better keyboard navigation. We have added several new shortcuts. Some examples:

  • Next / Previous navigation element – Up / Down in the navigation tree
  • Next / Previous Module – Ctrl-Down / Ctrl-Up
  • Next / Previous SubApplication – Ctrl-PgDn / Ctrl-PgUp
  • Close Module / ModuleGroup – Ctrl-W / Ctrl-Shift-W
  • Focus on Navigation / Workarea – F6 / F7
  • Focus on Window Menu – F10 (windows only)
  • Quit Application – Alt+F4 (windows only)

and  SubApplication titles now support mnemonics for easier access via the keyboard:

riena mnemonics subapps Eclipse Riena 1.2.0.M1 released

Here’s the complete New & Noteworthy.

Kind regards,
Elias.

PS: SubApplication, Module, ModuleGroup are explained here.

on Aug 22nd, 2009Introduction to Eclipse Riena UI and Navigation

Starting out with Eclipse Riena?  I hope you find my one-picture-summary of the Riena UI and navigation useful:

riena ui 300x250 Introduction to Eclipse Riena UI and Navigation

Conceptually the window is divided into the navigation tree on the left - showing a navigation model – and the work area on the right - showing the view that is currently active. Other window areas are the menu bar, the coolbar and the status bar.

The navigation tree shows the navigation model of the current SubApplication and can change during run-time (for example elements can be added / removed). Conceptually it is a tree constructed like this:

1 Riena Application  - root of the navigation tree; non-interactive
> 1-n SubApplications – each sub application has a clickable tab in the top part of the window
>> 1-n ModuleGroups – groups several modules together; non-interactive
>>> 1-n Modules – has a title (blue background) and 1-n SubModules
>>>> 1-n SubModules – is associated with a View and Controller. When a SubModule becomes selected the corresponding View is shown in the work area. SubModules can be nested. If module has just one SubModule it is not shown.

As you can see, Riena steps away a bit from perspectives, views, editors in favor of a task oriented interaction (side note: underneath this we use views and perspectives, and we support integration of regular views). For example you could have a SubApplication called “Customers”, with a Search Module and additional Modules for each of the customers you are currently editing:

riena demo 300x225 Introduction to Eclipse Riena UI and Navigation

For the full details read the excellent ‘Riena Navigation‘ page on the Riena wiki. The wiki explains this in more detail and shows how to create the navigation structure through Java code or the plugin.xml file.

on Jul 8th, 2009Tracing Keybindings in Eclipse RCP

When adding keybindings to an existing Eclipse RCP application, it is extremelly helpful to get realtime information about which keybinding registered and to what command handlers it is mapped to. Why is that?  Because sometimes the operating system or another widget will consume the keyboard event before it gets to the command framework. Other times there are several handlers bound to the same key causing a conflict.

Enabling Tracing for Keybindigs

Fortunatelly, this information is easy to get, if you enable the right tracing options:

org.eclipse.ui/debug = true
org.eclipse.ui/trace/keyBindings = true
org.eclipse.ui/trace/keyBindings.verbose = true

trace keybindings Tracing Keybindings in Eclipse RCP

After that each keystroke will produce some output on the console:

KEYS --- WorkbenchKeyboard.press(potentialKeyStrokes = [CTRL+PAGE_UP, CTRL+])
KEYS --- WorkbenchKeyboard.executeCommand(commandId = 'org.eclipse.riena.navigation.ui.previousSubApplication', parameters = {})

In the above you can see that Ctrl+PageUp is mapped to the ‘previousSubApplication’ command.

Some times there is a conflict – i.e. one keybinding is mapped to two or more ‘active’ command handlers. This looks like this:

BINDINGS --- A conflict occurred for CTRL+SHIFT+W
BINDINGS ---     [Binding(CTRL+SHIFT+W,
	ParameterizedCommand(Command(org.eclipse.ui.file.closeAll,Close All,
		Close all editors,
		Category(org.eclipse.ui.category.file,File,null,true),
		org.eclipse.ui.internal.CloseAllHandler,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.ui.contexts.window,,,system), Binding(CTRL+SHIFT+W,
	ParameterizedCommand(Command(org.eclipse.riena.navigation.ui.closeModuleGroup,Close module group,
		,
		Category(org.eclipse.riena.navigation.ui.swt,Riena Navigation Commands,null,true),
		org.eclipse.riena.internal.navigation.ui.swt.handlers.CloseModuleGroup@39880a,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.ui.contexts.window,,,system)]

What happened here is that Ctrl+Shift+W was already bound to the CloseAllHandler via the ‘file.closeAll’ command. I was not aware of this initially, because it is defined in the org.eclipse.ui plugin. So I accidentally bound another command and handler to Ctrl+Shift+W. With the output I quickly realized what was going on. I ditched my own command and instead made ‘CloseModuleGroup’ a handler for the ‘file.closeAll’ command.

on Jun 1st, 2009Java One – Good looking apps with RAP

If you are at JavaOne, drop by the Eclipse Foundation (Mo 5-7pm, Tu 11:30-1-30) or EclipseSource booths (all week) for a demo of the Rich Ajax Platform (RAP).

In my demos, I’ll focus on the CSS customizations and enhanced theming capabilities that ship with the new with RAP 1.2 release (Galileo).

Here’s a screenshot showing a ‘RAP Addressbook’ application:

rap addressbook dark Java One   Good looking apps with RAP

It is inspired by Kai’s recent work on the E4 Contacts Demo, but based entirely on my own codebase. I wanted to use a slightly richer data-model and UI, as I want this to become a replacement for the dated ‘Palm Desktop’ application I’m using. What you see is my progress after one day of work. It’s still very alpha, but you can get the code on github.

The second screenshot shows the same app using the new ‘business’ example theme:

rap addressbook business Java One   Good looking apps with RAP

With RAP 1.2, we have added the ability to customize the header, footer and part-stacks of the application. This is build on top of the Platform’s Presentation API but with our own extension points that should simplify things. You can find this under ‘org.eclipse.rap.design.example’ in the RAP CVS. Look forward for a blog post decicated to this topic later this week.

See you at Java One!

on May 8th, 2009UI.toString() in a snippet

Ever wanted to get a print out of all components that make up a piece of UI?

This little recursive snippet does that for you.

private void printChildren(Composite composite, int count) {
  StringBuilder spaces = new StringBuilder(count * 2);
  for (int i = 0; i < count * 2; i++) {
    spaces.append(' ');
  }
  for (Control c : composite.getChildren()) {
    System.out.println(String.format("%s%s (%s)", spaces.toString(), c.toString(), c.getLayoutData()));
    if (c instanceof Composite) {
      printChildren((Composite) c, count + 1);
    }
  }
}

Here’s an example of the output:

ui to string UI.toString() in a snippet

Composite {} (null)
  Composite {} (null)
    Composite {} (null)
      Composite {} (GridData {horizontalAlignment=Undefined 256 grabExcessHorizontalSpace=true verticalAlignment=GridData.CENTER})
        Label {Subject:} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
        Label {This is a message about the cool Eclipse RCP!} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
        Label {From:} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
        Link {<a>nicole@mail.org</a>} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
        Label {Date:} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
        Label {10:34 am} (GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER})
      Text {} (GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.FILL grabExcessVerticalSpace=true})
© EclipseSource 2008 - 2011