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.apps.projects;
029
030import org.opencms.file.CmsObject;
031import org.opencms.file.CmsProject;
032import org.opencms.main.CmsException;
033import org.opencms.main.CmsLog;
034import org.opencms.main.OpenCms;
035import org.opencms.ui.A_CmsUI;
036import org.opencms.ui.CmsCssIcon;
037import org.opencms.ui.CmsVaadinUtils;
038import org.opencms.ui.apps.A_CmsWorkplaceApp;
039import org.opencms.ui.apps.CmsAppWorkplaceUi;
040import org.opencms.ui.apps.Messages;
041import org.opencms.ui.components.CmsBasicDialog;
042import org.opencms.ui.components.CmsBasicDialog.DialogWidth;
043import org.opencms.ui.components.CmsConfirmationDialog;
044import org.opencms.ui.components.CmsErrorDialog;
045import org.opencms.ui.components.CmsResourceInfo;
046import org.opencms.ui.components.OpenCmsTheme;
047import org.opencms.ui.components.extensions.CmsGwtDialogExtension;
048import org.opencms.ui.contextmenu.CmsContextMenu;
049import org.opencms.ui.contextmenu.CmsMenuItemVisibilityMode;
050import org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry;
051import org.opencms.util.CmsStringUtil;
052import org.opencms.util.CmsUUID;
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import java.util.Locale;
058import java.util.Set;
059
060import org.apache.commons.logging.Log;
061
062import com.vaadin.server.Resource;
063import com.vaadin.shared.MouseEventDetails.MouseButton;
064import com.vaadin.ui.UI;
065import com.vaadin.ui.VerticalLayout;
066import com.vaadin.ui.Window;
067import com.vaadin.ui.themes.ValoTheme;
068import com.vaadin.v7.data.Item;
069import com.vaadin.v7.data.util.IndexedContainer;
070import com.vaadin.v7.data.util.filter.Or;
071import com.vaadin.v7.data.util.filter.SimpleStringFilter;
072import com.vaadin.v7.event.ItemClickEvent;
073import com.vaadin.v7.event.ItemClickEvent.ItemClickListener;
074import com.vaadin.v7.ui.Label;
075import com.vaadin.v7.ui.Table;
076
077/**
078 * The projects table.<p>
079 */
080public class CmsProjectsTable extends Table {
081
082    public static class ProjectResources extends ArrayList<String> {
083
084        public ProjectResources(List<String> origin) {
085
086            super(origin);
087        }
088
089        @Override
090        public String toString() {
091
092            return CmsStringUtil.listAsString(this, ", ");
093        }
094
095    }
096
097    /**
098     * The delete project context menu entry.<p>
099     */
100    class DeleteEntry implements I_CmsSimpleContextMenuEntry<Set<CmsUUID>> {
101
102        /**
103         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#executeAction(java.lang.Object)
104         */
105        public void executeAction(final Set<CmsUUID> data) {
106
107            List<CmsResourceInfo> projectInfos = new ArrayList<CmsResourceInfo>();
108            String message;
109            CmsCssIcon projectIcon = new CmsCssIcon(OpenCmsTheme.ICON_PROJECT);
110            if (data.size() == 1) {
111                Item item = m_container.getItem(data.iterator().next());
112                message = CmsVaadinUtils.getMessageText(
113                    Messages.GUI_PROJECTS_CONFIRM_DELETE_PROJECT_1,
114                    item.getItemProperty(PROP_NAME).getValue());
115                projectInfos.add(
116                    new CmsResourceInfo(
117                        (String)item.getItemProperty(PROP_NAME).getValue(),
118                        (String)item.getItemProperty(PROP_DESCRIPTION).getValue(),
119                        projectIcon));
120            } else {
121                message = "";
122                for (CmsUUID id : data) {
123                    if (message.length() > 0) {
124                        message += ", ";
125                    }
126                    Item item = m_container.getItem(id);
127                    message += item.getItemProperty(PROP_NAME).getValue();
128                    projectInfos.add(
129                        new CmsResourceInfo(
130                            (String)item.getItemProperty(PROP_NAME).getValue(),
131                            (String)item.getItemProperty(PROP_DESCRIPTION).getValue(),
132                            projectIcon));
133                }
134                message = CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_CONFIRM_DELETE_PROJECTS_1, message);
135            }
136
137            CmsConfirmationDialog.show(
138                CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DELETE_0),
139                message,
140                new Runnable() {
141
142                    public void run() {
143
144                        for (CmsUUID projectId : data) {
145                            try {
146                                A_CmsUI.getCmsObject().deleteProject(projectId);
147                                CmsAppWorkplaceUi.get().reload();
148                            } catch (CmsException e) {
149                                LOG.error("Error deleting project " + projectId, e);
150                                displayException(e);
151                            }
152                        }
153                    }
154                }).displayResourceInfoDirectly(projectInfos);
155        }
156
157        /**
158         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getTitle(java.util.Locale)
159         */
160        public String getTitle(Locale locale) {
161
162            return CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DELETE_0);
163        }
164
165        /**
166         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getVisibility(java.lang.Object)
167         */
168        public CmsMenuItemVisibilityMode getVisibility(Set<CmsUUID> data) {
169
170            return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
171        }
172    }
173
174    /**
175     * The edit project context menu entry.<p>
176     */
177    class EditEntry implements I_CmsSimpleContextMenuEntry<Set<CmsUUID>> {
178
179        /**
180         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#executeAction(java.lang.Object)
181         */
182        public void executeAction(Set<CmsUUID> data) {
183
184            CmsUUID id = data.iterator().next();
185
186            Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
187            CmsEditProjectForm form = new CmsEditProjectForm(CmsProjectsTable.this, id, window);
188            window.setContent(form);
189            window.setCaption(
190                CmsVaadinUtils.getMessageText(
191                    Messages.GUI_PROJECTS_EDIT_1,
192                    m_container.getItem(id).getItemProperty(PROP_NAME).getValue()));
193            A_CmsUI.get().addWindow(window);
194            window.center();
195        }
196
197        /**
198         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getTitle(java.util.Locale)
199         */
200        public String getTitle(Locale locale) {
201
202            return CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_EDIT_0);
203        }
204
205        /**
206         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getVisibility(java.lang.Object)
207         */
208        public CmsMenuItemVisibilityMode getVisibility(Set<CmsUUID> data) {
209
210            return (data != null) && (data.size() == 1)
211            ? CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE
212            : CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE;
213        }
214    }
215
216    /**
217     * The publish project context menu entry.<p>
218     */
219    class PublishEntry implements I_CmsSimpleContextMenuEntry<Set<CmsUUID>> {
220
221        /**
222         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#executeAction(java.lang.Object)
223         */
224        public void executeAction(Set<CmsUUID> data) {
225
226            CmsUUID projectId = data.iterator().next();
227            CmsAppWorkplaceUi.get().disableGlobalShortcuts();
228            CmsGwtDialogExtension extension = new CmsGwtDialogExtension(A_CmsUI.get(), null);
229            try {
230                extension.openPublishDialog(A_CmsUI.getCmsObject().readProject(projectId));
231            } catch (CmsException e) {
232                LOG.error("Error reading project " + projectId, e);
233                displayException(e);
234            }
235        }
236
237        /**
238         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getTitle(java.util.Locale)
239         */
240        public String getTitle(Locale locale) {
241
242            return CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_PUBLISH_0);
243        }
244
245        /**
246         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getVisibility(java.lang.Object)
247         */
248        public CmsMenuItemVisibilityMode getVisibility(Set<CmsUUID> data) {
249
250            if ((data != null) && (data.size() == 1)) {
251                if (A_CmsUI.getCmsObject().getRequestContext().getCurrentProject().isOnlineProject()) {
252                    return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE;
253                }
254                CmsUUID projectId = data.iterator().next();
255                try {
256                    return A_CmsUI.getCmsObject().countLockedResources(projectId) == 0
257                    ? CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE
258                    : CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE;
259                } catch (CmsException e) {
260                    LOG.error("Error reading locked resources on project " + projectId, e);
261                }
262            }
263            return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE;
264        }
265    }
266
267    /**
268     * The show project files context menu entry.<p>
269     */
270    class ShowFilesEntry
271    implements I_CmsSimpleContextMenuEntry<Set<CmsUUID>>, I_CmsSimpleContextMenuEntry.I_HasCssStyles {
272
273        /**
274         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#executeAction(java.lang.Object)
275         */
276        public void executeAction(Set<CmsUUID> data) {
277
278            CmsUUID id = data.iterator().next();
279            m_manager.openSubView(
280                A_CmsWorkplaceApp.addParamToState(CmsProjectManager.PATH_NAME_FILES, "projectId", id.toString()),
281                true);
282        }
283
284        /**
285         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry.I_HasCssStyles#getStyles()
286         */
287        public String getStyles() {
288
289            return ValoTheme.LABEL_BOLD;
290        }
291
292        /**
293         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getTitle(java.util.Locale)
294         */
295        public String getTitle(Locale locale) {
296
297            return CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_SHOW_FILES_0);
298        }
299
300        /**
301         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getVisibility(java.lang.Object)
302         */
303        public CmsMenuItemVisibilityMode getVisibility(Set<CmsUUID> data) {
304
305            if ((data == null) || (data.size() != 1)) {
306                return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE;
307            }
308            if (A_CmsUI.getCmsObject().getRequestContext().getCurrentProject().isOnlineProject()) {
309                return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE;
310            }
311            return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
312        }
313    }
314
315    /**
316     * The unlock project context menu entry.<p>
317     */
318    class UnlockEntry implements I_CmsSimpleContextMenuEntry<Set<CmsUUID>> {
319
320        /**
321         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#executeAction(java.lang.Object)
322         */
323        public void executeAction(Set<CmsUUID> data) {
324
325            for (CmsUUID projectId : data) {
326                try {
327                    A_CmsUI.getCmsObject().unlockProject(projectId);
328                } catch (CmsException e) {
329                    LOG.error("Error unlocking project " + projectId, e);
330                    displayException(e);
331                }
332            }
333        }
334
335        /**
336         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getTitle(java.util.Locale)
337         */
338        public String getTitle(Locale locale) {
339
340            return CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_UNLOCK_FILES_0);
341        }
342
343        /**
344         * @see org.opencms.ui.contextmenu.I_CmsSimpleContextMenuEntry#getVisibility(java.lang.Object)
345         */
346        public CmsMenuItemVisibilityMode getVisibility(Set<CmsUUID> data) {
347
348            if (A_CmsUI.getCmsObject().getRequestContext().getCurrentProject().isOnlineProject()) {
349                return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE;
350            }
351            if (data.size() == 1) {
352                CmsUUID projectId = data.iterator().next();
353                try {
354                    if (A_CmsUI.getCmsObject().countLockedResources(projectId) == 0) {
355                        return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE;
356                    }
357                } catch (CmsException e) {
358                    LOG.error("Error reading locked resources on project " + projectId, e);
359                }
360            }
361            return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
362        }
363    }
364
365    /** Project date created property. */
366    public static final String PROP_DATE_CREATED = "dateCreated";
367
368    /** Project description property. */
369    public static final String PROP_DESCRIPTION = "descrition";
370
371    /** Project icon property. */
372    public static final String PROP_ICON = "icon";
373
374    /** Project id property. */
375    public static final String PROP_ID = "id";
376
377    /** Project manager property. */
378    public static final String PROP_MANAGER = "manager";
379
380    /** Project name property. */
381    public static final String PROP_NAME = "name";
382
383    /** Project org unit property. */
384    public static final String PROP_ORG_UNIT = "orgUnit";
385
386    /** Project owner property. */
387    public static final String PROP_OWNER = "owner";
388
389    /** Project resources property. */
390    public static final String PROP_RESOURCES = "resources";
391
392    /** Project user property. */
393    public static final String PROP_USER = "user";
394
395    /** The logger for this class. */
396    protected static Log LOG = CmsLog.getLog(CmsProjectsTable.class.getName());
397
398    /** The serial version id. */
399    private static final long serialVersionUID = 1540265836332964510L;
400
401    /** The data container. */
402    IndexedContainer m_container;
403
404    /** The project manager instance. */
405    CmsProjectManager m_manager;
406
407    /** The context menu. */
408    CmsContextMenu m_menu;
409
410    /** The available menu entries. */
411    private List<I_CmsSimpleContextMenuEntry<Set<CmsUUID>>> m_menuEntries;
412
413    /**
414     * Constructor.<p>
415     *
416     * @param manager the project manager
417     */
418    public CmsProjectsTable(CmsProjectManager manager) {
419
420        m_manager = manager;
421
422        m_container = new IndexedContainer();
423        m_container.addContainerProperty(PROP_ID, CmsUUID.class, null);
424        m_container.addContainerProperty(PROP_ICON, Resource.class, new CmsCssIcon(OpenCmsTheme.ICON_PROJECT));
425        m_container.addContainerProperty(PROP_NAME, String.class, "");
426        m_container.addContainerProperty(PROP_DESCRIPTION, String.class, "");
427        m_container.addContainerProperty(PROP_ORG_UNIT, String.class, "");
428        m_container.addContainerProperty(PROP_OWNER, String.class, "");
429        m_container.addContainerProperty(PROP_MANAGER, String.class, "");
430        m_container.addContainerProperty(PROP_USER, String.class, "");
431        m_container.addContainerProperty(PROP_DATE_CREATED, Date.class, null);
432        m_container.addContainerProperty(PROP_RESOURCES, ProjectResources.class, null);
433
434        setContainerDataSource(m_container);
435        setItemIconPropertyId(PROP_ICON);
436        setRowHeaderMode(RowHeaderMode.ICON_ONLY);
437        setColumnHeader(PROP_NAME, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_NAME_0));
438        setColumnHeader(PROP_DESCRIPTION, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DESCRIPTION_0));
439        setColumnHeader(PROP_ORG_UNIT, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ORG_UNIT_0));
440        setColumnHeader(PROP_OWNER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_OWNER_0));
441        setColumnHeader(PROP_MANAGER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_MANAGER_GROUP_0));
442        setColumnHeader(PROP_USER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_USER_GROUP_0));
443        setColumnHeader(PROP_DATE_CREATED, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DATE_CREATED_0));
444        setColumnHeader(PROP_RESOURCES, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_RESOURCES_0));
445        setColumnWidth(null, 40);
446        setColumnExpandRatio(PROP_NAME, 2);
447        setColumnExpandRatio(PROP_DESCRIPTION, 2);
448        setColumnExpandRatio(PROP_RESOURCES, 2);
449        setSelectable(true);
450        setMultiSelect(true);
451        m_menu = new CmsContextMenu();
452        m_menu.setAsTableContextMenu(this);
453        addItemClickListener(new ItemClickListener() {
454
455            private static final long serialVersionUID = 1L;
456
457            public void itemClick(ItemClickEvent event) {
458
459                onItemClick(event);
460            }
461        });
462        setCellStyleGenerator(new CellStyleGenerator() {
463
464            private static final long serialVersionUID = 1L;
465
466            public String getStyle(Table source, Object itemId, Object propertyId) {
467
468                if (PROP_NAME.equals(propertyId)) {
469                    return OpenCmsTheme.HOVER_COLUMN;
470                }
471                return null;
472            }
473        });
474    }
475
476    /**
477     * Displays project resources in a popup dialog.
478     *
479     * @param item the item from which to take the project resources
480     */
481    public static void showProjectResources(Item item) {
482
483        VerticalLayout layout = new VerticalLayout();
484        ProjectResources pr = (ProjectResources)(item.getItemProperty(PROP_RESOURCES).getValue());
485        for (String path : pr) {
486            layout.addComponent(new Label(path));
487        }
488        layout.setSpacing(false);
489        CmsBasicDialog dialog = new CmsBasicDialog();
490
491        dialog.setContent(layout);
492        Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
493        String ou = "" + item.getItemProperty(PROP_ORG_UNIT).getValue();
494        String project = "" + item.getItemProperty(PROP_NAME).getValue();
495        String caption = CmsVaadinUtils.getMessageText(
496            org.opencms.ui.apps.Messages.GUI_PROJECTS_RESOURCES_POPUP_CAPTION_2,
497            project,
498            ou);
499        window.setCaption(caption);
500        window.setContent(dialog);
501        CmsAppWorkplaceUi.get().addWindow(window);
502    }
503
504    /**
505     * Filters the displayed projects.<p>
506     *
507     * @param filter the filter
508     */
509    public void filterTable(String filter) {
510
511        m_container.removeAllContainerFilters();
512        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
513            m_container.addContainerFilter(
514                new Or(
515                    new SimpleStringFilter(PROP_NAME, filter, true, false),
516                    new SimpleStringFilter(PROP_ORG_UNIT, filter, true, false),
517                    new SimpleStringFilter(PROP_DESCRIPTION, filter, true, false)));
518        }
519        if ((getValue() != null) & !((Set<CmsUUID>)getValue()).isEmpty()) {
520            setCurrentPageFirstItemId(((Set<CmsUUID>)getValue()).iterator().next());
521        }
522    }
523
524    /**
525     * Loads the projects table.<p>
526     */
527    public void loadProjects() {
528
529        CmsObject cms = A_CmsUI.getCmsObject();
530        Locale locale = UI.getCurrent().getLocale();
531        m_container.removeAllItems();
532        boolean isMultiOU = false;
533        // hide ou column if only one ou exists
534        try {
535            isMultiOU = !OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true).isEmpty();
536        } catch (CmsException e) {
537            // noop
538        }
539        if (isMultiOU) {
540            setVisibleColumns(
541                PROP_NAME,
542                PROP_DESCRIPTION,
543                PROP_ORG_UNIT,
544                PROP_OWNER,
545                PROP_MANAGER,
546                PROP_USER,
547                PROP_DATE_CREATED,
548                PROP_RESOURCES);
549        } else {
550            setVisibleColumns(
551                PROP_NAME,
552                PROP_DESCRIPTION,
553                PROP_OWNER,
554                PROP_MANAGER,
555                PROP_USER,
556                PROP_DATE_CREATED,
557                PROP_RESOURCES);
558        }
559
560        // get content
561        try {
562            List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(cms, "", true);
563            for (CmsProject project : projects) {
564                Item item = m_container.addItem(project.getUuid());
565                item.getItemProperty(PROP_ID).setValue(project.getUuid());
566                item.getItemProperty(PROP_NAME).setValue(project.getSimpleName());
567                item.getItemProperty(PROP_DESCRIPTION).setValue(project.getDescription());
568                try {
569                    item.getItemProperty(PROP_ORG_UNIT).setValue(
570                        OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName(
571                            locale));
572                    item.getItemProperty(PROP_OWNER).setValue(cms.readUser(project.getOwnerId()).getName());
573                    item.getItemProperty(PROP_MANAGER).setValue(
574                        cms.readGroup(project.getManagerGroupId()).getSimpleName());
575                    item.getItemProperty(PROP_USER).setValue(cms.readGroup(project.getGroupId()).getSimpleName());
576                } catch (CmsException e) {
577                    LOG.warn("Error reading project properties for " + project + ". " + e.getLocalizedMessage(), e);
578                }
579                item.getItemProperty(PROP_DATE_CREATED).setValue(new Date(project.getDateCreated()));
580
581                StringBuffer html = new StringBuffer(512);
582                try {
583                    item.getItemProperty(PROP_RESOURCES).setValue(
584                        new ProjectResources(cms.readProjectResources(project)));
585                } catch (CmsException e) {
586                    LOG.error("Error reading project resources for " + project.getSimpleName());
587                }
588
589            }
590        } catch (CmsException e) {
591            LOG.error("Error reading manageable projects", e);
592            CmsErrorDialog.showErrorDialog(e);
593        }
594    }
595
596    /**
597     * Displays the given exception in the error dialog and reloads the UI on close.<p>
598     *
599     * @param e the exception
600     */
601    protected void displayException(Throwable e) {
602
603        CmsErrorDialog.showErrorDialog(e, new Runnable() {
604
605            public void run() {
606
607                CmsAppWorkplaceUi.get().reload();
608            }
609        });
610    }
611
612    /**
613     * Returns the available menu entries.<p>
614     *
615     * @return the menu entries
616     */
617    List<I_CmsSimpleContextMenuEntry<Set<CmsUUID>>> getMenuEntries() {
618
619        if (m_menuEntries == null) {
620            m_menuEntries = new ArrayList<I_CmsSimpleContextMenuEntry<Set<CmsUUID>>>();
621            m_menuEntries.add(new ShowFilesEntry());
622            m_menuEntries.add(new UnlockEntry());
623            m_menuEntries.add(new PublishEntry());
624            m_menuEntries.add(new EditEntry());
625            m_menuEntries.add(new DeleteEntry());
626        }
627        return m_menuEntries;
628    }
629
630    /**
631     * Handles the table item clicks.<p>
632     *
633     * @param event the click event
634     */
635    @SuppressWarnings("unchecked")
636    void onItemClick(ItemClickEvent event) {
637
638        if (!event.isCtrlKey() && !event.isShiftKey()) {
639            // don't interfere with multi-selection using control key
640            if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
641                CmsUUID itemId = (CmsUUID)event.getItemId();
642                Set<CmsUUID> value = (Set<CmsUUID>)getValue();
643                if (value == null) {
644                    select(itemId);
645                } else if (!value.contains(itemId)) {
646                    setValue(null);
647                    select(itemId);
648                }
649                m_menu.setEntries(getMenuEntries(), (Set<CmsUUID>)getValue());
650                m_menu.openForTable(event, this);
651            } else if (event.getButton().equals(MouseButton.LEFT) && PROP_NAME.equals(event.getPropertyId())) {
652                Item item = event.getItem();
653                CmsUUID id = (CmsUUID)item.getItemProperty(PROP_ID).getValue();
654                m_manager.openSubView(
655                    A_CmsWorkplaceApp.addParamToState(CmsProjectManager.PATH_NAME_FILES, "projectId", id.toString()),
656                    true);
657            } else if (event.getButton().equals(MouseButton.LEFT) && PROP_RESOURCES.equals(event.getPropertyId())) {
658                Item item = event.getItem();
659                showProjectResources(item);
660            }
661        }
662    }
663}