Package org.eclipse.sapphire.ui.forms

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


       
        this.enumValues = (Enum<?>[]) property().definition().getTypeClass().getEnumConstants();

        this.buttonsGroup = (RadioButtonsGroup) control;
       
        final PropertyEditorPart part = propertyEditorPresentation.part();
        final Property property = part.property();
        final EnumValueType enumValueType = new EnumValueType( this.enumValues[ 0 ].getDeclaringClass() );

        for( final Enum<?> enumItem : this.enumValues )
        {
            final String enumItemStr = property.service( MasterConversionService.class ).convert( enumItem, String.class );
            final String auxText = part.getRenderingHint( PropertyEditorDef.HINT_AUX_TEXT + "." + enumItemStr, null );
            final ValueImageService imageService = property.service( ValueImageService.class );
            final ImageData imageData = imageService.provide( enumItemStr );
            final Image image = propertyEditorPresentation.resources().image( imageData );
            final Button button = this.buttonsGroup.addRadioButton( enumValueType.getLabel( enumItem, false, CapitalizationType.FIRST_WORD_ONLY, true ), auxText, image );
            button.setData( enumItem );
View Full Code Here


    }

    @Override
    protected void createContents( final Composite parent )
    {
        final PropertyEditorPart part = part();
       
        final CheckboxLayout checkboxLayout;
        final String checkboxLayoutHint = part.definition().getHint( PropertyEditorDef.HINT_CHECKBOX_LAYOUT );
       
        if( checkboxLayoutHint == null )
        {
            checkboxLayout = CheckboxLayout.TRAILING_LABEL;
        }
        else if( checkboxLayoutHint.equalsIgnoreCase( PropertyEditorDef.HINT_VALUE_CHECKBOX_LAYOUT_LEADING_LABEL ) )
        {
            checkboxLayout = CheckboxLayout.LEADING_LABEL;
        }
        else if( checkboxLayoutHint.equalsIgnoreCase( PropertyEditorDef.HINT_VALUE_CHECKBOX_LAYOUT_TRAILING_LABEL ) )
        {
            checkboxLayout = CheckboxLayout.TRAILING_LABEL;
        }
        else if( checkboxLayoutHint.equalsIgnoreCase( PropertyEditorDef.HINT_VALUE_CHECKBOX_LAYOUT_TRAILING_LABEL_INDENTED ) )
        {
            checkboxLayout = CheckboxLayout.TRAILING_LABEL_INDENTED;
        }
        else
        {
            checkboxLayout = CheckboxLayout.TRAILING_LABEL;
        }
       
        final Composite composite = createMainComposite
        (
            parent,
            new CreateMainCompositeDelegate( part )
            {
                @Override
                public boolean getShowLabel()
                {
                    if( checkboxLayout == CheckboxLayout.TRAILING_LABEL || checkboxLayout == CheckboxLayout.TRAILING_LABEL_INDENTED )
                    {
                        return false;
                    }
                    else
                    {
                        return super.getShowLabel();
                    }
                }
               
                @Override
                public boolean getSpanBothColumns()
                {
                    if( checkboxLayout == CheckboxLayout.TRAILING_LABEL )
                    {
                        return true;
                    }
                    else
                    {
                        return super.getSpanBothColumns();
                    }
                }
            }
        );
       
        final boolean isDeprecated = property().definition().hasAnnotation( Deprecated.class );
       
        composite.setLayout( glspacing( glayout( ( isDeprecated ? 3 : 2 ), 0, 0 ), 2 ) );

        final PropertyEditorAssistDecorator decorator = createDecorator( composite );
        decorator.control().setLayoutData( gdvalign( gd(), SWT.CENTER ) );
       
        this.checkbox = new Button( composite, SWT.CHECK );
        this.checkbox.setLayoutData( gd() );
       
        if( checkboxLayout != CheckboxLayout.LEADING_LABEL )
        {
            final Runnable updateLabelOp = new Runnable()
            {
                public void run()
                {
                    CheckBoxPropertyEditorPresentation.this.checkbox.setText( part.label( CapitalizationType.FIRST_WORD_ONLY, true ) );
                }
            };
           
            attachPartListener
            (
View Full Code Here

        throw new UnsupportedOperationException();
    }
   
    public final void render()
    {
        final PropertyEditorPart part = part();
        final Composite composite = composite();
       
        createContents( composite );
       
        final String auxText = part.getRenderingHint( PropertyEditorDef.HINT_AUX_TEXT, null );
       
        final Class<AuxTextProvider> auxTextProviderClass
            = part.getRenderingHint( PropertyEditorDef.HINT_AUX_TEXT_PROVIDER, (Class<AuxTextProvider>) null );
       
        if( auxTextProviderClass != null )
        {
            try
            {
                this.auxTextProvider = auxTextProviderClass.newInstance();
            }
            catch( Exception e )
            {
                Sapphire.service( LoggingService.class ).log( e );
            }
        }
       
        if( auxText != null || this.auxTextProvider != null )
        {
            final boolean spanBothColumns = part.getSpanBothColumns();
           
            if( ! spanBothColumns )
            {
                final Label placeholder = new Label( composite, SWT.NONE );
                placeholder.setLayoutData( gd() );
                placeholder.setText( MiscUtil.EMPTY_STRING );
            }
           
            final int hindent = part.getMarginLeft() + 9;
           
            this.auxTextControl = new Label( composite, SWT.WRAP );
            this.auxTextControl.setLayoutData( gdwhint( gdhindent( gdhspan( gdhfill(), spanBothColumns ? 2 : 1 ), hindent ), 10 ) );
            this.auxTextControl.setForeground( composite.getDisplay().getSystemColor( SWT.COLOR_DARK_GRAY ) );
           
View Full Code Here

    }
   
    protected final Composite createMainComposite( final Composite parent,
                                                   final CreateMainCompositeDelegate delegate )
    {
        final PropertyEditorPart part = part();
       
        final boolean showLabel = delegate.getShowLabel();
        final int leftMargin = delegate.getLeftMargin();
        final boolean spanBothColumns = delegate.getSpanBothColumns();
        final boolean singleLinePresentation = isSingleLine();
        final List<FormComponentPart> relatedContentParts = part.getRelatedContent();
        final int count = relatedContentParts.size();
       
        if( showLabel )
        {
            final Label label = new Label( parent, SWT.NONE );
           
            register( label );
           
            final Runnable updateLabelOp = new Runnable()
            {
                public void run()
                {
                    label.setText( delegate.getLabel( CapitalizationType.FIRST_WORD_ONLY, true ) + ":" );
                }
            };
           
            attachPartListener
            (
                new FilteredListener<LabelChangedEvent>()
                {
                    @Override
                    protected void handleTypedEvent( final LabelChangedEvent event )
                    {
                        updateLabelOp.run();
                        layout();
                    }
                }
            );
           
            updateLabelOp.run();
           
            label.setLayoutData( gdhindent( gdhspan( gdvalign( gd(), singleLinePresentation ? SWT.CENTER : SWT.TOP ), spanBothColumns ? 2 : 1 ), leftMargin + 9 ) );
           
            addControl( label );
        }
        else if( ! spanBothColumns )
        {
            final Label spacer = new Label( parent, SWT.NONE );
            spacer.setLayoutData( gd() );
            spacer.setText( MiscUtil.EMPTY_STRING );
           
            register( spacer );
        }
       
        GridData gd;
       
        if( delegate.canScaleVertically() )
        {
            final boolean scaleVertically = part.getScaleVertically();
            gd = gdhhint( ( scaleVertically ? gdfill() : gdhfill() ), part.getHeight( 150 ) );
        }
        else
        {
            gd = gdhfill();
        }
       
        if( spanBothColumns )
        {
            gd = gdhindent( gdhspan( gd, 2 ), leftMargin );
        }
       
        gd = gdwhint( gd, part.getWidth( 200 ) );
       
        final Composite composite = new Composite( parent, SWT.NONE );
        composite.setLayoutData( gd );
       
        register( composite );
       
        if( count == 0 )
        {
            this.mainPropertyEditorComposite = composite;
        }
        else
        {
            composite.setLayout( glspacing( glayout( 3, 0, 0 ), 0 ) );
           
            final Composite mainPropertyEditorOuterComposite = new Composite( composite, SWT.NONE );
            mainPropertyEditorOuterComposite.setLayout( glayout( 1, 0, 4, 0, 0 ) );

            final Composite mainPropertyEditorComposite = new Composite( mainPropertyEditorOuterComposite, SWT.NONE );
           
            final Sash sash = new Sash( composite, SWT.VERTICAL );
            sash.setLayoutData( gdhhint( gdvfill(), 1 ) );
           
            final Composite relatedContentComposite = new Composite( composite, SWT.NONE );
            relatedContentComposite.setLayout( glayout( 2, 0, 0 ) );
           
            relatedContentComposite.setData( RELATED_CONTENT_WIDTH, ( (double) part.getRelatedContentWidth() ) / ( (double) 100 ) );
           
            composite.addListener
            (
                SWT.Resize,
                new org.eclipse.swt.widgets.Listener()
View Full Code Here

TOP

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

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.