001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.uif.widget; 017 018import org.kuali.rice.krad.datadictionary.parse.BeanTag; 019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 020import org.kuali.rice.krad.uif.element.Header; 021 022/** 023 * Widget that renders text syntax highlighted 024 * 025 * <p> 026 * The widget renders a div with a header. In the div the source code text will be added in pre tags with the 027 * specified plugin class that is needed for the plugin to alter the text. 028 * </p> 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032@BeanTag(name = "syntaxHighlighter", parent = "Uif-SyntaxHighlighter") 033public class SyntaxHighlighter extends WidgetBase { 034 035 private Header header; 036 private String sourceCode; 037 private String pluginCssClass; 038 private boolean allowCopy; 039 private boolean showCopyConfirmation; 040 041 public SyntaxHighlighter() { 042 super(); 043 allowCopy = true; 044 showCopyConfirmation = false; 045 } 046 047 @BeanTagAttribute 048 public Header getHeader() { 049 return header; 050 } 051 052 public void setHeader(Header header) { 053 this.header = header; 054 } 055 056 /** 057 * The text to render with syntax highlighting 058 * 059 * @return String 060 */ 061 @BeanTagAttribute 062 public String getSourceCode() { 063 return sourceCode; 064 } 065 066 /** 067 * Setter for the source code text 068 * 069 * @param sourceCode 070 */ 071 public void setSourceCode(String sourceCode) { 072 this.sourceCode = sourceCode; 073 } 074 075 /** 076 * The class that will be set on the pre tags 077 * 078 * <p> 079 * The class is used by the prettify plugin to identify text to highlight and to specify type of highlighting. 080 * </p> 081 * 082 * @return String 083 */ 084 @BeanTagAttribute 085 public String getPluginCssClass() { 086 return pluginCssClass; 087 } 088 089 /** 090 * Setter for the plugin css class 091 * 092 * @param pluginCssClass 093 */ 094 public void setPluginCssClass(String pluginCssClass) { 095 this.pluginCssClass = pluginCssClass; 096 } 097 098 /** 099 * 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}