diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java index f58fefe50..4c2f5fd16 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java @@ -89,6 +89,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { private boolean refreshNameFilter = true; private int filterByNamePosition = 0; private int numberOfGroupsByName = 10; + private PaginationType paginationType; private WeakReferencedListeners nameFilterListener = WeakReferencedListeners.create(); @@ -104,9 +105,10 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { public ResourcesLoadPanel(List groups, TimeTracker timeTracker, Component componentOnWhichGiveFeedback, - boolean expandResourceLoadViewCharts) { + boolean expandResourceLoadViewCharts, PaginationType paginationType) { this.componentOnWhichGiveFeedback = componentOnWhichGiveFeedback; this.expandResourceLoadViewCharts = expandResourceLoadViewCharts; + this.paginationType = paginationType; init(groups, timeTracker); } @@ -311,9 +313,13 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { listZoomLevels = (Listbox) getFellow("listZoomLevels"); listZoomLevels.setSelectedIndex(timeTracker.getDetailLevel().ordinal()); - if(refreshNameFilter) { + if(paginationType == PaginationType.INTERNAL_PAGINATION && refreshNameFilter) { setupNameFilter(); } + else if(paginationType == PaginationType.NONE) { + getFellow("filterByNameCombo").setVisible(false); + getFellow("filterByNameLabel").setVisible(false); + } getFellow("insertionPointChart").appendChild(loadChart); @@ -389,7 +395,8 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { * @return */ private List getGroupsToShow() { - if(filterByNamePosition == -1) { + if(paginationType != PaginationType.INTERNAL_PAGINATION || + filterByNamePosition == -1) { return groups; } int endPosition = @@ -400,9 +407,11 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { } public void onSelectFilterByName(Integer filterByNamePosition) { + if(paginationType != PaginationType.NONE) { this.filterByNamePosition = filterByNamePosition.intValue(); this.feedBackMessage = _("filtering by name"); changeNameFilterWithFeedback(); + } } private void changeNameFilterWithFeedback() { @@ -411,11 +420,14 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { @Override public void doAction() throws Exception { - treeModel = createModelForTree(); - timeTrackerComponent = timeTrackerForResourcesLoadPanel(timeTracker); - resourceLoadList = new ResourceLoadList(timeTracker, treeModel); - leftPane = new ResourceLoadLeftPane(treeModel, resourceLoadList); - registerNeededScripts(); + if(paginationType == PaginationType.INTERNAL_PAGINATION) { + //if the pagination is internal, we are in charge of repainting the graph + treeModel = createModelForTree(); + timeTrackerComponent = timeTrackerForResourcesLoadPanel(timeTracker); + resourceLoadList = new ResourceLoadList(timeTracker, treeModel); + leftPane = new ResourceLoadLeftPane(treeModel, resourceLoadList); + registerNeededScripts(); + } nameFilterListener.fireEvent(new IListenerNotification() { @Override public void doNotify(IPaginationFilterChangedListener listener) { @@ -432,7 +444,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { }); } - public void setNameFilterDisabled(boolean disabled) { + public void setInternalPaginationDisabled(boolean disabled) { Combobox combo = ((Combobox) getFellow("filterByNameCombo")); if(combo.isDisabled() != disabled) { filterByNamePosition = disabled? -1 : @@ -475,4 +487,28 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { return numberOfGroupsByName; } + public Combobox getPaginationFilterCombobox() { + if(paginationType == PaginationType.EXTERNAL_PAGINATION) { + return (Combobox) getFellow("filterByNameCombo"); + } + return null; + } + + public enum PaginationType { + /** + * Sets the widget to take care of the pagination of all the LoadTimeLine objects received. + */ + INTERNAL_PAGINATION, + /** + * The widget will only show the combo box but its content has to be configured externally. + * The pagination has to be managed externally too: the widget will show all the LoadTimeLine + * objects received. + */ + EXTERNAL_PAGINATION, + /** + * Disables pagination. Shows all the LoadTimeLine objects received. + */ + NONE; + } + } \ No newline at end of file diff --git a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul index b31211410..b5a2a76eb 100644 --- a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul +++ b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul @@ -46,7 +46,7 @@ resourcesLoadPanel = self; onSelect="resourcesLoadPanel.setFilter(self.selectedItem.value);"> - ${i18n:_('Name filter')}: + diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadController.java index 702c257e1..c1f6409d1 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadController.java @@ -66,6 +66,7 @@ import org.zkoss.ganttz.resourceload.IPaginationFilterChangedListener; import org.zkoss.ganttz.resourceload.ISeeScheduledOfListener; import org.zkoss.ganttz.resourceload.ResourcesLoadPanel; import org.zkoss.ganttz.resourceload.ResourcesLoadPanel.IToolbarCommand; +import org.zkoss.ganttz.resourceload.ResourcesLoadPanel.PaginationType; import org.zkoss.ganttz.timetracker.TimeTracker; import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener; import org.zkoss.ganttz.timetracker.zoom.SeveralModificators; @@ -242,7 +243,7 @@ public class ResourceLoadController implements Composer { } //if the bandbox filter is active, we disable the name filter - resourcesLoadPanel.setNameFilterDisabled( + resourcesLoadPanel.setInternalPaginationDisabled( !bandBox.getSelectedElements().isEmpty()); } resourcesLoadPanel.init(resourceLoadModel.getLoadTimeLines(), @@ -254,7 +255,8 @@ public class ResourceLoadController implements Composer { } else { resourcesLoadPanel = new ResourcesLoadPanel(resourceLoadModel .getLoadTimeLines(), timeTracker, parent, resourceLoadModel - .isExpandResourceLoadViewCharts()); + .isExpandResourceLoadViewCharts(), PaginationType.INTERNAL_PAGINATION); + if(filterBy == null) { addWorkersBandbox(); addTimeFilter();