No tabbed view with SWING [message #1107493] |
Thu, 12 September 2013 09:40  |
Eclipse User |
|
|
|
Hi all
Our application shows multiple forms within the main application window. See attachment.
The forms are defined with DISPLAY_HINT_VIEW.
The SWT client shows all forms with tabs so the user can switch between the showed forms.
The same works if the client is shown as RAP client.
Unfortunately this behavior is not reflected by SWING. The SWING client only shows one form, if 'opening' a new form, the former form will be coverd by the new one.
Does anyone have a hint, to get SWING presenting forms with DISPLAY_HINT_VIEW the same way as they are presented with SWT and RAP client?
THX
Daniele
|
|
|
Re: No tabbed view with SWING [message #1112380 is a reply to message #1107493] |
Thu, 19 September 2013 11:39   |
Eclipse User |
|
|
|
Hi Daniele,
To give you a short answer to your question first, the current implementation does not support multiple tabbed views in Swing. However, I think it should be possible to add such an extension.
Background information:
The Scout desktop is divided into a 3x3 matrix, each cell in the matrix is able to display one (or more in SWT / RAP) view(s). The location of a view can be addressed with a view id like North, South, East, West, Center, North-East, etc.
In your SWT project the views are configured by default to allow multiple instances of a view (see plugin.xml -> extensions -> org.eclipse.ui.views).
In Swing however, the concepts are a bit different: The desktop is divided into a 3x3 matrix, too. If you configure your form to be displayed as a view (DISPLAY_HINT_VIEW), the AbstractSwingEnvironment will create a SwingScoutInternalFrame (cf. method AbstractSwingEnvironment.createInternalFrame) that allocates a JInternalFrame as a UI element. The JInternalFrame is then added to the JDesktopPane (see method SwingScoutInternalFrame.openView).
To be able to have multiple tabbed views, I suggest to introduce a new layer, i.e. instead of adding the JInternalFrame directly to the JDesktopPane, you should create a JTabbedPane first and add the JInternalFrame to the JTabbedPane. The JTabbedPane is then attached to the JDesktopPane.
A simple Swing example:
public class SwingTabbedPaneExample {
public static void main( String[] arg ) {
JDesktopPane desktop = new JDesktopPane();
JInternalFrame internalFrame1 = new JInternalFrame( "Internal Frame 1", true, true, true, true );
internalFrame1.setSize(200, 200);
internalFrame1.setVisible(true);
desktop.add(internalFrame1);
JInternalFrame internalFrame2 = new JInternalFrame( "Internal Frame 2", true, true, true, true );
internalFrame2.setSize(200, 200);
internalFrame2.setVisible(true);
desktop.add(internalFrame2);
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add("First Frame", internalFrame1);
tabbedPane.add("Second Frame", internalFrame2);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(tabbedPane);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
This may only be done if another Scout form is already displayed in the same view / matrix cell. So you probably need keeping track of that.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03271 seconds