Пример #1
0
  private void buildLessonTree(Response response) {
    TreeItem item = null;
    JsArray<LessonCategoryJS> lessonJSArray = JsonUtils.safeEval(response.getText());

    for (int i = 0; i < lessonJSArray.length(); i++) {
      LessonCategoryJS lessonCategoryJS = lessonJSArray.get(i);
      TreeItem category = new TreeItem();
      category.setText(lessonCategoryJS.getName());

      JsArray<LessonJS> lessons = lessonCategoryJS.getChildren();
      for (int j = 0; j < lessons.length(); j++) {
        LessonJS lesson = lessons.get(j);

        TreeItem lessonItem = new TreeItem();
        Storage sessionStorage = Storage.getSessionStorageIfSupported();
        String lastUrl = sessionStorage.getItem("lastUrl");
        lessonItem.setText(lesson.getText());
        category.addItem(lessonItem);
        lessonsTreeMap.put(lessonItem.getText(), lesson);
        if (lesson.getTechnology().equals(LessonTechnology.GWT.toString())) {
          addLessonToMap(lesson);
        }
        if (lastUrl != null && lastUrl.equals(lesson.getUrl())) {
          item = lessonItem;
          lessonPanel.setSelectedLesson(lesson);
          category.setState(true);
        }
      }
      lessonTree.addItem(category);
    }
    lessonTree.setSelectedItem(item);
  }
 public byte[] load_licence(Options option) {
   /*        Preferences prefs = Preferences.userNodeForPackage(this.getClass());
           return prefs.getByteArray("licence."+ option.getHostname(),null);
   */
   Storage store = Storage.getLocalStorageIfSupported();
   if (store != null) {
     return store.getItem("licence." + option.getHostname()).getBytes();
   } else return null;
 }
Пример #3
0
 /**
  * constructor
  *
  * @param appName The name of the Xholon Java-based app (ex: "HelloWorld");
  */
 public XholonWorkbookBundle(String appName) {
   Storage storage = Storage.getLocalStorageIfSupported();
   if (storage != null) {
     workbookContents = storage.getItem(appName);
     if (exists()) {
       resourceMap = new HashMap<String, String>();
       processWb();
     }
   }
 }
Пример #4
0
  protected AbstractPresenter(MyClerkServiceAsync rpcService, HandlerManager eventBus) {
    this.eventBus = eventBus;

    this.rpcService = rpcService;
    menu = MainMenu.getInstance(eventBus);
    this.selectMenuLink();
    Storage clientStore = Storage.getSessionStorageIfSupported();
    this.loggedUser = clientStore.getItem("username");
    System.out.println("Logged user is: " + loggedUser);
    if (loggedUser == null) menu.setMenu(false);
    else menu.setMenu(true);
  }
Пример #5
0
  /**
   * Retrieves the current authentication.
   *
   * @return The current authentication.
   */
  public Authentication getAuthentication() {
    final Authentication authentication = authenticationProvider.get();

    if (authentication.getUserEmail() == null) {
      // Search the last logged user in the users database
      final Storage storage = Storage.getLocalStorageIfSupported();
      final String email = storage.getItem(LocalDispatchServiceAsync.LAST_USER_ITEM);

      authentication.setUserEmail(email);
    }

    return authentication;
  }
Пример #6
0
 public OptionViewImpl() {
   initWidget(uiBinder.createAndBindUi(this));
   boolean storageSupported = Storage.isLocalStorageSupported();
   this.storageNotAvailable.setVisible(!storageSupported);
   this.offline.setVisible(storageSupported);
   this.clearData.setVisible(storageSupported);
 }
Пример #7
0
 private CollectionTabTitleVc getPersistantTabObjectUsingTabFlag() {
   CollectionTabTitleVc objectToReturn = contentTabVc;
   stockStore = Storage.getLocalStorageIfSupported();
   String tabFlag = stockStore.getItem("tabKey");
   if (stockStore != null) {
     if (stockStore != null) {
       if (tabFlag.equalsIgnoreCase("infoTab")) {
         objectToReturn = infoTabVc;
       } else if (tabFlag.equalsIgnoreCase("contentTab")) {
         objectToReturn = contentTabVc;
       }
     } else {
       objectToReturn = contentTabVc;
     }
   }
   return objectToReturn;
 }
 @Override
 public void clear() {
   for (Index i : index) {
     storage.removeItem(getId(i.getId()));
   }
   index.clear();
   updateIndex();
 }
 @Override
 public void delete(long key) {
   for (Index i : index) {
     if (i.getId() == key) {
       index.remove(i);
       storage.removeItem(getId(key));
       updateIndex();
       break;
     }
   }
 }
Пример #10
0
  private void updateIndex() {
    Collections.sort(index, comparator);
    DataOutput dataOutput = new DataOutput();
    dataOutput.writeInt(index.size());

    for (Index i : index) {
      dataOutput.writeLong(i.getId());
      dataOutput.writeLong(i.getSortKey());
    }

    storage.setItem("list_" + prefix + "_index", toBase64(dataOutput.toByteArray()));
  }
Пример #11
0
  @Override
  public void updateOrAdd(ListEngineRecord record) {
    // Update Index
    for (Index i : index) {
      if (i.getId() == record.getKey()) {
        index.remove(i);
        break;
      }
    }
    index.add(new Index(record.getKey(), record.getOrder()));
    updateIndex();

    // Save record
    storage.setItem(getId(record.getKey()), toBase64(record.getData()));
  }
Пример #12
0
 @Override
 public void onError(final Request request, final Throwable exception) {
   if (exception instanceof StatusCodeException) {
     if (Storage.isSessionStorageSupported()) {
       final Storage storage = Storage.getSessionStorageIfSupported();
       if (storage.getItem(cacheKey()) != null) {
         callback.onResponseReceived(request, getOldResponse(storage));
       }
     } else if (Storage.isLocalStorageSupported()) {
       final Storage storage = Storage.getLocalStorageIfSupported();
       if (storage.getItem(cacheKey()) != null) {
         callback.onResponseReceived(request, getOldResponse(storage));
       }
     }
   } else {
     callback.onError(request, exception);
   }
 }
Пример #13
0
  @Override
  public ListEngineRecord loadItem(long key) {
    Index indexValue = null;
    for (Index i : index) {
      if (i.getId() == key) {
        indexValue = i;
        break;
      }
    }

    if (indexValue == null) {
      return null;
    }

    String item = storage.getItem(getId(key));
    if (item != null) {
      byte[] res = fromBase64(item);
      return new ListEngineRecord(key, indexValue.getSortKey(), null, res);
    }
    return null;
  }
Пример #14
0
  public JsListStorage(String prefix, Storage storage) {
    this.storage = storage;
    this.prefix = prefix;

    String indexData = storage.getItem("list_" + prefix + "_index");
    if (indexData != null) {
      try {
        byte[] data = fromBase64(indexData);
        DataInput dataInput = new DataInput(data, 0, data.length);
        int count = dataInput.readInt();
        for (int i = 0; i < count; i++) {
          long id = dataInput.readLong();
          long order = dataInput.readLong();
          index.add(new Index(id, order));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    updateIndex();
  }
Пример #15
0
 public void setPersistantTabFlag(String flag) {
   stockStore = Storage.getLocalStorageIfSupported();
   if (stockStore != null) {
     stockStore.setItem("tabKey", flag);
   }
 }
 public void save_licence(byte[] databytes, Options option) {
   /*        Preferences prefs = Preferences.userNodeForPackage(this.getClass());
           prefs.putByteArray("licence."+ option.getHostname(), databytes);
   */ Storage store = Storage.getLocalStorageIfSupported();
   if (store != null) store.setItem("licence." + option.getHostname(), new String(databytes));
 }
Пример #17
0
 @Override
 public void onResponseReceived(final Request request, @Nonnull final Response response) {
   if (response.getStatusCode() == 304 && Storage.isSessionStorageSupported()) {
     final Storage storage = Storage.getSessionStorageIfSupported();
     if (storage.getItem(cacheKey()) != null) {
       callback.onResponseReceived(request, getOldResponse(storage));
       return;
     }
   }
   if (response.getStatusCode() == 304 && Storage.isLocalStorageSupported()) {
     final Storage storage = Storage.getLocalStorageIfSupported();
     if (storage.getItem(cacheKey()) != null) {
       callback.onResponseReceived(request, getOldResponse(storage));
       return;
     }
   }
   if (response.getStatusCode() == 200
       && response.getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE) != null
       && response
           .getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE)
           .equals(CachingScope.USER.name())) {
     serializedResponse = response.getText();
     if (Storage.isLocalStorageSupported()) {
       final Storage storage = Storage.getLocalStorageIfSupported();
       storage.setItem(cacheKey(), serializedResponse);
     }
   } else if (response.getStatusCode() == 200
       && response.getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE) != null
       && response
           .getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE)
           .equals(CachingScope.SESSION.name())) {
     serializedResponse = response.getText();
     if (Storage.isSessionStorageSupported()) {
       final Storage storage = Storage.getSessionStorageIfSupported();
       storage.setItem(cacheKey(), serializedResponse);
     }
   }
   callback.onResponseReceived(request, response);
 }