diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/IFilterChangedListener.java b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/IFilterChangedListener.java new file mode 100644 index 000000000..f607aa3ac --- /dev/null +++ b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/IFilterChangedListener.java @@ -0,0 +1,27 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.zkoss.ganttz.resourceload; + +public interface IFilterChangedListener { + + public void filterChanged(boolean filter); + +} 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 ee5f55529..a6239f493 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java @@ -20,6 +20,8 @@ package org.zkoss.ganttz.resourceload; +import static org.zkoss.ganttz.i18n.I18nHelper._; + import java.util.List; import org.apache.commons.lang.StringUtils; @@ -30,6 +32,8 @@ import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.ganttz.util.ComponentsFinder; import org.zkoss.ganttz.util.MutableTreeModel; import org.zkoss.ganttz.util.OnZKDesktopRegistry; +import org.zkoss.ganttz.util.WeakReferencedListeners; +import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification; import org.zkoss.ganttz.util.script.IScriptsRegister; import org.zkoss.zk.au.out.AuInvoke; import org.zkoss.zk.ui.Component; @@ -42,7 +46,6 @@ import org.zkoss.zul.ListModel; import org.zkoss.zul.Separator; import org.zkoss.zul.SimpleListModel; import org.zkoss.zul.api.Listbox; - public class ResourcesLoadPanel extends HtmlMacroComponent { public interface IToolbarCommand { @@ -59,16 +62,28 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { private ResourceLoadList resourceLoadList; - private final List groups; + private List groups; private MutableTreeModel treeModel; - private final TimeTracker timeTracker; + private TimeTracker timeTracker; + + private WeakReferencedListeners zoomListeners = WeakReferencedListeners + .create(); private Listbox listZoomLevels; + private static final String filterResources = _("Filter by resources"); + private static final String filterCriterions = _("Filter by criterions"); + private boolean filterbyResources = true; + public ResourcesLoadPanel(List groups, TimeTracker timeTracker) { + init(groups, timeTracker); + + } + + public void init(List groups, TimeTracker timeTracker) { this.groups = groups; this.timeTracker = timeTracker; treeModel = createModelForTree(); @@ -78,6 +93,37 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { registerNeededScripts(); } + public ListModel getFilters() { + String[] filters = new String[] { filterResources, filterCriterions }; + return new SimpleListModel(filters); + } + + public void setFilter(String filterby) { + if (filterby.equals(filterResources)) { + this.filterbyResources = true; + } else { + this.filterbyResources = false; + } + } + + public boolean getFilter() { + return filterbyResources; + } + + public void onApplyFilter() { + zoomListeners + .fireEvent(new IListenerNotification() { + @Override + public void doNotify(IFilterChangedListener listener) { + listener.filterChanged(getFilter()); + } + }); + } + + public void addFilterListener(IFilterChangedListener listener) { + zoomListeners.addListener(listener); + } + public ListModel getZoomLevels() { return new SimpleListModel(ZoomLevel.values()); } @@ -192,6 +238,12 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { listZoomLevels.setSelectedIndex(timeTracker.getDetailLevel().ordinal()); } + public void clearComponents() { + getFellow("insertionPointLeftPanel").getChildren().clear(); + getFellow("insertionPointRightPanel").getChildren().clear(); + getFellow("insertionPointTimetracker").getChildren().clear(); + } + private TimeTrackerComponent createTimeTrackerHeader() { return new TimeTrackerComponent( timeTracker) { diff --git a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul index c07002122..5b0a7f20e 100644 --- a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul +++ b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul @@ -38,22 +38,14 @@ resourcesLoadPanel = self; onSelect="resourcesLoadPanel.setZoomLevel(self.selectedItem.value);" > - From: to: - Filter: - - - - - - - - - - - + + +