Replaced listener on zul code with listener on widget
* When GanttPannel's zoomLevel is changed we have to update the timetracker and scroll the pannel, so we need the timetracker's scrollLeft value. Instead of asking for it to the GanttPannel after the listener is executed at Planner.java we will send both the selected zoomLevel and the scroll value. We replaced the listener at the zul file and added a new listener at Planner's widget class. Currently we are only sending the desired zoomLevel FEA: ItEr02S03MigracionZK5
This commit is contained in:
parent
09e62a9d2d
commit
d85543e0b3
3 changed files with 45 additions and 2 deletions
|
|
@ -53,9 +53,15 @@ import org.zkoss.ganttz.util.LongOperationFeedback;
|
|||
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
||||
import org.zkoss.json.JSONArray;
|
||||
import org.zkoss.lang.Objects;
|
||||
import org.zkoss.zk.au.AuRequest;
|
||||
import org.zkoss.zk.au.AuService;
|
||||
import org.zkoss.zk.mesg.MZk;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.UiException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
|
@ -330,6 +336,34 @@ public class Planner extends HtmlMacroComponent {
|
|||
|
||||
this.visibleChart = configuration.isExpandPlanningViewCharts();
|
||||
((South) getFellow("graphics")).setOpen(this.visibleChart);
|
||||
|
||||
setAuService(new AuService(){
|
||||
public boolean service(AuRequest request, boolean everError){
|
||||
String command = request.getCommand();
|
||||
String[] requestData;
|
||||
String zoomindex;
|
||||
|
||||
if (command.equals("onZoomLevelChange")){
|
||||
requestData = retrieveData(request, 1);
|
||||
zoomindex = requestData[0];
|
||||
|
||||
setZoomLevel((ZoomLevel)((Listbox)getFellow("listZoomLevels")).getModel().getElementAt(Integer.parseInt(zoomindex)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String[] retrieveData(AuRequest request, int requestLength){
|
||||
String [] requestData = (String[]) ((JSONArray)request.getData().get("")).toArray(new String[requestLength]);
|
||||
|
||||
if (requestData == null || requestData.length != requestLength) {
|
||||
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
|
||||
new Object[] { Objects.toString(requestData), this });
|
||||
}
|
||||
|
||||
return requestData;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void resettingPreviousComponentsToNull() {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ planner = self;
|
|||
<!-- Visualization modes -->
|
||||
<label>${i18n:_('Zoom')}:</label>
|
||||
<listbox id="listZoomLevels" mold="select" rows="1"
|
||||
model="${planner.zoomLevels}"
|
||||
onSelect="planner.setZoomLevel(self.selectedItem.value);" >
|
||||
model="${planner.zoomLevels}">
|
||||
</listbox>
|
||||
<button id="showCriticalPath" onClick="planner.showCriticalPath();"
|
||||
image="/common/img/ico_criticalpath.png"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ ganttz.Planner = zk.$extends(zk.Macro,{
|
|||
bind_ : function(){
|
||||
this.$supers('bind_', arguments);
|
||||
this.adjustScrollableDimensions();
|
||||
//Zoomlevel selector
|
||||
this.domListen_(jq('.plannerlayout .toolbar-box select'), 'onChange', '_zoomLevelChanged');
|
||||
},
|
||||
unbind_ : function(){
|
||||
this.$supers('unbind_', arguments);
|
||||
this.domUnlisten_(jq('.plannerlayout .toolbar-box select'), 'onChange', '_zoomLevelChanged');
|
||||
},
|
||||
adjustScrollableDimensions : function(){
|
||||
|
||||
|
|
@ -48,6 +54,10 @@ ganttz.Planner = zk.$extends(zk.Macro,{
|
|||
|
||||
// Inner divs need recalculation to adjust to new scroll displacement lenght
|
||||
ganttz.GanttPanel.getInstance().reScrollX(DOMWatermark.outerWidth());
|
||||
},
|
||||
_zoomLevelChanged : function(event){
|
||||
var zoomindex = event.domTarget.selectedIndex;
|
||||
zAu.send(new zk.Event(this, 'onZoomLevelChange', [new String(zoomindex)]));
|
||||
}
|
||||
},{
|
||||
FOOTER_HEIGHT : 40, // Design-relative footer height
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue