View Javadoc

1   /**
2    * Copyright 2005-2013 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.component.Component;
21  import org.kuali.rice.krad.uif.element.Header;
22  import org.kuali.rice.krad.uif.view.View;
23  
24  import java.io.Serializable;
25  
26  /**
27   * Widget that renders text syntax highlighted
28   *
29   * <p>
30   * The widget renders a div with a header. In the div the source code text will be added in pre tags with the
31   * specified plugin class that is needed for the plugin to alter the text.
32   * </p>
33   *
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   */
36  @BeanTag(name = "syntaxHighlighter-bean", parent = "Uif-SyntaxHighlighter")
37  public class SyntaxHighlighter extends WidgetBase {
38  
39      private Header header;
40      private String sourceCode;
41      private String pluginCssClass;
42      private boolean allowCopy;
43      private boolean showCopyConfirmation;
44      
45      public SyntaxHighlighter() {
46          super();
47          allowCopy = true;
48          showCopyConfirmation = false;
49      }
50  
51      @Override
52      public void performFinalize(View view, Object model, Component parent) {
53          super.performFinalize(view, model, parent);
54      }
55  
56      @BeanTagAttribute(name="header")
57      public Header getHeader() {
58          return header;
59      }
60  
61      public void setHeader(Header header) {
62          this.header = header;
63      }
64  
65      /**
66       * The text to render with syntax highlighting
67       *
68       * @return String
69       */
70      @BeanTagAttribute(name="sourceCode")
71      public String getSourceCode() {
72          return sourceCode;
73      }
74  
75      /**
76       * Setter for the source code text
77       *
78       * @param sourceCode
79       */
80      public void setSourceCode(String sourceCode) {
81          this.sourceCode = sourceCode;
82      }
83  
84      /**
85       * The class that will be set on the pre tags
86       *
87       * <p>
88       * The class is used by the prettify plugin to identify text to highlight and to specify type of highlighting.
89       * </p>
90       *
91       * @return String
92       */
93      @BeanTagAttribute(name="pluginCssClass")
94      public String getPluginCssClass() {
95          return pluginCssClass;
96      }
97  
98      /**
99       * Setter for the plugin css class
100      *
101      * @param pluginCssClass
102      */
103     public void setPluginCssClass(String pluginCssClass) {
104         this.pluginCssClass = pluginCssClass;
105     }
106 
107     /**
108      * Indicates if the ZeroClipboard copy functionality must be added
109      *
110      * <p>
111      * When copy is allowed a copy button will be shown when the mouse hovers over the syntax highlighter. This button
112      * will be hidden the otherwise to avoid obstructing some of the displayed code.
113      * </p>
114      *
115      * @return  boolean
116      */
117     public boolean isAllowCopy() {
118         return allowCopy;
119     }
120 
121     /**
122      * Setter for the allow copy flag
123      *
124      * @param allowCopy
125      */
126     public void setAllowCopy(boolean allowCopy) {
127         this.allowCopy = allowCopy;
128     }
129 
130     /**
131      * Indicates if a confirmation dialog must be shown after copy action
132      *
133      * @return boolean
134      */
135     public boolean isShowCopyConfirmation() {
136         return showCopyConfirmation;
137     }
138 
139     /**
140      * Setter for the show copy confirmation dialog flag
141      *
142      * @param showCopyConfirmation
143      */
144     public void setShowCopyConfirmation(boolean showCopyConfirmation) {
145         this.showCopyConfirmation = showCopyConfirmation;
146     }
147 }