1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.services.gui.swing.frames;
18
19 import javax.swing.JComponent;
20
21 import org.bushe.swing.event.annotation.AnnotationProcessor;
22 import org.noos.xing.mydoggy.Content;
23
24 import ch.elca.el4j.services.gui.swing.wrapper.AbstractWrapperFactory;
25
26
27
28
29
30
31
32
33 public class ContentApplicationFrame implements ApplicationFrame {
34
35
36
37 protected Content m_content;
38
39
40
41
42 protected ContentConfiguration m_contentConfiguration;
43
44
45
46
47
48 public ContentApplicationFrame(ContentConfiguration contentDescriptor) {
49 m_contentConfiguration = contentDescriptor;
50 }
51
52
53 public JComponent getContent() {
54 if (m_content == null) {
55 return m_contentConfiguration.getComponent();
56 } else {
57 return (JComponent) m_content.getComponent();
58 }
59 }
60
61
62 public void setContent(JComponent component) {
63 checkFrame();
64 m_content.setComponent(component);
65
66 if (component instanceof ApplicationFrameAware) {
67 ApplicationFrameAware awareComponent = (ApplicationFrameAware) component;
68 awareComponent.setApplicationFrame(this);
69 }
70 }
71
72
73 public Object getFrame() {
74 if (m_content != null && m_content.getDockableManager() == null) {
75 m_content = null;
76 }
77 return m_content;
78 }
79
80
81 public void setFrame(Object frame) {
82 m_content = (Content) frame;
83 }
84
85
86 public void setName(String name) {
87 if (m_content == null) {
88 m_contentConfiguration.setId(name);
89 }
90
91 }
92
93
94 public void setTitle(String title) {
95 if (m_content == null) {
96 m_contentConfiguration.setTitle(title);
97 } else {
98 m_content.setTitle(title);
99 }
100 }
101
102
103 public void setMinimizable(boolean minimizable) {
104 checkFrame();
105 m_content.getContentUI().setMinimizable(minimizable);
106 }
107
108
109 public void setMaximizable(boolean maximizable) {
110 checkFrame();
111
112 }
113
114
115 public void setClosable(boolean closable) {
116 checkFrame();
117 m_content.getContentUI().setCloseable(closable);
118 }
119
120
121 public void setMinimized(boolean minimized) {
122 checkFrame();
123 m_content.setMinimized(minimized);
124 }
125
126
127 public void setMaximized(boolean maximized) {
128 checkFrame();
129 m_content.setMaximized(maximized);
130 }
131
132
133 public void show() {
134
135 AnnotationProcessor.process(getContent());
136
137
138 }
139
140
141 public void setSelected(boolean selected) {
142 checkFrame();
143 m_content.setSelected(selected);
144 }
145
146
147 public void close() {
148 checkFrame();
149 if (getContent() != null) {
150
151 AnnotationProcessor.unsubscribe(getContent());
152 }
153 AbstractWrapperFactory.removeWrapper(getContent());
154
155 m_content.getDockableManager().removeContent(m_content);
156 m_content = null;
157 }
158
159
160
161
162 public ContentConfiguration getConfiguration() {
163 return m_contentConfiguration;
164 }
165
166
167
168
169 public void setConfiguration(ContentConfiguration configuration) {
170 m_contentConfiguration = configuration;
171 }
172
173
174
175
176 private void checkFrame() {
177 if (m_content == null) {
178 throw new IllegalStateException("Frame is not yet set.");
179 }
180 }
181 }