| 1 | /* |
| 2 | *Copyright 2007, SDQ, IPD, University of Karlsruhe |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.gmf.usage.edit.commands; |
| 5 | |
| 6 | import java.util.List; |
| 7 | |
| 8 | import org.eclipse.core.runtime.IAdaptable; |
| 9 | import org.eclipse.core.runtime.IProgressMonitor; |
| 10 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
| 11 | import org.eclipse.gmf.runtime.common.core.command.CommandResult; |
| 12 | import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; |
| 13 | import org.eclipse.gmf.runtime.notation.Edge; |
| 14 | import org.eclipse.gmf.runtime.notation.View; |
| 15 | |
| 16 | /** |
| 17 | * @generated |
| 18 | */ |
| 19 | public class PalladioComponentModelReorientConnectionViewCommand extends |
| 20 | AbstractTransactionalCommand { |
| 21 | |
| 22 | /** |
| 23 | * @generated |
| 24 | */ |
| 25 | private IAdaptable edgeAdaptor; |
| 26 | |
| 27 | /** |
| 28 | * @generated |
| 29 | */ |
| 30 | public PalladioComponentModelReorientConnectionViewCommand( |
| 31 | TransactionalEditingDomain editingDomain, String label) { |
| 32 | super(editingDomain, label, null); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @generated |
| 37 | */ |
| 38 | public List getAffectedFiles() { |
| 39 | View view = (View) edgeAdaptor.getAdapter(View.class); |
| 40 | if (view != null) { |
| 41 | return getWorkspaceFiles(view); |
| 42 | } |
| 43 | return super.getAffectedFiles(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @generated |
| 48 | */ |
| 49 | public IAdaptable getEdgeAdaptor() { |
| 50 | return edgeAdaptor; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @generated |
| 55 | */ |
| 56 | public void setEdgeAdaptor(IAdaptable edgeAdaptor) { |
| 57 | this.edgeAdaptor = edgeAdaptor; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @generated |
| 62 | */ |
| 63 | protected CommandResult doExecuteWithResult( |
| 64 | IProgressMonitor progressMonitor, IAdaptable info) { |
| 65 | assert null != edgeAdaptor : "Null child in PalladioComponentModelReorientConnectionViewCommand"; //$NON-NLS-1$ |
| 66 | Edge edge = (Edge) getEdgeAdaptor().getAdapter(Edge.class); |
| 67 | assert null != edge : "Null edge in PalladioComponentModelReorientConnectionViewCommand"; //$NON-NLS-1$ |
| 68 | View tempView = edge.getSource(); |
| 69 | edge.setSource(edge.getTarget()); |
| 70 | edge.setTarget(tempView); |
| 71 | return CommandResult.newOKCommandResult(); |
| 72 | } |
| 73 | } |