Search in sources :

Example 56 with Path

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

the class ResetFilesPresenter method onResetClicked.

/** {@inheritDoc} */
@Override
public void onResetClicked() {
    Path[] paths = new Path[0];
    for (IndexFile file : indexedFiles) {
        if (!file.isIndexed()) {
            paths = add(paths, Path.valueOf(file.getPath()));
        }
    }
    final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
    if (paths.length == 0) {
        view.close();
        console.print(constant.nothingToReset());
        consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
        notificationManager.notify(constant.nothingToReset());
        return;
    }
    view.close();
    service.reset(appContext.getDevMachine(), project.getLocation(), "HEAD", ResetType.MIXED, paths).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.resetFilesSuccessfully());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.resetFilesSuccessfully());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            String errorMassage = error.getMessage() != null ? error.getMessage() : constant.resetFilesFailed();
            console.printError(errorMassage);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(errorMassage);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) PromiseError(org.eclipse.che.api.promises.client.PromiseError) IndexFile(org.eclipse.che.api.git.shared.IndexFile) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 57 with Path

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

the class NewJavaSourceFilePresenter method getPackageQualifier.

private String getPackageQualifier(String packageFragment) {
    final Optional<Resource> srcFolder = parent.getParentWithMarker(SourceFolderMarker.ID);
    if (!srcFolder.isPresent() && isNullOrEmpty(packageFragment)) {
        return "\n";
    }
    final Path path = parent.getLocation().removeFirstSegments(srcFolder.get().getLocation().segmentCount());
    String packageFQN = path.toString().replace('/', '.');
    if (!packageFragment.isEmpty()) {
        packageFQN = packageFQN.isEmpty() ? packageFragment : packageFQN + '.' + packageFragment;
    }
    if (!packageFQN.isEmpty()) {
        return "package " + packageFQN + ";\n\n";
    } else {
        return "\n";
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 58 with Path

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

the class JavaCommandPagePresenter method setMainClass.

public void setMainClass(Resource resource, String fqn) {
    if (editedCommandModel.getMainClass().equals(resource.getLocation().toString())) {
        return;
    }
    final Optional<Project> project = resource.getRelatedProject();
    if (!project.isPresent()) {
        return;
    }
    final Path relPath = resource.getLocation().removeFirstSegments(project.get().getLocation().segmentCount());
    view.setMainClass(relPath.toString());
    String commandLine = editedCommandModel.getCommandLine();
    commandLine = commandLine.replace(editedCommandModel.getMainClass(), relPath.toString());
    commandLine = commandLine.replace(' ' + editedCommandModel.getMainClassFQN(), ' ' + fqn);
    editedCommandModel.setMainClass(view.getMainClass());
    editedCommandModel.setCommandLine(commandLine);
    editedCommand.setCommandLine(editedCommandModel.toCommandLine());
    listener.onDirtyStateChanged();
}
Also used : Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project)

Example 59 with Path

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

the class BreakpointManagerImpl method registerEventHandlers.

/**
     * Registers events handlers.
     */
private void registerEventHandlers(EventBus eventBus) {
    eventBus.addHandler(WorkspaceReadyEvent.getType(), new WorkspaceReadyEvent.WorkspaceReadyHandler() {

        @Override
        public void onWorkspaceReady(WorkspaceReadyEvent event) {
            restoreBreakpoints();
        }
    });
    eventBus.addHandler(EditorOpenedEvent.TYPE, new EditorOpenedEventHandler() {

        @Override
        public void onEditorOpened(EditorOpenedEvent event) {
            onOpenEditor(event.getFile().getLocation().toString(), event.getEditor());
        }
    });
    eventBus.addHandler(DeleteProjectEvent.TYPE, new DeleteProjectHandler() {

        @Override
        public void onProjectDeleted(DeleteProjectEvent event) {
            if (breakpoints.isEmpty()) {
                return;
            }
            ProjectConfigDto config = event.getProjectConfig();
            String path = config.getPath() + "/";
            deleteBreakpoints(getBreakpointPaths(path));
        }
    });
    eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {

        @Override
        public void onResourceChanged(ResourceChangedEvent event) {
            if (event.getDelta().getKind() == ResourceDelta.REMOVED) {
                if (breakpoints.isEmpty()) {
                    return;
                }
                final Resource resource = event.getDelta().getResource();
                Path path = resource.getLocation();
                if (resource.isFolder()) {
                    path.addTrailingSeparator();
                    deleteBreakpoints(getBreakpointPaths(path.toString()));
                } else if (resource.isFile()) {
                    deleteBreakpoints(Collections.singleton(path.toString()));
                }
            }
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DeleteProjectEvent(org.eclipse.che.ide.api.event.project.DeleteProjectEvent) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) DeleteProjectHandler(org.eclipse.che.ide.api.event.project.DeleteProjectHandler) EditorOpenedEventHandler(org.eclipse.che.ide.api.editor.EditorOpenedEventHandler) WorkspaceReadyEvent(org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent)

Example 60 with Path

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

the class EditorContentSynchronizerImpl method unTrackEditor.

/**
     * Stops to track given editor.
     *
     * @param editor
     *         editor to stop tracking
     */
@Override
public void unTrackEditor(EditorPartPresenter editor) {
    Path path = editor.getEditorInput().getFile().getLocation();
    EditorGroupSynchronization group = editorGroups.get(path);
    if (group == null) {
        return;
    }
    group.removeEditor(editor);
    if (group.getSynchronizedEditors().isEmpty()) {
        group.unInstall();
        editorGroups.remove(path);
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path)

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