ItEr16S09RFComportamentoGraficoPlanificadorItEr15S12: Watermark weekend days is shown with different style in day-grained zoomlevel
This commit is contained in:
parent
3b9f2bd0f9
commit
7643e3ff98
4 changed files with 68 additions and 22 deletions
|
|
@ -1,9 +1,14 @@
|
|||
package org.zkoss.ganttz.util.zoom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.ReadablePeriod;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
/**
|
||||
* Zoom level for weeks in the first level and days in the second level
|
||||
|
|
@ -65,4 +70,26 @@ public class DetailFiveTimeTrackerState extends TimeTrackerStateUsingJodaTime {
|
|||
return down ? date.withDayOfWeek(1) : date.withDayOfWeek(1)
|
||||
.plusWeeks(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
// Just change styles for holidays
|
||||
public Collection<DetailItem> getSecondLevelDetails(Interval interval) {
|
||||
// Also mark holidays and current date
|
||||
List<DetailItem> items = (List<DetailItem>) createDetailsForSecondLevel(interval);
|
||||
ArrayList<DetailItem> result = new ArrayList<DetailItem>();
|
||||
int dayOfWeek;
|
||||
|
||||
for (DetailItem detailItem : items) {
|
||||
dayOfWeek = detailItem.getStartDate().dayOfWeek().get();
|
||||
if ((dayOfWeek == 6) || (dayOfWeek == 7)) {
|
||||
detailItem.setBankHoliday(true);
|
||||
result.add(detailItem);
|
||||
} else {
|
||||
detailItem.setBankHoliday(false);
|
||||
result.add(detailItem);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,11 +14,11 @@ import java.util.List;
|
|||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.JodaTimePermission;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
/**
|
||||
* @author Francisco Javier Moran Rúa
|
||||
* @author Francisco Javier Moran Rúa <jmoran@igalia.com>
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public abstract class TimeTrackerState {
|
||||
|
||||
|
|
@ -28,7 +28,8 @@ public abstract class TimeTrackerState {
|
|||
/**
|
||||
* This class was conceived as an immutable class but it required to
|
||||
* procesate twice DetailItem collections so it has now proper setters
|
||||
* @author Francisco Javier Moran Rúa
|
||||
* @author Francisco Javier Moran Rúa <jmoran@igalia.com>
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public final static class DetailItem {
|
||||
|
||||
|
|
@ -36,37 +37,39 @@ public abstract class TimeTrackerState {
|
|||
private String name;
|
||||
|
||||
private boolean even;
|
||||
private boolean bankHoliday;
|
||||
|
||||
private boolean currentPeriod;
|
||||
private int currentDayOffset;
|
||||
|
||||
private DateTime startDate;
|
||||
private DateTime endDate;
|
||||
|
||||
private DateTime endDate;
|
||||
|
||||
public DetailItem(int size, String name) {
|
||||
this(size, name, false);
|
||||
}
|
||||
|
||||
public DetailItem(int size, String name,
|
||||
DateTime startDate, DateTime endDate) {
|
||||
public DetailItem(int size, String name, DateTime startDate,
|
||||
DateTime endDate) {
|
||||
this(size, name, false);
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.markCurrentDay();
|
||||
}
|
||||
|
||||
public void markCurrentDay( ) {
|
||||
if ( this.startDate.isBeforeNow() && this.endDate.isAfterNow() ) {
|
||||
int offsetInPx = Math.round(
|
||||
( ( (float) Days.daysBetween(this.startDate, new DateTime() ).getDays() ) /
|
||||
( (float) Days.daysBetween(this.startDate, this.endDate).getDays() )
|
||||
) * this.size);
|
||||
public void markCurrentDay() {
|
||||
if (this.startDate.isBeforeNow() && this.endDate.isAfterNow()) {
|
||||
int offsetInPx = Math
|
||||
.round((((float) Days.daysBetween(this.startDate,
|
||||
new DateTime()).getDays()) / ((float) Days
|
||||
.daysBetween(this.startDate, this.endDate)
|
||||
.getDays()))
|
||||
* this.size);
|
||||
this.markCurrentDay(offsetInPx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DetailItem(int size, String name, boolean even) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
|
|
@ -79,6 +82,7 @@ public abstract class TimeTrackerState {
|
|||
this.size = size;
|
||||
this.name = name;
|
||||
this.even = false;
|
||||
this.bankHoliday = false;
|
||||
this.currentPeriod = true;
|
||||
this.currentDayOffset = currentdayoffset;
|
||||
}
|
||||
|
|
@ -91,6 +95,14 @@ public abstract class TimeTrackerState {
|
|||
return name;
|
||||
}
|
||||
|
||||
public DateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public DateTime getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEven(boolean even) {
|
||||
this.even = even;
|
||||
}
|
||||
|
|
@ -100,16 +112,18 @@ public abstract class TimeTrackerState {
|
|||
this.currentDayOffset = offset;
|
||||
}
|
||||
|
||||
/* public DetailItem markEven(boolean even) {
|
||||
return new DetailItem(size, name, even,
|
||||
currentPeriod, currentDayOffset);
|
||||
} */
|
||||
|
||||
|
||||
public boolean isEven() {
|
||||
return even;
|
||||
}
|
||||
|
||||
public boolean isBankHoliday() {
|
||||
return bankHoliday;
|
||||
}
|
||||
|
||||
public void setBankHoliday(boolean bankHoliday) {
|
||||
this.bankHoliday = bankHoliday;
|
||||
}
|
||||
|
||||
public boolean isCurrentPeriod() {
|
||||
return currentPeriod;
|
||||
}
|
||||
|
|
@ -133,11 +147,10 @@ public abstract class TimeTrackerState {
|
|||
|
||||
for (DetailItem detailItem : items) {
|
||||
detailItem.setEven(even);
|
||||
result.add( detailItem );
|
||||
result.add(detailItem);
|
||||
even = !even;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
protected abstract Collection<DetailItem> createDetailsForFirstLevel(
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ top = self;
|
|||
</n:tr>
|
||||
<n:tr id="watermark" style="height:100px">
|
||||
<n:td class="timetracker_column${(each.even?'_even':'')}
|
||||
${(each.bankHoliday?'bankHoliday':'')}
|
||||
${(each.currentPeriod?'timetracker_column_today':'')}"
|
||||
forEach="${top.detailsSecondLevel}"
|
||||
style="background-position: ${each.currentDayOffset}px"/>
|
||||
|
|
|
|||
|
|
@ -232,6 +232,11 @@ zkTasklist.GANTT_PANEL_LEFT = 300
|
|||
background-repeat: repeat-y;
|
||||
}
|
||||
|
||||
#watermark .bankHoliday {
|
||||
background-color: #FFEEEE; !important;
|
||||
}
|
||||
|
||||
|
||||
/* Reduce spacing and font-size for watermark legend */
|
||||
.z-columns, .z-column {
|
||||
font-size: 8px !important;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue