Skip to content

Commit

Permalink
Fixed the custom color NullPointException bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
cchao committed Jun 4, 2012
1 parent 62f5a6b commit 99f61ef
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.birt.report.model.api.metadata.IElementDefn;
import org.eclipse.birt.report.model.api.metadata.MetaDataConstants;
import org.eclipse.birt.report.model.api.util.ColorUtil;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
Expand Down Expand Up @@ -1347,7 +1346,7 @@ public RGB[] getCustomColorsPreference( )
.getPreferences( this, UIUtil.getCurrentProject( ) )
.getString( CUSTOM_COLORS_PREFERENCE );
List<RGB> rgbList = new ArrayList<RGB>( );
if ( rgbs != null )
if ( rgbs != null && rgbs.trim( ).length( ) > 0 )
{
String[] splits = rgbs.split( ";" );
for ( int i = 0; i < splits.length; i++ )
Expand Down Expand Up @@ -1379,22 +1378,27 @@ public void setCustomColorsPreference( RGB[] rgbs )
}
}

PreferenceFactory.getInstance( )
String newColorStatus = buffer.toString( );
String oldColorStatus = PreferenceFactory.getInstance( )
.getPreferences( this, UIUtil.getCurrentProject( ) )
.setValue( CUSTOM_COLORS_PREFERENCE,
buffer.toString( ).length( ) > 0 ? buffer.toString( )
: null );
try
.getString( CUSTOM_COLORS_PREFERENCE );

if ( !newColorStatus.equalsIgnoreCase( oldColorStatus ) )
{
PreferenceFactory.getInstance( )
.getPreferences( this, UIUtil.getCurrentProject( ) )
.save( );
}
catch ( IOException e )
{
ExceptionHandler.handle( e );
.setValue( CUSTOM_COLORS_PREFERENCE, newColorStatus );
try
{
PreferenceFactory.getInstance( )
.getPreferences( this, UIUtil.getCurrentProject( ) )
.save( );
}
catch ( IOException e )
{
ExceptionHandler.handle( e );
}
}

}

/**
Expand Down

0 comments on commit 99f61ef

Please sign in to comment.