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 java.beans.PropertyVetoException;
20
21 import javax.swing.JComponent;
22 import javax.swing.JInternalFrame;
23
24 import org.bushe.swing.event.annotation.AnnotationProcessor;
25
26 import ch.elca.el4j.services.gui.swing.wrapper.AbstractWrapperFactory;
27
28
29
30
31
32
33
34
35 public class InternalApplicationFrame implements ApplicationFrame {
36
37
38
39 private JInternalFrame m_internalFrame;
40
41
42
43
44 public InternalApplicationFrame(JInternalFrame internalFrame) {
45 m_internalFrame = internalFrame;
46 }
47
48
49 public JComponent getContent() {
50 return (JComponent) m_internalFrame.getContentPane();
51 }
52
53
54 public Object getFrame() {
55 return m_internalFrame;
56 }
57
58
59 public void setFrame(Object frame) {
60 m_internalFrame = (JInternalFrame) frame;
61 }
62
63
64 public void setName(String name) {
65 m_internalFrame.setName(name);
66 }
67
68
69 public void setContent(JComponent component) {
70 m_internalFrame.setContentPane(component);
71
72 if (component instanceof ApplicationFrameAware) {
73 ApplicationFrameAware awareComponent = (ApplicationFrameAware) component;
74 awareComponent.setApplicationFrame(this);
75 }
76
77 m_internalFrame.setClosable(true);
78 m_internalFrame.setResizable(true);
79 m_internalFrame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
80 m_internalFrame.pack();
81 }
82
83
84 public void setMinimizable(boolean minimizable) {
85 m_internalFrame.setIconifiable(minimizable);
86 }
87
88
89 public void setMaximizable(boolean maximizable) {
90 m_internalFrame.setMaximizable(maximizable);
91 }
92
93
94 public void setClosable(boolean closable) {
95 m_internalFrame.setClosable(closable);
96 }
97
98
99 public void setTitle(String title) {
100 m_internalFrame.setTitle(title);
101 }
102
103
104 public void setMinimized(boolean minimized) {
105 try {
106 m_internalFrame.setIcon(minimized);
107 } catch (PropertyVetoException e) {
108 return;
109 }
110 }
111
112
113 public void setMaximized(boolean maximized) {
114 try {
115 m_internalFrame.setMaximum(maximized);
116 } catch (PropertyVetoException e) {
117 return;
118 }
119 }
120
121
122 public void show() {
123
124 AnnotationProcessor.process(getContent());
125
126 m_internalFrame.show();
127 }
128
129
130 public void setSelected(boolean selected) {
131 try {
132 m_internalFrame.setSelected(selected);
133 } catch (PropertyVetoException e) {
134 return;
135 }
136 }
137
138
139 public void close() {
140 if (getContent() != null) {
141
142 AnnotationProcessor.unsubscribe(getContent());
143 }
144
145 AbstractWrapperFactory.removeWrapper(getContent());
146 m_internalFrame.dispose();
147 }
148 }