1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.services.gui.swing.wrapper;
18
19 import javax.swing.JComponent;
20 import javax.swing.JFrame;
21
22 import org.noos.xing.mydoggy.ContentManager;
23
24 import ch.elca.el4j.services.gui.swing.DockingApplication;
25 import ch.elca.el4j.services.gui.swing.GUIApplication;
26 import ch.elca.el4j.services.gui.swing.frames.ContentApplicationFrame;
27 import ch.elca.el4j.services.gui.swing.frames.ContentConfiguration;
28
29
30
31
32
33
34
35
36 public class ContentWrapperFactory extends AbstractWrapperFactory<ContentApplicationFrame> {
37
38
39
40 private static AbstractWrapperFactory<ContentApplicationFrame> s_factory = null;
41
42
43
44
45
46
47
48 public static ContentApplicationFrame wrap(JComponent component) {
49 if (s_factory == null) {
50 s_factory = new ContentWrapperFactory();
51 }
52 return s_factory.wrapComponent(component);
53 }
54
55
56 @Override
57 protected ContentApplicationFrame createApplicationFrame(String name, String title, JComponent component) {
58 DockingApplication application = (DockingApplication) GUIApplication.getInstance();
59
60 ContentManager contentManager = application.getToolWindowManager().getContentManager();
61
62
63 String uniqueName = title;
64 if (contentManager.getContent(uniqueName) != null) {
65 int index = 1;
66 while (contentManager.getContent(uniqueName + " (" + index + ")") != null) {
67 index++;
68 }
69 uniqueName = uniqueName + " (" + index + ")";
70 }
71
72 ContentConfiguration contentDescriptor = new ContentConfiguration(uniqueName, title, null, component);
73
74 return new ContentApplicationFrame(contentDescriptor);
75 }
76 }