List of usage examples for com.google.gwt.core.client JavaScriptObject cast
@Override @SuppressWarnings("unchecked") public <T extends JavascriptObjectEquivalent> T cast()
From source file:org.nsesa.editor.gwt.core.client.ui.rte.ckeditor.CKEditorVisualStructureInsertionPlugin.java
License:EUPL
private void fireEvent(JavaScriptObject jsObject, boolean moreTagsSelected, String selectedText) { Element el = jsObject.cast(); clientFactory.getEventBus()/* w ww . j a v a2 s . co m*/ .fireEvent(new VisualStructureSelectionChangedEvent(el, moreTagsSelected, selectedText)); }
From source file:org.nsesa.editor.gwt.core.client.ui.rte.DefaultRichTextEditorPlugin.java
License:EUPL
/** * Create a list of overlay widgets from the editor body * * @param editor The editor//from w w w .ja v a2 s .c om * @param overlayFactory The factory used to create widgets * @return A List of overlay widgets */ protected List<OverlayWidget> getEditorBodyChildrenAsOverlay(JavaScriptObject editor, OverlayFactory overlayFactory) { List<OverlayWidget> result = new ArrayList<OverlayWidget>(); JavaScriptObject body = getBody(editor); if (body != null) { Element bodyElement = body.cast(); for (int i = 0; i < bodyElement.getChildCount(); i++) { final Node node = bodyElement.getChild(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = node.cast(); final OverlayWidget widget = overlayFactory.getAmendableWidget(element); if (widget != null) { result.add(widget); } } } } return result; }
From source file:org.nsesa.editor.gwt.core.client.ui.rte.DefaultRichTextEditorPlugin.java
License:EUPL
protected OverlayWidget getEditorBodyAsOverlay(JavaScriptObject editor, OverlayFactory overlayFactory) { JavaScriptObject body = getBody(editor); if (body != null) { Element bodyElement = body.cast(); return overlayFactory.getAmendableWidget(bodyElement); }//from ww w . j av a 2 s .c om return null; }
From source file:org.opencms.ade.galleries.client.ui.CmsGalleryField.java
License:Open Source License
/** * Opens the upload dialog with the given file references to upload.<p> * * @param files the file references/* w w w .j a va 2 s. co m*/ */ private void openUploadWithFiles(JavaScriptObject files) { JsArray<CmsFileInfo> cmsFiles = files.cast(); List<CmsFileInfo> fileObjects = new ArrayList<CmsFileInfo>(); for (int i = 0; i < cmsFiles.length(); ++i) { fileObjects.add(cmsFiles.get(i)); } ((CmsDialogUploadButtonHandler) m_uploadButton.getButtonHandler()).openDialogWithFiles(fileObjects); }
From source file:org.opencms.ui.client.CmsUploadAreaConnector.java
License:Open Source License
/** * Opens the upload dialog with the given file references to upload.<p> * * @param files the file references//from w w w . ja va 2 s . c o m */ private void openUploadWithFiles(JavaScriptObject files) { JsArray<CmsFileInfo> cmsFiles = files.cast(); List<CmsFileInfo> fileObjects = new ArrayList<CmsFileInfo>(); for (int i = 0; i < cmsFiles.length(); ++i) { fileObjects.add(cmsFiles.get(i)); } CmsDialogUploadButtonHandler buttonHandler = new CmsDialogUploadButtonHandler( new Supplier<I_CmsUploadContext>() { /** * @see com.google.common.base.Supplier#get() */ public I_CmsUploadContext get() { return new I_CmsUploadContext() { public void onUploadFinished(List<String> uploadedFiles) { uploadFinished(uploadedFiles); } }; } }); buttonHandler.setIsTargetRootPath(true); buttonHandler.setTargetFolder(getState().getTargetFolderRootPath()); buttonHandler.openDialogWithFiles(fileObjects); }
From source file:org.primordion.xholon.base.Xholon.java
License:Open Source License
public void processReceivedMessage(IMessage msg) { if ((msg.getSignal() == ISignal.SIGNAL_XHOLON_CONSOLE_REQ) && (this.getActionList() != null)) { this.doAction((String) msg.getData()); } else if (msg.getSignal() == ISignal.SIGNAL_BPLEX) { // ex (using Dev Tools): var bait = temp1; bait["FishingRodbplex"].msg(-12, ["FishingRodbplex"], bait); // ex: var bait = temp1; bait["FishingRodbplex"].msg(-12, {bplexName:"FishingRodbplex"}, bait); Object data = msg.getData(); if (data == null) { return; }// ww w . ja v a 2s . c om String clogStr = "bplex msg sender:" + msg.getSender() + " this:" + this.getName(); String bplexName = null; if (data instanceof JavaScriptObject) { clogStr += " datatype:JavaScriptObject"; JavaScriptObject jso = (JavaScriptObject) data; bplexName = (String) getJsoPropertyValue(jso, "bplexName"); if (bplexName == null) { // this may be a JavaScript Array JsArrayMixed marr = jso.cast(); if (marr.length() == 0) { return; } bplexName = marr.getString(0); if (marr.length() > 1) { // TODO the msg might contain a second nested message, or some other IXholon(s) or Object(s) //anode = (Object)marr.getObject(1); } clogStr += " Array"; } else { clogStr += " Object"; } } else if (data instanceof Object[]) { clogStr += " datatype:Java Object[]"; Object[] oarr = (Object[]) data; if (oarr.length == 0) { return; } bplexName = (String) oarr[0]; } else { return; } consoleLog(clogStr); //this.setColor("indigo"); // this works if (msg.getSender() != this) { // send to next node in the bplex if (bplexName != null) { IXholon nextBplexNode = getPortNative(this, bplexName); if (nextBplexNode != null) { // send the same message contents to the next node in the bplex nextBplexNode.sendMessage(msg.getSignal(), data, msg.getSender()); } } } } else { forwardMessage(msg); } }
From source file:org.primordion.xholon.service.timeline.TimelineViewerChapJSON.java
License:Open Source License
@Override public IMessage processReceivedSyncMessage(IMessage msg) { Object response = null;// w ww. j a v a 2 s . c om Object data = msg.getData(); switch (msg.getSignal()) { case SIG_INITIALIZE_REQ: { // the data is an array of three items String outFileName = null; String modelName = null; Object root = null; if (data instanceof JavaScriptObject) { JavaScriptObject jso = (JavaScriptObject) data; JsArrayMixed arr = jso.cast(); outFileName = arr.getString(0); modelName = arr.getString(1); root = (Object) arr.getObject(2); } else if (data instanceof Object[]) { Object[] iobj = (Object[]) data; outFileName = (String) (iobj[0]); modelName = (String) (iobj[1]); root = (Object) (iobj[2]); } else { break; } initialize(outFileName, modelName, (IXholon) root); break; } case SIG_PARAMETERS_REQ: // there are no parameters yet break; case SIG_CAPTURE_REQ: { Object dateTimeObj = null; String content = null; if (data instanceof JavaScriptObject) { JavaScriptObject jso = (JavaScriptObject) data; JsArrayMixed arr = jso.cast(); // dateTimeObj can be a String or Date; for now assume it's a String dateTimeObj = arr.getString(0); content = arr.getString(1); } else if (data instanceof Object[]) { Object[] cobj = (Object[]) data; dateTimeObj = cobj[0]; content = (String) (cobj[1]); } capture(dateTimeObj, content); break; } case SIG_DRAW_REQ: drawTimeline(); break; default: return super.processReceivedSyncMessage(msg); } return new Message(SIG_PROCESS_RSP, response, this, msg.getSender()); }
From source file:org.rest.client.activity.RequestActivity.java
License:Apache License
private void fromGoogleDriveAction(final String entryId) { requestView.reset();//w w w .jav a 2 s .co m clientFactory.getChromeMessagePassing().postMessage(ExternalEventsFactory.EXT_GET_EXTERNAL_REQUEST_DATA, entryId, new BackgroundJsCallback() { @Override public void onSuccess(JavaScriptObject message) { ExternalDriveCreateResponse response; try { response = message.cast(); } catch (Exception e) { StatusNotification.notify("Unable to read response from background page", StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } if (response.isError()) { StatusNotification.notify(response.getErrorMessage(), StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } ExternalDriveCreateData data = response.getData(); if (data == null) { StatusNotification.notify("No data passed to application.", StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } Storage store = Storage.getSessionStorageIfSupported(); store.setItem(LocalStore.GOOGLE_DRIVE_CREATE_FOLDER_ID, data.getFolderId()); store.setItem(LocalStore.GOOGLE_DRIVE_CREATE_USER_ID, data.getUserId()); tutorialFactory = new TutorialFactory("gdriveCreate", true); requestView.setUpDriveTutorial(tutorialFactory); } @Override public void onError(String message) { Log.error("Error get gdrive data", message); } }); }
From source file:org.rest.client.jso.RequestObject.java
License:Apache License
/** * /*from w ww .jav a 2s . c o m*/ * @param clientFactory * @param callback */ public static void restoreLatest(final Callback<RequestObject, Throwable> callback) { Storage store = GWT.create(Storage.class); JSONObject jo = new JSONObject(); jo.put(StoreKeys.LATEST_REQUEST_KEY, new JSONObject(null)); store.getLocal().get(jo.getJavaScriptObject(), new StorageItemsCallback() { @Override public void onError(String message) { if (RestClient.isDebug()) { Log.error("RequestObject::restoreLatest - " + message); } } @Override public void onResult(JavaScriptObject data) { StorageResult<RequestObject> result = data.cast(); if (result == null) { callback.onSuccess(null); return; } RequestObject ro = result.getObject(StoreKeys.LATEST_REQUEST_KEY).cast(); if (ro != null) { callback.onSuccess(ro); } else { Log.error("Error perform RequestObject::restoreLatest. Result is null."); callback.onFailure( new Throwable("Error perform RequestObject::restoreLatest. Result is null.")); } } }); }
From source file:org.rstudio.studio.client.common.filetypes.FileTypeRegistry.java
License:Open Source License
private void satelliteEditFile(JavaScriptObject file, JavaScriptObject position, boolean highlightLine) { FileSystemItem fsi = file.cast(); FilePosition pos = position.cast();// w w w. ja va 2 s . co m editFile(fsi, pos); }