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<ProfileTuple> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ProfileTuple.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 for(ProfileTuple entry : selectedEntries) {
36 Resource list = graph.getPossibleObject(entry.getBaseProfile(), DIA.HasEntries);
37 OrderedSetUtils.remove(graph, list, entry.getEntry());
43 } catch (DatabaseException e) {