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); }
public void docRemoved(ProjectFile file) { // 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 (this.file.equals(file)) { layout.removeAllComponents(); getWindow().showNotification("File " + file.getName() + " was deleted"); } // } }