1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.actions;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.exception.DatabaseException;
\r
17 import org.simantics.layer0.Layer0;
\r
18 import org.simantics.operation.Layer0X;
\r
19 import org.simantics.sysdyn.SysdynResource;
\r
20 import org.simantics.ui.DoubleClickEvent;
\r
21 import org.simantics.ui.IDoubleClickAction;
\r
22 import org.simantics.ui.utils.ResourceAdaptionUtils;
\r
23 import org.simantics.utils.ui.action.PriorityAction;
\r
25 public class ConsumeUnnecessaryEntersAction implements IDoubleClickAction {
\r
28 public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {
\r
29 ReadGraph g = e.getGraph();
\r
30 Layer0 l0 = Layer0.getInstance(g);
\r
31 Layer0X L0X = Layer0X.getInstance(g);
\r
32 final Resource resource = ResourceAdaptionUtils.toSingleResource(e.getResource());
\r
33 if(resource == null)
\r
35 SysdynResource sr = SysdynResource.getInstance(g);
\r
37 if(g.isInstanceOf(resource, sr.SysdynModel) || g.isInstanceOf(resource, sr.Variable)) {
\r
39 } else if(g.hasStatement(resource, L0X.Represents)){
\r
40 Resource represents = g.getSingleObject(resource, L0X.Represents);
\r
41 if (g.isInstanceOf(represents, sr.Variable)) {
\r
47 private void consume(DoubleClickEvent e) {
\r
48 e.add(new PriorityAction(PriorityAction.HIGH) {
\r