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.workplace.editors.directedit; 029 030/** 031 * Constants to indicate the direct edit permissions of a user for a VFS resource, 032 * used to describe if and how to show the direct edit buttons for the resource.<p> 033 * 034 * @since 6.2.3 035 */ 036public final class CmsDirectEditPermissions { 037 038 /** 039 * Describes the "disabled" permission.<p> 040 * 041 * User has general permissions to direct edit a resource, but this is currently not possible 042 * because for example another user has locked the resource.<p> 043 * 044 * Direct edit buttons are displayed, but "grayed out". 045 */ 046 public static final CmsDirectEditPermissions DISABLED = new CmsDirectEditPermissions(1); 047 048 /** 049 * Describes the "enabled" permission.<p> 050 * 051 * User has permissions to direct edit a resource, the resource is also available for direct edit.<p> 052 * 053 * Direct edit buttons are displayed and active. 054 */ 055 public static final CmsDirectEditPermissions ENABLED = new CmsDirectEditPermissions(2); 056 057 /** 058 * Describes the "inactive" permission.<p> 059 * 060 * User has no permissions to direct edit a resource. 061 * This may be because of write permissions, or because the resource is not part of the current 062 * project, or for other reasons.<p> 063 * 064 * Direct edit buttons are not displayed at all. 065 */ 066 public static final CmsDirectEditPermissions INACTIVE = new CmsDirectEditPermissions(0); 067 068 /** String constant for {@link #DISABLED}. */ 069 public static final String VALUE_DISABLED = "disabled"; 070 071 /** String constant for {@link #ENABLED}. */ 072 public static final String VALUE_ENABLED = "enabled"; 073 074 /** String constant for {@link #INACTIVE}. */ 075 public static final String VALUE_INACTIVE = "inactive"; 076 077 /** The direct edit permission value. */ 078 int m_permission; 079 080 /** 081 * Hides the public constructor.<p> 082 * 083 * @param value the direct edit mode 084 */ 085 private CmsDirectEditPermissions(int value) { 086 087 m_permission = value; 088 } 089 090 /** 091 * Returns the direct edit permission int value.<p> 092 * 093 * The possible value are: 094 * <ul> 095 * <li>0: Permission is {@link #INACTIVE}. 096 * <li>1: Permission is {@link #DISABLED}. 097 * <li>2: Permission is {@link #ENABLED}. 098 * </ul> 099 * 100 * @return the direct edit permission int value 101 */ 102 public int getPermission() { 103 104 return m_permission; 105 } 106 107 /** 108 * @see java.lang.Object#toString() 109 */ 110 @Override 111 public String toString() { 112 113 String result; 114 switch (m_permission) { 115 case 1: 116 result = VALUE_DISABLED; 117 break; 118 case 2: 119 result = VALUE_ENABLED; 120 break; 121 default: 122 result = VALUE_INACTIVE; 123 } 124 return result; 125 } 126}