本文整理汇总了Java中netscape.javascript.JSObject类的典型用法代码示例。如果您正苦于以下问题:Java JSObject类的具体用法?Java JSObject怎么用?Java JSObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSObject类属于netscape.javascript包,在下文中一共展示了JSObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadResults
import netscape.javascript.JSObject; //导入依赖的package包/类
public void loadResults() {
try {
JSObject windowObj = (JSObject)webEngine.executeScript("window");
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(testResult);
windowObj.setMember("result", json);
try {
webEngine.executeScript("refreshResult()");
} catch (JSException js) {
Logger.error(js, "error updating result");
}
} catch (JsonProcessingException e) {
return;
}
}
示例2: testGetSlotNoSuchSlot2
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for JSObject.getSlot call with an absent slot as parameter.
*/
@Test(timeout=10000)
public void testGetSlotNoSuchSlot2(){
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject arrO = getArray(engine);
resultObject = arrO.getSlot(1000);
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject != null);
}
});
Assert.assertEquals(UNDEFINED, resultObject);
}
示例3: showHisoty
import netscape.javascript.JSObject; //导入依赖的package包/类
private void showHisoty() {
debug = new HistorySearch(cmboHistoryMonth.getValue(), cmboFilterList.getValue());
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
if (newValue == Worker.State.SUCCEEDED) {
JSObject windowObject = (JSObject) webEngine.executeScript("window");
windowObject.setMember("HistorySearch", debug); // insert object
windowObject.call("ready"); // execute callback
}
}
}
);
URL url = getClass().getResource("/html/index.html");
webEngine.load(url.toString());
}
示例4: btnGo
import netscape.javascript.JSObject; //导入依赖的package包/类
@FXML
private void btnGo(ActionEvent event) {
historyByDate = new HistorySearchByDate(datePicker.getValue());
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
if (newValue == Worker.State.SUCCEEDED) {
JSObject windowObject = (JSObject) webEngine.executeScript("window");
windowObject.setMember("HistorySearchByDate", historyByDate); // insert object
windowObject.call("searchHistoryByDate"); // execute callback
}
}
}
);
URL url = getClass().getResource("/html/index.html");
webEngine.load(url.toString());
// String url = getClass().getResource("../html/index.html").toExternalForm();
// webEngine.load(url);
}
示例5: initComponent
import netscape.javascript.JSObject; //导入依赖的package包/类
private void initComponent() {
webView = new WebView();
String externalForm = ACEEditor.class.getResource("/Ace.html").toExternalForm();
WebEngine engine = webView.getEngine();
engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (newValue != State.SUCCEEDED) {
return;
}
JSObject window = (JSObject) engine.executeScript("window");
window.setMember("java", ACEEditor.this);
engine.executeScript("console.log = function(message)\n" + "{\n" + " java.log(message);\n" + "};");
ACEEditor.this.engine = engine;
setOptions(new JSONObject().put("showLineNumbers", showLinenumbers).put("firstLineNumber", startLineNumber)
.put("overwrite", false));
loadPreferences();
hookKeyBindings();
}
});
engine.load(externalForm);
ToolBarContainer container = ToolBarContainer.createDefaultContainer(Orientation.RIGHT);
if (withToolbar) {
ToolBarPanel toolBarPanel = container.getToolBarPanel();
createToolBars(toolBarPanel);
}
container.setContent(webView);
this.node = container;
}
示例6: getMaxZoomAtLatLng
import netscape.javascript.JSObject; //导入依赖的package包/类
public void getMaxZoomAtLatLng(LatLong loc, MaxZoomServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getMaxZoomAtLatLng(")
.append(loc.getVariableName())
.append(", ")
.append("function(result) {document.")
.append(getVariableName())
.append(".processResponse(result);});");
// System.out.println("MaxZoomService direct call: " + r.toString());
getJSObject().eval(r.toString());
}
示例7: getElevationForLocations
import netscape.javascript.JSObject; //导入依赖的package包/类
/** Create a request for elevations for multiple locations.
*
* @param req
* @param callback
*/
public void getElevationForLocations(LocationElevationRequest req, ElevationServiceCallback callback) {
this.callback = callback;
JSObject doc = (JSObject) getJSObject().eval("document");
doc.setMember(getVariableName(), this);
StringBuilder r = new StringBuilder(getVariableName())
.append(".")
.append("getElevationForLocations(")
.append(req.getVariableName())
.append(", ")
.append("function(results, status) {alert('rec:'+status);\ndocument.")
.append(getVariableName())
.append(".processResponse(results, status);});");
// System.out.println("ElevationService direct call: " + r.toString());
getJSObject().eval(r.toString());
}
示例8: processXml
import netscape.javascript.JSObject; //导入依赖的package包/类
@Override
protected void processXml(Object DOMNode) {
atomSetCollection = new AtomSetCollection(readerName, this);
String className = null;
Class<?> atomSetCollectionReaderClass;
XmlReader thisReader = null;
String name = readerName.substring(0, readerName.indexOf("("));
try {
className = Resolver.getReaderClassBase(name);
atomSetCollectionReaderClass = Class.forName(className);//,true, Thread.currentThread().getContextClassLoader());
thisReader = (XmlReader) atomSetCollectionReaderClass
.newInstance();
thisReader.processXml(this, atomSetCollection, reader, (JSObject) DOMNode);
} catch (Exception e) {
atomSetCollection.errorMessage = "File reader was not found:" + className;
}
}
示例9: walkDOMTree
import netscape.javascript.JSObject; //导入依赖的package包/类
protected void walkDOMTree(JSObject DOMNode) {
String namespaceURI = (String) DOMNode.getMember("namespaceURI");
String localName = (String) DOMNode.getMember("localName");
String qName = (String) DOMNode.getMember("nodeName");
JSObject attributes = (JSObject) DOMNode.getMember("attributes");
getAttributes(attributes);
startElement(namespaceURI, localName, qName);
if (((Boolean) DOMNode.call("hasChildNodes", null))
.booleanValue()) {
for (JSObject nextNode = (JSObject) DOMNode.getMember("firstChild");
nextNode != null;
nextNode = (JSObject) nextNode.getMember("nextSibling"))
walkDOMTree(nextNode);
}
endElement(namespaceURI, localName, qName);
}
示例10: sendJsTextStatus
import netscape.javascript.JSObject; //导入依赖的package包/类
void sendJsTextStatus(String message) {
if (!haveDocumentAccess || statusForm == null || statusText == null)
return;
try {
JSObject jsoWindow = JSObject.getWindow(appletWrapper);
JSObject jsoDocument = (JSObject) jsoWindow.getMember("document");
JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm);
if (statusText != null) {
JSObject jsoText = (JSObject) jsoForm.getMember(statusText);
jsoText.setMember("value", message);
}
} catch (Exception e) {
Logger.error("error indicating status at document." + statusForm + "."
+ statusText + ":" + e.toString());
}
}
示例11: testGetSlotById
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for simple JSObject.getSlot call.
*/
@Test(timeout=10000)
public void testGetSlotById(){
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject arrO = getArray(engine);
resultObject = arrO.getSlot(0);
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject != null);
}
});
Assert.assertEquals(ELEM_AT_0, resultObject);
}
示例12: testGetSlotNoSuchSlot1
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for JSObject.getSlot call with -1 slot number as parameter.
*/
@Test(timeout=10000)
public void testGetSlotNoSuchSlot1(){
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject arrO = getArray(engine);
resultObject = arrO.getSlot(-1);
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject != null);
}
});
Assert.assertEquals(UNDEFINED, resultObject);
}
示例13: testGetSlotNoSlots
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for JSObject.getSlot call on an object which has no indexed slots.
*/
@Test(timeout=10000)
public void testGetSlotNoSlots(){
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject arrO = getWindow(engine);
resultObject = arrO.getSlot(0);
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject != null);
}
});
Assert.assertEquals(UNDEFINED, resultObject);
}
示例14: testSetAbsentMember
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for JSObject.setMember call with an absent member name as a parameter.
*/
@Test(timeout=10000)
public void testSetAbsentMember(){
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject strO = getString(engine);
strO.setMember("iAmWrongMember", TEST_STRING);
resultObject = strO.getMember("iAmWrongMember");
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject != null);
}
});
Assert.assertEquals(TEST_STRING, resultObject);
}
示例15: testSetMemberNull
import netscape.javascript.JSObject; //导入依赖的package包/类
/**
* Test for JSObject.setMember call with null as value.
* CR associated with this test failure:
* http://javafx-jira.kenai.com/browse/RT-14178
*/
@Test(timeout=10000)
public void testSetMemberNull(){
resultObject = new Object();
Platform.runLater(new Runnable() {
public void run() {
initWebEngine();
JSObject strO = getString(engine);
strO.setMember("iAmWrongMember", null);
resultObject = strO.getMember("iAmWrongMember");
System.out.println(resultObject);
}
});
doWait(new Tester() {
public boolean isPassed() {
return (resultObject == null);
}
});
Assert.assertNull(resultObject);
}