10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.awt;
27
28 import java.awt.*;
29 import java.awt.KeyboardFocusManager;
30 import java.awt.event.InputEvent;
31 import java.awt.geom.Point2D;
32 import java.awt.image.BufferedImage;
33
34 import sun.misc.Unsafe;
35 import java.awt.peer.ComponentPeer;
36
37 import java.security.AccessController;
38 import java.security.AccessControlContext;
39
40 import java.io.File;
41
42 /**
43 * The AWTAccessor utility class.
44 * The main purpose of this class is to enable accessing
45 * private and package-private fields of classes from
46 * different classes/packages. See sun.misc.SharedSecretes
47 * for another example.
48 */
49 public final class AWTAccessor {
50
461 * Sets the files the user selects
462 */
463 void setFiles(FileDialog fileDialog, File files[]);
464
465 /*
466 * Sets the file the user selects
467 */
468 void setFile(FileDialog fileDialog, String file);
469
470 /*
471 * Sets the directory the user selects
472 */
473 void setDirectory(FileDialog fileDialog, String directory);
474
475 /*
476 * Returns whether the file dialog allows the multiple file selection.
477 */
478 boolean isMultipleMode(FileDialog fileDialog);
479 }
480
481 /*
482 * Accessor instances are initialized in the static initializers of
483 * corresponding AWT classes by using setters defined below.
484 */
485 private static ComponentAccessor componentAccessor;
486 private static ContainerAccessor containerAccessor;
487 private static WindowAccessor windowAccessor;
488 private static AWTEventAccessor awtEventAccessor;
489 private static InputEventAccessor inputEventAccessor;
490 private static FrameAccessor frameAccessor;
491 private static KeyboardFocusManagerAccessor kfmAccessor;
492 private static MenuComponentAccessor menuComponentAccessor;
493 private static EventQueueAccessor eventQueueAccessor;
494 private static PopupMenuAccessor popupMenuAccessor;
495 private static FileDialogAccessor fileDialogAccessor;
496
497 /*
498 * Set an accessor object for the java.awt.Component class.
499 */
500 public static void setComponentAccessor(ComponentAccessor ca) {
501 componentAccessor = ca;
502 }
503
504 /*
505 * Retrieve the accessor object for the java.awt.Component class.
506 */
507 public static ComponentAccessor getComponentAccessor() {
508 if (componentAccessor == null) {
509 unsafe.ensureClassInitialized(Component.class);
510 }
511
512 return componentAccessor;
513 }
514
515 /*
664 unsafe.ensureClassInitialized(PopupMenu.class);
665 }
666 return popupMenuAccessor;
667 }
668
669 /*
670 * Set an accessor object for the java.awt.FileDialog class.
671 */
672 public static void setFileDialogAccessor(FileDialogAccessor fda) {
673 fileDialogAccessor = fda;
674 }
675
676 /*
677 * Retrieve the accessor object for the java.awt.FileDialog class.
678 */
679 public static FileDialogAccessor getFileDialogAccessor() {
680 if (fileDialogAccessor == null) {
681 unsafe.ensureClassInitialized(FileDialog.class);
682 }
683 return fileDialogAccessor;
684 }
685
686 }
|
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.awt;
27
28 import java.awt.*;
29 import java.awt.KeyboardFocusManager;
30 import java.awt.event.*;
31 import java.awt.geom.Point2D;
32 import java.awt.image.BufferedImage;
33
34 import sun.misc.Unsafe;
35 import java.awt.peer.ComponentPeer;
36
37 import java.security.AccessController;
38 import java.security.AccessControlContext;
39
40 import java.io.File;
41
42 /**
43 * The AWTAccessor utility class.
44 * The main purpose of this class is to enable accessing
45 * private and package-private fields of classes from
46 * different classes/packages. See sun.misc.SharedSecretes
47 * for another example.
48 */
49 public final class AWTAccessor {
50
461 * Sets the files the user selects
462 */
463 void setFiles(FileDialog fileDialog, File files[]);
464
465 /*
466 * Sets the file the user selects
467 */
468 void setFile(FileDialog fileDialog, String file);
469
470 /*
471 * Sets the directory the user selects
472 */
473 void setDirectory(FileDialog fileDialog, String directory);
474
475 /*
476 * Returns whether the file dialog allows the multiple file selection.
477 */
478 boolean isMultipleMode(FileDialog fileDialog);
479 }
480
481 /**
482 * An accessor for the InvocationEvent class
483 */
484 public interface InvocationEventAccessor {
485 /**
486 * Dispose an InvocationEvent (cancel it).
487 */
488 void dispose(InvocationEvent ie);
489 }
490
491 /*
492 * Accessor instances are initialized in the static initializers of
493 * corresponding AWT classes by using setters defined below.
494 */
495 private static ComponentAccessor componentAccessor;
496 private static ContainerAccessor containerAccessor;
497 private static WindowAccessor windowAccessor;
498 private static AWTEventAccessor awtEventAccessor;
499 private static InputEventAccessor inputEventAccessor;
500 private static FrameAccessor frameAccessor;
501 private static KeyboardFocusManagerAccessor kfmAccessor;
502 private static MenuComponentAccessor menuComponentAccessor;
503 private static EventQueueAccessor eventQueueAccessor;
504 private static PopupMenuAccessor popupMenuAccessor;
505 private static FileDialogAccessor fileDialogAccessor;
506 private static InvocationEventAccessor invocationEventAccessor;
507
508 /*
509 * Set an accessor object for the java.awt.Component class.
510 */
511 public static void setComponentAccessor(ComponentAccessor ca) {
512 componentAccessor = ca;
513 }
514
515 /*
516 * Retrieve the accessor object for the java.awt.Component class.
517 */
518 public static ComponentAccessor getComponentAccessor() {
519 if (componentAccessor == null) {
520 unsafe.ensureClassInitialized(Component.class);
521 }
522
523 return componentAccessor;
524 }
525
526 /*
675 unsafe.ensureClassInitialized(PopupMenu.class);
676 }
677 return popupMenuAccessor;
678 }
679
680 /*
681 * Set an accessor object for the java.awt.FileDialog class.
682 */
683 public static void setFileDialogAccessor(FileDialogAccessor fda) {
684 fileDialogAccessor = fda;
685 }
686
687 /*
688 * Retrieve the accessor object for the java.awt.FileDialog class.
689 */
690 public static FileDialogAccessor getFileDialogAccessor() {
691 if (fileDialogAccessor == null) {
692 unsafe.ensureClassInitialized(FileDialog.class);
693 }
694 return fileDialogAccessor;
695 }
696
697 /**
698 * Set an accessor object for the java.awt.event.InvocationEvent class.
699 */
700 public static void setInvocationEventAccessor(InvocationEventAccessor iea) {
701 invocationEventAccessor = iea;
702 }
703
704 /**
705 * Retrieve the accessor object for the java.awt.event.InvocationEvent class.
706 */
707 public static InvocationEventAccessor getInvocationEventAccessor() {
708 if (invocationEventAccessor == null) {
709 unsafe.ensureClassInitialized(InvocationEvent.class);
710 }
711 return invocationEventAccessor;
712 }
713
714 }
|