KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > view > ui > EditorAreaFrame


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.core.windows.view.ui;
22
23
24 import java.awt.event.WindowAdapter JavaDoc;
25 import java.awt.event.WindowEvent JavaDoc;
26 import org.netbeans.core.windows.view.Controller;
27 import org.openide.util.NbBundle;
28
29 import javax.swing.*;
30 import java.awt.*;
31
32
33 /**
34  * Frame representing separate editor area.
35  *
36  * @author Peter Zavadsky
37  */

38 public class EditorAreaFrame extends JFrame {
39
40
41     private Component desktop;
42     private Controller controller;
43     private long frametimestamp = 0;
44
45     /** Creates a new instance of EditorAreaFrame */
46     public EditorAreaFrame() {
47         super(NbBundle.getMessage(EditorAreaFrame.class, "LBL_EditorAreaFrameTitle"));
48         
49         setIconImage(MainWindow.createIDEImage());
50         
51     }
52     
53     public void setWindowActivationListener(Controller control) {
54         controller = control;
55         addWindowListener(new WindowAdapter JavaDoc() {
56             public void windowActivated(WindowEvent JavaDoc evt) {
57                 if (frametimestamp != 0 && System.currentTimeMillis() > frametimestamp + 500) {
58                     controller.userActivatedEditorWindow();
59                 }
60             }
61             public void windowOpened(WindowEvent JavaDoc event) {
62                 frametimestamp = System.currentTimeMillis();
63             }
64         });
65     }
66     
67     public void toFront() {
68         // ignore the window activation event, is not done by user.
69
frametimestamp = System.currentTimeMillis();
70         super.toFront();
71     }
72     
73     public void setVisible(boolean visible) {
74         frametimestamp = System.currentTimeMillis();
75         super.setVisible(visible);
76     }
77     
78     public void setDesktop(Component component) {
79         if(desktop == component) {
80             return;
81         }
82         
83         if(desktop != null) {
84             getContentPane().remove(desktop);
85         }
86         
87         desktop = component;
88         
89         if(component != null) {
90             getContentPane().add(component);
91         }
92     }
93
94     private long timeStamp = 0;
95     
96     public void setUserStamp(long stamp) {
97         timeStamp = stamp;
98     }
99     
100     public long getUserStamp() {
101         return timeStamp;
102     }
103     
104     private long mainWindowStamp = 0;
105     
106     public void setMainWindowStamp(long stamp) {
107         mainWindowStamp = stamp;
108     }
109     
110     public long getMainWindowStamp() {
111         return mainWindowStamp;
112     }
113     
114     
115     
116 }
117
Popular Tags