blob: 10112e41df8970f462f3d1bae445c198852fdbc4 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2016 CEA LIST.
*
*
* 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:
* David LOPEZ BETANCUR (CEA LIST)
* Sebastien REVOL (CEA LIST)
*
*****************************************************************************/
package org.eclipse.papyrus.moka.datavisualization.handlers;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.ui.command.AbstractCommandHandler;
import org.eclipse.papyrus.moka.datavisualization.profile.DataSource;
import org.eclipse.papyrus.moka.datavisualization.util.VisualizationUtil;
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Stereotype;
public class CreateXYGraphFromDataSourceHandler extends AbstractCommandHandler{
@Override
protected Command getCommand(IEvaluationContext context) {
EObject selectedElement = getSelectedElement();
if( !(selectedElement instanceof DataType) )
return null;
DataType dataType = (DataType) selectedElement;
Stereotype stereotype = VisualizationUtil.getDataSourceStereotype(dataType);
if( stereotype == null )
return null;
DataSource dataSource = (DataSource)dataType.getStereotypeApplication(stereotype);
return new CreateXYGraphFromDataSourceCommand(getEditingDomain(context), dataSource, context);
}
}