| /********************************************************************* |
| * 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; |
| |
| import org.eclipse.graphiti.features.IFeatureProvider; |
| import org.eclipse.graphiti.features.context.IContext; |
| 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.Diagram; |
| import org.eclipse.graphiti.mm.pictograms.PictogramElement; |
| import org.eclipse.graphiti.mm.pictograms.Shape; |
| |
| /** |
| * The Class AbstractColorFeature. |
| */ |
| public abstract class AbstractColorFeature extends AbstractCustomFeature { |
| |
| /** |
| * The Constructor. |
| * |
| * @param fp |
| * the fp |
| */ |
| public AbstractColorFeature(IFeatureProvider fp) { |
| super(fp); |
| } |
| |
| @Override |
| public boolean isAvailable(IContext context) { |
| boolean ret = false; |
| if (context instanceof ICustomContext) { |
| PictogramElement[] pes = ((ICustomContext) context).getPictogramElements(); |
| if (pes != null && pes.length >= 1) { |
| ret = true; |
| for (int i = 0; ret && i < pes.length; i++) { |
| PictogramElement pe = pes[i]; |
| if (pe instanceof Shape && !(pe instanceof Diagram)) { |
| Shape s = (Shape) pe; |
| GraphicsAlgorithm ga = s.getGraphicsAlgorithm(); |
| if (ga != null) { |
| ret = true; |
| } |
| } |
| } |
| } |
| } |
| return ret; |
| } |
| } |