use of org.eclipse.swt.browser.TitleListener in project BiglyBT by BiglySoftware.
the class BrowserWrapperFake method setUrl.
@Override
public void setUrl(final String _url) {
url = _url;
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
String url_str = _url;
int pos = url_str.indexOf('?');
if (pos != -1) {
url_str = url_str.substring(0, pos);
}
link_label.setText(url_str);
browser.layout();
for (LocationListener l : location_listeners) {
try {
LocationEvent event = new LocationEvent(browser);
event.top = true;
event.location = _url;
l.changed(event);
} catch (Throwable e) {
Debug.out(e);
}
}
for (ProgressListener l : progress_listeners) {
try {
ProgressEvent event = new ProgressEvent(browser);
l.completed(event);
} catch (Throwable e) {
Debug.out(e);
}
}
for (TitleListener l : title_listeners) {
try {
TitleEvent event = new TitleEvent(browser);
event.title = "Browser Disabled";
l.changed(event);
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
}
use of org.eclipse.swt.browser.TitleListener in project BiglyBT by BiglySoftware.
the class BrowserWindow method init.
public void init(Shell parent, String url, int w, int h, boolean allowResize, boolean isModal) {
int style = SWT.DIALOG_TRIM;
if (allowResize) {
style |= SWT.RESIZE;
}
if (isModal) {
style |= SWT.APPLICATION_MODAL;
}
shell = ShellFactory.createShell(parent, style);
shell.setLayout(new FillLayout());
Utils.setShellIcon(shell);
shell.setText(url);
shell.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_ESCAPE) {
shell.dispose();
e.doit = false;
}
}
});
final Listener escListener = new Listener() {
@Override
public void handleEvent(Event event) {
if (event.keyCode == 27) {
shell.dispose();
}
}
};
shell.getDisplay().addFilter(SWT.KeyDown, escListener);
shell.addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(Event event) {
event.display.removeFilter(SWT.KeyDown, escListener);
}
});
browser = Utils.createSafeBrowser(shell, SWT.NONE);
if (browser == null) {
shell.dispose();
return;
}
context = new BrowserContext("browser-window" + Math.random(), browser, null, true);
context.addMessageListener(new TorrentListener());
context.addMessageListener(new VuzeListener());
context.addMessageListener(new DisplayListener());
context.addMessageListener(new ConfigListener(browser));
context.addMessageListener(new MetaSearchListener(new OpenCloseSearchDetailsListener() {
@Override
public void resizeSecondaryBrowser() {
}
@Override
public void resizeMainBrowser() {
}
@Override
public void openSearchResults(Map params) {
}
@Override
public void closeSearchResults(Map params) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
shell.dispose();
}
}));
browser.addProgressListener(new ProgressListener() {
@Override
public void completed(ProgressEvent event) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
shell.open();
}
@Override
public void changed(ProgressEvent event) {
}
});
browser.addCloseWindowListener(new CloseWindowListener() {
@Override
public void close(WindowEvent event) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
context.debug("window.close called");
shell.dispose();
}
});
browser.addTitleListener(new TitleListener() {
@Override
public void changed(TitleEvent event) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
shell.setText(event.title);
}
});
browser.addStatusTextListener(new StatusTextListener() {
@Override
public void changed(StatusTextEvent event) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
if (MessageBoxShell.STATUS_TEXT_CLOSE.equals(event.text)) {
// For some reason disposing the shell / browser in the same Thread makes
// ieframe.dll crash on windows.
Utils.execSWTThreadLater(0, new Runnable() {
@Override
public void run() {
if (!browser.isDisposed() && !shell.isDisposed()) {
shell.close();
}
}
});
}
}
});
SimpleTimer.addEvent("showWin", SystemTime.getOffsetTime(3000), new TimerEventPerformer() {
@Override
public void perform(TimerEvent event) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (shell != null && !shell.isDisposed()) {
shell.open();
}
}
});
}
});
if (w > 0 && h > 0) {
Rectangle computeTrim = shell.computeTrim(0, 0, w, h);
shell.setSize(computeTrim.width, computeTrim.height);
// shell.setSize(w, h);
}
Utils.centerWindowRelativeTo(shell, parent);
browser.setUrl(url);
browser.setData("StartURL", url);
}
use of org.eclipse.swt.browser.TitleListener in project eclipse-integration-commons by spring-projects.
the class StsBrowserEditor method createPartControl.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
* .Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
browserViewer = new StsBrowserViewer(parent, hasToolbar() ? StsBrowserViewer.BUTTON_BAR | StsBrowserViewer.LOCATION_BAR : SWT.NONE);
final Browser browser = browserViewer.getBrowser();
if (getEditorInput() instanceof WebBrowserEditorInput) {
homeUrl = ((WebBrowserEditorInput) getEditorInput()).getURL().toString();
browserViewer.setVisible(true);
}
if (homeUrl != null) {
browserViewer.setHomeUrl(homeUrl);
browserViewer.setURL(homeUrl);
} else {
browser.setText("<h1>URL not set</h1>" + "<p>Url should be provided via the setInitializationData method</p>");
}
if (getName() == null) {
browser.addTitleListener(new TitleListener() {
@Override
public void changed(TitleEvent event) {
String newValue = event.title;
setName(newValue);
setPartName(newValue);
}
});
}
browser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
StsBrowserViewer browserViewer = getBrowserViewer();
if (browserViewer != null) {
if (browserManager == null) {
browserManager = new StsBrowserManager();
}
browserManager.setClient(browserViewer.getBrowser());
if (getEditorInput() instanceof WebBrowserEditorInput) {
String url = browserViewer.getURL();
try {
setInput(new WebBrowserEditorInput(new URL(url), SWT.NONE, url));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
}
});
}
Aggregations