summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-11-28 02:32:21 (EST)
committer mwu2011-11-28 02:32:21 (EST)
commit8db3a9e60f8af8fd8d3f4a903bcd31b2b165a4f7 (patch)
tree719fe9cb3cb6f446f704508ceeea13991711d9bf
parentba0b85774a2e613ca31829d3545cd1278e7bec89 (diff)
downloadorg.eclipse.birt-8db3a9e60f8af8fd8d3f4a903bcd31b2b165a4f7.zip
org.eclipse.birt-8db3a9e60f8af8fd8d3f4a903bcd31b2b165a4f7.tar.gz
org.eclipse.birt-8db3a9e60f8af8fd8d3f4a903bcd31b2b165a4f7.tar.bz2
Checkin: format the output of tooltip for TimeFunction as "FUNC NAME (
YYYY-MM-DD To YYYY-MM-DD )"
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java70
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties8
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java8
-rw-r--r--data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java8
4 files changed, 30 insertions, 64 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 5d89a81..b73bb89 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
@@ -16,6 +16,7 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.birt.core.exception.BirtException;
+import org.eclipse.birt.core.format.DateFormatter;
import org.eclipse.birt.data.engine.api.IBinding;
import org.eclipse.birt.data.engine.api.timefunction.IParallelPeriod;
import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
@@ -526,16 +527,19 @@ public class TimeFunctionManager
Date date = functionBinding.getTimeFunction( ).getReferenceDate( ).getDate( );
Calendar cal = Calendar.getInstance( locale );
cal.setTime( date );
- int levelCount = dim.getDefaultHierarchy( ).getLevelCount( );
- int[] values = new int[levelCount];
- String[] levelTypes = new String[levelCount];
+ // int levelCount = dim.getDefaultHierarchy( ).getLevelCount( );
+ int[] values = new int[3];
+ String[] levelTypes = new String[3];
+ levelTypes[0] = TimeMember.TIME_LEVEL_TYPE_YEAR;
+ levelTypes[1] = TimeMember.TIME_LEVEL_TYPE_MONTH;
+ levelTypes[2] = TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH;
- for ( int i = 0; i < levelCount; i++ )
- {
- levelTypes[i] = dim.getDefaultHierarchy( )
- .getLevel( i )
- .getDateTimeLevelType( );
- }
+// for ( int i = 0; i < levelCount; i++ )
+// {
+// levelTypes[i] = dim.getDefaultHierarchy( )
+// .getLevel( i )
+// .getDateTimeLevelType( );
+// }
values = getValueFromCal( cal, levelTypes );
TimeMember member = new TimeMember( values, levelTypes );
IPeriodsFunction periodsFunction = null;
@@ -590,45 +594,23 @@ public class TimeFunctionManager
{
StringBuffer result = new StringBuffer( "" );
result.append( funcName ).append( " ( " );
- for ( int i = 0; i < from.getLevelType( ).length; i++ )
- {
- result.append( getLocalizedDisplayTimeUnitName( from.getLevelType( )[i] ) );
- result.append( from.getMemberValue( )[i] ).append( " " );
- }
- result.append( Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_TO ) ).append( " " );
-
- for ( int i = 0; i < to.getLevelType( ).length; i++ )
- {
- result.append( getLocalizedDisplayTimeUnitName( to.getLevelType( )[i] ) );
- result.append( to.getMemberValue( )[i] ).append( " " );
- }
+ result.append( from.getMemberValue( )[0] )
+ .append( "-" )
+ .append( from.getMemberValue( )[1] )
+ .append( "-" )
+ .append( from.getMemberValue( )[2] );
+ 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( " )" );
return result.toString( );
}
- private static String getLocalizedDisplayTimeUnitName( String name )
- {
- if ( name.equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_YEAR );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_QUARTER ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_QUARTER );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_MONTH ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_MONTH );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_WEEKOFMONTH );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_WEEKOFYEAR );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_DAYOFMONTH );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_DAYOFWEEK );
- else if ( name.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR ) )
- return Message.getMessage( ResourceConstants.TIMEFUNCTION_TOOLTIP_DAYOFYEAR );
-
- return "";
- }
-
-
private static String toLevelType( TimePeriodType timePeriodType )
{
if( timePeriodType == TimePeriodType.YEAR )
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
index 516c2ad..fd66f44 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
@@ -106,13 +106,5 @@ timeFunction.N1.displayName = The first N
timeFunction.N2.displayName = The second N
timeFunction.toolTip.to=To
-timeFunction.toolTip.year=Year:
-timeFunction.toolTip.quarter=Quarter:
-timeFunction.toolTip.month=Month:
-timeFunction.toolTip.dayOfMonth=Day Of Month:
-timeFunction.toolTip.dayOfWeek=Day Of Week:
-timeFunction.toolTip.weekOfYear=Week Of Year:
-timeFunction.toolTip.weekOfMonth=Week Of Month:
-timeFunction.toolTip.dayOfYear=Day Of Year:
\ No newline at end of file
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
index abd5eda..f53f6e8 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
@@ -110,12 +110,4 @@ public class ResourceConstants
//toolTip
public final static String TIMEFUNCTION_TOOLTIP_TO = "timeFunction.toolTip.to";
- public final static String TIMEFUNCTION_TOOLTIP_YEAR = "timeFunction.toolTip.year";
- public final static String TIMEFUNCTION_TOOLTIP_QUARTER = "timeFunction.toolTip.quarter";
- public final static String TIMEFUNCTION_TOOLTIP_MONTH = "timeFunction.toolTip.month";
- public final static String TIMEFUNCTION_TOOLTIP_WEEKOFYEAR = "timeFunction.toolTip.weekOfYear";
- public final static String TIMEFUNCTION_TOOLTIP_WEEKOFMONTH = "timeFunction.toolTip.weekOfMonth";
- public final static String TIMEFUNCTION_TOOLTIP_DAYOFWEEK = "timeFunction.toolTip.dayOfWeek";
- public final static String TIMEFUNCTION_TOOLTIP_DAYOFMONTH = "timeFunction.toolTip.dayOfMonth";
- public final static String TIMEFUNCTION_TOOLTIP_DAYOFYEAR = "timeFunction.toolTip.dayOfYear";
}
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 e01042d..a98eb90 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
@@ -351,7 +351,7 @@ public class TimeFunctionManagerTest extends TestCase
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
String desc = TimeFunctionManager.getTooltipForTimeFunction( cube1.getDimension( "TimeDimension" ), computedHandle, ULocale.getDefault( ) );
- assertTrue(desc.equals( "Quarter to Date ( Year:2003 Quarter:3 Month:7 Day Of Year:182 To Year:2003 Quarter:3 Month:8 Day Of Year:229 )" ) );
+ assertTrue(desc.equals( "Quarter to Date ( 2003-7-1 To 2003-8-17 )" ) );
}
public void testGettingToolTipForTimeFunction2() throws BirtException
@@ -369,7 +369,7 @@ public class TimeFunctionManagerTest extends TestCase
"dimension[\"TimeDimension\"]" );
String desc = TimeFunctionManager.getTooltipForTimeFunction( cube1.getDimension( "TimeDimension" ), computedHandle, ULocale.getDefault( ) );
- assertTrue(desc.equals( "previous Year to Date ( Year:2002 Quarter:1 Month:1 Day Of Year:1 To Year:2002 Quarter:3 Month:8 Day Of Year:229 )" ) );
+ assertTrue(desc.equals( "previous Year to Date ( 2002-1-1 To 2002-8-17 )" ) );
}
public void testGettingToolTipForTimeFunction3() throws BirtException
@@ -387,7 +387,7 @@ public class TimeFunctionManagerTest extends TestCase
"dimension[\"TimeDimension\"]" );
String desc = TimeFunctionManager.getTooltipForTimeFunction( cube1.getDimension( "TimeDimension" ), computedHandle, ULocale.getDefault( ) );
- assertTrue(desc.equals( "Trailing 12 Months ( Year:2002 Quarter:3 Month:8 Day Of Year:230 To Year:2003 Quarter:3 Month:8 Day Of Year:229 )" ) );
+ assertTrue(desc.equals( "Trailing 12 Months ( 2002-8-18 To 2003-8-17 )" ) );
}
public void testGettingToolTipForTimeFunction4() throws BirtException
@@ -403,6 +403,6 @@ public class TimeFunctionManagerTest extends TestCase
computedHandle.setProperty( ComputedColumn.TIME_DIMENSION_MEMBER,
"dimension[\"TimeDimension\"]" );
String desc = TimeFunctionManager.getTooltipForTimeFunction( cube1.getDimension( "TimeDimension" ), computedHandle, ULocale.getDefault( ) );
- assertTrue(desc.equals( "Current Year ( Year:2003 Quarter:1 Month:1 Day Of Year:1 To Year:2003 Quarter:4 Month:12 Day Of Year:365 )" ) );
+ assertTrue(desc.equals( "Current Year ( 2003-1-1 To 2003-12-31 )" ) );
}
}