Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.Property


    public static final class Condition extends ServiceCondition
    {
        @Override
        public boolean applicable( final ServiceContext context )
        {
            final Property property = context.find( Property.class );
            return ( property != null && property.service( JavaTypeConstraintService.class ) != null );
        }
View Full Code Here


    @SuppressWarnings( "unchecked" ) // TreeViewer is parameterized since Eclipse 4.4
   
    protected Control createContents( final Composite parent, final boolean embedded )
    {
        final PropertyEditorPart part = part();
        final Property property = part.property();
        final boolean isReadOnly = part.isReadOnly();
        final boolean showHeader = part.getRenderingHint( PropertyEditorDef.HINT_SHOW_HEADER, true );
       
        final SapphireActionGroup actions = getActions();
        final SapphireActionPresentationManager actionPresentationManager = getActionPresentationManager();
       
        final SapphireToolBarActionPresentation toolBarActionsPresentation = new SapphireToolBarActionPresentation( actionPresentationManager );
        toolBarActionsPresentation.addFilter( createFilterByActionId( ACTION_ASSIST ) );
        toolBarActionsPresentation.addFilter( createFilterByActionId( ACTION_JUMP ) );
       
        final SapphireMenuActionPresentation menuActionsPresentation = new SapphireMenuActionPresentation( actionPresentationManager );
        menuActionsPresentation.addFilter( createFilterByActionId( ACTION_ASSIST ) );
        menuActionsPresentation.addFilter( createFilterByActionId( ACTION_JUMP ) );
       
        addOnDisposeOperation
        (
            new Runnable()
            {
                public void run()
                {
                    actionPresentationManager.dispose();
                }
            }
        );
       
        final Composite mainComposite = createMainComposite
        (
            parent,
            new CreateMainCompositeDelegate( part )
            {
                @Override
                public boolean getShowLabel()
                {
                    return ( embedded ? false : super.getShowLabel() );
                }

                @Override
                public int getLeftMargin()
                {
                    return ( embedded ? 0 : super.getLeftMargin() );
                }

                @Override
                public boolean getSpanBothColumns()
                {
                    return ( embedded ? true : super.getSpanBothColumns() );
                }
            }
        );
       
        final Composite tableComposite;
       
        if( this.decorator == null )
        {
            tableComposite = new Composite( mainComposite, SWT.NULL );
            tableComposite.setLayoutData( gdfill() );
            tableComposite.setLayout( glspacing( glayout( 2, 0, 0 ), 2 ) );
           
            this.decorator = createDecorator( tableComposite );
            this.decorator.control().setLayoutData( gdvalign( gd(), SWT.TOP ) );

            this.decorator.addEditorControl( tableComposite );
        }
        else
        {
            tableComposite = mainComposite;
        }
       
        this.decorator.addEditorControl( mainComposite );
       
        // 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 tableParentComposite = new Composite( tableComposite, SWT.NULL );
        tableParentComposite.setLayoutData( gdwhint( gdfill(), 1 ) );
        final TableColumnLayout tableColumnLayout = new TableColumnLayout();
        tableParentComposite.setLayout( tableColumnLayout );
       
        this.tableViewer = new CustomTableViewer( tableParentComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI );
        this.table = this.tableViewer.getTable();
        this.decorator.addEditorControl( this.table );
       
        final List<Control> relatedControls = new ArrayList<Control>();
        this.table.setData( RELATED_CONTROLS, relatedControls );
       
        this.table.addListener
        (
            SWT.MeasureItem,
            new org.eclipse.swt.widgets.Listener()
            {
                public void handleEvent( final org.eclipse.swt.widgets.Event event )
                {
                    // The rows should be 18 pixels at minimum to allow sufficient
                    // room for the cell editors.
                   
                    event.height = Math.max( event.height, 18 );
                }
            }
        );
       
        this.columnHandlers = new ArrayList<ColumnHandler>();
       
        final ColumnViewerEditorActivationStrategy activationStrategy = new ColumnViewerEditorActivationStrategy( this.tableViewer )
        {
            protected boolean isEditorActivationEvent( final ColumnViewerEditorActivationEvent event )
            {
                final int columnIndex = ( (ViewerCell) event.getSource() ).getColumnIndex();
                final ColumnHandler columnHandler = getColumnHandler( columnIndex );
                return columnHandler.isEditorActivationEvent( event );
            }
        };
       
        TableViewerEditor.create( this.tableViewer, null, activationStrategy, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_CYCLE_IN_ROW );

        this.table.setHeaderVisible( showHeader );
       
        this.selectionProvider = new SelectionProvider( this.tableViewer );
       
        this.table.addFocusListener
        (
            new FocusAdapter()
            {
                @Override
                public void focusGained( final FocusEvent event )
                {
                    handleTableFocusGainedEvent();
                }
            }
        );
       
        this.refreshOperation = new Runnable()
        {
            boolean running = false;
           
            public void run()
            {
                if( TablePropertyEditorPresentation.this.table.isDisposed() )
                {
                    return;
                }
               
                if( this.running == true )
                {
                    return;
                }
               
                this.running = true;
               
                try
                {
                    TablePropertyEditorPresentation.this.tableViewer.refresh();

                    if( TablePropertyEditorPresentation.this.table.isDisposed() )
                    {
                        return;
                    }
                   
                    TablePropertyEditorPresentation.this.table.notifyListeners( SWT.Selection, null );
                    tableParentComposite.layout();
                }
                finally
                {
                    this.running = false;
                }
            }
        };
       
        final Listener listener = new FilteredListener<PropertyContentEvent>()
        {
            @Override
            protected void handleTypedEvent( final PropertyContentEvent event )
            {
                TablePropertyEditorPresentation.this.refreshOperation.run();
            }
        };
       
        property.attach( listener );
       
        addOnDisposeOperation
        (
            new Runnable()
            {
                public void run()
                {
                    property.detach( listener );
                }
            }
        );
       
        boolean showImages = true;
       
        final String columnWidthsHint = part.getRenderingHint( PropertyEditorDef.HINT_COLUMN_WIDTHS, "" );
        final StringTokenizer columnWidthsHintTokenizer = new StringTokenizer( columnWidthsHint, "," );
       
        for( final ModelPath childPropertyPath : part.getChildProperties() )
        {
            final PropertyDef childProperty = property.definition().getType().property( childPropertyPath );
            final PropertyEditorDef childPropertyEditorDef = part.definition().getChildPropertyEditor( childPropertyPath );
            final TableViewerColumn tableViewerColumn = new TableViewerColumn( this.tableViewer, SWT.NONE );
           
            if( childPropertyEditorDef == null )
            {
                final String label = childProperty.getLabel( false, CapitalizationType.TITLE_STYLE, false );
                tableViewerColumn.getColumn().setText( label );
            }
            else
            {
                final MutableReference<FunctionResult> labelFunctionResultRef = new MutableReference<FunctionResult>();
               
                final Runnable updateLabelOp = new Runnable()
                {
                    public void run()
                    {
                        String label = (String) labelFunctionResultRef.get().value();
                        label = LabelTransformer.transform( label, CapitalizationType.TITLE_STYLE, false );
                        tableViewerColumn.getColumn().setText( label );
                    }
                };
               
                final FunctionResult labelFunctionResult = part.initExpression
                (
                    childPropertyEditorDef.getLabel().content(),
                    String.class,
                    Literal.create( childProperty.getLabel( false, CapitalizationType.NO_CAPS, true ) ),
                    updateLabelOp
                );
               
                labelFunctionResultRef.set( labelFunctionResult );
               
                updateLabelOp.run();
               
                addOnDisposeOperation
                (
                    new Runnable()
                    {
                        public void run()
                        {
                            labelFunctionResult.dispose();
                        }
                    }
                );
            }
           
            ColumnWeightData columnWeightData = null;
           
            if( columnWidthsHintTokenizer.hasMoreTokens() )
            {
                final String columnWidthHint = columnWidthsHintTokenizer.nextToken();
                final String[] columnWidthHintSplit = columnWidthHint.split( ":" );
               
                if( columnWidthHintSplit.length == 1 || columnWidthHintSplit.length == 2 )
                {
                    try
                    {
                        final int minColumnWidth = Integer.parseInt( columnWidthHintSplit[ 0 ].trim() );
                        final int columnWeight;
                       
                        if( columnWidthHintSplit.length == 2 )
                        {
                            columnWeight = Integer.parseInt( columnWidthHintSplit[ 1 ].trim() );
                        }
                        else
                        {
                            columnWeight = 0;
                        }
                       
                        columnWeightData = new ColumnWeightData( columnWeight, minColumnWidth, true );
                    }
                    catch( NumberFormatException e ) {}
                }
            }
           
            if( columnWeightData == null )
            {
                columnWeightData = new ColumnWeightData( 1, 100, true );
            }
           
            tableColumnLayout.setColumnData( tableViewerColumn.getColumn(), columnWeightData );
           
            final ColumnHandler columnHandler = createColumnHandler( this.columnHandlers, childPropertyPath, showImages, childPropertyEditorDef );
           
            showImages = false; // Only the first column should ever show the image.
           
            tableViewerColumn.setLabelProvider( columnHandler.getLabelProvider() );
            tableViewerColumn.setEditingSupport( columnHandler.getEditingSupport() );
           
            final TableColumn tableColumn = tableViewerColumn.getColumn();
           
            tableColumn.addSelectionListener
            (
                new SelectionAdapter()
                {
                    @Override
                    public void widgetSelected( final SelectionEvent event )
                    {
                        final TableColumn currentSortColumn = TablePropertyEditorPresentation.this.table.getSortColumn();
                       
                        if( currentSortColumn != tableColumn )
                        {
                            TablePropertyEditorPresentation.this.table.setSortColumn( tableColumn );
                            TablePropertyEditorPresentation.this.table.setSortDirection( SWT.DOWN );
                            TablePropertyEditorPresentation.this.tableViewer.setComparator( new TableSorter( columnHandler, SWT.DOWN ) );
                        }
                        else
                        {
                            final int currentSortDirection = TablePropertyEditorPresentation.this.table.getSortDirection();
                           
                            if( currentSortDirection == SWT.DOWN )
                            {
                                TablePropertyEditorPresentation.this.table.setSortDirection( SWT.UP );
                                TablePropertyEditorPresentation.this.tableViewer.setComparator( new TableSorter( columnHandler, SWT.UP ) );
                            }
                            else
                            {
                                TablePropertyEditorPresentation.this.table.setSortColumn( null );
                                TablePropertyEditorPresentation.this.tableViewer.setComparator( null );
                            }
                        }
                       
                        for( SapphireAction action : actions.getActions() )
                        {
                            for( SapphireActionHandler handler : action.getActiveHandlers() )
                            {
                                if( handler instanceof PropertyEditorActionHandler )
                                {
                                    ( (PropertyEditorActionHandler) handler ).refreshEnablementState();
                                }
                            }
                        }
                    }
                }
            );
        }
       
        final IStructuredContentProvider contentProvider = new IStructuredContentProvider()
        {
            public Object[] getElements( final Object inputElement )
            {
                final ElementList<?> list = property();
                final Map<Element,TableRow> rows = new LinkedHashMap<Element,TableRow>();
               
                for( Element element : list )
                {
                    TableRow row = null;
                   
                    if( TablePropertyEditorPresentation.this.rows != null )
                    {
                        row = TablePropertyEditorPresentation.this.rows.remove( element );
                    }
                   
                    if( row == null )
                    {
                        ImageProvider imageProvider = null;
                       
                        final ImageService imageService = element.service( ImageService.class );
                       
                        if( imageService != null )
                        {
                            imageProvider = new ImageProvider()
                            {
                                private Listener imageServiceListener;
                               
                                @Override
                                public ImageData image()
                                {
                                    if( this.imageServiceListener == null )
                                    {
                                        this.imageServiceListener = new Listener()
                                        {
                                            @Override
                                            public void handle( final Event event )
                                            {
                                                update( row() );
                                            }
                                        };
                                       
                                        imageService.attach( this.imageServiceListener );
                                    }
                                   
                                    return imageService.image();
                                }

                                @Override
                                public void dispose()
                                {
                                    if( this.imageServiceListener != null )
                                    {
                                        imageService.detach( this.imageServiceListener );
                                    }
                                }
                            };
                        }
                        else if( getColumnCount() == 1 )
                        {
                            final Value<?> value = (Value<?>) element.property( getColumnHandler( 0 ).property() );
                            final ValueImageService valueImageService = value.service( ValueImageService.class );
                           
                            if( valueImageService != null )
                            {
                                imageProvider = new ImageProvider()
                                {
                                    @Override
                                    public ImageData image()
                                    {
                                        return valueImageService.provide( value.text() );
                                    }
                                };
                            }
                        }
                       
                        row = new TableRow( element, imageProvider );
                    }
                   
                    rows.put( element, row );
                }
               
                if( TablePropertyEditorPresentation.this.rows != null )
                {
                    for( TableRow row : TablePropertyEditorPresentation.this.rows.values() )
                    {
                        row.dispose();
                    }
                }
               
                TablePropertyEditorPresentation.this.rows = rows;

                return rows.values().toArray();
            }

            public void inputChanged( final Viewer viewer,
                                      final Object oldInput,
                                      final Object newInput )
            {
            }

            public void dispose()
            {
                for( TableRow row : TablePropertyEditorPresentation.this.rows.values() )
                {
                    row.dispose();
                }
            }
        };
       
        this.tableViewer.setContentProvider( contentProvider );
        this.tableViewer.setInput( contentProvider );
       
        this.table.addTraverseListener
        (
            new TraverseListener()
            {
                public void keyTraversed( final TraverseEvent event )
                {
                    handleTableTraverseEvent( event );
                }
            }
        );
       
        final ListSelectionService selectionService = part.service( ListSelectionService.class );
       
        this.selectionProvider.addSelectionChangedListener
        (
            new ISelectionChangedListener()
            {
                public void selectionChanged( SelectionChangedEvent event )
                {
                    selectionService.select( getSelectedElements() );
                }
            }
        );
       
        setSelectedElements( selectionService.selection() );
       
        final org.eclipse.sapphire.Listener selectionServiceListener = new FilteredListener<ListSelectionChangedEvent>()
        {
            @Override
            protected void handleTypedEvent( final ListSelectionChangedEvent event )
            {
                setSelectedElements( event.after() );
            }
        };

        selectionService.attach( selectionServiceListener );

        if( ! isReadOnly )
        {
            if( this.exposeAddAction )
            {
                final SapphireAction addAction = actions.getAction( ACTION_ADD );
                final List<SapphireActionHandler> addActionHandlers = new ArrayList<SapphireActionHandler>();
               
                final org.eclipse.sapphire.Listener addActionHandlerListener = new org.eclipse.sapphire.Listener()
                {
                    @Override
                    public void handle( final org.eclipse.sapphire.Event event )
                    {
                        if( event instanceof PostExecuteEvent )
                        {
                            if( TablePropertyEditorPresentation.this.table.isDisposed() )
                            {
                                return;
                            }
                           
                            final Element newListElement = (Element) ( (PostExecuteEvent) event ).getResult();
       
                            if( newListElement != null )
                            {
                                TablePropertyEditorPresentation.this.refreshOperation.run();
                               
                                final TableRow row = findTableRow( newListElement );
                               
                                TablePropertyEditorPresentation.this.tableViewer.setSelection( new StructuredSelection( row ), true );
                               
                                if( TablePropertyEditorPresentation.this.table.isDisposed() )
                                {
                                    return;
                                }
                               
                                TablePropertyEditorPresentation.this.tableViewer.editElement( row, 0 );
                                TablePropertyEditorPresentation.this.table.notifyListeners( SWT.Selection, null );
                            }
                        }
                    }
                };
               
                final PossibleTypesService possibleTypesService = property.service( PossibleTypesService.class );

                final Runnable refreshAddActionHandlersOp = new Runnable()
                {
                    public void run()
                    {
                        addAction.removeHandlers( addActionHandlers );
                       
                        for( SapphireActionHandler addActionHandler : addActionHandlers )
                        {
                            addActionHandler.dispose();
                        }
                       
                        for( ElementType memberType : possibleTypesService.types() )
                        {
                            final SapphireActionHandler addActionHandler = new AddActionHandler( memberType );
                            addActionHandler.init( addAction, null );
                            addActionHandler.attach( addActionHandlerListener );
                            addActionHandlers.add( addActionHandler );
                            addAction.addHandler( addActionHandler );
                        }
                    }
                };
               
                refreshAddActionHandlersOp.run();
               
                final org.eclipse.sapphire.Listener possibleTypesServiceListener = new org.eclipse.sapphire.Listener()
                {
                    @Override
                    public void handle( final org.eclipse.sapphire.Event event )
                    {
                        refreshAddActionHandlersOp.run();
                    }
                };
               
                possibleTypesService.attach( possibleTypesServiceListener );
               
                addOnDisposeOperation
                (
                    new Runnable()
                    {
                        public void run()
                        {
                            addAction.removeHandlers( addActionHandlers );
                           
                            for( SapphireActionHandler addActionHandler : addActionHandlers )
                            {
                                addActionHandler.dispose();
                            }
                           
                            possibleTypesService.detach( possibleTypesServiceListener );
                        }
                    }
                );
            }
           
            if( this.exposeDeleteAction )
            {
                final SapphireAction deleteAction = actions.getAction( ACTION_DELETE );
                final SapphireActionHandler deleteActionHandler = new DeleteActionHandler();
                deleteActionHandler.init( deleteAction, null );
                deleteAction.addHandler( deleteActionHandler );
               
                addOnDisposeOperation
                (
                    new Runnable()
                    {
                        public void run()
                        {
                            deleteAction.removeHandler( deleteActionHandler );
                        }
                    }
                );
            }

            if( ! property.definition().hasAnnotation( FixedOrderList.class ) )
            {
                final SapphireAction moveUpAction = actions.getAction( ACTION_MOVE_UP );
                final SapphireActionHandler moveUpActionHandler = new MoveUpActionHandler();
                moveUpActionHandler.init( moveUpAction, null );
                moveUpAction.addHandler( moveUpActionHandler );
               
                addOnDisposeOperation
                (
                    new Runnable()
                    {
                        public void run()
                        {
                            moveUpAction.removeHandler( moveUpActionHandler );
                        }
                    }
                );
               
                final SapphireAction moveDownAction = actions.getAction( ACTION_MOVE_DOWN );
                final SapphireActionHandler moveDownActionHandler = new MoveDownActionHandler();
                moveDownActionHandler.init( moveDownAction, null );
                moveDownAction.addHandler( moveDownActionHandler );
               
                addOnDisposeOperation
                (
                    new Runnable()
                    {
                        public void run()
                        {
                            moveDownAction.removeHandler( moveDownActionHandler );
                        }
                    }
                );

                final org.eclipse.sapphire.Listener moveActionHandlerListener = new org.eclipse.sapphire.Listener()
                {
                    @Override
                    public void handle( final org.eclipse.sapphire.Event event )
                    {
                        if( event instanceof PostExecuteEvent )
                        {
                            TablePropertyEditorPresentation.this.refreshOperation.run();
                           
                            // This is a workaround for a weird problem on SWT on Windows. If modifier keys are pressed
                            // when the list is re-ordered (as in when issuing move up or move down command from the
                            // keyboard), the focused row can detached from selected row.
                           
                            final Element element = getSelectedElement();
                            final TableItem[] items = TablePropertyEditorPresentation.this.table.getItems();
                           
                            for( int i = 0; i < items.length; i++ )
                            {
                                if( items[ i ].getData() == element )
                                {
                                    TablePropertyEditorPresentation.this.table.setSelection( i );
                                    break;
                                }
                            }
                        }
                    }
                };
               
                moveUpAction.attach( moveActionHandlerListener );
                moveDownAction.attach( moveActionHandlerListener );
               
                final ElementsTransfer transfer = new ElementsTransfer( element().type().getModelElementClass().getClassLoader() );
                final Transfer[] transfers = new Transfer[] { transfer };
               
                final DragSource dragSource = new DragSource( this.table, DND.DROP_COPY | DND.DROP_MOVE );
                dragSource.setTransfer( transfers );

                final List<Element> dragElements = new ArrayList<Element>();
               
                dragSource.addDragListener
                (
                    new DragSourceListener()
                    {
                        public void dragStart( final DragSourceEvent event )
                        {
                            if( TablePropertyEditorPresentation.this.tableViewer.getComparator() == null )
                            {
                                dragElements.addAll( getSelectedElements() );
                                event.doit = true;
                            }
                            else
                            {
                                event.doit = false;
                            }
                        }
                       
                        public void dragSetData( final DragSourceEvent event )
                        {
                            event.data = dragElements;
                        }
                       
                        public void dragFinished( final DragSourceEvent event )
                        {
                            if( event.detail == DND.DROP_MOVE )
                            {
                                // When drop target is the same editor as drag source, the drop handler takes care of removing
                                // elements from their original location. The following block of code accounts for the case when
                                // dropping into another editor.
                               
                                boolean droppedIntoAnotherEditor = false;
                               
                                for( Element dragElement : dragElements )
                                {
                                    if( ! dragElement.disposed() )
                                    {
                                        droppedIntoAnotherEditor = true;
                                        break;
                                    }
                                }
                               
                                if( droppedIntoAnotherEditor )
                                {
                                    try
                                    {
                                        final Element selectionPostDelete = findSelectionPostDelete( property(), dragElements );
                                       
                                        for( Element dragElement : dragElements )
                                        {
                                            final ElementList<?> dragElementContainer = (ElementList<?>) dragElement.parent();
                                            dragElementContainer.remove( dragElement );
                                        }
                                       
                                        setSelectedElement( selectionPostDelete );
                                    }
                                    catch( Exception e )
                                    {
                                        // Log this exception unless the cause is EditFailedException. These exception
                                        // are the result of the user declining a particular action that is necessary
                                        // before the edit can happen (such as making a file writable).
                                       
                                        final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                                       
                                        if( editFailedException == null )
                                        {
                                            Sapphire.service( LoggingService.class ).log( e );
                                        }
                                    }
                                }
                            }
                           
                            dragElements.clear();
                        }
                    }
                );
               
                final DropTarget target = new DropTarget( this.table, DND.DROP_COPY | DND.DROP_MOVE );
                target.setTransfer( transfers );
               
                target.addDropListener
                (
                    new DropTargetAdapter()
                    {
                        public void dragOver( final DropTargetEvent event )
                        {
                            if( event.item != null )
                            {
                                final TableItem dragOverItem = (TableItem) event.item;

                                final Point pt = dragOverItem.getDisplay().map( null, TablePropertyEditorPresentation.this.table, event.x, event.y );
                                final Rectangle bounds = dragOverItem.getBounds();
                               
                                if( pt.y < bounds.y + bounds.height / 2 )
                                {
                                    event.feedback = DND.FEEDBACK_INSERT_BEFORE;
                                }
                                else
                                {
                                    event.feedback = DND.FEEDBACK_INSERT_AFTER;
                                }
                            }
                           
                            event.feedback |= DND.FEEDBACK_SCROLL;
                        }

                        public void drop( final DropTargetEvent event )
                        {
                            if( event.data == null )
                            {
                                event.detail = DND.DROP_NONE;
                                return;
                            }
                           
                            final List<ElementData> droppedElements = (List<ElementData>) event.data;
                            final Set<ElementType> possibleTypesService = property.service( PossibleTypesService.class ).types();
                           
                            for( final ElementData droppedElement : droppedElements )
                            {
                                if( ! possibleTypesService.contains( droppedElement.type() ) )
                                {
View Full Code Here

   
    @Override
    public PropertyEditorPresentation2 createChildPropertyEditorPresentation( final PropertyEditorPart part )
    {
        final Table table = this.table;
        final Property property = part.property();
        final Element element = findTableRowElement( property.element() );
       
        ColumnHandler handler = null;
       
        for( final ColumnHandler h : this.columnHandlers )
        {
View Full Code Here

            {
                row = findTableRow( el );
               
                if( row == null )
                {
                    final Property parent = el.parent();
                   
                    if( parent != null )
                    {
                        el = parent.element();
                    }
                }
            }
           
            if( row != null )
View Full Code Here

public final class RelativePathBrowseActionHandlerCondition 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

public final class EnumPropertyEditorPresentationFactory extends PropertyEditorPresentationFactory
{
    @Override
    public PropertyEditorPresentation create( final PropertyEditorPart part, final SwtPresentation parent, final Composite composite )
    {
        final Property property = part.property();
       
        if( property instanceof Value && property.definition().isOfType( Enum.class ) )
        {
            final Enum<?>[] enumValues = (Enum<?>[]) property.definition().getTypeClass().getEnumConstants();
           
            if( enumValues.length > 3 )
            {
                return new PopUpListFieldPropertyEditorPresentation( part, parent, composite, PopUpListFieldStyle.STRICT );
            }
View Full Code Here

    }

    @Override
    protected void createContents( final Composite parent )
    {
        final Property property = property();
       
        // TODO support readonly
        //final boolean isReadOnly = ( property.isReadOnly() || part.getRenderingHint( HINT_READ_ONLY, false ) );

        final SortedSet<PropertyDef> allMemberProperties = property.definition().getType().properties();
       
        if( allMemberProperties.size() == 1 )
        {
            final PropertyDef prop = allMemberProperties.first();
           
View Full Code Here

        }
       
        for( MasterDetailsContentNodePart node : nodesToDelete )
        {
            final Element element = node.getModelElement();
            final Property elementParent = element.parent();
           
            if( elementParent.definition() instanceof ListProperty )
            {
                ( (ElementList<?>) elementParent ).remove( element );
            }
            else
            {
View Full Code Here

    }

    @Override
    protected void initValidationService()
    {
        final Property property = context( Property.class );

        property.service( JavaTypeConstraintService.class ).attach
        (
            new Listener()
            {
                @Override
                public void handle( final Event event )
                {
                    refresh();
                }
            }
        );
       
        property.service( ReferenceService.class ).attach
        (
            new Listener()
            {
                @Override
                public void handle( final Event event )
View Full Code Here

    public static final class Condition extends ServiceCondition
    {
        @Override
        public boolean applicable( final ServiceContext context )
        {
            final Property property = context.find( Property.class );
           
            if( property != null && property.definition().getTypeClass() == JavaTypeName.class )
            {
                final Reference referenceAnnotation = property.definition().getAnnotation( Reference.class );
               
                if( referenceAnnotation != null && referenceAnnotation.target() == JavaType.class )
                {
                    return property.service( JavaTypeConstraintService.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.