| /******************************************************************************* |
| * Copyright (c) 2013 IBM Corporation and others. |
| * 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.stem.model.ui.editor.parts; |
| |
| import org.eclipse.gef.commands.Command; |
| import org.eclipse.gef.editpolicies.ComponentEditPolicy; |
| import org.eclipse.gef.requests.GroupRequest; |
| import org.eclipse.stem.model.ui.editor.commands.CompartmentDeleteCommand; |
| import org.eclipse.stem.model.ui.editor.vismodel.CompartmentElement; |
| import org.eclipse.stem.model.ui.editor.vismodel.ModelElement; |
| |
| |
| /** |
| * |
| * |
| */ |
| class CompartmentComponentEditPolicy extends ComponentEditPolicy { |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest) |
| */ |
| protected Command createDeleteCommand(GroupRequest deleteRequest) { |
| Object parent = getHost().getParent().getModel(); |
| Object child = getHost().getModel(); |
| if (parent instanceof ModelElement && child instanceof CompartmentElement) { |
| return new CompartmentDeleteCommand((ModelElement) parent, (CompartmentElement) child); |
| } |
| return super.createDeleteCommand(deleteRequest); |
| } |
| } |