View Javadoc
1   /**
2    * This file Copyright (c) 2011-2018 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.annotation.deprecation.MgnlDeprecated;
37  import info.magnolia.i18nsystem.I18nText;
38  import info.magnolia.ui.form.field.converter.IdentifierToPathConverter;
39  
40  /**
41   * The link field allows you to create a link to content stored in Magnolia. You can browse any specified workspace and
42   * select a content node to link to such as a page (website), file (dms) or data item (data).
43   * @deprecated since 6.0, please use {@link info.magnolia.ui.field.LinkFieldDefinition} instead.
44   */
45  @MgnlDeprecated(since = "6.0")
46  public class LinkFieldDefinition extends ConfiguredFieldDefinition {
47  
48      private String targetTreeRootPath;
49      private String appName;
50      private String targetWorkspace = "website";
51      private String buttonSelectNewLabel;
52      private String buttonSelectOtherLabel;
53      private IdentifierToPathConverter identifierToPathConverter;
54      private ContentPreviewDefinition contentPreviewDefinition;
55      private boolean fieldEditable = true;
56      private String targetPropertyToPopulate;
57      private String placeholder;
58  
59      /**
60       * @return the target App Name used to create the ContentView, like 'pages'
61       */
62      public String getAppName() {
63          return appName;
64      }
65  
66      /**
67       * @return the target property name to populate into the link field.
68       */
69      public String getTargetPropertyToPopulate() {
70          return targetPropertyToPopulate;
71      }
72  
73      /**
74       * @return the workspace from which the link was retrieve.
75       */
76      public String getTargetWorkspace() {
77          return targetWorkspace;
78      }
79  
80      /**
81       * If not define, no translation will be performed.
82       *
83       * @return the implemented class used to perform the translation between a path and an Identifier.
84       */
85      public IdentifierToPathConverter getIdentifierToPathConverter() {
86          return identifierToPathConverter;
87      }
88  
89      /**
90       * If not define, no Content preview component will added to the selection field.
91       *
92       * @return the implemented class used to display the File preview.
93       */
94      public ContentPreviewDefinition getContentPreviewDefinition() {
95          return contentPreviewDefinition;
96      }
97  
98      /**
99       * @return the root of the target tree.
100      */
101     public String getTargetTreeRootPath() {
102         return this.targetTreeRootPath;
103     }
104 
105     /**
106      * @return the Button Label displayed when no link is yet selected.
107      */
108     @I18nText
109     public String getButtonSelectNewLabel() {
110         return buttonSelectNewLabel;
111     }
112 
113     /**
114      * @return the Button Label displayed when a link is selected.
115      */
116     @I18nText
117     public String getButtonSelectOtherLabel() {
118         return buttonSelectOtherLabel;
119     }
120 
121     /**
122      * @return if true, the select link field is editable, else it is defined as readOnly.
123      */
124     public boolean isFieldEditable() {
125         return fieldEditable;
126     }
127 
128     public void setTargetPropertyToPopulate(String targetPropertyToPopulate) {
129         this.targetPropertyToPopulate = targetPropertyToPopulate;
130     }
131 
132     public void setTargetWorkspace(String targetWorkspace) {
133         this.targetWorkspace = targetWorkspace;
134     }
135 
136 
137     public void setTargetTreeRootPath(String targetTreeRootPath) {
138         this.targetTreeRootPath = targetTreeRootPath;
139     }
140 
141     public void setAppName(String appName) {
142         this.appName = appName;
143     }
144 
145     public void setButtonSelectNewLabel(String buttonSelectNewLabel) {
146         this.buttonSelectNewLabel = buttonSelectNewLabel;
147     }
148 
149     public void setButtonSelectOtherLabel(String buttonSelectOtherLabel) {
150         this.buttonSelectOtherLabel = buttonSelectOtherLabel;
151     }
152 
153     public void setIdentifierToPathConverter(IdentifierToPathConverter identifierToPathConverter) {
154         this.identifierToPathConverter = identifierToPathConverter;
155     }
156 
157     public void setContentPreviewDefinition(ContentPreviewDefinition contentPreviewDefinition) {
158         this.contentPreviewDefinition = contentPreviewDefinition;
159     }
160 
161     public void setFieldEditable(boolean fieldEditable) {
162         this.fieldEditable = fieldEditable;
163     }
164 
165     @I18nText
166     public String getPlaceholder() {
167         return placeholder;
168     }
169 
170     public void setPlaceholder(String placeholder) {
171         this.placeholder = placeholder;
172     }
173 
174     @I18nText
175     public String getButtonSelectNewDefaultLabel() {
176         return "buttons.select.new";
177     }
178 
179     @I18nText
180     public String getButtonSelectOtherDefaultLabel() {
181         return "buttons.select.another";
182     }
183 }