Search in sources :

Example 6 with VirtualFile

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);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Constraints(org.eclipse.che.ide.api.constraints.Constraints)

Example 7 with VirtualFile

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));
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartStack(org.eclipse.che.ide.api.parts.EditorPartStack)

Example 8 with VirtualFile

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."));
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Optional(com.google.common.base.Optional) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 9 with VirtualFile

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());
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Operation(org.eclipse.che.api.promises.client.Operation) JarEntry(org.eclipse.che.ide.ext.java.shared.JarEntry) JarFileNode(org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 10 with VirtualFile

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;
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Aggregations

VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)48 Project (org.eclipse.che.ide.api.resources.Project)21 Resource (org.eclipse.che.ide.api.resources.Resource)19 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)18 OperationException (org.eclipse.che.api.promises.client.OperationException)15 Operation (org.eclipse.che.api.promises.client.Operation)14 PromiseError (org.eclipse.che.api.promises.client.PromiseError)9 File (org.eclipse.che.ide.api.resources.File)8 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)6 Test (org.junit.Test)6 Optional (com.google.common.base.Optional)5 Scheduler (com.google.gwt.core.client.Scheduler)4 HashMap (java.util.HashMap)4 EditorInput (org.eclipse.che.ide.api.editor.EditorInput)4 OpenEditorCallbackImpl (org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl)4 JarEntry (org.eclipse.che.ide.ext.java.shared.JarEntry)4 ClassContent (org.eclipse.che.ide.ext.java.shared.dto.ClassContent)4 Path (org.eclipse.che.ide.resource.Path)4 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)3 JarFileNode (org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode)3