Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to create a popup window
How to create a popup window [message #832139] Thu, 29 March 2012 20:36
Mariusz Cwikla is currently offline Mariusz CwiklaFriend
Messages: 15
Registered: January 2012
Junior Member
Hello guys,
how can I create a popup window? Currently I'm doing something like this:

public abstract class PopupWindow {
	
	public void open()
	{
		final Shell shell = new Shell(SWT.NONE);
		shell.setLayout(new FillLayout(SWT.VERTICAL));
		createContent(shell);
		shell.addShellListener(new ShellAdapter(){

			@Override
			public void shellDeactivated(ShellEvent e) {
				shell.close();
			}
			
		});
		shell.open();
	}

	protected abstract void createContent(Shell shell);			
}

Is this correct way?

And another question: I want to open few popup windows in different places on the screen. When user clicks anywhere on the screen beside those popup windows then all popup windows should disappear. I thought about iterating over all shells from Display.getCurrent().getShells() other than my shells and if any of those is activated, then close my shells, like this (treat it as pseudo-code, I haven't tested it yet, I'm just wondering):

final Shell[] myShells = new Shell[5];
//open all the shells

for(final Shell shell: Display.getCurrent().getShells())
{
	boolean notMine = true;
	for(Shell myshell: myShells)
		if(shell==myshell){
			notMine = false;
		}
	if(notMine){
		ShellAdapter adapter = new ShellAdapter(){

			@Override
			public void shellActivated(ShellEvent e) {
				for(Shell myshell: myShells)
				{
					myshell.close();
					shell.removeShellListener(this);
				}
			}
			
		};
	}				
}
Previous Topic:How to redirect the complete browser url to a different page
Next Topic:e4 Application and RAP
Goto Forum:
  


Current Time: Sat Jul 27 15:03:41 GMT 2024

Powered by FUDForum. Page generated in 0.02575 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top