[Bug #765] Fixes the position of the scroll bar in the gantt.
it calculates the new position of the scrollbar when the zoom is changed. FEA : ItEr68S04BugFixing
This commit is contained in:
parent
5e9431e631
commit
6b16b19327
12 changed files with 227 additions and 16 deletions
|
|
@ -49,7 +49,7 @@ public class DatesMapperOnInterval implements IDatesMapper {
|
|||
public LocalDate toDate(int pixels) {
|
||||
int daysInto = Fraction.getFraction(pixels, 1).divideBy(pixelsPerDay)
|
||||
.intValue();
|
||||
return interval.getStart().plusDays(daysInto);
|
||||
return getInterval().getStart().plusDays(daysInto);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,7 +62,7 @@ public class DatesMapperOnInterval implements IDatesMapper {
|
|||
}
|
||||
|
||||
private Fraction getProportion(DateTime dateTime) {
|
||||
return interval.getProportion(dateTime);
|
||||
return getInterval().getProportion(dateTime);
|
||||
}
|
||||
|
||||
private int toPixels(Fraction proportion) {
|
||||
|
|
@ -72,7 +72,7 @@ public class DatesMapperOnInterval implements IDatesMapper {
|
|||
|
||||
@Override
|
||||
public int toPixels(ReadableDuration duration) {
|
||||
DateTime end = interval.getStart().toDateTimeAtStartOfDay()
|
||||
DateTime end = getInterval().getStart().toDateTimeAtStartOfDay()
|
||||
.plus(duration);
|
||||
return toPixels(getProportion(end));
|
||||
}
|
||||
|
|
@ -98,4 +98,12 @@ public class DatesMapperOnInterval implements IDatesMapper {
|
|||
return this.horizontalSize;
|
||||
}
|
||||
|
||||
public Fraction getPixelsPerDay() {
|
||||
return pixelsPerDay;
|
||||
}
|
||||
|
||||
public Interval getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,11 +22,13 @@ package org.zkoss.ganttz;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.timetracker.TimeTracker;
|
||||
import org.zkoss.ganttz.timetracker.TimeTrackerComponent;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
import org.zkoss.zul.impl.XulElement;
|
||||
|
|
@ -43,6 +45,10 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
|
||||
private final Planner planner;
|
||||
|
||||
private LocalDate previousStart;
|
||||
|
||||
private Interval previousInterval;
|
||||
|
||||
public GanttPanel(
|
||||
Planner planner,
|
||||
List<? extends CommandOnTaskContextualized<?>> commandsOnTasksContextualized,
|
||||
|
|
@ -71,10 +77,36 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
TimeTracker timeTracker) {
|
||||
return new TimeTrackerComponent(timeTracker) {
|
||||
@Override
|
||||
protected void scrollHorizontalPercentage(int pixelsDisplacement) {
|
||||
protected void scrollHorizontalPercentage(int daysDisplacement) {
|
||||
response("scroll_horizontal", new AuInvoke(GanttPanel.this,
|
||||
"scroll_horizontal", "" + pixelsDisplacement));
|
||||
"scroll_horizontal", "" + daysDisplacement));
|
||||
moveCurrentPositionScroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// get the previous data.
|
||||
LocalDate previousStart = getPreviousStart();
|
||||
|
||||
// get the current data
|
||||
int diffDays = getTimeTrackerComponent().getDiffDays(
|
||||
previousStart);
|
||||
double pixelPerDay = getTimeTrackerComponent().getPixelPerDay();
|
||||
|
||||
response("move_scroll", new AuInvoke(GanttPanel.this,
|
||||
"move_scroll", "" + diffDays, "" + pixelPerDay));
|
||||
}
|
||||
|
||||
protected void updateCurrentDayScroll() {
|
||||
double previousPixelPerDay = getTimeTracker().getMapper()
|
||||
.getPixelsPerDay()
|
||||
.doubleValue();
|
||||
|
||||
response("update_day_scroll", new AuInvoke(GanttPanel.this,
|
||||
"update_day_scroll", "" + previousPixelPerDay));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +117,7 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
.asDependencyComponents(diagramGraph.getVisibleDependencies()));
|
||||
timeTrackerComponent.afterCompose();
|
||||
dependencyList.afterCompose();
|
||||
|
||||
savePreviousData();
|
||||
if (planner.isExpandAll()) {
|
||||
FunctionalityExposedForExtensions<?> context = (FunctionalityExposedForExtensions<?>) planner
|
||||
.getContext();
|
||||
|
|
@ -115,10 +147,14 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public void zoomIncrease() {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
getTimeTracker().zoomIncrease();
|
||||
}
|
||||
|
||||
public void zoomDecrease() {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
getTimeTracker().zoomDecrease();
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +163,25 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public void setZoomLevel(ZoomLevel zoomLevel) {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
getTimeTracker().setZoomLevel(zoomLevel);
|
||||
}
|
||||
|
||||
private void savePreviousData() {
|
||||
this.previousStart = getTimeTracker().getRealInterval().getStart();
|
||||
this.previousInterval = getTimeTracker().getMapper().getInterval();
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return planner;
|
||||
}
|
||||
|
||||
public LocalDate getPreviousStart() {
|
||||
return previousStart;
|
||||
}
|
||||
|
||||
public Interval getPreviousInterval() {
|
||||
return previousInterval;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,10 @@
|
|||
|
||||
package org.zkoss.ganttz;
|
||||
|
||||
import org.apache.commons.lang.math.Fraction;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.ReadableDuration;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
public interface IDatesMapper {
|
||||
|
||||
|
|
@ -41,4 +43,7 @@ public interface IDatesMapper {
|
|||
|
||||
int getHorizontalSize();
|
||||
|
||||
Fraction getPixelsPerDay();
|
||||
|
||||
Interval getInterval();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.commons.lang.math.Fraction;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.DependencyType;
|
||||
|
|
@ -43,6 +45,7 @@ import org.zkoss.ganttz.timetracker.TimeTracker;
|
|||
import org.zkoss.ganttz.timetracker.TimeTrackerComponent;
|
||||
import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.ganttz.util.MenuBuilder;
|
||||
import org.zkoss.ganttz.util.MenuBuilder.ItemAction;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
|
|
@ -292,12 +295,19 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
taskComponent.zoomChanged();
|
||||
}
|
||||
adjustZoomColumnsHeight();
|
||||
adjustZoomPositionScroll();
|
||||
}
|
||||
};
|
||||
getTimeTracker().addZoomListener(zoomLevelChangedListener);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalDate toDate(int pixels, Fraction pixelsPerDay, Interval interval) {
|
||||
int daysInto = Fraction.getFraction(pixels, 1).divideBy(pixelsPerDay)
|
||||
.intValue();
|
||||
return interval.getStart().plusDays(daysInto);
|
||||
}
|
||||
|
||||
private Map<TaskComponent, Menupopup> contextMenus = new HashMap<TaskComponent, Menupopup>();
|
||||
|
||||
private Menupopup getContextMenuFor(TaskComponent taskComponent) {
|
||||
|
|
@ -337,6 +347,10 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
response("adjust_height", new AuInvoke(TaskList.this, "adjust_height"));
|
||||
}
|
||||
|
||||
private void adjustZoomPositionScroll() {
|
||||
getTimeTrackerComponent().movePositionScroll();
|
||||
}
|
||||
|
||||
public void redrawDependencies() {
|
||||
getGanttPanel().getDependencyList().redrawDependencies();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,6 +287,18 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
"adjustScrollHorizontalPosition", pixelsDisplacement
|
||||
+ ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -345,6 +357,18 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
@Override
|
||||
protected void scrollHorizontalPercentage(int pixelsDisplacement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ import org.zkoss.ganttz.timetracker.zoom.TimeTrackerState;
|
|||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ package org.zkoss.ganttz.timetracker;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.IDatesMapper;
|
||||
import org.zkoss.ganttz.timetracker.zoom.DetailItem;
|
||||
import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
||||
import org.zkoss.ganttz.timetracker.zoom.TimeTrackerState;
|
||||
|
|
@ -94,7 +97,11 @@ public abstract class TimeTrackerComponent extends HtmlMacroComponent {
|
|||
return this.getTimeTracker().getDetailLevel();
|
||||
}
|
||||
|
||||
protected abstract void scrollHorizontalPercentage(int pixelsDisplacement);
|
||||
protected abstract void scrollHorizontalPercentage(int daysDisplacement);
|
||||
|
||||
protected abstract void moveCurrentPositionScroll();
|
||||
|
||||
protected abstract void updateCurrentDayScroll();
|
||||
|
||||
public Collection<DetailItem> getDetailsFirstLevel() {
|
||||
return timeTracker.getDetailsFirstLevel();
|
||||
|
|
@ -164,8 +171,26 @@ public abstract class TimeTrackerComponent extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private void changeDetailLevel(double days) {
|
||||
scrollHorizontalPercentage((int) Math.floor(days
|
||||
/ getTimeTrackerState().daysPerPixel()));
|
||||
scrollHorizontalPercentage((int) Math.floor(days));
|
||||
}
|
||||
|
||||
public void movePositionScroll() {
|
||||
moveCurrentPositionScroll();
|
||||
}
|
||||
|
||||
public void updateDayScroll() {
|
||||
updateCurrentDayScroll();
|
||||
}
|
||||
|
||||
public int getDiffDays(LocalDate previousStart) {
|
||||
// get the current data
|
||||
IDatesMapper mapper = getTimeTracker().getMapper();
|
||||
LocalDate start = getTimeTracker().getRealInterval().getStart();
|
||||
return Days.daysBetween(start, previousStart).getDays();
|
||||
}
|
||||
|
||||
public double getPixelPerDay() {
|
||||
return getTimeTracker().getMapper().getPixelsPerDay().doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,16 @@ public class TimeTrackerComponentWithoutColumns extends TimeTrackerComponent {
|
|||
@Override
|
||||
protected void scrollHorizontalPercentage(int pixelsDisplacement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,10 +97,10 @@ planner = self;
|
|||
id="taskdetailsContainer" sclass="taskdetailsContainer">
|
||||
<div sclass="leftpanelgap" id="insertionPointLeftPanel"></div>
|
||||
</west>
|
||||
<center sclass="taskspanel">
|
||||
<center id="taskpanel" sclass="taskspanel">
|
||||
<borderlayout>
|
||||
<north border="0"><div sclass="timetrackergap" id="insertionPointTimetracker"></div></north>
|
||||
<center autoscroll="true" border="0" sclass="rightpanellayout">
|
||||
<center id="centerPanel" autoscroll="true" border="10" sclass="rightpanellayout">
|
||||
<div id="insertionPointRightPanel" sclass="taskspanelgap"></div>
|
||||
</center>
|
||||
</borderlayout>
|
||||
|
|
|
|||
|
|
@ -24,13 +24,62 @@
|
|||
*/
|
||||
zkGanttPanel = {};
|
||||
|
||||
SCROLL_DAY = 0;
|
||||
|
||||
zkGanttPanel.init = function(cmp){
|
||||
}
|
||||
|
||||
zkGanttPanel.update_day_scroll = function(cmp,previousPixelPerDay) {
|
||||
fromPixelToDay(previousPixelPerDay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls horizontally the ganttpanel when the zoom has resized the component
|
||||
* width.
|
||||
*/
|
||||
zkGanttPanel.scroll_horizontal = function(cmp, offsetInPx) {
|
||||
document.getElementById('ganttpanel_scroller_x').scrollLeft = offsetInPx;
|
||||
zkGanttPanel.scroll_horizontal = function(cmp,daysDisplacement) {
|
||||
SCROLL_DAY = daysDisplacement;
|
||||
}
|
||||
|
||||
zkGanttPanel.move_scroll = function(cmp,diffDays,pixelPerDay) {
|
||||
fromDayToPixel(diffDays,pixelPerDay);
|
||||
}
|
||||
|
||||
function fromPixelToDay(previousPixelPerDay){
|
||||
var div1 = document.getElementById ("ganttpanel").parentNode;
|
||||
var div2 = div1.parentNode;
|
||||
var div3 = div2.parentNode;
|
||||
|
||||
var maxHPosition = div3.scrollWidth - div3.clientWidth;
|
||||
if( maxHPosition > 0 ){
|
||||
var proportion = div3.scrollWidth / maxHPosition;
|
||||
var positionInScroll = div3.scrollLeft;
|
||||
var positionInPx = positionInScroll * proportion;
|
||||
if(positionInPx > 0){
|
||||
var position = positionInPx / previousPixelPerDay;
|
||||
var day = position;
|
||||
SCROLL_DAY = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fromDayToPixel(diffDays,pixelPerDay){
|
||||
var div1 = document.getElementById ("ganttpanel").parentNode;
|
||||
var div2 = div1.parentNode;
|
||||
var div3 = div2.parentNode;
|
||||
|
||||
var day = SCROLL_DAY;
|
||||
day += parseInt(diffDays);
|
||||
var newPosInPx = parseInt(day * pixelPerDay);
|
||||
var maxHPosition = div3.scrollWidth - div3.clientWidth;
|
||||
var newProportion = div3.scrollWidth / maxHPosition;
|
||||
if( newProportion > 0){
|
||||
var newPosInScroll = newPosInPx / newProportion;
|
||||
if(newPosInScroll < 0){
|
||||
newPosInScroll = 0;
|
||||
}
|
||||
div1.scrollLeft = newPosInScroll;
|
||||
div2.scrollLeft = newPosInScroll;
|
||||
div3.scrollLeft = newPosInScroll;
|
||||
}
|
||||
}
|
||||
|
|
@ -285,8 +285,8 @@ function adjustScrollableDimensions() {
|
|||
// Inner divs need recalculation to adjust to new scroll displacement lenght
|
||||
document.getElementById('ganttpanel_inner_scroller_x').style["width"] = watermark.offsetWidth
|
||||
+ "px";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueue
|
|||
import org.navalplanner.business.resources.entities.LimitingResourceQueue;
|
||||
import org.zkoss.ganttz.DependencyList;
|
||||
import org.zkoss.ganttz.timetracker.TimeTracker;
|
||||
import org.zkoss.ganttz.timetracker.TimeTracker.IDetailItemFilter;
|
||||
import org.zkoss.ganttz.timetracker.TimeTrackerComponent;
|
||||
import org.zkoss.ganttz.timetracker.TimeTracker.IDetailItemFilter;
|
||||
import org.zkoss.ganttz.timetracker.zoom.DetailItem;
|
||||
import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
|
|
@ -305,6 +305,16 @@ public class LimitingResourcesPanel extends HtmlMacroComponent {
|
|||
protected void scrollHorizontalPercentage(int pixelsDisplacement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -317,6 +327,16 @@ public class LimitingResourcesPanel extends HtmlMacroComponent {
|
|||
"adjustScrollHorizontalPosition", pixelsDisplacement
|
||||
+ ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -351,6 +371,10 @@ public class LimitingResourcesPanel extends HtmlMacroComponent {
|
|||
getFellow("insertionPointTimetracker").getChildren().clear();
|
||||
}
|
||||
|
||||
public TimeTrackerComponent getTimeTrackerComponent() {
|
||||
return timeTrackerComponent;
|
||||
}
|
||||
|
||||
public void unschedule(QueueTask task) {
|
||||
LimitingResourceQueueElement queueElement = task.getLimitingResourceQueueElement();
|
||||
LimitingResourceQueue queue = queueElement.getLimitingResourceQueue();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue