Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ToolDockable |
|
| 2.3333333333333335;2.333 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.editor.policy.gui.dock; | |
11 | ||
12 | import java.awt.BorderLayout; | |
13 | ||
14 | import bibliothek.gui.dock.common.DefaultSingleCDockable; | |
15 | ||
16 | import org.openpermis.editor.policy.view.Tool; | |
17 | ||
18 | /** | |
19 | * Dockable implementation for tool views. | |
20 | * <p>Tool views are displayed at the sides of the working area and display | |
21 | * generic information like search results, filtered trees and other non-editable | |
22 | * information.</p> | |
23 | * <p>The difference between an {@code EditorDockable} and a {@link ToolDockable} | |
24 | * is that while a tool dockable is unique there may be several {@code EditorDockable}s | |
25 | * that display different parts of a policy.</p> | |
26 | * @see EditorDockable | |
27 | * @since 0.1.0 | |
28 | */ | |
29 | 0 | public class ToolDockable |
30 | extends DefaultSingleCDockable | |
31 | implements ViewDockable | |
32 | { | |
33 | ||
34 | //---- State | |
35 | ||
36 | /** | |
37 | * The view that is attached to this tool dockable. | |
38 | * @since 0.1.0 | |
39 | */ | |
40 | private final Tool view; | |
41 | ||
42 | //---- Constructors | |
43 | ||
44 | /** | |
45 | * Creates a new tool dockable and attaches the specified view. | |
46 | * @param view the view displayed by this tool. | |
47 | * @since 0.1.0 | |
48 | */ | |
49 | public ToolDockable (Tool view) { | |
50 | 0 | super(view.getToolIdentifier(), view.getTitle()); |
51 | 0 | this.view = view; |
52 | 0 | setCloseable(true); |
53 | 0 | setExternalizable(false); |
54 | 0 | setMinimizable(false); |
55 | 0 | setMaximizable(true); |
56 | 0 | setTitleIcon(view.getIcon()); |
57 | // putAction(CDockable.ACTION_KEY_MAXIMIZE, CBlank.BLANK); | |
58 | 0 | getContentPane().setLayout(new BorderLayout()); |
59 | 0 | if (view.getToolBar() != null) { |
60 | 0 | getContentPane().add(view.getToolBar(), BorderLayout.NORTH); |
61 | } | |
62 | 0 | if (view.getContentPane() != null) { |
63 | 0 | getContentPane().add(view.getContentPane(), BorderLayout.CENTER); |
64 | } | |
65 | 0 | } |
66 | ||
67 | //---- ViewDockable | |
68 | ||
69 | /** | |
70 | * @since 0.1.0 | |
71 | */ | |
72 | public Tool getView () { | |
73 | 0 | return this.view; |
74 | } | |
75 | ||
76 | /** | |
77 | * @since 0.1.0 | |
78 | */ | |
79 | public void updateTitle () { | |
80 | 0 | setTitleText(this.view == null ? "" : this.view.getTitle()); |
81 | 0 | setTitleIcon(this.view == null ? null : this.view.getIcon()); |
82 | 0 | } |
83 | ||
84 | } |