1 19 20 21 package org.netbeans.core.windows.view.ui; 22 23 24 import java.awt.event.WindowAdapter ; 25 import java.awt.event.WindowEvent ; 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 38 public class EditorAreaFrame extends JFrame { 39 40 41 private Component desktop; 42 private Controller controller; 43 private long frametimestamp = 0; 44 45 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 () { 56 public void windowActivated(WindowEvent evt) { 57 if (frametimestamp != 0 && System.currentTimeMillis() > frametimestamp + 500) { 58 controller.userActivatedEditorWindow(); 59 } 60 } 61 public void windowOpened(WindowEvent event) { 62 frametimestamp = System.currentTimeMillis(); 63 } 64 }); 65 } 66 67 public void toFront() { 68 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 |