Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ProjectSettings |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$1 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$10 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$11 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$12 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$13 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$2 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$3 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$4 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$5 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$6 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$7 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$8 |
|
| 1.2871287128712872;1.287 | ||||
ProjectSettings$9 |
|
| 1.2871287128712872;1.287 |
1 | /* $Id: ProjectSettings.java 18876 2010-12-04 17:33:08Z bobtarling $ | |
2 | ******************************************************************************* | |
3 | * Copyright (c) 2010 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 | * Michiel van der Wulp | |
11 | * Bob Tarling | |
12 | ******************************************************************************* | |
13 | * | |
14 | * Some portions of this file were previously release using the BSD License: | |
15 | */ | |
16 | ||
17 | // $Id: ProjectSettings.java 18876 2010-12-04 17:33:08Z bobtarling $ | |
18 | // Copyright (c) 2006-2009 The Regents of the University of California. All | |
19 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
20 | // software and its documentation without fee, and without a written | |
21 | // agreement is hereby granted, provided that the above copyright notice | |
22 | // and this paragraph appear in all copies. This software program and | |
23 | // documentation are copyrighted by The Regents of the University of | |
24 | // California. The software program and documentation are supplied "AS | |
25 | // IS", without any accompanying services from The Regents. The Regents | |
26 | // does not warrant that the operation of the program will be | |
27 | // uninterrupted or error-free. The end-user understands that the program | |
28 | // was developed for research purposes and is advised not to rely | |
29 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
30 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
31 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
32 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
33 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
34 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
35 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
36 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
37 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
38 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
39 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
40 | ||
41 | package org.argouml.kernel; | |
42 | ||
43 | import java.awt.Font; | |
44 | import java.beans.PropertyChangeEvent; | |
45 | ||
46 | import org.argouml.application.events.ArgoEventPump; | |
47 | import org.argouml.application.events.ArgoEventTypes; | |
48 | import org.argouml.application.events.ArgoNotationEvent; | |
49 | import org.argouml.configuration.Configuration; | |
50 | import org.argouml.configuration.ConfigurationKey; | |
51 | import org.argouml.notation.Notation; | |
52 | import org.argouml.notation.NotationName; | |
53 | import org.argouml.notation.NotationSettings; | |
54 | import org.argouml.uml.diagram.DiagramSettings; | |
55 | import org.tigris.gef.undo.Memento; | |
56 | import org.tigris.gef.undo.UndoManager; | |
57 | ||
58 | /** | |
59 | * A datastructure for settings for a Project. <p> | |
60 | * | |
61 | * Most getters return a string, since they are used by "argo.tee". | |
62 | * This is also the reason all these attributes | |
63 | * are not part of a Map or something. <p> | |
64 | * | |
65 | * TODO: The header comment is currently not used - this function | |
66 | * is not completely implemented yet. How do we store this in the project? | |
67 | * Where should the user enter his header comment? See issue 4813. | |
68 | * | |
69 | * @author michiel | |
70 | */ | |
71 | 2 | public class ProjectSettings { |
72 | ||
73 | // Default diagram settings | |
74 | private DiagramSettings diaDefault; | |
75 | ||
76 | // Default notation settings | |
77 | private NotationSettings npSettings; | |
78 | ||
79 | /** Setting to control whether stereotypes are shown in explorer view */ | |
80 | private boolean showExplorerStereotypes; | |
81 | ||
82 | /* Generation preferences: */ | |
83 | 968 | private String headerComment = |
84 | "Your copyright and other header comments"; | |
85 | ||
86 | private Project project; | |
87 | ||
88 | /** | |
89 | * Create a new set of project settings for the given project, | |
90 | * based on the application defaults. <p> | |
91 | * | |
92 | * The constructor is not public, since this | |
93 | * class is only created from the Project.. | |
94 | * @param project the project owning these settings | |
95 | */ | |
96 | ProjectSettings(Project project) { | |
97 | 968 | this(); |
98 | 968 | this.project = project; |
99 | 968 | } |
100 | ||
101 | /** | |
102 | * Create a new set of project settings, | |
103 | * based on the application defaults. <p> | |
104 | * | |
105 | * The constructor is not public, since this | |
106 | * class is only created from the Project.. | |
107 | */ | |
108 | ProjectSettings() { | |
109 | 968 | super(); |
110 | ||
111 | 968 | diaDefault = new DiagramSettings(); |
112 | 968 | diaDefault.initFromConfiguration(); |
113 | ||
114 | 968 | npSettings = diaDefault.getNotationSettings(); |
115 | ||
116 | 968 | String notationLanguage = |
117 | Notation.getConfiguredNotation().getConfigurationValue(); | |
118 | 968 | npSettings.setNotationLanguage(notationLanguage); |
119 | ||
120 | 968 | npSettings.setUseGuillemets(Configuration.getBoolean( |
121 | Notation.KEY_USE_GUILLEMOTS, false)); | |
122 | /* | |
123 | * The next one defaults to TRUE, to stay compatible with older | |
124 | * ArgoUML versions that did not have this setting: | |
125 | */ | |
126 | 968 | npSettings.setShowAssociationNames(Configuration.getBoolean( |
127 | Notation.KEY_SHOW_ASSOCIATION_NAMES, true)); | |
128 | 968 | npSettings.setShowVisibilities(Configuration.getBoolean( |
129 | Notation.KEY_SHOW_VISIBILITY)); | |
130 | 968 | npSettings.setShowMultiplicities(Configuration.getBoolean( |
131 | Notation.KEY_SHOW_MULTIPLICITY)); | |
132 | 968 | npSettings.setShowInitialValues(Configuration.getBoolean( |
133 | Notation.KEY_SHOW_INITIAL_VALUE)); | |
134 | 968 | npSettings.setShowProperties(Configuration.getBoolean( |
135 | Notation.KEY_SHOW_PROPERTIES)); | |
136 | /* | |
137 | * The next ones defaults to TRUE, to stay compatible with older | |
138 | * ArgoUML versions that did not have this setting: | |
139 | */ | |
140 | 968 | npSettings.setShowTypes(Configuration.getBoolean( |
141 | Notation.KEY_SHOW_TYPES, true)); | |
142 | ||
143 | 968 | showExplorerStereotypes = Configuration.getBoolean( |
144 | Notation.KEY_SHOW_STEREOTYPES); | |
145 | /* | |
146 | * The next one defaults to TRUE, despite that this is | |
147 | * NOT compatible with older ArgoUML versions | |
148 | * (before 0.24) that did | |
149 | * not have this setting - see issue 1395 for the rationale: | |
150 | */ | |
151 | 968 | npSettings.setShowSingularMultiplicities(Configuration.getBoolean( |
152 | Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES, true)); | |
153 | 968 | } |
154 | ||
155 | /** | |
156 | * Send all events required for post-load of project.<p> | |
157 | * @deprecated for 0.27.2 by tfmorris. No replacement. Diagrams/Figs are | |
158 | * now created with the correct initial settings. | |
159 | */ | |
160 | @Deprecated | |
161 | public void init() { | |
162 | /* | |
163 | * Since this is (hopefully) a temporary solution, and nobody ever looks | |
164 | * at the type of notation event, we can simplify from sending every | |
165 | * existing event to one event only. But since there is no catch-all | |
166 | * event defined, we just make one up. Rationale: reduce the number of | |
167 | * total refreshes of the drawing. | |
168 | */ | |
169 | 0 | init(true, Configuration.makeKey("notation", "all")); |
170 | ||
171 | 0 | diaDefault.notifyOfChangedSettings(); |
172 | 0 | } |
173 | ||
174 | private void init(boolean value, ConfigurationKey key) { | |
175 | 0 | fireNotationEvent(key, value, value); |
176 | 0 | } |
177 | ||
178 | /** | |
179 | * @return the default diagram settings | |
180 | */ | |
181 | public DiagramSettings getDefaultDiagramSettings() { | |
182 | 2687 | return diaDefault; |
183 | } | |
184 | ||
185 | /** | |
186 | * @return the default project wide notation settings | |
187 | */ | |
188 | public NotationSettings getNotationSettings() { | |
189 | 132 | return npSettings; |
190 | } | |
191 | ||
192 | /** | |
193 | * Used by "argo.tee". | |
194 | * | |
195 | * @return Returns the notation language. | |
196 | */ | |
197 | public String getNotationLanguage() { | |
198 | 157 | return npSettings.getNotationLanguage(); |
199 | } | |
200 | ||
201 | /** | |
202 | * @return Return the notation name. | |
203 | */ | |
204 | public NotationName getNotationName() { | |
205 | 22 | return Notation.findNotation(getNotationLanguage()); |
206 | } | |
207 | ||
208 | /** | |
209 | * @param newLanguage the notation language. | |
210 | * @return true if the notation is set - false if it does not exist | |
211 | */ | |
212 | public boolean setNotationLanguage(final String newLanguage) { | |
213 | 14 | if (getNotationLanguage().equals(newLanguage)) { |
214 | 13 | return true; |
215 | } | |
216 | 1 | if (Notation.findNotation(newLanguage) == null) { |
217 | /* This Notation is not available! */ | |
218 | 0 | return false; |
219 | } | |
220 | ||
221 | 1 | final String oldLanguage = getNotationLanguage(); |
222 | ||
223 | 1 | Memento memento = new Memento() { |
224 | 1 | private final ConfigurationKey key = Notation.KEY_DEFAULT_NOTATION; |
225 | ||
226 | public void redo() { | |
227 | 1 | npSettings.setNotationLanguage(newLanguage); |
228 | 1 | fireNotationEvent(key, oldLanguage, newLanguage); |
229 | 1 | } |
230 | ||
231 | public void undo() { | |
232 | 0 | npSettings.setNotationLanguage(oldLanguage); |
233 | 0 | fireNotationEvent(key, newLanguage, oldLanguage); |
234 | 0 | } |
235 | }; | |
236 | 1 | doUndoable(memento); |
237 | 1 | return true; |
238 | } | |
239 | ||
240 | private void doUndoable(Memento memento) { | |
241 | // TODO: This needs to be managing undo on a per-project basis | |
242 | // instead of using GEF's global undo manager | |
243 | 1 | if (UndoManager.getInstance().isGenerateMementos()) { |
244 | 1 | UndoManager.getInstance().addMemento(memento); |
245 | } | |
246 | 1 | memento.redo(); |
247 | 1 | project.setDirty(true); |
248 | 1 | } |
249 | ||
250 | /** | |
251 | * @param nn the new notation language | |
252 | */ | |
253 | public void setNotationLanguage(NotationName nn) { | |
254 | 2 | setNotationLanguage(nn.getConfigurationValue()); |
255 | 2 | } |
256 | ||
257 | /** | |
258 | * Used by "argo.tee". | |
259 | * | |
260 | * @return Returns "true" if we show bold names. | |
261 | */ | |
262 | public String getShowBoldNames() { | |
263 | 0 | return Boolean.toString(diaDefault.isShowBoldNames()); |
264 | } | |
265 | ||
266 | /** | |
267 | * Used by "argo.tee". | |
268 | * | |
269 | * @see #getUseGuillemotsValue() | |
270 | * @return Returns "true" if we show guillemets. | |
271 | */ | |
272 | public String getUseGuillemots() { | |
273 | 0 | return Boolean.toString(getUseGuillemotsValue()); |
274 | } | |
275 | ||
276 | /** | |
277 | * Get setting controlling whether guillemets (the double angle brackets | |
278 | * quotation mark characters from Unicode) are to be used for formatting | |
279 | * instead of two individual characters for each quote mark (e.g. >>). NOTE: | |
280 | * This affects not only the Diagrams, but also display in the explorer view | |
281 | * and other places. | |
282 | * | |
283 | * @return Returns <code>true</code> if we show guillemets. | |
284 | */ | |
285 | public boolean getUseGuillemotsValue() { | |
286 | 132 | return npSettings.isUseGuillemets(); |
287 | } | |
288 | ||
289 | ||
290 | /** | |
291 | * @see #getUseGuillemotsValue() | |
292 | * @param showem <code>true</code> if guillemets are to be used. | |
293 | */ | |
294 | public void setUseGuillemots(String showem) { | |
295 | 0 | setUseGuillemots(Boolean.valueOf(showem).booleanValue()); |
296 | 0 | } |
297 | ||
298 | /** | |
299 | * @see #getUseGuillemotsValue() | |
300 | * @param showem <code>true</code> if guillemets are to be shown. | |
301 | */ | |
302 | public void setUseGuillemots(final boolean showem) { | |
303 | 12 | if (getUseGuillemotsValue() == showem) { |
304 | 12 | return; |
305 | } | |
306 | ||
307 | 0 | Memento memento = new Memento() { |
308 | 0 | private final ConfigurationKey key = Notation.KEY_USE_GUILLEMOTS; |
309 | ||
310 | public void redo() { | |
311 | 0 | npSettings.setUseGuillemets(showem); |
312 | 0 | fireNotationEvent(key, !showem, showem); |
313 | 0 | } |
314 | ||
315 | public void undo() { | |
316 | 0 | npSettings.setUseGuillemets(!showem); |
317 | 0 | fireNotationEvent(key, showem, !showem); |
318 | 0 | } |
319 | }; | |
320 | 0 | doUndoable(memento); |
321 | 0 | } |
322 | ||
323 | /** | |
324 | * Used by "argo.tee". | |
325 | * | |
326 | * @return Returns "true" if we show association names. | |
327 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
328 | */ | |
329 | @Deprecated | |
330 | public String getShowAssociationNames() { | |
331 | 0 | return Boolean.toString(getShowAssociationNamesValue()); |
332 | } | |
333 | ||
334 | /** | |
335 | * @return Returns <code>true</code> if we show association names. | |
336 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
337 | */ | |
338 | @Deprecated | |
339 | public boolean getShowAssociationNamesValue() { | |
340 | 0 | return npSettings.isShowAssociationNames(); |
341 | } | |
342 | ||
343 | /** | |
344 | * @param showem <code>true</code> if association names are to be shown. | |
345 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
346 | */ | |
347 | @Deprecated | |
348 | public void setShowAssociationNames(String showem) { | |
349 | 0 | setShowAssociationNames(Boolean.valueOf(showem).booleanValue()); |
350 | 0 | } |
351 | ||
352 | /** | |
353 | * @param showem <code>true</code> if association names are to be shown. | |
354 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
355 | */ | |
356 | @Deprecated | |
357 | public void setShowAssociationNames(final boolean showem) { | |
358 | 0 | if (npSettings.isShowAssociationNames() == showem) { |
359 | 0 | return; |
360 | } | |
361 | ||
362 | 0 | Memento memento = new Memento() { |
363 | 0 | private final ConfigurationKey key = |
364 | Notation.KEY_SHOW_ASSOCIATION_NAMES; | |
365 | ||
366 | public void redo() { | |
367 | 0 | npSettings.setShowAssociationNames(showem); |
368 | 0 | fireNotationEvent(key, !showem, showem); |
369 | 0 | } |
370 | ||
371 | public void undo() { | |
372 | 0 | npSettings.setShowAssociationNames(!showem); |
373 | 0 | fireNotationEvent(key, showem, !showem); |
374 | 0 | } |
375 | }; | |
376 | 0 | doUndoable(memento); |
377 | 0 | } |
378 | ||
379 | /** | |
380 | * Used by "argo.tee". | |
381 | * | |
382 | * @return Returns "true" if we show visibilities. | |
383 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
384 | */ | |
385 | @Deprecated | |
386 | public String getShowVisibility() { | |
387 | 0 | return Boolean.toString(getShowVisibilityValue()); |
388 | } | |
389 | ||
390 | /** | |
391 | * @return Returns <code>true</code> if we show visibilities. | |
392 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
393 | */ | |
394 | @Deprecated | |
395 | public boolean getShowVisibilityValue() { | |
396 | 0 | return npSettings.isShowVisibilities(); |
397 | } | |
398 | ||
399 | /** | |
400 | * @param showem <code>true</code> if visibilities are to be shown. | |
401 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
402 | */ | |
403 | @Deprecated | |
404 | public void setShowVisibility(String showem) { | |
405 | 0 | setShowVisibility(Boolean.valueOf(showem).booleanValue()); |
406 | 0 | } |
407 | ||
408 | /** | |
409 | * @param showem <code>true</code> if visibilities are to be shown. | |
410 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
411 | */ | |
412 | @Deprecated | |
413 | public void setShowVisibility(final boolean showem) { | |
414 | 0 | if (npSettings.isShowVisibilities() == showem) { |
415 | 0 | return; |
416 | } | |
417 | ||
418 | 0 | Memento memento = new Memento() { |
419 | 0 | private final ConfigurationKey key = Notation.KEY_SHOW_VISIBILITY; |
420 | ||
421 | public void redo() { | |
422 | 0 | npSettings.setShowVisibilities(showem); |
423 | 0 | fireNotationEvent(key, !showem, showem); |
424 | 0 | } |
425 | ||
426 | public void undo() { | |
427 | 0 | npSettings.setShowVisibilities(!showem); |
428 | 0 | fireNotationEvent(key, showem, !showem); |
429 | 0 | } |
430 | }; | |
431 | 0 | doUndoable(memento); |
432 | 0 | } |
433 | ||
434 | /** | |
435 | * Used by "argo.tee". | |
436 | * | |
437 | * @return Returns "true" if we show multiplicities. | |
438 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
439 | */ | |
440 | @Deprecated | |
441 | public String getShowMultiplicity() { | |
442 | 0 | return Boolean.toString(getShowMultiplicityValue()); |
443 | } | |
444 | ||
445 | /** | |
446 | * @return Returns <code>true</code> if we show multiplicities. | |
447 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
448 | */ | |
449 | @Deprecated | |
450 | public boolean getShowMultiplicityValue() { | |
451 | 0 | return npSettings.isShowMultiplicities(); |
452 | } | |
453 | ||
454 | /** | |
455 | * @param showem <code>true</code> if multiplicity is to be shown. | |
456 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
457 | */ | |
458 | @Deprecated | |
459 | public void setShowMultiplicity(String showem) { | |
460 | 0 | setShowMultiplicity(Boolean.valueOf(showem).booleanValue()); |
461 | 0 | } |
462 | ||
463 | /** | |
464 | * @param showem <code>true</code> if the multiplicity is to be shown. | |
465 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
466 | */ | |
467 | @Deprecated | |
468 | public void setShowMultiplicity(final boolean showem) { | |
469 | 0 | if (npSettings.isShowMultiplicities() == showem) { |
470 | 0 | return; |
471 | } | |
472 | ||
473 | 0 | Memento memento = new Memento() { |
474 | 0 | private final ConfigurationKey key = Notation.KEY_SHOW_MULTIPLICITY; |
475 | ||
476 | public void redo() { | |
477 | 0 | npSettings.setShowMultiplicities(showem); |
478 | 0 | fireNotationEvent(key, !showem, showem); |
479 | 0 | } |
480 | ||
481 | public void undo() { | |
482 | 0 | npSettings.setShowMultiplicities(!showem); |
483 | 0 | fireNotationEvent(key, showem, !showem); |
484 | 0 | } |
485 | }; | |
486 | 0 | doUndoable(memento); |
487 | 0 | } |
488 | ||
489 | /** | |
490 | * Used by "argo.tee". | |
491 | * | |
492 | * @return Returns "true" if we show initial values. | |
493 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
494 | */ | |
495 | @Deprecated | |
496 | public String getShowInitialValue() { | |
497 | 0 | return Boolean.toString(getShowInitialValueValue()); |
498 | } | |
499 | ||
500 | /** | |
501 | * @return Returns <code>true</code> if we show initial values. | |
502 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
503 | */ | |
504 | @Deprecated | |
505 | public boolean getShowInitialValueValue() { | |
506 | 0 | return npSettings.isShowInitialValues(); |
507 | } | |
508 | ||
509 | /** | |
510 | * @param showem <code>true</code> if initial values are to be shown. | |
511 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
512 | */ | |
513 | @Deprecated | |
514 | public void setShowInitialValue(String showem) { | |
515 | 0 | setShowInitialValue(Boolean.valueOf(showem).booleanValue()); |
516 | 0 | } |
517 | ||
518 | /** | |
519 | * @param showem <code>true</code> if initial values are to be shown. | |
520 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
521 | */ | |
522 | @Deprecated | |
523 | public void setShowInitialValue(final boolean showem) { | |
524 | 0 | if (npSettings.isShowInitialValues() == showem) { |
525 | 0 | return; |
526 | } | |
527 | ||
528 | 0 | Memento memento = new Memento() { |
529 | 0 | private final ConfigurationKey key = |
530 | Notation.KEY_SHOW_INITIAL_VALUE; | |
531 | ||
532 | public void redo() { | |
533 | 0 | npSettings.setShowInitialValues(showem); |
534 | 0 | fireNotationEvent(key, !showem, showem); |
535 | 0 | } |
536 | ||
537 | public void undo() { | |
538 | 0 | npSettings.setShowInitialValues(!showem); |
539 | 0 | fireNotationEvent(key, showem, !showem); |
540 | 0 | } |
541 | }; | |
542 | 0 | doUndoable(memento); |
543 | 0 | } |
544 | ||
545 | /** | |
546 | * Used by "argo.tee". | |
547 | * | |
548 | * @return Returns "true" if we show properties. | |
549 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
550 | */ | |
551 | @Deprecated | |
552 | public String getShowProperties() { | |
553 | 0 | return Boolean.toString(getShowPropertiesValue()); |
554 | } | |
555 | ||
556 | /** | |
557 | * @return Returns <code>true</code> if we show properties. | |
558 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
559 | */ | |
560 | @Deprecated | |
561 | public boolean getShowPropertiesValue() { | |
562 | 0 | return npSettings.isShowProperties(); |
563 | } | |
564 | ||
565 | /** | |
566 | * @param showem <code>true</code> if properties are to be shown. | |
567 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
568 | */ | |
569 | @Deprecated | |
570 | public void setShowProperties(String showem) { | |
571 | 0 | setShowProperties(Boolean.valueOf(showem).booleanValue()); |
572 | 0 | } |
573 | ||
574 | /** | |
575 | * @param showem <code>true</code> if properties are to be shown. | |
576 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
577 | */ | |
578 | @Deprecated | |
579 | public void setShowProperties(final boolean showem) { | |
580 | 0 | if (npSettings.isShowProperties() == showem) { |
581 | 0 | return; |
582 | } | |
583 | ||
584 | 0 | Memento memento = new Memento() { |
585 | 0 | private final ConfigurationKey key = |
586 | Notation.KEY_SHOW_PROPERTIES; | |
587 | ||
588 | public void redo() { | |
589 | 0 | npSettings.setShowProperties(showem); |
590 | 0 | fireNotationEvent(key, !showem, showem); |
591 | 0 | } |
592 | ||
593 | public void undo() { | |
594 | 0 | npSettings.setShowProperties(!showem); |
595 | 0 | fireNotationEvent(key, showem, !showem); |
596 | 0 | } |
597 | }; | |
598 | 0 | doUndoable(memento); |
599 | 0 | } |
600 | ||
601 | /** | |
602 | * Used by "argo.tee". | |
603 | * | |
604 | * @return Returns "true" if we show types. | |
605 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
606 | */ | |
607 | @Deprecated | |
608 | public String getShowTypes() { | |
609 | 0 | return Boolean.toString(getShowTypesValue()); |
610 | } | |
611 | ||
612 | /** | |
613 | * @return Returns <code>true</code> if we show types. | |
614 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
615 | */ | |
616 | @Deprecated | |
617 | public boolean getShowTypesValue() { | |
618 | 0 | return npSettings.isShowTypes(); |
619 | } | |
620 | ||
621 | /** | |
622 | * @param showem <code>true</code> if types are to be shown. | |
623 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
624 | */ | |
625 | @Deprecated | |
626 | public void setShowTypes(String showem) { | |
627 | 0 | setShowTypes(Boolean.valueOf(showem).booleanValue()); |
628 | 0 | } |
629 | ||
630 | /** | |
631 | * @param showem <code>true</code> if types are to be shown. | |
632 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
633 | */ | |
634 | @Deprecated | |
635 | public void setShowTypes(final boolean showem) { | |
636 | 0 | if (npSettings.isShowTypes() == showem) { |
637 | 0 | return; |
638 | } | |
639 | ||
640 | 0 | Memento memento = new Memento() { |
641 | 0 | private final ConfigurationKey key = Notation.KEY_SHOW_TYPES; |
642 | ||
643 | public void redo() { | |
644 | 0 | npSettings.setShowTypes(showem); |
645 | 0 | fireNotationEvent(key, !showem, showem); |
646 | 0 | } |
647 | ||
648 | public void undo() { | |
649 | 0 | npSettings.setShowTypes(!showem); |
650 | 0 | fireNotationEvent(key, showem, !showem); |
651 | 0 | } |
652 | }; | |
653 | 0 | doUndoable(memento); |
654 | 0 | } |
655 | ||
656 | ||
657 | /** | |
658 | * Used by "argo.tee". | |
659 | * | |
660 | * @return Returns "true" if we show stereotypes in the explorer. | |
661 | */ | |
662 | public String getShowStereotypes() { | |
663 | 0 | return Boolean.toString(getShowStereotypesValue()); |
664 | } | |
665 | ||
666 | /** | |
667 | * TODO: Is this used in places other than on Diagrams? If so, it needs to | |
668 | * stay in ProjectSettings (as well as being a DiagramSetting). | |
669 | * | |
670 | * @return Returns <code>true</code> if we show stereotypes in the explorer | |
671 | */ | |
672 | public boolean getShowStereotypesValue() { | |
673 | 130 | return showExplorerStereotypes; |
674 | } | |
675 | ||
676 | /** | |
677 | * @param showem <code>true</code> if stereotypes are to be shown in the | |
678 | * explorer. | |
679 | */ | |
680 | public void setShowStereotypes(String showem) { | |
681 | 0 | setShowStereotypes(Boolean.valueOf(showem).booleanValue()); |
682 | 0 | } |
683 | ||
684 | /** | |
685 | * @param showem <code>true</code> if stereotypes are to be shown in the | |
686 | * explorer view. | |
687 | */ | |
688 | public void setShowStereotypes(final boolean showem) { | |
689 | 12 | if (showExplorerStereotypes == showem) { |
690 | 12 | return; |
691 | } | |
692 | ||
693 | 0 | Memento memento = new Memento() { |
694 | 0 | private final ConfigurationKey key = Notation.KEY_SHOW_STEREOTYPES; |
695 | ||
696 | public void redo() { | |
697 | 0 | showExplorerStereotypes = showem; |
698 | 0 | fireNotationEvent(key, !showem, showem); |
699 | 0 | } |
700 | ||
701 | public void undo() { | |
702 | 0 | showExplorerStereotypes = !showem; |
703 | 0 | fireNotationEvent(key, showem, !showem); |
704 | 0 | } |
705 | }; | |
706 | 0 | doUndoable(memento); |
707 | 0 | } |
708 | ||
709 | /** | |
710 | * Used by "argo.tee". | |
711 | * | |
712 | * @return Returns "true" if we show "1" Multiplicities. | |
713 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
714 | */ | |
715 | @Deprecated | |
716 | public String getShowSingularMultiplicities() { | |
717 | 0 | return Boolean.toString(getShowSingularMultiplicitiesValue()); |
718 | } | |
719 | ||
720 | /** | |
721 | * @return Returns <code>true</code> if we show "1" Multiplicities. | |
722 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
723 | */ | |
724 | @Deprecated | |
725 | public boolean getShowSingularMultiplicitiesValue() { | |
726 | 0 | return npSettings.isShowSingularMultiplicities(); |
727 | } | |
728 | ||
729 | /** | |
730 | * @param showem <code>true</code> if "1" Multiplicities are to be shown. | |
731 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
732 | */ | |
733 | @Deprecated | |
734 | public void setShowSingularMultiplicities(String showem) { | |
735 | 0 | setShowSingularMultiplicities(Boolean.valueOf(showem).booleanValue()); |
736 | 0 | } |
737 | ||
738 | /** | |
739 | * @param showem <code>true</code> if "1" Multiplicities are to be shown. | |
740 | * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}. | |
741 | */ | |
742 | @Deprecated | |
743 | public void setShowSingularMultiplicities(final boolean showem) { | |
744 | 0 | if (npSettings.isShowSingularMultiplicities() == showem) { |
745 | 0 | return; |
746 | } | |
747 | ||
748 | 0 | Memento memento = new Memento() { |
749 | 0 | private final ConfigurationKey key = |
750 | Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES; | |
751 | ||
752 | public void redo() { | |
753 | 0 | npSettings.setShowSingularMultiplicities(showem); |
754 | 0 | fireNotationEvent(key, !showem, showem); |
755 | 0 | } |
756 | ||
757 | public void undo() { | |
758 | 0 | npSettings.setShowSingularMultiplicities(!showem); |
759 | 0 | fireNotationEvent(key, showem, !showem); |
760 | 0 | } |
761 | }; | |
762 | 0 | doUndoable(memento); |
763 | 0 | } |
764 | ||
765 | /** | |
766 | * Used by "argo.tee". | |
767 | * | |
768 | * @return Returns "true" if we show the arrows when | |
769 | * both association ends of an association are navigable. | |
770 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
771 | */ | |
772 | @Deprecated | |
773 | public String getHideBidirectionalArrows() { | |
774 | 0 | return Boolean.toString(getHideBidirectionalArrowsValue()); |
775 | } | |
776 | ||
777 | /** | |
778 | * @return Returns <code>true</code> if we show the arrows when | |
779 | * both association ends of an association are navigable. | |
780 | ||
781 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
782 | */ | |
783 | @Deprecated | |
784 | public boolean getHideBidirectionalArrowsValue() { | |
785 | 0 | return !diaDefault.isShowBidirectionalArrows(); |
786 | } | |
787 | ||
788 | /** | |
789 | * @param hideem <code>true</code> if both arrows are to be shown when | |
790 | * both association ends of an association are navigable. | |
791 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
792 | */ | |
793 | @Deprecated | |
794 | public void setHideBidirectionalArrows(String hideem) { | |
795 | 0 | setHideBidirectionalArrows(Boolean.valueOf(hideem).booleanValue()); |
796 | 0 | } |
797 | ||
798 | /** | |
799 | * @param hideem <code>true</code> if both arrows are to be shown when | |
800 | * both association ends of an association are navigable. | |
801 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
802 | */ | |
803 | @Deprecated | |
804 | public void setHideBidirectionalArrows(final boolean hideem) { | |
805 | 0 | if (diaDefault.isShowBidirectionalArrows() == !hideem) { |
806 | 0 | return; |
807 | } | |
808 | ||
809 | 0 | Memento memento = new Memento() { |
810 | ||
811 | public void redo() { | |
812 | 0 | diaDefault.setShowBidirectionalArrows(!hideem); |
813 | 0 | } |
814 | ||
815 | public void undo() { | |
816 | 0 | diaDefault.setShowBidirectionalArrows(hideem); |
817 | 0 | } |
818 | }; | |
819 | 0 | doUndoable(memento); |
820 | 0 | } |
821 | ||
822 | /** | |
823 | * Used by "argo.tee". | |
824 | * | |
825 | * @return Returns the shadow width. | |
826 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
827 | */ | |
828 | @Deprecated | |
829 | public String getDefaultShadowWidth() { | |
830 | 0 | return Integer.valueOf(getDefaultShadowWidthValue()).toString(); |
831 | } | |
832 | ||
833 | /** | |
834 | * @return Returns the shadow width. | |
835 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
836 | */ | |
837 | @Deprecated | |
838 | public int getDefaultShadowWidthValue() { | |
839 | 0 | return diaDefault.getDefaultShadowWidth(); |
840 | } | |
841 | ||
842 | /** | |
843 | * @param newWidth The Shadow Width. | |
844 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
845 | */ | |
846 | @Deprecated | |
847 | public void setDefaultShadowWidth(final int newWidth) { | |
848 | 0 | final int oldValue = diaDefault.getDefaultShadowWidth(); |
849 | 0 | if (oldValue == newWidth) { |
850 | 0 | return; |
851 | } | |
852 | ||
853 | 0 | Memento memento = new Memento() { |
854 | ||
855 | public void redo() { | |
856 | 0 | diaDefault.setDefaultShadowWidth(newWidth); |
857 | 0 | } |
858 | ||
859 | public void undo() { | |
860 | 0 | diaDefault.setDefaultShadowWidth(oldValue); |
861 | 0 | } |
862 | }; | |
863 | 0 | doUndoable(memento); |
864 | 0 | } |
865 | ||
866 | /** | |
867 | * @param width The shadow width to set. | |
868 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
869 | */ | |
870 | @Deprecated | |
871 | public void setDefaultShadowWidth(String width) { | |
872 | 0 | setDefaultShadowWidth(Integer.parseInt(width)); |
873 | 0 | } |
874 | ||
875 | /** | |
876 | * Used by "argo.tee". | |
877 | * | |
878 | * @return Returns the default stereotype view | |
879 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
880 | */ | |
881 | @Deprecated | |
882 | public String getDefaultStereotypeView() { | |
883 | 0 | return Integer.valueOf(getDefaultStereotypeViewValue()).toString(); |
884 | } | |
885 | ||
886 | /** | |
887 | * @return Returns the default stereotype view | |
888 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
889 | */ | |
890 | @Deprecated | |
891 | public int getDefaultStereotypeViewValue() { | |
892 | 0 | return diaDefault.getDefaultStereotypeViewInt(); |
893 | } | |
894 | ||
895 | ||
896 | /** | |
897 | * No longer used by "argo.tee". All uses deprecated. | |
898 | * | |
899 | * @return the output directory name | |
900 | * @deprecated for 0.27.2 by tfmorris. This is a user setting, not a project | |
901 | * setting. | |
902 | */ | |
903 | @Deprecated | |
904 | public String getGenerationOutputDir() { | |
905 | 0 | return ""; |
906 | } | |
907 | ||
908 | /** | |
909 | * @param od the output directory name | |
910 | * @deprecated for 0.27.2 by tfmorris. This is a user setting, not a project | |
911 | * setting. Any uses will be ignored. | |
912 | */ | |
913 | @Deprecated | |
914 | public void setGenerationOutputDir(@SuppressWarnings("unused") String od) { | |
915 | // ignored | |
916 | 0 | } |
917 | ||
918 | /** | |
919 | * @return the header comment string | |
920 | */ | |
921 | public String getHeaderComment() { | |
922 | 0 | return headerComment; |
923 | } | |
924 | ||
925 | /** | |
926 | * @param newView the default stereotype view | |
927 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
928 | */ | |
929 | @Deprecated | |
930 | public void setDefaultStereotypeView(final int newView) { | |
931 | 0 | final int oldValue = diaDefault.getDefaultStereotypeViewInt(); |
932 | 0 | if (oldValue == newView) { |
933 | 0 | return; |
934 | } | |
935 | ||
936 | 0 | Memento memento = new Memento() { |
937 | 0 | private final ConfigurationKey key = |
938 | ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW; | |
939 | ||
940 | public void redo() { | |
941 | 0 | diaDefault.setDefaultStereotypeView(newView); |
942 | 0 | fireNotationEvent(key, oldValue, newView); |
943 | 0 | } |
944 | ||
945 | public void undo() { | |
946 | 0 | diaDefault.setDefaultStereotypeView(oldValue); |
947 | 0 | fireNotationEvent(key, newView, oldValue); |
948 | 0 | } |
949 | }; | |
950 | 0 | doUndoable(memento); |
951 | 0 | } |
952 | ||
953 | /** | |
954 | * @param c the header comment string | |
955 | */ | |
956 | 0 | public void setHeaderComment(String c) { headerComment = c; } |
957 | ||
958 | ||
959 | /** | |
960 | * Convenience methods to fire notation configuration change events. | |
961 | * | |
962 | * @param key the ConfigurationKey that is related to the change | |
963 | * @param oldValue the old value | |
964 | * @param newValue the new value | |
965 | */ | |
966 | private void fireNotationEvent( | |
967 | ConfigurationKey key, int oldValue, int newValue) { | |
968 | 0 | fireNotationEvent(key, Integer.toString(oldValue), |
969 | Integer.toString(newValue)); | |
970 | 0 | } |
971 | ||
972 | /** | |
973 | * Convenience methods to fire notation configuration change events. | |
974 | * | |
975 | * @param key the ConfigurationKey that is related to the change | |
976 | * @param oldValue the old value | |
977 | * @param newValue the new value | |
978 | */ | |
979 | private void fireNotationEvent(ConfigurationKey key, boolean oldValue, | |
980 | boolean newValue) { | |
981 | 0 | fireNotationEvent(key, Boolean.toString(oldValue), |
982 | Boolean.toString(newValue)); | |
983 | 0 | } |
984 | ||
985 | /** | |
986 | * Convenience methods to fire notation configuration change events. | |
987 | * | |
988 | * @param key the ConfigurationKey that is related to the change | |
989 | * @param oldValue the old value | |
990 | * @param newValue the new value | |
991 | */ | |
992 | private void fireNotationEvent(ConfigurationKey key, String oldValue, | |
993 | String newValue) { | |
994 | 1 | ArgoEventPump.fireEvent(new ArgoNotationEvent( |
995 | ArgoEventTypes.NOTATION_CHANGED, new PropertyChangeEvent(this, | |
996 | key.getKey(), oldValue, newValue))); | |
997 | 1 | } |
998 | ||
999 | /** | |
1000 | * Diagram font name. <p> | |
1001 | * | |
1002 | * Used by "argo.tee". | |
1003 | * | |
1004 | * @return diagram font name. | |
1005 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1006 | */ | |
1007 | @Deprecated | |
1008 | public String getFontName() { | |
1009 | 0 | return diaDefault.getFontName(); |
1010 | } | |
1011 | ||
1012 | /** | |
1013 | * Diagram font name. | |
1014 | * @param newFontName diagram font name. | |
1015 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1016 | */ | |
1017 | @Deprecated | |
1018 | public void setFontName(String newFontName) { | |
1019 | 0 | diaDefault.setFontName(newFontName); |
1020 | 0 | } |
1021 | ||
1022 | /** | |
1023 | * Diagram font size. <p> | |
1024 | * | |
1025 | * Used by "argo.tee". | |
1026 | * | |
1027 | * @return diagram font size. | |
1028 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1029 | */ | |
1030 | @Deprecated | |
1031 | public int getFontSize() { | |
1032 | 0 | return diaDefault.getFontSize(); |
1033 | } | |
1034 | ||
1035 | /** | |
1036 | * Diagram font size. | |
1037 | * @param newFontSize diagram font size. | |
1038 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1039 | */ | |
1040 | @Deprecated | |
1041 | public void setFontSize(int newFontSize) { | |
1042 | 0 | diaDefault.setFontSize(newFontSize); |
1043 | 0 | } |
1044 | ||
1045 | ||
1046 | /** | |
1047 | * Returns the Plain diagram font which corresponds | |
1048 | * to selected parameters. | |
1049 | * | |
1050 | * @return plain diagram font | |
1051 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1052 | */ | |
1053 | @Deprecated | |
1054 | public Font getFontPlain() { | |
1055 | 0 | return diaDefault.getFontPlain(); |
1056 | } | |
1057 | ||
1058 | /** | |
1059 | * Returns the Italic diagram font which corresponds | |
1060 | * to selected parameters. | |
1061 | * | |
1062 | * @return italic diagram font | |
1063 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1064 | */ | |
1065 | @Deprecated | |
1066 | public Font getFontItalic() { | |
1067 | 0 | return diaDefault.getFontItalic(); |
1068 | } | |
1069 | ||
1070 | /** | |
1071 | * Returns the Bold diagram font which corresponds | |
1072 | * to selected parameters. | |
1073 | * | |
1074 | * @return bold diagram font | |
1075 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1076 | */ | |
1077 | @Deprecated | |
1078 | public Font getFontBold() { | |
1079 | 0 | return diaDefault.getFontBold(); |
1080 | } | |
1081 | ||
1082 | /** | |
1083 | * Returns the Bold-Italic diagram font which corresponds | |
1084 | * to selected parameters. | |
1085 | * | |
1086 | * @return bold-italic diagram font | |
1087 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1088 | */ | |
1089 | @Deprecated | |
1090 | public Font getFontBoldItalic() { | |
1091 | 0 | return diaDefault.getFontBoldItalic(); |
1092 | } | |
1093 | ||
1094 | /** | |
1095 | * Utility function to convert a font style integer into a Font. | |
1096 | * | |
1097 | * @param fontStyle the style; see the predefined constants in Font | |
1098 | * @return the Font that corresponds to the style | |
1099 | * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}. | |
1100 | */ | |
1101 | @Deprecated | |
1102 | public Font getFont(int fontStyle) { | |
1103 | 0 | return diaDefault.getFont(fontStyle); |
1104 | } | |
1105 | } |