Package org.eclipse.sapphire.ui.forms

Examples of org.eclipse.sapphire.ui.forms.ActuatorPart


        {
            part = new SpacerPart();
        }
        else if( definition instanceof ActuatorDef )
        {
            part = new ActuatorPart();
        }
        else if( definition instanceof CustomFormComponentDef )
        {
            final JavaType customPartImplClass = ( (CustomFormComponentDef) definition ).getImplClass().target();
           
View Full Code Here


    }

    @Override
    public void render()
    {
        final ActuatorPart part = part();
        final ActuatorDef def = part.definition();
       
        final SapphireActionGroup actions = part.getActions();
        this.actionPresentationManager = new SapphireActionPresentationManager( this, actions );
        final SapphireKeyboardActionPresentation keyboardActionPresentation = new SapphireKeyboardActionPresentation( this.actionPresentationManager );
       
        final HorizontalAlignment hAlign = def.getHorizontalAlignment().content();
        final int hAlignCode = ( hAlign == HorizontalAlignment.LEFT ? SWT.LEFT : ( hAlign == HorizontalAlignment.RIGHT ? SWT.RIGHT : SWT.CENTER ) );
       
        final int hSpan = ( def.getSpanBothColumns().content() ? 2 : 1 );
       
        if( hSpan == 1 )
        {
            final Label spacer = new Label( composite(), SWT.NONE );
            spacer.setLayoutData( gd() );
            spacer.setText( EMPTY_STRING );
           
            register( spacer );
        }
       
        final Button button = new Button( composite(), SWT.PUSH );
        button.setLayoutData( gdhspan( gdhindent( gdhalign( gd(), hAlignCode ), 8 ), hSpan ) );
       
        register( button );
       
        keyboardActionPresentation.attach( button );
       
        final String label = part.label( CapitalizationType.TITLE_STYLE, true );
       
        if( label != null )
        {
            button.setText( label );
        }
       
        final ImageData image = part.image( 16 );
       
        if( image != null )
        {
            button.setImage( resources().image( image ) );
        }
       
        button.addSelectionListener
        (
            new SelectionAdapter()
            {
                @Override
                public void widgetSelected( SelectionEvent e )
                {
                    final SapphireActionHandler handler = part.handler();
                   
                    if( handler != null )
                    {
                        handler.execute( ActuatorButtonPresentation.this );
                    }
                }
            }
        );
       
        button.setEnabled( part.enabled() );
       
        attachPartListener
        (
            new Listener()
            {
                @Override
                public void handle( final Event event )
                {
                    if( event instanceof EnablementChangedEvent )
                    {
                        button.setEnabled( part.enabled() );
                    }
                    else if( event instanceof LabelChangedEvent )
                    {
                        final String label = part.label( CapitalizationType.TITLE_STYLE );
                        button.setText( label == null ? EMPTY_STRING : label );
                        button.getParent().layout( true, true );
                    }
                    else if( event instanceof ImageChangedEvent )
                    {
                        button.setImage( resources().image( part.image( 16 ) ) );
                    }
                }
            }
        );
           
View Full Code Here

    }

    @Override
    public void render()
    {
        final ActuatorPart part = part();
        final ActuatorDef def = part.definition();
       
        final SapphireActionGroup actions = part.getActions();
        this.actionPresentationManager = new SapphireActionPresentationManager( this, actions );
        final SapphireKeyboardActionPresentation keyboardActionPresentation = new SapphireKeyboardActionPresentation( this.actionPresentationManager );
       
        final HorizontalAlignment hAlign = def.getHorizontalAlignment().content();
        final int hAlignCode = ( hAlign == HorizontalAlignment.LEFT ? SWT.LEFT : ( hAlign == HorizontalAlignment.RIGHT ? SWT.RIGHT : SWT.CENTER ) );
       
        final int hSpan = ( def.getSpanBothColumns().content() ? 2 : 1 );
       
        if( hSpan == 1 )
        {
            final Label spacer = new Label( composite(), SWT.NONE );
            spacer.setLayoutData( gd() );
            spacer.setText( EMPTY_STRING );
           
            register( spacer );
        }
       
        final ImageData image = part.image( 16 );
       
        final Composite composite = new Composite( composite(), SWT.NONE );
        composite.setLayoutData( gdhalign( gdhindent( gdhspan( gd(), hSpan ), 8 ), hAlignCode ) );
        composite.setLayout( glayout( ( image == null ? 1 : 2 ), 0, 0 ) );
       
        register( composite );

        final Label imageControl;
       
        if( image != null )
        {
            imageControl = new Label( composite, SWT.NONE );
            imageControl.setImage( resources().image( image ) );
            imageControl.setLayoutData( gdvalign( gd(), SWT.CENTER ) );
            imageControl.setEnabled( part.enabled() );
        }
        else
        {
            imageControl = null;
        }
       
        final SapphireFormText text = new SapphireFormText( composite, SWT.NONE );
        text.setLayoutData( gdvalign( gdhfill(), SWT.CENTER ) );
       
        keyboardActionPresentation.attach( text );
       
        String label = part.label( CapitalizationType.FIRST_WORD_ONLY );
        label = ( label == null ? labelNotSpecified.text() : label );
       
        final StringBuilder buf = new StringBuilder();
        buf.append( "<form><p vspace=\"false\"><a href=\"action\" nowrap=\"true\">" );
        buf.append( label );
        buf.append( "</a></p></form>" );
       
        text.setText( buf.toString(), true, false );
       
        text.addHyperlinkListener
        (
            new HyperlinkAdapter()
            {
                @Override
                public void linkActivated( final HyperlinkEvent event )
                {
                    final SapphireActionHandler handler = part.handler();
                   
                    if( handler != null )
                    {
                        handler.execute( ActuatorLinkPresentation.this );
                    }
                }
            }
        );
       
        text.setEnabled( part.enabled() );
       
        attachPartListener
        (
            new Listener()
            {
                @Override
                public void handle( final Event event )
                {
                    if( event instanceof EnablementChangedEvent )
                    {
                        final boolean enabled = part.enabled();
                       
                        if( imageControl != null )
                        {
                            imageControl.setEnabled( enabled );
                        }
                       
                        text.setEnabled( enabled );
                    }
                    else if( event instanceof LabelChangedEvent )
                    {
                        final StringBuilder buf = new StringBuilder();
                        buf.append( "<form><p vspace=\"false\"><a href=\"action\" nowrap=\"true\">" );
                        buf.append( part.label( CapitalizationType.FIRST_WORD_ONLY ) );
                        buf.append( "</a></p></form>" );
                       
                        text.setText( buf.toString(), true, false );
                       
                        composite.getParent().layout( true, true );
                    }
                    else if( event instanceof ImageChangedEvent )
                    {
                        if( imageControl != null )
                        {
                            imageControl.setImage( resources().image( part.image( 16 ) ) );
                        }
                    }
                }
            }
        );
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ui.forms.ActuatorPart

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.