svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.swing / org.gvsig.expressionevaluator.swing.api / src / main / java / org / gvsig / expressionevaluator / swing / spi / AbstractElement.java @ 44098
History | View | Annotate | Download (1.9 KB)
1 |
package org.gvsig.expressionevaluator.swing.spi; |
---|---|
2 |
|
3 |
import javax.swing.ImageIcon; |
4 |
import org.gvsig.expressionevaluator.swing.Element; |
5 |
import org.gvsig.tools.swing.api.Component; |
6 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
7 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
8 |
import org.slf4j.Logger; |
9 |
import org.slf4j.LoggerFactory; |
10 |
|
11 |
/**
|
12 |
*
|
13 |
* @author jjdelcerro
|
14 |
*/
|
15 |
public abstract class AbstractElement implements Element { |
16 |
|
17 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractElement.class); |
18 |
|
19 |
final String name; |
20 |
final String description; |
21 |
final String iconName; |
22 |
final ImageIcon icon; |
23 |
|
24 |
protected AbstractElement(String name, String description) { |
25 |
this(name,description,null); |
26 |
} |
27 |
|
28 |
protected AbstractElement(String name, String description, String iconName) { |
29 |
this.name = name;
|
30 |
this.description = description;
|
31 |
this.iconName = iconName;
|
32 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
33 |
if( theme.exists(iconName) ) {
|
34 |
this.icon = theme.get(iconName);
|
35 |
} else if( this instanceof GroupElement ) { |
36 |
this.icon = theme.get("expressionbuilder-element-group"); |
37 |
} else {
|
38 |
this.icon = theme.get("expressionbuilder-element"); |
39 |
} |
40 |
} |
41 |
|
42 |
@Override
|
43 |
public String getName() { |
44 |
return this.name; |
45 |
} |
46 |
|
47 |
@Override
|
48 |
public String getDescription() { |
49 |
return this.description; |
50 |
} |
51 |
|
52 |
@Override
|
53 |
public String getIconName() { |
54 |
return iconName;
|
55 |
} |
56 |
|
57 |
@Override
|
58 |
public ImageIcon getIcon() { |
59 |
return this.icon; |
60 |
} |
61 |
|
62 |
@Override
|
63 |
public Component getAditionalPanel() { |
64 |
return null; |
65 |
} |
66 |
|
67 |
@Override
|
68 |
public String toString() { |
69 |
return this.getName(); |
70 |
} |
71 |
|
72 |
@Override
|
73 |
public void reload() { |
74 |
} |
75 |
|
76 |
@Override
|
77 |
public boolean isEnabled() { |
78 |
return true; |
79 |
} |
80 |
|
81 |
} |