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));
              }
            }
          }
        }
      }
    }
  }
Esempio n. 2
0
  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));
  }
  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);
    }
  }
  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);
        }
      }
    }
  }
Esempio n. 5
0
    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;
    }
Esempio n. 6
0
 // 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]);
     }
   }
 }
 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);
   }
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 /** 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;
 }
Esempio n. 11
0
 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;
 }
Esempio n. 12
0
 @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);
 }
Esempio n. 14
0
 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);
   }
 }
 /**
  * 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 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;
 }
Esempio n. 17
0
  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;
  }
Esempio n. 18
0
    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());
    }
  private RmdFrontMatterOutputOptions transferOptions(
      RmdFrontMatter frontMatter, RmdTemplate template, String format) {
    RmdFrontMatterOutputOptions result = RmdFrontMatterOutputOptions.create();

    // loop over each option applicable to the new format; if it's
    // transferable, try to find it in one of the other formats
    JsArrayString options = template.getFormat(format).getOptions();
    for (int i = 0; i < options.length(); i++) {
      String optionName = options.get(i);
      RmdTemplateFormatOption option = template.getOption(optionName);
      if (!option.isTransferable()) continue;

      // option is transferable, is it present in another front matter entry?
      JsArrayString formats = frontMatter.getFormatList();
      for (int j = 0; j < formats.length(); j++) {
        RmdFrontMatterOutputOptions outOptions = frontMatter.getOutputOption(formats.get(j));
        if (outOptions == null) continue;
        String val = outOptions.getOptionValue(optionName);
        if (val != null) result.setOptionValue(option, val);
      }
    }

    return result;
  }
Esempio n. 20
0
 public String getCategoriesAsString() {
   final StringBuilder catBuilder = new StringBuilder();
   final JsArrayString categories = getCategories();
   if (categories.length() > 0) {
     if (categories.length() == 1) {
       catBuilder.append("Category: ");
     } else {
       catBuilder.append("Categories: ");
     }
     for (int i = 0; i < categories.length(); i++) {
       catBuilder.append(categories.get(i));
       if (i != (categories.length() - 1)) {
         catBuilder.append(", ");
       }
     }
   }
   return catBuilder.toString();
 }
Esempio n. 21
0
 private ArrayList<String> convertList(JsArrayString jsList) {
   ArrayList<String> list = new ArrayList<String>();
   for (int i = 0; i < jsList.length(); i++) list.add(jsList.get(i));
   return list;
 }
Esempio n. 22
0
  public final int getConsoleIndex() {
    JsArrayString panes = getPanes();
    for (int i = 0; i < panes.length(); i++) if (panes.get(i).equals("Console")) return i;

    throw new IllegalStateException();
  }
Esempio n. 23
0
 public final boolean getConsoleLeft() {
   JsArrayString panes = getPanes();
   return panes.get(0).equals("Console") || panes.get(1).equals("Console");
 }
 private static void assertEquals(JsArrayString start, JsArrayString end) {
   assertEquals("length", start.length(), end.length());
   for (int i = 0, j = start.length(); i < j; i++) {
     assertEquals("frame " + i, start.get(i), end.get(i));
   }
 }
Esempio n. 25
0
 private void setHistory(JsArrayString history) {
   ArrayList<String> historyList = new ArrayList<String>(history.length());
   for (int i = 0; i < history.length(); i++) historyList.add(history.get(i));
   historyManager_.setHistory(historyList);
   browseHistoryManager_.resetPosition();
 }