Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.Property


                            final Map<String,String> params )
        {
            final ModelPath path = new ModelPath( substituteParams( definition.getProperty().content(), params ) );
           
            Element element = getLocalModelElement();
            Property p = null;
           
            for( int i = 0, n = path.length(); i < n; i++ )
            {
                if( p != null )
                {
                    throw new RuntimeException( path.toString() );
                }
               
                final ModelPath.Segment segment = path.segment( i );
               
                if( segment instanceof ModelPath.ModelRootSegment )
                {
                    element = element.root();
                }
                else if( segment instanceof ModelPath.ParentElementSegment )
                {
                    element = element.parent().element();
                }
                else if( segment instanceof ModelPath.PropertySegment )
                {
                    final Property property = element.property( ( (ModelPath.PropertySegment) segment ).getPropertyName() );
                   
                    if( property != null && property.definition() instanceof ImpliedElementProperty )
                    {
                        element = ( (ElementHandle<?>) property ).content();
                    }
                    else if( property instanceof ElementList || property instanceof ElementHandle )
                    {
View Full Code Here


   
    public SlushBucketPropertyEditorPresentation( final FormComponentPart part, final SwtPresentation parent, final Composite composite )
    {
        super( part, parent, composite );
       
        final Property property = property();
       
        this.memberType = property.definition().getType();
        this.memberProperty = (ValueProperty) this.memberType.properties().first();
        this.possibleValuesService = property.service( PossibleValuesService.class );
       
        setAddActionDesired( ! this.possibleValuesService.strict() );
    }
View Full Code Here

    @Test
   
    public void test() throws Exception
    {
        final TestElement element = TestElement.TYPE.instantiate();
        final Property property = element.property( TestElement.PROP_VALUE );
       
        final List<PossibleValuesService> xl = property.services( PossibleValuesService.class );
        final List<TestPossibleValuesService> yl = property.services( TestPossibleValuesService.class );
       
        assertEquals( 1, xl.size() );
        assertEquals( 1, yl.size() );
        assertSame( xl.get( 0 ), yl.get( 0 ) );
       
        final PossibleValuesService x = property.service( PossibleValuesService.class );
        final TestPossibleValuesService y = property.service( TestPossibleValuesService.class );
       
        assertNotNull( x );
        assertSame( x, y );
    }
View Full Code Here

    @Test
   
    public void testVersionCompatibilityEnablementServiceForValue() throws Exception
    {
        final RootElement root = RootElement.TYPE.instantiate();
        final Property property = root.property( RootElement.PROP_VALUE_SINCE );
       
        assertFalse( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
       
        root.setVersion( "3.0" );
        assertTrue( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
    }
View Full Code Here

    @Test
   
    public void testVersionCompatibilityEnablementServiceForElement() throws Exception
    {
        final RootElement root = RootElement.TYPE.instantiate();
        final Property property = root.property( RootElement.PROP_CHILD );
       
        assertFalse( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
       
        root.setVersion( "3.0" );
        assertTrue( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
    }
View Full Code Here

    @Test
   
    public void testVersionCompatibilityEnablementServiceForElementImplied() throws Exception
    {
        final RootElement root = RootElement.TYPE.instantiate();
        final Property property = root.property( RootElement.PROP_CHILD_IMPLIED );
       
        assertFalse( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
       
        root.setVersion( "3.0" );
        assertTrue( property.enabled() );
       
        root.setVersion( "1.0" );
        assertFalse( property.enabled() );
    }
View Full Code Here

    setId(ID);
  }

  @Override
  public String browse(final Presentation context) {
    final Property property = property();

    final IJavaProject project = property.element().adapt(IJavaProject.class);

    try {
      final SelectionDialog dlg = JavaUI.createPackageDialog(((FormComponentPresentation) context).shell(),
          project, 0, null);

      dlg.setTitle( dialogTitle.format( property.definition().getLabel( true, CapitalizationType.TITLE_STYLE, false ) ) );
      dlg.setMessage( dialogMessage.text() );

      if (dlg.open() == SelectionDialog.OK) {
        Object results[] = dlg.getResult();
        assert results != null && results.length == 1;
View Full Code Here

  }

  public static final class Condition extends PropertyEditorCondition {
    @Override
    protected boolean evaluate(final PropertyEditorPart part) {
      final Property property = part.property();

      return
            (
                property instanceof Value &&
                property.definition().isOfType( JavaPackageName.class ) &&
                property.element().adapt( IJavaProject.class ) != null
            );
    }
View Full Code Here

    }

    @Override
    public String browse( final Presentation context )
    {
        final Property property = property();
       
        final EnumSet<JavaTypeKind> kinds = EnumSet.noneOf( JavaTypeKind.class );
       
        if( this.paramKinds != null )
        {
            for( String kindString : this.paramKinds.split( "," ) )
            {
                kindString = kindString.trim();
               
                if( kindString.equalsIgnoreCase( JavaTypeKind.CLASS.name() ) )
                {
                    kinds.add( JavaTypeKind.CLASS );
                }
                else if( kindString.equalsIgnoreCase( JavaTypeKind.ABSTRACT_CLASS.name() ) )
                {
                    kinds.add( JavaTypeKind.ABSTRACT_CLASS );
                }
                else if( kindString.equalsIgnoreCase( JavaTypeKind.INTERFACE.name() ) )
                {
                    kinds.add( JavaTypeKind.INTERFACE );
                }
                else if( kindString.equalsIgnoreCase( JavaTypeKind.ANNOTATION.name() ) )
                {
                    kinds.add( JavaTypeKind.ANNOTATION );
                }
                else if( kindString.equalsIgnoreCase( JavaTypeKind.ENUM.name() ) )
                {
                    kinds.add( JavaTypeKind.ENUM );
                }
                else
                {
                    final String msg = typeKindNotRecognized.format( kindString );
                    Sapphire.service( LoggingService.class ).logError( msg );
                }
            }
        }
        else
        {
            final JavaTypeConstraintService javaTypeConstraintService = property.service( JavaTypeConstraintService.class );
           
            if( javaTypeConstraintService != null )
            {
                kinds.addAll( javaTypeConstraintService.kinds() );
            }
        }
       
        int browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;       
        int count = kinds.size();
       
        if( count == 1 )
        {
            final JavaTypeKind kind = kinds.iterator().next();
           
            switch( kind )
            {
                case CLASS:           browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES; break;
                case ABSTRACT_CLASS:  browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES; break;
                case INTERFACE:       browseDialogStyle = IJavaElementSearchConstants.CONSIDER_INTERFACES; break;
                case ANNOTATION:      browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES; break;
                case ENUM:            browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ENUMS; break;
                default:              throw new IllegalStateException();
            }
        }
        else if( count == 2 )
        {
            if( kinds.contains( JavaTypeKind.CLASS ) || kinds.contains( JavaTypeKind.ABSTRACT_CLASS ) )
            {
                if( kinds.contains( JavaTypeKind.INTERFACE ) )
                {
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES;
                }
                else if( kinds.contains( JavaTypeKind.ENUM ) )
                {
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS;
                }
            }
        }

        final IProject project = property.element().adapt( IProject.class );
       
        try
        {
            final SelectionDialog dlg
                = JavaUI.createTypeDialog( ( (FormComponentPresentation) context ).shell(), null, project, browseDialogStyle, false );
           
            dlg.setTitle( dialogTitle.format( property.definition().getLabel( true, CapitalizationType.TITLE_STYLE, false ) ) );
           
            if (dlg.open() == SelectionDialog.OK) {
                Object results[] = dlg.getResult();
                assert results != null && results.length == 1;
                if (results[0] instanceof IType) {
View Full Code Here

    public static final class Condition extends PropertyEditorCondition
    {
        @Override
        protected boolean evaluate( final PropertyEditorPart part )
        {
            final Property property = part.property();
           
            if( property instanceof Value && property.definition().isOfType( JavaTypeName.class ) )
            {
                final Reference referenceAnnotation = property.definition().getAnnotation( Reference.class );
               
                return
                (
                    referenceAnnotation != null &&
                    referenceAnnotation.target() == JavaType.class &&
                    property.element().adapt( IJavaProject.class ) != null
                );
            }
           
            return false;
        }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.Property

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.