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.actions; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.main.CmsException; 033import org.opencms.ui.A_CmsUI; 034import org.opencms.ui.CmsVaadinUtils; 035import org.opencms.ui.I_CmsDialogContext; 036import org.opencms.ui.Messages; 037import org.opencms.ui.components.CmsBasicDialog.DialogWidth; 038import org.opencms.ui.components.CmsErrorDialog; 039import org.opencms.ui.contextmenu.CmsMenuItemVisibilityMode; 040import org.opencms.ui.contextmenu.CmsStandardVisibilityCheck; 041import org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility; 042import org.opencms.ui.dialogs.CmsEmbeddedDialogContext; 043import org.opencms.ui.favorites.CmsFavoriteDAO; 044import org.opencms.ui.favorites.CmsFavoriteDialog; 045import org.opencms.ui.favorites.CmsPageEditorFavoriteContext; 046 047import java.util.List; 048 049import com.vaadin.server.VaadinRequest; 050 051/** 052 * The action for the favorite dialog. 053 * 054 * This is only used for the favorite dialog opened from the page editor. 055 */ 056public class CmsFavoriteDialogAction extends A_CmsWorkplaceAction { 057 058 /** The action id. */ 059 public static final String ACTION_ID = "favorite"; 060 061 /** The action visibility. */ 062 public static final I_CmsHasMenuItemVisibility VISIBILITY = CmsStandardVisibilityCheck.DEFAULT; 063 064 /** 065 * @see org.opencms.ui.actions.I_CmsWorkplaceAction#executeAction(org.opencms.ui.I_CmsDialogContext) 066 */ 067 public void executeAction(I_CmsDialogContext context) { 068 069 try { 070 VaadinRequest req = VaadinRequest.getCurrent(); 071 CmsFavoriteDialog dialog = new CmsFavoriteDialog( 072 new CmsPageEditorFavoriteContext((CmsEmbeddedDialogContext)context), 073 new CmsFavoriteDAO(A_CmsUI.getCmsObject())); 074 context.start( 075 CmsVaadinUtils.getMessageText(Messages.GUI_FAVORITES_DIALOG_TITLE_0), 076 dialog, 077 DialogWidth.max); 078 } catch (CmsException e) { 079 CmsErrorDialog.showErrorDialog(e); 080 } 081 082 } 083 084 /** 085 * @see org.opencms.ui.actions.I_CmsWorkplaceAction#getId() 086 */ 087 public String getId() { 088 089 return ACTION_ID; 090 } 091 092 /** 093 * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.file.CmsObject, java.util.List) 094 */ 095 public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) { 096 097 return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; 098 } 099 100 /** 101 * @see org.opencms.ui.actions.A_CmsWorkplaceAction#getVisibility(org.opencms.ui.I_CmsDialogContext) 102 */ 103 @Override 104 public CmsMenuItemVisibilityMode getVisibility(I_CmsDialogContext context) { 105 106 return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; 107 } 108 109 /** 110 * @see org.opencms.ui.actions.A_CmsWorkplaceAction#getTitleKey() 111 */ 112 @Override 113 protected String getTitleKey() { 114 115 return "FAVORITE"; 116 } 117}