Esempio n. 1
0
 @Override
 public void attach() {
   super.attach();
   project.getTeam().setUserFileOpen(file, user, editor.getCollaboratorId());
   getWindow().addListener(this);
   showUsers();
   editor.addListener(this);
   project.addListenerWeakRef(this);
   project.getTeam().addListener(this);
 }
Esempio n. 2
0
 @Override
 public void detach() {
   super.detach();
   editor.removeListener(this);
   project.removeListenerWeakRef(this);
   project.getTeam().removeListener(this);
   project.getTeam().setUserFileClosed(file, user, editor.getCollaboratorId());
   if (popup != null) {
     getWindow().removeWindow(popup);
   }
 }
Esempio n. 3
0
  public EditorView(ProjectFile file, Project project, User user, boolean inIde, int line) {
    super();
    this.file = file;
    this.project = project;
    this.user = user;
    layout.setSizeFull();

    HorizontalLayout ho = new HorizontalLayout();
    if (!inIde) {
      String url = "#" + project.getName() + "/" + file.getName() + "!";
      Link link = new Link("<<< " + file.getName(), new ExternalResource(url));
      link.setDescription("View project");
      layout.addComponent(link);
    }
    if (inIde) {
      String url = "#" + project.getName() + "/" + file.getName();
      Link link = new Link(file.getName() + " >>>", new ExternalResource(url));
      link.setDescription("View in standalone window");
      layout.addComponent(link);
    }

    layout.addComponent(ho);

    layout.setExpandRatio(ho, 1);
    ho.setSizeFull();

    cdoc = project.getDoc(file);

    editor = createEditor(file, project);
    editor.setSizeFull();
    editor.setEnabled(user != null);
    editor.setUser(user.getUserId(), user.getStyle());

    final int pos =
        org.vaadin.aceeditor.gwt.shared.Util.cursorPosFromLineCol(
            cdoc.getShared().getValue().getText(), line, 0, 1);
    editor.scrollToPosition(pos);
    ho.addComponent(editor);
    ho.setExpandRatio(editor, 1);

    VerticalLayout rightBar = new VerticalLayout();
    rightBar.setWidth("64px");
    rightBar.addComponent(userLayout);
    rightBar.addComponent(markerLayout);

    ho.addComponent(rightBar);

    setSizeFull();
    setCompositionRoot(layout);
  }
Esempio n. 4
0
  private void addMarker(Marker m, ChatLine chatLine) {
    String markerId = editor.newItemId();
    Doc v = cdoc.getShared().getValue();
    // Adding the marker to the selection marker position, a bit of a hack.
    Marker sema = v.getMarkers().get(user.getSelectionMarkerId());
    if (sema == null) {
      getWindow().showNotification("Something went wrong marker-wise :( Please try again.");
      return;
    }
    String text = v.getText();
    int start = sema.getStart();
    int end = sema.getEnd();
    m = m.withNewPos(start, end);

    DocDiff d = DocDiff.addMarker(markerId, m, text);
    cdoc.getShared().applyDiff(d, editor.getCollaboratorId());

    if (chatLine != null) {
      List<ChatLine> lines = Collections.singletonList(chatLine);
      project.getDoc(file).getMarkerChatCreateIfNotExist(markerId, lines);
    }

    latestMarkers.put(markerId, m);
    activeMarker = markerId;

    updateMarkers(latestMarkers);
    showMarkerPopup();
    editor.requestRepaint();
  }
Esempio n. 5
0
 private void showUsers() {
   userLayout.removeAllComponents();
   Collection<User> users = project.getTeam().getUsersByFile(file);
   for (User u : users) {
     userLayout.addComponent(new UserWidget(u, false));
   }
 }
Esempio n. 6
0
 public void userFilesChanged(Set<User> users, Set<ProjectFile> files) {
   // TODO
   // "always synchronize on the application instance when accessing
   // Vaadin UI components or related data from another thread."
   // https://vaadin.com/forum/-/message_boards/view_message/1785789#_19_message_212956
   // Is this enough of synchronization?
   //		synchronized (getApplication()) {
   if (files.contains(file)) {
     showUsers();
   }
   if (users.contains(user) && !project.getTeam().hasUser(user)) {
     layout.removeAllComponents();
     getWindow().showNotification(user.getName() + " has left");
   }
   //		}
 }
Esempio n. 7
0
 private void showMarkerPopup(int yCoord) {
   final String markerId = activeMarker;
   SharedChat chat = project.getDoc(file).getMarkerChat(markerId);
   String firstLine = chat.getValue().getFrozenLines().get(0).getText();
   Marker m = latestMarkers.get(markerId);
   MarkerComponent mc = new MarkerComponent(m, user, chat);
   mc.addListener(
       new MarkerComponentListener() {
         public void removeMarker() {
           if (popup != null) {
             popup.setVisible(false);
           }
           activeMarker = null;
           latestMarkers.remove(markerId);
           updateMarkers(latestMarkers);
           removeMarkerById(markerId);
         }
       });
   showPopup(firstLine, mc, yCoord);
 }
Esempio n. 8
0
 public void windowClose(CloseEvent e) {
   project.getTeam().setUserFileClosed(file, user, editor.getCollaboratorId());
 }