try { FileDialog dialog; if ( getSelection( ) instanceof ReportDesignHandle ) { dialog = new FileDialog( UIUtil.getDefaultShell( ), SWT.SAVE ); } else { dialog = new FileDialog( UIUtil.getDefaultShell( ), SWT.OPEN ); } dialog.setFilterExtensions( new String[]{"*.rptlibrary" } ); String filename = dialog.open( ); if ( filename == null ) { return; } pref = ReportPlugin.getDefault( ).getPreferenceStore( ).getInt( PREF_KEY ); if ( !filename.endsWith( ".rptlibrary" ) ) { filename += ".rptlibrary"; } if ( filename != null ) {
	public void run( )	{		try		{			FileDialog dialog;			if ( getSelection( ) instanceof ReportDesignHandle )			{				dialog = new FileDialog( UIUtil.getDefaultShell( ), SWT.SAVE );			}			else			{				dialog = new FileDialog( UIUtil.getDefaultShell( ), SWT.OPEN );			}			dialog.setFilterExtensions( new String[]{"*.rptlibrary" //$NON-NLS-1$					} );			String filename = dialog.open( );			if ( filename == null )			{				return;			}			pref = ReportPlugin.getDefault( ).getPreferenceStore( ).getInt(					PREF_KEY );			if ( !filename.endsWith( ".rptlibrary" ) ) //$NON-NLS-1$			{				filename += ".rptlibrary"; //$NON-NLS-1$			}			if ( filename != null )			{				if ( pref == PREF_PROMPT && new File(filename).exists())				{					MessageDialog prefDialog = new MessageDialog( dialog							.getParent( ), DIALOG_TITLE, null, DIALOG_MESSAGE,							MessageDialog.INFORMATION, new String[]{BUTTON_YES,									BUTTON_NO, BUTTON_CANCEL}, 0 )					{						/*						 * (non-Javadoc)						 * 						 * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)						 */						protected Control createCustomArea( Composite parent )						{							Composite container = new Composite( parent,									SWT.NONE );							GridLayout gridLayout = new GridLayout( );							gridLayout.marginWidth = 20;							// gridLayout.marginTop = 15;							container.setLayout( gridLayout );							Button chkbox = new Button( container, SWT.CHECK );							chkbox.setText( REMEMBER_DECISION );							chkbox									.addSelectionListener( new SelectionListener( ) {										public void widgetSelected(												SelectionEvent e )										{											saveDecision = !saveDecision;										}										public void widgetDefaultSelected(												SelectionEvent e )										{											saveDecision = false;										}									} );							return super.createCustomArea( parent );						}						/*						 * (non-Javadoc)						 * 						 * @see org.eclipse.jface.dialogs.MessageDialog#buttonPressed(int)						 */						protected void buttonPressed( int buttonId )						{							switch ( buttonId )							{								case 0 :									pref = PREF_OVERWRITE;									break;								case 1 :									pref = PREF_NOT_OVERWRITE;									break;								default :									break;							}							if ( saveDecision )							{								ReportPlugin.getDefault( ).getPreferenceStore( )										.setValue( PREF_KEY, pref );							}							super.buttonPressed( buttonId );						}					};					if ( prefDialog.open( ) == 2 )						return;				}				if ( getSelection( ) instanceof ReportDesignHandle )				{					ElementExportUtil.exportDesign(							(ReportDesignHandle) getSelection( ), filename, pref == PREF_OVERWRITE, true );				}				else				{					ElementExportUtil.exportElement(							(DesignElementHandle) getSelection( ),							filename, pref == PREF_OVERWRITE );				}			}		}		catch ( Exception e )		{			ExceptionHandler.handle( e );		}	}