Beispiel #1
0
  public void textInserted(Message.TextInsertMsg m) {
    if (EditorServer_Debug) System.err.println("EditorServer-> textInserted.");

    try {
      int ClientId = m.getClientId();
      int offset = m.getOffset();
      String characterInserted = m.getText();

      if (EditorServer_Debug)
        System.out.println("EditorServer-> textInserted : *" + characterInserted + "*");

      Vector pars = lockManager.textInserted(m.getPar(), offset, characterInserted, ClientId);

      textChannel.sendToOthers(client, new Data(m));
      EditorClient c = getEditorClient(ClientId);

      // new condition inserted to avoid timestamp generation if the character
      // is a newline

      if (characterInserted.equals("\n")) {
        if (EditorServer_Debug)
          System.out.println("EditorServer-> textInserted : attempting to insert a newLine");
      }
      c.addTextInsertAction(System.currentTimeMillis(), pars, offset, characterInserted);
      clientsPanel.updateActionTableFor(c);
      updateParagraphList();

    } catch (Exception e) {
      System.err.println("EditorServer-> textInserted: error receiving-sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }