// Given an array of tabs, replace any obsolete entries with their // replacements public static void replaceObsoleteTabs(JsArrayString tabs) { for (int idx = 0; idx < tabs.length(); idx++) { if (indexOfReplacedTab(tabs.get(idx)) >= 0) { tabs.set(idx, getReplacementTabs()[idx]); } } }
/** * IDs of map types to show in the control. * * @param ids */ public final void setMapTypeIds(ArrayList<MapTypeId> ids) { JsArrayString strings = JsArrayString.createArray().cast(); for (MapTypeId id : ids) { strings.push(id.getValue()); } setMapTypeIds(strings); }
protected void onReceiving(int statusCode, String responseText, boolean connected) { if (statusCode != Response.SC_OK) { if (!connected) { expectingDisconnection = true; listener.onError(new StatusCodeException(statusCode, responseText), connected); } } else { int index = responseText.lastIndexOf(SEPARATOR); if (index > read) { List<Serializable> messages = new ArrayList<Serializable>(); JsArrayString data = AtmosphereClient.split(responseText.substring(read, index), SEPARATOR); int length = data.length(); for (int i = 0; i < length; i++) { if (aborted) { return; } parse(data.get(i), messages); } read = index + 1; if (!messages.isEmpty()) { listener.onMessage(messages); } } if (!connected) { if (expectingDisconnection) { listener.onDisconnected(); } else { listener.onError(new AtmosphereClientException("Unexpected disconnection"), false); } } } }
/** * Display one or more error messages associated with this field, using msgTarget to determine how * to display the messages and applying invalidCls to the field's UI element. * * <p><b>Note</b>: this method does not cause the Field's validate or isValid methods to return * false if the value does pass validation. So simply marking a Field as invalid will not prevent * submission of forms submitted with the Ext.form.action.Submit.clientValidation option set. */ public void markInvalid(String... values) { JsArrayString peers = JsArray.createArray().cast(); for (String s : values) { peers.push(s); } _markInvalid(peers); }
private static JsArrayString fromListOfString(List<String> values) { JsArrayString strings = JsArray.createArray().cast(); for (String s : values) { strings.push(s); } return strings; }
public void setDepthColors(String... values) { JsArrayString peers = JsArrayString.createArray().cast(); for (String s : values) { peers.push(s); } this.setDepthColors(peers); }
public void setCategories(final String[] categories) { final JsArrayString array = JsArrayString.createArray().cast(); for (final String category : categories) { array.push(category); } final JSObject jsObject = array.cast(); getJSObject().setProperty(Property.CATEGORIES, jsObject); }
private final String[] getScopes() { JsArrayString jsa = getScopesNative(); String[] arr = new String[jsa.length()]; for (int i = 0; i < jsa.length(); i++) { arr[i] = jsa.get(i); } return arr; }
public void addComponentInheritanceInfo(ValueMap valueMap) { JsArrayString keyArray = valueMap.getKeyArray(); for (int i = 0; i < keyArray.length(); i++) { String key = keyArray.get(i); int value = valueMap.getInt(key); componentInheritanceMap.put(Integer.parseInt(key), value); } }
/** IDs of map types to show in the control. */ public final ArrayList<MapTypeId> getMapTypeIds() { ArrayList<MapTypeId> ids = new ArrayList<MapTypeId>(); JsArrayString values = _getMapTypeIds(); for (int index = 0; index < values.length(); index++) { ids.add(MapTypeId.fromValue(values.get(index))); } return ids; }
public List<String> getTextPropertyNames() { final JsArrayString nativeNames = getNativePropertyNames(getJSObject()); final List<String> names = new ArrayList<String>(); for (int i = 0; i < nativeNames.length(); i++) { names.add(nativeNames.get(i)); } return names; }
public List<String> getCategoryList() { final List<String> categories = new ArrayList<String>(); final JsArrayString jsCategories = getCategories(); for (int i = 0; i < jsCategories.length(); i++) { categories.add(jsCategories.get(i)); } return categories; }
@Deprecated public final Set<String> keySet() { JsArrayString array = keys(); Set<String> set = new HashSet<String>(); for (int i = 0; i < array.length(); i++) { set.add(array.get(i)); } return set; }
@Override @SuppressWarnings("unchecked") public String getAddressPath(int n) { initArray(this, keyAddressPath); JsArrayString array = getPropertyAsObject(this, keyAddressPath).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
public void addProjectIcon(Project project) { FlowPanel projectPanel = new FlowPanel(); JsArrayString appStrings = project.getApps(); String description = ""; for (int i = 0; i < appStrings.length(); i++) { if (i == appStrings.length() - 1) description += appStrings.get(i); else description += appStrings.get(i) + ", "; } final String projectName = project.getName(); final String appNames = description; Image projectImg = new Image(res.projectdefaulticon2().getUrl()); projectImg.setPixelSize(64, 64); projectPanel.add(projectImg); projectPanel.add(new Label(projectName)); final FocusPanel testLabel = new FocusPanel(); testLabel.add(projectPanel); testLabel.setStyleName(style.projectIcon()); testLabel.addMouseOverHandler( new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { testLabel.setStyleName(style.projectIconActive()); desc.show(); desc.setPopupPosition( testLabel.getAbsoluteLeft() + testLabel.getOffsetWidth(), testLabel.getAbsoluteTop() - 5); desc.setTitle("Applications"); desc.setText(appNames); } }); testLabel.addMouseOutHandler( new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { testLabel.setStyleName(style.projectIcon()); desc.hide(); } }); testLabel.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { testLabel.setStyleName(style.projectIcon()); eventBus.fireEvent( new PanelTransitionEvent( PanelTransitionEvent.TransitionTypes.DASHBOARD, projectName)); } }); projectIconsFlowPanel.add(testLabel); iconMap.put(project.getName(), projectIconsFlowPanel.getWidgetIndex(testLabel)); }
/** The <code>which</code> parameter is used to support the deprecated API. */ private static StyleElement flush(JavaScriptObject which) { StyleElement toReturn = null; StyleElement maybeReturn; if (toInjectAtStart.length() != 0) { String css = toInjectAtStart.join(""); maybeReturn = StyleInjectorImpl.IMPL.injectStyleSheetAtStart(css); if (toInjectAtStart == which) { toReturn = maybeReturn; } toInjectAtStart.setLength(0); } if (toInject.length() != 0) { String css = toInject.join(""); maybeReturn = StyleInjectorImpl.IMPL.injectStyleSheet(css); if (toInject == which) { toReturn = maybeReturn; } toInject.setLength(0); } if (toInjectAtEnd.length() != 0) { String css = toInjectAtEnd.join(""); maybeReturn = StyleInjectorImpl.IMPL.injectStyleSheetAtEnd(css); if (toInjectAtEnd == which) { toReturn = maybeReturn; } toInjectAtEnd.setLength(0); } needsInjection = false; return toReturn; }
private void init() { Map<String, Element> containers = contentContainerFactory.list(); for (String containerName : containers.keySet()) { List<String> containerStyles = new ArrayList<String>(); styles.put(containerName, containerStyles); Element element = containers.get(containerName); List<JavaScriptRegExp> matchers = new ArrayList<JavaScriptRegExp>(); if (element.hasAttribute("id")) { matchers.add( JavaScriptRegExp.create( "^\\s*#" + element.getAttribute("id") + "\\s+>?\\s*([^\\s,]+)")); } String[] cssClasseNames = element.getClassName().trim().split("\\s+"); for (String cssClassName : cssClasseNames) { matchers.add(JavaScriptRegExp.create("^\\s*." + cssClassName + "\\s+>?\\s*([^\\s,]+)")); } JsArray<StyleSheet> styleSheets = StyleSheet.getAll(); for (int i = 0; i < styleSheets.length(); i++) { StyleSheet styleSheet = styleSheets.get(i); if (styleSheet == null) continue; // In Chrome, if stylesheet originates from a different domain, // ss.cssRules simply won't exist. I believe the same is true for IE, but // I haven't tested it. // // In Firefox, if stylesheet originates from a different domain, trying // to access ss.cssRules will throw a SecurityError. Hence, we must use // try/catch to detect this condition in Firefox. JsArray<CSSStyleRule> cssRules; try { cssRules = styleSheet.cssRules(); } catch (JavaScriptException e) { cssRules = null; } if (cssRules == null) continue; for (int j = 0; j < cssRules.length(); j++) { CSSStyleRule rule = cssRules.get(j); if (rule == null) continue; if (rule.selectorText() == null) continue; String[] selectors = rule.selectorText().split(","); for (String selector : selectors) { for (JavaScriptRegExp matcher : matchers) { JsArrayString matches = matcher.match(selector); if (matches != null && matches.length() == 2 && !containerStyles.contains(matches.get(1))) { containerStyles.add(matches.get(1)); } } } } } } }
/** * Restricts the Place search results to Places with a type matching at least one of the specified * types in this array. Valid types are given <a href= * "https://developers.google.com/maps/documentation/places/supported_types" >here</a>. */ public final AutocompleteType[] getTypes() { JsArrayString at = getTypesImpl(); if (at == null) { return null; } AutocompleteType[] types = new AutocompleteType[at.length()]; for (int i = 0; i < at.length(); i++) { types[i] = AutocompleteType.fromValue(at.get(i)); } return types; }
private void redrawVocabularies(TaxonomyDto taxonomy, FlowPanel panelTaxonomy) { JsArrayString vocabularies = JsArrays.toSafeArray(taxonomy.getVocabulariesArray()); if (vocabularies.length() > 0) { panelTaxonomy.add(new Heading(5, translations.vocabulariesLabel())); FlowPanel vocabulariesPanel = new FlowPanel(); for (int i = 0; i < vocabularies.length(); i++) { vocabulariesPanel.add(getVocabularyLink(getUiHandlers(), taxonomy, vocabularies.get(i))); } panelTaxonomy.add(vocabulariesPanel); } }
private boolean modePresent(final String modeName) { if (modeName == null) { return false; } final JsArrayString modeNames = this.codeMirror.modeNames(); for (int i = 0; i < modeNames.length(); i++) { if (modeName.equals(modeNames.get(i))) { return true; } } return false; }
private boolean sameElements(JsArrayString a, String[] b) { if (a.length() != b.length) return false; ArrayList<String> a1 = new ArrayList<String>(); for (int i = 0; i < a.length(); i++) a1.add(a.get(i)); Collections.sort(a1); Arrays.sort(b); for (int i = 0; i < b.length; i++) if (!a1.get(i).equals(b[i])) return false; return true; }
private String getUri() { UriBuilder uriBuilder = tableIsView() ? UriBuilders.DATASOURCE_VIEW_VARIABLES.create() : UriBuilders.DATASOURCE_TABLE_VARIABLES.create(); for (int i = nb_deleted, added = 0; i < variableNames.length() && added < BATCH_SIZE; i++, added++) { uriBuilder.query("variable", variableNames.get(i)); } return uriBuilder.build(table.getDatasourceName(), table.getName()); }
public void addComponentMappings(ValueMap valueMap, WidgetSet widgetSet) { JsArrayString keyArray = valueMap.getKeyArray(); for (int i = 0; i < keyArray.length(); i++) { String key = keyArray.get(i).intern(); int value = valueMap.getInt(key); tagToServerSideClassName.put(value, key); } for (int i = 0; i < keyArray.length(); i++) { String key = keyArray.get(i).intern(); int value = valueMap.getInt(key); widgetSet.ensureConnectorLoaded(value, this); } }
/** Just make sure that reentrant behavior doesn't fail. */ public static void testReentrantCalls() { if (!GWT.isScript()) { // sample is useless in Development Mode return; } JsArrayString start = sample(); JsArrayString stack = countDown(5); assertNotNull(stack); assertTrue(stack.length() > 0); JsArrayString end = sample(); assertEquals(start, end); }
public boolean isEquals(BucketsOverlay other) { if (super.equals(other)) return true; final JsArrayString keys = getKeysNative(); final JsArrayString otherKeys = other.getKeysNative(); if (arraysEquals(keys, otherKeys)) { for (int i = 0; i < keys.length(); i++) { if (!arraysEquals(getNative(keys.get(i)), other.getNative(otherKeys.get(i)))) { return false; } } return true; } return false; }
/** * Checks the given error for message flooding * * @param error client error to check */ private void checkMessageFlooding(ClientErrorDto error) { boolean match = false; if (latestClientError != null && latestClientError.getStatus().equals(error.getStatus())) { JsArrayString array1 = latestClientError.getArgumentsArray(); JsArrayString array2 = error.getArgumentsArray(); match = array1.toString().equals(array2.toString()); } if (match) { currentErrorCount++; // one more occurrence of the same error } else { latestClientError = error; currentErrorCount = 0; } }
public JsArrayString getCategories() { final JSObject property = getJSObject().getProperty(Property.CATEGORIES); if (property == null) { return JsArrayString.createArray().cast(); } else { return property.cast(); } }
@Override public void onDeleteVariables(List<VariableDto> variableDtos) { if (variableDtos.isEmpty()) { fireEvent(NotificationEvent.newBuilder().error("DeleteVariableSelectAtLeastOne").build()); } else { JsArrayString variableNames = JsArrays.create().cast(); for (VariableDto variable : variableDtos) { variableNames.push(variable.getName()); } deleteVariablesConfirmation = new RemoveVariablesRunnable(variableNames); fireEvent( ConfirmationRequiredEvent.createWithMessages( deleteVariablesConfirmation, translationMessages.removeVariables(), translationMessages.confirmRemoveVariables(variableNames.length()))); } }
private CMEditorOptionsOverlay getConfiguration() { final CMEditorOptionsOverlay options = CMEditorOptionsOverlay.create(); // show line numbers options.setLineNumbers(true); // set a theme options.setTheme("codenvy"); // autoclose brackets/tags, match brackets/tags options.setProperty(AUTOCLOSE_BRACKETS, true); options.setProperty(MATCH_BRACKETS, true); options.setProperty(AUTOCLOSE_TAGS, true); // folding options.setProperty(FOLD_GUTTER, true); // gutters - define 2 : line and fold final JsArrayString gutters = JsArray.createArray(4).cast(); gutters.push(CodemirrorGutter.CODE_MIRROR_GUTTER_BREAKPOINTS); gutters.push(CodemirrorGutter.CODE_MIRROR_GUTTER_ANNOTATIONS); gutters.push(CodemirrorGutter.CODE_MIRROR_GUTTER_LINENUMBERS); gutters.push(CodemirrorGutter.CODE_MIRROR_GUTTER_FOLDGUTTER); options.setGutters(gutters); // highlight matching tags final CMMatchTagsConfig matchTagsConfig = CMMatchTagsConfig.create(); matchTagsConfig.setBothTags(true); options.setProperty(OptionKey.MATCH_TAGS, matchTagsConfig); // highlight active line options.setProperty(STYLE_ACTIVE_LINE, true); // activate continueComments addon options.setProperty(OptionKey.CONTINUE_COMMENT, true); /* simple and overlay style scrollbar fix appearance on firefox */ options.setScrollbarStyle("simple"); return options; }
private ImportCommandOptionsDto createImportCommandOptionsDto(@Nullable String selectedFile) { ImportCommandOptionsDto dto = ImportCommandOptionsDto.create(); dto.setDestination(importConfig.getDestinationDatasourceName()); if (importConfig.isArchiveMove()) { dto.setArchive(importConfig.getArchiveDirectory()); JsArrayString selectedFiles = JavaScriptObject.createArray().cast(); selectedFiles.push(selectedFile); dto.setFilesArray(selectedFiles); } if (importConfig.isIdentifierSharedWithUnit()) { dto.setUnit(importConfig.getUnit()); dto.setForce(false); dto.setIgnore(true); } JsArrayString selectedTables = JavaScriptObject.createArray().cast(); for (String tableName : comparedDatasourcesReportPresenter.getSelectedTables()) { selectedTables.push(importConfig.getTransientDatasourceName() + "." + tableName); } dto.setTablesArray(selectedTables); return dto; }