本文整理汇总了Java中com.vaadin.ui.JavaScript类的典型用法代码示例。如果您正苦于以下问题:Java JavaScript类的具体用法?Java JavaScript怎么用?Java JavaScript使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaScript类属于com.vaadin.ui包,在下文中一共展示了JavaScript类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: callBlind
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
void callBlind(final JavaScriptCallback<Void> javaScriptCallback)
{
final Stopwatch timer = Stopwatch.createStarted();
final ScheduledFuture<?> future = createTimeoutHook();
JavaScript.getCurrent().addFunction(hookName, new JavaScriptFunction()
{
boolean done = false;
private static final long serialVersionUID = 1L;
@Override
public void call(JsonArray arguments)
{
logger.debug("Handling response for " + hookName);
if (!done)
{
done = true;
javaScriptCallback.callback(null);
}
else
{
logger.warn("This appears to have been a duplicate callback, ignoring it!");
}
future.cancel(false);
removeHooks(hookName, errorHookName);
if (timer.elapsed(TimeUnit.MILLISECONDS) > EXPECTED_RESPONSE_TIME_MS)
{
logger.warn(jsToExecute + "\n\nResponded after {}ms", timer.elapsed(TimeUnit.MILLISECONDS));
}
}
});
setupErrorHook(future);
JavaScript.getCurrent().execute(wrapJSInTryCatchBlind(jsToExecute));
}
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:38,代码来源:JSCallWithReturnValue.java
示例2: FileExample
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public FileExample() {
setCaption("Interactive SVG");
addComponent(new MLabel(
"A simple example from an svg file using Embedded component. Unlike with Image component, the SVGs JS etc are active. The example also demonstrates how to provide a trivial server side integration API for the SVG."));
Embedded svg = new Embedded();
svg.setWidth("400px");
svg.setHeight("400px");
svg.setSource(new ClassResource("/pull.svg"));
// Expose a JS hook that pull.svg file calls when clicked
JavaScript.getCurrent().addFunction("callMyVaadinFunction", (JsonArray arguments) -> {
Notification.show("Message from SVG:" + arguments.getString(0));
});
addComponent(svg);
}
开发者ID:mstahv,项目名称:svgexamples,代码行数:17,代码来源:FileExample.java
示例3: registerJavaScriptFunctionsIfNeeded
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
@SuppressWarnings("serial")
private final void registerJavaScriptFunctionsIfNeeded()
{
if (jsFunctionsRegistered.getAndSet(true))
{
return; // already registered
}
final JavaScript javaScript = JavaScript.getCurrent();
javaScript.addFunction(JS_FUNC_OnSwipe, new JavaScriptFunction()
{
@Override
public void call(final JsonArray arguments)
{
invokeOnSwipe(arguments);
}
});
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:19,代码来源:SwipeHelper.java
示例4: getCookieValue
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void getCookieValue(String key, final Callback callback) {
final String callbackid = "hybridbpmcookie"+UUID.randomUUID().toString().substring(0,8);
JavaScript.getCurrent().addFunction(callbackid, new JavaScriptFunction() {
@Override
public void call(JsonArray arguments) {
JavaScript.getCurrent().removeFunction(callbackid);
if(arguments.length() == 0) {
callback.onValue(null);
} else {
callback.onValue(arguments.getString(0));
}
}
});
JavaScript.getCurrent().execute(String.format(
"var nameEQ = \"%2$s=\";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) {%1$s( c.substring(nameEQ.length,c.length)); return;};} %1$s();",
callbackid,key
));
}
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:21,代码来源:CookieManager.java
示例5: detectCookieValue
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void detectCookieValue(String key, final Callback callback) {
final String callbackid = "viritincookiecb"+UUID.randomUUID().toString().substring(0,8);
JavaScript.getCurrent().addFunction(callbackid, new JavaScriptFunction() {
private static final long serialVersionUID = -3426072590182105863L;
@Override
public void call(JsonArray arguments) {
JavaScript.getCurrent().removeFunction(callbackid);
if(arguments.length() == 0) {
callback.onValueDetected(null);
} else {
callback.onValueDetected(arguments.getString(0));
}
}
});
JavaScript.getCurrent().execute(String.format(
"var nameEQ = \"%2$s=\";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) {%1$s( c.substring(nameEQ.length,c.length)); return;};} %1$s();",
callbackid,key
));
}
开发者ID:viritin,项目名称:viritin,代码行数:23,代码来源:BrowserCookie.java
示例6: requestClose
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
/**
* Do on test closing
*
* @param event
*/
public void requestClose(@Observes final CloseTestEvent event) {
log.debug("close requested");
if (requestBack) {
log.debug("closing ProcessUI with history back");
JavaScript javaScript = ui.getPage().getJavaScript();
javaScript.execute("window.history.back();");
ui.requestClose();
} else {
String path = VaadinServlet.getCurrent().getServletContext().getContextPath();
ui.getPage().setLocation(path + CLOSE_URL);
// this is also possible way but not for SWT browser
// Page.getCurrent().getJavaScript().execute("window.setTimeout(function(){/*window.open('','_self','');*/window.close();},10);")
log.debug("closing ProcessUI");
ui.requestClose();
}
}
开发者ID:tilioteo,项目名称:hypothesis,代码行数:24,代码来源:ProcessUIPresenter.java
示例7: showHelpBrowserWindow
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void showHelpBrowserWindow(String guid) {
JavaScript javaScript = MainUI.getCurrent().getPage().getJavaScript();
if (!useFirstName) {
javaScript.execute(closeNativeWindow(HELP_WINDOW_NAME_1));
} else {
javaScript.execute(closeNativeWindow(HELP_WINDOW_NAME_2));
}
MainUI.getCurrent().getPage().open("/WebHelp/" + guid,
useFirstName ? HELP_WINDOW_NAME_1 : HELP_WINDOW_NAME_2);
useFirstName = !useFirstName;
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:13,代码来源:ViewUtil.java
示例8: setBeforePageUnloadMessage
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void setBeforePageUnloadMessage(final String message)
{
final JavaScript javaScript = Page.getCurrent().getJavaScript();
if (message == null || message.trim().isEmpty())
{
javaScript.execute("$(window).off('beforeunload');");
}
else
{
// TODO: escape the message
javaScript.execute("$(window).on('beforeunload', function() { return \"" + message + "\"; });");
}
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:14,代码来源:JavascriptUtils.java
示例9: enable
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public synchronized void enable(final Component component, final SwipeHandler handler)
{
Preconditions.checkNotNull(component, "component is null");
final String componentId = component.getId();
Preconditions.checkNotNull(componentId, "componentId is null");
final ComponentSwipe swipe = new ComponentSwipe(componentId, handler);
component2swipe.put(component, swipe);
componentId2swipe.put(componentId, swipe);
registerJavaScriptFunctionsIfNeeded();
final JavaScript javaScript = JavaScript.getCurrent();
javaScript.execute(""
+ "if (!window.swipesMap) { window.swipesMap={}; }"
//
+ "window.swipesMap['" + componentId + "'] = Swiped.init({"
+ "query: '#" + componentId + "'"
+ ", left: 300"
+ ", right: 300"
+ ", tolerance: 200"
+ ", onOpen: function() { " + JS_FUNC_OnSwipe + "('" + componentId + "'); }"
+ "});"
//
+ "\n console.log('Enabled swiping for element: " + componentId + "');"
);
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:29,代码来源:SwipeHelper.java
示例10: destroy
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public void destroy()
{
JavaScript.getCurrent().execute("window.swipesMap['" + componentId + "'].destroy(false);"); // isRemoveNode=false
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:5,代码来源:SwipeHelper.java
示例11: setCookie
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void setCookie(String key, String value, String path) {
JavaScript.getCurrent().execute(String.format(
"document.cookie = \"%s=%s; path=%s\";", key, value, path
));
}
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:6,代码来源:CookieManager.java
示例12: addTypeStyle
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
private static void addTypeStyle(final Long tagId, final String color) {
final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
UI.getCurrent()
.access(() -> javaScript.execute(
HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
+ "{background-color:" + color + " !important;background-image:none !important }")));
}
开发者ID:eclipse,项目名称:hawkbit,代码行数:8,代码来源:SwModuleTable.java
示例13: _jsSetTimeStep
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
private void _jsSetTimeStep(TimeStep timeStep) {
JavaScript.getCurrent()
.execute("document.getElementById('" + LIVE_CHART_ID
+ "').firstElementChild.contentDocument.getElementsByClassName('stepli')["
+ timeStep.ordinal() + "].click();");
}
开发者ID:xyfreemind,项目名称:trader,代码行数:7,代码来源:LiveChart.java
示例14: setCookie
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public static void setCookie(String key, String value, LocalDateTime expirationTime) {
String expires = toCookieGMTDate(expirationTime);
JavaScript.getCurrent().execute(String.format(
"document.cookie = \"%s=%s; Expires=%s\";", key, value, expires
));
}
开发者ID:viritin,项目名称:viritin,代码行数:9,代码来源:BrowserCookie.java
示例15: removeHooks
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
void removeHooks(final String hook1, final String hook2)
{
final JavaScript js = JavaScript.getCurrent();
js.removeFunction(hook1);
js.removeFunction(hook2);
}
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:8,代码来源:JSCallWithReturnValue.java
示例16: setupErrorHook
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
private void setupErrorHook(final ScheduledFuture<?> future)
{
trace = new JavaScriptException("Java Script Invoked From Here, JS:" + jsToExecute);
JavaScript.getCurrent().addFunction(errorHookName, new JavaScriptFunction()
{
private static final long serialVersionUID = 1L;
@Override
public void call(JsonArray arguments)
{
try
{
String value = arguments.getString(0);
logger.error(jsToExecute + " -> resulted in the error: " + value, trace);
Exception ex = new JavaScriptException(trace.getMessage() + " , JS Cause: " + value, trace);
ErrorWindow.showErrorWindow(ex);
}
catch (Exception e)
{
ErrorWindow.showErrorWindow(trace);
}
finally
{
future.cancel(false);
JavaScript.getCurrent().removeFunction(hookName);
JavaScript.getCurrent().removeFunction(errorHookName);
}
}
});
}
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:36,代码来源:JSCallWithReturnValue.java
示例17: ajaxRefreshInit
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
private void ajaxRefreshInit(JavaScriptFunction intervalFn) {
JavaScript.getCurrent().addFunction("Persephone.logs.refreshLogs", intervalFn);
String js = String.format("Persephone.logs.refreshLogsInterval = setInterval(Persephone.logs.refreshLogs, %s);", refreshTimeout * 1000);
JavaScript.getCurrent().execute(js);
}
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:7,代码来源:LogsPage.java
示例18: ajaxRefreshDestroy
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
private void ajaxRefreshDestroy() {
JavaScript.getCurrent().execute("clearInterval(Persephone.logs.refreshLogsInterval)");
JavaScript.getCurrent().removeFunction("Persephone.logs.refreshLogs");
}
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:5,代码来源:LogsPage.java
示例19: open
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public void open()
{
JavaScript.getCurrent().execute("window.swipesMap['" + componentId + "'].open();");
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:5,代码来源:SwipeHelper.java
示例20: close
import com.vaadin.ui.JavaScript; //导入依赖的package包/类
public void close()
{
JavaScript.getCurrent().execute("window.swipesMap['" + componentId + "'].close(); console.log('swipe.close for " + componentId + "');");
}
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:5,代码来源:SwipeHelper.java
注:本文中的com.vaadin.ui.JavaScript类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论