Exemplo n.º 1
0
  /**
   * Update the content panel with the new history
   *
   * @param historyTokens the history tokens
   */
  public void update(final List<String> historyTokens) {
    HistoryResolver foundResolver = null;
    for (final HistoryResolver resolver : resolvers) {
      if (historyTokens.get(0).equals(resolver.getHistoryToken())) {
        currHistoryPath = historyTokens;
        foundResolver = resolver;
        break;
      }
    }

    if (foundResolver != null) {
      update(historyTokens, foundResolver);
    } else {
      HistoryUtils.newHistory(Theme.RESOLVER, "Error404.html");
    }
  }
Exemplo n.º 2
0
 @Override
 public void resolve(List<String> historyTokens, AsyncCallback<Widget> callback) {
   if (historyTokens.size() >= 1) {
     StringBuilder sb = new StringBuilder();
     boolean first = true;
     for (String token : historyTokens) {
       if (first) {
         first = false;
       } else {
         sb.append("/");
       }
       sb.append(token);
     }
     Theme theme = new Theme(sb.toString());
     callback.onSuccess(theme);
   } else {
     HistoryUtils.newHistory(Theme.RESOLVER);
     callback.onSuccess(null);
   }
 }
Exemplo n.º 3
0
  private void setWindowTitle(List<String> historyTokens) {
    String tokenI18N = "";
    boolean resolved = false;
    List<String> tokens = historyTokens;

    while (!resolved && tokens.size() > 0) {
      String token = StringUtils.join(tokens, "_");
      tokenI18N = messages.title(token).toUpperCase();

      if (tokenI18N.isEmpty()) {
        tokens = HistoryUtils.removeLast(tokens);
      } else {
        resolved = true;
      }
    }

    if (!resolved) {
      String lastToken = historyTokens.get(historyTokens.size() - 1);

      // TODO generalize suffix approach
      if (lastToken.endsWith(".html")) {
        lastToken = lastToken.substring(0, lastToken.length() - ".html".length());
      }

      // transform camel case to spaces
      lastToken = lastToken.replaceAll("([A-Z])", " $1");

      // upper-case
      lastToken = lastToken.toUpperCase();

      tokenI18N = lastToken;
    }

    // title.setText(tokenI18N);
    Window.setTitle(messages.windowTitle(tokenI18N));
  }