1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2008 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
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.ToolWindowAnchor;
23
24 import ch.elca.el4j.services.gui.swing.frames.ToolWindowTabApplicationFrame;
25 import ch.elca.el4j.services.gui.swing.frames.ToolWindowTabConfiguration;
26
27 /**
28 * This factory wraps components into {@link ToolWindowTabApplicationFrame}s.
29 *
30 * @svnLink $Revision: 3884 $;$Date: 2009-08-04 15:48:31 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/swing/src/main/java/ch/elca/el4j/services/gui/swing/wrapper/ToolWindowWrapperFactory.java $
31 *
32 * @author Stefan Wismer (SWI)
33 */
34 public class ToolWindowWrapperFactory extends AbstractWrapperFactory<ToolWindowTabApplicationFrame> {
35 /**
36 * The abstract factory.
37 */
38 private static AbstractWrapperFactory<ToolWindowTabApplicationFrame> s_factory = null;
39
40 /**
41 * Wraps a GUI component into a {@link JFrame}.
42 *
43 * @param component the component to wrap
44 * @return the wrapper
45 */
46 public static ToolWindowTabApplicationFrame wrap(JComponent component) {
47 if (s_factory == null) {
48 s_factory = new ToolWindowWrapperFactory();
49 }
50 return s_factory.wrapComponent(component);
51 }
52
53 /** {@inheritDoc} */
54 @Override
55 protected ToolWindowTabApplicationFrame createApplicationFrame(String name, String title, JComponent component) {
56 /*DockingApplication application = (DockingApplication) GUIApplication.getInstance();
57
58 final ToolWindowManager toolWindowManager = application.getToolWindowManager();
59
60 String id = "__tmp";
61 ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
62 if (toolWindow == null) {
63 toolWindow = toolWindowManager.registerToolWindow(
64 id, id, null, component, ToolWindowAnchor.BOTTOM);
65
66 DockedTypeDescriptor typeDescriptor = (DockedTypeDescriptor)
67 toolWindow.getTypeDescriptor(ToolWindowType.DOCKED);
68
69 // default behavior: close tool window when clicking on X
70 typeDescriptor.setToolWindowActionHandler(new ToolWindowActionHandler() {
71 public void onHideButtonClick(ToolWindow toolWindow) {
72 toolWindowManager.unregisterToolWindow(toolWindow.getId());
73 }
74 });
75 }
76
77 // Register the tool.
78 ToolWindow tool = toolWindowManager.registerToolWindow(
79 name, title, null,
80 component, ToolWindowAnchor.BOTTOM);
81
82 tool.setAvailable(false);
83
84 DockedTypeDescriptor typeDescriptor = (DockedTypeDescriptor) tool.getTypeDescriptor(ToolWindowType.DOCKED);
85
86 // default behavior: close tool window when clicking on X
87 typeDescriptor.setToolWindowActionHandler(new ToolWindowActionHandler() {
88 public void onHideButtonClick(ToolWindow toolWindow) {
89 toolWindowManager.unregisterToolWindow(toolWindow.getId());
90 }
91 });
92
93 ToolWindowTab toolWindowTab = toolWindow.addToolWindowTab(tool);
94 toolWindow.removeToolWindowTab(toolWindowTab);
95
96 toolWindowManager.unregisterToolWindow(id);*/
97
98 ToolWindowTabConfiguration configuration = new ToolWindowTabConfiguration(
99 name, title, null, component, ToolWindowAnchor.BOTTOM);
100
101 return new ToolWindowTabApplicationFrame(configuration);
102 }
103 }