public void widgetSelected( SelectionEvent e )
{
InterceptorDialog dialog = new InterceptorDialog( interceptors );
if ( Dialog.OK == dialog.open() )
{
InterceptorEnum newInterceptor = dialog.getInterceptor();
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() )
{
InterceptorEnum interceptor = ( InterceptorEnum ) 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() )
{
InterceptorEnum interceptor = ( InterceptorEnum ) selection.getFirstElement();
int index = interceptors.indexOf( interceptor );
if ( index > 0 )
{
InterceptorEnum 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() )
{
InterceptorEnum interceptor = ( InterceptorEnum ) selection.getFirstElement();
int index = interceptors.indexOf( interceptor );
if ( index < ( interceptors.size() - 1 ) )
{
InterceptorEnum interceptorAfter = interceptors.get( index + 1 );
if ( interceptorAfter != null )
{
interceptors.set( index + 1, interceptor );
interceptors.set( index, interceptorAfter );