Package com.google.gwt.gears.sample.gwtnote.client.rpc

Examples of com.google.gwt.gears.sample.gwtnote.client.rpc.Note


    this.rtw = mainPanel;
    rtw.addNameChangeListener(new ChangeListener() {
      public void onChange(Widget sender) {
        String newName = rtw.getName();
        if (noteData.containsKey(newName)) {
          Note n = noteData.get(newName);
          if (!rtw.getHTML().equals(n.getText())) {
            rtw.setHTML(n.getText());
          }
        }
      }
    });
  }
View Full Code Here


    syncFromGears(true);
    syncToServer(true);
   
    // init the dirty-testing code
    localDirty = false;
    Note def = noteData.get("default");
    if (def != null) {
      lastData = def.getText();
    }
  }
View Full Code Here

    if (!gears.gearsEnabled()) {
      return;
    }

    Note[] notes = gears.getNotes();
    Note n = null;
    if (notes != null && notes.length > 0) {
      for (int i = 0; i < notes.length; ++i) {
        n = notes[i];
        if (!noteData.containsKey(n.getName())) {
          n = notes[i];
          noteData.put(n.getName(), n);
        }
      }
    }
    if (isInit) {
      n = noteData.get("default");
      if (n != null) {
        rtw.setHTML(n.getText());
      }
    }
  }
View Full Code Here

          ready = true;
          return;
        }

        // process the results and figure out if we need to update our state
        Note n = null;
        for (int i = 0; i < notes.length; ++i) {
          n = notes[i];

          // server sent us a totally new record -- just store it
          if (!noteData.containsKey(n.getName())) {
            noteData.put(n.getName(), n);
            gears.updateNote(n);
            continue;
          }

          // record exists -- check if server version is more recent & handle it
          Note current = noteData.get(n.getName());
          if (!current.getVersion().equals(n.getVersion())) {
            current.setVersion(n.getVersion());
            if (current.getText().equals(n.getText())) {
              // versions don't match but text is same anyway
              gears.updateNote(current); // to update version...
              localDirty = false;
              lastData = current.getText();
            } else if (current.getName().equals(rtw.getName()) && localDirty
                && Window.confirm(REPLACE_CONF_TEXT)) {
              // if versions don't match, ask user for permission to override
              gears.updateNote(current); // to update version...
              // we are proceeding w/ local data, so don't touch UI
            } else {
              // user rejected override, or else was not current note
              current.setText(n.getText());
              gears.updateNote(current);
             
              localDirty = false;
              lastData = current.getText();

              // don't forget to update UI state...
              if (rtw.getName().equals(current.getName())) {
                rtw.setHTML(current.getText());
              }
            }
            continue;
          }
        }

        // in the special case of startup, check for default value
        if (isInit) {
          Note def = noteData.get("default");
          if (def != null) {
            rtw.setHTML(def.getText());
          }
        }
        ready = true;
      }
    });
View Full Code Here

    // upload our current data
    rpc.setNotes(notes, new AsyncCallback<Void>() {
      public void onFailure(Throwable caught) {
        // next call is also likely to fail, so don't bother to try
        if (isInit) {
          Note def = noteData.get("default");
          if (def != null) {
            rtw.setHeight(def.getText());
          }
        }
        ready = true;
      }
View Full Code Here

      lastData = curData;
    }

    if (noteData.containsKey(curName)) {
      // fetch the latest data for the note the user is trying to look at
      Note n = noteData.get(curName);
      if (!n.getText().equals(curData)) {
        // if the UI doesn't currently show latest data, update it
        n.setText(curData);
        gears.updateNote(n);
      }
    } else {
      // if the user has created a new record (unknown name) just store it
      Note n = new Note(curName, "1", curData);
      noteData.put(curName, n);
      gears.updateNote(n);
    }

    // add all the notes to the options list
View Full Code Here

      return;
    }
    Map<String,Note> data = getDataMap();
    for (int i = 0; i < notes.length; ++i) {
      if (data.containsKey(notes[i].getName())) {
        Note nd = data.get(notes[i].getName());
        int newVer = Integer.parseInt(notes[i].getVersion());
        int oldVer = Integer.parseInt(nd.getVersion());
        if (newVer >= oldVer) {
          if (!nd.getText().equals(notes[i].getText())) {
            nd.setText(notes[i].getText());
            nd.setVersion("" + ((newVer > oldVer ? newVer : oldVer) + 1));
          }
        }
      } else {
        data.put(notes[i].getName(), notes[i]);
      }
View Full Code Here

    ResultSet rs = null;
    ArrayList<Note> al = new ArrayList<Note>();
    try {
      rs = db.execute(DB_FETCH_TEXT);
      while (rs.isValidRow()) {
        Note nd = new Note(rs.getFieldAsString(0), rs.getFieldAsString(1),
            rs.getFieldAsString(2));
        al.add(nd);
        rs.next();
      }
    } catch (DatabaseException e) {
View Full Code Here

   */
  protected Map<String,Note> getDataMap() {
    Map<String,Note> m = (Map<String,Note>) getServletContext().getAttribute("com.google.gearsdemo.data");
    if (m == null) {
      m = new HashMap<String,Note>();
      m.put("default", new Note("default", "1", ""));
      getServletContext().setAttribute("com.google.gearsdemo.data", m);
    }
    return m;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.gears.sample.gwtnote.client.rpc.Note

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.