Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Strange behaviour of an open shell (needs a mouse click twice before noticing any event on the shell
Strange behaviour of an open shell (needs a mouse click twice before noticing any event on the shell [message #336130] Mon, 25 May 2009 09:20 Go to next message
Eclipse User
Originally posted by: wigor.oows.de

Hello,

i´ve got following strange behaviour within my rcp application. My RCP
Application browses through some list of pdf documents (which are
displayed within a table widget). When the user clicks on a row of my
table, a separate window (here: shell) should be opened an the pdf
document should be displayed.

My problem is the following curious behaviour:
When I open or display the shell, the window recognizes mouse events
after a second mouse click, though the window seems to be active and
seems to have the current focus on the application window.

If I add some special listeners on the current shell and add here some
logging statements, it seems that the current shell looses the focus
directly after gaining the focus.

Does anybody know whats wrong ?

Thanks
wigor



>>>> begin
/**
* Opens a new shell for opening an pdf document in a separate
application window.
*
* @param url fileurl
* @param docId unique document id
* @param docName pdf title / document name
*/
public void createPDFShell(final String url, final String docId,final
String docName, boolean isDraft){

final Display display = PlatformUI.createDisplay();
// ...
display.asyncExec(new Runnable() {

@Override
public void run() {

Display.getCurrent().getActiveShell().setCapture(false);

final Shell shell = new Shell(Display.getCurrent());

shell.setLayout(new FillLayout());
shell.setSize( 1024, 768 );
shell.setText("PDF Viewer");
shell.setCapture(true);


// Adding some shell-icons
Bundle plugin = Platform.getBundle ("example.pdfviewer");
try {
final InputStream in16 =
plugin.getEntry("/icons/wic16.gif").openStream();
final InputStream in32 =
plugin.getEntry("/icons/wic32.gif").openStream();
final Image[] images = {new Image(display,in16),new
Image(display,in32)};
shell.setImages(images);
in16.close();
in32.close();
} catch (IOException e) {
Logger.getLogger(PDFShellHandler.class).error("error while creating
icons for pdf shell", e);
}

// Adding some menus Menus
final Menu m = new Menu(shell,SWT.BAR );

final MenuItem file = new MenuItem(m, SWT.CASCADE);
file.setText("File");
final Menu filemenu = new Menu(shell, SWT.DROP_DOWN);
file.setMenu(filemenu);
final MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
exitItem.setText("Exit");

final MenuItem fav = new MenuItem(m, SWT.CASCADE );
fav.setText("Favourties");
final Menu favmenu = new Menu(shell, SWT.DROP_DOWN);
fav.setMenu(favmenu);
final MenuItem addItem = new MenuItem(favmenu, SWT.PUSH);
addItem.setText("Add current Document to your Favourites..");

shell.setMenuBar(m);

final Browser browser = new Browser(shell, SWT.BORDER);
browser.setUrl(url);



shell.open ();

// shell.forceActive(); or
shell.forceFocus();

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

}
});
}

<<<< end-of
Re: Strange behaviour of an open shell (needs a mouse click twice before noticing any event on the s [message #336133 is a reply to message #336130] Mon, 25 May 2009 12:32 Go to previous message
Eclipse User
Originally posted by: wigor.oows.de

Hello Guys,

i fixed the problem by initialize the Shell-constructor without any
parameters.


final Shell shell = new Shell();
....

instead of ...

//old: final Shell shell = new Shell(currentDisplay);

CY

Wagner wrote:
> Hello,
>
> i´ve got following strange behaviour within my rcp application. My RCP
> Application browses through some list of pdf documents (which are
> displayed within a table widget). When the user clicks on a row of my
> table, a separate window (here: shell) should be opened an the pdf
> document should be displayed.
>
> My problem is the following curious behaviour:
> When I open or display the shell, the window recognizes mouse events
> after a second mouse click, though the window seems to be active and
> seems to have the current focus on the application window.
>
> If I add some special listeners on the current shell and add here some
> logging statements, it seems that the current shell looses the focus
> directly after gaining the focus.
>
> Does anybody know whats wrong ?
>
> Thanks
> wigor
>
>
>
> >>>> begin
> /**
> * Opens a new shell for opening an pdf document in a separate
> application window.
> *
> * @param url fileurl
> * @param docId unique document id
> * @param docName pdf title / document name
> */
> public void createPDFShell(final String url, final String
> docId,final String docName, boolean isDraft){
>
> final Display display = PlatformUI.createDisplay();
> // ...
> display.asyncExec(new Runnable() {
>
> @Override
> public void run() {
>
> Display.getCurrent().getActiveShell().setCapture(false);
>
> final Shell shell = new Shell(Display.getCurrent());
>
> shell.setLayout(new FillLayout());
> shell.setSize( 1024, 768 );
> shell.setText("PDF Viewer");
> shell.setCapture(true);
>
>
> // Adding some shell-icons
> Bundle plugin = Platform.getBundle
> ("example.pdfviewer");
> try {
> final InputStream in16 =
> plugin.getEntry("/icons/wic16.gif").openStream();
> final InputStream in32 =
> plugin.getEntry("/icons/wic32.gif").openStream();
> final Image[] images = {new Image(display,in16),new
> Image(display,in32)};
> shell.setImages(images);
> in16.close();
> in32.close();
> } catch (IOException e) {
> Logger.getLogger(PDFShellHandler.class).error("error
> while creating icons for pdf shell", e);
> }
>
> // Adding some menus Menus
> final Menu m = new Menu(shell,SWT.BAR );
>
> final MenuItem file = new MenuItem(m, SWT.CASCADE);
> file.setText("File");
> final Menu filemenu = new Menu(shell, SWT.DROP_DOWN);
> file.setMenu(filemenu);
> final MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
> exitItem.setText("Exit");
>
> final MenuItem fav = new MenuItem(m, SWT.CASCADE );
> fav.setText("Favourties");
> final Menu favmenu = new Menu(shell, SWT.DROP_DOWN);
> fav.setMenu(favmenu);
> final MenuItem addItem = new MenuItem(favmenu, SWT.PUSH);
> addItem.setText("Add current Document to your
> Favourites..");
>
> shell.setMenuBar(m);
>
> final Browser browser = new Browser(shell, SWT.BORDER);
> browser.setUrl(url);
>
>
>
> shell.open ();
>
> // shell.forceActive(); or
> shell.forceFocus();
>
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
>
> }
> });
> }
>
> <<<< end-of
Previous Topic:Why the problemd view don't use the AdapterManager
Next Topic:[CommonNavigator] setting up initial input accross many providers
Goto Forum:
  


Current Time: Thu Sep 18 11:43:01 GMT 2014

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

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