001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.galleries.client;
029
030import org.opencms.ade.galleries.shared.CmsGalleryFolderBean;
031import org.opencms.ade.galleries.shared.CmsGallerySearchBean;
032import org.opencms.ade.galleries.shared.CmsResourceTypeBean;
033import org.opencms.util.CmsUUID;
034
035import com.google.gwt.event.logical.shared.CloseEvent;
036import com.google.gwt.event.logical.shared.CloseHandler;
037import com.google.gwt.event.logical.shared.ValueChangeHandler;
038import com.google.gwt.event.shared.HandlerRegistration;
039import com.google.gwt.user.client.ui.PopupPanel;
040
041/**
042 * The abstract class for the tab handler.<p>
043 *
044 * This class receives event information from the gallery dialog and
045 * delegates it to the gallery controller.
046 *
047 * @since 8.0.0
048 */
049public abstract class A_CmsTabHandler implements CloseHandler<PopupPanel> {
050
051    /** The gallery controller. */
052    protected CmsGalleryController m_controller;
053
054    /**
055     * Constructor.<p>
056     *
057     * @param controller the controller
058     */
059    public A_CmsTabHandler(CmsGalleryController controller) {
060
061        m_controller = controller;
062    }
063
064    /**
065     * Adds a change handler for the gallery search bean.<p>
066     *
067     * @param handler the handler
068     *
069     * @return the handler registration
070     */
071    public HandlerRegistration addSearchChangeHandler(ValueChangeHandler<CmsGallerySearchBean> handler) {
072
073        return m_controller.addValueChangeHandler(handler);
074    }
075
076    /**
077     * Clears the search parameters of this tab.<p>
078     */
079    public abstract void clearParams();
080
081    /**
082     * Returns the gallery folder info to the given path.<p>
083     *
084     * @param galleryPath the gallery folder path
085     *
086     * @return the gallery folder info
087     */
088    public CmsGalleryFolderBean getGalleryInfo(String galleryPath) {
089
090        return m_controller.getGalleryInfo(galleryPath);
091    }
092
093    /**
094     * Returns the resource type info for the given resource type name.<p>
095     *
096     * @param typeName the resource type name
097     *
098     * @return the type info
099     */
100    public CmsResourceTypeBean getTypeInfo(String typeName) {
101
102        return m_controller.getTypeInfo(typeName);
103    }
104
105    /**
106     * Execute when the upload dialog is closed.<p>
107     *
108     * @param event the close event
109     */
110    public void onClose(CloseEvent<PopupPanel> event) {
111
112        m_controller.setSearchObjectChanged();
113    }
114
115    /**
116     * Will be triggered when the tab is deselected.<p>
117     */
118    public void onDeselection() {
119
120        // do nothing
121    }
122
123    /**
124     * Will be triggered when the tab is selected.<p>
125     */
126    public abstract void onSelection();
127
128    /**
129     * Sorts the list, if present.<p>
130     *
131     * @param sortParams the sort parameters
132     * @param filter the filter phrase
133     */
134    public abstract void onSort(String sortParams, String filter);
135
136    /**
137     * Removes the search parameter with the given key from the search object.<p>
138     *
139     * @param paramKey the parameter key
140     */
141    public abstract void removeParam(String paramKey);
142
143    /**
144     * Selects the given resource and sets its path into the xml-content field or editor link.<p>
145     *
146     * @param resourcePath the item resource path
147     * @param structureId the structure id
148     * @param title the resource title
149     * @param resourceType the item resource type
150     */
151    public void selectResource(String resourcePath, CmsUUID structureId, String title, String resourceType) {
152
153        m_controller.selectResource(resourcePath, structureId, title, resourceType);
154    }
155
156    /**
157     * Selects the result tab.<p>
158     */
159    public void selectResultTab() {
160
161        m_controller.selectResultTab();
162    }
163
164    /**
165     * Delegates the clear input action (click on the clear button) to the controller.<p>
166     *
167     * @param searchQuery the search query
168     */
169    public void setSearchQuery(String searchQuery) {
170
171        m_controller.addSearchQuery(searchQuery);
172    }
173
174    /**
175     * Updates the gallery index and triggers a new search afterwards.<p>
176     */
177    public void updateIndex() {
178
179        m_controller.updateIndex();
180    }
181
182    /**
183     * Updates the tab size.<p>
184     */
185    public void updateSize() {
186
187        m_controller.updateActiveTabSize();
188    }
189
190}