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.sitemap.client.edit;
029
030import org.opencms.ade.sitemap.client.CmsSitemapView;
031import org.opencms.ade.sitemap.client.Messages;
032import org.opencms.ade.sitemap.client.ui.css.I_CmsSitemapLayoutBundle;
033import org.opencms.ade.sitemap.shared.CmsLocaleComparePropertyData;
034import org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapServiceAsync;
035import org.opencms.gwt.client.property.CmsReloadMode;
036import org.opencms.gwt.client.property.I_CmsPropertyEditorHandler;
037import org.opencms.gwt.client.rpc.CmsRpcAction;
038import org.opencms.gwt.client.util.CmsJsUtil;
039import org.opencms.gwt.shared.CmsGwtConstants;
040import org.opencms.gwt.shared.CmsListInfoBean;
041import org.opencms.gwt.shared.property.CmsClientProperty;
042import org.opencms.gwt.shared.property.CmsClientTemplateBean;
043import org.opencms.gwt.shared.property.CmsPropertyModification;
044import org.opencms.util.CmsUUID;
045
046import java.util.List;
047import java.util.Map;
048
049/**
050 * Property submission handler for the sitemap editor's locale comparison mode.<p>
051 */
052public class CmsLocaleComparePropertyHandler implements I_CmsPropertyEditorHandler {
053
054    private String m_defaultFilePath;
055
056    /** The property data loaded from the server. */
057    private CmsLocaleComparePropertyData m_data;
058
059    /** The page information. */
060    private CmsListInfoBean m_pageInfo;
061
062    /**
063     * Creates a new instance.<p>
064     *
065     * @param data the property data loaded from the server
066     */
067    public CmsLocaleComparePropertyHandler(CmsLocaleComparePropertyData data) {
068
069        m_data = data;
070    }
071
072    /**
073     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getAllPropertyNames()
074     */
075    public List<String> getAllPropertyNames() {
076
077        return CmsSitemapView.getInstance().getController().getData().getAllPropertyNames();
078
079    }
080
081    /**
082     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDefaultFileId()
083     */
084    public CmsUUID getDefaultFileId() {
085
086        return m_data.getDefaultFileId();
087    }
088
089    /**
090     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDefaultFilePath()
091     */
092    public String getDefaultFilePath() {
093
094        return m_defaultFilePath;
095    }
096
097    /**
098     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDefaultFileProperties()
099     */
100    public Map<String, CmsClientProperty> getDefaultFileProperties() {
101
102        return m_data.getDefaultFileProperties();
103    }
104
105    /**
106     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDialogTitle()
107     */
108    public String getDialogTitle() {
109
110        return Messages.get().key(Messages.GUI_PROPERTY_EDITOR_TITLE_0);
111    }
112
113    /**
114     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getForbiddenUrlNames()
115     */
116    public List<String> getForbiddenUrlNames() {
117
118        return m_data.getForbiddenUrlNames();
119    }
120
121    /**
122     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getId()
123     */
124    public CmsUUID getId() {
125
126        return m_data.getId();
127    }
128
129    /**
130     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getInheritedProperty(java.lang.String)
131     */
132    public CmsClientProperty getInheritedProperty(String name) {
133
134        return m_data.getInheritedProperty(name);
135    }
136
137    /**
138     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getModeClass()
139     */
140    public String getModeClass() {
141
142        return I_CmsSitemapLayoutBundle.INSTANCE.sitemapItemCss().navMode();
143    }
144
145    /**
146     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getName()
147     */
148    public String getName() {
149
150        return m_data.getName();
151
152    }
153
154    /**
155     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getOwnProperties()
156     */
157    public Map<String, CmsClientProperty> getOwnProperties() {
158
159        return m_data.getOwnProperties();
160    }
161
162    /**
163     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPageInfo()
164     */
165    public CmsListInfoBean getPageInfo() {
166
167        return m_pageInfo;
168    }
169
170    /**
171     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPath()
172     */
173    public String getPath() {
174
175        return m_data.getPath();
176    }
177
178    /**
179     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPossibleTemplates()
180     */
181    public Map<String, CmsClientTemplateBean> getPossibleTemplates() {
182
183        // TODO Auto-generated method stub
184        return null;
185    }
186
187    /**
188     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#handleSubmit(java.lang.String, java.lang.String, java.util.List, boolean, org.opencms.gwt.client.property.CmsReloadMode)
189     */
190    public void handleSubmit(
191        final String newUrlName,
192        String vfsPath,
193        final List<CmsPropertyModification> propertyChanges,
194        final boolean editedName,
195        CmsReloadMode reloadMode) {
196
197        final CmsUUID id = m_data.getId();
198        final I_CmsSitemapServiceAsync service = CmsSitemapView.getInstance().getController().getService();
199        CmsRpcAction<Void> action = new CmsRpcAction<Void>() {
200
201            @Override
202            public void execute() {
203
204                start(0, false);
205                service.savePropertiesForLocaleCompareMode(id, newUrlName, propertyChanges, editedName, this);
206            }
207
208            @Override
209            protected void onResponse(Void result) {
210
211                stop(false);
212                CmsJsUtil.callNamedFunctionWithString(CmsGwtConstants.CALLBACK_HANDLE_CHANGED_PROPERTIES, "" + id);
213
214            }
215        };
216        action.execute();
217    }
218
219    /**
220     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#hasEditableName()
221     */
222    public boolean hasEditableName() {
223
224        return m_data.hasEditableName();
225    }
226
227    /**
228     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isFolder()
229     */
230    public boolean isFolder() {
231
232        return m_data.isFolder();
233    }
234
235    /**
236     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isHiddenProperty(java.lang.String)
237     */
238    public boolean isHiddenProperty(String key) {
239
240        return false;
241    }
242
243    /**
244     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isSimpleMode()
245     */
246    public boolean isSimpleMode() {
247
248        return true;
249    }
250
251    /**
252     * Sets the default file path.
253     *
254     * @param defaultFilePath the default file path
255     */
256    public void setDefaultFilePath(String defaultFilePath) {
257
258        m_defaultFilePath = defaultFilePath;
259    }
260
261    /**
262     * Sets the page information.<p>
263     *
264     * @param pageInfo the page information
265     */
266    public void setPageInfo(CmsListInfoBean pageInfo) {
267
268        m_pageInfo = pageInfo;
269
270    }
271
272    /**
273     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#useAdeTemplates()
274     */
275    public boolean useAdeTemplates() {
276
277        return true;
278    }
279
280}