/*******************************************************************************
* <copyright>
*
* Copyright (c) 2005, 2010 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>
*
*******************************************************************************/
/*
* Created on 12.12.2005
*/
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;
}
}