1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.sysdyn.ui.browser.actions.remove;
14 import org.simantics.db.Resource;
15 import org.simantics.db.WriteGraph;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.layer0.adapter.impl.AbstractRemover;
18 import org.simantics.db.layer0.adapter.impl.EntityRemover;
19 import org.simantics.layer0.Layer0;
20 import org.simantics.sysdyn.SysdynResource;
27 public class ModuleSymbolRemover extends AbstractRemover {
29 public ModuleSymbolRemover(Resource resource) {
34 public void remove(WriteGraph g) throws DatabaseException {
37 Layer0 L0 = Layer0.getInstance(g);
38 SysdynResource sr = SysdynResource.getInstance(g);
40 //We need to remove the Module object, not just the symbol.
41 //Thus, if the resource is the symbol, find the parent Module first
42 if(g.isInstanceOf(resource, sr.ModuleSymbol)) {
43 Resource module = g.getPossibleObject(resource, L0.PartOf);
45 EntityRemover.remove(g, module, false); //Remove Module instead - was of type ModuleSymbol
47 EntityRemover.remove(g, resource, false);
50 EntityRemover.remove(g, resource, false); //Remove resource - not of type ModuleSymbol
55 public String toString() {
56 return getClass().getSimpleName() + resource;