View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.widget;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.uif.element.Header;
21  
22  /**
23   * Widget that renders text syntax highlighted
24   *
25   * <p>
26   * The widget renders a div with a header. In the div the source code text will be added in pre tags with the
27   * specified plugin class that is needed for the plugin to alter the text.
28   * </p>
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  @BeanTag(name = "syntaxHighlighter", parent = "Uif-SyntaxHighlighter")
33  public class SyntaxHighlighter extends WidgetBase {
34  
35      private Header header;
36      private String sourceCode;
37      private String pluginCssClass;
38      private boolean allowCopy;
39      private boolean showCopyConfirmation;
40      
41      public SyntaxHighlighter() {
42          super();
43          allowCopy = true;
44          showCopyConfirmation = false;
45      }
46  
47      @BeanTagAttribute
48      public Header getHeader() {
49          return header;
50      }
51  
52      public void setHeader(Header header) {
53          this.header = header;
54      }
55  
56      /**
57       * The text to render with syntax highlighting
58       *
59       * @return String
60       */
61      @BeanTagAttribute
62      public String getSourceCode() {
63          return sourceCode;
64      }
65  
66      /**
67       * Setter for the source code text
68       *
69       * @param sourceCode
70       */
71      public void setSourceCode(String sourceCode) {
72          this.sourceCode = sourceCode;
73      }
74  
75      /**
76       * The class that will be set on the pre tags
77       *
78       * <p>
79       * The class is used by the prettify plugin to identify text to highlight and to specify type of highlighting.
80       * </p>
81       *
82       * @return String
83       */
84      @BeanTagAttribute
85      public String getPluginCssClass() {
86          return pluginCssClass;
87      }
88  
89      /**
90       * Setter for the plugin css class
91       *
92       * @param pluginCssClass
93       */
94      public void setPluginCssClass(String pluginCssClass) {
95          this.pluginCssClass = pluginCssClass;
96      }
97  
98      /**
99       * Indicates if the ZeroClipboard copy functionality must be added
100      *
101      * <p>
102      * When copy is allowed a copy button will be shown when the mouse hovers over the syntax highlighter. This button
103      * will be hidden the otherwise to avoid obstructing some of the displayed code.
104      * </p>
105      *
106      * @return  boolean
107      */
108     @BeanTagAttribute
109     public boolean isAllowCopy() {
110         return allowCopy;
111     }
112 
113     /**
114      * Setter for the allow copy flag
115      *
116      * @param allowCopy
117      */
118     public void setAllowCopy(boolean allowCopy) {
119         this.allowCopy = allowCopy;
120     }
121 
122     /**
123      * Indicates if a confirmation dialog must be shown after copy action
124      *
125      * @return boolean
126      */
127     @BeanTagAttribute
128     public boolean isShowCopyConfirmation() {
129         return showCopyConfirmation;
130     }
131 
132     /**
133      * Setter for the show copy confirmation dialog flag
134      *
135      * @param showCopyConfirmation
136      */
137     public void setShowCopyConfirmation(boolean showCopyConfirmation) {
138         this.showCopyConfirmation = showCopyConfirmation;
139     }
140 }