Search in sources :

Example 16 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class DebugConfigurationsManagerImpl method apply.

@Override
public void apply(final DebugConfiguration debugConfiguration) {
    if (debugConfiguration == null) {
        return;
    }
    if (debuggerManager.getActiveDebugger() != null) {
        dialogFactory.createMessageDialog(localizationConstants.connectToRemote(), localizationConstants.debuggerAlreadyConnected(), null).show();
        return;
    }
    final Debugger debugger = debuggerManager.getDebugger(debugConfiguration.getType().getId());
    if (debugger != null) {
        debuggerManager.setActiveDebugger(debugger);
        currentProjectPathMacro.expand().then(new Operation<String>() {

            @Override
            public void apply(String arg) throws OperationException {
                Map<String, String> connectionProperties = prepareConnectionProperties(debugConfiguration, arg);
                debugger.connect(connectionProperties).catchError(new Operation<PromiseError>() {

                    @Override
                    public void apply(PromiseError arg) throws OperationException {
                        debuggerManager.setActiveDebugger(null);
                    }
                });
            }
        });
    }
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) HashMap(java.util.HashMap) Map(java.util.Map) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 17 with OperationException

use of org.eclipse.che.api.promises.client.OperationException 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 18 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class ProcessesPanelPresenter method onPreviewSsh.

@Override
public void onPreviewSsh(String machineId) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
        return;
    }
    Machine machine = (Machine) machineTreeNode.getData();
    final OutputConsole defaultConsole = commandConsoleFactory.create("SSH");
    addCommandOutput(machineId, defaultConsole);
    final String machineName = machine.getConfig().getName();
    String sshServiceAddress = getSshServerAddress(machine);
    final String machineHost;
    final String sshPort;
    if (sshServiceAddress != null) {
        String[] parts = sshServiceAddress.split(":");
        machineHost = parts[0];
        sshPort = (parts.length == 2) ? parts[1] : SSH_PORT;
    } else {
        sshPort = SSH_PORT;
        machineHost = "";
    }
    // user
    final String userName;
    String user = machine.getRuntime().getProperties().get("config.user");
    if (isNullOrEmpty(user)) {
        userName = "root";
    } else {
        userName = user;
    }
    // ssh key
    final String workspaceName = appContext.getWorkspace().getConfig().getName();
    Promise<SshPairDto> sshPairDtoPromise = sshServiceClient.getPair("workspace", machine.getWorkspaceId());
    sshPairDtoPromise.then(new Operation<SshPairDto>() {

        @Override
        public void apply(SshPairDto sshPairDto) throws OperationException {
            if (defaultConsole instanceof DefaultOutputConsole) {
                ((DefaultOutputConsole) defaultConsole).enableAutoScroll(false);
                ((DefaultOutputConsole) defaultConsole).printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort, workspaceName, userName, localizationConstant.sshConnectInfoPrivateKey(sshPairDto.getPrivateKey())));
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            if (defaultConsole instanceof DefaultOutputConsole) {
                ((DefaultOutputConsole) defaultConsole).enableAutoScroll(false);
                ((DefaultOutputConsole) defaultConsole).printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort, workspaceName, userName, localizationConstant.sshConnectInfoNoPrivateKey()));
            }
        }
    });
}
Also used : SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Operation(org.eclipse.che.api.promises.client.Operation) ExtendedMachine(org.eclipse.che.api.core.model.workspace.ExtendedMachine) Machine(org.eclipse.che.api.core.model.machine.Machine) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 19 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class SshCategoryPresenter method updateTargetRecipe.

/**
     * Updates as existent target recipe and save it.
     */
private void updateTargetRecipe() {
    RecipeUpdate recipeUpdate = dtoFactory.createDto(RecipeUpdate.class).withId(selectedTarget.getRecipe().getId()).withName(sshView.getTargetName()).withType(selectedTarget.getRecipe().getType()).withTags(selectedTarget.getRecipe().getTags()).withDescription(selectedTarget.getRecipe().getDescription()).withScript("{" + "\"host\": \"" + selectedTarget.getHost() + "\", " + "\"port\": \"" + selectedTarget.getPort() + "\", " + "\"username\": \"" + selectedTarget.getUserName() + "\", " + "\"password\": \"" + selectedTarget.getPassword() + "\"" + "}");
    Promise<RecipeDescriptor> updateRecipe = recipeServiceClient.updateRecipe(recipeUpdate);
    updateRecipe.then(new Operation<RecipeDescriptor>() {

        @Override
        public void apply(RecipeDescriptor recipe) throws OperationException {
            onTargetSaved(recipe);
        }
    });
    updateRecipe.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            dialogFactory.createMessageDialog("Error", machineLocale.targetsViewSaveError(), null).show();
        }
    });
}
Also used : RecipeUpdate(org.eclipse.che.api.machine.shared.dto.recipe.RecipeUpdate) PromiseError(org.eclipse.che.api.promises.client.PromiseError) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 20 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class SshCategoryPresenter method createTargetRecipe.

/**
     * Create a new target recipe and save it.
     */
private void createTargetRecipe() {
    List<String> tags = new ArrayList<>();
    tags.add(this.getCategory());
    NewRecipe newRecipe = dtoFactory.createDto(NewRecipe.class).withName(selectedTarget.getName()).withType(getCategory()).withScript("{" + "\"host\": \"" + selectedTarget.getHost() + "\", " + "\"port\": \"" + selectedTarget.getPort() + "\", " + "\"username\": \"" + selectedTarget.getUserName() + "\", " + "\"password\": \"" + selectedTarget.getPassword() + "\"" + "}").withTags(tags);
    Promise<RecipeDescriptor> createRecipe = recipeServiceClient.createRecipe(newRecipe);
    createRecipe.then(new Operation<RecipeDescriptor>() {

        @Override
        public void apply(RecipeDescriptor recipe) throws OperationException {
            onTargetSaved(recipe);
        }
    });
    createRecipe.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            dialogFactory.createMessageDialog("Error", machineLocale.targetsViewSaveError(), null).show();
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException) NewRecipe(org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)158 PromiseError (org.eclipse.che.api.promises.client.PromiseError)123 Operation (org.eclipse.che.api.promises.client.Operation)115 Project (org.eclipse.che.ide.api.resources.Project)53 Resource (org.eclipse.che.ide.api.resources.Resource)48 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)19 Promise (org.eclipse.che.api.promises.client.Promise)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)15 Path (org.eclipse.che.ide.resource.Path)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)14 ArrayList (java.util.ArrayList)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Optional (com.google.common.base.Optional)10 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10