use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class SplitHorizontallyAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent event) {
final String tabId = getEditorTab(event).getId();
final VirtualFile file = getEditorFile(event);
final Constraints constraints = new Constraints(HORIZONTALLY, tabId);
editorAgent.openEditor(file, constraints);
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class ReopenClosedFileAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent event) {
EditorPartStack currentPartStack = getEditorPane(event);
EditorPartPresenter lastClosed = currentPartStack.getLastClosed();
VirtualFile file = lastClosed.getEditorInput().getFile();
eventBus.fireEvent(FileEvent.createOpenFileEvent(file));
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class BasicActiveFileHandler method tryFindFileInProject.
protected void tryFindFileInProject(final Location location, final AsyncCallback<VirtualFile> callback) {
Resource resource = appContext.getResource();
if (resource == null) {
callback.onFailure(new IllegalStateException("Resource is undefined"));
return;
}
Optional<Project> project = resource.getRelatedProject();
if (!project.isPresent()) {
callback.onFailure(new IllegalStateException("Project is undefined"));
return;
}
project.get().getFile(location.getTarget()).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
openFileAndScrollToLine(file.get(), location.getLineNumber(), callback);
} else {
callback.onFailure(new IllegalArgumentException(location.getTarget() + " not found."));
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
callback.onFailure(new IllegalArgumentException(location.getTarget() + " not found."));
}
});
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class JavaDebuggerFileHandler method openExternalResource.
private void openExternalResource(final Location location, final AsyncCallback<VirtualFile> callback) {
final String className = extractOuterClassFqn(location.getTarget());
final int libId = location.getExternalResourceId();
final Path projectPath = new Path(location.getResourceProjectPath());
service.getEntry(projectPath, libId, className).then(new Operation<JarEntry>() {
@Override
public void apply(final JarEntry jarEntry) throws OperationException {
final JarFileNode file = nodeFactory.newJarFileNode(jarEntry, libId, projectPath, null);
AsyncCallback<VirtualFile> downloadSourceCallback = new AsyncCallback<VirtualFile>() {
@Override
public void onSuccess(final VirtualFile result) {
if (file.isContentGenerated()) {
handleContentGeneratedResource(file, location, callback);
} else {
handleActivatedFile(file, callback, location.getLineNumber());
}
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
};
handleActivatedFile(file, downloadSourceCallback, location.getLineNumber());
eventBus.fireEvent(FileEvent.createOpenFileEvent(file));
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
callback.onFailure(arg.getCause());
}
});
}
use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.
the class RecipeEditorPanel method showEditor.
/** {@inheritDoc} */
@Override
public void showEditor() {
if (isInitialized) {
return;
}
VirtualFile recipeFile = recipeFileFactory.newInstance(recipeDescriptor.getScript());
initializeEditor(recipeFile);
isInitialized = true;
}
Aggregations