Search in sources :

Example 36 with Path

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

the class HistoryPresenterTest method disarm.

@Override
public void disarm() {
    super.disarm();
    Resource resource = mock(Resource.class);
    when(resource.getLocation()).thenReturn(EMPTY);
    when(appContext.getResource()).thenReturn(resource);
    when(appContext.getRootProject()).thenReturn(project);
    when(service.log(any(DevMachine.class), any(Path.class), any(Path[].class), anyInt(), anyInt(), anyBoolean())).thenReturn(logPromise);
    when(service.diff(any(DevMachine.class), any(Path.class), anyList(), any(DiffType.class), anyBoolean(), anyInt(), anyString(), anyString())).thenReturn(stringPromise);
    when(service.showFileContent(any(DevMachine.class), any(Path.class), any(Path.class), anyString())).thenReturn(showPromise);
    when(stringPromise.then(any(Operation.class))).thenReturn(stringPromise);
    when(stringPromise.catchError(any(Operation.class))).thenReturn(stringPromise);
    when(logPromise.then(any(Operation.class))).thenReturn(logPromise);
    when(logPromise.catchError(any(Operation.class))).thenReturn(logPromise);
    when(constant.historyTitle()).thenReturn("title");
    when(constant.historyNothingToDisplay()).thenReturn("error message");
    when(constant.compareReadOnlyTitle()).thenReturn("(Read only)");
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) DiffType(org.eclipse.che.api.git.shared.DiffType)

Example 37 with Path

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

the class AddToIndexAction method addToIndex.

private void addToIndex(final GitOutputConsole console) {
    Resource[] resources = appContext.getResources();
    Path[] paths = new Path[resources.length];
    for (int i = 0; i < resources.length; i++) {
        Path path = resources[i].getLocation().removeFirstSegments(1);
        paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
    }
    service.add(appContext.getDevMachine(), appContext.getRootProject().getLocation(), false, paths).then(voidArg -> {
        console.print(constant.addSuccess());
        notificationManager.notify(constant.addSuccess());
    }).catchError(error -> {
        console.printError(constant.addFailed());
        notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Inject(com.google.inject.Inject) GitServiceClient(org.eclipse.che.ide.api.git.GitServiceClient) FAIL(org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL) Resource(org.eclipse.che.ide.api.resources.Resource) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) AddToIndexPresenter(org.eclipse.che.ide.ext.git.client.add.AddToIndexPresenter) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) FontAwesome(org.eclipse.che.ide.FontAwesome) FLOAT_MODE(org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE) AppContext(org.eclipse.che.ide.api.app.AppContext) GitLocalizationConstant(org.eclipse.che.ide.ext.git.client.GitLocalizationConstant) GitOutputConsoleFactory(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsoleFactory) NotificationManager(org.eclipse.che.ide.api.notification.NotificationManager) Singleton(com.google.inject.Singleton) ProcessesPanelPresenter(org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter) Path(org.eclipse.che.ide.resource.Path) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 38 with Path

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

the class OrionEditorPresenter method onResourceCreated.

private void onResourceCreated(ResourceDelta delta) {
    if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) {
        return;
    }
    final Resource resource = delta.getResource();
    final Path movedFrom = delta.getFromPath();
    //file moved directly
    if (document.getFile().getLocation().equals(movedFrom)) {
        deletedFilesController.add(movedFrom.toString());
        document.setFile((File) resource);
        input.setFile((File) resource);
        updateContent();
    } else if (movedFrom.isPrefixOf(document.getFile().getLocation())) {
        //directory where file moved
        final Path relPath = document.getFile().getLocation().removeFirstSegments(movedFrom.segmentCount());
        final Path newPath = delta.getToPath().append(relPath);
        appContext.getWorkspaceRoot().getFile(newPath).then(new Operation<Optional<File>>() {

            @Override
            public void apply(Optional<File> file) throws OperationException {
                if (file.isPresent()) {
                    final Path location = document.getFile().getLocation();
                    deletedFilesController.add(location.toString());
                    generalEventBus.fireEvent(newFileTrackingStartEvent(file.get().getLocation().toString()));
                    document.setFile(file.get());
                    input.setFile(file.get());
                    updateTabReference(file.get(), location);
                    updateContent();
                }
            }
        });
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) Optional(com.google.common.base.Optional) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) File(org.eclipse.che.ide.api.resources.File)

Example 39 with Path

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

the class PlainJavaPagePresenter method onNodeSelected.

@Override
public void onNodeSelected(List<Node> nodes) {
    String projectName = dataObject.getName();
    List<String> nodeRelativePath = new LinkedList<>();
    for (Node node : nodes) {
        Path nodeLocation = ((ResourceNode) node).getData().getLocation();
        nodeRelativePath.add(nodeLocation.makeRelativeTo(valueOf(projectName)).toString());
    }
    if (isSourceSelected) {
        view.setSourceFolder(convertAttributeValuesToString(nodeRelativePath));
    } else {
        view.setLibraryFolder(convertAttributeValuesToString(nodeRelativePath));
    }
    onCoordinatesChanged();
}
Also used : Path(org.eclipse.che.ide.resource.Path) Node(org.eclipse.che.ide.api.data.tree.Node) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode) LinkedList(java.util.LinkedList)

Example 40 with Path

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

the class EditorPartStackPresenter method onResourceChanged.

@Override
public void onResourceChanged(ResourceChangedEvent event) {
    final ResourceDelta delta = event.getDelta();
    if (delta.getKind() != REMOVED) {
        return;
    }
    Path resourcePath = delta.getResource().getLocation();
    for (EditorPartPresenter editorPart : closedParts) {
        Path editorPath = editorPart.getEditorInput().getFile().getLocation();
        if (editorPath.equals(resourcePath)) {
            closedParts.remove(editorPart);
            return;
        }
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) ResourceDelta(org.eclipse.che.ide.api.resources.ResourceDelta) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

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