Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SettingsTabPreferences |
|
| 1.125;1.125 |
1 | /* $Id: SettingsTabPreferences.java 17841 2010-01-12 19:17:52Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * tfmorris | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2007 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.ui; | |
40 | ||
41 | import java.awt.BorderLayout; | |
42 | import java.awt.GridBagConstraints; | |
43 | import java.awt.GridBagLayout; | |
44 | import java.awt.Insets; | |
45 | ||
46 | import javax.swing.JCheckBox; | |
47 | import javax.swing.JPanel; | |
48 | ||
49 | import org.argouml.application.api.Argo; | |
50 | import org.argouml.application.api.GUISettingsTabInterface; | |
51 | import org.argouml.configuration.Configuration; | |
52 | import org.argouml.i18n.Translator; | |
53 | ||
54 | /** | |
55 | * Settings tab panel for handling ArgoUML application related settings. | |
56 | * | |
57 | * @author Thierry Lach | |
58 | * @since 0.9.4 | |
59 | */ | |
60 | class SettingsTabPreferences extends JPanel | |
61 | implements GUISettingsTabInterface { | |
62 | ||
63 | private JPanel topPanel; | |
64 | private JCheckBox chkSplash; | |
65 | private JCheckBox chkReloadRecent; | |
66 | private JCheckBox chkStripDiagrams; | |
67 | ||
68 | /** | |
69 | * The constructor. | |
70 | * | |
71 | */ | |
72 | 900 | SettingsTabPreferences() { |
73 | 900 | } |
74 | ||
75 | private void buildPanel() { | |
76 | 19 | setLayout(new BorderLayout()); |
77 | 19 | topPanel = new JPanel(); |
78 | 19 | topPanel.setLayout(new GridBagLayout()); |
79 | ||
80 | 19 | GridBagConstraints checkConstraints = new GridBagConstraints(); |
81 | 19 | checkConstraints.anchor = GridBagConstraints.LINE_START; |
82 | 19 | checkConstraints.gridy = 0; |
83 | 19 | checkConstraints.gridx = 0; |
84 | 19 | checkConstraints.gridwidth = 1; |
85 | 19 | checkConstraints.gridheight = 1; |
86 | 19 | checkConstraints.insets = new Insets(4, 10, 0, 10); |
87 | ||
88 | 19 | checkConstraints.gridy = 2; |
89 | 19 | JCheckBox j = new JCheckBox(Translator.localize("label.splash")); |
90 | 19 | chkSplash = j; |
91 | 19 | topPanel.add(chkSplash, checkConstraints); |
92 | ||
93 | 19 | checkConstraints.gridy++; |
94 | 19 | JCheckBox j2 = |
95 | new JCheckBox(Translator.localize("label.reload-recent")); | |
96 | 19 | chkReloadRecent = j2; |
97 | 19 | topPanel.add(chkReloadRecent, checkConstraints); |
98 | ||
99 | 19 | checkConstraints.gridy++; |
100 | 19 | JCheckBox j3 = |
101 | new JCheckBox(Translator.localize("label.strip-diagrams")); | |
102 | 19 | chkStripDiagrams = j3; |
103 | 19 | topPanel.add(chkStripDiagrams, checkConstraints); |
104 | ||
105 | 19 | checkConstraints.fill = GridBagConstraints.HORIZONTAL; |
106 | ||
107 | 19 | add(topPanel, BorderLayout.NORTH); |
108 | 19 | } |
109 | ||
110 | /* | |
111 | * @see GUISettingsTabInterface#handleSettingsTabRefresh() | |
112 | */ | |
113 | public void handleSettingsTabRefresh() { | |
114 | 19 | chkSplash.setSelected(Configuration.getBoolean(Argo.KEY_SPLASH, true)); |
115 | 19 | chkReloadRecent.setSelected( |
116 | Configuration.getBoolean(Argo.KEY_RELOAD_RECENT_PROJECT, | |
117 | false)); | |
118 | 19 | chkStripDiagrams.setSelected( |
119 | Configuration.getBoolean(Argo.KEY_XMI_STRIP_DIAGRAMS, | |
120 | false)); | |
121 | 19 | } |
122 | ||
123 | /* | |
124 | * @see GUISettingsTabInterface#handleSettingsTabSave() | |
125 | */ | |
126 | public void handleSettingsTabSave() { | |
127 | 0 | Configuration.setBoolean(Argo.KEY_SPLASH, chkSplash.isSelected()); |
128 | 0 | Configuration.setBoolean(Argo.KEY_RELOAD_RECENT_PROJECT, |
129 | chkReloadRecent.isSelected()); | |
130 | 0 | Configuration.setBoolean(Argo.KEY_XMI_STRIP_DIAGRAMS, |
131 | chkStripDiagrams.isSelected()); | |
132 | 0 | } |
133 | ||
134 | /* | |
135 | * @see GUISettingsTabInterface#handleSettingsTabCancel() | |
136 | */ | |
137 | public void handleSettingsTabCancel() { | |
138 | 0 | handleSettingsTabRefresh(); |
139 | 0 | } |
140 | ||
141 | /* | |
142 | * @see org.argouml.ui.GUISettingsTabInterface#handleResetToDefault() | |
143 | */ | |
144 | public void handleResetToDefault() { | |
145 | // Do nothing - these buttons are not shown. | |
146 | 0 | } |
147 | ||
148 | /* | |
149 | * @see GUISettingsTabInterface#getTabPanel() | |
150 | */ | |
151 | public JPanel getTabPanel() { | |
152 | 19 | if (topPanel == null) { |
153 | 19 | buildPanel(); |
154 | } | |
155 | 19 | return this; |
156 | } | |
157 | ||
158 | /* | |
159 | * @see GUISettingsTabInterface#getTabKey() | |
160 | */ | |
161 | public String getTabKey() { | |
162 | 19 | return "tab.preferences"; |
163 | } | |
164 | ||
165 | /** | |
166 | * The UID. | |
167 | */ | |
168 | private static final long serialVersionUID = -340220974967836979L; | |
169 | } | |
170 |