View Javadoc

1   /**
2    * This file Copyright (c) 2011-2014 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.ui.form.field.definition;
35  
36  import info.magnolia.ui.form.field.converter.IdentifierToPathConverter;
37  
38  /**
39   * The link field allows you to create a link to content stored in Magnolia. You can browse any specified workspace and
40   * select a content node to link to such as a page (website), file (dms) or data item (data).
41   */
42  public class LinkFieldDefinition extends ConfiguredFieldDefinition {
43  
44      private String targetTreeRootPath;
45      private String appName;
46      private String targetWorkspace = "website";
47      private String buttonSelectNewLabel = "field.link.select.new";
48      private String buttonSelectOtherLabel = "field.link.select.another";
49      private IdentifierToPathConverter identifierToPathConverter;
50      private ContentPreviewDefinition contentPreviewDefinition;
51      private boolean fieldEditable = true;
52      private String targetPropertyToPopulate;
53  
54      /**
55       * @return the target App Name used to create the ContentView, like 'pages'
56       */
57      public String getAppName() {
58          return appName;
59      }
60  
61      /**
62       * @return the target property name to populate into the link field.
63       */
64      public String getTargetPropertyToPopulate() {
65          return targetPropertyToPopulate;
66      }
67  
68      /**
69       * @return the workspace from which the link was retrieve.
70       */
71      public String getTargetWorkspace() {
72          return targetWorkspace;
73      }
74  
75      /**
76       * If not define, no translation will be performed.
77       * 
78       * @return the implemented class used to perform the translation between a path and an Identifier.
79       */
80      public IdentifierToPathConverter getIdentifierToPathConverter() {
81          return identifierToPathConverter;
82      }
83  
84      /**
85       * If not define, no Content preview component will added to the selection field.
86       * 
87       * @return the implemented class used to display the File preview.
88       */
89      public ContentPreviewDefinition getContentPreviewDefinition() {
90          return contentPreviewDefinition;
91      }
92  
93      /**
94       * @return the root of the target tree.
95       */
96      public String getTargetTreeRootPath() {
97          return this.targetTreeRootPath;
98      }
99  
100     /**
101      * @return the Button Label displayed when no link is yet selected.
102      */
103     public String getButtonSelectNewLabel() {
104         return buttonSelectNewLabel;
105     }
106 
107     /**
108      * @return the Button Label displayed when a link is selected.
109      */
110     public String getButtonSelectOtherLabel() {
111         return buttonSelectOtherLabel;
112     }
113 
114     /**
115      * @return if true, the select link field is editable, else it is defined as readOnly.
116      */
117     public boolean isFieldEditable() {
118         return fieldEditable;
119     }
120 
121     public void setTargetPropertyToPopulate(String targetPropertyToPopulate) {
122         this.targetPropertyToPopulate = targetPropertyToPopulate;
123     }
124 
125     public void setTargetWorkspace(String targetWorkspace) {
126         this.targetWorkspace = targetWorkspace;
127     }
128 
129 
130     public void setTargetTreeRootPath(String targetTreeRootPath) {
131         this.targetTreeRootPath = targetTreeRootPath;
132     }
133 
134     public void setAppName(String appName) {
135         this.appName = appName;
136     }
137 
138     public void setButtonSelectNewLabel(String buttonSelectNewLabel) {
139         this.buttonSelectNewLabel = buttonSelectNewLabel;
140     }
141 
142     public void setButtonSelectOtherLabel(String buttonSelectOtherLabel) {
143         this.buttonSelectOtherLabel = buttonSelectOtherLabel;
144     }
145 
146     public void setIdentifierToPathConverter(IdentifierToPathConverter identifierToPathConverter) {
147         this.identifierToPathConverter = identifierToPathConverter;
148     }
149 
150     public void setContentPreviewDefinition(ContentPreviewDefinition contentPreviewDefinition) {
151         this.contentPreviewDefinition = contentPreviewDefinition;
152     }
153 
154     public void setFieldEditable(boolean fieldEditable) {
155         this.fieldEditable = fieldEditable;
156     }
157 }