Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mitre/cvw/DisplayPrefPanel.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 javax.swing.*;
10  import java.awt.*;
11  import java.awt.event.*;
12  import java.util.Vector;
13  
14  /* 8/26/98 dage - moved idleMsg and timeStampCheck to MiscPrefPanel
15   */
16  /**
17   * The GUI for allowing the user to change their display preferences:
18   * currently:  which windows/panels open upon connection, location/size
19   * of all tools, including av tools.
20   * @version 1.0
21   * @author Deb Ercolini
22   */
23  public class DisplayPrefPanel extends CVWPreferencePanel {
24  
25    JCheckBox mapChk, carryChk, audioChk, videoChk, onlineChk;
26    JCheckBox roomChk, usersChk, toolbarChk, statusChk;
27    JButton locButton, audiolocButton, videolocButton;
28    AVToolFrame audioFrame, videoFrame;
29    //Label currLocLabel;
30    JLabel mapLabel, onlineLabel, carryLabel, proxyLabel;
31  
32    CmdChoice mainCmdChoice, proxyCmdChoice;
33  
34    GridBagLayout gridbag;
35  
36  /**
37   * Constructor
38   *
39   * @param pref an instance of the CVWPreference that this panel is representing
40   * @param folder the frame that it is opened in
41   */
42    DisplayPrefPanel(CVWPreferences pref, FolderDialog folder) {
43  
44      gridbag = new GridBagLayout();
45      this.setLayout(gridbag);
46  
47      insideOf = folder;
48      cvwPref = pref;
49  
50      Font f = new Font("Dialog", Font.BOLD, 12);
51      Font sf = new Font("Helvetica", Font.BOLD, 12);
52      Font pf = new Font("Helvetica", Font.PLAIN, 12);
53  
54      JLabel initDisplayLabel = new JLabel("Display CVW Components Upon Startup");
55      initDisplayLabel.setFont(f);
56      mapChk=new JCheckBox("CVW Map");
57      mapChk.setSelected(cvwPref.getMapShow());
58      carryChk=new JCheckBox("Carrying Folder");
59      carryChk.setSelected(cvwPref.getCarryShow());
60      audioChk=new JCheckBox("Audio");
61      audioChk.setSelected(cvwPref.getAudioShow());
62      videoChk=new JCheckBox("Video");
63      videoChk.setSelected(cvwPref.getVideoShow());
64      onlineChk=new JCheckBox("Online Users");
65      onlineChk.setSelected(cvwPref.getOnlineShow());
66  
67      usersChk=new JCheckBox("Room Users");
68      usersChk.setSelected(cvwPref.getUsersShow());
69      roomChk=new JCheckBox("Room Contents");
70      roomChk.setSelected(cvwPref.getContentsShow());
71      toolbarChk=new JCheckBox("Toolbar");
72      toolbarChk.setSelected(cvwPref.getToolbarShow());
73      statusChk=new JCheckBox("Status Bar");
74      statusChk.setSelected(cvwPref.getStatusBarShow());
75      
76      JLabel defCmdLabel = new JLabel("Default CVW Command Upon Startup");
77      defCmdLabel.setFont(f);
78      JLabel mainCmdLabel = new JLabel("Main window");
79      mainCmdLabel.setFont(f);
80   
81      Vector v = CVWCoordinator.getInstance().getCmdChoiceMenuItems();
82      mainCmdChoice = new CmdChoice(v);
83      mainCmdChoice.setSelectedCmd(cvwPref.getMainDefaultCmd());
84      
85      Vector pv = ProxyWindow.getMenuItems();
86      proxyCmdChoice = new CmdChoice(pv);
87      proxyCmdChoice.setSelectedCmd(cvwPref.getProxyDefaultCmd());
88   
89      JLabel proxyCmdLabel = new JLabel("Proxy window");
90      proxyCmdLabel.setFont(f);
91     
92      JLabel locLabel = new JLabel("Save Current Window Location");
93      locLabel.setFont(f);
94      locButton = new JButton("Save Location");
95      // srj 3/3/99 1.1
96      locButton.addActionListener(new ActionListener() {
97        public void actionPerformed(ActionEvent e) {
98    saveLoc();
99        }
100     });
101 
102     WindowMgr mgr = WindowMgr.getWindowMgr();
103     JLabel mainLabel = new JLabel("Main Window");
104     mainLabel.setFont(sf);
105     Window win;
106 
107     mapLabel = new JLabel("Map Window");
108     mapLabel.setFont(pf);
109     win = mgr.findToolWindow("CVWMapWin");
110     if (win != null && win.isVisible() && win.isShowing())
111   mapLabel.setFont(sf);
112 
113     onlineLabel = new JLabel("Online Users");
114     onlineLabel.setFont(pf);
115     win = mgr.findToolWindow("OnlineUserList");
116     if (win != null && win.isVisible() && win.isShowing())
117   onlineLabel.setFont(sf);
118 
119     proxyLabel = new JLabel("Proxy Window");
120     proxyLabel.setFont(pf);
121     if (ProxyWindow.isOpen())
122   proxyLabel.setFont(sf);
123 
124     carryLabel = new JLabel("Carrying Folder");
125     carryLabel.setFont(pf);
126     win = ContentsCoordinator.getCarryingFolder();
127     if (win != null && win.isVisible() && win.isShowing())
128   carryLabel.setFont(sf);
129 
130     JLabel audioLocLabel = new JLabel("Audio Conference Tool");
131     JLabel videoLocLabel = new JLabel("Video Conference Tool");
132     audioLocLabel.setFont(f);
133     videoLocLabel.setFont(f);
134     audiolocButton = new JButton("Set Location...");
135     videolocButton = new JButton("Set Location...");
136 
137     // srj 3/3/99 1.1
138     audiolocButton.addActionListener(new ActionListener() {
139       public void actionPerformed(ActionEvent e) {
140   saveAudioLoc();
141       }
142     });
143 
144     videolocButton.addActionListener(new ActionListener() {
145       public void actionPerformed(ActionEvent e) {
146   saveVideoLoc();
147       }
148     });
149 
150 /* for debugging purposes */
151     //currLocLabel = new JLabel();
152     //setCurrLocLabel();
153     constrain(this, initDisplayLabel, 0, 0, GridBagConstraints.REMAINDER, 1,
154                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 0.0, 0.0,
155                 5, 15, 0, 15, 0, 0);
156     constrain(this, usersChk, 0, GridBagConstraints.RELATIVE, 1, 1,
157                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
158                 5, 25, 0, 0, 0, 0);
159     constrain(this, toolbarChk, 1, GridBagConstraints.RELATIVE, 1, 1,
160                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
161                 5, 5, 0, 0, 0, 0);
162     constrain(this, carryChk, 2, GridBagConstraints.RELATIVE, 1, 1,
163                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
164                 5, 5, 0, 0, 0, 0);
165     constrain(this, mapChk, 3, GridBagConstraints.RELATIVE, 1, 1,
166                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
167                 5, 5, 0, 0, 0, 0);
168     constrain(this, onlineChk, 4, GridBagConstraints.RELATIVE, 1, 1, 
169                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
170                 5, 5, 0, 0, 0, 0);
171                 
172     constrain(this, roomChk, 0, GridBagConstraints.RELATIVE, 1, 1,
173                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
174                 5, 25, 0, 0, 0, 0);
175     constrain(this, statusChk, 1, GridBagConstraints.RELATIVE, 1, 1,
176                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
177                 5, 5, 0, 0, 0, 0);
178     constrain(this, audioChk, 2, GridBagConstraints.RELATIVE, 1, 1,
179                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
180                 5, 5, 0, 0, 0, 0);
181     constrain(this, videoChk, 3, GridBagConstraints.RELATIVE, 1, 1,
182                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
183                 5, 5, 0, 0, 0, 0);
184 
185     constrain(this, defCmdLabel, 0, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
186                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
187                 10, 15, 0, 15, 0, 0);
188     constrain(this, mainCmdLabel, 0, GridBagConstraints.RELATIVE, 1, 1,
189                 GridBagConstraints.NONE, GridBagConstraints.WEST, 1.0, 0.0,
190                 5, 25, 0, 15, 0, 0);
191     constrain(this, mainCmdChoice, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
192                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
193                 5, 15, 0, 15, 0, 0);
194 
195     constrain(this, proxyCmdLabel, 0, GridBagConstraints.RELATIVE, 1, 1,
196                 GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, 1.0, 0.0,
197                 5, 25, 0, 15, 0, 0);
198     constrain(this, proxyCmdChoice, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
199                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
200                 5, 15, 0, 15, 0, 0);
201 
202     constrain(this, locLabel, 0, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
203                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
204                 15, 15, 0, 15, 0, 0);
205     constrain(this, locButton, 0, GridBagConstraints.RELATIVE, 1, 2,
206                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
207                 5, 25, 0, 15, 0, 0);
208     constrain(this, mainLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, 1, 1,
209                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
210                 5, 15, 0, 15, 0, 0);
211     constrain(this, mapLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, 1, 1,
212                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
213                 5, 15, 0, 15, 0, 0);
214     constrain(this, proxyLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
215                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
216                 5, 15, 0, 15, 0, 0);
217     constrain(this, carryLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, 1, 1,
218                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
219                 5, 15, 0, 15, 0, 0);
220     constrain(this, onlineLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
221                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
222                 5, 15, 0, 15, 0, 0);
223 
224     constrain(this, audioLocLabel, 0, GridBagConstraints.RELATIVE, 2, 1,
225                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
226                 15, 15, 0, 15, 0, 0);
227     constrain(this, videoLocLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
228                 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1.0, 0.0,
229                 15, 15, 0, 15, 0, 0);
230 
231     constrain(this, audiolocButton,  0, GridBagConstraints.RELATIVE, 2, 1,
232                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
233                 5, 25, 0, 15, 0, 0);
234     constrain(this, videolocButton,  GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
235                 GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
236                 5, 25, 0, 15, 0, 0);
237     //constrain(this, currLocLabel, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, 1, 1,
238                 //GridBagConstraints.NONE, GridBagConstraints.WEST, 0.0, 0.0,
239                 //5, 15, 0, 15, 0, 0);
240   }
241 
242 /**
243  * Returns the preferred size of this panel.
244  * @return the preferred size
245  */
246     public Dimension getPreferredSize() {
247         return new Dimension(400, 350);
248    }
249 
250 /** 
251  * Used for debugging purposes
252  */
253  void setCurrLocLabel() {
254     //currLocLabel.setText("("+ cvwPref.x + "x" + cvwPref.y+ ", " 
255         //+ cvwPref.w + "x"+ cvwPref.h + ")");
256   }
257 
258 /** 
259  * Saves size and location of all tool windows open.  Invoked when the user
260  * presses the Save Location button.
261  */
262   void saveLoc() {
263     Rectangle dim = CVWCoordinator.getInstance().getBounds();
264     cvwPref.setMainSize(dim);
265     //cvwPref.x = dim.x;
266     //cvwPref.y = dim.y;
267     //cvwPref.w = dim.width;
268     //cvwPref.h = dim.height; 
269 
270     WindowMgr mgr = WindowMgr.getWindowMgr();
271     Window win;
272 
273     if (mapLabel.getFont().isBold()) {
274       win = mgr.findToolWindow("CVWMapWin");
275       cvwPref.setMapSize(win.getBounds());
276      }
277  
278     if (onlineLabel.getFont().isBold()) {
279       win = mgr.findToolWindow("OnlineUserList");
280       cvwPref.setOnlineSize(win.getBounds());
281      }
282  
283     if (proxyLabel.getFont().isBold()) {
284       ProxyWindow pwin = ProxyWindow.getInstance();
285       cvwPref.setProxySize(pwin.getBounds());
286       cvwPref.setProxyUsersShow(pwin.isUserVisible());
287       cvwPref.setProxyToolbarShow(pwin.isToolbarVisible());
288       cvwPref.setProxyStatusBarShow(pwin.isStatusBarVisible());
289      }
290  
291     if (carryLabel.getFont().isBold()) {
292       win = ContentsCoordinator.getCarryingFolder();
293       cvwPref.setCarrySize(win.getBounds());
294      }
295  
296     //setCurrLocLabel();
297   }
298 
299 /**
300  * Opens the video location window.    This is because we can't get the 
301  * dimensions of the actual audio tool, have the user save the location 
302  * and size of a dummy window and then use those dimensions for the actual
303  * audio tool.
304  * @see AVToolFrame
305  */
306   void saveAudioLoc() {
307      if (audioFrame == null) {
308        audioFrame = new AVToolFrame(insideOf, "Audio", cvwPref);
309        audioFrame.pack();
310       }
311      audioFrame.setVisible(true);
312    }
313 
314 /**
315  * Opens the video location window.  This is because we can't get the 
316  * dimensions of the actual video tool, have the user save the location 
317  * and size of a dummy window and then use those dimensions for the actual
318  * video tool.
319  * @see AVToolFrame
320  */
321   void saveVideoLoc() {
322      if (videoFrame == null) {
323        videoFrame = new AVToolFrame(insideOf, "Video", cvwPref);
324        videoFrame.pack();
325       }
326      videoFrame.setVisible(true);
327    }
328 
329 /**
330  * Closes the AV windows.
331  */
332   void closeAVFrames() {
333      if (videoFrame != null) {
334   videoFrame.destroy();
335       }
336      if (audioFrame != null) {
337   audioFrame.destroy();
338       }
339    }
340 
341 /**
342  * Proccesses the data entered in this panel when the user hits ok, saving
343  * all changes. 
344  * @return <code>true</code>
345  */
346   public boolean ok(){
347     cvwPref.setAudioShow(audioChk.isSelected());
348     cvwPref.setVideoShow(videoChk.isSelected());
349     cvwPref.setMapShow(mapChk.isSelected());
350     cvwPref.setOnlineShow(onlineChk.isSelected());
351     
352     cvwPref.setContentsShow(roomChk.isSelected());
353     cvwPref.setUsersShow(usersChk.isSelected());
354     cvwPref.setToolbarShow(toolbarChk.isSelected());
355     cvwPref.setStatusBarShow(statusChk.isSelected());
356     cvwPref.setCarryShow(carryChk.isSelected());
357 
358     cvwPref.setProxyDefaultCmd(proxyCmdChoice.getSelectedCmd().keyInt());
359     cvwPref.setMainDefaultCmd(mainCmdChoice.getSelectedCmd().keyInt());
360     
361     closeAVFrames();
362     return true;
363   }
364 
365 /**
366  * User has cancelled the dialog, close AV windows.
367  *
368  * @return <code>true</code>
369  */
370   public boolean cancel() {
371     closeAVFrames();
372     return true;
373   }
374 
375 }