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     * Gets the warning message.
177     * 
178     * @return the warning message 
179     */
180    public String getWarning() {
181
182        return m_data.getWarning();
183    }
184
185    /**
186     * @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)
187     */
188    public void handleSubmit(
189        String newUrlName,
190        String vfsPath,
191        final List<CmsPropertyModification> propertyChanges,
192        boolean editedName,
193        CmsReloadMode reloadMode) {
194
195        // ignore reloadMode; it's only relevant for the sitemap editor
196
197        final I_CmsVfsServiceAsync vfsService = CmsCoreProvider.getVfsService();
198        CmsRpcAction<Void> saveAction = new CmsRpcAction<Void>() {
199
200            @Override
201            public void execute() {
202
203                start(300, false);
204                CmsPropertyChangeSet changeBean = new CmsPropertyChangeSet(m_data.getStructureId(), propertyChanges);
205                vfsService.saveProperties(changeBean, true, this);
206            }
207
208            @Override
209            protected void onResponse(Void result) {
210
211                stop(false);
212                m_dialog.runAction();
213
214            }
215        };
216        saveAction.execute();
217    }
218
219    /**
220     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#hasEditableName()
221     */
222    public boolean hasEditableName() {
223
224        return false;
225    }
226
227    /**
228     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isFolder()
229     */
230    public boolean isFolder() {
231
232        // TODO: Auto-generated method stub
233        return false;
234    }
235
236    /**
237     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isHiddenProperty(java.lang.String)
238     */
239    public boolean isHiddenProperty(String key) {
240
241        // TODO: Auto-generated method stub
242        return false;
243    }
244
245    /**
246     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#isSimpleMode()
247     */
248    public boolean isSimpleMode() {
249
250        return false;
251    }
252
253    /**
254     * Sets the dialog instance.<p>
255     *
256     * @param dialog the dialog used for editing the properties
257     */
258    public void setDialog(CmsUploadPropertyDialog dialog) {
259
260        m_dialog = dialog;
261    }
262
263    /**
264     * @see org.opencms.gwt.client.property.I_CmsPropertyEditorHandler#useAdeTemplates()
265     */
266    public boolean useAdeTemplates() {
267
268        return false;
269    }
270
271}