List of usage examples for com.google.gwt.core.client JsArrayString push
public final native void push(String value) ;
From source file:org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.java
License:Open Source License
public final RnwOptionCompletionResult getCompletions(String line, int optionsStartOffset, int cursorPos, RnwWeave rnwWeave) {/* ww w . jav a2s . c om*/ assert cursorPos >= optionsStartOffset : "cursorPos was less than optionsStartOffset"; String linePart = line.substring(optionsStartOffset, cursorPos); // This can be pretty simple because Noweb doesn't allow = or , to appear // in names or values (i.e. no quotes or escaping to make parsing more // complicated). String token = null; JsArrayString completions = JsArrayString.createArray().cast(); ArrayList<String> names = new ArrayList<String>(); ArrayList<String> values = new ArrayList<String>(); parseRnwChunkHeader(linePart, names, values); assert names.size() == values.size(); String name = names.size() == 0 ? null : names.get(names.size() - 1); String value = values.size() == 0 ? null : values.get(values.size() - 1); if (value != null) { token = value; // If value is not null, we follow an equal sign; try to complete // based on value. completeValue(rnwWeave, name, value, completions); } else if (name != null) { token = name; for (String optionName : this.getOptions()) if (optionName.startsWith(name)) completions.push(optionName + "="); } RnwOptionCompletionResult result = new RnwOptionCompletionResult(); result.token = token; result.completions = completions; return result; }
From source file:org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.java
License:Open Source License
private void completeValue(RnwWeave rnwWeave, String name, String value, JsArrayString completions) { String optionType = StringUtil.notNull(this.getOptionType(name)); if (optionType.equals("logical")) { CompletionOptions options = new CompletionOptions(); options.addOption("TRUE", 0); options.addOption("FALSE", 0); if (!rnwWeave.usesCodeForOptions()) { // Legacy Sweave is case insensitive options.addOption("true", 1); options.addOption("false", 1); options.addOption("True", 2); options.addOption("False", 2); }/*from ww w. j av a 2s . c om*/ for (String logical : options.getCompletions(value)) completions.push(logical); } else if (optionType.equals("list")) { CompletionOptions options = new CompletionOptions(); ArrayList<String> optionValues = this.getOptionValues(name); if (!rnwWeave.usesCodeForOptions()) { // Legacy Sweave for (String optionVal : optionValues) options.addOption(optionVal, 0); } else { for (String optionVal : optionValues) options.addOption("'" + optionVal + "'", 0); for (String optionVal : optionValues) options.addOption('"' + optionVal + '"', 1); } for (String option : options.getCompletions(value)) completions.push(option); } }
From source file:org.sigmah.offline.indexeddb.Database.java
License:Open Source License
/** * Open a new transaction in the given mode. * // w w w . ja va 2 s .com * @param mode Write mode. * @param stores Stores to access during the transaction. * @return A new transaction. * @throws IndexedDBException If an error occurs when opening the transaction. */ public Transaction<S> getTransaction(Transaction.Mode mode, Collection<S> stores) throws IndexedDBException { final JsArrayString array = (JsArrayString) JavaScriptObject.createArray(); for (final S store : stores) { array.push(store.name()); } try { return new Transaction<S>(nativeDatabase.getTransaction(array, mode.getArgument()), mode, stores); } catch (JavaScriptException e) { throw new IndexedDBException(e); } }
From source file:org.sigmah.offline.js.ExtendedComputationElementJS.java
License:Open Source License
/** * Creates a new <code>ComputationJS</code> object with the given element. * /*from ww w .j av a2 s. c o m*/ * @param computationElement * Computation element to map. * @return A new <code>ComputationJS</code>. */ public static ExtendedComputationElementJS toJavaScript(final ComputationElementDTO computationElement) { final JsArrayString dependencies = Values.createJavaScriptArray(JsArrayString.class); int contribution = 0; final Computation computation = Computations.parse(computationElement.getRule(), Collections.<FlexibleElementDTO>emptyList()); for (final Dependency dependency : computation.getDependencies()) { if (dependency instanceof CollectionDependency) { dependencies.push(((CollectionDependency) dependency).flexibleElementString()); } if (dependency instanceof ContributionDependency) { contribution = 1; } } final ExtendedComputationElementJS computationJS = Values.createJavaScriptObject(); computationJS.setId(computationElement.getId()); computationJS.setLabel(computationElement.getLabel()); computationJS.setCode(computationElement.getCode()); computationJS.setRule(computationElement.getRule()); computationJS.setContribution(contribution); computationJS.setDependencies(dependencies); computationJS.setProjectModel(computationElement.getProjectModel()); return computationJS; }
From source file:org.sigmah.offline.js.ProfileJS.java
License:Open Source License
public void setGlobalPermissions(Set<GlobalPermissionEnum> globalPermissions) { if (globalPermissions != null) { JsArrayString array = Values.createJavaScriptArray(JsArrayString.class); for (final GlobalPermissionEnum globalPermission : globalPermissions) { if (globalPermission != null) { array.push(globalPermission.name()); }//ww w. j a v a 2 s . c o m } setGlobalPermissions(array); } }
From source file:org.talend.mdm.webapp.welcomeportal.client.widget.DataChart.java
License:Open Source License
@Override protected void furtherInitPlot() { PlotModel model = plot.getModel();//w w w .j a v a 2 s . co m PlotOptions plotOptions = plot.getOptions(); plotOptions.setGlobalSeriesOptions(GlobalSeriesOptions.create() .setPieSeriesOptions(PieSeriesOptions.create().setShow(true).setRadius(1).setInnerRadius(0.2) .setHighlight(Highlight.create().setOpacity(0.3)) .setLabel(com.googlecode.gflot.client.options.PieSeriesOptions.Label.create().setShow(true) .setRadius(3d / 4d).setBackground(Background.create().setOpacity(0.8)) .setThreshold(0.05).setFormatter(new Formatter() { @Override public String format(String label, Series series) { return "<div class='welcomePieChartLabel'>" //$NON-NLS-1$ + label + "<br/>" + formatter.format(series.getData().getY(0)) //$NON-NLS-1$ + " / " //$NON-NLS-1$ + formatter.format(percentageValueMap.get(label)) + "%</div>"; //$NON-NLS-1$ } })))); plotOptions.setLegendOptions(LegendOptions.create().setShow(false)); plotOptions.setGridOptions(GridOptions.create().setHoverable(true)); JsArrayString colors = JavaScriptObject.createArray().cast(); colors.push(SERIES_1_COLOR); colors.push(SERIES_2_COLOR); colors.push(SERIES_3_COLOR); colors.push(SERIES_4_COLOR); plotOptions.setDefaultColorTheme(colors); // create series and add data for (String entityName : entityNamesSorted) { SeriesHandler seriesEntity = model.addSeries(Series.of(entityName)); seriesEntity.add(DataPoint.of(entityName, (Integer) chartData.get(entityName))); } plot.addDomHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { hoveringTXT = ""; //$NON-NLS-1$ entityName = ""; //$NON-NLS-1$ portal.setStyleAttribute("cursor", "default"); //$NON-NLS-1$//$NON-NLS-2$ } }, MouseOutEvent.getType()); plot.addDomHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { cursorX = event.getClientX() + 10; cursorY = event.getClientY() - 10; } }, MouseMoveEvent.getType()); plot.addLoadHandler(new PlotLoadEvent.Handler() { @Override public void onLoad(PlotLoadEvent event) { // Flot has limitations on the pie labels // If it cannot be drawn it creates a div of class error with message // "Could not draw pie with labels contained inside canvas" // Workaround the issue by redrawing but without the labels boolean errorOccurred = plot.getParent().getElement().getInnerHTML() .contains("Could not draw pie with labels contained inside canvas"); //$NON-NLS-1$ if (errorOccurred) {// don't show labels if error occurred plot.getOptions().getGlobalSeriesOptions().getPieSeriesOptions().getLabel().setShow(false); plot.redraw(); } else {// reset to true for next creation plot.getOptions().getGlobalSeriesOptions().getPieSeriesOptions().getLabel().setShow(true); } } }); }
From source file:org.thechiselgroup.choosel.protovis.client.jsutil.JsUtils.java
License:Apache License
public final static JsArrayString toJsArrayString(String... values) { JsArrayString array = createJsArrayString(); for (String value : values) { array.push(value); }// w w w. j a v a2s .c o m return array; }
From source file:org.vaadin.addon.leaflet.client.vaadin.LeafletMapConnector.java
License:Apache License
private void setBaseLayers() { // clear old layers for (ILayer l : layers.values()) { map.removeLayer(l);// www .j av a 2 s .co m } layers.clear(); // add layers from state BaseLayer[] baseLayers = getState().getBaseLayers(); if (baseLayers != null) { for (BaseLayer baseLayer : baseLayers) { // suck big time in V7, can't access the raw json, should use // e.g. gson and serialize as string in state Options tileOptions = new Options(); tileOptions.setProperty("attribution", baseLayer.getAttributionString()); if (baseLayer.getDetectRetina() != null && baseLayer.getDetectRetina()) { tileOptions.setProperty("detectRetina", true); } if (baseLayer.getSubDomains() != null) { JsArrayString domain = JsArrayString.createArray().cast(); for (String a : baseLayer.getSubDomains()) { domain.push(a); } tileOptions.setProperty("subdomains", (JSObject) domain.cast()); } if (baseLayer.getMaxZoom() != null) { tileOptions.setProperty("maxZoom", baseLayer.getMaxZoom()); } if (baseLayer.getTms() != null && baseLayer.getTms()) { tileOptions.setProperty("tms", true); } if (baseLayer.getOpacity() != null) { tileOptions.setProperty("opacity", baseLayer.getOpacity()); } if (baseLayer.getWms() != null && baseLayer.getWms() == true) { if (baseLayer.getLayers() != null) { tileOptions.setProperty("layers", baseLayer.getLayers()); } if (baseLayer.getStyles() != null) { tileOptions.setProperty("styles", baseLayer.getStyles()); } if (baseLayer.getFormat() != null) { tileOptions.setProperty("format", baseLayer.getFormat()); } if (baseLayer.getTransparent() != null && baseLayer.getTransparent()) { tileOptions.setProperty("transparent", true); } if (baseLayer.getVersion() != null) { tileOptions.setProperty("version", baseLayer.getVersion()); } WmsLayer layer = new WmsLayer(baseLayer.getUrl(), tileOptions); map.addLayer(layer); layers.put(baseLayer, layer); } else { TileLayer layer = new TileLayer(baseLayer.getUrl(), tileOptions); map.addLayer(layer); layers.put(baseLayer, layer); } } } }
From source file:org.xwiki.gwt.wysiwyg.client.WysiwygEditorApi.java
License:Open Source License
/** * @return the list of editor configuration parameters *///from w ww. j a v a2 s . c o m public JsArrayString getParameterNames() { JsArrayString parameterNames = JavaScriptObject.createArray().cast(); for (String parameterName : editor.getConfigurationSource().getParameterNames()) { parameterNames.push(parameterName); } return parameterNames; }
From source file:tigase.jaxmpp.gwt.client.connectors.WebSocket.java
License:Open Source License
public WebSocket(String url, String protocol, WebSocketCallback callback) { this.callback = callback; JsArrayString jsProtocols = (JsArrayString) JsArrayString.createArray(); if (protocol != null) { jsProtocols.push(protocol); }/*w ww . j a va 2 s .c o m*/ this.jsWebSocket = createJSWebSocket(url, jsProtocols, this); }