Skip to content

Commit

Permalink
[2032] Add the selection variable to form
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
  • Loading branch information
frouene committed Jun 8, 2023
1 parent 95fe9d0 commit 944cac2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Expand Up @@ -17,6 +17,7 @@
import java.util.Optional;
import java.util.function.Function;

import org.eclipse.sirius.components.collaborative.forms.variables.FormVariableProvider;
import org.eclipse.sirius.components.core.api.IObjectService;
import org.eclipse.sirius.components.forms.description.FormDescription;
import org.eclipse.sirius.components.forms.description.PageDescription;
Expand All @@ -39,6 +40,7 @@ public Optional<FormDescription> aggregate(List<PageDescription> pageDescription
for (Object object : objects) {
VariableManager pageVariableManager = new VariableManager();
pageVariableManager.put(VariableManager.SELF, object);
pageVariableManager.put(FormVariableProvider.SELECTION.name(), objects);

eligiblePageDescriptions.addAll(pageDescriptions.stream()
.filter(pageDescription -> pageDescription.getCanCreatePredicate().test(pageVariableManager))
Expand Down
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.collaborative.forms.variables;

import java.util.List;

import org.eclipse.sirius.components.core.api.variables.IVariableProvider;
import org.eclipse.sirius.components.core.api.variables.Variable;
import org.springframework.stereotype.Service;

/**
* Used to provide the variables available for all form operations.
*
* @author frouene
*/
@Service
public class FormVariableProvider implements IVariableProvider {

public static final Variable SELECTION = new Variable("selection", List.of(Object.class), "The selection of the workbench");

@Override
public List<Variable> getVariables(String operation) {
return List.of();
}
}

0 comments on commit 944cac2

Please sign in to comment.