Java Code Examples for org.eclipse.ui.forms.editor.FormEditor#doSave()

The following examples show how to use org.eclipse.ui.forms.editor.FormEditor#doSave() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreviewSupport.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void preview( String format, boolean allowPage )
{
	if ( !prePreview( ) )
	{
		return;
	}

	FormEditor editor = UIUtil.getActiveReportEditor( false );
	ModuleHandle model = null;

	if ( editor instanceof MultiPageReportEditor )
	{
		model = ( (MultiPageReportEditor) editor ).getModel( );
	}

	if ( !UIUtil.canPreviewWithErrors( model ) )
		return;

	if ( editor != null )
	{
		IFormPage activePageInstance=editor.getActivePageInstance();
		if ( model.needsSave( ) ||(activePageInstance!=null && activePageInstance.isDirty()))//Do save when current active page is dirty.
		{
			editor.doSave( null );
		}
	}
	Map<String, Object> options = new HashMap<String, Object>( );
	options.put( WebViewer.FORMAT_KEY, format );
	options.put( WebViewer.ALLOW_PAGE_KEY, Boolean.valueOf( allowPage ) );
	options.put( WebViewer.RESOURCE_FOLDER_KEY, ReportPlugin.getDefault( )
			.getResourceFolder( ) );
	if (hasParameters(model)) {
		options.put(WebViewer.SHOW_PARAMETER_PAGE_KEY, "true");
	}
	WebViewer.display( model.getFileName( ), options );
}
 
Example 2
Source File: PreviewSupport.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void preview( EmitterInfo ei, IEmitterDescriptor descriptor )
{
	if ( !prePreview( ) )
	{
		return;
	}

	FormEditor editor = UIUtil.getActiveReportEditor( false );
	ModuleHandle model = null;

	if ( editor instanceof MultiPageReportEditor )
	{
		model = ( (MultiPageReportEditor) editor ).getModel( );
	}

	if ( !UIUtil.canPreviewWithErrors( model ) )
		return;

	if ( editor != null )
	{
		if ( model.needsSave( ) )
		{
			editor.doSave( null );
		}
	}

	Map<String, Object> options = new HashMap<String, Object>( );
	options.put( WebViewer.EMITTER_ID_KEY, ei.getID( ) );
	options.put( WebViewer.FORMAT_KEY, ei.getFormat( ) );
	options.put( WebViewer.ALLOW_PAGE_KEY, Boolean.valueOf( false ) );
	options.put( WebViewer.RESOURCE_FOLDER_KEY, ReportPlugin.getDefault( )
			.getResourceFolder( ) );

	WebViewer.display( model.getFileName( ), options );
}
 
Example 3
Source File: GenerateDocumentToolbarMenuAction.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void gendoc( IAction action )
{
	// cleanup system settings
	PreviewUtil.clearSystemProperties();

	FormEditor editor = UIUtil.getActiveReportEditor( false );
	ModuleHandle model = null;
	if (model == null )
	{
		if (editor instanceof MultiPageReportEditor)
		{
			model = ((MultiPageReportEditor)editor).getModel( );
		}
	}
	if (model == null)
	{
		return;
	}
	if ( editor != null )
	{
		if ( model.needsSave( ) )
		{
			editor.doSave( null );
		}
	}

	Map options = new HashMap( );
	options.put( WebViewer.RESOURCE_FOLDER_KEY, ReportPlugin.getDefault( )
			.getResourceFolder( ) );
	options.put( WebViewer.SERVLET_NAME_KEY, WebViewer.VIEWER_DOCUMENT );

	Object adapter = ElementAdapterManager.getAdapter( action,
			IPreviewAction.class );

	if ( adapter instanceof IPreviewAction )
	{
		IPreviewAction delegate = (IPreviewAction) adapter;

		delegate.setProperty( IPreviewConstants.REPORT_PREVIEW_OPTIONS,
				options );
		delegate.setProperty( IPreviewConstants.REPORT_FILE_PATH,
				model.getFileName( ) );

		delegate.run( );

		return;
	}

	WebViewer.display( model.getFileName( ), options );
}