Search in sources :

Example 1 with RecipeEditorPanel

use of org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel in project che by eclipse.

the class RecipePartPresenter method onSaveButtonClicked.

/** {@inheritDoc} */
@Override
public void onSaveButtonClicked() {
    RecipeEditorPanel editorPanel = recipesContainerPresenter.getEditorPanel(selectedRecipe);
    RecipeDescriptor recipeDescriptor = selectedRecipe.getDescriptor();
    final RecipeUpdate recipeUpdate = dtoFactory.createDto(RecipeUpdate.class).withId(recipeDescriptor.getId()).withType(recipeDescriptor.getType()).withScript(editorPanel.getScript()).withName(editorPanel.getName()).withTags(editorPanel.getTags());
    Promise<RecipeDescriptor> updateRecipe = service.updateRecipe(recipeUpdate);
    updateRecipe.then(new Operation<RecipeDescriptor>() {

        @Override
        public void apply(RecipeDescriptor recipeDescriptor) throws OperationException {
            RecipeDescriptor selectedRecipeDescriptor = recipes.get(selectedRecipe);
            selectedRecipeDescriptor.setScript(recipeDescriptor.getScript());
            selectedRecipeDescriptor.setTags(recipeDescriptor.getTags());
            selectedRecipeDescriptor.setName(recipeDescriptor.getName());
            selectedRecipe.setName(recipeDescriptor.getName());
            notificationManager.notify("Recipe \"" + recipeDescriptor.getName() + "\" was saved.");
        }
    });
    updateRecipe.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            if (arg.getMessage() != null) {
                notificationManager.notify(locale.failedToSaveRecipe(), arg.getMessage(), FAIL, FLOAT_MODE);
            }
        }
    });
}
Also used : RecipeUpdate(org.eclipse.che.api.machine.shared.dto.recipe.RecipeUpdate) PromiseError(org.eclipse.che.api.promises.client.PromiseError) RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with RecipeEditorPanel

use of org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel in project che by eclipse.

the class RecipePartPresenter method showEditorStubPanel.

private void showEditorStubPanel() {
    RecipeEditorPanel editorStubPanel = recipesContainerPresenter.getEditorStubPanel();
    RecipeEditorView stubPanelView = (RecipeEditorView) editorStubPanel.getView();
    stubPanelView.setName("");
    stubPanelView.setTags(Collections.<String>emptyList());
    editorStubPanel.setVisibleSaveCancelCloneDeleteBtns(false);
    editorStubPanel.setDelegate(this);
    recipesContainerPresenter.showEditorStubPanel();
}
Also used : RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel) RecipeEditorView(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorView)

Example 3 with RecipeEditorPanel

use of org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel in project che by eclipse.

the class RecipesContainerPresenter method addRecipePanel.

/**
     * Adds new recipe panel to container.
     *
     * @param recipe
     *         current recipe widget
     */
public void addRecipePanel(@NotNull RecipeWidget recipe) {
    if (recipePanels.get(recipe) != null) {
        return;
    }
    RecipeEditorPanel editorPanel = entityFactory.createRecipeEditorPanel(recipe.getDescriptor());
    recipePanels.put(recipe, editorPanel);
    RecipeEditorView editorView = ((RecipeEditorView) editorPanel.getView());
    RecipeDescriptor recipeDescriptor = recipe.getDescriptor();
    editorView.setScriptUrl(recipeDescriptor.getLink("get recipe script").getHref());
    editorView.setTags(recipeDescriptor.getTags());
    editorView.setName(recipeDescriptor.getName());
}
Also used : RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) RecipeEditorView(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorView)

Example 4 with RecipeEditorPanel

use of org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel in project che by eclipse.

the class RecipesContainerPresenter method showEditorPanel.

/**
     * Shows recipe panel into container.
     *
     * @param recipe
     *         current recipe widget
     */
public void showEditorPanel(@NotNull RecipeWidget recipe) {
    RecipeEditorPanel recipeEditorPanel = recipePanels.get(recipe);
    recipeEditorPanel.showEditor();
    view.showWidget(recipeEditorPanel.getView());
}
Also used : RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel)

Example 5 with RecipeEditorPanel

use of org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel in project che by eclipse.

the class RecipePartPresenter method onRecipeClicked.

/** {@inheritDoc} */
@Override
public void onRecipeClicked(@NotNull RecipeWidget recipeWidget) {
    if (selectedRecipe != null && selectedRecipe.equals(recipeWidget)) {
        return;
    }
    for (RecipeWidget recipe : recipes.keySet()) {
        recipe.unSelect();
    }
    selectedRecipe = recipeWidget;
    selectedRecipe.select();
    recipesContainerPresenter.showEditorPanel(selectedRecipe);
    RecipeEditorPanel recipePanel = recipesContainerPresenter.getEditorPanel(selectedRecipe);
    recipePanel.setDelegate(this);
}
Also used : RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel) RecipeWidget(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget)

Aggregations

RecipeEditorPanel (org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel)7 RecipeDescriptor (org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor)2 RecipeEditorView (org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorView)2 NewRecipe (org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe)1 RecipeUpdate (org.eclipse.che.api.machine.shared.dto.recipe.RecipeUpdate)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 RecipeWidget (org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget)1