Skip to content

Add support for time zone for date filters. #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions filteringtable-addon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.tepi.filtertable</groupId>
<artifactId>filteringtable</artifactId>
<packaging>jar</packaging>
<version>1.0.1.v8</version>
<version>1.0.2.v8</version>
<name>FilteringTable</name>

<prerequisites>
Expand Down Expand Up @@ -147,4 +147,4 @@
</resource>
</resources>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import org.tepi.filtertable.datefilter.DateFilterPopup;
import org.tepi.filtertable.datefilter.DateInterval;
Expand Down Expand Up @@ -59,6 +60,7 @@ class FilterFieldGenerator implements Serializable {
private final ValueChangeListener listener = initializeListener();

private boolean runFiltersOnDemand;
private TimeZone timeZone;

FilterFieldGenerator(IFilterTable owner) {
this.owner = owner;
Expand Down Expand Up @@ -468,6 +470,7 @@ private AbstractField<?> createBooleanField(Object propertyId) {

private DateFilterPopup createDateField(Object propertyId) {
DateFilterPopup dateFilterPopup = new DateFilterPopup(owner.getFilterDecorator(), propertyId);
dateFilterPopup.setTimeZone(timeZone);
dates.put(dateFilterPopup, propertyId);
return dateFilterPopup;
}
Expand Down Expand Up @@ -641,4 +644,12 @@ void setFilterOnDemandMode(boolean filterOnDemand) {
initializeFilterFields();
}
}

public TimeZone getTimeZone() {
return timeZone;
}

public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;

import org.tepi.filtertable.FilterFieldGenerator.IFilterTable;
import org.tepi.filtertable.client.ui.FilterTableConnector;
Expand Down Expand Up @@ -54,6 +55,8 @@ public class FilterTable extends Table implements IFilterTable {
/* Fields from Table accessed via reflection */
private KeyMapper<Object> _columnIdMap;
private HashSet<Component> _visibleComponents;
/* Timezone for date filters */
private TimeZone timeZone;

/**
* Creates a new empty FilterTable
Expand Down Expand Up @@ -510,4 +513,21 @@ public String getColumnHeaderStylename(Object propertyId) {
}
return columnHeaderStylenames.get(propertyId);
}

/**
* Get TimeZone, used for Date filters
* @return TimeZone of FilterTable
*/
public TimeZone getTimeZone() {
return timeZone;
}

/**
* Set TimeZone, used for Date filters
* @param timeZone TimeZone of FilterTable
*/
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
generator.setTimeZone(timeZone);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import org.tepi.filtertable.FilterDecorator;
import org.vaadin.hene.popupbutton.PopupButton;
Expand Down Expand Up @@ -40,6 +41,7 @@ public class DateFilterPopup extends CustomField<DateInterval> {
protected Button set, clear;
private final Object propertyId;
private String dateFormatPattern;
private TimeZone timeZone;

private static final String DEFAULT_FROM_CAPTION = "From";
private static final String DEFAULT_TO_CAPTION = "To";
Expand Down Expand Up @@ -182,6 +184,9 @@ private void updateCaption(boolean nullTheCaption) {
}
} else {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormatPattern);
if (timeZone != null) {
sdf.setTimeZone(timeZone);
}
content.setCaption((fromField.getValue() == null ? "" : sdf.format(fromField.getValue())) + " - "
+ (toField.getValue() == null ? "" : sdf.format(toField.getValue())));
}
Expand Down Expand Up @@ -279,4 +284,16 @@ public void setReadOnly(boolean readOnly) {
fromField.setEnabled(!readOnly);
toField.setEnabled(!readOnly);
}

public TimeZone getTimeZone() {
return timeZone;
}

public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
if (timeZone != null) {
fromField.setTimeZone(timeZone);
toField.setTimeZone(timeZone);
}
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.tepi.filteringtable</groupId>
<artifactId>filteringtable-root</artifactId>
<packaging>pom</packaging>
<version>1.0.1.v8</version>
<version>1.0.2.v8</version>
<name>FilteringTable Add-on Root Project</name>

<prerequisites>
Expand All @@ -17,4 +17,4 @@
<module>filteringtable-demo</module>
</modules>

</project>
</project>