Skip to content

Commit

Permalink
Border display is not accurate(54233)
Browse files Browse the repository at this point in the history
Remove the hardcode default color, now get the default color from model.
  • Loading branch information
ning.zhang authored and cchao committed Oct 25, 2012
1 parent b47bb5a commit ce699aa
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;

public abstract class BorderDescriptorProvider extends AbstractDescriptorProvider
public abstract class BorderDescriptorProvider extends
AbstractDescriptorProvider
{

protected Object input;
Expand Down Expand Up @@ -51,7 +52,26 @@ protected String getLocalStringValue( String property )
return value;
}


protected String getDefaultStringValue( String property )
{
GroupElementHandle handle = null;
if ( input instanceof List )
handle = DEUtil.getGroupElementHandle( (List) input );
if ( handle == null )
return ""; //$NON-NLS-1$
if ( getLocalStringValue( property ).equals( "" ) )
{
String value = handle.getStringProperty( property );
if ( value == null )
// && multiSelectionHandle.shareSameValue( property ) )
{
value = ""; //$NON-NLS-1$
}
return value;
}
else
return ""; //$NON-NLS-1$
}

protected void save( String property, Object value )
throws SemanticException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,31 @@ public Object load( )
info.setStyle( getLocalStringValue( StyleHandle.BORDER_LEFT_STYLE_PROP ) );
info.setWidth( getLocalStringValue( StyleHandle.BORDER_LEFT_WIDTH_PROP ) );
info.setColor( convertToRGB( getLocalStringValue( StyleHandle.BORDER_LEFT_COLOR_PROP ) ) );
info.setDefaultColor( convertToRGB( getDefaultStringValue( StyleHandle.BORDER_LEFT_COLOR_PROP ) ) );
}
else if ( property.equals( StyleHandle.BORDER_RIGHT_STYLE_PROP ) )
{
info.setPosition( BorderInfomation.BORDER_RIGHT );
info.setStyle( getLocalStringValue( StyleHandle.BORDER_RIGHT_STYLE_PROP ) );
info.setWidth( getLocalStringValue( StyleHandle.BORDER_RIGHT_WIDTH_PROP ) );
info.setColor( convertToRGB( getLocalStringValue( StyleHandle.BORDER_RIGHT_COLOR_PROP ) ) );
info.setDefaultColor( convertToRGB( getDefaultStringValue( StyleHandle.BORDER_RIGHT_COLOR_PROP ) ) );
}
else if ( property.equals( StyleHandle.BORDER_TOP_STYLE_PROP ) )
{
info.setPosition( BorderInfomation.BORDER_TOP );
info.setStyle( getLocalStringValue( StyleHandle.BORDER_TOP_STYLE_PROP ) );
info.setWidth( getLocalStringValue( StyleHandle.BORDER_TOP_WIDTH_PROP ) );
info.setColor( convertToRGB( getLocalStringValue( StyleHandle.BORDER_TOP_COLOR_PROP ) ) );
info.setDefaultColor( convertToRGB( getDefaultStringValue( StyleHandle.BORDER_TOP_COLOR_PROP ) ) );
}
else if ( property.equals( StyleHandle.BORDER_BOTTOM_STYLE_PROP ) )
{
info.setPosition( BorderInfomation.BORDER_BOTTOM );
info.setStyle( getLocalStringValue( StyleHandle.BORDER_BOTTOM_STYLE_PROP ) );
info.setWidth( getLocalStringValue( StyleHandle.BORDER_BOTTOM_WIDTH_PROP ) );
info.setColor( convertToRGB( getLocalStringValue( StyleHandle.BORDER_BOTTOM_COLOR_PROP ) ) );
info.setDefaultColor( convertToRGB( getDefaultStringValue( StyleHandle.BORDER_BOTTOM_COLOR_PROP ) ) );
}
return info;
}
Expand Down Expand Up @@ -195,10 +199,8 @@ else if ( getPosition( ).equals( BorderInfomation.BORDER_RIGHT ) )

}


public String getProperty( )
{
return property;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class BorderPropertyDescriptor implements

private BorderInfomation restoreInfo;

private static final RGB autoColor = DEUtil.getRGBValue( ColorUtil.parsePredefinedColor( "black" ) ); //$NON-NLS-1$

public BorderPropertyDescriptor( boolean isFormStyle )
{
this.isFormStyle = isFormStyle;
Expand Down Expand Up @@ -108,7 +106,7 @@ public Control createControl( Composite parent )

builder = new ColorBuilder( choices, SWT.NONE, isFormStyle );
builder.setChoiceSet( colorProvider.getElementChoiceSet( ) );
colorProvider.setIndex( IColorConstants.BLACK );
// colorProvider.setIndex( IColorConstants.BLACK );
data = new GridData( );
data.widthHint = 200;
data.heightHint = builder.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
Expand Down Expand Up @@ -190,10 +188,10 @@ public void widgetSelected( SelectionEvent e )
.getCommandStack( );
stack.startTrans( Messages.getString( "BordersPage.Trans.SelectAllborders" ) ); //$NON-NLS-1$
selectedColor = builder.getRGB( );
if ( selectedColor == null )
{
selectedColor = autoColor;
}
// if ( selectedColor == null )
// {
// selectedColor = autoColor;
// }
for ( int i = 0; i < toggleProviders.length; i++ )
{
BorderInfomation information = new BorderInfomation( );
Expand Down Expand Up @@ -226,16 +224,16 @@ public void widgetSelected( SelectionEvent e )
BorderInfomation info = (BorderInfomation) toggleProviders[i].load( );
oldColor = info.getColor( );
selectedColor = builder.getRGB( );
if ( oldColor == null )
{
oldColor = autoColor;
}
if ( selectedColor == null )
{
selectedColor = autoColor;
}
// if ( oldColor == null )
// {
// oldColor = autoColor;
// }
// if ( selectedColor == null )
// {
// selectedColor = autoColor;
// }
if ( !( info.getStyle( ).equals( (String) styleProvider.getItems( )[styleCombo.getSelectionIndex( )] ) )
|| !( oldColor.equals( selectedColor ) )
|| !( ( oldColor == null && selectedColor == null ) || ( oldColor != null && oldColor.equals( selectedColor ) ) )
|| !( resolveEmptyWidth( info ).equals( (String) widthProvider.getItems( )[widthCombo.getSelectionIndex( )] ) ) )
{
reset = false;
Expand Down Expand Up @@ -272,16 +270,8 @@ public void widgetSelected( SelectionEvent e )
for ( int i = 0; i < toggleProviders.length; i++ )
{
BorderInfomation information = new BorderInfomation( );

information.setPosition( toggleProviders[i].getPosition( ) );
if ( builder.getRGB( ) == null )
{
information.setColor( autoColor );
}
else
{
information.setColor( builder.getRGB( ) );
}
information.setColor( builder.getRGB( ) );
information.setStyle( (String) styleProvider.getItems( )[styleCombo.getSelectionIndex( )] );
information.setWidth( (String) widthProvider.getItems( )[widthCombo.getSelectionIndex( )] );
previewCanvas.setBorderInfomation( information );
Expand Down Expand Up @@ -596,16 +586,16 @@ private void handleBorderDeselection(
BorderInfomation oldInfo = (BorderInfomation) provider.load( );
RGB oldColor = oldInfo.getColor( );
RGB selectedColor = builder.getRGB( );
if ( oldColor == null )
{
oldColor = autoColor;
}
if ( selectedColor == null )
{
selectedColor = autoColor;
}
// if ( oldColor == null )
// {
// oldColor = autoColor;
// }
// if ( selectedColor == null )
// {
// selectedColor = autoColor;
// }
if ( !( oldInfo.getStyle( ).equals( (String) styleProvider.getItems( )[styleCombo.getSelectionIndex( )] ) )
|| !( oldColor.equals( selectedColor ) )
|| !( ( oldColor == null && selectedColor == null ) || ( oldColor != null && oldColor.equals( selectedColor ) ) )
|| !( resolveEmptyWidth( oldInfo ).equals( (String) widthProvider.getItems( )[widthCombo.getSelectionIndex( )] ) ) )
{
CommandStack stack = SessionHandleAdapter.getInstance( )
Expand Down Expand Up @@ -719,8 +709,8 @@ public void reset( )

private String resolveEmptyWidth( BorderInfomation info )
{
String width = info.getWidth( );
if("".equals( width ))
String width = info.getWidth( );
if ( "".equals( width ) )
return DesignChoiceConstants.LINE_WIDTH_MEDIUM;
return width;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,16 @@ protected void paintControl( PaintEvent e )
continue;

if ( info.getColor( ) == null )
gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_BLACK ) );
{
if ( info.getDefaultColor( ) != null )
{
gc.setForeground( ColorManager.getColor( info.getDefaultColor( ) ) );
}
else
{
gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_BLACK ) );
}
}
else
gc.setForeground( ColorManager.getColor( info.getColor( ) ) );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,69 @@

package org.eclipse.birt.report.designer.internal.ui.swt.custom;

import org.eclipse.swt.graphics.RGB;


public class BorderInfomation
{

public static final String BORDER_LEFT = "left"; //$NON-NLS-1$
public static final String BORDER_TOP = "top"; //$NON-NLS-1$
public static final String BORDER_RIGHT = "right"; //$NON-NLS-1$
public static final String BORDER_BOTTOM= "bottom"; //$NON-NLS-1$


public static final String BORDER_BOTTOM = "bottom"; //$NON-NLS-1$

String position;
String style;
RGB color;
String width;

RGB defaultColor;

public RGB getDefaultColor( )
{
return defaultColor;
}

public String getPosition( )
{
return position;
}

public void setPosition( String position )
{
this.position = position;
}

public String getStyle( )
{
return style;
}

public void setStyle( String style )
{
this.style = style;
}

public RGB getColor( )
{
return color;
}

public void setColor( RGB color )
{
this.color = color;
}

public String getWidth( )
{
return width;
}

public void setWidth( String width )
{
this.width = width;
}

public void setDefaultColor( RGB defaultColor )
{
this.defaultColor = defaultColor;
}
}

0 comments on commit ce699aa

Please sign in to comment.