Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian

Thanks.... Should each shell / screen of a project maintain the same logic? I ask because as a practice I've passed my parent shell to child shells similar to this:

myMethod (parentShell);

Public myClass(Shell myShell) {

	Shell childShell = myShell;

}

 

-----Original Message-----
From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] On Behalf Of Bogdan Gheorghe
Sent: October 29, 2009 17:55
To: Eclipse Platform SWT component developers list.
Subject: RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian


In order to process events from the OS, SWT needs an event loop that reads and dispatches events (i.e. delivers them to a widget for processing). It needs to keep doing this for the entire life cycle of the app (represented by the while (!shell.isDisposed()) check where shell is your app's main window). When there are no other events in the queue, we want the program to go to "sleep", thus yielding the CPU to other programs. If you don't tell the display to sleep, it will busy wait (continuously polling for events) and hang on to the CPU needlessly which impacts system performance. So the inner loop just says read and dispatch the next available event which returns true if an event was dispatched and false if there were no events available. If there are no events available, go to sleep. The display will be woken up again when an event is in the OS queue or some other thread calls wake, and the cycle continues... 




From: 	"Corbett, James" <James.Corbett@xxxxxxxxxxxxx> 
To: 	"Eclipse Platform SWT component developers list." <platform-swt-dev@xxxxxxxxxxx> 
Date: 	10/29/2009 12:53 PM 
Subject: 	RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian 
Sent by: 	platform-swt-dev-bounces@xxxxxxxxxxx

________________________________




Hi:

...nice explanation. If you wouldn't mind, I've used the following code for what seems forever but don't really understand what it does. I've been using / programming with SWT for nearly five years now and feel I'm proficient, but the reasoning eludes me.

Snipet:

       while (!shell.isDisposed()) { 
               if (!display.readAndDispatch()) 
                       display.sleep(); 
       }   

-----Original Message-----
From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx <mailto:platform-swt-dev-bounces@xxxxxxxxxxx> ] On Behalf Of Bogdan Gheorghe
Sent: October 29, 2009 12:25
To: Eclipse Platform SWT component developers list.
Subject: RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian


You have to explicitly close the shell, it won't close for free - try the attached snippet below. BTW, I'm not sure why you are parenting the dialog on a SYSTEM_MODAL, ON_TOP shell - this seems wrong. System modal means modal to all other windows on your desktop! A  FileDialog will be modal to all other shells in your app (depending on which version of GTK you are running, a shell might seem to take focus, but you shouldn't be able to click on any other controls. If you can please open a bug). 


public static void main(String[] args) { 
       
       Display display = new Display(); 
       final Shell shell = new Shell(display, SWT.ON_TOP | SWT.SYSTEM_MODAL); 
       shell.setLayout(new GridLayout(1, false)); 
       shell.setBounds(50, 50, 100, 100); 
       shell.open(); 
               
       final FileDialog dialog = new FileDialog(shell, SWT.OPEN); 
       String s= dialog.open(); 
       System.out.println(s); 
       if (s != null) { 
               shell.close(); 
       } 
       
       while (!shell.isDisposed()) { 
               if (!display.readAndDispatch()) 
                       display.sleep(); 
       } 
       display.dispose();
} 




From:                  Stéphane WASSERHARDT <stephane.wasserhardt@xxxxxxxxxxxx> 
To:                  "'Eclipse Platform SWT component developers list.'" <platform-swt-dev@xxxxxxxxxxx> 
Date:                  10/28/2009 10:03 AM 
Subject:                  RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian 
Sent by:                  platform-swt-dev-bounces@xxxxxxxxxxx

________________________________




I just tried with SWT.NONE instead of SYSTEM_MODAL and ON_TOP, but this didn't change anything :-( 
 

________________________________


De : platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx <mailto:platform-swt-dev-bounces@xxxxxxxxxxx>  <mailto:platform-swt-dev-bounces@xxxxxxxxxxx <mailto:platform-swt-dev-bounces@xxxxxxxxxxx> > ] De la part de Stéphane WASSERHARDT Envoyé : mercredi 28 octobre 2009 14:50 À : SWT Objet : [platform-swt-dev] FileDialog/DirectoryDialog under Debian 
 
Hello, 
 
I have a problem with both FileDialog and DirectoryDialog under Debian Lenny (GTK2) : when such dialog is closed (either when double clicking an item, using select or cancel button, or simply closing it), the "open" method returns with the expected result, but the shell remains open ! 
The shell is not repainted anymore, so it seems to be "disposed", but it's still visible... 
Moreover, if I open another file or directory dialog, the previous one disappears! 
Note that the parent shell is created with style "SWT.SYSTEM_MODAL | SWT.ON_TOP" (and I'd like to keep this style...) 
 
I tried with both SWT 3.4.2 and SWT 3.5.1... 
 
Here is the code I'm using : 
 
// The following Shell is not made visible. We only show the file dialog. 
final Shell shell = new Shell(display, SWT.SYSTEM_MODAL | SWT.ON_TOP); 
           try { 
                 final FileDialog fd = new FileDialog(shell, SWT.OPEN); 
 
// ... Setting of file dialog properties : text, filterPath, etc. ... 
 
                 fd.open(); // Opens correctly, and return normally, but the dialog remains open ! 
 
// Get the correct result. 
                 final String[] selectedFiles = fd.getFileNames(); 
 
                 // ... Process the result ... 
 
           } finally { 
                 // I tried to close the parent shell in a async runnable just in case... But it doesn't change anything. 
                 display.asyncExec(new Runnable() { 
                       @Override 
                       public void run() { 
                            shell.close(); 
                            shell.dispose(); 
                       } 
                 }); 
           } 
 
I'm currently trying to remove "SWT.SYSTEM_MODAL | SWT.ON_TOP" just to see if it changes something, but I really need the dialog to be displayed on top and to block other running applications... 
 
Any help is welcome! Thanks in advance! 
 
Stephane_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev <https://dev.eclipse.org/mailman/listinfo/platform-swt-dev>  <https://dev.eclipse.org/mailman/listinfo/platform-swt-dev <https://dev.eclipse.org/mailman/listinfo/platform-swt-dev> > 



_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev <https://dev.eclipse.org/mailman/listinfo/platform-swt-dev> 





Back to the top