blob: 04a8c7b20d3ec8f9d3a52c2d7c7bd75e6bd5599d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.treeeditor.commands;
import org.eclipse.viatra2.core.IModelElement;
import org.eclipse.viatra2.errors.VPMCoreException;
public class RemoveTypeCommand extends ViatraEditorCommand
{
private IModelElement targetElem, typeElem;
private String targetElem_name, typeElem_name;
public void setTargetElem(IModelElement e)
{
targetElem = e;
targetElem_name = e.getFullyQualifiedName();
}
public void setTypeElem(IModelElement e)
{
typeElem = e;
typeElem_name = e.getFullyQualifiedName();
}
@Override
public void execute() throws VPMCoreException
{
targetElem = Lookup(targetElem, targetElem_name);
typeElem = Lookup(typeElem, typeElem_name);
if (targetElem != null && typeElem != null)
{
iTransactionID = targetElem.getModelSpace().getTransactionManager().beginUndoableTransaction();
//targetElem.getModelSpace().getUndoManager().nextUndoBlock("vte_addty");
targetElem.getModelSpace().getModelManager().deleteInstanceOf(typeElem, targetElem);
targetElem.getModelSpace().getTransactionManager().commitTransaction();
}
}
@Override
public void undo() throws VPMCoreException
{
targetElem = Lookup(targetElem, targetElem_name);
typeElem = Lookup(typeElem, typeElem_name);
if (targetElem != null && typeElem != null)
{
targetElem.getModelSpace().getTransactionManager().undoTransaction(iTransactionID);
//targetElem.getModelSpace().getUndoManager().undo("vte_addty");
}
}
}