[Bug #765] Fixes the position of the scroll bar in the resources load screen.
it calculates the new position of the scrollbar when the zoom is changed. FEA : FEA : ItEr68S04BugFixing
This commit is contained in:
parent
ea39f8e08b
commit
723ccd3cbd
3 changed files with 104 additions and 7 deletions
|
|
@ -25,12 +25,14 @@ import static org.zkoss.ganttz.i18n.I18nHelper._;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.IChartVisibilityChangedListener;
|
||||
import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
|
||||
import org.zkoss.ganttz.timetracker.TimeTracker;
|
||||
import org.zkoss.ganttz.timetracker.TimeTrackerComponent;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.ComponentsFinder;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback;
|
||||
import org.zkoss.ganttz.util.MutableTreeModel;
|
||||
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
|
||||
|
|
@ -74,6 +76,10 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
|
||||
private TimeTracker timeTracker;
|
||||
|
||||
private LocalDate previousStart;
|
||||
|
||||
private Interval previousInterval;
|
||||
|
||||
private final Component componentOnWhichGiveFeedback;
|
||||
|
||||
private WeakReferencedListeners<IFilterChangedListener> zoomListeners = WeakReferencedListeners
|
||||
|
|
@ -188,17 +194,41 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public void setZoomLevel(final ZoomLevel zoomLevel) {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
timeTracker.setZoomLevel(zoomLevel);
|
||||
}
|
||||
|
||||
public void zoomIncrease() {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
timeTracker.zoomIncrease();
|
||||
}
|
||||
|
||||
public void zoomDecrease() {
|
||||
savePreviousData();
|
||||
getTimeTrackerComponent().updateDayScroll();
|
||||
timeTracker.zoomDecrease();
|
||||
}
|
||||
|
||||
private void savePreviousData() {
|
||||
TimeTracker timeTracker = getTimeTrackerComponent().getTimeTracker();
|
||||
this.previousStart = timeTracker.getRealInterval().getStart();
|
||||
this.previousInterval = timeTracker.getMapper().getInterval();
|
||||
}
|
||||
|
||||
public LocalDate getPreviousStart() {
|
||||
return previousStart;
|
||||
}
|
||||
|
||||
public Interval getPreviousInterval() {
|
||||
return previousInterval;
|
||||
}
|
||||
|
||||
public TimeTrackerComponent getTimeTrackerComponent() {
|
||||
return timeTrackerComponent;
|
||||
}
|
||||
|
||||
public void add(final IToolbarCommand... commands) {
|
||||
Component toolbar = getToolbar();
|
||||
resetToolbar(toolbar);
|
||||
|
|
@ -282,21 +312,32 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
TimeTracker timeTracker) {
|
||||
return new TimeTrackerComponent(timeTracker) {
|
||||
@Override
|
||||
protected void scrollHorizontalPercentage(int pixelsDisplacement) {
|
||||
protected void scrollHorizontalPercentage(int daysDisplacement) {
|
||||
response("", new AuInvoke(resourceLoadList,
|
||||
"adjustScrollHorizontalPosition", pixelsDisplacement
|
||||
+ ""));
|
||||
"scroll_horizontal", daysDisplacement + ""));
|
||||
moveCurrentPositionScroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveCurrentPositionScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
// 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(resourceLoadList,
|
||||
"move_scroll", "" + diffDays, "" + pixelPerDay));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentDayScroll() {
|
||||
// TODO Auto-generated method stub
|
||||
double previousPixelPerDay = getTimeTracker().getMapper()
|
||||
.getPixelsPerDay().doubleValue();
|
||||
|
||||
response("update_day_scroll", new AuInvoke(resourceLoadList,
|
||||
"update_day_scroll", "" + previousPixelPerDay));
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -341,6 +382,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
|
||||
this.visibleChart = expandResourceLoadViewCharts;
|
||||
((South) getFellow("graphics")).setOpen(this.visibleChart);
|
||||
savePreviousData();
|
||||
}
|
||||
|
||||
public void clearComponents() {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ zkResourcesLoadList.recalculateTimetrackerHeight = function (cmp) {
|
|||
function addResourcesLoadListMethods(object) {
|
||||
var scrollSync;
|
||||
|
||||
var SCROLL_DAY = 0;
|
||||
|
||||
function watermark() {
|
||||
return document.getElementById('watermark');
|
||||
}
|
||||
|
|
@ -128,5 +130,53 @@ function addResourcesLoadListMethods(object) {
|
|||
cmp.scrollLeft = offsetInPx;
|
||||
}
|
||||
|
||||
object.update_day_scroll = function(cmp,previousPixelPerDay) {
|
||||
var div1 = cmp;
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Scrolls horizontally the ganttpanel when the zoom has resized the component
|
||||
* width.
|
||||
*/
|
||||
|
||||
object.scroll_horizontal = function(cmp,daysDisplacement) {
|
||||
SCROLL_DAY = daysDisplacement;
|
||||
};
|
||||
|
||||
object.move_scroll = function(cmp,diffDays,pixelPerDay) {
|
||||
var div1 = cmp;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
@ -30,10 +30,10 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.joda.time.LocalDate;
|
||||
|
|
@ -579,6 +579,7 @@ public class ResourceLoadController implements Composer {
|
|||
if (resourcesLoadPanel.isVisibleChart()) {
|
||||
loadChart.fillChart();
|
||||
}
|
||||
adjustZoomPositionScroll();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -587,6 +588,10 @@ public class ResourceLoadController implements Composer {
|
|||
return zoomListener;
|
||||
}
|
||||
|
||||
private void adjustZoomPositionScroll() {
|
||||
resourcesLoadPanel.getTimeTrackerComponent().movePositionScroll();
|
||||
}
|
||||
|
||||
private IChartVisibilityChangedListener fillOnChartVisibilityChange(
|
||||
final Chart loadChart) {
|
||||
IChartVisibilityChangedListener chartVisibilityChangedListener = new IChartVisibilityChangedListener() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue