Package org.eclipse.sapphire.ui.assist.internal

Examples of org.eclipse.sapphire.ui.assist.internal.PropertyEditorAssistDecorator


       
        final Composite decoratorComposite = new Composite( sourceTableComposite, SWT.NONE );
        decoratorComposite.setLayoutData( gdvalign( gd(), SWT.TOP ) );
        decoratorComposite.setLayout( glayout( 1, 0, 2, 0, 0 ) );
       
        final PropertyEditorAssistDecorator decorator = new PropertyEditorAssistDecorator( part, decoratorComposite );
       
        decorator.control().setLayoutData( gd() );
        setDecorator( decorator );
       
        final Control sourceTable = createSourceControl( sourceTableComposite );
        sourceTable.setLayoutData( gdfill() );
       
        final Composite toolbarComposite = new Composite( sourceTableComposite, SWT.NONE );
        toolbarComposite.setLayoutData( gd() );
        toolbarComposite.setLayout( glayout( 1, 5, 5, 0, 0 ) );
       
        final ToolBar toolbar = new ToolBar( toolbarComposite, SWT.FLAT | SWT.VERTICAL );
        toolbar.setLayoutData( gd() );
        addControl( toolbar );
       
        final Composite tableComposite = new Composite( mainComposite, SWT.NONE );
        tableComposite.setLayout( glayout( 2, 0, 0 ) );
       
        decorator.addEditorControl( mainComposite );
        decorator.addEditorControl( sourceTableComposite );
        decorator.addEditorControl( decoratorComposite );
        decorator.addEditorControl( sourceTable );
        decorator.addEditorControl( toolbarComposite );
        decorator.addEditorControl( toolbar );
       
        final Table mainTable = (Table) super.createContents( tableComposite, true );
       
        final SapphireActionGroup actions = getActions();
        final SapphireAction moveRightAction = actions.getAction( SapphireActionSystem.ACTION_MOVE_RIGHT );
View Full Code Here


        // Create Controls
       
        final Composite mainComposite = createMainComposite( parent );
        mainComposite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );
       
        final PropertyEditorAssistDecorator decorator = createDecorator( mainComposite );
        decorator.control().setLayoutData( gdvalign( gd(), SWT.TOP ) );
       
        // Setting the whint in the following code is a hacky workaround for the problem
        // tracked by the following JFace bug:
        //
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=215997
        //
       
        final Composite tableComposite = new Composite( mainComposite, SWT.NONE );
        tableComposite.setLayoutData( gdwhint( gdfill(), 1 ) );
       
        final TableColumnLayout tableColumnLayout = new TableColumnLayout();
        tableComposite.setLayout( tableColumnLayout );
       
        this.tableViewer = CheckboxTableViewer.newCheckList( tableComposite, SWT.BORDER | SWT.FULL_SELECTION );
        this.table = this.tableViewer.getTable();
       
        final TableViewerColumn viewerColumn = new TableViewerColumn( this.tableViewer, SWT.NONE );
        final TableColumn column = viewerColumn.getColumn();
        column.setText( this.memberProperty.getLabel( false, CapitalizationType.TITLE_STYLE, false ) );
        tableColumnLayout.setColumnData( column, new ColumnWeightData( 1, 100, true ) );
       
        decorator.addEditorControl( mainComposite );
       
        suppressDashedTableEntryBorder( this.table );
       
        // Bind to Model
       
View Full Code Here

        nestedComposite.setLayoutData( isLongString ? gdfill() : gdvalign( gdhfill(), SWT.CENTER ) );
        nestedComposite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );
       
        addControl( nestedComposite );
       
        final PropertyEditorAssistDecorator decorator = createDecorator( nestedComposite );
       
        decorator.control().setLayoutData( gdvalign( gd(), SWT.TOP ) );
        decorator.addEditorControl( nestedComposite );
       
        final int style
            = SWT.BORDER |
              ( isLongString ? SWT.MULTI | SWT.WRAP | SWT.V_SCROLL : SWT.NONE ) |
              ( ( isReadOnly || isBrowseOnly ) ? SWT.READ_ONLY : SWT.NONE ) |
              ( isSensitiveData ? SWT.PASSWORD : SWT.NONE );
       
        this.textField = new Text( nestedComposite, style );
        this.textField.setLayoutData( gdfill() );
        decorator.addEditorControl( this.textField, true );
       
        final Serialization serialization = property.definition().getAnnotation( Serialization.class );

        final TextOverlayPainter.Controller textOverlayPainterController = new TextOverlayPainter.Controller()
        {
            @Override
            public boolean isHyperlinkEnabled()
            {
                return ( jumpActionHandler == null ? false : jumpActionHandler.isEnabled() );
            }

            @Override
            public void handleHyperlinkEvent()
            {
                if( jumpActionHandler != null )
                {
                    jumpActionHandler.execute( TextFieldPropertyEditorPresentation.this );
                }
            }

            @Override
            public String overlay()
            {
                String def = property.disposed() ? null : property.getDefaultText();
               
                if( def != null && isSensitiveData )
                {
                    final StringBuilder buf = new StringBuilder();
                   
                    for( int i = 0, n = def.length(); i < n; i++ )
                    {
                        buf.append( "\u25CF" );
                    }
                   
                    def = buf.toString();
                }
               
                if( def == null && serialization != null )
                {
                    def = serialization.primary();
                }
               
                return def;
            }
        };
           
        TextOverlayPainter.install( this.textField, textOverlayPainterController );
       
        if( isBrowseOnly || isReadOnly )
        {
            final Color bgcolor = new Color( this.textField.getDisplay(), 245, 245, 245 );
            this.textField.setBackground( bgcolor );
           
            this.textField.addDisposeListener
            (
                new DisposeListener()
                {
                    public void widgetDisposed( final DisposeEvent event )
                    {
                        bgcolor.dispose();
                    }
                }
            );
        }
       
        final List<Control> relatedControls = new ArrayList<Control>();
        this.textField.setData( RELATED_CONTROLS, relatedControls );
       
        final Listener actionHandlerListener = new Listener()
        {
            @Override
            public void handle( final Event event )
            {
                if( event instanceof PostExecuteEvent )
                {
                    if( ! TextFieldPropertyEditorPresentation.this.textField.isDisposed() )
                    {
                        TextFieldPropertyEditorPresentation.this.textField.setFocus();
                        TextFieldPropertyEditorPresentation.this.textField.setSelection( 0, TextFieldPropertyEditorPresentation.this.textField.getText().length() );
                    }
                }
            }
        };
       
        for( SapphireAction action : actions.getActions() )
        {
            if( ! action.getId().equals( ACTION_ASSIST ) )
            {
                for( SapphireActionHandler handler : action.getActiveHandlers() )
                {
                    handler.attach( actionHandlerListener );
                }
            }
        }
       
        if( isActionsToolBarNeeded )
        {
            final int alignment = ( isLongString ? SWT.VERTICAL : SWT.HORIZONTAL );
            final ToolBar toolbar = new ToolBar( textFieldParent, SWT.FLAT | alignment );
            toolbar.setLayoutData( gdvfill() );
            toolBarActionsPresentation.setToolBar( toolbar );
            toolBarActionsPresentation.render();
            addControl( toolbar );
            decorator.addEditorControl( toolbar );
            relatedControls.add( toolbar );
        }
       
        final ContentProposalService contentProposalService = property.service( ContentProposalService.class );
       
View Full Code Here

                if( style == Style.CHECKBOX )
                {
                    typeSelectorComposite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );
                   
                    final PropertyEditorAssistDecorator decorator = new PropertyEditorAssistDecorator( part, property, typeSelectorComposite );
                    decorator.control().setLayoutData( gd() );
                   
                    final Button masterCheckBox = new Button( typeSelectorComposite, SWT.CHECK );
                    masterCheckBox.setLayoutData( gd() );
                    decorator.addEditorControl( masterCheckBox );
                    actionPresentationKeyboard.attach( masterCheckBox );
                    attachHelp( masterCheckBox, property );
                   
                    if( showLabel )
                    {
                        masterCheckBox.setText( part.label( CapitalizationType.FIRST_WORD_ONLY, true ) );
                       
                        attachPartListener
                        (
                            new FilteredListener<LabelChangedEvent>()
                            {
                                @Override
                                protected void handleTypedEvent( final LabelChangedEvent event )
                                {
                                    masterCheckBox.setText( part.label( CapitalizationType.FIRST_WORD_ONLY, true ) );
                                    layout();
                                }
                            }
                        );
                    }
                   
                    updateUserInterfaceOp = new Runnable()
                    {
                        public void run()
                        {
                            if( Display.getCurrent() == null )
                            {
                                masterCheckBox.getDisplay().asyncExec( this );
                                return;
                            }
                           
                            final Element subModelElement = ( (ElementHandle<?>) property ).content();
                           
                            masterCheckBox.setSelection( subModelElement != null );
                            masterCheckBox.setEnabled( property.enabled() );
                        }
                    };
                           
                    masterCheckBox.addSelectionListener
                    (
                        new SelectionAdapter()
                        {
                            @Override
                            public void widgetSelected( final SelectionEvent event )
                            {
                                try
                                {
                                    final ElementHandle<?> handle = (ElementHandle<?>) property;
                                   
                                    if( masterCheckBox.getSelection() == true )
                                    {
                                        handle.content( true );
                                    }
                                    else
                                    {
                                        handle.clear();
                                    }
                                }
                                catch( Exception e )
                                {
                                    // Note that the EditFailedException is ignored here because the user has already
                                    // been notified and likely has taken action that led to the exception (such as
                                    // declining to make a file writable).
                                   
                                    final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                                   
                                    if( editFailedException == null )
                                    {
                                        Sapphire.service( LoggingService.class ).log( e );
                                    }
                                }
                            }
                        }
                    );
                }
                else
                {
                    typeSelectorComposite.setLayout( glspacing( glayout( 3, 0, 0 ), 2 ) );
                   
                    if( showLabel )
                    {
                        final Label label = new Label( typeSelectorComposite, SWT.NONE );
                        label.setLayoutData( gdhindent( gd(), 9 ) );
                        label.setText( part.label( CapitalizationType.FIRST_WORD_ONLY, true ) + ":" );
                       
                        attachPartListener
                        (
                            new FilteredListener<LabelChangedEvent>()
                            {
                                @Override
                                protected void handleTypedEvent( final LabelChangedEvent event )
                                {
                                    label.setText( part.label( CapitalizationType.FIRST_WORD_ONLY, true ) + ":" );
                                    layout();
                                }
                            }
                        );
                    }
                   
                    final PropertyEditorAssistDecorator decorator = new PropertyEditorAssistDecorator( part, property, typeSelectorComposite );
                    decorator.control().setLayoutData( gdhindent( gdvalign( gd(), ( style == Style.DROP_DOWN_LIST ? SWT.TOP : SWT.CENTER ) ), ( showLabel ? 3 : 0 ) ) );
                   
                    if( style == Style.RADIO_BUTTONS )
                    {
                        final RadioButtonsGroup radioButtonsGroup = new RadioButtonsGroup( typeSelectorComposite, false );
                        radioButtonsGroup.setLayoutData( gdhfill() );
                       
                        final Map<ElementType,Button> typeToButton = new HashMap<ElementType,Button>();
                        final Map<Button,ElementType> buttonToType = new HashMap<Button,ElementType>();
                       
                        for( final ElementType type : allPossibleTypes )
                        {
                            final String label = type.getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false );
                            final Button button = radioButtonsGroup.addRadioButton( label );
                            typeToButton.put( type, button );
                            buttonToType.put( button, type );
                            decorator.addEditorControl( button );
                            actionPresentationKeyboard.attach( button );
                            attachHelp( button, property );
                        }
                       
                        final Button noneButton = radioButtonsGroup.addRadioButton( noneSelection.text() );
                        noneButton.setVisible( false );
                        decorator.addEditorControl( noneButton );
                        actionPresentationKeyboard.attach( noneButton );
                        attachHelp( noneButton, property );
                       
                        updateUserInterfaceOp = new Runnable()
                        {
                            public void run()
                            {
                                if( Display.getCurrent() == null )
                                {
                                    radioButtonsGroup.getDisplay().asyncExec( this );
                                    return;
                                }
                               
                                final Element subModelElement = ( (ElementHandle<?>) property ).content();
                                final Button button;
                               
                                if( subModelElement == null )
                                {
                                    button = noneButton;
                                    noneButton.setVisible( true );
                                }
                                else
                                {
                                    button = typeToButton.get( subModelElement.type() );
                                    noneButton.setVisible( false );
                                }
                               
                                if( radioButtonsGroup.getSelection() != button )
                                {
                                    radioButtonsGroup.setSelection( button );
                                }
                               
                                radioButtonsGroup.setEnabled( property.enabled() );
                            }
                        };
                               
                        radioButtonsGroup.addSelectionListener
                        (
                            new SelectionAdapter()
                            {
                                @Override
                                public void widgetSelected( final SelectionEvent event )
                                {
                                    try
                                    {
                                        final ElementHandle<?> handle = (ElementHandle<?>) property;
                                        final Button button = radioButtonsGroup.getSelection();
                                       
                                        if( button == noneButton )
                                        {
                                            handle.clear();
                                        }
                                        else
                                        {
                                            final ElementType type = buttonToType.get( button );
                                            handle.content( true, type );
                                        }
                                    }
                                    catch( Exception e )
                                    {
                                        // Note that the EditFailedException is ignored here because the user has already
                                        // been notified and likely has taken action that led to the exception (such as
                                        // declining to make a file writable).
                                       
                                        final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                                       
                                        if( editFailedException == null )
                                        {
                                            Sapphire.service( LoggingService.class ).log( e );
                                        }
                                    }
                                }
                            }
                        );
                    }
                    else if( style == Style.DROP_DOWN_LIST )
                    {
                        final Combo combo = new Combo( typeSelectorComposite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
                        combo.setLayoutData( gdhfill() );
                        decorator.addEditorControl( combo );
                        actionPresentationKeyboard.attach( combo );
                        attachHelp( combo, property );
                       
                        final Map<ElementType,Integer> typeToIndex = new HashMap<ElementType,Integer>();
                        final Map<Integer,ElementType> indexToType = new HashMap<Integer,ElementType>();
View Full Code Here

            final ProxyResource resource = new ProxyResource();
            final Element proxyElement = this.memberProperty.getModelElementType().instantiate(list, resource);
            resource.init(proxyElement, this.memberProperty);
            final PropertyEditorPart editor = part.getChildPropertyEditor( proxyElement, this.memberProperty );
           
            PropertyEditorAssistDecorator decorator = addDecorator(editor);

            Text text = new Text(this.textComposite, SWT.BORDER);
            text.setLayoutData( gdhindent( gdwhint( gdhfill(), 150 ), 0 ) );
            TextBinding binding = new TextBinding(text, resource);
            binding.setDecorator(decorator);
            this.textBindings.add(binding);

            addControl( text );

            addToolbar(binding, editor);
           
            decorator.addEditorControl(text);
            decorator.addEditorControl(binding.getToolbar());
        }

        this.addText = new SapphireFormText( this.mainComposite, SWT.NONE );
        this.addText.setLayoutData( gdhindent( gdvalign( gdhfill(), SWT.CENTER ), 10 ) );
       
View Full Code Here

       
        TextOverlayPainter.install( binding.getText(), textOverlayPainterController );
    }
   
    private PropertyEditorAssistDecorator addDecorator(final PropertyEditorPart editor) {
        final PropertyEditorAssistDecorator decorator = new PropertyEditorAssistDecorator(editor, this.textComposite);
        decorator.control().setLayoutData( gdvindent( gdvalign( gd(), SWT.TOP ), 2 ) );

        return decorator;
    }
View Full Code Here

        ProxyResource resource = new ProxyResource();
        final Element proxyElement = this.memberProperty.getModelElementType().instantiate(list(), resource);
        resource.init(proxyElement, this.memberProperty);
        PropertyEditorPart editor = part().getChildPropertyEditor( proxyElement, this.memberProperty );

        PropertyEditorAssistDecorator decorator = addDecorator(editor);

        Text text = new Text(this.textComposite, SWT.BORDER);
        text.setLayoutData( gdwhint( gdhfill(), 150 ) );
        TextBinding binding = new TextBinding(text, resource);
        binding.setDecorator(decorator);
        this.textBindings.add(binding);
       
        addControl(text);
       
        addToolbar(binding, editor);
       
        decorator.addEditorControl(text);
        decorator.addEditorControl(binding.getToolbar());

        layout();
        text.setFocus();
    }
View Full Code Here

   
    void deleteBinding(TextBinding binding) {
        Element elem = binding.getModelElement();
        Text text = binding.getText();
        ToolBar toolbar = binding.getToolbar();
        PropertyEditorAssistDecorator decorator = binding.getDecorator();
       
        binding.setModifying(true);
       
        if (elem != null) {
            list().remove(elem);
        }
       
        binding.setModifying(false);

        if (this.textBindings.size() > 1) {
            binding.removeListener();
            this.textBindings.remove(binding);
            text.dispose();
            toolbar.dispose();
           
            Control control = decorator.control();
            decorator.removeEditorControl(control);
            control.dispose();

            layout();
        } else {
            binding.refreshModelElement(null);
View Full Code Here

        }

        final Composite mainComposite = createMainComposite( parent );
        mainComposite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );

        final PropertyEditorAssistDecorator decorator = createDecorator( mainComposite );
        decorator.control().setLayoutData( gdvindent( gdvalign( gd(), ( this.orientation == Orientation.HORIZONTAL ? SWT.CENTER : SWT.TOP ) ), ( this.orientation == Orientation.HORIZONTAL ? 0 : 4 ) ) );
       
        this.checkBoxesComposite = new Composite( mainComposite, SWT.NONE );
        this.checkBoxesComposite.setLayoutData( gdvalign( gd(), SWT.CENTER ) );
       
        final RowLayout checkBoxesCompositeLayout = new RowLayout();
View Full Code Here

       
        final Composite composite = new Composite( this.rootComposite, SWT.NONE );
        composite.setLayoutData( gdhfill() );
        composite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );
       
        final PropertyEditorAssistDecorator decorator = new PropertyEditorAssistDecorator( part, composite );
       
        decorator.control().setLayoutData( gdvalign( gd(), SWT.CENTER ) );
        decorator.addEditorControl( this.rootComposite );
        decorator.addEditorControl( composite );
       
        this.overallLabelControl = new Label( composite, SWT.WRAP );
        this.overallLabelControl.setLayoutData( gd() );
        this.overallLabelControl.setText( property.getLabel( true, CapitalizationType.FIRST_WORD_ONLY, true ) );
        decorator.addEditorControl( this.overallLabelControl );
       
        final SelectionListener selectionListener = new SelectionAdapter()
        {
            @Override
            public void widgetSelected( final SelectionEvent event )
            {
                handleRadioButtonSelectedEvent( event );
            }
        };
       
        final Composite radioButtonsComposite = new Composite( this.rootComposite, SWT.NONE );
        radioButtonsComposite.setLayoutData( gdhindent( gdhfill(), 20 ) );
        radioButtonsComposite.setLayout( glayout( 2, 0, 0, 0, 0 ) );
        decorator.addEditorControl( radioButtonsComposite );
       
        this.radioButtonGroup = new ArrayList<Button>();
       
        final String arbitraryValueLabel
            = property.getLocalizationService().text( namedValuesAnnotation.arbitraryValueLabel(), CapitalizationType.FIRST_WORD_ONLY, true ) + ":";
   
        this.arbitraryValueRadioButton = createRadioButton( radioButtonsComposite, arbitraryValueLabel );
        this.arbitraryValueRadioButton.setLayoutData( gd() );
        this.arbitraryValueRadioButton.addSelectionListener( selectionListener );
        this.radioButtonGroup.add( this.arbitraryValueRadioButton );
        decorator.addEditorControl( this.arbitraryValueRadioButton );

        this.arbitraryValueTextField = new Text( radioButtonsComposite, SWT.BORDER );
        this.arbitraryValueTextField.setLayoutData( gdwhint( gd(), 150 ) );
        decorator.addEditorControl( this.arbitraryValueTextField );
       
        this.arbitraryValueTextField.addModifyListener
        (
            new ModifyListener()
            {
                public void modifyText( final ModifyEvent event )
                {
                    handleArbitraryValueTextFieldChangedEvent( event );
                }
            }
        );
       
        final TextOverlayPainter.Controller textOverlayPainterController = new TextOverlayPainter.Controller()
        {
            @Override
            public String overlay()
            {
                return ( (Value<?>) property() ).getDefaultText();
            }
        };
   
        TextOverlayPainter.install( this.arbitraryValueTextField, textOverlayPainterController );
       
        this.namedValuesRadioButtons = new Button[ this.namedValues.length ];
       
        for( int i = 0; i < this.namedValues.length; i++ )
        {
            final Button rb = createRadioButton( radioButtonsComposite, this.namedValues[ i ].valueName );
            rb.addSelectionListener( selectionListener );
            decorator.addEditorControl( rb );
            this.namedValuesRadioButtons[ i ] = rb;
            this.radioButtonGroup.add( rb );
        }
       
        this.rootComposite.setData( "peditor", this );
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ui.assist.internal.PropertyEditorAssistDecorator

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.