KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > editors > directedit > CmsDirectEditButtonSelection


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/editors/directedit/CmsDirectEditButtonSelection.java,v $
3  * Date : $Date: 2006/10/26 12:25:34 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.editors.directedit;
33
34 /**
35  * Constants to indicate which direct edit buttons should be displayed for a direct edit resource
36  * if the user has the permissions.<p>
37  *
38  * The actual permission check is done later using {@link CmsDirectEditPermissions}.<p>
39  *
40  * This button selection is used internally to indicate the buttons that <i>may</i> be displayed.
41  * Usually, for an XmlPage only the "edit" button is displayed, while for an XmlContent
42  * there may be an "edit", "delete" or "new" button.<p>
43  *
44  * Currently there are only constants for thouse button combinations that are actually used
45  * in practice. These are {@link #EDIT}, {@link #EDIT_DELETE} and {@link #EDIT_DELETE_NEW}.<p>
46  *
47  * @author Alexander Kandzior
48  *
49  * @version $Revision: 1.2 $
50  *
51  * @since 6.2.3
52  */

53 public final class CmsDirectEditButtonSelection {
54
55     /** Constant to indicate "show only the edit button". */
56     public static final CmsDirectEditButtonSelection EDIT = new CmsDirectEditButtonSelection(true, false, false);
57
58     /** Constant to indicate "show the edit and the delete button". */
59     public static final CmsDirectEditButtonSelection EDIT_DELETE = new CmsDirectEditButtonSelection(true, true, false);
60
61     /** Constant to indicate "show the edit, the delete and the new button". */
62     public static final CmsDirectEditButtonSelection EDIT_DELETE_NEW = new CmsDirectEditButtonSelection(
63         true,
64         true,
65         true);
66
67     /** String value that indicates the "delete" button should be displayed. */
68     public static final String JavaDoc VALUE_DELETE = "delete";
69
70     /** String value that indicates the "edit" button should be displayed. */
71     public static final String JavaDoc VALUE_EDIT = "edit";
72
73     /** String value that indicates the "new" button should be displayed. */
74     public static final String JavaDoc VALUE_NEW = "new";
75
76     /** Indicates if the "delete" button should be displayed. */
77     private boolean m_showDelete;
78
79     /** Indicates if the "edit" button should be displayed. */
80     private boolean m_showEdit;
81
82     /** Indicates if the "new" button should be displayed. */
83     private boolean m_showNew;
84
85     /** Pre-calculated String value. */
86     private String JavaDoc m_stringValue;
87
88     /**
89      * Hides the public constructor.<p>
90      *
91      * @param showEdit if <code>true</code> then the "edit" button should be displayed
92      * @param showDelete if <code>true</code> then the "delete" button should be displayed
93      * @param showNew if <code>true</code> then the "new" button should be displayed
94      */

95     private CmsDirectEditButtonSelection(boolean showEdit, boolean showDelete, boolean showNew) {
96
97         m_showEdit = showEdit;
98         m_showDelete = showDelete;
99         m_showNew = showNew;
100     }
101
102     /**
103      * Returns <code>true</code> if the "delete" button should be displayed.<p>
104      *
105      * @return <code>true</code> if the "delete" button should be displayed
106      */

107     public boolean isShowDelete() {
108
109         return m_showDelete;
110     }
111
112     /**
113      * Returns <code>true</code> if the "edit" button should be displayed.<p>
114      *
115      * @return <code>true</code> if the "edit" button should be displayed
116      */

117     public boolean isShowEdit() {
118
119         return m_showEdit;
120     }
121
122     /**
123      * Returns <code>true</code> if the "new" button should be displayed.<p>
124      *
125      * @return <code>true</code> if the "new" button should be displayed
126      */

127     public boolean isShowNew() {
128
129         return m_showNew;
130     }
131
132     /**
133      * Returns the selected edit options as a String in the form <code>edit|delete|new</code>.<p>
134      *
135      * @return the selected edit options as a String
136      */

137     public String JavaDoc toString() {
138
139         if (m_stringValue == null) {
140             StringBuffer JavaDoc result = new StringBuffer JavaDoc(32);
141             if (m_showEdit) {
142                 result.append(VALUE_EDIT);
143             }
144             result.append('|');
145             if (m_showDelete) {
146                 result.append(VALUE_DELETE);
147             }
148             result.append('|');
149             if (m_showNew) {
150                 result.append(VALUE_NEW);
151             }
152             m_stringValue = result.toString();
153         }
154         return m_stringValue;
155     }
156 }
Popular Tags