ItEr23S10CUAsignacionGrupoRecursosAPlanificacionItEr22S10: Moving DetailItem to top level
This commit is contained in:
parent
9c898cb61f
commit
d44d69ec7c
4 changed files with 120 additions and 117 deletions
|
|
@ -9,10 +9,10 @@ import org.joda.time.LocalDate;
|
|||
import org.zkoss.ganttz.DatesMapperOnInterval;
|
||||
import org.zkoss.ganttz.IDatesMapper;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.timetracker.zoom.DetailItem;
|
||||
import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
||||
import org.zkoss.ganttz.timetracker.zoom.TimeTrackerState;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.timetracker.zoom.TimeTrackerState.DetailItem;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
||||
|
|
@ -45,7 +45,7 @@ public class TimeTracker {
|
|||
zoomListeners.addListener(listener);
|
||||
}
|
||||
|
||||
public Collection<TimeTrackerState.DetailItem> getDetailsFirstLevel() {
|
||||
public Collection<DetailItem> getDetailsFirstLevel() {
|
||||
if (detailsFirstLevelCached == null) {
|
||||
detailsFirstLevelCached = getTimeTrackerState()
|
||||
.getFirstLevelDetails(interval);
|
||||
|
|
@ -53,7 +53,7 @@ public class TimeTracker {
|
|||
return detailsFirstLevelCached;
|
||||
}
|
||||
|
||||
public Collection<TimeTrackerState.DetailItem> getDetailsSecondLevel() {
|
||||
public Collection<DetailItem> getDetailsSecondLevel() {
|
||||
if (detailsSecondLevelCached == null) {
|
||||
detailsSecondLevelCached = getTimeTrackerState()
|
||||
.getSecondLevelDetails(interval);
|
||||
|
|
@ -89,7 +89,7 @@ public class TimeTracker {
|
|||
// Code to improve. Not optimus. We have to calculate the details twice
|
||||
int result = 0;
|
||||
Collection<DetailItem> detailsFirstLevel = getDetailsFirstLevel();
|
||||
for (TimeTrackerState.DetailItem item : detailsFirstLevel) {
|
||||
for (DetailItem item : detailsFirstLevel) {
|
||||
result += item.getSize();
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.zkoss.ganttz.timetracker;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.zkoss.ganttz.timetracker.zoom.DetailItem;
|
||||
import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
||||
import org.zkoss.ganttz.timetracker.zoom.TimeTrackerState;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
|
|
@ -64,11 +65,11 @@ public abstract class TimeTrackerComponent extends HtmlMacroComponent {
|
|||
|
||||
protected abstract void scrollHorizontalPercentage(int pixelsDisplacement);
|
||||
|
||||
public Collection<TimeTrackerState.DetailItem> getDetailsFirstLevel() {
|
||||
public Collection<DetailItem> getDetailsFirstLevel() {
|
||||
return timeTracker.getDetailsFirstLevel();
|
||||
}
|
||||
|
||||
public Collection<TimeTrackerState.DetailItem> getDetailsSecondLevel() {
|
||||
public Collection<DetailItem> getDetailsSecondLevel() {
|
||||
return timeTracker.getDetailsSecondLevel();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,113 @@
|
|||
package org.zkoss.ganttz.timetracker.zoom;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
|
||||
/**
|
||||
* 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 <jmoran@igalia.com>
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public final class DetailItem {
|
||||
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
private boolean even;
|
||||
private boolean bankHoliday;
|
||||
|
||||
private boolean currentPeriod;
|
||||
private int currentDayOffset;
|
||||
|
||||
private DateTime startDate;
|
||||
|
||||
private DateTime endDate;
|
||||
|
||||
public DetailItem(int size, String name) {
|
||||
this(size, name, false);
|
||||
}
|
||||
|
||||
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);
|
||||
this.markCurrentDay(offsetInPx);
|
||||
}
|
||||
}
|
||||
|
||||
public DetailItem(int size, String name, boolean even) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.even = even;
|
||||
this.currentPeriod = false;
|
||||
this.currentDayOffset = 0;
|
||||
}
|
||||
|
||||
public DetailItem(int size, String name, int currentdayoffset) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.even = false;
|
||||
this.bankHoliday = false;
|
||||
this.currentPeriod = true;
|
||||
this.currentDayOffset = currentdayoffset;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public DateTime getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEven(boolean even) {
|
||||
this.even = even;
|
||||
}
|
||||
|
||||
public void markCurrentDay(int offset) {
|
||||
this.currentPeriod = true;
|
||||
this.currentDayOffset = offset;
|
||||
}
|
||||
|
||||
public boolean isEven() {
|
||||
return even;
|
||||
}
|
||||
|
||||
public boolean isBankHoliday() {
|
||||
return bankHoliday;
|
||||
}
|
||||
|
||||
public void setBankHoliday(boolean bankHoliday) {
|
||||
this.bankHoliday = bankHoliday;
|
||||
}
|
||||
|
||||
public boolean isCurrentPeriod() {
|
||||
return currentPeriod;
|
||||
}
|
||||
|
||||
public int getCurrentDayOffset() {
|
||||
return currentDayOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,8 +7,6 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
/**
|
||||
|
|
@ -20,115 +18,6 @@ public abstract class TimeTrackerState {
|
|||
protected static final long MILLSECONDS_IN_DAY = 1000 * 60 * 60 * 24;
|
||||
protected static final int NUMBER_OF_ITEMS_MINIMUM = 10;
|
||||
|
||||
/**
|
||||
* 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 <jmoran@igalia.com>
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public final static class DetailItem {
|
||||
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
private boolean even;
|
||||
private boolean bankHoliday;
|
||||
|
||||
private boolean currentPeriod;
|
||||
private int currentDayOffset;
|
||||
|
||||
private DateTime startDate;
|
||||
|
||||
private DateTime endDate;
|
||||
|
||||
public DetailItem(int size, String name) {
|
||||
this(size, name, false);
|
||||
}
|
||||
|
||||
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);
|
||||
this.markCurrentDay(offsetInPx);
|
||||
}
|
||||
}
|
||||
|
||||
public DetailItem(int size, String name, boolean even) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.even = even;
|
||||
this.currentPeriod = false;
|
||||
this.currentDayOffset = 0;
|
||||
}
|
||||
|
||||
public DetailItem(int size, String name, int currentdayoffset) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.even = false;
|
||||
this.bankHoliday = false;
|
||||
this.currentPeriod = true;
|
||||
this.currentDayOffset = currentdayoffset;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public DateTime getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEven(boolean even) {
|
||||
this.even = even;
|
||||
}
|
||||
|
||||
public void markCurrentDay(int offset) {
|
||||
this.currentPeriod = true;
|
||||
this.currentDayOffset = offset;
|
||||
}
|
||||
|
||||
public boolean isEven() {
|
||||
return even;
|
||||
}
|
||||
|
||||
public boolean isBankHoliday() {
|
||||
return bankHoliday;
|
||||
}
|
||||
|
||||
public void setBankHoliday(boolean bankHoliday) {
|
||||
this.bankHoliday = bankHoliday;
|
||||
}
|
||||
|
||||
public boolean isCurrentPeriod() {
|
||||
return currentPeriod;
|
||||
}
|
||||
|
||||
public int getCurrentDayOffset() {
|
||||
return currentDayOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Collection<DetailItem> getFirstLevelDetails(Interval interval) {
|
||||
return markEvens(createDetailsForFirstLevel(interval));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue