001/*
002 * #%L
003 * GwtMaterial
004 * %%
005 * Copyright (C) 2015 - 2017 GwtMaterialDesign
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 * 
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 * 
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package gwt.material.design.client.data;
021
022import gwt.material.design.client.data.component.CategoryComponent;
023import gwt.material.design.client.data.component.ComponentFactory;
024import gwt.material.design.client.data.factory.CategoryComponentFactory;
025
026import java.util.List;
027
028public interface HasCategories {
029
030    /**
031     * Set your own custom {@link CategoryComponentFactory} to generate your categories.
032     */
033    void setCategoryFactory(ComponentFactory<? extends CategoryComponent, String> categoryFactory);
034
035    /**
036     * Get a stored category component.
037     * @param categoryName name of the category component.
038     */
039    CategoryComponent getCategory(String categoryName);
040
041    /**
042     * Get all registered category components.
043     */
044    List<CategoryComponent> getCategories();
045
046    /**
047     * Get all the open {@link CategoryComponent}'s or null if categories are disabled.
048     */
049    List<CategoryComponent> getOpenCategories();
050
051    /**
052     * Check if a category has data to provide.
053     */
054    boolean isCategoryEmpty(CategoryComponent category);
055
056    /**
057     * Explicitly add a category, which will be drawn to the table.
058     * If the category already exists then it will be ignored.
059     * @param category The category name.
060     */
061    void addCategory(String category);
062
063    /**
064     * Explicitly add a {@link CategoryComponent}, which will be drawn to the table.
065     * If the category already exists then it will be ignored.
066     * @param category The category data defined.
067     */
068    void addCategory(CategoryComponent category);
069
070    /**
071     * Has this data view got an existing {@link CategoryComponent} with given name.
072     */
073    boolean hasCategory(String categoryName);
074
075    /**
076     * Disable a data view category.
077     */
078    void disableCategory(String categoryName);
079
080    /**
081     * Enable a data view category.
082     */
083    void enableCategory(String categoryName);
084
085    /**
086     * Open an existing Category.
087     */
088    void openCategory(String categoryName);
089
090    /**
091     * Open an existing Category.
092     */
093    void openCategory(CategoryComponent category);
094
095    /**
096     * Close an existing Category.
097     */
098    void closeCategory(String categoryName);
099
100    /**
101     * Close an existing Category.
102     */
103    void closeCategory(CategoryComponent category);
104
105    /**
106     * Clear all rows and categories.
107     *
108     * @param clearData should we also clear the stored data.
109     */
110    void clearRowsAndCategories(boolean clearData);
111
112    /**
113     * Clear all categories.
114     */
115    void clearCategories();
116}