/****************************************************************************** * Copyright (c) 2016 Oracle * 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: * Konstantin Komissarchik - initial implementation and ongoing maintenance ******************************************************************************/ package org.eclipse.sapphire.services.internal; import java.util.SortedSet; import org.eclipse.sapphire.LocalizableText; import org.eclipse.sapphire.PropertyDef; import org.eclipse.sapphire.Text; import org.eclipse.sapphire.modeling.annotations.ReadOnly; import org.eclipse.sapphire.services.FactsService; import org.eclipse.sapphire.services.ServiceCondition; import org.eclipse.sapphire.services.ServiceContext; /** * Creates fact statements about property's read-only state by using semantical information * specified by @ReadOnly annotation. * * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> */ public final class ReadOnlyPropertyFactsService extends FactsService { @Text( "Cannot be modified" ) private static LocalizableText statement; static { LocalizableText.init( ReadOnlyPropertyFactsService.class ); } @Override protected void facts( final SortedSet<String> facts ) { facts.add( statement.text() ); } public static final class Condition extends ServiceCondition { @Override public boolean applicable( final ServiceContext context ) { return context.find( PropertyDef.class ).hasAnnotation( ReadOnly.class ); } } }