Package org.eclipse.sapphire.java

Examples of org.eclipse.sapphire.java.JavaType


        {
            part = new ActuatorPart();
        }
        else if( definition instanceof CustomFormComponentDef )
        {
            final JavaType customPartImplClass = ( (CustomFormComponentDef) definition ).getImplClass().target();
           
            if( customPartImplClass != null )
            {
                try
                {
                    part = (SapphirePart) ( (Class<?>) customPartImplClass.artifact() ).newInstance();
                }
                catch( Exception e )
                {
                    Sapphire.service( LoggingService.class ).log( e );
                }
View Full Code Here


                    {
                        if( element instanceof ServiceDef )
                        {
                            final ServiceDef def = (ServiceDef) element;
                            final String id = def.getId().text();
                            final JavaType type = def.getImplementation().target();
                            final Class<?> cl = ( type == null ? null : (Class<?>) type.artifact() );
                           
                            if( id != null && id.startsWith( "Sapphire." ) &&
                                cl != null && ConversionService.class.isAssignableFrom( cl ) )
                            {
                                return true;
                            }
                        }

                        return false;
                    }
                };

                final String functions = op.execute( getExtensions(), filter );

                content = loadResource( "html/services/ConversionService.html" );
                content = content.replace( "##servicess##", functions );
            }
            else if( href.startsWith( "html/services/FactsService.html" ) )
            {
                final ExtensionSummaryExportOp op = ExtensionSummaryExportOp.TYPE.instantiate();
                op.setCreateFinishedDocument( false );

                final ExtensionSummarySectionDef section = op.getSections().insert();
                section.setExtensionType( SapphireExtensionDef.PROP_SERVICES.name() );
                section.setIncludeSectionHeader( false );

                final ExtensionSummarySectionColumnDef idColumn = section.getColumns().insert();
                idColumn.setName( ServiceDef.PROP_ID.name() );

                final ExtensionSummarySectionColumnDef descColumn = section.getColumns().insert();
                descColumn.setName( ServiceDef.PROP_DESCRIPTION.name() );
               
                final Filter<Element> filter = new Filter<Element>()
                {
                    @Override
                    public boolean allows( final Element element )
                    {
                        if( element instanceof ServiceDef )
                        {
                            final ServiceDef def = (ServiceDef) element;
                            final String id = def.getId().text();
                            final JavaType type = def.getImplementation().target();
                            final Class<?> cl = ( type == null ? null : (Class<?>) type.artifact() );
                           
                            if( id != null && id.startsWith( "Sapphire." ) &&
                                cl != null && FactsService.class.isAssignableFrom( cl ) )
                            {
                                return true;
View Full Code Here

           
            File file = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
            file = new File( file, ".metadata/.plugins/org.eclipse.sapphire.ui/state" );
            file = new File( file, digest );
           
            final JavaType persistedStateElementJavaType = definition().getPersistentStateElementType().target();
           
            if( persistedStateElementJavaType == null )
            {
                throw new IllegalStateException();
            }
           
            final ElementType persistedStateElementType = ElementType.read( (Class<?>) persistedStateElementJavaType.artifact() );
           
            try
            {
                final Resource resource = new RootXmlResource( new XmlResourceStore( file ) ) ;
               
View Full Code Here

           
            if( action != null && isForContext( def ) && checkCondition( def ) )
            {
                try
                {
                    final JavaType implType = def.getImplClass().target();
                   
                    if( implType != null )
                    {
                        final Class<?> implClass = (Class<?>) implType.artifact();
                       
                        if( implClass != null )
                        {
                            final SapphireActionHandler handler = (SapphireActionHandler) implClass.newInstance();
                            handler.init( action, def );
View Full Code Here

           
            if( action != null && isForContext( def ) && checkCondition( def ) )
            {
                try
                {
                    final JavaType implType = def.getImplClass().target();
                   
                    if( implType != null )
                    {
                        final Class<?> implClass = (Class<?>) implType.artifact();
                       
                        if( implClass != null )
                        {
                            final SapphireActionHandlerFactory factory = (SapphireActionHandlerFactory) implClass.newInstance();
                            factory.init( action, def );
View Full Code Here

        {
            if( isForContext( def ) )
            {
                try
                {
                    final JavaType implClass = def.getImplClass().target();
                   
                    if( implClass != null )
                    {
                        final SapphireActionHandlerFilter filter = (SapphireActionHandlerFilter) ( (Class<?>) implClass.artifact() ).newInstance();
                        addFilter( filter );
                    }
                }
                catch( Exception e )
                {
View Full Code Here

    private boolean checkCondition( final ISapphireConditionHostDef def )
    {
        try
        {
            final JavaType conditionType = def.getConditionClass().target();
           
            if( conditionType != null )
            {
                final Class<?> conditionClass = (Class<?>) conditionType.artifact();
               
                if( conditionClass != null )
                {
                    final SapphireCondition condition = SapphireCondition.create( this.part, conditionClass, null );
                   
View Full Code Here

    }
   
    @SuppressWarnings( "unchecked" )
    private static <T> Class<T> resolve( final ReferenceValue<JavaTypeName,JavaType> ref )
    {
        final JavaType type = ref.target();
        return ( type != null ? (Class<T>) type.artifact() : null );
    }
View Full Code Here

            final Map<?,?> properties = (Map<?,?>) data;
   
            final String sdef = (String) properties.get( "sdef" );
            final DefinitionLoader.Reference<WizardDef> definition = DefinitionLoader.context( context ).sdef( sdef ).wizard();
           
            final JavaType operationJavaType = definition.resolve().getElementType().target();
            final ElementType operationElementType = ElementType.read( (Class<?>) operationJavaType.artifact(), true );
   
            init( operationElementType, definition );
           
            this.editor = (String) properties.get( "editor" );
        }
View Full Code Here

       
        final String val = value.text( false );
       
        if( val != null )
        {
            final JavaType type = (JavaType) value.target();
           
            if( type == null )
            {
                return Status.createOkStatus();
            }
           
            final JavaTypeKind kind = type.kind();
           
            switch( kind )
            {
                case CLASS:
                {
                    if( ! kinds.contains( JavaTypeKind.CLASS ) )
                    {
                        final String label = value.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
                        final String msg = classNotAllowed.format( val, label );
                        return Status.createErrorStatus( msg );
                    }
                   
                    break;
                }
                case ABSTRACT_CLASS:
                {
                    if( ! kinds.contains( JavaTypeKind.ABSTRACT_CLASS ) )
                    {
                        final String label = value.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
                        final String msg = abstractClassNotAllowed.format( val, label );
                        return Status.createErrorStatus( msg );
                    }
                   
                    break;
                }
                case INTERFACE:
                {
                    if( ! kinds.contains( JavaTypeKind.INTERFACE ) )
                    {
                        final String label = value.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
                        final String msg = interfaceNotAllowed.format( val, label );
                        return Status.createErrorStatus( msg );
                    }
                   
                    break;
                }
                case ANNOTATION:
                {
                    if( ! kinds.contains( JavaTypeKind.ANNOTATION ) )
                    {
                        final String label = value.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
                        final String msg = annotationNotAllowed.format( val, label );
                        return Status.createErrorStatus( msg );
                    }
                   
                    break;
                }
                case ENUM:
                {
                    if( ! kinds.contains( JavaTypeKind.ENUM ) )
                    {
                        final String label = value.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
                        final String msg = enumNotAllowed.format( val, label );
                        return Status.createErrorStatus( msg );
                    }
                   
                    break;
                }
                default:
                {
                    throw new IllegalStateException();
                }
            }
           
            if( kind != JavaTypeKind.ENUM && kind != JavaTypeKind.ANNOTATION )
            {
                if( behavior == JavaTypeConstraintBehavior.ALL )
                {
                    for( String baseType : requiredBaseTypes )
                    {
                        if( ! type.isOfType( baseType ) )
                        {
                            final LocalizableText template = ( type.kind() == JavaTypeKind.INTERFACE ? interfaceDoesNotExtend : classDoesNotImplementOrExtend );
                            final String msg = template.format( val, baseType );
                            return Status.createErrorStatus( msg );
                        }
                    }
                }
                else
                {
                    boolean satisfied = false;
                   
                    for( String baseType : requiredBaseTypes )
                    {
                        if( type.isOfType( baseType ) )
                        {
                            satisfied = true;
                            break;
                        }
                    }
                   
                    if( ! satisfied )
                    {
                        final StringBuilder list = new StringBuilder();
                       
                        for( String baseType : requiredBaseTypes )
                        {
                            if( list.length() > 0 )
                            {
                                list.append( ", " );
                            }
                           
                            list.append( baseType );
                        }
                       
                        final LocalizableText template = ( type.kind() == JavaTypeKind.INTERFACE ? interfaceDoesNotExtendOneOf : classDoesNotImplementOrExtendOneOf );
                        final String msg = template.format( val, list.toString() );
                        return Status.createErrorStatus( msg );
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.java.JavaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.