org.eclipse.swt.browser.Browser.execute()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中org.eclipse.swt.browser.Browser.execute()方法的一些代码示例,展示了Browser.execute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Browser.execute()方法的具体详情如下:
包路径:org.eclipse.swt.browser.Browser
类名称:Browser
方法名:execute

Browser.execute介绍

[英]Executes the specified script.

Executes a script containing javascript commands in the context of the current document. If document-defined functions or properties are accessed by the script then this method should not be invoked until the document has finished loading (ProgressListener.completed() gives notification of this).
[中]执行指定的脚本。
在当前文档的上下文中执行包含javascript命令的脚本。如果脚本访问文档定义的函数或属性,则在文档完成加载之前不应调用此方法(ProgressListener.completed()发出此通知)。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

@Override
 public void completed( ProgressEvent event ) {
  if ( fromPrint ) {
   wBrowser.execute( PRINT_SCRIPT );
   fromPrint = false;
  }
  setForwardBackEnable();
 }
};

代码示例来源:origin: pentaho/pentaho-kettle

private void print() {
 String printURL = wBrowser.getUrl();
 if ( printURL.startsWith( PREFIX ) ) {
  printURL = printURL.replace( PREFIX, PRINT_PREFIX );
  fromPrint = true;
  wBrowser.setUrl( printURL );
 } else {
  wBrowser.execute( PRINT_SCRIPT );
 }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public boolean
execute(
  String        str )
{
  //System.out.println( "execute: " + str );
  return( browser.execute( str ));
}

代码示例来源:origin: org.xworker/xworker_swt

public void completed(ProgressEvent event) { 
    //println "completed";        
    ((Browser) event.widget).execute("getContents()");
  }
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

public void handleEvent(Event e) {
   if (swtBrowser != null)
     swtBrowser.execute("print()");
     //swtBrowser.execute("window.print()");
     //swtBrowser.execute("javascript:print()");
 }
});

代码示例来源:origin: org.codehaus.openxma/xmartserver

public void handleEvent(Event e) {
   if (swtBrowser != null)
     swtBrowser.execute("print()");
     //swtBrowser.execute("window.print()");
     //swtBrowser.execute("javascript:print()");
 }
});

代码示例来源:origin: org.eclipse/org.eclipse.help.ui

private void doPrint() {
  browser.execute("window.print();"); //$NON-NLS-1$
}

代码示例来源:origin: org.eclipse.mylyn.wikitext/ui

@Override
  public void completed(ProgressEvent event) {
    browser.removeProgressListener(this);
    if (outlineItem != null) {
      revealInBrowser(outlineItem);
    } else {
      browser.execute(String.format("window.scrollTo(0,%d);", verticalScrollbarPos)); //$NON-NLS-1$
    }
  }
});

代码示例来源:origin: org.eclipse/org.eclipse.help.ui

private String executeQuery(String domValue) {
  String query = "window.status=\"" + QUERY + "\"+" + domValue + ";"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  boolean status = browser.execute(query);
  if (status) {
    return (String) browser.getData("query"); //$NON-NLS-1$
  }
  return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

buffer.append ("document.addEventListener('keypress', SWTkeyhandler, true);"); //$NON-NLS-1$
  buffer.append ("document.addEventListener('keyup', SWTkeyhandler, true);"); //$NON-NLS-1$
  browser.execute (buffer.toString ());
  buffer.append ("document.addEventListener('mouseout', SWTmousehandler, true);"); //$NON-NLS-1$
  browser.execute (buffer.toString ());
} else {
  StringBuffer buffer = new StringBuffer ("for (var i = 0; i < frames.length; i++) {"); //$NON-NLS-1$
  buffer.append ("frames[i].document.addEventListener('dragstart', window.SWTmousehandler, true);"); //$NON-NLS-1$
  buffer.append ('}');
  browser.execute (buffer.toString ());

代码示例来源:origin: org.eclipse.mylyn.wikitext/ui

private void revealInBrowser(OutlineItem item) {
  browser.execute(String.format(
      "document.getElementById('%s').scrollIntoView(true);window.location.hash = '%s';", item.getId(), item.getId())); //$NON-NLS-1$
}

代码示例来源:origin: org.xworker/xworker_swt

public static void executeScript(Browser browser, String script, ActionContext actionContext) {
  if(SwtUtils.isRWT()) {
    Thing swt = World.getInstance().getThing("xworker.swt.SWT");
    swt.doAction("rwtBrowserEvaluate", actionContext, "browser", browser, "script", script, "callback", null);
  }else {
    browser.execute(script);
  }
}

代码示例来源:origin: stackoverflow.com

public void handleEvent(Event arg0)
  browser.execute("window.print()");

代码示例来源:origin: stackoverflow.com

public static void main( String[] args ) {
 String html = "<html><head></head><body>";
 for( int i = 0; i < 100; i++ ) {
  html += "<h2 id=\"id" + i + "\">This is header " + i + "</h2>";
 }
 html += "</body></html>";
 Display display = new Display();
 Shell shell = new Shell( display );
 shell.setLayout( new GridLayout( 1, false ) );
 Button button = new Button( shell, SWT.PUSH );
 button.setText( "Focus header 17" );
 Browser browser = new Browser( shell, SWT.BORDER );
 browser.setText( html );
 browser.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
 button.addListener( SWT.Selection, new Listener() {
  @Override
  public void handleEvent( Event event ) {
   if( !browser.execute( "document.getElementById( 'id17' ).focus();" ) ) {
    throw new RuntimeException( "Failed to execute Javascript" );
   }
  }
 } );
 shell.open();
 while( !shell.isDisposed() ) {
  if( !display.readAndDispatch() )
   display.sleep();
 }
 display.dispose();
}

代码示例来源:origin: stackoverflow.com

public void handleEvent(Event event) {
  browser.execute("cookieCallback(document.cookie.split( ';' ).map( function( x ) { return x.trim().split( '=' ); } ));");

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

int didClearWindowObject (int /*long*/ webView, int /*long*/ context, int /*long*/ windowScriptObject, int /*long*/ frame) {
  WebKit_win32.JSGlobalContextRetain (context);
  int /*long*/ globalObject = WebKit_win32.JSContextGetGlobalObject (context);
  int /*long*/ privateData = ((WebKit)browser.webBrowser).webViewData;
  int /*long*/ externalObject = WebKit_win32.JSObjectMake (context, WebKit.ExternalClass, privateData);
  byte[] bytes = null;
  try {
    bytes = (OBJECTNAME_EXTERNAL + '\0').getBytes (WebKit.CHARSET_UTF8);
  } catch (UnsupportedEncodingException e) {
    bytes = (OBJECTNAME_EXTERNAL + '\0').getBytes ();
  }
  int /*long*/ name = WebKit_win32.JSStringCreateWithUTF8CString (bytes);
  WebKit_win32.JSObjectSetProperty (context, globalObject, name, externalObject, 0, null);
  WebKit_win32.JSStringRelease (name);

  for (BrowserFunction current : browser.webBrowser.functions.values()) {
    browser.execute (current.functionString);
  }

  IWebView iwebView = new IWebView (webView);
  int /*long*/[] mainFrame = new int /*long*/[1];
  iwebView.mainFrame (mainFrame);
  boolean top = mainFrame[0] == frame;
  new IWebFrame (mainFrame[0]).Release ();
  addEventHandlers (top);
  return COM.S_OK;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

SWT.error( SWT.ERROR_NULL_ARGUMENT );
boolean success = execute( prepareScript( script ) );
if( !success ) {
 throw createException();

代码示例来源:origin: stackoverflow.com

ToolItem item = (ToolItem)event.widget;
String string = item.getText();
if (string.equals("Print")) browser.execute("javascript:window.print();");

代码示例来源:origin: stackoverflow.com

"}";
System.out.println(browser.execute(s));

代码示例来源:origin: org.xworker/xworker_swt

}catch(Throwable e){   
  browser.execute("window.status=getContents();");
  value =  browser.getData("query");

相关文章