Пример #1
0
  public void sendHighlights() {

    // send highlights to everybody
    try {
      Iterator i = highlights.getHighlights().iterator();
      while (i.hasNext()) {
        Highlights.Highlight h = (Highlights.Highlight) i.next();
        Paragraph sPar = lockManager.getParFromOffset(h.getStart());
        Paragraph ePar = lockManager.getParFromOffset(h.getEnd());

        if (EditorServer_Debug) {
          System.out.println("StartPar: " + sPar.toString());
          System.out.println("EndPar: " + ePar.toString());
        }

        Message.HighlightAddMsg msg =
            new Message.HighlightAddMsg(
                -1,
                h.getId(),
                h.getType().getId(),
                sPar.getID(),
                ePar.getID(),
                h.getStart() - sPar.getOffset(),
                h.getEnd() - ePar.getOffset());
        textChannel.sendToOthers(client, new Data(msg));
      }
    } catch (Exception e) {
      System.err.println("EditorServer: sendHighlights: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Пример #2
0
  public void highlightTypeAdded(Message.HighlightTypeMsg m) {
    if (EditorServer_Debug) System.err.println("EditorServer: highlightTypeAdded.");

    highlights.addHighlightType(m.getId(), m.getName(), m.getColor());

    try {
      textChannel.sendToOthers(client, new Data(m));
    } catch (Exception e) {
      System.err.println("EditorServer: highlightTypeAdded: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Пример #3
0
  public void highlightDeleted(Message.HighlightDeleteMsg m) {
    if (EditorServer_Debug) System.err.println("EditorServer: highlightDeleted.");

    highlights.deleteHighlight(m.getId());
    EditorClient c = getEditorClient(m.getClientId());
    try {
      textChannel.sendToOthers(client, new Data(m));
    } catch (Exception e) {
      System.err.println("EditorServer: highlightDeleted: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Пример #4
0
  public void highlightEdited(Message.HighlightEditMsg m) {
    if (EditorServer_Debug) System.err.println("EditorServer: highlightEdited.");

    highlights.editHighlight(
        m.getId(), m.getStartPar(), m.getStartOffset(), m.getEndPar(), m.getEndOffset());

    try {
      textChannel.sendToOthers(client, new Data(m));
    } catch (Exception e) {
      System.err.println("EditorServer: highlightEdited: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Пример #5
0
  public void sendHighlightTypes() {
    //      send highlightTypes to everybody
    try {
      Iterator i = highlights.getHighlightTypes().iterator();

      while (i.hasNext()) {
        HighlightType type = (HighlightType) i.next();

        if (EditorServer_Debug)
          System.out.println("EditorServer: sendHighlightTypes. " + String.valueOf(type.getId()));

        Message.HighlightTypeMsg msg =
            new Message.HighlightTypeMsg(-1, type.getId(), type.getName(), type.getColor());
        textChannel.sendToOthers(client, new Data(msg));
      }
    } catch (Exception e) {
      System.err.println("EditorServer: sendHighlightTypes: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }