summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-11-29 23:49:42 (EST)
committer mwu2011-11-29 23:49:42 (EST)
commit9928c9ff82a37f527a3e5ed9a2e9ab5795ba4fdd (patch)
tree93351e712f397f1d87faef4192d8264ee18b3e9b
parente73914279187283534258bab5c30a37c433f4b0b (diff)
downloadorg.eclipse.birt-9928c9ff82a37f527a3e5ed9a2e9ab5795ba4fdd.zip
org.eclipse.birt-9928c9ff82a37f527a3e5ed9a2e9ab5795ba4fdd.tar.gz
org.eclipse.birt-9928c9ff82a37f527a3e5ed9a2e9ab5795ba4fdd.tar.bz2
Checkin: Support to show tooltip which is formatted according to the
login locale
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java32
-rw-r--r--data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java10
2 files changed, 24 insertions, 18 deletions
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
index 59951ff..bfd492a 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
@@ -15,6 +15,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.format.DateFormatter;
import org.eclipse.birt.data.engine.api.IBinding;
@@ -573,13 +574,13 @@ public class TimeFunctionManager
{
desc = constructTimeFunctionToolTip( list.get( list.size( ) - 1 ),
list.get( 0 ),
- getCalculationType( column.getCalculationType( ), locale ).getDisplayName( ) );
+ getCalculationType( column.getCalculationType( ), locale ).getDisplayName( ), locale );
}
else
{
desc = constructTimeFunctionToolTip( list.get( 0 ),
list.get( list.size( ) - 1 ),
- getCalculationType( column.getCalculationType( ), locale ).getDisplayName( ) );
+ getCalculationType( column.getCalculationType( ), locale ).getDisplayName( ), locale );
}
@@ -587,27 +588,32 @@ public class TimeFunctionManager
}
private static String constructTimeFunctionToolTip( TimeMember from,
- TimeMember to, String funcName )
+ TimeMember to, String funcName, ULocale locale ) throws BirtException
{
StringBuffer result = new StringBuffer( "" );
result.append( funcName ).append( " ( " );
- result.append( from.getMemberValue( )[0] )
- .append( "-" )
- .append( from.getMemberValue( )[1] )
- .append( "-" )
- .append( from.getMemberValue( )[2] );
+ result.append( getFormattedDateStringFromTimeMember( from, locale ) );
result.append( " " )
.append( Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_TO ) )
.append( " " );
- result.append( to.getMemberValue( )[0] )
- .append( "-" )
- .append( to.getMemberValue( )[1] )
- .append( "-" )
- .append( to.getMemberValue( )[2] );
+ result.append( getFormattedDateStringFromTimeMember( to, locale ) );
result.append( " )" );
return result.toString( );
}
+ private static String getFormattedDateStringFromTimeMember( TimeMember member, ULocale locale ) throws BirtException
+ {
+ Calendar calendar = Calendar.getInstance( locale );
+ calendar.clear( );
+ calendar.set( Calendar.YEAR, member.getMemberValue( )[0] );
+ calendar.set( Calendar.MONTH, member.getMemberValue( )[1]-1 );
+ calendar.set( Calendar.DAY_OF_MONTH, member.getMemberValue( )[2] );
+ java.sql.Date date = (java.sql.Date) DataTypeUtil.toSqlDate( calendar.getTime( ) );
+ DateFormatter formatter = new DateFormatter(locale);
+
+ return formatter.format( date );
+ }
+
private static String toLevelType( TimePeriodType timePeriodType )
{
if( timePeriodType == TimePeriodType.YEAR )
diff --git a/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java b/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
index 00131de..64c7533 100644
--- a/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
+++ b/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
@@ -350,7 +350,7 @@ public class TimeFunctionManagerTest extends TestCase
.setExpression( new Expression( "\"2003-08-17\"", null ) );
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
- String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.getDefault( ) );
+ String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.CHINA );
assertTrue(desc.equals( "Quarter to Date ( 2003-7-1 To 2003-8-17 )" ) );
}
@@ -368,8 +368,8 @@ public class TimeFunctionManagerTest extends TestCase
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
- String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.getDefault( ) );
- assertTrue(desc.equals( "previous Year to Date ( 2002-1-1 To 2002-8-17 )" ) );
+ String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.CHINA );
+ assertTrue(desc.equals( "Previous Year to Date ( 2002-1-1 To 2002-8-17 )" ) );
}
public void testGettingToolTipForTimeFunction3() throws BirtException
@@ -386,7 +386,7 @@ public class TimeFunctionManagerTest extends TestCase
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
- String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.getDefault( ) );
+ String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.CHINA );
assertTrue(desc.equals( "Trailing 12 Months ( 2002-8-18 To 2003-8-17 )" ) );
}
@@ -402,7 +402,7 @@ public class TimeFunctionManagerTest extends TestCase
.setExpression( new Expression( "\"2003-08-17\"", null ) );
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
- String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.getDefault( ) );
+ String desc = TimeFunctionManager.getTooltipForTimeFunction( computedHandle, ULocale.CHINA );
assertTrue(desc.equals( "Current Year ( 2003-1-1 To 2003-12-31 )" ) );
}
}