use of org.eclipse.swt.browser.WindowEvent in project eclipse.platform.text by eclipse.
the class BrowserInformationControl method createContent.
@Override
protected void createContent(Composite parent) {
fBrowser = new Browser(parent, SWT.NONE);
fBrowser.setJavascriptEnabled(false);
Display display = getShell().getDisplay();
fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fBrowser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
fCompleted = true;
}
});
fBrowser.addOpenWindowListener(new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
// Cancel opening of new windows
event.required = true;
}
});
// Replace browser's built-in context menu with none
fBrowser.setMenu(new Menu(getShell(), SWT.NONE));
createTextLayout();
}
use of org.eclipse.swt.browser.WindowEvent in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_browser_Browser method test_VisibilityWindowListener_multiple_shells.
/**
* Verify that if multiple child shells are open, no duplicate visibility events are sent.
*/
@Test
public void test_VisibilityWindowListener_multiple_shells() {
AtomicBoolean secondChildCompleted = new AtomicBoolean(false);
AtomicInteger childCount = new AtomicInteger(0);
browser.addOpenWindowListener(event -> {
Shell childShell = new Shell(shell);
childShell.setText("Child shell " + childCount.get());
childShell.setLayout(new FillLayout());
Browser browserChild = new Browser(childShell, SWT.NONE);
event.browser = browserChild;
browserChild.setText("Child window");
browserChild.addVisibilityWindowListener(new VisibilityWindowAdapter() {
AtomicInteger invocationCount = new AtomicInteger(1);
AtomicInteger childID = new AtomicInteger(childCount.get());
@Override
public void show(WindowEvent event) {
if (childID.get() == 0 && invocationCount.get() >= 2) {
// are considered 'legal' as long as they don't contain size and location information.
if (event.location != null || event.size != null) {
fail("Child browser's visibility show listener should only be fired once");
}
}
invocationCount.incrementAndGet();
}
});
if (childCount.get() == 1) {
browserChild.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
secondChildCompleted.set(true);
}
});
}
childShell.open();
childCount.incrementAndGet();
});
shell.open();
browser.setText("<html>" + "<script type='text/javascript'>" + // opens child window.
"window.open();" + "window.open();" + "</script>\n" + "<body>This test uses javascript to open a new window.</body></html>");
boolean passed = waitForPassCondition(() -> secondChildCompleted.get());
String errMsg = "\nTest timed out.";
assertTrue(errMsg, passed);
}
use of org.eclipse.swt.browser.WindowEvent in project translationstudio8 by heartsome.
the class BrowserTab method hookOpenListner.
public void hookOpenListner() {
openLisenter = new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
event.required = true;
BrowserComponent app = new BrowserComponent(false);
event.browser = app.getBrowser();
}
};
browser.addOpenWindowListener(openLisenter);
}
use of org.eclipse.swt.browser.WindowEvent in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_browser_Browser method test_VisibilityWindowListener_newListener_closeShell.
@Test
public void test_VisibilityWindowListener_newListener_closeShell() {
Display display = Display.getCurrent();
Shell shell = new Shell(display);
Browser browser = new Browser(shell, SWT.NONE);
browser.addVisibilityWindowListener(new VisibilityWindowListener() {
@Override
public void hide(WindowEvent event) {
}
@Override
public void show(WindowEvent event) {
}
});
shell.close();
}
Aggregations