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 |
Wim Anckaert 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 #1726221 is a reply to message #1726191] |
Thu, 10 March 2016 15:28 |
Wim Anckaert 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 #1726229 is a reply to message #1726228] |
Thu, 10 March 2016 16:03 |
Wim Anckaert 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
|
|
| | | |
Goto Forum:
Current Time: Tue Mar 19 03:12:23 GMT 2024
Powered by FUDForum. Page generated in 0.02198 seconds
|