1 56 package org.objectstyle.cayenne.modeler.util; 57 58 import java.awt.Dialog ; 59 import java.awt.Frame ; 60 import java.awt.GraphicsConfiguration ; 61 import java.awt.HeadlessException ; 62 import java.awt.event.ActionEvent ; 63 import java.awt.event.ActionListener ; 64 import java.awt.event.KeyEvent ; 65 import java.awt.event.WindowEvent ; 66 67 import javax.swing.JComponent ; 68 import javax.swing.JDialog ; 69 import javax.swing.KeyStroke ; 70 import javax.swing.event.HyperlinkEvent ; 71 import javax.swing.event.HyperlinkListener ; 72 73 import org.objectstyle.cayenne.modeler.Application; 74 import org.objectstyle.cayenne.modeler.CayenneModelerFrame; 75 import org.objectstyle.cayenne.modeler.ProjectController; 76 import org.scopemvc.view.awt.AWTUtilities; 77 78 84 public class CayenneDialog extends JDialog implements HyperlinkListener { 85 86 public CayenneDialog() throws HeadlessException { 87 super(); 88 } 89 90 public CayenneDialog(Frame owner) throws HeadlessException { 91 super(owner); 92 } 93 94 public CayenneDialog(Frame owner, boolean modal) throws HeadlessException { 95 super(owner, modal); 96 } 97 98 public CayenneDialog(Frame owner, String title) throws HeadlessException { 99 super(owner, title); 100 } 101 102 public CayenneDialog(Frame owner, String title, boolean modal) 103 throws HeadlessException { 104 super(owner, title, modal); 105 } 106 107 public CayenneDialog( 108 Frame owner, 109 String title, 110 boolean modal, 111 GraphicsConfiguration gc) { 112 super(owner, title, modal, gc); 113 } 114 115 public CayenneDialog(Dialog owner) throws HeadlessException { 116 super(owner); 117 } 118 119 public CayenneDialog(Dialog owner, boolean modal) throws HeadlessException { 120 super(owner, modal); 121 } 122 123 public CayenneDialog(Dialog owner, String title) throws HeadlessException { 124 super(owner, title); 125 } 126 127 public CayenneDialog(Dialog owner, String title, boolean modal) 128 throws HeadlessException { 129 super(owner, title, modal); 130 } 131 132 public CayenneDialog( 133 Dialog owner, 134 String title, 135 boolean modal, 136 GraphicsConfiguration gc) 137 throws HeadlessException { 138 super(owner, title, modal, gc); 139 } 140 141 public CayenneDialog(CayenneModelerFrame frame, String title, boolean modal) { 142 super(frame, title, modal); 143 } 144 145 148 protected void initCloseOnEscape() { 149 157 KeyStroke escReleased = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true); 158 ActionListener closeAction = new ActionListener () { 159 public void actionPerformed(ActionEvent e) { 160 if (CayenneDialog.this.isVisible()) { 161 WindowEvent windowClosing = 163 new WindowEvent (CayenneDialog.this, WindowEvent.WINDOW_CLOSING); 164 CayenneDialog.super.processWindowEvent(windowClosing); 165 } 166 } 167 }; 168 getRootPane().registerKeyboardAction( 169 closeAction, 170 escReleased, 171 JComponent.WHEN_IN_FOCUSED_WINDOW); 172 } 173 174 177 public void centerWindow() { 178 AWTUtilities.centreOnWindow(getParentEditor(), this); 179 } 180 181 public CayenneModelerFrame getParentEditor() { 182 return (CayenneModelerFrame) super.getParent(); 183 } 184 185 188 public void hyperlinkUpdate(HyperlinkEvent event) { 189 if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 190 BrowserControl.displayURL(event.getURL().toExternalForm()); 191 } 192 } 193 194 197 public ProjectController getMediator() { 198 return Application.getInstance().getFrameController().getProjectController(); 199 } 200 201 protected void dialogInit() { 202 super.dialogInit(); 203 initCloseOnEscape(); 204 } 205 } | Popular Tags |