Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.Property


    }

    @Override
    protected void facts( final SortedSet<String> facts )
    {
        final Property property = context( Property.class );
       
        final JavaTypeConstraintService service = property.service( JavaTypeConstraintService.class );

        final List<JavaTypeKind> kinds = new ArrayList<JavaTypeKind>( service.kinds() );
       
        if( kinds.size() > 0 && kinds.size() < 5 )
        {
            if( kinds.size() == 1 )
            {
                facts.add( statementKindOne.format( term( kinds.get( 0 ) ) ) );
            }
            else if( kinds.size() == 2 )
            {
                facts.add( statementKindTwo.format( term( kinds.get( 0 ) ), term( kinds.get( 1 ) ) ) );
            }
            else if( kinds.size() == 3 )
            {
                facts.add( statementKindThree.format( term( kinds.get( 0 ) ), term( kinds.get( 1 ) ), term( kinds.get( 2 ) ) ) );
            }
            else if( kinds.size() == 4 )
            {
                facts.add( statementKindFour.format( term( kinds.get( 0 ) ), term( kinds.get( 1 ) ), term( kinds.get( 2 ) ), term( kinds.get( 3 ) ) ) );
            }
        }
       
        final List<String> types = new ArrayList<String>( service.types() );
       
        if( types.size() > 0 )
        {
            if( types.size() == 1 )
            {
                final String typeName = types.get( 0 );
                String verb = verbImplementOrExtend.text();
               
                final ReferenceService<?> referenceService = property.service( ReferenceService.class );
               
                if( referenceService != null && referenceService instanceof JavaTypeReferenceService )
                {
                    JavaType type = null;
               
View Full Code Here


    @Override
    protected boolean computeEnablementState()
    {
        if( super.computeEnablementState() == true )
        {
            final Property property = property();
            final Path relativePath = (Path) ( (Value<?>) property ).content();
           
            if( relativePath != null )
            {
                final Path absolutePath = property.service( RelativePathService.class ).convertToAbsolute( relativePath );
               
                if( absolutePath != null )
                {
                    final File absoluteFile = absolutePath.toFile();
                   
View Full Code Here

    }

    @Override
    protected Object run( final Presentation context )
    {
        final Property property = property();
        final Path relativePath = (Path) ( (Value<?>) property ).content();
       
        if( relativePath != null )
        {
            final Path absolutePath = property.service( RelativePathService.class ).convertToAbsolute( relativePath );
           
            if( absolutePath != null )
            {
                final File file = absolutePath.toFile();
               
View Full Code Here

        setId( ID );
        setLabel( label.text() );
        addImage( IMG_FILE );
       
        final Property property = property();
       
        this.type = null;
       
        final String paramType = def.getParam( PARAM_TYPE );
       
        if( paramType != null )
        {
            if( paramType.equalsIgnoreCase( "file" ) )
            {
                this.type = FileSystemResourceType.FILE;
            }
            else if( paramType.equalsIgnoreCase( "folder" ) )
            {
                this.type = FileSystemResourceType.FOLDER;
            }
        }
        else
        {
            final ValidFileSystemResourceType validFileSystemResourceTypeAnnotation
                = property.definition().getAnnotation( ValidFileSystemResourceType.class );
       
            if( validFileSystemResourceTypeAnnotation != null )
            {
                this.type = validFileSystemResourceTypeAnnotation.value();
            }
        }

        final String staticFileExtensions = def.getParam( PARAM_EXTENSIONS );
       
        if( staticFileExtensions == null )
        {
            this.fileExtensionService = property.service( FileExtensionsService.class );
           
            if( this.fileExtensionService == null )
            {
                this.staticFileExtensionsList = Collections.emptyList();
            }
View Full Code Here

    @Override
   
    protected String browse( final Presentation context )
    {
        final FormComponentPresentation p = (FormComponentPresentation) context;
        final Property property = property();
        final List<Path> roots = getBasePaths();
        String selectedAbsolutePath = null;
       
        final List<String> extensions;
       
        if( this.fileExtensionService == null )
        {
            extensions = this.staticFileExtensionsList;
        }
        else
        {
            extensions = this.fileExtensionService.extensions();
        }
       
        if( enclosed() )
        {
            final List<IContainer> baseContainers = new ArrayList<IContainer>();
           
            for( Path path : roots )
            {
                final IContainer baseContainer = getWorkspaceContainer( path.toFile() );
               
                if( baseContainer != null )
                {
                    baseContainers.add( baseContainer );
                }
                else
                {
                    break;
                }
            }
           
            final ITreeContentProvider contentProvider;
            final ILabelProvider labelProvider;
            final ViewerComparator viewerComparator;
            final Object input;

            if( roots.size() == baseContainers.size() )
            {
                // All paths are in the Eclipse Workspace. Use the available content and label
                // providers.
           
                contentProvider = new WorkspaceContentProvider( baseContainers );
                labelProvider = new WorkbenchLabelProvider();
                viewerComparator = new ResourceComparator();
                input = ResourcesPlugin.getWorkspace().getRoot();
            }
            else
            {
                // At least one of the roots is not in the Eclipse Workspace. Use custom file
                // system content and label providers.
               
                contentProvider = new FileSystemContentProvider( roots );
                labelProvider = new FileSystemLabelProvider( p );
                viewerComparator = new FileSystemNodeComparator();
                input = new Object();
            }
       
            final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( p.shell(), labelProvider, contentProvider );
           
            dialog.setTitle( property.definition().getLabel( false, CapitalizationType.TITLE_STYLE, false ) );
            dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel( true, CapitalizationType.NO_CAPS, false ) ) );
            dialog.setAllowMultiple( false );
            dialog.setHelpAvailable( false );
            dialog.setInput( input );
            dialog.setComparator( viewerComparator );
           
            final Path currentPathAbsolute = convertToAbsolute( (Path) ( (Value<?>) property ).content() );
           
            if( currentPathAbsolute != null )
            {
                Object initialSelection = null;
               
                if( contentProvider instanceof WorkspaceContentProvider )
                {
                    final URI uri = currentPathAbsolute.toFile().toURI();
                    final IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
                   
                    final IFile[] files = wsroot.findFilesForLocationURI( uri );
                   
                    if( files.length > 0 )
                    {
                        final IFile file = files[ 0 ];
                       
                        if( file.exists() )
                        {
                            initialSelection = file;
                        }
                    }
                   
                    if( initialSelection == null )
                    {
                        final IContainer[] containers = wsroot.findContainersForLocationURI( uri );
                       
                        if( containers.length > 0 )
                        {
                            final IContainer container = containers[ 0 ];
                           
                            if( container.exists() )
                            {
                                initialSelection = container;
                            }
                        }                      
                    }
                }
                else
                {
                    initialSelection = ( (FileSystemContentProvider) contentProvider ).find( currentPathAbsolute );
                }
               
                if( initialSelection != null )
                {
                    dialog.setInitialSelection( initialSelection );
                }
            }
           
            if( this.type == FileSystemResourceType.FILE )
            {
                dialog.setValidator( new FileSelectionStatusValidator() );
            }
            else if( this.type == FileSystemResourceType.FOLDER )
            {
                dialog.addFilter( new ContainersOnlyViewerFilter() );
            }
           
            if( ! extensions.isEmpty() )
            {
                dialog.addFilter( new ExtensionBasedViewerFilter( extensions ) );
            }
           
            if( dialog.open() == Window.OK )
            {
                final Object firstResult = dialog.getFirstResult();
               
                if( firstResult instanceof IResource )
                {
                    selectedAbsolutePath = ( (IResource) firstResult ).getLocation().toString();
                }
                else
                {
                    selectedAbsolutePath = ( (FileSystemNode) firstResult ).getFile().getPath();
                }
            }
        }
        else if( this.type == FileSystemResourceType.FOLDER )
        {
            final DirectoryDialog dialog = new DirectoryDialog( p.shell() );
            dialog.setText( property.definition().getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false ) );
            dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel( true, CapitalizationType.NO_CAPS, false ) ) );
           
            final Value<?> value = (Value<?>) property;
            final Path path = (Path) value.content();
           
            if( path != null )
            {
                dialog.setFilterPath( path.toOSString() );
            }
            else if( roots.size() > 0 )
            {
                dialog.setFilterPath( roots.get( 0 ).toOSString() );
            }
           
            selectedAbsolutePath = dialog.open();
        }
        else
        {
            final FileDialog dialog = new FileDialog( p.shell() );
            dialog.setText( property.definition().getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false ) );
           
            final Value<?> value = (Value<?>) property;
            final Path path = (Path) value.content();
           
            if( path != null && path.segmentCount() > 1 )
View Full Code Here

            return f.evaluate( this );
        }
        else if( element == this || element instanceof Element )
        {
            final Element el = ( element == this ? element() : (Element) element );
            final Property property = el.property( name );
           
            if( property != null )
            {
                final Function f = new ReadPropertyFunction( property, name, PropertyContentEvent.class )
                {
View Full Code Here

        }

        @Override
        public final FunctionResult evaluate( final FunctionContext context )
        {
            final Property property = this.context;
            final Class<? extends PropertyEvent> eventType = this.eventType;
           
            return new FunctionResult( this, context )
            {
                private Listener listener;
               
                @Override
                protected void init()
                {
                    super.init();
                   
                    this.listener = new Listener()
                    {
                        @Override
                        public void handle( final Event event )
                        {
                            if( eventType.isInstance( event ) )
                            {
                                refresh();
                            }
                        }
                    };
                   
                    property.attach( this.listener );
                }

                @Override
                protected Object evaluate()
                {
                    return ReadPropertyFunction.this.evaluate();
                }
               
                @Override
                public void dispose()
                {
                    super.dispose();
                    property.detach( this.listener );
                }
            };
        }
View Full Code Here

public final class ColorBrowseActionHandler extends BrowseActionHandler
{
    @Override
    protected String browse( final Presentation context )
    {
        final Property property = property();
       
        final Shell parent = ( (FormComponentPresentation) context ).shell();
        final Rectangle bounds = parent.getBounds();
       
        // There is no means to compute the size of the color dialog. In the following
        // computations, measurements of the dialog on Windows 7 are used. Will need to
        // generalize in the future.
       
        final int x = bounds.x + bounds.width / 2 - 120;
        final int y = bounds.y + bounds.height / 2 - 170;

        final Shell shell = new Shell( parent );
       
        try
        {
            shell.setBounds( x, y, 0, 0 );
           
            final ColorDialog dialog = new ColorDialog( shell );
           
            dialog.setText( property.definition().getLabel( false, CapitalizationType.TITLE_STYLE, false ) );
            dialog.setRGB( convert( (Color) ( (Value<?>) property ).content() ) );
           
            final RGB pickedColor = dialog.open();
           
            if( pickedColor != null )
View Full Code Here

public final class RelativePathJumpActionHandlerCondition extends PropertyEditorCondition
{
    @Override
    protected boolean evaluate( final PropertyEditorPart part )
    {
        final Property property = part.property();
        return ( property.definition() instanceof ValueProperty && Path.class.isAssignableFrom( property.definition().getTypeClass() ) && property.service( RelativePathService.class ) != null );
    }
View Full Code Here

           
            @Override
            protected Object evaluate()
            {
                final Element element = operand( 0, Element.class, false );
                final Property parent = element.parent();
               
                if( parent instanceof ElementList )
                {
                    final ElementList<?> list = (ElementList<?>) parent;
                   
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.