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(); }
public void selectionChanged(int start, int end) { selMin = Math.min(start, end); selMax = Math.max(start, end); DocDiff diff = user.cursorDiff(selMin, selMax, editor.getShadow().getText()); cdoc.getShared().applyDiff(diff, editor.getCollaboratorId()); checkMarkers(); }
private SuggestibleCollabAceEditor createEditor(ProjectFile file, Project project) { SuggestibleCollabAceEditor ed = EditorUtil.createEditorFor(cdoc.getShared(), file); if (file.getName().endsWith(".java") && project instanceof VaadinProject) { InMemoryCompiler compiler = ((VaadinProject) project).getCompiler(); String className = ((VaadinProject) project).getPackageName() + "." + file.getName().substring(0, file.getName().length() - 5); ed.setSuggester(new VaadinSuggester(compiler, className), VaadinSuggester.DEFAULT_SHORTCUT); } return ed; }
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); }
private void removeMarkerById(String markerId) { cdoc.getShared().applyDiff(DocDiff.removeMarker(markerId), editor.getCollaboratorId()); }