Esempio n. 1
0
  public void textInserted(Message.TextPasteMsg m) {

    try {

      int SenderId = m.getClientId();
      int offset = m.getOffset();
      String textPasted = m.getText();

      if (EditorServer_Debug)
        System.err.println("EditorServer->textinserted : PASTED by : " + SenderId);

      Vector pars = null;
      try {
        pars = lockManager.textInserted(m.getPar(), offset, textPasted, SenderId);
        if (EditorServer_Debug)
          System.err.println("\n+=*%EditorServer--> textInserted recovered VECTOR...");
      } catch (Exception e) {
        System.err.println("\n+=*%EditorServer--> textInserted VECTOR error ");
      }

      textChannel.sendToOthers(client, new Data(m));

      EditorClient SenderClient = getEditorClient(SenderId);
      SenderClient.addTextPasteAction(System.currentTimeMillis(), pars, offset, textPasted);
      clientsPanel.updateActionTableFor(SenderClient);
      updateParagraphList();
    } catch (Exception e) {
      System.err.println("\nEditorServer--> textPasted: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Esempio n. 2
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();
    }
  }
Esempio n. 3
0
  public void gestureLine(Message.GestureLineMsg m) {
    if (EditorServer_Debug)
      System.err.println("EditorServer: gestureLine." + String.valueOf(m.getId()));

    try {
      clientChannel.sendToOthers(client, new Data(m));
      EditorClient c = getEditorClient(m.getClientId());
      long par = getParIdForGesture(m.getPar(), m.getAY());
      c.addGestureAction(System.currentTimeMillis(), m.getId(), par, m.getAX(), m.getAY(), this);
      c.addGestureAction(System.currentTimeMillis(), m.getId(), par, m.getBX(), m.getBY(), this);
      clientsPanel.updateActionTableFor(c);
    } catch (Exception e) {
      System.err.println("EditorServer: gestureLine: error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Esempio n. 4
0
  public void textDeleted(Message.TextCutMsg m) {
    if (EditorServer_Debug) System.err.println("EditorServer ->textCut.");

    try {

      long StartPar = m.getStartPar();
      long EndPar = m.getEndPar();
      int StartOffset = m.getStartOffset();
      int EndOffset = m.getEndOffset();

      String text = lockManager.getText(StartPar, StartOffset, EndPar, EndOffset);
      Vector pars = lockManager.textDeleted(StartPar, StartOffset, EndPar, EndOffset);
      textChannel.sendToOthers(client, new Data(m));
      EditorClient c = getEditorClient(m.getClientId());
      c.addTextCutAction(System.currentTimeMillis(), pars, StartOffset, EndOffset, text);
      clientsPanel.updateActionTableFor(c);
      updateParagraphList();
    } catch (Exception e) {
      System.err.println("EditorServer---> textDeleted(cut): error sending msg");
      if (EditorServer_Debug) e.printStackTrace();
    }
  }
Esempio n. 5
0
  public EditorServer(String fileName, String name, String desc) {
    super();
    self = this;
    if (fileName == null || !loadDocument(fileName)) {
      clients = new Vector();
      document = new EditorDocument(name, desc, "", System.currentTimeMillis());

      try {
        // ascii code for first blue line...
        document.insertString(0, "·-·+·*=·x·\n", document.getStyle("line"));
      } catch (BadLocationException ble) {
        System.out.println("EditorServer->const: BadLocationException");
      }

      paragraphs = new Paragraphs(document);
      lockManager = new LockManager(clients, document, paragraphs);
      highlights = new Highlights(lockManager, document);

      nextClientId = 1;
    }

    isAudioOptionSelected = false;
    // to avoid unecessary Audio - Text participant matching

    documentPanel = new DocumentPanel();
    updateParagraphList();

    clientsPanel = new ClientsPanel();
    clientsPanel.updateClientList();

    Icon clockIcon = getImageIcon("images/clock.gif");

    Icon clockIcon2 = getImageIcon("images/clock2.gif");

    startRTPrecording = new JButton("START RTP Recording", clockIcon);

    startRTPrecording.setRolloverIcon(clockIcon2);

    RecordingHandler recHandler = new RecordingHandler(self);

    startRTPrecording.addActionListener(recHandler);

    Icon stopIcon = getImageIcon("images/stop.gif");

    stopRTPrecording = new JButton("STOP RTP recording", stopIcon);

    stopRTPrecording.setEnabled(false);

    stopRTPrecording.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            recorder.endRecording();

            stopRTPrecording.setEnabled(false);
            startRTPrecording.setEnabled(true);
          }
        });

    Container container = getContentPane();

    container.setLayout(new FlowLayout());

    container.add(startRTPrecording);
    container.add(stopRTPrecording);

    // JTabbedPane tabPane = new JTabbedPane() ;
    tabPane.add("Document", documentPanel);
    tabPane.add("Text Clients", clientsPanel);
    container.add(tabPane, BorderLayout.CENTER);

    setTitle("EditorServer");
    setSize(new Dimension(800, 600));

    addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent e) {
            lockManager.saveDocument(null, highlights, self);
            System.exit(0);
          }
        });

    JMenuItem mnuSave = new JMenuItem("Save");
    mnuSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser dialog = new JFileChooser();
            dialog.addChoosableFileFilter(
                new MyFileFilter("Collabortive Document File (*.cde)", ".cde"));
            dialog.setAcceptAllFileFilterUsed(false);

            if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
              lockManager.saveDocument(dialog.getSelectedFile().getPath(), highlights, self);
            }
          }
        });

    JMenuItem mnuSaveXML = new JMenuItem("Save XML");
    mnuSaveXML.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser dialog = new JFileChooser();
            dialog.addChoosableFileFilter(new MyFileFilter("XML File (*.xml)", ".xml"));
            dialog.setAcceptAllFileFilterUsed(false);

            if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
              lockManager.saveXML(dialog.getSelectedFile().getPath(), highlights, self);
            }
          }
        });

    JMenu mnuFile = new JMenu("File");
    mnuFile.add(mnuSave);
    mnuFile.add(mnuSaveXML);
    JMenuBar menu = new JMenuBar();
    menu.add(mnuFile);
    setJMenuBar(menu);

    Thread backupThread =
        new Thread() {
          public void run() {
            while (1 == 1) {
              yield();
              try {
                // sleep(1000) ;
                sleep(5 * 60 * 1000);
                lockManager.saveDocument(null, highlights, self);
              } catch (Exception e) {
                System.out.println("EditorServer: backupThread. error");
                e.printStackTrace();
              }
            }
          }
        };
    backupThread.setDaemon(true);
    backupThread.start();
  } // endof const WITHOUT audio profile maker