addButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
Interceptor newInterceptor = new Interceptor( getNewName() );
interceptors.add( newInterceptor );
viewer.refresh();
viewer.setSelection( new StructuredSelection( newInterceptor ) );
setEditorDirty();
}
} );
deleteButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
interceptors.remove( interceptor );
viewer.refresh();
setEditorDirty();
}
}
} );
upButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
int index = interceptors.indexOf( interceptor );
if ( index > 0 )
{
Interceptor interceptorBefore = interceptors.get( index - 1 );
if ( interceptorBefore != null )
{
interceptors.set( index - 1, interceptor );
interceptors.set( index, interceptorBefore );
viewer.refresh();
setEditorDirty();
enableDisableUpDownButtons();
}
}
}
}
} );
downButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
int index = interceptors.indexOf( interceptor );
if ( index < ( interceptors.size() - 1 ) )
{
Interceptor interceptorAfter = interceptors.get( index + 1 );
if ( interceptorAfter != null )
{
interceptors.set( index + 1, interceptor );
interceptors.set( index, interceptorAfter );