1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hivegui.docking; |
16 | |
17 | import javax.swing.JComponent; |
18 | |
19 | import org.flexdock.docking.Dockable; |
20 | import org.flexdock.docking.DockableFactory; |
21 | |
22 | public class HiveGuiDockableFactory extends DockableFactory.Stub |
23 | { |
24 | public HiveGuiDockableFactory( ViewContentFactory contentFactory, |
25 | ViewFactory viewFactory) |
26 | { |
27 | _contentFactory = contentFactory; |
28 | _viewFactory = viewFactory; |
29 | } |
30 | |
31 | @Override public Dockable getDockable(String id) |
32 | { |
33 | if (EmptyableViewport.EMPTY_VIEW_ID.equals(id)) |
34 | { |
35 | return getEmptyView(); |
36 | } |
37 | else |
38 | { |
39 | return createDockable(id); |
40 | } |
41 | } |
42 | |
43 | protected Dockable createDockable(String id) |
44 | { |
45 | // Instantiate actual component |
46 | JComponent content = _contentFactory.createContent(id); |
47 | // Instantiate dockable view |
48 | return _viewFactory.createView(id, content); |
49 | } |
50 | |
51 | protected Dockable getEmptyView() |
52 | { |
53 | if (_emptyView == null) |
54 | { |
55 | _emptyView = createDockable(EmptyableViewport.EMPTY_VIEW_ID); |
56 | } |
57 | return _emptyView; |
58 | } |
59 | |
60 | protected final ViewContentFactory _contentFactory; |
61 | protected final ViewFactory _viewFactory; |
62 | protected Dockable _emptyView; |
63 | } |