blob: cc4b007ec8f3f547532224c6edb7788c70c90b92 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 CEA LIST
*
* 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:
* Ansgar Radermacher (CEA LIST) <ansgar.radermacher@cea.fr> - initial API and implementation
*
*******************************************************************************/
package org.eclipse.papyrus.designer.patterns.transformations.handlers;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.designer.patterns.transformations.dialogs.SelectDesignPatternDialog;
import org.eclipse.papyrus.uml.diagram.common.handlers.CmdHandler;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.NamedElement;
/**
* Implementation class for ClassAction action
*/
public class ApplyDesignPatternHandler extends CmdHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
if(!(selectedEObject instanceof NamedElement)) {
return null;
}
final NamedElement element = (NamedElement)selectedEObject;
final Shell shell = Display.getCurrent().getActiveShell();
if(element instanceof NamedElement) {
SelectDesignPatternDialog selectDesignPattern = new SelectDesignPatternDialog(
shell, (NamedElement)element);
selectDesignPattern.open();
}
return null;
}
}