Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Dialog buttons don't work all the time
Dialog buttons don't work all the time [message #1726130] Wed, 09 March 2016 22:20 Go to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hi,

I have an Entrypoint which creates a maximized shell, on top of the created composite, with a button on it that open a JFace dialog.
Sometimes, OK and Cancel button don't react. (RAP 2.3, appeared in Chrome, FF, IE and Edge, running on tomcat 7 on System i, stuck with java 6, also appears in Development mode running Jetty in Eclipse on Windows machines (7 & 10) )
The dialog can only be closed by pressing the (x) button in the title bar of the shell.
After closing the dialog this problem doesn't occur anymore in the same session.

I wasn't able to reproduce this in a simple version. But basicly it does the same as the code below.
At the moment the new shell is opening I have no reference to a Control. So I use Display.getCurrent() with fallback to Display.getDefault().

I have been debugging and found that while executing the events : Display.executeNextEvent the check EventUtil.allowProcessing returns false. Drilling more down it seems that in EventUtil.isShellAccessible
Shell activeShell = shell.getDisplay().getActiveShell();

the "active shell" is not the same as "shell"
Maybe some extra info:
The events that are looped when it works :
org.eclipse.swt.widgets.Event{type=26 Button {Cancel} time=1567909917 data=null x=0 y=0 width=0 height=0 detail=0}
org.eclipse.swt.widgets.Event{type=26 Composite {} time=1567909918 data=null x=0 y=0 width=0 height=0 detail=0}
org.eclipse.swt.widgets.Event{type=13 Button {Cancel} time=1567909919 data=null x=0 y=0 width=0 height=0 detail=0}
When it doesn't work, only one event :
org.eclipse.swt.widgets.Event{type=13 Button {Cancel} time=1567909919 data=null x=0 y=0 width=0 height=0 detail=0}

At the client side I see that the same json been send to the backend:
working json:
{"head":{"requestCounter":48},"operations":[["notify","w903","Selection",{"button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}],["set","w1",{"cursorLocation":[1221,457]}]]}
json not worked:
{"head":{"requestCounter":20},"operations":[["notify","w385","Selection",{"button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}],["set","w1",{"cursorLocation":[1120,467]}]]}


import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class TestEntryPoint extends AbstractEntryPoint {

    @Override
    protected void createContents(Composite parent) {
        openNewShell();
    }

    private void openNewShell() {
        final Display display = getDisplay();
        final Shell shell = new Shell(display, SWT.APPLICATION_MODAL);
        shell.setMaximized(true);
        shell.setLocation(0, 0);
        display.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event event) {
                if (shell != null && !shell.isDisposed()) {
                    shell.setMaximized(true);
                    shell.layout();
                }
            }
        });
        shell.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event event) {
                if (shell != null && !shell.isDisposed()) {
                    shell.setMaximized(true);
                }
                shell.layout();
            }
        });
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 0;
        layout.marginBottom = 0;
        layout.marginHeight = 0;
        layout.marginLeft = 0;
        layout.marginRight = 0;
        layout.marginTop = 0;
        layout.marginWidth = 0;
        shell.setLayout(layout);

        new Label(shell, SWT.NONE).setText("-----------------");
        SelectionAdapter listener = new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new MyDialog(display.getActiveShell()).open();
            }
        };
        for (int i = 0; i < 10; i++) {
            Button button = new Button(shell, SWT.PUSH);
            button.setText("test button:" + i);
            button.setFocus();
            button.addSelectionListener(listener);

        }
        shell.open();
    }

    private Display getDisplay() {
        Display display = Display.getCurrent();
        if (display == null) {
            display = Display.getDefault();
        }
        return display;
    }

    class MyDialog extends Dialog {

        public MyDialog(Shell parentShell) {
            super(parentShell);
            setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.MAX | SWT.RESIZE | SWT.APPLICATION_MODAL | getDefaultOrientation() | SWT.BORDER);
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            new Label(parent, SWT.NONE).setText("Text");
            return parent;
        }
    };

}
Re: Dialog buttons don't work all the time [message #1726146 is a reply to message #1726130] Thu, 10 March 2016 07:24 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Wim,
could you try to reproduce it with RAP 3.1M5? If the problem persists,
please open a bugzilla with a simple snippet to reproduce the issue.
Regards,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726170 is a reply to message #1726130] Thu, 10 March 2016 09:47 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
.... I found something... your new Shell and your dialog Shell are both
SWT.APPLICATION_MODAL. Is this intentional?
Regards,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726174 is a reply to message #1726170] Thu, 10 March 2016 10:22 Go to previous messageGo to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hi Ivan,
tx for the reply.
It's hard to reproduce and appears randomly and as far as I know only happens once per session.

The first shell should be application wide, non closeable.
The button on the shell should open a dialog and the user has to answer/close the dialog.

Am I using the wrong stylebits?
Kind regards,
Wim
Re: Dialog buttons don't work all the time [message #1726185 is a reply to message #1726174] Thu, 10 March 2016 12:26 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
no... everything looks good and it's working for me with RAP 3.1M5.
Without a way to reproduce it I can't help much.
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726191 is a reply to message #1726174] Thu, 10 March 2016 12:50 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
..... just looked at the code EventUtil#isShellAccessible. There is a
check for APPLICATION_MODAL shells. Just for a test please use
PRIMARY_MODAL or SYSTEM_MODAL instead of APPLICATION_MODAL. Does it
change anything?

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726221 is a reply to message #1726191] Thu, 10 March 2016 15:28 Go to previous messageGo to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hi,

I've tested removing the APPLICATION_MODAL from the jface shellstyle but then I didn't get the problem on a Jface dialog but on a MessageDialog.openError.
As a side effect, the user could continue using the application without closing/confirming the dialog.

I've changed my test code a little bit and then I could reproduce it in this testcase with FF, chrome, IE and Edge.
As soon as I refreshed the webbrowser, or clicked on the close button of the dialog the problem did not occur anymore.
Even when I restart the browser or restart jetty I couldn't reproduce it.

But then I found a way to reproduce it constantly.
Running the code below I had it always in the first time.
To reproduce it another time I had to change the code (changing btn.setText("push123....") )
(at least running in debug)

{edit}
Also tried with RAP 3.0 and reproducable.
{/edit}

As if some classloading has to be done first so the "cache" was cleared.


import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class TestEntryPoint extends AbstractEntryPoint {

    @Override
    protected void createContents(Composite parent) {
        openNewShell();
    }

    private void openNewShell() {
        final Display display = getDisplay();
        final Shell shell = new Shell(display, SWT.APPLICATION_MODAL);
        shell.setMaximized(true);
        shell.setLocation(0, 0);
        display.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event event) {
                if (shell != null && !shell.isDisposed()) {
                    shell.setMaximized(true);
                    shell.layout();
                }
            }
        });
        shell.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event event) {
                if (shell != null && !shell.isDisposed()) {
                    shell.setMaximized(true);
                }
                shell.layout();
            }
        });
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 0;
        layout.marginBottom = 0;
        layout.marginHeight = 0;
        layout.marginLeft = 0;
        layout.marginRight = 0;
        layout.marginTop = 0;
        layout.marginWidth = 0;
        shell.setLayout(layout);

        new Label(shell, SWT.NONE).setText("-----------------");
        SelectionAdapter listener = new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new MyDialog(display.getActiveShell()).open();
            }
        };
        for (int i = 0; i < 10; i++) {
            Button button = new Button(shell, SWT.PUSH);
            button.setText("test button:" + i);
            button.setFocus();
            button.addSelectionListener(listener);

        }
        shell.open();
        shell.forceActive();
    }

    private Display getDisplay() {
        Display display = Display.getCurrent();
        if (display == null) {
            display = Display.getDefault();
        }
        return display;
    }

    class MyDialog extends Dialog {

        public MyDialog(Shell parentShell) {
            super(parentShell);
            setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.MAX | SWT.RESIZE | SWT.APPLICATION_MODAL | getDefaultOrientation() | SWT.BORDER);

        }

        @Override
        protected Control createDialogArea(Composite parent) {
            new Label(parent, SWT.NONE).setText("Text");
            final Button btn = new Button(parent, SWT.PUSH);
            btn.setText("pushing");
            btn.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    MessageDialog.openError(btn.getShell(), "", "button in dialog pressed");
                }
            });
            return parent;
        }
    };

}

[Updated on: Thu, 10 March 2016 15:50]

Report message to a moderator

Re: Dialog buttons don't work all the time [message #1726228 is a reply to message #1726221] Thu, 10 March 2016 15:48 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
I still can't reproduce it in RAP 3.1M5. Did you try RAP 3.1M5?
Regards,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726229 is a reply to message #1726228] Thu, 10 March 2016 16:03 Go to previous messageGo to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hi Ivan,

I've tried it in RAP 3.0 and I was able to reproduce it.
Then I switched my target to RAP3.1 (changing the software site of my target to http://download.eclipse.org/rt/rap/3.1)
Restarted application and I was able to reproduce it.
Restarted eclipse and tried again and also reproducable.

steps I did :
- surfing to entrypoint
- clicking button => dialog opens
- pressing ok : this works.
- altering code (fe btn.setText("Pushing second load") );
- refreshing browser
- clicking button => dialog opens
- pressing ok : dialog stays open.

Kind regards,
Wim


{edit}
maybe for completeness, On my local machine I have java 8u65
{/edit}

[Updated on: Thu, 10 March 2016 16:12]

Report message to a moderator

Re: Dialog buttons don't work all the time [message #1726238 is a reply to message #1726229] Thu, 10 March 2016 16:44 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
OK... great. Now I can reproduce it wit RAP 3.1M5 (from master branch).
Please file a bugzilla to track the progress on this issue.
Thanks,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Dialog buttons don't work all the time [message #1726240 is a reply to message #1726238] Thu, 10 March 2016 17:04 Go to previous messageGo to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Tx Ivan,

I filed a bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=489373

I'm glad that I was able to reproduce it.
Re: Dialog buttons don't work all the time [message #1726481 is a reply to message #1726240] Mon, 14 March 2016 09:17 Go to previous message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hi Ivan,
I was testing a bit more and concluded that I didn't follow your instruction entirely.
I changed the first shell creation to PRIMARY_MODAL instead of APPLICATION_MODAL and the I wasn't able to reproduce it anymore.

final Shell shell = new Shell(display, SWT.PRIMARY_MODAL);

I will update the bug wit this.

grz
Previous Topic:Unable to export product from warproduct file
Next Topic:Is it possible to have application level custom error page
Goto Forum:
  


Current Time: Tue Mar 19 03:12:23 GMT 2024

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

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

Back to the top