Examples of EditFailedException


Examples of org.eclipse.sapphire.modeling.EditFailedException

                {
                    property().write( value, true );
                }
                catch( Exception e )
                {
                    final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                   
                    if( editFailedException != null )
                    {
                        rollback = true;
                    }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

        {
            doUpdateModel();
        }
        catch( Exception e )
        {
            final EditFailedException editFailedException = EditFailedException.findAsCause( e );
           
            if( editFailedException != null )
            {
                rollback = true;
            }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

            {
                // 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 );
                }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

                            {
                                // The EditFailedException happen here only as the result of the user explicitly deciding
                                // not not go forward with an action. They serve the purpose of an abort signal so we
                                // don't log them. Everything else gets logged.
                               
                                final EditFailedException editFailedException = EditFailedException.findAsCause( e );
                               
                                if( editFailedException == null )
                                {
                                    Sapphire.service( LoggingService.class ).log( e );
                                }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

        {
            // 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 );
            }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

                                {
                                    // 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>();
                       
                        int index = 0;
                       
                        for( ElementType type : allPossibleTypes )
                        {
                            final String label = type.getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false );
                            combo.add( label );
                            typeToIndex.put( type, index );
                            indexToType.put( index, type );
                           
                            index++;
                        }
                       
                        updateUserInterfaceOp = new Runnable()
                        {
                            public void run()
                            {
                                if( Display.getCurrent() == null )
                                {
                                    combo.getDisplay().asyncExec( this );
                                    return;
                                }
                               
                                final Element subModelElement = ( (ElementHandle<?>) property ).content();
                                final int index;
                               
                                if( subModelElement == null )
                                {
                                    index = -1;
                                }
                                else
                                {
                                    index = typeToIndex.get( subModelElement.type() );
                                }
                               
                                if( combo.getSelectionIndex() != index )
                                {
                                    if( index == -1 )
                                    {
                                        combo.deselectAll();
                                    }
                                    else
                                    {
                                        combo.select( index );
                                    }
                                }
                               
                                combo.setEnabled( property.enabled() );
                            }
                        };
   
                        combo.addSelectionListener
                        (
                            new SelectionAdapter()
                            {
                                @Override
                                public void widgetSelected( final SelectionEvent event )
                                {
                                    try
                                    {
                                        final ElementHandle<?> handle = (ElementHandle<?>) property;
                                        final int index = combo.getSelectionIndex();
                                       
                                        if( index == -1 )
                                        {
                                            handle.clear();
                                        }
                                        else
                                        {
                                            final ElementType type = indexToType.get( index );
                                            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 );
                                        }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

                                    {
                                        // 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() ) )
                                {
                                    event.detail = DND.DROP_NONE;
                                    return;
                                }
                            }
                           
                            final ElementList<?> list = property();
                           
                            int position;
                           
                            if( event.item == null )
                            {
                                position = list.size();
                            }
                            else
                            {
                                final TableItem dropTargetItem = (TableItem) event.item;
                                final TableRow dropTargetRow = (TableRow) dropTargetItem.getData();
                                final Element dropTargetElement = dropTargetRow.element();
                               
                                final Point pt = TablePropertyEditorPresentation.this.table.getDisplay().map( null, TablePropertyEditorPresentation.this.table, event.x, event.y );
                                final Rectangle bounds = dropTargetItem.getBounds();
                               
                                position = list.indexOf( dropTargetElement );
                               
                                if( pt.y >= bounds.y + bounds.height / 2 )
                                {
                                    position++;
                                }
                            }
                           
                            try
                            {
                                if( event.detail == DND.DROP_MOVE )
                                {
                                    for( Element dragElement : dragElements )
                                    {
                                        final ElementList<?> dragElementContainer = (ElementList<?>) dragElement.parent();
                                       
                                        if( dragElementContainer == list && dragElementContainer.indexOf( dragElement ) < position )
                                        {
                                            position--;
                                        }
                                       
                                        dragElementContainer.remove( dragElement );
                                    }
                                }
           
                                final List<Element> newSelection = new ArrayList<Element>();
                               
                                for( final ElementData droppedElement : droppedElements )
                                {
                                    final Element insertedElement = list.insert( droppedElement.type(), position );
                                    insertedElement.copy( droppedElement );
                                   
                                    newSelection.add( insertedElement );
                                   
                                    position++;
                                }
                               
                                if( TablePropertyEditorPresentation.this.table.isDisposed() )
                                {
                                    return;
                                }
                               
                                TablePropertyEditorPresentation.this.tableViewer.refresh();
                                setSelectedElements( newSelection );
                            }
                            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 );
                                }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

            {
                // 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 );
                }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

        {
            property().write( value, true );
        }
        catch( Exception e )
        {
            final EditFailedException editFailedException = EditFailedException.findAsCause( e );
           
            if( editFailedException != null )
            {
                update();
            }
View Full Code Here

Examples of org.eclipse.sapphire.modeling.EditFailedException

                            {
                                // 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 );
                                }
                            }
                            finally
                            {
                                suspension.dispose();
                                outline.listeners().queue().process();
                            }
                           
                            parentNode.getContentTree().setSelectedNode( selectionPostDelete );
                        }
                    }
                   
                    dragElements.clear();
                }
            }
        );
       
        final DropTarget target = new DropTarget( tree, DND.DROP_COPY | DND.DROP_MOVE );
        target.setTransfer( transfers );
       
        target.addDropListener
        (
            new DropTargetAdapter()
            {
                public void dragOver( final DropTargetEvent event )
                {
                    if( event.item != null )
                    {
                        final TreeItem dragOverItem = (TreeItem) event.item;
                        final MasterDetailsContentNodePart dragOverNode = (MasterDetailsContentNodePart) dragOverItem.getData();
                        final MasterDetailsContentNodePart parentNode = dragOverNode.getParentNode();
                        final List<MasterDetailsContentNodePart> siblingNodes = parentNode.nodes().visible();

                        final Point pt = dragOverItem.getDisplay().map( null, tree, event.x, event.y );
                        final Rectangle bounds = dragOverItem.getBounds();
                       
                        boolean dragOverNodeAcceptedDrop = false;
                       
                        if( pt.y > bounds.y + bounds.height / 3 && pt.y < bounds.y + bounds.height - bounds.height / 3 )
                        {
                            for( final PropertyDef dragOverTargetChildProperty : dragOverNode.getChildNodeFactoryProperties() )
                            {
                                if( dragOverTargetChildProperty instanceof ListProperty && ! dragOverTargetChildProperty.isReadOnly() )
                                {
                                    dragOverNodeAcceptedDrop = true;
                                    event.feedback = DND.FEEDBACK_SELECT;
                                   
                                    break;
                                }
                            }
                        }
                       
                        if( ! dragOverNodeAcceptedDrop )
                        {
                            MasterDetailsContentNodePart precedingNode = null;
                            MasterDetailsContentNodePart trailingNode = null;
   
                            if( pt.y < bounds.y + bounds.height / 2 )
                            {
                                precedingNode = findPrecedingItem( siblingNodes, dragOverNode );
                                trailingNode = dragOverNode;
                               
                                event.feedback = DND.FEEDBACK_INSERT_BEFORE;
                            }
                            else
                            {
                                precedingNode = dragOverNode;
                                trailingNode = findTrailingItem( siblingNodes, dragOverNode );
   
                                event.feedback = DND.FEEDBACK_INSERT_AFTER;
                            }
                           
                            boolean ok = false;
                           
                            if( precedingNode != null )
                            {
                                final Element precedingElement = precedingNode.getModelElement();
                               
                                if( precedingElement.parent() instanceof ElementList && precedingNode.controls( precedingElement ) )
                                {
                                    ok = true;
                                }
                            }
                           
                            if( ! ok && trailingNode != null )
                            {
                                final Element trailingElement = trailingNode.getModelElement();
                               
                                if( trailingElement.parent() instanceof ElementList && trailingNode.controls( trailingElement ) )
                                {
                                    ok = true;
                                }
                            }
                           
                            if( ! ok )
                            {
                                event.feedback = DND.FEEDBACK_NONE;
                            }
                        }
                    }
                   
                    event.feedback |= DND.FEEDBACK_SCROLL;
                }

                @SuppressWarnings( "unchecked" )
               
                public void drop( final DropTargetEvent event )
                {
                    if( event.data == null || event.item == null)
                    {
                        event.detail = DND.DROP_NONE;
                        return;
                    }
                   
                    // Determine where something was dropped.
                   
                    final List<ElementData> droppedElements = (List<ElementData>) event.data;
                    final TreeItem dropTargetItem = (TreeItem) event.item;
                    final MasterDetailsContentNodePart dropTargetNode = (MasterDetailsContentNodePart) dropTargetItem.getData();
                    final MasterDetailsContentNodePart parentNode = dropTargetNode.getParentNode();
                    final List<MasterDetailsContentNodePart> siblingNodes = parentNode.nodes().visible();
                   
                    final Point pt = tree.getDisplay().map( null, tree, event.x, event.y );
                    final Rectangle bounds = dropTargetItem.getBounds();
                   
                    MasterDetailsContentNodePart precedingNode = null;
                    MasterDetailsContentNodePart trailingNode = null;
                   
                    boolean dropTargetNodeAcceptedDrop = false;

                    if( pt.y > bounds.y + bounds.height / 3 && pt.y < bounds.y + bounds.height - bounds.height / 3 )
                    {
                        for( final PropertyDef dropTargetChildProperty : dropTargetNode.getChildNodeFactoryProperties() )
                        {
                            if( dropTargetChildProperty instanceof ListProperty && ! dropTargetChildProperty.isReadOnly() )
                            {
                                dropTargetNodeAcceptedDrop = true;
                                break;
                            }
                        }
                    }
                   
                    if( ! dropTargetNodeAcceptedDrop )
                    {
                        if( pt.y < bounds.y + bounds.height / 2 )
                        {
                            precedingNode = findPrecedingItem( siblingNodes, dropTargetNode );
                            trailingNode = dropTargetNode;
                        }
                        else
                        {
                            precedingNode = dropTargetNode;
                            trailingNode = findTrailingItem( siblingNodes, dropTargetNode );
                        }
                    }
                   
                    // Determine whether the drop was valid from model standpoint and figure out
                    // where in the model the dropped elements are to be inserted.
                   
                    ElementList<?> list = null;
                    int position = -1;
                   
                    if( precedingNode != null )
                    {
                        final Element precedingElement = precedingNode.getModelElement();
                       
                        if( precedingElement.parent() instanceof ElementList && ! precedingElement.parent().definition().isReadOnly() &&
                            precedingNode.controls( precedingElement ) )
                        {
                            list = (ElementList<?>) precedingElement.parent();
                           
                            final Set<ElementType> possibleListElementTypes = list.definition().service( PossibleTypesService.class ).types();
                           
                            for( final ElementData droppedElement : droppedElements )
                            {
                                if( ! possibleListElementTypes.contains( droppedElement.type() ) )
                                {
                                    list = null;
                                    break;
                                }
                            }
                           
                            if( list != null )
                            {
                                position = list.indexOf( precedingElement ) + 1;
                            }
                        }
                    }
                   
                    if( list == null && trailingNode != null )
                    {
                        final Element trailingElement = trailingNode.getModelElement();
                       
                        if( trailingElement.parent() instanceof ElementList && ! trailingElement.parent().definition().isReadOnly() &&
                            trailingNode.controls( trailingElement ) )
                        {
                            list = (ElementList<?>) trailingElement.parent();
                           
                            final Set<ElementType> possibleListElementTypes = list.definition().service( PossibleTypesService.class ).types();
                           
                            for( final ElementData droppedElement : droppedElements )
                            {
                                if( ! possibleListElementTypes.contains( droppedElement.type() ) )
                                {
                                    list = null;
                                    break;
                                }
                            }
                           
                            if( list != null )
                            {
                                position = list.indexOf( trailingElement );
                            }
                        }
                    }
                   
                    if( list == null )
                    {
                        for( PropertyDef dropTargetChildProperty : dropTargetNode.getChildNodeFactoryProperties() )
                        {
                            if( dropTargetChildProperty instanceof ListProperty && ! dropTargetChildProperty.isReadOnly() )
                            {
                                final ListProperty dropTargetChildListProperty = (ListProperty) dropTargetChildProperty;
                               
                                boolean compatible = true;
                               
                                final Set<ElementType> possibleListElementTypes = dropTargetChildListProperty.service( PossibleTypesService.class ).types();
                               
                                for( final ElementData droppedElement : droppedElements )
                                {
                                    if( ! possibleListElementTypes.contains( droppedElement.type() ) )
                                    {
                                        compatible = false;
                                        break;
                                    }
                                }
                               
                                if( compatible )
                                {
                                    list = dropTargetNode.getLocalModelElement().property( dropTargetChildListProperty );
                                    position = list.size();
                                }
                            }
                        }
                    }
                   
                    if( list == null )
                    {
                        event.detail = DND.DROP_NONE;
                        return;
                    }
                   
                    // Prevent a drop within a drag element.
                   
                    for( Property p = list; p != null; p = p.element().parent() )
                    {
                        for( final Element dragElement : dragElements )
                        {
                            if( p.element() == dragElement )
                            {
                                event.detail = DND.DROP_NONE;
                                return;
                            }
                        }
                    }
                   
                    // Perform the removal and insertion into the new location.
                   
                    final Disposable suspension = outline.listeners().queue().suspend( SelectionChangedEventFilter.INSTANCE );
                   
                    try
                    {
                        if( event.detail == DND.DROP_MOVE )
                        {
                            for( Element dragElement : dragElements )
                            {
                                final ElementList<?> dragElementContainer = (ElementList<?>) dragElement.parent();
                               
                                if( dragElementContainer == list && dragElementContainer.indexOf( dragElement ) < position )
                                {
                                    position--;
                                }
                               
                                dragElementContainer.remove( dragElement );
                            }
                        }
   
                        final List<MasterDetailsContentNodePart> newSelection = new ArrayList<MasterDetailsContentNodePart>();
                       
                        for( final ElementData droppedElement : droppedElements )
                        {
                            final Element insertedElement = list.insert( droppedElement.type(), position );
                            insertedElement.copy( droppedElement );
                           
                            newSelection.add( parentNode.findNode( insertedElement ) );
                           
                            position++;
                        }
                       
                        parentNode.getContentTree().setSelectedNodes( newSelection );
                    }
                    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 );
                        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.