Skip to main content
Jump to: navigation, search

Difference between revisions of "Scout/HowTo/3.7/Open a Form in a View"

< Scout‎ | HowTo‎ | 3.7
m (using source tag)
m (Download)
Line 51: Line 51:
=== Download ===  
=== Download ===  
[[|Demo Project]]
[[|Demo Project]]

Revision as of 06:26, 20 September 2011

Wiki Home

When starting a newly created form you will notice that the form is opened in a new window. You may have also noticed that some forms like the "Outline Tree Form" don't open in a new window, instead they are shown inline in the main application window. Those inline forms are referred to as views. In this howto you will learn how to create such views and how to arrange them in the application window.

Changing the display style

In fact it is very easy to open a form in a view instead of a dialog. You only need to change the display style from dialog to view and define the viewId which should be used.

protected int getConfiguredDisplayHint() {
protected String getConfiguredDisplayViewId() {
  return VIEW_ID_CENTER;

This is how it is done for the outline forms like DefaultOutlineTreeForm or the DesktopForm.

Arranging the views

To specify where the view should be placed inside the application window the displayViewId needs to be set. There are several orientations available like North, South, East etc. Try to set one of those values and see what happens.
If you start the swt client and the form is not there although you started it correctly the viewId probably is not mapped. Have a look at the client log to verify that.

!MESSAGE org.eclipse.scout.rt.ui.swt.AbstractSwtEnvironment.showStandaloneForm(null:-1) no view defined for scoutViewId: E

Linking the eclipse views with the scout forms (SWT)

In order to make a form which should be opened in a view visible in the swt client you need to define a mapping between the displayViewId and the actual eclipse view. You will find that mapping in the SwtEnvironment. When creating a new scout application there are four default mappings defined:

registerPart(IForm.VIEW_ID_CENTER, Activator.CENTER_VIEW_ID);
registerPart(IForm.VIEW_ID_OUTLINE, Activator.OUTLINE_VIEW_ID);
registerPart(IForm.VIEW_ID_PAGE_TABLE, Activator.TABLE_PAGE_VIEW_ID);
registerPart(IForm.VIEW_ID_PAGE_SEARCH, Activator.SEAECH_VIEW_ID);

So only these four displayViewIds will work out of the box. To map another id simply add a new line with the desired id and map it to an eclipse view id. The eclipse view id itself needs to be specified in the plugin.xml by using the extension point org.eclipse.ui.views.
Doing this will show up the view but likely in the wrong position.

Arranging the eclipse view (SWT)

It is not sufficient to only create an eclipse view. It is also necessary to specify where the view should be placed. You can either do this programmatically in the class or declarative with the extension point org.eclipse.ui.perspectiveExtensions. In my opinion the declarative way is much easier so I suggest to use that. Since this is pure eclipse rcp and has nothing to do with scout I won't explain that in this howto. If you are not familiar with these things have a look at the demo project, it should help you. Please notice that in the demo project the declarative way is used and therefor the generated code in the has been removed.

Demo Project

The demo project consists of three views: The main desktop view, a bottom and a right view.

Example View Layout (SWT)


Demo Project

Back to the top