@Override public final boolean register(final Browser browser, final IDesignationListener<? super T> listener) { browserFunction = new BrowserFunction(browser, getCallbackName()) { @Override public Object function(final Object[] arguments) { super.function(arguments); final T result = createResult(arguments); getBrowser().getDisplay().asyncExec(new Runnable() { @Override public void run() { listener.onDesignation(result); } }); return null; } }; return browser.execute(getJsStartFunctionName() + "('" + getCallbackName() + "');"); }
private boolean open( RepositoryMeta repositoryMeta, boolean relogin, String errorMessage ) { new BrowserFunction( browser, "closeWindow" ) { @Override public Object function( Object[] arguments ) { browser.dispose(); dialog.close(); dialog.dispose(); return true; } }; controller.setCurrentRepository( repositoryMeta ); controller.setRelogin( relogin ); while ( !dialog.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } return result; }
private void addMapBrowserFunctions() { new BrowserFunction(mapBrowser, "getTreedataById"){ @Override public Object function( Object[] arguments ) { return getTreedataById(arguments); } }; }
private BrowserFunctionHandle(final String functionName, final BrowserFunction browserFunction) { this.functionName = functionName; this.browserFunction = browserFunction; }
private void addChartBrowserFunction( final Browser chartBrowser ) { new BrowserFunction(chartBrowser, "getTreeAndSlicesData"){ @Override public Object function( Object[] arguments ) { String treeId = arguments[0].toString(); JSONObject treeObject = id2TreeJsonMap.get(treeId); if (treeObject != null) { // tree data JSONObject treeObj = new JSONObject(); double minP = treeObject.getDouble(JSON_TREE_MIN_P); treeObj.put(JSON_TREE_MIN_P, minP); double maxP = treeObject.getDouble(JSON_TREE_MAX_P); treeObj.put(JSON_TREE_MAX_P, maxP); if (treeObject.has(JSON_TREE_DIAM)) { double diam = treeObject.getDouble(JSON_TREE_DIAM); treeObj.put(JSON_TREE_DIAM, diam); } double progressive = treeObject.getDouble(JSON_TREE_PROGRESSIVE); treeObj.put(JSON_TREE_PROGRESSIVE, progressive); double height = treeObject.getDouble(JSON_TREE_HEIGHT); treeObj.put(JSON_TREE_HEIGHT, height); if (treeObject.has(JSON_TREE_ID_MATCHED)) { String matchedTreeId = treeObject.getString(JSON_TREE_ID_MATCHED); treeObj.put(JSON_TREE_ID_MATCHED, matchedTreeId); for( String dir : JSON_DIRECTIONS ) { treeObj.put(JSON_TREE_PROGRESSIVE_MATCHED + dir, treeObject.getDouble(JSON_TREE_PROGRESSIVE_MATCHED + dir)); } double heightMatched = treeObject.getDouble(JSON_TREE_HEIGHT_MATCHED); treeObj.put(JSON_TREE_HEIGHT_MATCHED, heightMatched); } // slice data JSONObject slicesObj = treeObject.getJSONObject(JSON_TREE_SLICES); JSONArray profileDataArray = slicesObj.getJSONArray(chartBrowser.getData().toString()); Object[] returnObjs = {treeObj.toString(), profileDataArray.toString()}; return returnObjs; } return null; } }; }