/******************************************************************************* * Copyright (c) 2006-2012 * Software Technology Group, Dresden University of Technology * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 * * 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: * Software Technology Group - TU Dresden, Germany; * DevBoost GmbH - Berlin, Germany * - initial API and implementation ******************************************************************************/ /* * Copyright (c) 2006, 2007 Borland Software Corporation * * 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: * Dmitry Stadnik (Borland) - initial API and implementation */ package org.reuseware.application.taipan.gmf.editor.edit.policies; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreateConnectionRequest; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.reuseware.application.taipan.gmf.editor.edit.commands.TaiPanReorientConnectionViewCommand; import org.reuseware.application.taipan.gmf.editor.providers.TaiPanElementTypes; /** * @generated */ public class WarshipGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy { /** * @generated */ protected Command getConnectionCompleteCommand( CreateConnectionRequest request) { IElementType elementType = getElementType(request); if (TaiPanElementTypes.BesiegePortOrder_4005 == elementType) { if (request.getSourceEditPart() != getHost()) { return getConnectionWithReorientedViewCompleteCommand(request); } } return super.getConnectionCompleteCommand(request); } /** * @generated */ protected IElementType getElementType(CreateConnectionRequest request) { if (request instanceof CreateConnectionViewAndElementRequest) { CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request) .getConnectionViewAndElementDescriptor() .getCreateElementRequestAdapter(); return (IElementType) requestAdapter.getAdapter(IElementType.class); } return null; } /** * @generated */ protected Command getConnectionWithReorientedViewCompleteCommand( CreateConnectionRequest request) { ICommandProxy c = (ICommandProxy) super .getConnectionCompleteCommand(request); CompositeCommand cc = (CompositeCommand) c.getICommand(); TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) .getEditingDomain(); TaiPanReorientConnectionViewCommand rcvCommand = new TaiPanReorientConnectionViewCommand( editingDomain, null); rcvCommand.setEdgeAdaptor(getViewAdapter()); cc.compose(rcvCommand); return c; } }