1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.common.ui.krad.uif.element;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.krad.uif.component.Component;
21 import org.kuali.rice.krad.uif.element.Image;
22 import org.kuali.rice.krad.uif.view.View;
23 import org.kuali.student.common.uif.element.KSUifActionButton;
24
25 import java.text.MessageFormat;
26
27
28
29
30
31
32
33 public class ActionImageButton extends KSUifActionButton {
34
35 private String imageSource;
36 private String imageSourceOnHover;
37
38 @Override
39 public void performFinalize(View view, Object model, Component parent) {
40 super.performFinalize(view, model, parent);
41
42 Image img = this.getActionImage();
43 if (null == img) {
44 throw new RuntimeException("Implementation of "+ this.getClass() +" did not instantiate \"actionImage\" property.");
45 }
46
47 if (StringUtils.isBlank(img.getSource()) && StringUtils.isNotBlank(this.imageSource)) {
48 img.setSource(this.imageSource);
49 }
50
51 if (StringUtils.isNotBlank(this.imageSourceOnHover)) {
52 String script = MessageFormat.format("ksButtonImageChanger(this,\"{0}\");", this.imageSourceOnHover);
53 if (StringUtils.isNotBlank(this.getOnMouseOverScript())) {
54 script += this.getOnMouseOverScript();
55 }
56 this.setOnMouseOverScript(script);
57
58 script = MessageFormat.format("ksButtonImageChanger(this,\"{0}\");", img.getSource());
59 if (StringUtils.isNotBlank(this.getOnMouseOutScript())) {
60 script += this.getOnMouseOutScript();
61 }
62 this.setOnMouseOutScript(script);
63 }
64 }
65
66 public String getImageSource() {
67 return imageSource;
68 }
69 public void setImageSource(String imageSource) {
70 this.imageSource = imageSource;
71 }
72
73 public String getImageSourceOnHover() {
74 return imageSourceOnHover;
75 }
76 public void setImageSourceOnHover(String imageSourceOnHover) {
77 this.imageSourceOnHover = imageSourceOnHover;
78 }
79
80
81
82
83 @Override
84 protected <T> void copyProperties(T component) {
85 super.copyProperties(component);
86
87 ActionImageButton actionImageButtonCopy = (ActionImageButton) component;
88
89 actionImageButtonCopy.setImageSource(this.imageSource);
90 actionImageButtonCopy.setImageSourceOnHover(this.imageSourceOnHover);
91 }
92 }