1 package org.simantics.diagram.profile.view;
5 import org.eclipse.jface.viewers.ISelection;
6 import org.simantics.Simantics;
7 import org.simantics.browsing.ui.swt.ModelledActionImpl;
8 import org.simantics.db.Resource;
9 import org.simantics.db.WriteGraph;
10 import org.simantics.db.common.request.WriteRequest;
11 import org.simantics.db.common.utils.OrderedSetUtils;
12 import org.simantics.db.exception.DatabaseException;
13 import org.simantics.db.layer0.SelectionHints;
14 import org.simantics.diagram.stubs.DiagramResource;
15 import org.simantics.utils.ui.ISelectionUtils;
17 public class AddEntriesAction extends ModelledActionImpl<Resource> {
19 public AddEntriesAction(Resource configuration) {
23 public void run(final Resource runtimeDiagram) {
25 ISelection selection = getParameter(DiagramResource.URIs.ProfilesView_SelectedAvailableEntries);
26 final List<Resource> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, Resource.class);
27 if(selectedEntries != null && !selectedEntries.isEmpty()) {
29 Simantics.getSession().syncRequest(new WriteRequest() {
32 public void perform(WriteGraph graph) throws DatabaseException {
34 DiagramResource DIA = DiagramResource.getInstance(graph);
35 Resource activeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
36 Resource list = graph.getPossibleObject(activeProfile, DIA.HasEntries);
38 for(Resource entry : selectedEntries) {
39 OrderedSetUtils.add(graph, list, entry);
45 } catch (DatabaseException e) {