1 |
|
---|
2 | package de.ugoe.cs.quest.plugin.jfc.guimodel;
|
---|
3 |
|
---|
4 | import de.ugoe.cs.quest.eventcore.guimodel.AbstractDefaultGUIElement;
|
---|
5 | import de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * <p>
|
---|
9 | * Base class for all JFC GUI elements.
|
---|
10 | * </p>
|
---|
11 | *
|
---|
12 | * @version 1.0
|
---|
13 | * @author Patrick Harms
|
---|
14 | */
|
---|
15 | public class JFCGUIElement extends AbstractDefaultGUIElement {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * <p>
|
---|
19 | * Id for object serialization.
|
---|
20 | * </p>
|
---|
21 | */
|
---|
22 | private static final long serialVersionUID = 1L;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * <p>
|
---|
26 | * Specification of the GUI Element
|
---|
27 | * </p>
|
---|
28 | */
|
---|
29 | private JFCGUIElementSpec specification;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * <p>
|
---|
33 | * Constructor. Creates a new JFCGUIElement.
|
---|
34 | * </p>
|
---|
35 | *
|
---|
36 | * @param specification
|
---|
37 | * specification of created GUI element
|
---|
38 | * @param parent
|
---|
39 | * parent of the created GUI element; null means that the element is a top-level
|
---|
40 | * window
|
---|
41 | */
|
---|
42 | public JFCGUIElement(JFCGUIElementSpec specification, JFCGUIElement parent) {
|
---|
43 | super(specification, parent);
|
---|
44 | this.specification = specification;
|
---|
45 | }
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * (non-Javadoc)
|
---|
49 | *
|
---|
50 | * @see de.ugoe.cs.quest.eventcore.IEventTarget#getPlatform()
|
---|
51 | */
|
---|
52 | @Override
|
---|
53 | public String getPlatform() {
|
---|
54 | return "JFC";
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * <p>
|
---|
59 | * Returns the type of the GUI element, i.e., the name of its Java class.
|
---|
60 | * </p>
|
---|
61 | *
|
---|
62 | * @return the Java class name
|
---|
63 | */
|
---|
64 | public String getJavaType() {
|
---|
65 | return specification.getType();
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * <p>
|
---|
70 | * Returns the name of the GUI element.
|
---|
71 | * </p>
|
---|
72 | *
|
---|
73 | * @return the name
|
---|
74 | */
|
---|
75 | String getName() {
|
---|
76 | return specification.getName();
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * <p>
|
---|
81 | * Returns the icon of the GUI element.
|
---|
82 | * </p>
|
---|
83 | *
|
---|
84 | * @return the icon
|
---|
85 | */
|
---|
86 | String getIcon() {
|
---|
87 | return specification.getIcon();
|
---|
88 | }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * <p>
|
---|
92 | * Returns the index of the GUI element.
|
---|
93 | * </p>
|
---|
94 | *
|
---|
95 | * @return the index
|
---|
96 | */
|
---|
97 | int getIndex() {
|
---|
98 | return specification.getIndex();
|
---|
99 | }
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * <p>
|
---|
103 | * Returns the object hash of the GUI element.
|
---|
104 | * </p>
|
---|
105 | *
|
---|
106 | * @return the object hash
|
---|
107 | */
|
---|
108 | int getElementHash() {
|
---|
109 | return specification.getElementHash();
|
---|
110 | }
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * (non-Javadoc)
|
---|
114 | *
|
---|
115 | * @see
|
---|
116 | * de.ugoe.cs.quest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.quest.eventcore
|
---|
117 | * .guimodel.IGUIElementSpec)
|
---|
118 | */
|
---|
119 | @Override
|
---|
120 | public void updateSpecification(IGUIElementSpec updateSpecification) {
|
---|
121 | if (updateSpecification instanceof JFCGUIElementSpec) {
|
---|
122 | specification.update(((JFCGUIElementSpec) updateSpecification));
|
---|
123 | }
|
---|
124 | }
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * (non-Javadoc)
|
---|
128 | *
|
---|
129 | * @see java.lang.Object#toString()
|
---|
130 | */
|
---|
131 | @Override
|
---|
132 | public String getStringIdentifier() {
|
---|
133 | String str = this.toString();
|
---|
134 | if (getParent() != null) {
|
---|
135 | return getParent().getStringIdentifier() + "->" + str;
|
---|
136 | }
|
---|
137 | return str;
|
---|
138 | }
|
---|
139 |
|
---|
140 | /*
|
---|
141 | * (non-Javadoc)
|
---|
142 | *
|
---|
143 | * @see java.lang.Object#toString()
|
---|
144 | */
|
---|
145 | @Override
|
---|
146 | public String toString() {
|
---|
147 | String str =
|
---|
148 | getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getIcon() +
|
---|
149 | "," + getIndex() + ")";
|
---|
150 | return str;
|
---|
151 | }
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * <p>
|
---|
155 | * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
|
---|
156 | * </p>
|
---|
157 | *
|
---|
158 | * @return short element descriptor
|
---|
159 | */
|
---|
160 | protected String getElementDescriptor() {
|
---|
161 | return "Default";
|
---|
162 | }
|
---|
163 |
|
---|
164 | }
|
---|