01: package com.xoetrope.awt;
02:
03: import java.awt.event.ActionEvent;
04: import java.awt.event.ActionListener;
05:
06: import net.xoetrope.awt.XImage;
07: import com.xoetrope.event.XClickListener;
08: import net.xoetrope.xui.XAttributedComponent;
09: import net.xoetrope.xui.XProjectManager;
10:
11: /**
12: * An easter eggs is a special control used to obscure access to certain
13: * functionality. Frequently it is used to control access to superuser mode
14: * menus and actions. In a modal/fullscreen application it may obscure access
15: * to the exit/shutdown functionality. A password can also be added to further
16: * protect access.
17: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
18: * the GNU Public License (GPL), please see license.txt for more details. If
19: * you make commercial use of this software you must purchase a commercial
20: * license from Xoetrope.</p>
21: * <p>$Revision: 1.4 $</p>
22: */
23: public class XEasterEgg extends XImage implements XAttributedComponent,
24: ActionListener {
25: String password = "";
26: XClickListener clickListener;
27:
28: public XEasterEgg() {
29: super ();
30: clickListener = new XClickListener(this );
31: if (currentProject.getAppFrame() != null)
32: addMouseListener(clickListener);
33: clickListener.addActionListener(this );
34: }
35:
36: /**
37: * Set one or more attributes of the component.
38: * @param attribName the name of the attribute
39: * @param attribValue the value of the attribute
40: */
41: public void setAttribute(String attribName, String attribValue) {
42: if (attribName.compareToIgnoreCase("password") == 0)
43: password = attribValue;
44: }
45:
46: /**
47: * Pops up a password dialog and exits the survey if the password matches
48: * @param e
49: */
50: public void actionPerformed(ActionEvent e) {
51: XPasswordDlg passwordDlg = new XPasswordDlg();
52: passwordDlg.showDialog(getParent(), null);
53: if (passwordDlg.getPassword().compareTo(password) == 0)
54: exitSurvey();
55: passwordDlg = null;
56: }
57:
58: /**
59: * Exist the survey and shuts down the application
60: */
61: public void exitSurvey() {
62: System.exit(0);
63: }
64: }
|