| /** |
| * Copyright (c)2020 CEA LIST, Committer Name, and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * CEA LIST - Initial API and implementation |
| * Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr |
| * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr |
| * |
| */ |
| package org.eclipse.papyrus.pdp4eng.designer.ui; |
| |
| import org.eclipse.core.commands.ExecutionEvent; |
| import org.eclipse.core.commands.ExecutionException; |
| import org.eclipse.papyrus.pdp4eng.designer.controller.api.ModelTransfoFactory; |
| import org.eclipse.papyrus.requirements.sysml14.common.PapyrusAbstractHandler; |
| import org.eclipse.uml2.uml.Element; |
| /** |
| * Executes the creation of a new Data based on the Papyrus |
| * preferences page. |
| * |
| */ |
| public class TransformDataHandler extends PapyrusAbstractHandler { |
| public Object execute(ExecutionEvent event) throws ExecutionException { |
| super.execute(event); |
| Element selectedElement = getSelection(); |
| ModelTransfoFactory factory= new ModelTransfoFactory(); |
| if (selectedElement != null) { |
| transactionalEditingDomain.getCommandStack().execute(factory.getAbstractionDataCommand(transactionalEditingDomain, selectedElement)); |
| } |
| return null; |
| } |
| |
| /** |
| * |
| * @see org.eclipse.core.commands.AbstractHandler#isEnabled() |
| * |
| * @return true if the handler is possible |
| */ |
| @Override |
| public boolean isEnabled() { |
| Element selectedElement = getSelection(); |
| if (selectedElement instanceof org.eclipse.uml2.uml.Class) { |
| return true; |
| } else { |
| return false; |
| } |
| } |
| } |