[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: General UI: Preventing shell/dialog from opening if already open
|
- From: Karan M G <k.kexor@xxxxxxxxx>
- Date: Tue, 14 Nov 2006 15:18:13 -0800
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Thunderbird 1.5.0.7 (Windows/20060909)
Thanks.
This is what I'm doing now and it works perfectly with minimum code added:
private static MyShell instance;
public MyShell()
{
if (instance == null)
{
instance = this;
..
.. whatever was in constructor originally..
..
}
else
instance.shell.setFocus();
}
Rich Kulp wrote:
You could simply have an instance variable for each dialog that can be
open only once at a time and have a different method for each dialog that
(a) checks if the instance variable is not-null and open, then just give
it focus
(b) if not then create the dialog, assign to the instance variable, and
open it.
That way you don't need a list that you would search through to see if
open because you already have to have special code to launch each one,
so just use the instance variable and find it directly.
Karan M G wrote:
Hello,
I am making my first SWT application which has a menu on the shell and
several dialogs and other shells which can all be opened by clicking
buttons, menu items, tree items etc. When a menu item is clicked it
opens up a dialog box. Now if I click the menu item again, another
instance of the same dialog will open up which is redundant and
possibly erroneous. Some of these dialogs are not necessarily
application modal (eg. About box, Welcome screen, Help etc.).
One way I can think of preventing a window from opening if already
open is keeping a list of opened shell/dialog in the primary UI class
and checking the list before opening the shell/dialog.
I want to know if there is a general way or a better way of solving this.
Thanks,
Karan