blob: 070813f37f41f8cfc8bbd4bae04a34a6904d630d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eugen Neufeld - initial API and implementation
******************************************************************************/
package org.eclipse.emf.ecp.view.internal.categorization.swt;
import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement;
import org.eclipse.emf.ecp.view.spi.categorization.swt.SWTCategorizationElementRenderer;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
import org.eclipse.emf.ecp.view.spi.model.VElement;
import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;
/**
* SWTCategorizationElementRendererService which provides the SWTCategorizationElementRenderer.
*
* @author Eugen Neufeld
*
*/
public class SWTCategorizationElementRendererService implements EMFFormsDIRendererService<VCategorizationElement> {
/**
* {@inheritDoc}
*
* @see org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService#isApplicable(VElement,ViewModelContext)
*/
@Override
public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
if (VCategorizationElement.class.isInstance(vElement)) {
if (VCategorizationElement.class.cast(vElement).getMainCategoryDepth() == 0) {
return 1;
}
}
return NOT_APPLICABLE;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#getRendererClass()
*/
@Override
public Class<? extends AbstractSWTRenderer<VCategorizationElement>> getRendererClass() {
return SWTCategorizationElementRenderer.class;
}
}