Search in sources :

Example 81 with Resource

use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.

the class RevertPresenter method show.

public void show() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    ConfirmDialog confirmDialog = createConfirmDialog(project, resources);
    confirmDialog.show();
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 82 with Resource

use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.

the class ShowLogPresenter method showLogs.

/**
     * Fetches and displays commit log messages for specified range.
     *
     * @param range
     *         range to be logged
     */
private void showLogs(String range) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    service.showLog(project.getLocation(), toRelative(project, resources), range).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), null, constants.commandLog());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 83 with Resource

use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.

the class MergePresenter method mergeClicked.

/**
     * Performs actions when clicking Merge button.
     */
@Override
public void mergeClicked() {
    view.hide();
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && resources.length == 1);
    service.merge(project.getLocation(), resources[0].getLocation(), Path.valueOf(sourceURL)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 84 with Resource

use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.

the class MergePresenter method merge.

/**
     * Prepares to merging and opens Merge dialog.
     */
public void merge() {
    view.enableMergeButton(false);
    view.sourceCheckBox().setValue(false);
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && resources.length == 1);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
                printErrors(response.getErrorOutput(), constants.commandInfo());
                notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
                return;
            }
            mergeTarget = response.getItems().get(0);
            view.targetTextBox().setValue(mergeTarget.getRelativeURL());
            String repositoryRoot = mergeTarget.getRepositoryRoot();
            service.info(project.getLocation(), repositoryRoot, "HEAD", true).then(new Operation<InfoResponse>() {

                @Override
                public void apply(InfoResponse response) throws OperationException {
                    if (!response.getErrorOutput().isEmpty()) {
                        printErrors(response.getErrorOutput(), constants.commandInfo());
                        notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
                        return;
                    }
                    sourceURL = response.getItems().get(0).getURL();
                    SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0));
                    List<Node> children = new ArrayList<>();
                    if (response.getItems().size() > 1) {
                        for (int i = 1; i < response.getItems().size(); i++) {
                            SubversionItem item = response.getItems().get(i);
                            if (!"file".equals(item.getNodeKind())) {
                                children.add(new SubversionItemNode(item));
                            }
                        }
                    }
                    subversionTreeNode.setChildren(children);
                    view.setRootNode(subversionTreeNode);
                    view.show();
                    validateSourceURL();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError error) throws OperationException {
                    notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
                }
            });
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) Node(org.eclipse.che.ide.api.data.tree.Node) AbstractTreeNode(org.eclipse.che.ide.api.data.tree.AbstractTreeNode) Resource(org.eclipse.che.ide.api.resources.Resource) ArrayList(java.util.ArrayList) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 85 with Resource

use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.

the class MovePresenter method showMove.

public void showMove() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    source = resources[0];
    this.project = project;
    view.onShow(true);
    view.setProject(project);
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource)

Aggregations

Resource (org.eclipse.che.ide.api.resources.Resource)146 Project (org.eclipse.che.ide.api.resources.Project)73 OperationException (org.eclipse.che.api.promises.client.OperationException)48 Operation (org.eclipse.che.api.promises.client.Operation)46 PromiseError (org.eclipse.che.api.promises.client.PromiseError)40 Container (org.eclipse.che.ide.api.resources.Container)32 Path (org.eclipse.che.ide.resource.Path)30 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)22 Optional (com.google.common.base.Optional)15 File (org.eclipse.che.ide.api.resources.File)14 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)14 List (java.util.List)13 Promise (org.eclipse.che.api.promises.client.Promise)13 FunctionException (org.eclipse.che.api.promises.client.FunctionException)12 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 ArrayList (java.util.ArrayList)11 Function (org.eclipse.che.api.promises.client.Function)9 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)9 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)9 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)8