/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 SAP AG. | |
* 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: | |
* SAP AG - initial API, implementation and documentation | |
* | |
* </copyright> | |
* | |
*******************************************************************************/ | |
package org.eclipse.fmc.blockdiagram.editor.features.custom; | |
import org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramImageProvider; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.features.context.ICustomContext; | |
import org.eclipse.graphiti.mm.pictograms.PictogramElement; | |
import org.eclipse.graphiti.mm.pictograms.Shape; | |
import org.eclipse.graphiti.services.Graphiti; | |
/** | |
* Makes the selected shape(s) the backmost one. | |
* | |
* @author Benjamin Schmeling | |
* @author Rainer Thome | |
* | |
*/ | |
public class SendToBackCustomFeature extends FMCCustomFeature { | |
private static final String FEATURE_NAME = "Send to Back"; | |
private static final String IMAGE_ID = BlockDiagramImageProvider.ICON_SEND_TO_BACK; | |
/** | |
* Default constructor. | |
* | |
* @param featureProvider | |
* The feature provider for this feature. | |
*/ | |
public SendToBackCustomFeature(IFeatureProvider featureProvider) { | |
super(featureProvider); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.graphiti.features.impl.AbstractFeature#getName() | |
*/ | |
@Override | |
public String getName() { | |
return FEATURE_NAME; | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.custom.AbstractCustomFeature#getImageId() | |
*/ | |
@Override | |
public String getImageId() { | |
return IMAGE_ID; | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.custom.AbstractCustomFeature#canExecute | |
* (org.eclipse.graphiti.features.context.ICustomContext) | |
*/ | |
@Override | |
public boolean canExecute(ICustomContext context) { | |
if (context.getPictogramElements() != null | |
&& context.getPictogramElements().length > 0) { | |
for (PictogramElement pe : context.getPictogramElements()) { | |
if (!(pe instanceof Shape)) | |
return false; | |
} | |
return true; | |
} | |
return false; | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.custom.ICustomFeature#execute(org.eclipse | |
* .graphiti.features.context.ICustomContext) | |
*/ | |
@Override | |
public void execute(ICustomContext context) { | |
for (PictogramElement pe : context.getPictogramElements()) { | |
if (pe instanceof Shape) | |
Graphiti.getPeService().sendToBack((Shape) pe); | |
} | |
} | |
} |