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.components;
029
030import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_CACHE;
031import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_COPYRIGHT;
032import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_DATE_CREATED;
033import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_DATE_EXPIRED;
034import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_DATE_MODIFIED;
035import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_DATE_RELEASED;
036import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_INSIDE_PROJECT;
037import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_IN_NAVIGATION;
038import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_IS_FOLDER;
039import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_NAVIGATION_POSITION;
040import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT;
041import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_PERMISSIONS;
042import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_PROJECT;
043import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RELEASED_NOT_EXPIRED;
044import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RESOURCE_NAME;
045import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RESOURCE_TYPE;
046import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_SITE_PATH;
047import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_SIZE;
048import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_STATE;
049import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_STATE_NAME;
050import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_TITLE;
051import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_TYPE_ICON;
052import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_USER_CREATED;
053import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_USER_LOCKED;
054import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_USER_MODIFIED;
055
056import org.opencms.ade.sitemap.shared.CmsClientSitemapEntry;
057import org.opencms.db.CmsResourceState;
058import org.opencms.file.CmsObject;
059import org.opencms.file.CmsProperty;
060import org.opencms.file.CmsPropertyDefinition;
061import org.opencms.file.CmsResource;
062import org.opencms.file.types.I_CmsResourceType;
063import org.opencms.i18n.CmsMessages;
064import org.opencms.main.CmsException;
065import org.opencms.main.CmsLog;
066import org.opencms.main.OpenCms;
067import org.opencms.ui.A_CmsUI;
068import org.opencms.ui.CmsVaadinUtils;
069import org.opencms.ui.util.I_CmsItemSorter;
070import org.opencms.util.CmsStringUtil;
071import org.opencms.util.CmsUUID;
072import org.opencms.workplace.CmsWorkplaceMessages;
073import org.opencms.workplace.explorer.CmsResourceUtil;
074
075import java.util.Arrays;
076import java.util.Collection;
077import java.util.Collections;
078import java.util.HashMap;
079import java.util.LinkedHashSet;
080import java.util.List;
081import java.util.Locale;
082import java.util.Map;
083import java.util.Set;
084
085import org.apache.commons.logging.Log;
086
087import com.google.common.collect.Lists;
088import com.google.common.collect.Sets;
089import com.vaadin.data.Item;
090import com.vaadin.data.util.IndexedContainer;
091import com.vaadin.event.dd.DropHandler;
092import com.vaadin.server.ThemeResource;
093import com.vaadin.ui.CustomComponent;
094import com.vaadin.ui.Image;
095import com.vaadin.ui.Table;
096import com.vaadin.ui.Table.RowHeaderMode;
097import com.vaadin.ui.Table.TableDragMode;
098
099/**
100 * Generic table for displaying lists of resources.<p>
101 */
102public class CmsResourceTable extends CustomComponent {
103
104    /**
105     * Helper class for easily configuring a set of columns to display, together with their visibility / collapsed status.<p>
106     */
107    public class ColumnBuilder {
108
109        /** The column entries configured so far. */
110        private List<ColumnEntry> m_columnEntries = Lists.newArrayList();
111
112        /**
113         * Sets up the table and its container using the columns configured so far.<p>
114         */
115        public void buildColumns() {
116
117            Set<CmsResourceTableProperty> visible = new LinkedHashSet<CmsResourceTableProperty>();
118            Set<CmsResourceTableProperty> collapsed = new LinkedHashSet<CmsResourceTableProperty>();
119            for (ColumnEntry entry : m_columnEntries) {
120                CmsResourceTableProperty prop = entry.getColumn();
121                m_container.addContainerProperty(prop, prop.getColumnType(), prop.getDefaultValue());
122                if (entry.isCollapsed()) {
123                    collapsed.add(entry.getColumn());
124                }
125                if (entry.isVisible()) {
126                    visible.add(entry.getColumn());
127                }
128            }
129            m_fileTable.setVisibleColumns(visible.toArray(new Object[0]));
130            setCollapsedColumns(collapsed.toArray(new Object[0]));
131            for (CmsResourceTableProperty visibleProp : visible) {
132                String headerKey = visibleProp.getHeaderKey();
133                if (!CmsStringUtil.isEmptyOrWhitespaceOnly(headerKey)) {
134                    m_fileTable.setColumnHeader(visibleProp, CmsVaadinUtils.getMessageText(headerKey));
135                } else {
136                    m_fileTable.setColumnHeader(visibleProp, "");
137                }
138                m_fileTable.setColumnCollapsible(visibleProp, visibleProp.isCollapsible());
139                if (visibleProp.getColumnWidth() > 0) {
140                    m_fileTable.setColumnWidth(visibleProp, visibleProp.getColumnWidth());
141                }
142                if (visibleProp.getExpandRatio() > 0) {
143                    m_fileTable.setColumnExpandRatio(visibleProp, visibleProp.getExpandRatio());
144                }
145                if (visibleProp.getConverter() != null) {
146                    m_fileTable.setConverter(visibleProp, visibleProp.getConverter());
147                }
148            }
149
150        }
151
152        /**
153         * Adds a new column.<p>
154         *
155         * @param prop the column
156         *
157         * @return this object
158         */
159        public ColumnBuilder column(CmsResourceTableProperty prop) {
160
161            column(prop, 0);
162            return this;
163        }
164
165        /**
166         * Adds a new column.<p<
167         *
168         * @param prop the column
169         * @param flags the flags for the column
170         *
171         * @return this object
172         */
173        public ColumnBuilder column(CmsResourceTableProperty prop, int flags) {
174
175            ColumnEntry entry = new ColumnEntry();
176            entry.setColumn(prop);
177            entry.setFlags(flags);
178            m_columnEntries.add(entry);
179            return this;
180        }
181    }
182
183    /**
184     * Contains the data for the given column, along with some flags to control visibility/collapsed status.<p>
185     *
186     */
187    public static class ColumnEntry {
188
189        /** The column. */
190        private CmsResourceTableProperty m_column;
191
192        /** The flags. */
193        private int m_flags;
194
195        /**
196         * Returns the column.<p>
197         *
198         * @return the column
199         */
200        public CmsResourceTableProperty getColumn() {
201
202            return m_column;
203        }
204
205        /**
206         * Returns the collapsed.<p>
207         *
208         * @return the collapsed
209         */
210        public boolean isCollapsed() {
211
212            return (m_flags & COLLAPSED) != 0;
213        }
214
215        /**
216         * Returns the visible.<p>
217         *
218         * @return the visible
219         */
220        public boolean isVisible() {
221
222            return 0 == (m_flags & INVISIBLE);
223        }
224
225        /**
226         * Sets the column.<p>
227         *
228         * @param column the column to set
229         */
230        public void setColumn(CmsResourceTableProperty column) {
231
232            m_column = column;
233        }
234
235        /**
236         * Sets the flags.<p>
237         *
238         * @param flags the flags to set
239         */
240        public void setFlags(int flags) {
241
242            m_flags = flags;
243        }
244
245    }
246
247    /**
248     * Extending the indexed container to make the number of un-filtered items available.<p>
249     */
250    protected static class ItemContainer extends IndexedContainer {
251
252        /** The serial version id. */
253        private static final long serialVersionUID = -2033722658471550506L;
254
255        /**
256         * @see com.vaadin.data.util.IndexedContainer#getSortableContainerPropertyIds()
257         */
258        @Override
259        public Collection<?> getSortableContainerPropertyIds() {
260
261            if (getItemSorter() instanceof I_CmsItemSorter) {
262                return ((I_CmsItemSorter)getItemSorter()).getSortableContainerPropertyIds(this);
263            } else {
264                return super.getSortableContainerPropertyIds();
265            }
266        }
267
268        /**
269         * Returns the number of items in the container, not considering any filters.<p>
270         *
271         * @return the number of items
272         */
273        protected int getItemCount() {
274
275            return getAllItemIds().size();
276        }
277    }
278
279    /** Flag to mark columns as initially collapsed.*/
280    public static final int COLLAPSED = 1;
281
282    /** Flag to mark columns as invisible. */
283    public static final int INVISIBLE = 2;
284
285    /** The logger instance for this class. */
286    private static final Log LOG = CmsLog.getLog(CmsResourceTable.class);
287
288    /** Serial version id. */
289    private static final long serialVersionUID = 1L;
290
291    /** The resource data container. */
292    protected ItemContainer m_container = new ItemContainer();
293
294    /** The table used to display the resource data. */
295    protected Table m_fileTable = new Table();
296
297    /**
298     * Creates a new instance.<p>
299     *
300     * This constructor does *not* set up the columns of the table; use the ColumnBuilder inner class for this.
301     */
302    public CmsResourceTable() {
303        m_fileTable.setContainerDataSource(m_container);
304        setCompositionRoot(m_fileTable);
305        m_fileTable.setRowHeaderMode(RowHeaderMode.HIDDEN);
306    }
307
308    /**
309     * Static helper method to initialize the 'standard' properties of a data item from a given resource.<p>
310     * @param resourceItem the resource item to fill
311     * @param cms the CMS context
312     * @param resource the resource
313     * @param messages the message bundle
314     * @param locale the locale
315     */
316    public static void fillItemDefault(
317        Item resourceItem,
318        CmsObject cms,
319        CmsResource resource,
320        CmsMessages messages,
321        Locale locale) {
322
323        if (resource == null) {
324            LOG.error("Error rendering item for 'null' resource");
325            return;
326        }
327
328        if (resourceItem == null) {
329            LOG.error("Error rendering 'null' item for resource " + resource.getRootPath());
330            return;
331        }
332        if (cms == null) {
333            cms = A_CmsUI.getCmsObject();
334            LOG.warn("CmsObject was 'null', using thread local CmsObject");
335        }
336        CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
337        Map<String, CmsProperty> resourceProps = null;
338        try {
339            List<CmsProperty> props = cms.readPropertyObjects(resource, false);
340            resourceProps = new HashMap<String, CmsProperty>();
341            for (CmsProperty prop : props) {
342                resourceProps.put(prop.getName(), prop);
343            }
344        } catch (CmsException e1) {
345            LOG.debug("Unable to read properties for resource '" + resource.getRootPath() + "'.", e1);
346        }
347        I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource);
348        if (resourceItem.getItemProperty(PROPERTY_TYPE_ICON) != null) {
349            resourceItem.getItemProperty(PROPERTY_TYPE_ICON).setValue(
350                new CmsResourceIcon(resUtil, resource.getState(), true));
351        }
352
353        if (resourceItem.getItemProperty(PROPERTY_PROJECT) != null) {
354            Image projectFlag = null;
355            switch (resUtil.getProjectState().getMode()) {
356                case 1:
357                    projectFlag = new Image(
358                        resUtil.getLockedInProjectName(),
359                        new ThemeResource(OpenCmsTheme.PROJECT_CURRENT_PATH));
360                    break;
361                case 2:
362                    projectFlag = new Image(
363                        resUtil.getLockedInProjectName(),
364                        new ThemeResource(OpenCmsTheme.PROJECT_OTHER_PATH));
365                    break;
366                case 5:
367                    projectFlag = new Image(
368                        resUtil.getLockedInProjectName(),
369                        new ThemeResource(OpenCmsTheme.PROJECT_PUBLISH_PATH));
370                    break;
371                default:
372            }
373            if (projectFlag != null) {
374                projectFlag.setDescription(resUtil.getLockedInProjectName());
375            }
376            resourceItem.getItemProperty(PROPERTY_PROJECT).setValue(projectFlag);
377        }
378
379        if (resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT) != null) {
380            resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT).setValue(Boolean.valueOf(resUtil.isInsideProject()));
381        }
382
383        if (resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED) != null) {
384            resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED).setValue(
385                Boolean.valueOf(resUtil.isReleasedAndNotExpired()));
386        }
387
388        if (resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME) != null) {
389            resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME).setValue(resource.getName());
390        }
391
392        if (resourceItem.getItemProperty(PROPERTY_SITE_PATH) != null) {
393            resourceItem.getItemProperty(PROPERTY_SITE_PATH).setValue(cms.getSitePath(resource));
394        }
395
396        if ((resourceItem.getItemProperty(PROPERTY_TITLE) != null) && (resourceProps != null)) {
397            resourceItem.getItemProperty(PROPERTY_TITLE).setValue(
398                resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_TITLE)
399                ? resourceProps.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue()
400                : "");
401        }
402        boolean inNavigation = false;
403        if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT) != null) && (resourceProps != null)) {
404            resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT).setValue(
405                resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT)
406                ? resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVTEXT).getValue()
407                : "");
408            inNavigation = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT);
409        }
410
411        if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION) != null) && (resourceProps != null)) {
412            try {
413                Float navPos = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVPOS)
414                ? Float.valueOf(resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVPOS).getValue())
415                : (inNavigation ? Float.valueOf(Float.MAX_VALUE) : null);
416                resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION).setValue(navPos);
417                inNavigation = navPos != null;
418            } catch (Exception e) {
419                LOG.debug("Error evaluating navPos property", e);
420            }
421        }
422
423        if (resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION) != null) {
424            if (inNavigation
425                && (resourceProps != null)
426                && resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVINFO)
427                && CmsClientSitemapEntry.HIDDEN_NAVIGATION_ENTRY.equals(
428                    resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVINFO).getValue())) {
429                inNavigation = false;
430            }
431            resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION).setValue(Boolean.valueOf(inNavigation));
432        }
433
434        if ((resourceItem.getItemProperty(PROPERTY_COPYRIGHT) != null) && (resourceProps != null)) {
435            resourceItem.getItemProperty(PROPERTY_COPYRIGHT).setValue(
436                resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_COPYRIGHT)
437                ? resourceProps.get(CmsPropertyDefinition.PROPERTY_COPYRIGHT).getValue()
438                : "");
439        }
440
441        if ((resourceItem.getItemProperty(PROPERTY_CACHE) != null) && (resourceProps != null)) {
442            resourceItem.getItemProperty(PROPERTY_CACHE).setValue(
443                resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_CACHE)
444                ? resourceProps.get(CmsPropertyDefinition.PROPERTY_CACHE).getValue()
445                : "");
446        }
447
448        if (resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE) != null) {
449            resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE).setValue(
450                CmsWorkplaceMessages.getResourceTypeName(locale, type.getTypeName()));
451        }
452
453        if (resourceItem.getItemProperty(PROPERTY_IS_FOLDER) != null) {
454            resourceItem.getItemProperty(PROPERTY_IS_FOLDER).setValue(Boolean.valueOf(resource.isFolder()));
455        }
456
457        if (resourceItem.getItemProperty(PROPERTY_SIZE) != null) {
458            if (resource.isFile()) {
459                resourceItem.getItemProperty(PROPERTY_SIZE).setValue(Integer.valueOf(resource.getLength()));
460            }
461        }
462
463        if (resourceItem.getItemProperty(PROPERTY_PERMISSIONS) != null) {
464            resourceItem.getItemProperty(PROPERTY_PERMISSIONS).setValue(resUtil.getPermissionString());
465        }
466
467        if (resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED) != null) {
468            resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED).setValue(Long.valueOf(resource.getDateLastModified()));
469        }
470
471        if (resourceItem.getItemProperty(PROPERTY_USER_MODIFIED) != null) {
472            resourceItem.getItemProperty(PROPERTY_USER_MODIFIED).setValue(resUtil.getUserLastModified());
473        }
474
475        if (resourceItem.getItemProperty(PROPERTY_DATE_CREATED) != null) {
476            resourceItem.getItemProperty(PROPERTY_DATE_CREATED).setValue(Long.valueOf(resource.getDateCreated()));
477        }
478
479        if (resourceItem.getItemProperty(PROPERTY_USER_CREATED) != null) {
480            resourceItem.getItemProperty(PROPERTY_USER_CREATED).setValue(resUtil.getUserCreated());
481        }
482
483        if (resourceItem.getItemProperty(PROPERTY_DATE_RELEASED) != null) {
484            long release = resource.getDateReleased();
485            if (release != CmsResource.DATE_RELEASED_DEFAULT) {
486                resourceItem.getItemProperty(PROPERTY_DATE_RELEASED).setValue(Long.valueOf(release));
487            }
488        }
489
490        if (resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED) != null) {
491            long expire = resource.getDateExpired();
492            if (expire != CmsResource.DATE_EXPIRED_DEFAULT) {
493                resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED).setValue(Long.valueOf(expire));
494            }
495        }
496
497        if (resourceItem.getItemProperty(PROPERTY_STATE_NAME) != null) {
498            resourceItem.getItemProperty(PROPERTY_STATE_NAME).setValue(resUtil.getStateName());
499        }
500
501        if (resourceItem.getItemProperty(PROPERTY_STATE) != null) {
502            resourceItem.getItemProperty(PROPERTY_STATE).setValue(resource.getState());
503        }
504
505        if (resourceItem.getItemProperty(PROPERTY_USER_LOCKED) != null) {
506            resourceItem.getItemProperty(PROPERTY_USER_LOCKED).setValue(resUtil.getLockedByName());
507        }
508    }
509
510    /**
511     * Gets the CSS style name for the given resource state.<p>
512     *
513     * @param state the resource state
514     * @return the CSS style name
515     */
516    public static String getStateStyle(CmsResourceState state) {
517
518        String stateStyle = "";
519        if (state != null) {
520            if (state.isDeleted()) {
521                stateStyle = OpenCmsTheme.STATE_DELETED;
522            } else if (state.isNew()) {
523                stateStyle = OpenCmsTheme.STATE_NEW;
524            } else if (state.isChanged()) {
525                stateStyle = OpenCmsTheme.STATE_CHANGED;
526            }
527        }
528        return stateStyle;
529    }
530
531    /**
532     * Clears the value selection.<p>
533     */
534    public void clearSelection() {
535
536        m_fileTable.setValue(Collections.emptySet());
537    }
538
539    /**
540     * Fills the resource table.<p>
541     *
542     * @param cms the current CMS context
543     * @param resources the resources which should be displayed in the table
544     */
545    public void fillTable(CmsObject cms, List<CmsResource> resources) {
546
547        fillTable(cms, resources, true);
548    }
549
550    /**
551     * Fills the resource table.<p>
552     *
553     * @param cms the current CMS context
554     * @param resources the resources which should be displayed in the table
555     * @param clearFilter <code>true</code> to clear the search filter
556     */
557    public void fillTable(CmsObject cms, List<CmsResource> resources, boolean clearFilter) {
558
559        Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
560        m_container.removeAllItems();
561        if (clearFilter) {
562            m_container.removeAllContainerFilters();
563        }
564        for (CmsResource resource : resources) {
565            fillItem(cms, resource, wpLocale);
566        }
567        m_fileTable.sort();
568        clearSelection();
569    }
570
571    /**
572     * Gets structure ids of resources for current folder in current sort order.<p>
573     *
574     * @return the structure ids of the current folder contents
575     */
576    public List<CmsUUID> getAllIds() {
577
578        @SuppressWarnings("unchecked")
579        List<CmsUUID> ids = (List<CmsUUID>)(m_fileTable.getContainerDataSource().getItemIds());
580        return Lists.newArrayList(ids);
581    }
582
583    /**
584     * Returns the number of currently visible items.<p>
585     *
586     * @return the number of currentliy visible items
587     */
588    public int getItemCount() {
589
590        return m_container.getItemCount();
591    }
592
593    /**
594     * Returns if the column with the given property id is visible and not collapsed.<p>
595     *
596     * @param propertyId the property id
597     *
598     * @return <code>true</code> if the column is visible
599     */
600    public boolean isColumnVisible(CmsResourceTableProperty propertyId) {
601
602        return Arrays.asList(m_fileTable.getVisibleColumns()).contains(propertyId)
603            && !m_fileTable.isColumnCollapsed(propertyId);
604    }
605
606    /**
607     * Selects all resources.<p>
608     */
609    public void selectAll() {
610
611        m_fileTable.setValue(m_fileTable.getItemIds());
612    }
613
614    /**
615     * Sets the list of collapsed columns.<p>
616     *
617     * @param collapsedColumns the list of collapsed columns
618     */
619    public void setCollapsedColumns(Object... collapsedColumns) {
620
621        Set<Object> collapsedSet = Sets.newHashSet();
622        for (Object collapsed : collapsedColumns) {
623            collapsedSet.add(collapsed);
624        }
625        for (Object key : m_fileTable.getVisibleColumns()) {
626            m_fileTable.setColumnCollapsed(key, collapsedSet.contains(key));
627        }
628    }
629
630    /**
631     * Sets the table drag mode.<p>
632     *
633     * @param dragMode the drag mode
634     */
635    public void setDragMode(TableDragMode dragMode) {
636
637        m_fileTable.setDragMode(dragMode);
638    }
639
640    /**
641     * Sets the table drop handler.<p>
642     *
643     * @param handler the drop handler
644     */
645    public void setDropHandler(DropHandler handler) {
646
647        m_fileTable.setDropHandler(handler);
648    }
649
650    /**
651     * Fills the file item data.<p>
652     *
653     * @param cms the cms context
654     * @param resource the resource
655     * @param locale the workplace locale
656     */
657    protected void fillItem(CmsObject cms, CmsResource resource, Locale locale) {
658
659        Item resourceItem = m_container.getItem(resource.getStructureId());
660        if (resourceItem == null) {
661            resourceItem = m_container.addItem(resource.getStructureId());
662        }
663        fillItemDefault(resourceItem, cms, resource, CmsVaadinUtils.getWpMessagesForCurrentLocale(), locale);
664    }
665
666}