List of usage examples for com.google.gwt.core.client JavaScriptObject cast
@Override @SuppressWarnings("unchecked") public <T extends JavascriptObjectEquivalent> T cast()
From source file:com.rhizospherejs.gwt.client.renderer.NativeRenderer.java
License:Open Source License
/** * Asks the GWT renderer managed by this class to perform style changes to a * model rendering./* w w w. j av a 2 s . com*/ * @param jso A JavaScriptObject wrapping the Rhizosphere model whose * associated rendering should be restyled. * @param props A key-value map of the style properties to set. * @param revert Whether this set of changes reverts the model rendering to * its original style or not. */ @SuppressWarnings("unchecked") public void delegateChangeStyle(JavaScriptObject jso, JavaScriptObject props, boolean revert) { T model = extractModel(jso); assert model != null; // NOTE: relies on the style being received from JSNI to match the // expectations of the Style class. Style style = props.cast(); Set<String> keys = new JSONObject(props).keySet(); ((HasChangeStyle<T>) gwtRenderer).changeStyle(model, modelWidgetMap.get(jso), keys, style, revert); }
From source file:com.rhizospherejs.gwt.client.renderer.RenderingHints.java
License:Open Source License
/** * Creates a new instance from a JSNI representation of the same hints. *///w w w . j a v a 2 s. co m static final RenderingHints create(JavaScriptObject nativeRenderingHints) { return nativeRenderingHints.cast(); }
From source file:com.vaadin.addon.spreadsheet.client.SheetTabSheet.java
public void setTabs(String[] tabNames, boolean clearScrollPosition) { // remove unnecessary tabs if (clearScrollPosition) { container.getStyle().clearMarginLeft(); tabScrollIndex = 0;/*from w w w.j a va2 s . c o m*/ tabScrollMargin = 0; } for (int i = tabNames.length; i < tabs.length(); i++) { ((Element) tabs.get(i).cast()).removeFromParent(); } tabs.setLength(tabNames.length); for (int i = 0; i < tabNames.length; i++) { JavaScriptObject jso = tabs.get(i); if (jso != null) { ((Element) jso.cast()).setInnerText(tabNames[i]); } else { Element newTab = createTabElement(tabNames[i]); container.appendChild(newTab); tabs.set(i, newTab); } } if (selectedTabIndex >= (tabs.length())) { selectedTabIndex = -1; } showHideScrollIcons(); }
From source file:com.vaadin.client.componentlocator.LegacyLocatorStrategy.java
License:Apache License
/** * Generates a String locator using domChild[x] parts for the element * relative to the baseElement./*from www .ja v a 2 s . c o m*/ * * @param element * The target element * @param baseElement * The starting point for the locator. The generated path is * relative to this element. * @return A String locator that can be used to locate the target element * using {@link #getElementByDOMPath(Element, String)} or null if * the locator String cannot be created. */ private String getDOMPathForElement(Element element, Element baseElement) { Element e = element; String path = ""; while (true) { int childIndex = -1; Element siblingIterator = e; while (siblingIterator != null) { childIndex++; siblingIterator = siblingIterator.getPreviousSiblingElement().cast(); } path = PARENTCHILD_SEPARATOR + "domChild[" + childIndex + "]" + path; JavaScriptObject parent = e.getParentElement(); if (parent == null) { return null; } // The parent check is a work around for Firefox 15 which fails to // compare elements properly (#9534) if (parent == baseElement) { break; } e = parent.cast(); } return path; }
From source file:gwt.g2d.client.graphics.canvas.CanvasGradient.java
License:Apache License
public static CanvasGradient as(JavaScriptObject jsObject) { return jsObject.cast(); }
From source file:gwt.g2d.client.graphics.canvas.CanvasPixelArray.java
License:Apache License
/** * Casts the JavaScriptObject into a CanvasPixelArray. * Requires: the given JavaScriptObject must be an instance of * CanvasPixelArray.//w w w . j a va 2s . com * * @param pixelArray */ public static CanvasPixelArray as(JavaScriptObject pixelArray) { return pixelArray.cast(); }
From source file:gwt.g2d.client.graphics.canvas.ContextImpl.java
License:Apache License
public static ContextImpl as(JavaScriptObject jsContext) { return jsContext.cast(); }
From source file:gwt.g3d.client.gl2.GL2Impl.java
License:Apache License
public static GL2Impl as(JavaScriptObject jsContext) { return jsContext.cast(); }
From source file:gwt.g3d.client.gl2.WebGLContextAttributes.java
License:Apache License
/** * Converts a JavaScriptObject to this WebGLContextAttributes. * //from www . ja v a 2 s .c o m * @param contextAttribs a JavaScriptObject whose type is * WebGLContextAttributes. */ WebGLContextAttributes(JavaScriptObject contextAttribs) { impl = contextAttribs.cast(); }
From source file:gwt.material.design.client.api.ApiRegistry.java
License:Apache License
/** * Will unregister the provided {@link ApiFeature} in to map of features. *//* www.j a v a2 s . co m*/ public static void unregister(ApiFeature apiFeature) { JavaScriptObject scriptObject = features.get(apiFeature); if (scriptObject != null) { if (scriptObject.cast() instanceof Element) { Element scriptElement = scriptObject.cast(); scriptElement.removeFromParent(); } } features.remove(apiFeature); }