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);
}
}
});
}
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();
}
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());
}
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());
}
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);
}
Aggregations