Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.ListProperty


            this.def = def;
        }
       
        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 );
                    }
                }
               
                if( columns.isEmpty() )
                {
                    columns.addAll( getDefaultColumns() );
                }
               
                for( Iterator<PropertyDef> itr = columns.iterator(); itr.hasNext(); )
                {
                    final PropertyDef cprop = itr.next();
                    boolean empty = true;
                   
                    if( cprop instanceof ValueProperty )
                    {
                        final ValueProperty cvprop = (ValueProperty) cprop;
                       
                        for( Element element : extElements )
                        {
                            if( element.property( cvprop ).text() != null )
                            {
                                empty = false;
                                break;
                            }
                        }
                    }
                    else if( cprop instanceof ListProperty )
                    {
                        final ListProperty clprop = (ListProperty) cprop;
                       
                        for( Element element : extElements )
                        {
                            if( ! element.property( clprop ).empty() )
                            {
View Full Code Here


                    text = formatClassName( text );
                }
            }
            else if( property instanceof ListProperty )
            {
                final ListProperty listProperty = (ListProperty) property;
                final ValueProperty entryValueProperty = (ValueProperty) listProperty.getType().properties().first();
                final StringBuilder buf = new StringBuilder();
               
                for( Element entry : element.property( listProperty ) )
                {
                    final String entryValuePropertyText = entry.property( entryValueProperty ).text();
View Full Code Here

            if( collection != null )
            {
                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;
                    }
                   
                    for( Element item : list )
                    {
                        items.add( item.property( listEntryProperty ).content() );
                    }
                   
                    final Element listParentElement = list.element();
                    final String listenerModelPath = listProperty.name() + "/" + listEntryProperty.name();
                   
                    if( this.lastListParentElement != listParentElement || ! this.lastListenerModelPath.equals( listenerModelPath ) )
                    {
                        if( this.lastListParentElement != null )
                        {
View Full Code Here

        addControl(this.addText);

        final StringBuilder buf = new StringBuilder();
        buf.append( "<form><p vspace=\"false\"><a href=\"action\" nowrap=\"true\">" );
        buf.append( "Add " );
        final ListProperty listProperty = (ListProperty) property().definition();
        buf.append( listProperty.getType().getLabel(false, CapitalizationType.NO_CAPS, false/*includeMnemonic*/) );
        buf.append( "</a></p></form>" );
       
        this.addText.setText( buf.toString(), true, false );
        if (this.addTextHyperlinkAdapter == null) {
            this.addTextHyperlinkAdapter = new HyperlinkAdapter() {
View Full Code Here

    public static final class Condition extends ServiceCondition
    {
        @Override
        public boolean applicable( final ServiceContext context )
        {
            final ListProperty property = context.find( ListProperty.class );
           
            if( property != null )
            {
                final CountConstraint constraint = property.getAnnotation( CountConstraint.class );
                return ( constraint != null && ( constraint.min() > 0 || constraint.max() < Integer.MAX_VALUE ) );
            }
           
            return false;
        }
View Full Code Here

    public static final class Condition extends ServiceCondition
    {
        @Override
        public boolean applicable( final ServiceContext context )
        {
            final ListProperty property = context.find( ListProperty.class );
            return ( property != null && property.hasAnnotation( CountConstraint.class ) );
        }
View Full Code Here

    }
   
    protected void handleModelPropertyChange(final PropertyEvent event)
    {
        final Element element = event.property().element();
        final ListProperty property = (ListProperty)event.property().definition();
        ElementList<?> newList = element.property(property);
       
        if (property == this.connListProperty)
        {
          handleConnectionListChange(element, property);
View Full Code Here

        this.diagramEditor = this.nodeTemplate.getDiagramEditorPart();
        this.connectionDef = (IDiagramConnectionDef)super.definition();
       
        this.diagramConnectionMap = new HashMap<Element, List<StandardDiagramConnectionPart>>();
       
        ListProperty nodeProperty = (ListProperty)this.nodeTemplate.getModelProperty();
        this.propertyName = this.bindingDef.getProperty().content();
        this.connListProperty = (ListProperty)nodeProperty.getType().property(this.propertyName);
       
        initConnPartListener();
       
        this.templateListeners = new CopyOnWriteArraySet<DiagramConnectionTemplateListener>();
       
        this.modelPropertyListener = new FilteredListener<PropertyContentEvent>()
        {
            @Override
            protected void handleTypedEvent( final PropertyContentEvent event )
            {
                handleModelPropertyChange( event );
            }
        };       
       
        String endpointPropStr = this.bindingDef.getEndpoint2().content().getProperty().content();
        this.endpointPath = new ModelPath(endpointPropStr);
       
        ElementList<Element> srcNodeList = getModelElement().property(nodeProperty);
        for (Element srcNodeModel : srcNodeList)
        {
            PropertyDef connProp = srcNodeModel.property(this.propertyName).definition();
            if (connProp instanceof ListProperty)
            {
                ListProperty connListProperty = (ListProperty)connProp;
                ElementList<?> connList = srcNodeModel.property(connListProperty);
                for (Element endpointModel : connList)
                {
                  createNewConnectionPart(endpointModel, srcNodeModel);                 
                }               
View Full Code Here

        Element srcNodeModel = srcNode.getLocalModelElement();
        PropertyDef modelProperty = this.nodeTemplate.getModelProperty();
        boolean found = false;
        if (modelProperty instanceof ListProperty)
        {
            ListProperty listProperty = (ListProperty)modelProperty;
            ElementList<?> list = getModelElement().property(listProperty);
            for (Element listEntryModelElement : list)
            {
                if (listEntryModelElement == srcNodeModel)
                {
                    found = true;
                    break;
                }               
            }
        }
        else if (modelProperty instanceof ElementProperty)
        {
            ElementProperty elementProperty = (ElementProperty)modelProperty;
            if (getModelElement().property(elementProperty) != null)
            {
                Element localModelElement = getModelElement().property(elementProperty).content();
                if (localModelElement == srcNodeModel)
                {
                    found = true;
                }
            }
        }
        if (!found)
        {
            throw new RuntimeException( "Cannot locate the source node element");
        }
       
        PropertyDef connProp = srcNodeModel.property(this.propertyName).definition();
        Element newEndpoint = null;
        if (connProp instanceof ListProperty)
        {
            ListProperty listProperty = (ListProperty)connProp;
            ElementList<?> list = srcNodeModel.property(listProperty);
            newEndpoint = list.insert();           
        }
       
        // Get serialized value of endpoint
View Full Code Here

    }
   
    @Override
    public void addModelListener()
    {
        ListProperty nodeProperty = (ListProperty)this.nodeTemplate.getModelProperty();
        ElementList<Element> srcNodeList = getModelElement().property(nodeProperty);
        for (Element srcNodeModel : srcNodeList)
        {
            addModelListener(srcNodeModel);
        }       
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ListProperty

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.