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 RemoveEntriesAction extends ModelledActionImpl<Resource> {
19 public RemoveEntriesAction(Resource configuration) {
23 public void run(Resource runtimeDiagram) {
25 ISelection selection = getParameter(DiagramResource.URIs.ProfilesView_SelectedEntries);
26 final List<ResourcePair> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ResourcePair.class);
27 if(selectedEntries != null && !selectedEntries.isEmpty()) {
28 System.err.println("RemoveEntriesAction has " + selection + " for " + runtimeDiagram);
30 Simantics.getSession().syncRequest(new WriteRequest() {
33 public void perform(WriteGraph graph) throws DatabaseException {
35 DiagramResource DIA = DiagramResource.getInstance(graph);
36 for(ResourcePair entry : selectedEntries) {
37 Resource list = graph.getPossibleObject(entry.getFirst(), DIA.HasEntries);
38 OrderedSetUtils.remove(graph, list, entry.getSecond());
44 } catch (DatabaseException e) {