use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project netxms by netxms.
the class ApplicationWorkbenchWindowAdvisor method postWindowCreate.
/* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowCreate()
*/
@Override
public void postWindowCreate() {
super.postWindowCreate();
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
// Changes the page title at runtime
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
if (executor != null) {
StringBuilder js = new StringBuilder();
// $NON-NLS-1$
js.append("document.title = ");
js.append("\"");
js.append(BrandingManager.getInstance().getProductName());
js.append(" - [");
js.append(session.getUserName());
js.append("@");
js.append(session.getServerAddress());
js.append("]");
js.append("\"");
executor.execute(js.toString());
}
BindingService service = (BindingService) getWindowConfigurer().getWindow().getWorkbench().getService(IBindingService.class);
BindingManager bindingManager = service.getBindingManager();
try {
// $NON-NLS-1$
bindingManager.setActiveScheme(service.getScheme("org.netxms.ui.eclipse.defaultKeyBinding"));
} catch (NotDefinedException e) {
e.printStackTrace();
}
final Shell shell = getWindowConfigurer().getWindow().getShell();
shell.setMaximized(true);
for (Control ctrl : shell.getChildren()) {
// $NON-NLS-1$
ctrl.setData(RWT.CUSTOM_VARIANT, "gray");
if (ctrl instanceof CBanner) {
for (Control cc : ((CBanner) ctrl).getChildren()) // $NON-NLS-1$
cc.setData(RWT.CUSTOM_VARIANT, "gray");
} else if (// $NON-NLS-1$
ctrl.getClass().getName().equals("org.eclipse.swt.widgets.Composite")) {
for (Control cc : ((Composite) ctrl).getChildren()) // $NON-NLS-1$
cc.setData(RWT.CUSTOM_VARIANT, "gray");
}
}
Menu menuBar = shell.getMenuBar();
if (menuBar != null)
// $NON-NLS-1$
menuBar.setData(RWT.CUSTOM_VARIANT, "menuBar");
}
use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project netxms by netxms.
the class WidgetHelper method copyToClipboard.
/**
* Copy given text to clipboard
*
* @param text
*/
public static void copyToClipboard(final String text) {
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
if (executor != null) {
StringBuilder js = new StringBuilder();
// $NON-NLS-1$
js.append("copyTextToClipboard(\'" + text + "\');");
executor.execute(js.toString());
}
}
use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project netxms by netxms.
the class AlarmNotifier method processNewAlarm.
/**
* Process new alarm
*/
private void processNewAlarm(final Alarm alarm) {
if (alarm.getState() != Alarm.STATE_OUTSTANDING)
return;
String fileName;
try {
fileName = getSoundAndDownloadIfRequired(SEVERITY_TEXT[alarm.getCurrentSeverity().getValue()]);
} catch (ArrayIndexOutOfBoundsException e) {
// $NON-NLS-1$
Activator.logError("Invalid alarm severity", e);
fileName = null;
}
if ((fileName != null) && !fileName.isEmpty()) {
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
File localFile = new File(workspaceUrl.getPath(), fileName);
String id = "audio-" + fileName;
// $NON-NLS-1$
DownloadServiceHandler.addDownload(id, fileName, localFile, "audio/wav");
StringBuilder js = new StringBuilder();
js.append("var testAudio = document.createElement('audio');");
js.append("if (testAudio.canPlayType !== undefined)");
js.append("{");
// $NON-NLS-1$
js.append("var audio = new Audio('");
js.append(DownloadServiceHandler.createDownloadUrl(id));
// $NON-NLS-1$
js.append("');");
// $NON-NLS-1$
js.append("audio.play();");
js.append("}");
executor.execute(js.toString());
}
}
use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.
the class EJRWTApplicationLauncher method reloadApplication.
public static void reloadApplication(EJFrameworkHelper frameworkHelper) {
// disable due to RWT bug
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=410895
// ExitConfirmation confirmation =
// RWT.getClient().getService(ExitConfirmation.class);
// confirmation.setMessage(null);
StringBuffer url = new StringBuffer();
url.append(RWT.getRequest().getContextPath());
url.append(RWT.getRequest().getServletPath());
String encodeURL = RWT.getResponse().encodeURL(url.toString());
if (encodeURL.contains("jsessionid")) {
encodeURL = encodeURL.substring(0, encodeURL.indexOf("jsessionid"));
}
String browserText = MessageFormat.format("parent.window.location.href = \"{0}\";", encodeURL);
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
if (executor != null) {
executor.execute(browserText);
}
}
use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.
the class EJRWTFileDownload method download.
public static void download(String sourcePath, String outputName) {
File file = new File(sourcePath);
if (!file.exists()) {
throw new EJApplicationException(String.format("File not found :%s", file.getName()));
}
UUID randomUUID = UUID.randomUUID();
String fileKey = randomUUID.toString();
keys.put(fileKey, sourcePath);
StringBuffer url = new StringBuffer();
url.append(RWT.getServiceManager().getServiceHandlerUrl(SERVICE_HANDLER));
url.append("&filename=");
url.append(fileKey);
url.append("&output=");
url.append(outputName);
String encodedURL = RWT.getResponse().encodeURL(url.toString());
// UrlLauncher urlLauncher =
// RWT.getClient().getService(UrlLauncher.class);
// urlLauncher.openURL(encodedURL);
JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
javaScriptExecutor.execute(String.format("window.location = '%s'", encodedURL));
}
Aggregations