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