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.ui;
029
030import org.opencms.file.CmsObject;
031import org.opencms.file.CmsProject;
032import org.opencms.file.CmsResource;
033import org.opencms.ui.components.CmsBasicDialog.DialogWidth;
034import org.opencms.util.CmsUUID;
035
036import java.util.Collection;
037import java.util.Collections;
038import java.util.List;
039import java.util.Map;
040
041import com.vaadin.ui.Component;
042import com.vaadin.ui.Window;
043
044/**
045 * Context for dialogs opened from the context menu.<p>
046 */
047public interface I_CmsDialogContext {
048
049    /**
050     * The available context types.<p>
051     */
052    enum ContextType {
053        /** The app toolbar context. */
054        appToolbar,
055
056        /** The container page toolbar context. */
057        containerpageToolbar,
058
059        /** The file table context. */
060        fileTable,
061
062        /** The sitemap toolbar context. */
063        sitemapToolbar
064    }
065
066    /** Request context attribute used to pass the sitemap configuration to sitemap context menu items. */
067    public static final String ATTR_SITEMAP_CONFIG_RESOURCE = "sitemap_config_resource";
068
069    /**
070     * Signals an error which occurred in the dialog.<p>
071     *
072     * @param error the error which occcurred
073     */
074    void error(Throwable error);
075
076    /**
077     * Signals that the dialog has finished.<p>
078     * Call when current project and or site have been changed.<p>
079     *
080     * @param project changed project
081     * @param siteRoot changed site root
082     */
083    void finish(CmsProject project, String siteRoot);
084
085    /**
086     * Signals that the dialog has finished.<p>
087     *
088     * @param result the list of structure ids of changed resources
089     */
090    void finish(Collection<CmsUUID> result);
091
092    /**
093     * Tell the system that the resource with the given id should be shown somehow.<p>
094     *
095     * @param structureId the structure id of a resource
096     */
097    void focus(CmsUUID structureId);
098
099    /**
100     * Gets a list of structure ids of all visible resources, not just the ones selected for the dialog.<p>
101     *
102     * @return the structure ids of all the resources in the current view
103     */
104    List<CmsUUID> getAllStructureIdsInView();
105
106    /**
107     * Returns the app id.<p>
108     *
109     * @return the app id
110     */
111    String getAppId();
112
113    /**
114     * Gets the CMS context to be used for dialog operations.<p>
115     *
116     * @return the CMS context
117     */
118    CmsObject getCms();
119
120    /**
121     * Returns the context type.<p>
122     * May be used for visibility evaluation.<p>
123     *
124     * @return the context type
125     */
126    ContextType getContextType();
127
128    /**
129     * Gets additional parameters.
130     *
131     * @return the map of additional parameters
132     */
133    default Map<String, String> getParameters() {
134
135        return Collections.emptyMap();
136    }
137
138    /**
139     * Gets the list of resources for which the dialog should be opened.<p>
140     *
141     * @return the list of resources
142     */
143    List<CmsResource> getResources();
144
145    /**
146     * Navigates to the given app.<p>
147     *
148     * @param appId the app id
149     */
150    void navigateTo(String appId);
151
152    /**
153     * Call when the dialog view has changed to re-center the dialog window.<p>
154     */
155    void onViewChange();
156
157    /**
158     * Reloads the UI.<p>
159     */
160    void reload();
161
162    /**
163     * Sets the current window.<p>
164     *
165     * @param window the current dialog window
166     */
167    void setWindow(Window window);
168
169    /**
170     * Called to start up the dialog with the given main widget and title string.<p>
171     *
172     * @param title the title to display
173     * @param dialog the dialog main widget
174     */
175    void start(String title, Component dialog);
176
177    /**
178     * Called to start up the dialog with the given main widget and title string.<p>
179     *
180     * @param title the title to display
181     * @param dialog the dialog main widget
182     * @param width the preferred width for the dialog
183     */
184    void start(String title, Component dialog, DialogWidth width);
185
186    /**
187     * Called when the user info was changed.<p>
188     */
189    void updateUserInfo();
190
191}