Skip to content

Commit

Permalink
NPE when delete datadesign and report while the datadesign is edited and
Browse files Browse the repository at this point in the history
not saved.[T60260]

Record the file close status, if it has been closed and set the close
status, then do nothing.
  • Loading branch information
cchao committed May 13, 2013
1 parent 4ddbd51 commit ae60cc9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
Expand Up @@ -199,7 +199,7 @@ public void windowOpened( IWorkbenchWindow window )

};

private void confirmSave( )
protected void confirmSave( )
{

if ( fIsHandlingActivation )
Expand Down
Expand Up @@ -11,6 +11,7 @@

package org.eclipse.birt.report.designer.ui.editors;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -52,7 +53,8 @@
public class IDEMultiPageReportEditor extends MultiPageReportEditor
{

private static final String ProblemMarkID = "org.eclipse.birt.report.designer.ui.ide" + ".birtproblemmarker";
private static final String ProblemMarkID = "org.eclipse.birt.report.designer.ui.ide"
+ ".birtproblemmarker";
protected static final Logger logger = Logger.getLogger( IDEMultiPageReportEditor.class.getName( ) );

/**
Expand Down Expand Up @@ -100,7 +102,7 @@ public void resourceChanged( IResourceChangeEvent event )
/**
* is visit successful
*/
public boolean visit( IResourceDelta delta )
public boolean visit( final IResourceDelta delta )
{
if ( delta == null
|| !delta.getResource( )
Expand Down Expand Up @@ -132,17 +134,28 @@ public void run( )
DLG_SAVE_BUTTON_SAVE,
DLG_SAVE_BUTTON_CLOSE
};

final IResource file = delta.getResource( );

if ( closedStatus.contains( file ) )
{
return;
}

MessageDialog dialog = new MessageDialog( getSite( ).getShell( ),
title,
null,
message,
MessageDialog.QUESTION,
buttons,
0 );

closedStatus.add( file );

if ( dialog.open( ) == Dialog.OK )
{
doSaveAs( );
if (!isExistModelFile( ))
if ( !isExistModelFile( ) )
{
closeEditor( false );
}
Expand All @@ -151,6 +164,15 @@ public void run( )
{
closeEditor( false );
}

Display.getDefault( )
.asyncExec( new Runnable( ) {

public void run( )
{
closedStatus.remove( file );
}
} );
}
}
} );
Expand Down Expand Up @@ -238,7 +260,7 @@ private void setAllInput( FileEditorInput input )
( (IReportEditorPage) page ).setInput( input );
}
}
updateRelatedViews();
updateRelatedViews( );
}
}

Expand Down Expand Up @@ -284,6 +306,8 @@ private IFile getFile( IEditorInput editorInput )
* @seeorg.eclipse.birt.report.designer.ui.editors.MultiPageReportEditor#
* partActivated(org.eclipse.ui.IWorkbenchPart)
*/
private static List<IResource> closedStatus = new ArrayList<IResource>( );

public void partActivated( IWorkbenchPart part )
{
super.partActivated( part );
Expand All @@ -292,7 +316,8 @@ public void partActivated( IWorkbenchPart part )
return;
if ( isWorkspaceResource )
{
if ( !( (IFileEditorInput) getEditorInput( ) ).getFile( ).exists( ) )
final IFile file = ( (IFileEditorInput) getEditorInput( ) ).getFile( );
if ( !file.exists( ) )
{

Shell shell = getSite( ).getShell( );
Expand All @@ -305,6 +330,11 @@ public void partActivated( IWorkbenchPart part )
DLG_SAVE_BUTTON_SAVE, DLG_SAVE_BUTTON_CLOSE
};

if ( closedStatus.contains( file ) )
{
return;
}

MessageDialog dialog = new MessageDialog( shell,
title,
null,
Expand All @@ -313,17 +343,26 @@ public void partActivated( IWorkbenchPart part )
buttons,
0 );

if ( dialog.open( ) == 0 )
closedStatus.add( file );

int result = dialog.open( );

if ( result == 0 )
{
doSaveAs( );
partActivated( part );
}

else
{
closeEditor( false );
}
Display.getDefault( ).asyncExec( new Runnable( ) {

public void run( )
{
closedStatus.remove( file );
}
} );
}
}
}
Expand Down Expand Up @@ -546,4 +585,17 @@ protected boolean prePageChanges( Object oldPage, Object newPage )
return isNewPageValid;
}

protected void confirmSave( )
{
final IFile file = ( (IFileEditorInput) getEditorInput( ) ).getFile( );
if ( !file.exists( ) )
{
if ( closedStatus.contains( file ) )
{
return;
}
}
super.confirmSave( );
}

}
Expand Up @@ -415,6 +415,9 @@ public void partActivated( IWorkbenchPart part )
*/
public void partBroughtToTop( IWorkbenchPart part )
{
if ( instance == null )
return;

if ( part instanceof ReportEditorProxy )
{
instance.partBroughtToTop( ( (ReportEditorProxy) part ).getEditorPart( ) );
Expand All @@ -423,7 +426,7 @@ public void partBroughtToTop( IWorkbenchPart part )
{
instance.partBroughtToTop( part );
}
partActivated(part);
partActivated( part );
}

/*
Expand Down

0 comments on commit ae60cc9

Please sign in to comment.