| /********************************************************************* |
| * Copyright (c) 2005, 2019 SAP SE |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * Contributors: |
| * SAP SE - initial API, implementation and documentation |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| **********************************************************************/ |
| package org.eclipse.graphiti.testtool.sketch.features.style; |
| |
| import org.eclipse.graphiti.features.IFeatureProvider; |
| import org.eclipse.graphiti.features.context.ICustomContext; |
| import org.eclipse.graphiti.features.custom.AbstractCustomFeature; |
| import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; |
| import org.eclipse.graphiti.mm.pictograms.PictogramElement; |
| import org.eclipse.graphiti.services.Graphiti; |
| |
| /** |
| * The Class IgnoreAllFeature. |
| */ |
| public class IgnoreAllFeature extends AbstractCustomFeature { |
| private static final String NAME = "Ignore All"; |
| |
| /** |
| * Instantiates a new ignore all feature. |
| * |
| * @param fp |
| * the fp |
| */ |
| public IgnoreAllFeature(IFeatureProvider fp) { |
| super(fp); |
| } |
| |
| public void execute(ICustomContext context) { |
| PictogramElement[] pes = context.getPictogramElements(); |
| |
| for (int i = 0; i < pes.length; i++) { |
| PictogramElement pe = pes[i]; |
| GraphicsAlgorithm ga = pe.getGraphicsAlgorithm(); |
| Graphiti.getGaService().resetAll(ga); |
| } |
| |
| } |
| |
| @Override |
| public String getName() { |
| return NAME; |
| } |
| |
| @Override |
| public boolean canExecute(ICustomContext context) { |
| PictogramElement[] pes = context.getPictogramElements(); |
| if (pes.length >= 1) { |
| GraphicsAlgorithm ga = pes[0].getGraphicsAlgorithm(); |
| if (ga != null) { |
| return true; |
| } |
| } |
| return false; |
| } |
| } |