Archive

Posts Tagged ‘Eclipse RCP’

Scroll SWT widgets into view when they get focus

Ноябрь 9th, 2010


Read more...

, , , , ,

Font handling in SWT

Ноябрь 9th, 2010

The Eclipse SWT framework is a great framework. It is fast, tidy and free. Unfortunately the documentation seems to lack a bit. Here secrets are unleashed! The code shows two things:

  • How to see all fonts available to your SWT program
  • how to load a font such as a *.ttf font!

When you load your font, you specify the file name of the file (e.g. *.ttf or *.fon or whatever). After loading the font, you must specify the font name. You can use getFontList() for this, and use a specific name or null for a full font list.

Read more...

, , , , , , ,

Equipping SWT applications with content assistants

Октябрь 28th, 2010

Source

Creating an HTML editor

The concept of content assistants is related to a specific implementation of JFace text viewers, the classorg.eclipse.jface.text.source.SourceViewer. Instances of this class are used throughout the Eclipse workbench to implement the various editors. However, SourceViewers are not restricted to the Eclipse workbench but may be used in any application that builds upon the SWT and JFace JARs. This article demonstrates the implementation of content assistants in the context of an Eclipse editor plug-in, and gives some hints on how to use content assistants with "naked" SourceViewers.

Let's implement a simple HTML editor. Here a content assistant can be very helpful. For example, a content assistant could generate typical HTML structures such as tables or links, or could wrap selected text areas into style tags.

Read more...

, , , , , , , ,

Eclipse Databinding + Validation + Decoration

Октябрь 5th, 2010

When it comes to databinding, a very common use case is to decorate form fields with little markers that indicate the state of the control. The following example explains how to do this with Eclipse databinding and JFace. Here is a screenshot:
The code to create an error decoration for a control is pretty straight forward:

, , , ,

How do I open an editor on something that is not a file?

Сентябрь 30th, 2010

Source

Since 3.3 you can use the new EFS support to open an text editor on a file store that's backed by any kind of EFS using IDE.openEditorOnFileStore(IWorkbenchPage, IFileStore).

Most editors will accept as input either an IFileEditorInput or an IStorageEditorInput. The former can be used only for opening files in the workspace, but the latter can be used to open a stream of bytes from anywhere. If you want to open a file on a database object, remote file, or other data source, IStorage is the way to go. The only downside is that this is a read-only input type, so you can use it only for viewing a file, not editing it. To use this approach, implement IStorage so that it returns the bytes for the file you want to display. Here is an IStorage that returns the contents of a string:

Read more...

, , , , ,