KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > template > SAbstractIconTextCompoundPropertyManager


1 /*
2  * $Id: SAbstractIconTextCompoundPropertyManager.java,v 1.3 2004/12/01 07:54:28 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.template;
15
16 import org.wings.SAbstractIconTextCompound;
17 import org.wings.SComponent;
18 import org.wings.SURLIcon;
19
20 /**
21  * @author armin
22  * created at 05.03.2004 10:24:07
23  */

24 public class SAbstractIconTextCompoundPropertyManager extends SComponentPropertyManager {
25     static final Class JavaDoc[] classes = {SAbstractIconTextCompound.class};
26
27     public SAbstractIconTextCompoundPropertyManager() {
28     }
29
30     public void setProperty(SComponent comp, String JavaDoc name, String JavaDoc value) {
31         SAbstractIconTextCompound c = (SAbstractIconTextCompound) comp;
32         if (name.equals("TEXT"))
33             c.setText(value);
34         else if (name.startsWith("ICON")) {
35             if (name.equals("ICON"))
36                 c.setIcon(new SURLIcon(value));
37             else if (name.equals("ICONWIDTH")) {
38                 try {
39                     int width = Integer.parseInt(value);
40                     if (c.getIcon() != null) {
41                         c.getIcon().setIconWidth(width);
42                     } // end of if ()
43
if (c.getDisabledIcon() != null) {
44                         c.getDisabledIcon().setIconWidth(width);
45                     } // end of if ()
46
if (c.getSelectedIcon() != null) {
47                         c.getSelectedIcon().setIconWidth(width);
48                     } // end of if ()
49
if (c.getRolloverIcon() != null) {
50                         c.getRolloverIcon().setIconWidth(width);
51                     } // end of if ()
52
if (c.getRolloverSelectedIcon() != null) {
53                         c.getRolloverSelectedIcon().setIconWidth(width);
54                     } // end of if ()
55
if (c.getPressedIcon() != null) {
56                         c.getPressedIcon().setIconWidth(width);
57                     } // end of if ()
58
} catch (NumberFormatException JavaDoc ex) {
59                 } // end of try-catch
60
} else if (name.equals("ICONHEIGHT")) {
61                 try {
62                     int height = Integer.parseInt(value);
63                     if (c.getIcon() != null) {
64                         c.getIcon().setIconHeight(height);
65                     } // end of if ()
66
if (c.getDisabledIcon() != null) {
67                         c.getDisabledIcon().setIconHeight(height);
68                     } // end of if ()
69
if (c.getSelectedIcon() != null) {
70                         c.getSelectedIcon().setIconHeight(height);
71                     } // end of if ()
72
if (c.getRolloverIcon() != null) {
73                         c.getRolloverIcon().setIconHeight(height);
74                     } // end of if ()
75
if (c.getRolloverSelectedIcon() != null) {
76                         c.getRolloverSelectedIcon().setIconHeight(height);
77                     } // end of if ()
78
if (c.getPressedIcon() != null) {
79                         c.getPressedIcon().setIconHeight(height);
80                     } // end of if ()
81
} catch (NumberFormatException JavaDoc ex) {
82                 } // end of try-catch
83
}
84         } else if (name.equals("DISABLEDICON"))
85             c.setDisabledIcon(new SURLIcon(value));
86         else if (name.equals("SELECTEDICON"))
87             c.setSelectedIcon(new SURLIcon(value));
88         else if (name.equals("ROLLOVERSELECTEDICON"))
89             c.setRolloverSelectedIcon(new SURLIcon(value));
90         else if (name.equals("PRESSEDICON"))
91             c.setPressedIcon(new SURLIcon(value));
92         else
93             super.setProperty(comp, name, value);
94     }
95
96     public Class JavaDoc[] getSupportedClasses() {
97         return classes;
98     }
99 }
100
Popular Tags