blob: e5d5eadde01a18df1f04b3cb83eefad4a1788643 [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 RemoveSupertypeCommand extends ViatraEditorCommand
{
private IModelElement targetElem, supertypeElem;
private String targetElem_name, supertypeElem_name;
public void setTargetElem(IModelElement e)
{
targetElem = e;
targetElem_name = e.getFullyQualifiedName();
}
public void setSupertypeElem(IModelElement e)
{
supertypeElem = e;
supertypeElem_name = e.getFullyQualifiedName();
}
@Override
public void execute() throws VPMCoreException
{
targetElem = Lookup(targetElem, targetElem_name);
supertypeElem = Lookup(supertypeElem, supertypeElem_name);
if (targetElem != null && supertypeElem != null)
{
iTransactionID = targetElem.getModelSpace().getTransactionManager().beginUndoableTransaction();
//targetElem.getModelSpace().getUndoManager().nextUndoBlock("vte_addst");
targetElem.getModelSpace().getModelManager().deleteSupertypeOf(supertypeElem, targetElem);
targetElem.getModelSpace().getTransactionManager().commitTransaction();
}
}
@Override
public void undo() throws VPMCoreException
{
targetElem = Lookup(targetElem, targetElem_name);
supertypeElem = Lookup(supertypeElem, supertypeElem_name);
if (targetElem != null && supertypeElem != null)
{
targetElem.getModelSpace().getTransactionManager().undoTransaction(iTransactionID);
//targetElem.getModelSpace().getUndoManager().undo("vte_addst");
}
}
}