提交 5eaeff5d 编写于 作者: L lana

Merge

......@@ -203,3 +203,5 @@ b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77
c933505d75c2a0a671f06d6dac5d2237a9228d2d jdk8-b79
dfb40f066c6ce129822f0f5dc2ac89173808781a jdk8-b80
c0f8022eba536dcdc8aae659005b33f3982b9368 jdk8-b81
624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82
ac519af51769e92c51b597a730974e8607357709 jdk8-b83
#
# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -34,6 +34,8 @@ JAVAC_MAX_WARNINGS = true
JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
JAVAC_LINT_OPTIONS += -Xlint:-overrides
#
# Files to compile
#
......
#
# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -33,6 +33,8 @@ JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
JAVAC_LINT_OPTIONS += -Xlint:-deprecation
#
# Files to compile
#
......
#
# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -76,6 +76,7 @@ FILES_c = \
debug_trace.c \
debug_util.c \
awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
......
......@@ -843,6 +843,7 @@ LIBAWT_XAWT_FILES:=\
debug_trace.c \
debug_util.c \
awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
......@@ -2663,11 +2664,8 @@ BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
##########################################################################################
ifndef DISABLE_INTREE_EC
#
# TODO Set DISABLE_INTREE_EC in configure if src/share/native/sun/security/ec/impl
# is not present
#
ifeq ($(ENABLE_INTREE_EC),yes)
BUILD_LIBSUNEC_FLAGS:= -I$(JDK_TOPDIR)/src/share/native/sun/security/ec \
-I$(JDK_TOPDIR)/src/share/native/sun/security/ec/impl
......
......@@ -83,14 +83,19 @@ public abstract class AquaButtonBorder extends AquaBorder implements Border, UIR
painter.state.set(state);
painter.state.set((state != State.DISABLED && state != State.INACTIVE) && b.isFocusPainted() && isFocused(b) ? Focused.YES : Focused.NO);
// Full border size of the component.
// g.setColor(new Color(0, 255, 0, 70));
// g.drawRect(x, y, width - 1, height - 1);
final Insets subInsets = sizeVariant.insets;
x += subInsets.left;
y += subInsets.top;
width -= (subInsets.left + subInsets.right);
height -= (subInsets.top + subInsets.bottom);
// g.setColor(Color.magenta);
// g.drawRect(x, y, width - 1, height - 1);
// Where the native border should start to paint.
// g.setColor(new Color(255, 0, 255, 70));
// g.drawRect(x, y, width - 1, height - 1);
doButtonPaint(b, model, g, x, y, width, height);
}
......
......@@ -184,30 +184,30 @@ public class AquaButtonExtendedTypes {
new BorderDefinedTypeSpecifier("round", Widget.BUTTON_ROUND, new SizeVariant().alterInsets(2, 0, 0, 0).alterMinSize(28, 28), -3, -3, -3, -3),
new BorderDefinedTypeSpecifier("texturedRound", Widget.BUTTON_ROUND_INSET, new SizeVariant().alterInsets(0, 0, 0, 0).alterMinSize(26, 26), -2, -2, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmented-first", Widget.BUTTON_SEGMENTED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 16, 6, 10).alterInsets(5, 3, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-middle", Widget.BUTTON_SEGMENTED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 9, 6, 10).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-last", Widget.BUTTON_SEGMENTED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 9, 6, 16).alterInsets(5, 0, 5, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-only", Widget.BUTTON_SEGMENTED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 16, 6, 16).alterInsets(5, 3, 5, 3).alterMinSize(34, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-first", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-middle", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-last", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-only", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-first", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-middle", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-last", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-only", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-first", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(6, 3, 6, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-middle", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(6, 0, 6, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-last", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(6, 0, 6, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-only", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(6, 3, 6, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-first", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-middle", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-last", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-only", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(34, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmented-first", Widget.BUTTON_SEGMENTED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 16, 6, 10).alterInsets(2, 3, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-middle", Widget.BUTTON_SEGMENTED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 9, 6, 10).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-last", Widget.BUTTON_SEGMENTED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 9, 6, 16).alterInsets(2, 0, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-only", Widget.BUTTON_SEGMENTED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 16, 6, 16).alterInsets(2, 3, 2, 3).alterMinSize(34, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-first", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-middle", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-last", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-only", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-first", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-middle", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-last", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-only", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-first", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 3, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-middle", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-last", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-only", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 3, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-first", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-middle", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-last", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-only", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(34, 28), 0, 0, 0, 0),
new BorderDefinedTypeSpecifier("segmentedGradient-first", Widget.BUTTON_BEVEL_INSET, new SizeVariant(18, 18).alterMargins(4, 5, 4, 5).replaceInsets(new Insets(-2,-0,-2,-0))),
new BorderDefinedTypeSpecifier("segmentedGradient-middle", Widget.BUTTON_BEVEL_INSET, new SizeVariant(18, 18).alterMargins(4, 5, 4, 5).replaceInsets(new Insets(-2,-1,-2,-0))),
......
......@@ -49,6 +49,42 @@ static int getBPPFromModeString(CFStringRef mode)
return 0;
}
static BOOL isValidDisplayMode(CGDisplayModeRef mode){
return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
}
static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFIndex numModes = CFArrayGetCount(allModes);
CFMutableArrayRef validModes = CFArrayCreateMutable(kCFAllocatorDefault, numModes + 1, NULL);
CFIndex n;
for (n=0; n < numModes; n++) {
CGDisplayModeRef cRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(allModes, n);
if (cRef != NULL && isValidDisplayMode(cRef)) {
CFArrayAppendValue(validModes, cRef);
}
}
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
BOOL containsCurrentMode = NO;
numModes = CFArrayGetCount(validModes);
for (n=0; n < numModes; n++) {
if(CFArrayGetValueAtIndex(validModes, n) == currentMode){
containsCurrentMode = YES;
break;
}
}
if (!containsCurrentMode) {
CFArrayAppendValue(validModes, currentMode);
}
return validModes;
}
/*
* Find the best possible match in the list of display modes that we can switch to based on
* the provided parameters.
......@@ -198,28 +234,30 @@ Java_sun_awt_CGraphicsDevice_nativeSetDisplayMode
(JNIEnv *env, jclass class, jint displayID, jint w, jint h, jint bpp, jint refrate)
{
JNF_COCOA_ENTER(env);
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
__block CGError retCode = kCGErrorSuccess;
if (closestMatch != NULL) {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
CGDisplayConfigRef config;
CGError retCode = CGBeginDisplayConfiguration(&config);
retCode = CGBeginDisplayConfiguration(&config);
if (retCode == kCGErrorSuccess) {
CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
if (config != NULL) {
CFRelease(config);
}
retCode = CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
}
}];
} else {
[JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
}
if (retCode != kCGErrorSuccess){
[JNFException raise:env as:kIllegalArgumentException reason:"Unable to set display mode!"];
}
CFRelease(allModes);
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetDisplayMode
......@@ -247,7 +285,8 @@ Java_sun_awt_CGraphicsDevice_nativeGetDisplayModes
{
jobjectArray jreturnArray = NULL;
JNF_COCOA_ENTER(env);
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
CFIndex numModes = CFArrayGetCount(allModes);
static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
......
......@@ -57,6 +57,7 @@ public class SynthScrollBarUI extends BasicScrollBarUI
*/
@Override
protected void installDefaults() {
super.installDefaults();
trackHighlight = NO_HIGHLIGHT;
if (scrollbar.getLayout() == null ||
(scrollbar.getLayout() instanceof UIResource)) {
......
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -437,6 +437,39 @@ gboolean gtk2_check_version()
}
}
/**
* Functions for awt_Desktop.c
*/
gboolean gtk2_show_uri_load() {
gboolean success = FALSE;
dlerror();
const char *gtk_version = fp_gtk_check_version(2, 14, 0);
if (gtk_version != NULL) {
// The gtk_show_uri is available from GTK+ 2.14
#ifdef INTERNAL_BUILD
fprintf (stderr, "The version of GTK is %s. "
"The gtk_show_uri function is supported "
"since GTK+ 2.14.\n", gtk_version);
#endif /* INTERNAL_BUILD */
} else {
// Loading symbols only if the GTK version is 2.14 and higher
fp_gtk_show_uri = dl_symbol("gtk_show_uri");
const char *dlsym_error = dlerror();
if (dlsym_error) {
#ifdef INTERNAL_BUILD
fprintf (stderr, "Cannot load symbol: %s \n", dlsym_error);
#endif /* INTERNAL_BUILD */
} else if (fp_gtk_show_uri == NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
#endif /* INTERNAL_BUILD */
} else {
success = TRUE;
}
}
return success;
}
/**
* Functions for sun_awt_X11_GtkFileDialogPeer.c
*/
......
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -42,6 +42,7 @@
#define GTK_STOCK_CANCEL "gtk-cancel"
#define GTK_STOCK_SAVE "gtk-save"
#define GTK_STOCK_OPEN "gtk-open"
#define GDK_CURRENT_TIME 0L
typedef enum _WidgetType
{
......@@ -280,6 +281,7 @@ struct _GSList
typedef void GdkColormap;
typedef void GdkDrawable;
typedef void GdkGC;
typedef void GdkScreen;
typedef void GdkPixbuf;
typedef void GdkPixmap;
typedef void GdkWindow;
......@@ -663,6 +665,15 @@ gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
*/
gboolean gtk2_load();
/*
* Loads fp_gtk_show_uri function pointer. This initialization is
* separated because the function is required only
* for java.awt.Desktop API. The function relies on initialization in
* gtk2_load, so it must be invoked only after a successful gtk2_load
* invocation
*/
gboolean gtk2_show_uri_load();
/*
* Unload the gtk2 library. If the library is already unloaded this method has
* no effect and returns success.
......@@ -795,4 +806,7 @@ void (*fp_gdk_threads_init)(void);
void (*fp_gdk_threads_enter)(void);
void (*fp_gdk_threads_leave)(void);
gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
guint32 timestamp, GError **error);
#endif /* !_GTK2_INTERFACE_H */
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,71 +23,11 @@
* questions.
*/
#include <jni.h>
#include <jvm_md.h>
#include <dlfcn.h>
#include "gtk2_interface.h"
#include "gnome_interface.h"
typedef int gboolean;
typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
GNOME_URL_SHOW_TYPE *gnome_url_show;
GNOME_VFS_INIT_TYPE *gnome_vfs_init;
int init(){
void *vfs_handle;
void *gnome_handle;
const char *errmsg;
vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY);
if (vfs_handle == NULL) {
vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
if (vfs_handle == NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not load libgnomevfs-2.so\n");
#endif
return 0;
}
}
dlerror(); /* Clear errors */
gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
if (gnome_vfs_init == NULL){
#ifdef INTERNAL_BUILD
fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
#endif
return 0;
}
if ((errmsg = dlerror()) != NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
#endif
return 0;
}
// call gonme_vfs_init()
(*gnome_vfs_init)();
gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY);
if (gnome_handle == NULL) {
gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
if (gnome_handle == NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not load libgnome-2.so\n");
#endif
return 0;
}
}
dlerror(); /* Clear errors */
gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
if ((errmsg = dlerror()) != NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not find symble gnome_url_show\n");
#endif
return 0;
}
return 1;
}
static gboolean gtk_has_been_loaded = FALSE;
static gboolean gnome_has_been_loaded = FALSE;
/*
* Class: sun_awt_X11_XDesktopPeer
......@@ -97,8 +37,20 @@ int init(){
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
(JNIEnv *env, jclass cls)
{
int init_ok = init();
return init_ok ? JNI_TRUE : JNI_FALSE;
if (gtk_has_been_loaded || gnome_has_been_loaded) {
return JNI_TRUE;
}
if (gtk2_load() && gtk2_show_uri_load()) {
gtk_has_been_loaded = TRUE;
return JNI_TRUE;
} else if (gnome_load()) {
gnome_has_been_loaded = TRUE;
return JNI_TRUE;
}
return JNI_FALSE;
}
/*
......@@ -109,16 +61,19 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
(JNIEnv *env, jobject obj, jbyteArray url_j)
{
gboolean success;
const char* url_c;
gboolean success = FALSE;
const gchar* url_c;
if (gnome_url_show == NULL) {
return JNI_FALSE;
url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
if (gtk_has_been_loaded) {
fp_gdk_threads_enter();
success = fp_gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
fp_gdk_threads_leave();
} else if (gnome_has_been_loaded) {
success = (*gnome_url_show)(url_c, NULL);
}
url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
// call gnome_url_show(const char* , GError**)
success = (*gnome_url_show)(url_c, NULL);
(*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
return success ? JNI_TRUE : JNI_FALSE;
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "gnome_interface.h"
GNOME_URL_SHOW_TYPE *gnome_url_show = NULL;
gboolean gnome_load() {
void *vfs_handle;
void *gnome_handle;
const char *errmsg;
GNOME_VFS_INIT_TYPE *gnome_vfs_init;
// trying to open the gnomevfs. VERSIONED_JNI_LIB_NAME
// macros formats the library name in a system specific manner
// see jdk/src/solaris/javavm/export/jvm_md.h for more details
vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY);
if (vfs_handle == NULL) {
// if we cannot load the library using a version assumed by JNI
// we are trying to load the library without a version suffix
vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
if (vfs_handle == NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not load libgnomevfs-2.so\n");
#endif
return FALSE;
}
}
dlerror(); /* Clear errors */
gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
if (gnome_vfs_init == NULL){
#ifdef INTERNAL_BUILD
fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
#endif
return FALSE;
}
if ((errmsg = dlerror()) != NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
#endif
return FALSE;
}
// call gonme_vfs_init()
(*gnome_vfs_init)();
gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY);
if (gnome_handle == NULL) {
gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
if (gnome_handle == NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not load libgnome-2.so\n");
#endif
return FALSE;
}
}
dlerror(); /* Clear errors */
gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
if ((errmsg = dlerror()) != NULL) {
#ifdef INTERNAL_BUILD
fprintf(stderr, "can not find symble gnome_url_show\n");
#endif
return FALSE;
}
return TRUE;
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef _GNOME_INTERFACE_H
#define _GNOME_INTERFACE_H
#include "gtk2_interface.h"
#include <dlfcn.h>
#include <jvm_md.h>
#include <jni.h>
typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
extern GNOME_URL_SHOW_TYPE *gnome_url_show;
gboolean gnome_load();
#endif /* !_GNOME_INTERFACE_H */
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -51,15 +51,15 @@ public class WDesktopPeer implements DesktopPeer {
}
public void open(File file) throws IOException {
this.ShellExecute(file.toURI(), ACTION_OPEN_VERB);
this.ShellExecute(file, ACTION_OPEN_VERB);
}
public void edit(File file) throws IOException {
this.ShellExecute(file.toURI(), ACTION_EDIT_VERB);
this.ShellExecute(file, ACTION_EDIT_VERB);
}
public void print(File file) throws IOException {
this.ShellExecute(file.toURI(), ACTION_PRINT_VERB);
this.ShellExecute(file, ACTION_PRINT_VERB);
}
public void mail(URI uri) throws IOException {
......@@ -70,6 +70,13 @@ public class WDesktopPeer implements DesktopPeer {
this.ShellExecute(uri, ACTION_OPEN_VERB);
}
private void ShellExecute(File file, String verb) throws IOException {
String errMsg = ShellExecute(file.getAbsolutePath(), verb);
if (errMsg != null) {
throw new IOException("Failed to " + verb + " " + file + ". Error message: " + errMsg);
}
}
private void ShellExecute(URI uri, String verb) throws IOException {
String errmsg = ShellExecute(uri.toString(), verb);
......@@ -79,6 +86,6 @@ public class WDesktopPeer implements DesktopPeer {
}
}
private static native String ShellExecute(String uri, String verb);
private static native String ShellExecute(String fileOrUri, String verb);
}
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -38,17 +38,17 @@ extern "C" {
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
(JNIEnv *env, jclass cls, jstring uri_j, jstring verb_j)
(JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
{
LPCWSTR uri_c = JNU_GetStringPlatformChars(env, uri_j, JNI_FALSE);
LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
// 6457572: ShellExecute possibly changes FPU control word - saving it here
unsigned oldcontrol87 = _control87(0, 0);
HINSTANCE retval = ::ShellExecute(NULL, verb_c, uri_c, NULL, NULL, SW_SHOWNORMAL);
HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
_control87(oldcontrol87, 0xffffffff);
JNU_ReleaseStringPlatformChars(env, uri_j, uri_c);
JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
JNU_ReleaseStringPlatformChars(env, verb_j, verb_c);
if ((int)retval <= 32) {
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 6550588
@summary java.awt.Desktop cannot open file with Windows UNC filename
@author Anton Litvinov
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class OpenByUNCPathNameTest {
private static boolean validatePlatform() {
String osName = System.getProperty("os.name");
if (osName == null) {
throw new RuntimeException("Name of the current OS could not be retrieved.");
}
return osName.startsWith("Windows");
}
private static void openFile() throws IOException {
if (!Desktop.isDesktopSupported()) {
System.out.println("java.awt.Desktop is not supported on this platform.");
} else {
Desktop desktop = Desktop.getDesktop();
File file = File.createTempFile("Read Me File", ".txt");
try {
// Test opening of the file with Windows local file path.
desktop.open(file);
Robot robot = null;
try {
Thread.sleep(5000);
robot = new Robot();
} catch (Exception e) {
e.printStackTrace();
}
pressAltF4Keys(robot);
// Test opening of the file with Windows UNC pathname.
String uncFilePath = "\\\\127.0.0.1\\" + file.getAbsolutePath().replace(':', '$');
File uncFile = new File(uncFilePath);
if (!uncFile.exists()) {
throw new RuntimeException(String.format(
"File with UNC pathname '%s' does not exist.", uncFilePath));
}
desktop.open(uncFile);
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
pressAltF4Keys(robot);
} finally {
file.delete();
}
}
}
private static void pressAltF4Keys(Robot robot) {
if (robot != null) {
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F4);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_ALT);
}
}
public static void main(String[] args) throws IOException {
if (!validatePlatform()) {
System.out.println("This test is only for MS Windows OS.");
} else {
openFile();
}
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8007146
* @summary [macosx] Setting a display mode crashes JDK under VNC
* @author Alexander Scherbatiy
* @run main CheckDisplayModes
*/
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
public class CheckDisplayModes {
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice graphicDevice = ge.getDefaultScreenDevice();
DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
checkDisplayMode(defaultDisplayMode);
graphicDevice.setDisplayMode(defaultDisplayMode);
DisplayMode[] displayModes = graphicDevice.getDisplayModes();
boolean isDefaultDisplayModeIncluded = false;
for (DisplayMode displayMode : displayModes) {
checkDisplayMode(displayMode);
graphicDevice.setDisplayMode(displayMode);
if (defaultDisplayMode.equals(displayMode)) {
isDefaultDisplayModeIncluded = true;
}
}
if (!isDefaultDisplayModeIncluded) {
throw new RuntimeException("Default display mode is not included");
}
}
static void checkDisplayMode(DisplayMode displayMode) {
if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
throw new RuntimeException("invalid display mode");
}
}
}
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -30,6 +30,7 @@
import com.sun.beans.TypeResolver;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Field;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
......@@ -199,6 +200,19 @@ public class TestTypeResolver {
public Annotation[] getDeclaredAnnotations() {
return null; // not used
}
public AnnotatedType[] getAnnotatedBounds() {
return null; // not used
}
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
return null; // not used
}
public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
return null; // not used
}
}
private static class ClassTypeVariable extends TypeVariableImpl<Class<?>> {
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import sun.awt.SunToolkit;
/**
* @test
* @bug 4515762
* @author Mark Davidson
* @summary Tests the ability to support duplicate mnemonics
* @library ../../regtesthelpers
* @build Util
* @run main bug4515762
*/
public class bug4515762 {
private static volatile boolean actionExpected = false;
private static volatile boolean actionRecieved = false;
/**
* @param str name of Menu
*/
private static JMenuBar createMenuBar() {
JMenuBar menubar = new JMenuBar();
// Duplicate menu item test for 4515762
JMenu menu = new JMenu("Duplicate Menu");
menu.setMnemonic('D');
menu.add(createMenuItem("Sunday", 'S'));
menu.add(createMenuItem("Monday", 'M'));
menu.add(createMenuItem("Tuesday", 'S'));
menu.add(createMenuItem("Wednesday", 'S'));
menu.add(createMenuItem("Thursday", 'S'));
menu.add(createMenuItem("Friday", 'F'));
menu.add(createMenuItem("Saturday", 'S'));
// Control with unique menu
JMenu menu2 = new JMenu("Unique Menu");
menu2.setMnemonic('U');
menu2.add(createMenuItem("Sunday", 'S'));
menu2.add(createMenuItem("Monday", 'M'));
menu2.add(createMenuItem("Tuesday", 'T'));
menu2.add(createMenuItem("Wednesday", 'W'));
menu2.add(createMenuItem("Thursday", 'U'));
menu2.add(createMenuItem("Friday", 'F'));
menu2.add(createMenuItem("Saturday", 'A'));
menubar.add(menu);
menubar.add(menu2);
return menubar;
}
/**
* Creates and returns the menu item.
*/
private static JMenuItem createMenuItem(String name, char mnemonic) {
JMenuItem menuItem = new JMenuItem(name, mnemonic);
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
JMenuItem item = (JMenuItem) evt.getSource();
if (actionExpected == false) {
throw new RuntimeException("Menu Action: "
+ item.getText() + " should not be called");
} else {
actionRecieved = true;
}
}
});
return menuItem;
}
public static void checkAction() {
if (actionRecieved == true) {
actionRecieved = false;
} else {
throw new RuntimeException("Action has not been received");
}
}
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setJMenuBar(createMenuBar());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_D);
toolkit.realSync();
// Press the S key many times (should not cause an action peformed)
int TIMES = 5;
for (int i = 0; i < TIMES; i++) {
Util.hitKeys(robot, KeyEvent.VK_S);
}
toolkit.realSync();
// Unique menu items.
actionExpected = true;
Util.hitMnemonics(robot, KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_M);
robot.keyRelease(KeyEvent.VK_M);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_T);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_W);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_U);
toolkit.realSync();
checkAction();
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import sun.awt.SunToolkit;
/**
* @test
* @bug 4670486
* @author Mark Davidson
* @summary Regression: Popup menu bindings doesn't work when a default button has been defined.
* @library ../../regtesthelpers
* @build Util
* @run main bug4670486
*/
public class bug4670486 {
public static volatile boolean actionExpected = false;
public static volatile boolean actionRecieved = false;
private static JMenuBar createMenuBar() {
JMenuBar menubar = new JMenuBar();
// Control with unique menu
JMenu menu = new JMenu("Unique Menu");
menu.setMnemonic('U');
menu.add(createMenuItem("Sunday", 'S'));
menu.add(createMenuItem("Monday", 'M'));
menu.add(createMenuItem("Tuesday", 'T'));
menu.add(createMenuItem("Wednesday", 'W'));
menu.add(createMenuItem("Thursday", 'U'));
menu.add(createMenuItem("Friday", 'F'));
menu.add(createMenuItem("Saturday", 'A'));
menubar.add(menu);
return menubar;
}
private static JPanel createPanel(JFrame frame) {
JPanel panel = new JPanel();
JButton button = new JButton("Button");
JButton button2 = new JButton("Button 2");
JButton button3 = new JButton("Button 3");
JRootPane root = frame.getRootPane();
root.setDefaultButton(button);
panel.add(button);
panel.add(button2);
panel.add(button3);
return panel;
}
/**
* Creates and returns the menu item.
*/
private static JMenuItem createMenuItem(String name, char mnemonic) {
JMenuItem menuItem = new JMenuItem(name, mnemonic);
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
actionRecieved = true;
}
});
return menuItem;
}
public static void checkAction() {
if (actionRecieved == true) {
actionRecieved = false;
} else {
throw new RuntimeException("Action has not been received");
}
}
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setContentPane(createPanel(frame));
frame.setJMenuBar(createMenuBar());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
// Change the default button to
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
Util.hitKeys(robot, KeyEvent.VK_TAB);
// If the bug exists, then as soon as the menu appears,
// the VK_ENTER, VK_DOWN, VK_UP and VK_ESC will have no
// effect.
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_DOWN);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
toolkit.realSync();
checkAction();
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7163696
* @summary Tests that JScrollBar scrolls to the left
* @author Sergey Malenkov
*/
import sun.awt.SunToolkit;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
public class Test7163696 implements Runnable {
private static final boolean AUTO = null != System.getProperty("test.src", null);
public static void main(String[] args) throws Exception {
new Test7163696().test();
}
private JScrollBar bar;
private void test() throws Exception {
Robot robot = new Robot();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel(info.getClassName());
SwingUtilities.invokeAndWait(this);
toolkit.realSync(500); // after creation
Point point = this.bar.getLocation();
SwingUtilities.convertPointToScreen(point, this.bar);
point.x += this.bar.getWidth() >> 2;
point.y += this.bar.getHeight() >> 1;
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync(500); // before validation
SwingUtilities.invokeAndWait(this);
if (this.bar != null) {
this.bar = null; // allows to reuse the instance
if (AUTO) { // error reporting only for automatic testing
throw new Error("TEST FAILED");
}
}
}
}
public void run() {
if (this.bar == null) {
this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
this.bar.setPreferredSize(new Dimension(400, 20));
JFrame frame = new JFrame();
frame.add(this.bar);
frame.pack();
frame.setVisible(true);
}
else if (40 != this.bar.getValue()) {
System.out.println("name = " + UIManager.getLookAndFeel().getName());
System.out.println("value = " + this.bar.getValue());
}
else {
SwingUtilities.getWindowAncestor(this.bar).dispose();
this.bar = null;
}
}
}
......@@ -48,8 +48,13 @@ public class bug8004298 {
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
UIManager.setLookAndFeel(new WindowsLookAndFeel());
try {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
} catch (javax.swing.UnsupportedLookAndFeelException ulafe) {
System.out.println(ulafe.getMessage());
System.out.println("The test is considered PASSED");
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override
......@@ -113,4 +118,4 @@ public class bug8004298 {
return super.getPathBounds(tree, path);
}
}
}
\ No newline at end of file
}
......@@ -145,6 +145,23 @@ public class Util {
return null;
}
/**
* Hits mnemonics by robot.
*/
public static void hitMnemonics(Robot robot, int... keys) {
ArrayList<Integer> mnemonicKeyCodes = getSystemMnemonicKeyCodes();
for (Integer mnemonic : mnemonicKeyCodes) {
robot.keyPress(mnemonic);
}
hitKeys(robot, keys);
for (Integer mnemonic : mnemonicKeyCodes) {
robot.keyRelease(mnemonic);
}
}
/**
* Hits keys by robot.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册