use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class BreakpointManagerImpl method setCurrentBreakpoint.
private void setCurrentBreakpoint(String filePath, int lineNumber) {
deleteCurrentBreakpoint();
EditorPartPresenter editor = getEditorForFile(filePath);
if (editor != null) {
VirtualFile activeFile = editor.getEditorInput().getFile();
doSetCurrentBreakpoint(activeFile, lineNumber);
}
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class EditorGroupSynchronizationImpl method updateContent.
private void updateContent(String newContent, String oldStamp, VirtualFile virtualFile) {
final DocumentHandle documentHandle = getDocumentHandleFor(groupLeaderEditor);
if (documentHandle == null) {
return;
}
final Document document = documentHandle.getDocument();
final String oldContent = document.getContents();
final TextPosition cursorPosition = document.getCursorPosition();
if (!(virtualFile instanceof File)) {
replaceContent(document, newContent, oldContent, cursorPosition);
return;
}
final File file = (File) virtualFile;
final String newStamp = file.getModificationStamp();
if (oldStamp == null && !Objects.equals(newContent, oldContent)) {
replaceContent(document, newContent, oldContent, cursorPosition);
return;
}
if (!Objects.equals(oldStamp, newStamp)) {
replaceContent(document, newContent, oldContent, cursorPosition);
notificationManager.notify("External operation", "File '" + file.getName() + "' is updated", SUCCESS, EMERGE_MODE);
}
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class EditorGroupSynchronizationImpl method onFileContentUpdate.
@Override
public void onFileContentUpdate(final FileContentUpdateEvent event) {
if (synchronizedEditors.keySet().isEmpty()) {
return;
}
if (groupLeaderEditor == null) {
groupLeaderEditor = synchronizedEditors.keySet().iterator().next();
resolveAutoSave();
}
final VirtualFile virtualFile = groupLeaderEditor.getEditorInput().getFile();
if (!event.getFilePath().equals(virtualFile.getLocation().toString())) {
return;
}
documentStorage.getDocument(virtualFile, new DocumentStorage.DocumentCallback() {
@Override
public void onDocumentReceived(final String content) {
updateContent(content, event.getModificationStamp(), virtualFile);
}
@Override
public void onDocumentLoadFailure(final Throwable caught) {
notificationManager.notify("", "Can not to update content for the file " + virtualFile.getDisplayName(), FAIL, EMERGE_MODE);
}
});
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class EditorAgentImpl method onActivePartChanged.
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
activePart = event.getActivePart();
if (!(event.getActivePart() instanceof EditorPartPresenter)) {
return;
}
activeEditor = (EditorPartPresenter) event.getActivePart();
activeEditor.activate();
final String isLinkedWithEditor = preferencesManager.getValue(LinkWithEditorAction.LINK_WITH_EDITOR);
if (parseBoolean(isLinkedWithEditor)) {
final VirtualFile file = activeEditor.getEditorInput().getFile();
eventBus.fireEvent(new RevealResourceEvent(file.getLocation()));
}
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class EditorCurrentProjectNameMacro method expand.
/** {@inheritDoc} */
@Override
public Promise<String> expand() {
final EditorPartPresenter editor = getActiveEditor();
if (editor == null) {
return promises.resolve("");
}
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
if (!project.isPresent()) {
return promises.resolve("");
}
return promises.resolve(project.get().getName());
}
return promises.resolve("");
}
Aggregations