Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.ElementType


            final XmlListBinding.Mapping[] mappings = annotation.mappings();
            this.xmlElementNames = new QName[ this.modelElementTypes.length ];
           
            for( int i = 0; i < this.modelElementTypes.length; i++ )
            {
                final ElementType type = this.modelElementTypes[ i ];
                       
                for( XmlListBinding.Mapping mapping : mappings )
                {
                    if( mapping.type() == type.getModelElementClass() )
                    {
                        final String mappingElementName = mapping.element().trim();
                       
                        if( mappingElementName.length() == 0 )
                        {
View Full Code Here


           
            if( property instanceof ElementProperty || property instanceof ListProperty )
            {
                boolean skip = false;
               
                final ElementType childType = property.service( PossibleTypesService.class ).types().first();
                final SortedSet<PropertyDef> childTypeProperties = childType.properties();
               
                if( childTypeProperties.size() == 1 )
                {
                    final PropertyDef childTypeProperty = childTypeProperties.first();
                   
View Full Code Here

                                        {
                                            handle.clear();
                                        }
                                        else
                                        {
                                            final ElementType type = buttonToType.get( button );
                                            handle.content( true, type );
                                        }
                                    }
                                    catch( Exception e )
                                    {
                                        // Note that the EditFailedException is ignored here because the user has already
                                        // been notified and likely has taken action that led to the exception (such as
                                        // declining to make a file writable).
                                       
                                        final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                                       
                                        if( editFailedException == null )
                                        {
                                            Sapphire.service( LoggingService.class ).log( e );
                                        }
                                    }
                                }
                            }
                        );
                    }
                    else if( style == Style.DROP_DOWN_LIST )
                    {
                        final Combo combo = new Combo( typeSelectorComposite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
                        combo.setLayoutData( gdhfill() );
                        decorator.addEditorControl( combo );
                        actionPresentationKeyboard.attach( combo );
                        attachHelp( combo, property );
                       
                        final Map<ElementType,Integer> typeToIndex = new HashMap<ElementType,Integer>();
                        final Map<Integer,ElementType> indexToType = new HashMap<Integer,ElementType>();
                       
                        int index = 0;
                       
                        for( ElementType type : allPossibleTypes )
                        {
                            final String label = type.getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false );
                            combo.add( label );
                            typeToIndex.put( type, index );
                            indexToType.put( index, type );
                           
                            index++;
                        }
                       
                        updateUserInterfaceOp = new Runnable()
                        {
                            public void run()
                            {
                                if( Display.getCurrent() == null )
                                {
                                    combo.getDisplay().asyncExec( this );
                                    return;
                                }
                               
                                final Element subModelElement = ( (ElementHandle<?>) property ).content();
                                final int index;
                               
                                if( subModelElement == null )
                                {
                                    index = -1;
                                }
                                else
                                {
                                    index = typeToIndex.get( subModelElement.type() );
                                }
                               
                                if( combo.getSelectionIndex() != index )
                                {
                                    if( index == -1 )
                                    {
                                        combo.deselectAll();
                                    }
                                    else
                                    {
                                        combo.select( index );
                                    }
                                }
                               
                                combo.setEnabled( property.enabled() );
                            }
                        };
   
                        combo.addSelectionListener
                        (
                            new SelectionAdapter()
                            {
                                @Override
                                public void widgetSelected( final SelectionEvent event )
                                {
                                    try
                                    {
                                        final ElementHandle<?> handle = (ElementHandle<?>) property;
                                        final int index = combo.getSelectionIndex();
                                       
                                        if( index == -1 )
                                        {
                                            handle.clear();
                                        }
                                        else
                                        {
                                            final ElementType type = indexToType.get( index );
                                            handle.content( true, type );
                                        }
                                    }
                                    catch( Exception e )
                                    {
View Full Code Here

        }
       
        public final void write()
        {
            final ListProperty extTypeListProperty = (ListProperty) SapphireExtensionDef.TYPE.property( this.def.getExtensionType().text() );
            final ElementType extType = extTypeListProperty.getType();
           
            final List<Element> extElements = new ArrayList<Element>();
           
            if( this.filter == null )
            {
                for( SapphireExtensionDef extension : this.extensions )
                {
                    extElements.addAll( extension.property( extTypeListProperty ) );
                }
            }
            else
            {
                for( SapphireExtensionDef extension : this.extensions )
                {
                    for( Element extElement : extension.property( extTypeListProperty ) )
                    {
                        if( this.filter.allows( extElement ) )
                        {
                            extElements.add( extElement );
                        }
                    }
                }
            }
           
            if( ! extElements.isEmpty() )
            {
                // Sort extensions.
               
                sort( extElements );
               
                // Write section header.
               
                if( this.def.getIncludeSectionHeader().content() )
                {
                    final ExtensionSummaryExportOp op = this.def.nearest( ExtensionSummaryExportOp.class );
                   
                    final String sectionHeaderLevel
                        = ( ( op.getCreateFinishedDocument().content() == false || op.getDocumentBodyTitle().content() == null ) ? "h1" : "h2" );
                   
                    this.out.println();
                    this.out.print( "<a name=\"" );
                    this.out.print( extTypeListProperty.name() );
                    this.out.print( "\"><" );
                    this.out.print( sectionHeaderLevel );
                    this.out.print( '>' );
                    this.out.print( extTypeListProperty.getLabel( true, CapitalizationType.TITLE_STYLE, false ) );
                    this.out.print( "</" );
                    this.out.print( sectionHeaderLevel );
                    this.out.print( "></a>" );
                    this.out.println();
                }
               
                // Determine columns.
               
                final List<PropertyDef> columns = new ArrayList<PropertyDef>();
               
                for( ExtensionSummarySectionColumnDef cdef : this.def.getColumns() )
                {
                    final PropertyDef cprop = extType.property( cdef.getName().text() );
                   
                    if( cprop != null )
                    {
                        columns.add( cprop );
                    }
View Full Code Here

            {
                if( collection instanceof ElementList )
                {
                    final ElementList<?> list = (ElementList<?>) collection;
                    final ListProperty listProperty = list.definition();
                    final ElementType listEntryType = listProperty.getType();
                    final ValueProperty listEntryProperty;
                   
                    if( operands().size() > 1 )
                    {
                        final String listEntryPropertyName = cast( operand( 1 ), String.class );
                   
                        final PropertyDef prop = listEntryType.property( listEntryPropertyName );
                       
                        if( prop == null )
                        {
                            throw new FunctionException( missingProperty.format( listEntryType.getSimpleName(), listEntryPropertyName ) );
                        }
                       
                        if( ! ( prop instanceof ValueProperty ) )
                        {
                            throw new FunctionException( notValueProperty.format( listEntryType.getSimpleName(), listEntryPropertyName ) );
                        }
                   
                        listEntryProperty = (ValueProperty) prop;
                    }
                    else
                    {
                        ValueProperty prop = null;
                       
                        for( PropertyDef p : listEntryType.properties() )
                        {
                            if( p instanceof ValueProperty )
                            {
                                prop = (ValueProperty) p;
                                break;
                            }
                        }
                       
                        if( prop == null )
                        {
                            throw new FunctionException( noValueProperties.format( listEntryType.getSimpleName() ) );
                        }
                       
                        listEntryProperty = prop;
                    }
                   
View Full Code Here

   
            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 int size = in.readInt();
           
            for( int i = 0; i < size; i++ )
            {
                final String qualifiedTypeName = in.readUTF();
                final ElementType type = ElementType.read( this.classLoader, qualifiedTypeName );
                final ElementData element = new ElementData( type );
                nativeToJava( in, element );
                elementsListFactory.add( element );
            }
           
View Full Code Here

                    element.write( propertyName, value );
                }
                else if( property instanceof ElementProperty )
                {
                    final String qualifiedTypeName = in.readUTF();
                    final ElementType type = ElementType.read( this.classLoader, qualifiedTypeName );
                    final ElementData child = new ElementData( type );
                    element.write( propertyName, child );
                    nativeToJava( in, child );
                }
                else if( property instanceof ListProperty )
                {
                    final ListFactory<ElementData> listFactory = ListFactory.start();
                    final int size = in.readInt();
                   
                    for( int i = 0; i < size; i++ )
                    {
                        final String qualifiedTypeName = in.readUTF();
                        final ElementType type = ElementType.read( this.classLoader, qualifiedTypeName );
                        final ElementData child = new ElementData( type );
                        listFactory.add( child );
                        nativeToJava( in, child );
                    }
                   
View Full Code Here

   
    protected void createContents( final Composite parent )
    {
        final ElementList<?> list = property();
       
        final ElementType memberType = list.definition().getType();
        final SortedSet<PropertyDef> allMemberProperties = memberType.properties();
       
        if( allMemberProperties.size() == 1 )
        {
            final PropertyDef prop = allMemberProperties.first();
           
View Full Code Here

{
    @Override
    protected void initStandardDocumentationService( final StringBuilder content,
                                                     final List<Topic> topics )
    {
        final ElementType type = context( ElementType.class );
        final Documentation docAnnotation = type.getAnnotation( Documentation.class );
       
        if( docAnnotation != null )
        {
            final LocalizationService localization = type.getLocalizationService();
            final String docAnnotationContent = localization.text( docAnnotation.content().trim(), CapitalizationType.NO_CAPS, false );
           
            if( docAnnotationContent.length() > 0 )
            {
                content.append( docAnnotationContent );
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ElementType

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.