blob: 7534b95921705f245c734002fe7570be23faa283 [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:
*
* Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.metrics.handlers;
import java.util.ArrayList;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.metrics.commands.CalculateRegisteredMeasuresCommand;
import org.eclipse.uml2.uml.Element;
/**
* This class handle the measures measurement
*
*/
public class MeasureMetricsHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
ArrayList<Element> selectedElements = getSelectionSet();
if (selectedElements.size() == 1) {
Element selectedElement = getSelection();
if (selectedElement != null) {
CalculateRegisteredMeasuresCommand calculateRegisteredMeasuresCommand = new CalculateRegisteredMeasuresCommand(selectedElement);
transactionalEditingDomain.getCommandStack().execute(calculateRegisteredMeasuresCommand);
}
}
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 != null) {
return true;
} else {
return false;
}
}
}