Search in sources :

Example 6 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class ClasspathMacroTest method defaultValueOfClasspathShouldBeBuilt.

@Test
public void defaultValueOfClasspathShouldBeBuilt() throws Exception {
    List<ClasspathEntryDto> entries = new ArrayList<>();
    Set<String> libs = new HashSet<>();
    Path projectsRoot = Path.valueOf("/projects");
    when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
    when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
    when(classpathResolver.getLibs()).thenReturn(libs);
    classpathMacro.expand();
    verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
    String classpath = classpathEntriesCapture.getValue().apply(entries);
    verify(classpathResolver).resolveClasspathEntries(entries);
    assertEquals("/projects/name:", classpath);
}
Also used : Path(org.eclipse.che.ide.resource.Path) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class EditorContentSynchronizerImpl method onActivePartChanged.

@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
    PartPresenter activePart = event.getActivePart();
    if (!(activePart instanceof EditorPartPresenter)) {
        return;
    }
    EditorPartPresenter activeEditor = (EditorPartPresenter) activePart;
    Path path = activeEditor.getEditorInput().getFile().getLocation();
    if (editorGroups.containsKey(path)) {
        editorGroups.get(path).onActiveEditorChanged(activeEditor);
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 8 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class EditorContentSynchronizerImpl method onResourceChanged.

@Override
public void onResourceChanged(ResourceChangedEvent event) {
    final ResourceDelta delta = event.getDelta();
    if (delta.getKind() != ADDED || (delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) {
        return;
    }
    final Path fromPath = delta.getFromPath();
    final Path toPath = delta.getToPath();
    if (delta.getResource().isFile()) {
        onFileChanged(fromPath, toPath);
    } else {
        onFolderChanged(fromPath, toPath);
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) ResourceDelta(org.eclipse.che.ide.api.resources.ResourceDelta)

Example 9 with Path

use of org.eclipse.che.ide.resource.Path 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 Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class SwitchPresenter method showWindow.

public void showWindow() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    switchView.showWindow();
    switchView.setSwitchButtonEnabled(false);
    invalidateLoadedData();
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(appContext.getRootProject().getLocation(), ".", "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (!response.getItems().isEmpty()) {
                SubversionItem subversionItem = response.getItems().get(0);
                projectUri = subversionItem.getProjectUri();
            }
            defaultViewInitialization();
            handleSwitchButton();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            projectUri = "^";
            Path location = appContext.getRootProject().getLocation();
            notificationManager.notify(constants.infoRequestError(location.toString()), error.getMessage(), FAIL, EMERGE_MODE);
            defaultViewInitialization();
            handleSwitchButton();
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

Path (org.eclipse.che.ide.resource.Path)72 Resource (org.eclipse.che.ide.api.resources.Resource)27 Operation (org.eclipse.che.api.promises.client.Operation)15 OperationException (org.eclipse.che.api.promises.client.OperationException)15 PromiseError (org.eclipse.che.api.promises.client.PromiseError)13 ArrayList (java.util.ArrayList)11 Project (org.eclipse.che.ide.api.resources.Project)11 Promise (org.eclipse.che.api.promises.client.Promise)10 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)10 List (java.util.List)8 Test (org.junit.Test)7 ResourceDelta (org.eclipse.che.ide.api.resources.ResourceDelta)6 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)6 Optional (com.google.common.base.Optional)5 Function (org.eclipse.che.api.promises.client.Function)5 FunctionException (org.eclipse.che.api.promises.client.FunctionException)5 Container (org.eclipse.che.ide.api.resources.Container)5 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)5 HashMap (java.util.HashMap)4 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)4