001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (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.postupload.client.ui;
029
030import org.opencms.ade.postupload.shared.CmsPostUploadDialogPanelBean;
031import org.opencms.gwt.client.CmsCoreProvider;
032import org.opencms.gwt.client.property.CmsReloadMode;
033import org.opencms.gwt.client.property.I_CmsPropertyEditorHandler;
034import org.opencms.gwt.client.rpc.CmsRpcAction;
035import org.opencms.gwt.shared.CmsListInfoBean;
036import org.opencms.gwt.shared.property.CmsClientProperty;
037import org.opencms.gwt.shared.property.CmsClientTemplateBean;
038import org.opencms.gwt.shared.property.CmsPropertyChangeSet;
039import org.opencms.gwt.shared.property.CmsPropertyModification;
040import org.opencms.gwt.shared.rpc.I_CmsVfsServiceAsync;
041import org.opencms.util.CmsUUID;
042
043import java.util.ArrayList;
044import java.util.Collections;
045import java.util.List;
046import java.util.Map;
047
048/**
049 * The property editor handler class for editing properties of uploaded files.<p>
050 */
051public class CmsUploadPropertyEditorHandler implements I_CmsPropertyEditorHandler {
052
053    /** The data used for editing the properties of a single resource. */
054    CmsPostUploadDialogPanelBean m_data;
055
056    /** The dialog containing the property editor. */
057    CmsUploadPropertyDialog m_dialog;
058
059    /**
060     * Creates a new instance.<p>
061     *
062     * @param dialog the dialog containing the property editor
063     * @param data the data for editing the properties
064     */
065    public CmsUploadPropertyEditorHandler(CmsUploadPropertyDialog dialog, CmsPostUploadDialogPanelBean data) {
066
067        m_data = data;
068        m_dialog = dialog;
069    }
070
071    /**
072     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getAllPropertyNames()
073     */
074    public List<String> getAllPropertyNames() {
075
076        return new ArrayList<String>(m_data.getPropertyDefinitions().keySet());
077    }
078
079    /**
080     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDefaultFileId()
081     */
082    public CmsUUID getDefaultFileId() {
083
084        return null;
085    }
086
087    /**
088     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDefaultFileProperties()
089     */
090    public Map<String, CmsClientProperty> getDefaultFileProperties() {
091
092        return null;
093    }
094
095    /**
096     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getDialogTitle()
097     */
098    public String getDialogTitle() {
099
100        return "DUMMY TITLE";
101    }
102
103    /**
104     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getForbiddenUrlNames()
105     */
106    public List<String> getForbiddenUrlNames() {
107
108        return Collections.emptyList();
109    }
110
111    /**
112     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getId()
113     */
114    public CmsUUID getId() {
115
116        return m_data.getStructureId();
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 null;
125    }
126
127    /**
128     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getModeClass()
129     */
130    public String getModeClass() {
131
132        return null;
133    }
134
135    /**
136     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getName()
137     */
138    public String getName() {
139
140        return m_data.getStructureId().toString();
141    }
142
143    /**
144     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getOwnProperties()
145     */
146    public Map<String, CmsClientProperty> getOwnProperties() {
147
148        return m_data.getProperties();
149    }
150
151    /**
152     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPageInfo()
153     */
154    public CmsListInfoBean getPageInfo() {
155
156        return m_data.getInfoBean();
157    }
158
159    /**
160     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPath()
161     */
162    public String getPath() {
163
164        return "DUMMY PATH";
165    }
166
167    /**
168     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#getPossibleTemplates()
169     */
170    public Map<String, CmsClientTemplateBean> getPossibleTemplates() {
171
172        return null;
173    }
174
175    /**
176     * @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)
177     */
178    public void handleSubmit(
179        String newUrlName,
180        String vfsPath,
181        final List<CmsPropertyModification> propertyChanges,
182        boolean editedName,
183        CmsReloadMode reloadMode) {
184
185        // ignore reloadMode; it's only relevant for the sitemap editor
186
187        final I_CmsVfsServiceAsync vfsService = CmsCoreProvider.getVfsService();
188        CmsRpcAction<Void> saveAction = new CmsRpcAction<Void>() {
189
190            @Override
191            public void execute() {
192
193                start(300, false);
194                CmsPropertyChangeSet changeBean = new CmsPropertyChangeSet(m_data.getStructureId(), propertyChanges);
195                vfsService.saveProperties(changeBean, this);
196            }
197
198            @Override
199            protected void onResponse(Void result) {
200
201                stop(false);
202                m_dialog.runAction();
203
204            }
205        };
206        saveAction.execute();
207    }
208
209    /**
210     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#hasEditableName()
211     */
212    public boolean hasEditableName() {
213
214        return false;
215    }
216
217    /**
218     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isFolder()
219     */
220    public boolean isFolder() {
221
222        // TODO: Auto-generated method stub
223        return false;
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        // TODO: Auto-generated method stub
232        return false;
233    }
234
235    /**
236     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isSimpleMode()
237     */
238    public boolean isSimpleMode() {
239
240        return false;
241    }
242
243    /**
244     * Sets the dialog instance.<p>
245     *
246     * @param dialog the dialog used for editing the properties
247     */
248    public void setDialog(CmsUploadPropertyDialog dialog) {
249
250        m_dialog = dialog;
251    }
252
253    /**
254     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#useAdeTemplates()
255     */
256    public boolean useAdeTemplates() {
257
258        return false;
259    }
260
261}