Source code: org/mitre/cvw/CVWPrefsFrame.java
1 /*
2 * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3 * All rights reserved.
4 * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5 */
6
7 package org.mitre.cvw;
8
9 import java.awt.*;
10 import javax.swing.*;
11
12 /**
13 * This is the window which displays the user preferences in a tabbed folder manner.
14 * @version 1.0 9/2/97
15 * @author Deb Ercolini
16 */
17 public class CVWPrefsFrame extends FolderDialog {
18 // declare variables
19 CVWPreferences cvwPrefs;
20 CVWPreferences origCvwPrefs;
21 AVConfAdvancedPrefPanel advAVPrefs;
22 AVConfPrefPanel genAVPrefs;
23 HiLightPrefPanel genHiLightPrefs;
24 HiLightUserPrefPanel userHiLightPrefs;
25 //FontPrefPanel fpp;
26
27 /**
28 * Constructor
29 *
30 * @param cvw the instance of CVWCoordinator
31 * @param title the title of the window
32 * @param the CVWPreferences this window is representing
33 */
34 CVWPrefsFrame(String title, CVWPreferences prefs) {
35 super(title);
36 cvwPrefs = prefs.copy(); //why is clone so complicated????
37 origCvwPrefs = prefs;
38
39 init();
40 }
41
42 /**
43 * Creates all tabbed panels.
44 */
45 public void init() {
46 addTab("Conferencing", genAVPrefs = new AVConfPrefPanel(cvwPrefs, this));
47 hideTab("Conferencing", advAVPrefs = new AVConfAdvancedPrefPanel(cvwPrefs, this));
48 addTab("Highlights", genHiLightPrefs = new HiLightPrefPanel(cvwPrefs, this));
49 hideTab("Highlights", userHiLightPrefs = new HiLightUserPrefPanel(cvwPrefs, this));
50 addTab("Display", new DisplayPrefPanel(cvwPrefs, this));
51 addTab("Misc", new MiscPrefPanel(cvwPrefs, this));
52 /* JRK - font stuff
53 long t1 = System.currentTimeMillis();
54 fpp = new FontPrefPanel(cvwPrefs,this);
55 long t2 = System.currentTimeMillis();
56 System.out.println("CREATED FONTPANEL TIME DIFF: " + (t2 - t1) + "Millis");
57 addTab("Fonts",fpp);
58 */
59 pack();
60 }
61
62 /**
63 * Toggles the basic and advanced av preferences panel.
64 *
65 * @param ADVANCED to switch to advance panel, GENERAL to switch to general panel
66 */
67 public void switchAV(int type) {
68 if (type == AVConfPrefPanel.ADVANCED)
69 replaceTab(0, advAVPrefs);
70 else
71 replaceTab(0, genAVPrefs);
72 }
73
74 /**
75 * Toggles the basic and advanced high light preferences panel.
76 *
77 * @param ADVANCED to switch to advance panel, GENERAL to switch to general panel
78 */
79 public void switchHiLight(int type) {
80 if (type == CVWPreferencePanel.ADVANCED)
81 replaceTab(1, userHiLightPrefs);
82 else
83 replaceTab(1, genHiLightPrefs);
84 }
85
86 /**
87 * Proccesses the save function when the user pushes the save button. Preferences
88 * are only saved when every panel has successfully save their values.
89 */
90 public void ok() {
91 boolean res = true;
92 for(i=0;i<count;i++) {
93 //if(CVWCoordinator.DEBUG) System.err.println("OKAY "+i);
94 // if(CVWCoordinator.DEBUG) System.err.println(fPanel[i]);
95 res = fPanel[i].ok();
96 if (!res) break;
97 }
98 if (res) {
99 origCvwPrefs.savePrefs(cvwPrefs);
100 destroy();
101 }
102 }
103
104 /**
105 * Closes this window and removes it from the window manager list.
106 * @return <code>true</code>
107 * @see WindowMgr#getWindowMgr
108 */
109 public boolean destroy() {
110 this.setVisible(false);
111 (WindowMgr.getWindowMgr()).removeToolWindow(this);
112 this.dispose();
113 return true;
114 }
115
116 }
117
118