提交 28627082 编写于 作者: L lana

Merge

......@@ -55,3 +55,6 @@ e6a5d095c356a547cf5b3c8885885aca5e91e09b jdk7-b77
1143e498f813b8223b5e3a696d79da7ff7c25354 jdk7-b78
918920710d65432a2d54fdf407c1524a5571c4ad jdk7-b79
049cfaaa9a7374e3768a79969a799e8b59ad52fa jdk7-b80
10b993d417fcdb40480dad7032ac241f4b87f1af jdk7-b81
69ef657320ad5c35cfa12e4d8322d877e778f8b3 jdk7-b82
9027c6b9d7e2c9ca04a1add691b5b50d0f22b1aa jdk7-b83
......@@ -138,6 +138,10 @@ JAVACFLAGS += $(OTHER_JAVACFLAGS)
# Needed for javah
JAVAHFLAGS += -bootclasspath $(CLASSBINDIR)
# Needed for javadoc to ensure it builds documentation
# against the newly built classes
JAVADOCFLAGS += -bootclasspath $(CLASSBINDIR)
# Needed for JAVADOC and BOOT_JAVACFLAGS
NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
......@@ -155,14 +159,15 @@ ifdef LANGTOOLS_DIST
-jar $(JAVAH_JAR) $(JAVAHFLAGS)
JAVADOC_CMD = $(BOOT_JAVA_CMD) \
"-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
-jar $(JAVADOC_JAR)
-jar $(JAVADOC_JAR) $(JAVADOCFLAGS)
else
# If no explicit tools, use boot tools (add VM flags in this case)
JAVAC_CMD = $(JAVA_TOOLS_DIR)/javac $(JAVAC_JVM_FLAGS) \
$(JAVACFLAGS)
JAVAH_CMD = $(JAVA_TOOLS_DIR)/javah \
$(JAVAHFLAGS)
JAVADOC_CMD = $(JAVA_TOOLS_DIR)/javadoc $(JAVA_TOOLS_FLAGS:%=-J%)
JAVADOC_CMD = $(JAVA_TOOLS_DIR)/javadoc $(JAVA_TOOLS_FLAGS:%=-J%) \
$(JAVADOCFLAGS)
endif
# Override of what javac to use (see deploy workspace)
......
......@@ -69,7 +69,7 @@ DRAFT = '<br><strong>DRAFT&nbsp;'$(MILESTONE)-$(BUILD_NUMBER)'</strong>'
THIS_YEAR := $(shell $(DATE) | $(SED) -e 's/ / /g' | $(CUT) -d' ' -f6)
TRADEMARK = &\#x2122;
IGNORED_TAGS = beaninfo revised since.unbundled spec Note ToDo
IGNORED_TAGS = beaninfo revised since.unbundled spec specdefault Note ToDo
JLS3_URL = http://java.sun.com/docs/books/jls/
JLS3_CITE = <a href="$(JLS3_URL)"> \
......
......@@ -25,7 +25,7 @@
#
# Makefile to build the BeanInfo generation tool (ie, a doclet), and
# then the beaninfo itself. Swing versions prior to 1.2 is no longer
# then the beaninfo itself. Swing versions prior to 1.2 are no longer
# built.
#
# This makefile could be a lot simpler if we made it more regular.
......@@ -44,13 +44,12 @@ swing-1.2-beans-debug:
$(MAKE) DEBUG_FLAG=true make-swing-beans
LOCAL_JAVADOC = $(JAVADOC_CMD) $(JAVADOCFLAGS)
# get the absolute path to the jar command.
PREFIX = 1.2
JAVADOCFLAGS = $(NO_PROPRIETARY_API_WARNINGS) $(LANGUAGE_VERSION)
JAVADOCFLAGS += $(NO_PROPRIETARY_API_WARNINGS) $(LANGUAGE_VERSION)
SWINGPKG = javax/swing
LOCAL_JAVAC_FLAGS = $(OTHER_JAVACFLAGS)
# since LOCAL_JAVADOC runs on ALT_BOOTDIR, the doclet and all its classes must be compiled to match
# since JAVADOC_CMD runs on ALT_BOOTDIR, the doclet and all its classes must be compiled to match
DOCLET_JAVAC_FLAGS = -source 6 -target 6
include FILES.gmk
......@@ -114,7 +113,7 @@ mkbeaninfo: $(BEANSRCDIR) .delete.beanlist $(FILES_beans) .javadoc.beanlist
.javadoc.beanlist:
if [ -s $(TEMPDIR)/.beans.list ]; \
then $(LOCAL_JAVADOC) $(DOCLETFLAGS) -x $(DEBUG_FLAG) -d $(BEANSRCDIR) -t $(DOCLETSRC)/SwingBeanInfo.template -docletpath $(DOCLETDST) \
then $(JAVADOC_CMD) $(DOCLETFLAGS) -x $(DEBUG_FLAG) -d $(BEANSRCDIR) -t $(DOCLETSRC)/SwingBeanInfo.template -docletpath $(DOCLETDST) \
$(shell if [ -s $(TEMPDIR)/.beans.list ]; then $(CAT) $(TEMPDIR)/.beans.list; fi); \
fi
@$(java-vm-cleanup)
......
......@@ -179,6 +179,8 @@ FILES_cpp = \
awt_Mlib.cpp \
awt_new.cpp \
awt_TrayIcon.cpp \
awt_DCHolder.cpp \
awt_ole.cpp \
ShaderList.cpp \
D3DBlitLoops.cpp \
D3DBufImgOps.cpp \
......
......@@ -250,13 +250,14 @@ ifeq ($(PLATFORM), windows)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \
imm32.lib ole32.lib uuid.lib shell32.lib \
comdlg32.lib winmm.lib comctl32.lib delayimp.lib \
comdlg32.lib winmm.lib comctl32.lib \
shlwapi.lib delayimp.lib \
$(JVMLIB) \
/DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
/DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
/DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
/DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
/DELAYLOAD:comctl32.dll
/DELAYLOAD:comctl32.dll /DELAYLOAD:shlwapi.dll
clean:: awt.clean
......
此差异已折叠。
......@@ -110,7 +110,7 @@ public abstract class GraphicsEnvironment {
// long t1 = System.currentTimeMillis();
// System.out.println("GE creation took " + (t1-t0)+ "ms.");
if (isHeadless()) {
localEnv = new HeadlessGraphicsEnvironment(localEnv);
ge = new HeadlessGraphicsEnvironment(ge);
}
} catch (ClassNotFoundException e) {
throw new Error("Could not find class: "+nm);
......
/*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. 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
......@@ -146,6 +146,8 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
* @param out The code output stream.
* @return An expression whose value is <code>oldInstance</code>.
*
* @throws NullPointerException if {@code out} is {@code null}
*
* @see #DefaultPersistenceDelegate(String[])
*/
protected Expression instantiate(Object oldInstance, Encoder out) {
......@@ -367,6 +369,8 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
*
* @throws NullPointerException if {@code out} is {@code null}
*
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.PropertyDescriptor
*/
......
/*
* Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. 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
......@@ -112,54 +112,82 @@ public class Encoder {
/**
* Returns the persistence delegate for the given type.
* The persistence delegate is calculated
* by applying the following of rules in order:
* <ul>
* The persistence delegate is calculated by applying
* the following rules in order:
* <ol>
* <li>
* If the type is an array, an internal persistence
* delegate is returned which will instantiate an
* array of the appropriate type and length, initializing
* each of its elements as if they are properties.
* If a persistence delegate is associated with the given type
* by using the {@link #setPersistenceDelegate} method
* it is returned.
* <li>
* If the type is a proxy, an internal persistence
* delegate is returned which will instantiate a
* new proxy instance using the static
* "newProxyInstance" method defined in the
* Proxy class.
* A persistence delegate is then looked up by the name
* composed of the the fully qualified name of the given type
* and the "PersistenceDelegate" postfix.
* For example, a persistence delegate for the {@code Bean} class
* should be named {@code BeanPersistenceDelegate}
* and located in the same package.
* <pre>
* public class Bean { ... }
* public class BeanPersistenceDelegate { ... }</pre>
* The instance of the {@code BeanPersistenceDelegate} class
* is returned for the {@code Bean} class.
* <li>
* If the BeanInfo for this type has a <code>BeanDescriptor</code>
* which defined a "persistenceDelegate" property, this
* value is returned.
* If the type is {@code null},
* a shared internal persistence delegate is returned
* that encodes {@code null} value.
* <li>
* In all other cases the default persistence delegate
* is returned. The default persistence delegate assumes
* the type is a <em>JavaBean</em>, implying that it has a default constructor
* and that its state may be characterized by the matching pairs
* of "setter" and "getter" methods returned by the Introspector.
* If the type is a {@code enum} declaration,
* a shared internal persistence delegate is returned
* that encodes constants of this enumeration
* by their names.
* <li>
* If the type is a primitive type or the corresponding wrapper,
* a shared internal persistence delegate is returned
* that encodes values of the given type.
* <li>
* If the type is an array,
* a shared internal persistence delegate is returned
* that encodes an array of the appropriate type and length,
* and each of its elements as if they are properties.
* <li>
* If the type is a proxy,
* a shared internal persistence delegate is returned
* that encodes a proxy instance by using
* the {@link java.lang.reflect.Proxy#newProxyInstance} method.
* <li>
* If the {@link BeanInfo} for this type has a {@link BeanDescriptor}
* which defined a "persistenceDelegate" attribute,
* the value of this named attribute is returned.
* <li>
* In all other cases the default persistence delegate is returned.
* The default persistence delegate assumes the type is a <em>JavaBean</em>,
* implying that it has a default constructor and that its state
* may be characterized by the matching pairs of "setter" and "getter"
* methods returned by the {@link Introspector} class.
* The default constructor is the constructor with the greatest number
* of parameters that has the {@link ConstructorProperties} annotation.
* If none of the constructors have the {@code ConstructorProperties} annotation,
* If none of the constructors has the {@code ConstructorProperties} annotation,
* then the nullary constructor (constructor with no parameters) will be used.
* For example, in the following the nullary constructor
* for {@code Foo} will be used, while the two parameter constructor
* for {@code Bar} will be used.
* <code>
* public class Foo {
* For example, in the following code fragment, the nullary constructor
* for the {@code Foo} class will be used,
* while the two-parameter constructor
* for the {@code Bar} class will be used.
* <pre>
* public class Foo {
* public Foo() { ... }
* public Foo(int x) { ... }
* }
* public class Bar {
* }
* public class Bar {
* public Bar() { ... }
* &#64;ConstructorProperties({"x"})
* public Bar(int x) { ... }
* &#64;ConstructorProperties({"x", "y"})
* public Bar(int x, int y) { ... }
* }
* </code>
* </ul>
* }</pre>
* </ol>
*
* @param type The type of the object.
* @return The persistence delegate for this type of object.
* @param type the class of the objects
* @return the persistence delegate for the given type
*
* @see #setPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
......@@ -176,21 +204,18 @@ public class Encoder {
}
/**
* Sets the persistence delegate associated with this <code>type</code> to
* <code>persistenceDelegate</code>.
* Associates the specified persistence delegate with the given type.
*
* @param type The class of objects that <code>persistenceDelegate</code> applies to.
* @param persistenceDelegate The persistence delegate for instances of <code>type</code>.
* @param type the class of objects that the specified persistence delegate applies to
* @param delegate the persistence delegate for instances of the given type
*
* @see #getPersistenceDelegate
* @see java.beans.Introspector#getBeanInfo
* @see java.beans.BeanInfo#getBeanDescriptor
*/
public void setPersistenceDelegate(Class<?> type,
PersistenceDelegate persistenceDelegate)
{
public void setPersistenceDelegate(Class<?> type, PersistenceDelegate delegate) {
synchronized (this.finder) {
this.finder.register(type, persistenceDelegate);
this.finder.register(type, delegate);
}
}
......
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. 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,12 +51,19 @@ public class Expression extends Statement {
private Object value = unbound;
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
* <code>methodName</code> and <code>arguments</code> as per the parameters.
* Creates a new {@link Expression} object
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param target The target of this expression.
* @param methodName The methodName of this expression.
* @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
* @param target the target object of this expression
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*
* @see #getValue
*/
......@@ -66,16 +73,23 @@ public class Expression extends Statement {
}
/**
* Creates a new <code>Expression</code> object for a method
* that returns a result. The result will never be calculated
* however, since this constructor uses the <code>value</code>
* parameter to set the value property by calling the
* <code>setValue</code> method.
* Creates a new {@link Expression} object with the specified value
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* The {@code value} value is used as the value of the {@code value} property,
* so the {@link #getValue} method will return it
* without executing this {@code Expression}.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param value The value of this expression.
* @param target The target of this expression.
* @param methodName The methodName of this expression.
* @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
* @param value the value of this expression
* @param target the target object of this expression
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*
* @see #setValue
*/
......
/*
* Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2010 Sun Microsystems, Inc. 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
......@@ -29,6 +29,8 @@ import com.sun.beans.WeakCache;
import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
......@@ -39,6 +41,7 @@ import java.util.Iterator;
import java.util.EventListener;
import java.util.List;
import java.util.TreeMap;
import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.reflect.misc.ReflectUtil;
......@@ -155,11 +158,11 @@ public class Introspector {
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
}
synchronized (BEANINFO_CACHE) {
WeakCache<Class<?>, BeanInfo> beanInfoCache =
(WeakCache<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
Map<Class<?>, BeanInfo> beanInfoCache =
(Map<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache == null) {
beanInfoCache = new WeakCache<Class<?>, BeanInfo>();
beanInfoCache = new WeakHashMap<Class<?>, BeanInfo>();
AppContext.getAppContext().put(BEANINFO_CACHE, beanInfoCache);
}
BeanInfo beanInfo = beanInfoCache.get(beanClass);
......@@ -341,7 +344,7 @@ public class Introspector {
public static void flushCaches() {
synchronized (BEANINFO_CACHE) {
WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.clear();
}
......@@ -369,7 +372,7 @@ public class Introspector {
throw new NullPointerException();
}
synchronized (BEANINFO_CACHE) {
WeakCache beanInfoCache = (WeakCache) AppContext.getAppContext().get(BEANINFO_CACHE);
Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
if (beanInfoCache != null) {
beanInfoCache.put(clz, null);
}
......@@ -1458,7 +1461,7 @@ class GenericBeanInfo extends SimpleBeanInfo {
private PropertyDescriptor[] properties;
private int defaultProperty;
private MethodDescriptor[] methods;
private BeanInfo targetBeanInfo;
private final Reference<BeanInfo> targetBeanInfoRef;
public GenericBeanInfo(BeanDescriptor beanDescriptor,
EventSetDescriptor[] events, int defaultEvent,
......@@ -1470,7 +1473,7 @@ class GenericBeanInfo extends SimpleBeanInfo {
this.properties = properties;
this.defaultProperty = defaultProperty;
this.methods = methods;
this.targetBeanInfo = targetBeanInfo;
this.targetBeanInfoRef = new SoftReference<BeanInfo>(targetBeanInfo);
}
/**
......@@ -1509,7 +1512,7 @@ class GenericBeanInfo extends SimpleBeanInfo {
methods[i] = new MethodDescriptor(old.methods[i]);
}
}
targetBeanInfo = old.targetBeanInfo;
this.targetBeanInfoRef = old.targetBeanInfoRef;
}
public PropertyDescriptor[] getPropertyDescriptors() {
......@@ -1537,6 +1540,7 @@ class GenericBeanInfo extends SimpleBeanInfo {
}
public java.awt.Image getIcon(int iconKind) {
BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
if (targetBeanInfo != null) {
return targetBeanInfo.getIcon(iconKind);
}
......
/*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. 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
......@@ -105,6 +105,8 @@ public abstract class PersistenceDelegate {
*
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
*
* @throws NullPointerException if {@code out} is {@code null}
*/
public void writeObject(Object oldInstance, Encoder out) {
Object newInstance = out.get(oldInstance);
......@@ -158,6 +160,8 @@ public abstract class PersistenceDelegate {
* @param oldInstance The instance that will be created by this expression.
* @param out The stream to which this expression will be written.
* @return An expression whose value is <code>oldInstance</code>.
*
* @throws NullPointerException if {@code out} is {@code null}
*/
protected abstract Expression instantiate(Object oldInstance, Encoder out);
......@@ -196,6 +200,8 @@ public abstract class PersistenceDelegate {
* @param oldInstance The instance to be copied.
* @param newInstance The instance that is to be modified.
* @param out The stream to which any initialization statements should be written.
*
* @throws NullPointerException if {@code out} is {@code null}
*/
protected void initialize(Class<?> type,
Object oldInstance, Object newInstance,
......
/*
* Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. 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
......@@ -69,13 +69,19 @@ public class Statement {
ClassLoader loader;
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
* <code>methodName</code> and <code>arguments</code> as per the parameters.
*
* @param target The target of this statement.
* @param methodName The methodName of this statement.
* @param arguments The arguments of this statement. If <code>null</code> then an empty array will be used.
* Creates a new {@link Statement} object
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param target the target object of this statement
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*/
@ConstructorProperties({"target", "methodName", "arguments"})
public Statement(Object target, String methodName, Object[] arguments) {
......@@ -85,27 +91,36 @@ public class Statement {
}
/**
* Returns the target of this statement.
* Returns the target object of this statement.
* If this method returns {@code null},
* the {@link #execute} method
* throws a {@code NullPointerException}.
*
* @return The target of this statement.
* @return the target object of this statement
*/
public Object getTarget() {
return target;
}
/**
* Returns the name of the method.
* Returns the name of the method to invoke.
* If this method returns {@code null},
* the {@link #execute} method
* throws a {@code NullPointerException}.
*
* @return The name of the method.
* @return the name of the method
*/
public String getMethodName() {
return methodName;
}
/**
* Returns the arguments of this statement.
* Returns the arguments for the method to invoke.
* The number of arguments and their types
* must match the method being called.
* {@code null} can be used as a synonym of an empty array.
*
* @return the arguments of this statement.
* @return the array of arguments
*/
public Object[] getArguments() {
return arguments;
......@@ -154,6 +169,9 @@ public class Statement {
}
Object[] arguments = getArguments();
if (arguments == null) {
arguments = emptyArray;
}
// Class.forName() won't load classes outside
// of core from a class inside core. Special
// case this method.
......@@ -285,7 +303,9 @@ public class Statement {
Object target = getTarget();
String methodName = getMethodName();
Object[] arguments = getArguments();
if (arguments == null) {
arguments = emptyArray;
}
StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "(");
int n = arguments.length;
for(int i = 0; i < n; i++) {
......
......@@ -232,7 +232,7 @@ public final class CollationElementIterator
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
} else {
} else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
......@@ -242,7 +242,7 @@ public final class CollationElementIterator
buffer = makeReorderedBuffer(consonant, value, buffer, true);
value = buffer[0];
expIndex = 1;
} else {
} else if (consonant != NormalizerBase.DONE) {
text.previous();
}
}
......
......@@ -621,6 +621,8 @@ class RuleBasedBreakIterator extends BreakIterator {
return handleNext();
}
private int cachedLastKnownBreak = BreakIterator.DONE;
/**
* Advances the iterator backwards, to the last boundary preceding this one.
* @return The position of the last boundary position preceding this one.
......@@ -638,8 +640,16 @@ class RuleBasedBreakIterator extends BreakIterator {
// the current position), but not necessarily the last one before
// where we started
int start = current();
getPrevious();
int lastResult = handlePrevious();
int lastResult = cachedLastKnownBreak;
if (lastResult >= start || lastResult <= BreakIterator.DONE) {
getPrevious();
lastResult = handlePrevious();
} else {
//it might be better to check if handlePrevious() give us closer
//safe value but handlePrevious() is slow too
//So, this has to be done carefully
text.setIndex(lastResult);
}
int result = lastResult;
// iterate forward from the known break position until we pass our
......@@ -653,6 +663,7 @@ class RuleBasedBreakIterator extends BreakIterator {
// set the current iteration position to be the last break position
// before where we started, and then return that value
text.setIndex(lastResult);
cachedLastKnownBreak = lastResult;
return lastResult;
}
......@@ -757,7 +768,8 @@ class RuleBasedBreakIterator extends BreakIterator {
// then we can just use next() to get our return value
text.setIndex(offset);
if (offset == text.getBeginIndex()) {
return handleNext();
cachedLastKnownBreak = handleNext();
return cachedLastKnownBreak;
}
// otherwise, we have to sync up first. Use handlePrevious() to back
......@@ -767,10 +779,19 @@ class RuleBasedBreakIterator extends BreakIterator {
// position at or before our starting position. Advance forward
// from here until we've passed the starting position. The position
// we stop on will be the first break position after the specified one.
int result = handlePrevious();
int result = cachedLastKnownBreak;
if (result >= offset || result <= BreakIterator.DONE) {
result = handlePrevious();
} else {
//it might be better to check if handlePrevious() give us closer
//safe value but handlePrevious() is slow too
//So, this has to be done carefully
text.setIndex(result);
}
while (result != BreakIterator.DONE && result <= offset) {
result = handleNext();
}
cachedLastKnownBreak = result;
return result;
}
......@@ -865,6 +886,8 @@ class RuleBasedBreakIterator extends BreakIterator {
text = new SafeCharIterator(newText);
}
text.first();
cachedLastKnownBreak = BreakIterator.DONE;
}
......
......@@ -953,7 +953,7 @@ public class Date
* without affecting its internal state.
*/
static final long getMillisOf(Date date) {
if (date.cdate == null) {
if (date.cdate == null || date.cdate.isNormalized()) {
return date.fastTime;
}
BaseCalendar.Date d = (BaseCalendar.Date) date.cdate.clone();
......
......@@ -27,6 +27,7 @@ package javax.swing;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
......@@ -89,11 +90,7 @@ class MultiUIDefaults extends UIDefaults
@Override
public int size() {
int n = super.size();
for (UIDefaults table : tables) {
n += (table != null) ? table.size() : 0;
}
return n;
return entrySet().size();
}
@Override
......@@ -104,40 +101,26 @@ class MultiUIDefaults extends UIDefaults
@Override
public Enumeration<Object> keys()
{
Enumeration[] enums = new Enumeration[1 + tables.length];
enums[0] = super.keys();
for(int i = 0; i < tables.length; i++) {
UIDefaults table = tables[i];
if (table != null) {
enums[i + 1] = table.keys();
}
}
return new MultiUIDefaultsEnumerator(enums);
return new MultiUIDefaultsEnumerator(
MultiUIDefaultsEnumerator.Type.KEYS, entrySet());
}
@Override
public Enumeration<Object> elements()
{
Enumeration[] enums = new Enumeration[1 + tables.length];
enums[0] = super.elements();
for(int i = 0; i < tables.length; i++) {
UIDefaults table = tables[i];
if (table != null) {
enums[i + 1] = table.elements();
}
}
return new MultiUIDefaultsEnumerator(enums);
return new MultiUIDefaultsEnumerator(
MultiUIDefaultsEnumerator.Type.ELEMENTS, entrySet());
}
@Override
public Set<Entry<Object, Object>> entrySet() {
Set<Entry<Object, Object>> set = new HashSet<Entry<Object, Object>>();
if (tables == null) return set;
for (UIDefaults table : tables) {
if (table != null) {
set.addAll(table.entrySet());
for (int i = tables.length - 1; i >= 0; i--) {
if (tables[i] != null) {
set.addAll(tables[i].entrySet());
}
}
set.addAll(super.entrySet());
return set;
}
......@@ -152,50 +135,46 @@ class MultiUIDefaults extends UIDefaults
private static class MultiUIDefaultsEnumerator implements Enumeration<Object>
{
Enumeration[] enums;
int n = 0;
public static enum Type { KEYS, ELEMENTS };
private Iterator<Entry<Object, Object>> iterator;
private Type type;
MultiUIDefaultsEnumerator(Enumeration[] enums) {
this.enums = enums;
MultiUIDefaultsEnumerator(Type type, Set<Entry<Object, Object>> entries) {
this.type = type;
this.iterator = entries.iterator();
}
public boolean hasMoreElements() {
for(int i = n; i < enums.length; i++) {
Enumeration e = enums[i];
if ((e != null) && (e.hasMoreElements())) {
return true;
}
}
return false;
return iterator.hasNext();
}
public Object nextElement() {
for(; n < enums.length; n++) {
Enumeration e = enums[n];
if ((e != null) && (e.hasMoreElements())) {
return e.nextElement();
}
switch (type) {
case KEYS: return iterator.next().getKey();
case ELEMENTS: return iterator.next().getValue();
default: return null;
}
return null;
}
}
@Override
public Object remove(Object key)
{
Object value = super.remove(key);
if (value != null) {
return value;
}
for (UIDefaults table : tables) {
value = (table != null) ? table.remove(key) : null;
if (value != null) {
return value;
Object value = null;
for (int i = tables.length - 1; i >= 0; i--) {
if (tables[i] != null) {
Object v = tables[i].remove(key);
if (v != null) {
value = v;
}
}
}
Object v = super.remove(key);
if (v != null) {
value = v;
}
return null;
return value;
}
@Override
......
/*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -627,6 +627,69 @@ public class TransferHandler implements Serializable {
this(null);
}
/**
* image for the {@code startDrag} method
*
* @see java.awt.dnd.DragGestureEvent#startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl)
*/
private Image dragImage;
/**
* anchor offset for the {@code startDrag} method
*
* @see java.awt.dnd.DragGestureEvent#startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl)
*/
private Point dragImageOffset;
/**
* Sets the drag image parameter. The image has to be prepared
* for rendering by the moment of the call. The image is stored
* by reference because of some performance reasons.
*
* @param img an image to drag
*/
public void setDragImage(Image img) {
dragImage = img;
}
/**
* Returns the drag image. If there is no image to drag,
* the returned value is {@code null}.
*
* @return the reference to the drag image
*/
public Image getDragImage() {
return dragImage;
}
/**
* Sets an anchor offset for the image to drag.
* It can not be {@code null}.
*
* @param p a {@code Point} object that corresponds
* to coordinates of an anchor offset of the image
* relative to the upper left corner of the image
*/
public void setDragImageOffset(Point p) {
dragImageOffset = new Point(p);
}
/**
* Returns an anchor offset for the image to drag.
*
* @return a {@code Point} object that corresponds
* to coordinates of an anchor offset of the image
* relative to the upper left corner of the image.
* The point {@code (0,0)} returns by default.
*/
public Point getDragImageOffset() {
if (dragImageOffset == null) {
return new Point(0,0);
}
return new Point(dragImageOffset);
}
/**
* Causes the Swing drag support to be initiated. This is called by
* the various UI implementations in the <code>javax.swing.plaf.basic</code>
......@@ -1522,7 +1585,12 @@ public class TransferHandler implements Serializable {
scrolls = c.getAutoscrolls();
c.setAutoscrolls(false);
try {
dge.startDrag(null, t, this);
Image im = th.getDragImage();
if (im == null) {
dge.startDrag(null, t, this);
} else {
dge.startDrag(null, im, th.getDragImageOffset(), t, this);
}
return;
} catch (RuntimeException re) {
c.setAutoscrolls(scrolls);
......
......@@ -90,6 +90,10 @@ final class ${LAF_NAME}Defaults {
*/
private Map<String, Region> registeredRegions =
new HashMap<String, Region>();
private Map<JComponent, Map<Region, SynthStyle>> overridesCache =
new WeakHashMap<JComponent, Map<Region, SynthStyle>>();
/**
* Our fallback style to avoid NPEs if the proper style cannot be found in
* this class. Not sure if relying on DefaultSynthStyle is the best choice.
......@@ -251,7 +255,11 @@ ${UI_DEFAULT_INIT}
}
//return the style, if found, or the default style if not found
return foundStyle == null ? defaultStyle : foundStyle.getStyle(comp);
return foundStyle == null ? defaultStyle : foundStyle.getStyle(comp, r);
}
public void clearOverridesCache(JComponent c) {
overridesCache.remove(c);
}
/*
......@@ -457,15 +465,6 @@ ${UI_DEFAULT_INIT}
* Cached shared style.
*/
private NimbusStyle style;
/**
* A weakly referenced hash map such that if the reference JComponent
* key is garbage collected then the entry is removed from the map.
* This cache exists so that when a JComponent has nimbus overrides
* in its client map, a unique style will be created and returned
* for that JComponent instance, always. In such a situation each
* JComponent instance must have its own instance of NimbusStyle.
*/
private WeakHashMap<JComponent, WeakReference<NimbusStyle>> overridesCache;
/**
* Create a new LazyStyle.
......@@ -513,17 +512,21 @@ ${UI_DEFAULT_INIT}
* Gets the style. Creates it if necessary.
* @return the style
*/
SynthStyle getStyle(JComponent c) {
SynthStyle getStyle(JComponent c, Region r) {
// if the component has overrides, it gets its own unique style
// instead of the shared style.
if (c.getClientProperty("Nimbus.Overrides") != null) {
if (overridesCache == null)
overridesCache = new WeakHashMap<JComponent, WeakReference<NimbusStyle>>();
WeakReference<NimbusStyle> ref = overridesCache.get(c);
NimbusStyle s = ref == null ? null : ref.get();
Map<Region, SynthStyle> map = overridesCache.get(c);
SynthStyle s = null;
if (map == null) {
map = new HashMap<Region, SynthStyle>();
overridesCache.put(c, map);
} else {
s = map.get(r);
}
if (s == null) {
s = new NimbusStyle(prefix, c);
overridesCache.put(c, new WeakReference<NimbusStyle>(s));
map.put(r, s);
}
return s;
}
......
......@@ -280,11 +280,15 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
String eName = ev.getPropertyName();
// Always update when overrides or size variant change
if ("Nimbus.Overrides" == eName ||
// These properties affect style cached inside NimbusDefaults (6860433)
if ("name" == eName ||
"ancestor" == eName ||
"Nimbus.Overrides" == eName ||
"Nimbus.Overrides.InheritDefaults" == eName ||
"JComponent.sizeVariant" == eName) {
JComponent c = (JComponent) ev.getSource();
defaults.clearOverridesCache(c);
return true;
}
......
......@@ -237,7 +237,16 @@ public class SynthButtonUI extends BasicButtonUI implements
// ********************************
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -250,7 +259,13 @@ public class SynthButtonUI extends BasicButtonUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -264,7 +279,8 @@ public class SynthButtonUI extends BasicButtonUI implements
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
AbstractButton b = (AbstractButton)context.getComponent();
......
......@@ -137,7 +137,16 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -151,7 +160,13 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -166,7 +181,8 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
* This implementation does not perform any actions.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -305,7 +305,16 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
// begin ComponentUI Implementation
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -319,7 +328,13 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -333,7 +348,8 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
hasFocus = comboBox.hasFocus();
......
......@@ -152,7 +152,16 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -166,7 +175,13 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -180,7 +195,8 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -439,7 +439,16 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -453,7 +462,13 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -467,7 +482,8 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -148,7 +148,16 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -164,7 +173,8 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
......
......@@ -194,7 +194,16 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -208,7 +217,13 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -222,7 +237,8 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -156,12 +156,16 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
}
/**
* Notifies this UI delegate that it's time to paint the specified
* component. This method is invoked by <code>JComponent</code>
* when the specified component is being painted.
*/
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -175,7 +179,13 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -189,7 +199,8 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JLabel label = (JLabel)context.getComponent();
......
......@@ -57,7 +57,16 @@ public class SynthListUI extends BasicListUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint
*/
@Override
public void update(Graphics g, JComponent c) {
......
......@@ -125,7 +125,16 @@ public class SynthMenuBarUI extends BasicMenuBarUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -139,7 +148,13 @@ public class SynthMenuBarUI extends BasicMenuBarUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -153,7 +168,8 @@ public class SynthMenuBarUI extends BasicMenuBarUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -227,7 +227,16 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -240,7 +249,13 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -254,7 +269,8 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem,
......
......@@ -227,7 +227,16 @@ public class SynthMenuUI extends BasicMenuUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -241,7 +250,13 @@ public class SynthMenuUI extends BasicMenuUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -255,7 +270,8 @@ public class SynthMenuUI extends BasicMenuUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem,
......
......@@ -149,7 +149,16 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -163,7 +172,13 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -177,7 +192,8 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -136,7 +136,16 @@ public class SynthPanelUI extends BasicPanelUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -150,7 +159,13 @@ public class SynthPanelUI extends BasicPanelUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -164,7 +179,8 @@ public class SynthPanelUI extends BasicPanelUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
// do actual painting
......
......@@ -132,7 +132,16 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -146,7 +155,13 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -160,7 +175,8 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -193,7 +193,16 @@ public class SynthProgressBarUI extends BasicProgressBarUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -208,7 +217,13 @@ public class SynthProgressBarUI extends BasicProgressBarUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -222,7 +237,8 @@ public class SynthProgressBarUI extends BasicProgressBarUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JProgressBar pBar = (JProgressBar)context.getComponent();
......
......@@ -102,7 +102,16 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -116,7 +125,13 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -130,7 +145,8 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -222,7 +222,16 @@ public class SynthScrollBarUI extends BasicScrollBarUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -237,7 +246,13 @@ public class SynthScrollBarUI extends BasicScrollBarUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -251,7 +266,8 @@ public class SynthScrollBarUI extends BasicScrollBarUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
SynthContext subcontext = getContext(scrollbar,
......
......@@ -64,7 +64,16 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -78,7 +87,13 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -92,7 +107,8 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Border vpBorder = scrollpane.getViewportBorder();
......
......@@ -135,7 +135,16 @@ public class SynthSeparatorUI extends SeparatorUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -151,7 +160,13 @@ public class SynthSeparatorUI extends SeparatorUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -165,7 +180,8 @@ public class SynthSeparatorUI extends SeparatorUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JSeparator separator = (JSeparator)context.getComponent();
......
......@@ -788,7 +788,16 @@ public class SynthSliderUI extends BasicSliderUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -802,7 +811,13 @@ public class SynthSliderUI extends BasicSliderUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -815,7 +830,8 @@ public class SynthSliderUI extends BasicSliderUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
recalculateIfInsetsChanged();
......
......@@ -283,7 +283,16 @@ public class SynthSpinnerUI extends BasicSpinnerUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -298,7 +307,13 @@ public class SynthSpinnerUI extends BasicSpinnerUI
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -312,7 +327,8 @@ public class SynthSpinnerUI extends BasicSpinnerUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -269,7 +269,16 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -283,7 +292,13 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -297,7 +312,8 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
// This is done to update package private variables in
......
......@@ -92,8 +92,8 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
private SynthStyle tabAreaStyle;
private SynthStyle tabContentStyle;
private Rectangle textRect;
private Rectangle iconRect;
private Rectangle textRect = new Rectangle();
private Rectangle iconRect = new Rectangle();
private Rectangle tabAreaBounds = new Rectangle();
......@@ -115,11 +115,6 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
return new SynthTabbedPaneUI();
}
private SynthTabbedPaneUI() {
textRect = new Rectangle();
iconRect = new Rectangle();
}
private boolean scrollableTabLayoutEnabled() {
return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT);
}
......@@ -362,7 +357,16 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -409,7 +413,13 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -423,7 +433,8 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
int selectedIndex = tabPane.getSelectedIndex();
......
......@@ -123,7 +123,16 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -137,7 +146,13 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -151,7 +166,8 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, context.getComponent());
......
......@@ -256,7 +256,16 @@ public class SynthTableUI extends BasicTableUI
//
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -279,7 +288,13 @@ public class SynthTableUI extends BasicTableUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -293,7 +308,8 @@ public class SynthTableUI extends BasicTableUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
......
......@@ -123,7 +123,16 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -140,7 +149,8 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
......
......@@ -161,7 +161,16 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -182,7 +191,8 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
* model to potentially be updated asynchronously.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent());
......
......@@ -198,7 +198,16 @@ public class SynthToolBarUI extends BasicToolBarUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -213,7 +222,13 @@ public class SynthToolBarUI extends BasicToolBarUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -258,7 +273,8 @@ public class SynthToolBarUI extends BasicToolBarUI
* Paints the toolbar.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
if (handleIcon != null && toolBar.isFloatable()) {
......
......@@ -121,7 +121,16 @@ public class SynthToolTipUI extends BasicToolTipUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -144,7 +153,13 @@ public class SynthToolTipUI extends BasicToolTipUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -158,7 +173,8 @@ public class SynthToolTipUI extends BasicToolTipUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
JToolTip tip = (JToolTip)context.getComponent();
......
......@@ -250,7 +250,16 @@ public class SynthTreeUI extends BasicTreeUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -273,7 +282,13 @@ public class SynthTreeUI extends BasicTreeUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -287,7 +302,8 @@ public class SynthTreeUI extends BasicTreeUI
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
paintContext = context;
......
......@@ -150,7 +150,16 @@ public class SynthViewportUI extends ViewportUI
}
/**
* @inheritDoc
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void update(Graphics g, JComponent c) {
......@@ -174,7 +183,13 @@ public class SynthViewportUI extends ViewportUI
}
/**
* @inheritDoc
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
@Override
public void paint(Graphics g, JComponent c) {
......@@ -188,7 +203,8 @@ public class SynthViewportUI extends ViewportUI
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
}
......
......@@ -13,7 +13,7 @@ public class ExtendedKeyCodes {
*/
// Keycodes declared in KeyEvent.java with corresponding Unicode values.
private final static HashMap<Integer, Integer> regularKeyCodesMap =
new HashMap<Integer,Integer>(122, 1.0f);
new HashMap<Integer,Integer>(83, 1.0f);
// Keycodes derived from Unicode values. Here should be collected codes
// for characters appearing on the primary layer of at least one
......@@ -22,7 +22,6 @@ public class ExtendedKeyCodes {
private final static HashSet<Integer> extendedKeyCodesSet =
new HashSet<Integer>(501, 1.0f);
final public static int getExtendedKeyCodeForChar( int c ) {
int rc = KeyEvent.VK_UNDEFINED;
int uc = Character.toUpperCase( c );
int lc = Character.toLowerCase( c );
if (regularKeyCodesMap.containsKey( c )) {
......@@ -38,22 +37,25 @@ public class ExtendedKeyCodes {
}else if (extendedKeyCodesSet.contains( lc )) {
return lc;
}
return rc;
return KeyEvent.VK_UNDEFINED;
}
static {
regularKeyCodesMap.put(0x0a, KeyEvent.VK_ENTER);
regularKeyCodesMap.put(0x08, KeyEvent.VK_BACK_SPACE);
regularKeyCodesMap.put(0x09, KeyEvent.VK_TAB);
regularKeyCodesMap.put(0x0a, KeyEvent.VK_ENTER);
regularKeyCodesMap.put(0x1B, KeyEvent.VK_ESCAPE);
regularKeyCodesMap.put(0x20AC, KeyEvent.VK_EURO_SIGN);
regularKeyCodesMap.put(0x20, KeyEvent.VK_SPACE);
regularKeyCodesMap.put(0x21, KeyEvent.VK_PAGE_UP);
regularKeyCodesMap.put(0x22, KeyEvent.VK_PAGE_DOWN);
regularKeyCodesMap.put(0x23, KeyEvent.VK_END);
regularKeyCodesMap.put(0x24, KeyEvent.VK_HOME);
regularKeyCodesMap.put(0x25, KeyEvent.VK_LEFT);
regularKeyCodesMap.put(0x26, KeyEvent.VK_UP);
regularKeyCodesMap.put(0x27, KeyEvent.VK_RIGHT);
regularKeyCodesMap.put(0x28, KeyEvent.VK_DOWN);
regularKeyCodesMap.put(0x21, KeyEvent.VK_EXCLAMATION_MARK);
regularKeyCodesMap.put(0x22, KeyEvent.VK_QUOTEDBL);
regularKeyCodesMap.put(0x23, KeyEvent.VK_NUMBER_SIGN);
regularKeyCodesMap.put(0x24, KeyEvent.VK_DOLLAR);
regularKeyCodesMap.put(0x26, KeyEvent.VK_AMPERSAND);
regularKeyCodesMap.put(0x27, KeyEvent.VK_QUOTE);
regularKeyCodesMap.put(0x28, KeyEvent.VK_LEFT_PARENTHESIS);
regularKeyCodesMap.put(0x29, KeyEvent.VK_RIGHT_PARENTHESIS);
regularKeyCodesMap.put(0x2A, KeyEvent.VK_ASTERISK);
regularKeyCodesMap.put(0x2B, KeyEvent.VK_PLUS);
regularKeyCodesMap.put(0x2C, KeyEvent.VK_COMMA);
regularKeyCodesMap.put(0x2D, KeyEvent.VK_MINUS);
regularKeyCodesMap.put(0x2E, KeyEvent.VK_PERIOD);
......@@ -68,102 +70,59 @@ public class ExtendedKeyCodes {
regularKeyCodesMap.put(0x37, KeyEvent.VK_7);
regularKeyCodesMap.put(0x38, KeyEvent.VK_8);
regularKeyCodesMap.put(0x39, KeyEvent.VK_9);
regularKeyCodesMap.put(0x3A, KeyEvent.VK_COLON);
regularKeyCodesMap.put(0x3B, KeyEvent.VK_SEMICOLON);
regularKeyCodesMap.put(0x3C, KeyEvent.VK_LESS);
regularKeyCodesMap.put(0x3D, KeyEvent.VK_EQUALS);
regularKeyCodesMap.put(0x3E, KeyEvent.VK_GREATER);
regularKeyCodesMap.put(0x40, KeyEvent.VK_AT);
regularKeyCodesMap.put(0x41, KeyEvent.VK_A);
regularKeyCodesMap.put(0x61, KeyEvent.VK_A);
regularKeyCodesMap.put(0x42, KeyEvent.VK_B);
regularKeyCodesMap.put(0x62, KeyEvent.VK_B);
regularKeyCodesMap.put(0x43, KeyEvent.VK_C);
regularKeyCodesMap.put(0x63, KeyEvent.VK_C);
regularKeyCodesMap.put(0x44, KeyEvent.VK_D);
regularKeyCodesMap.put(0x64, KeyEvent.VK_D);
regularKeyCodesMap.put(0x45, KeyEvent.VK_E);
regularKeyCodesMap.put(0x65, KeyEvent.VK_E);
regularKeyCodesMap.put(0x46, KeyEvent.VK_F);
regularKeyCodesMap.put(0x66, KeyEvent.VK_F);
regularKeyCodesMap.put(0x47, KeyEvent.VK_G);
regularKeyCodesMap.put(0x67, KeyEvent.VK_G);
regularKeyCodesMap.put(0x48, KeyEvent.VK_H);
regularKeyCodesMap.put(0x68, KeyEvent.VK_H);
regularKeyCodesMap.put(0x49, KeyEvent.VK_I);
regularKeyCodesMap.put(0x69, KeyEvent.VK_I);
regularKeyCodesMap.put(0x4A, KeyEvent.VK_J);
regularKeyCodesMap.put(0x6A, KeyEvent.VK_J);
regularKeyCodesMap.put(0x4B, KeyEvent.VK_K);
regularKeyCodesMap.put(0x6B, KeyEvent.VK_K);
regularKeyCodesMap.put(0x4C, KeyEvent.VK_L);
regularKeyCodesMap.put(0x6C, KeyEvent.VK_L);
regularKeyCodesMap.put(0x4D, KeyEvent.VK_M);
regularKeyCodesMap.put(0x6D, KeyEvent.VK_M);
regularKeyCodesMap.put(0x4E, KeyEvent.VK_N);
regularKeyCodesMap.put(0x6E, KeyEvent.VK_N);
regularKeyCodesMap.put(0x4F, KeyEvent.VK_O);
regularKeyCodesMap.put(0x6F, KeyEvent.VK_O);
regularKeyCodesMap.put(0x50, KeyEvent.VK_P);
regularKeyCodesMap.put(0x70, KeyEvent.VK_P);
regularKeyCodesMap.put(0x51, KeyEvent.VK_Q);
regularKeyCodesMap.put(0x71, KeyEvent.VK_Q);
regularKeyCodesMap.put(0x52, KeyEvent.VK_R);
regularKeyCodesMap.put(0x72, KeyEvent.VK_R);
regularKeyCodesMap.put(0x53, KeyEvent.VK_S);
regularKeyCodesMap.put(0x73, KeyEvent.VK_S);
regularKeyCodesMap.put(0x54, KeyEvent.VK_T);
regularKeyCodesMap.put(0x74, KeyEvent.VK_T);
regularKeyCodesMap.put(0x55, KeyEvent.VK_U);
regularKeyCodesMap.put(0x75, KeyEvent.VK_U);
regularKeyCodesMap.put(0x56, KeyEvent.VK_V);
regularKeyCodesMap.put(0x76, KeyEvent.VK_V);
regularKeyCodesMap.put(0x57, KeyEvent.VK_W);
regularKeyCodesMap.put(0x77, KeyEvent.VK_W);
regularKeyCodesMap.put(0x58, KeyEvent.VK_X);
regularKeyCodesMap.put(0x78, KeyEvent.VK_X);
regularKeyCodesMap.put(0x59, KeyEvent.VK_Y);
regularKeyCodesMap.put(0x79, KeyEvent.VK_Y);
regularKeyCodesMap.put(0x5A, KeyEvent.VK_Z);
regularKeyCodesMap.put(0x7A, KeyEvent.VK_Z);
regularKeyCodesMap.put(0x5B, KeyEvent.VK_OPEN_BRACKET);
regularKeyCodesMap.put(0x5C, KeyEvent.VK_BACK_SLASH);
regularKeyCodesMap.put(0x5D, KeyEvent.VK_CLOSE_BRACKET);
// regularKeyCodesMap.put(0x60, KeyEvent.VK_NUMPAD0);
// regularKeyCodesMap.put(0x61, KeyEvent.VK_NUMPAD1);
// regularKeyCodesMap.put(0x62, KeyEvent.VK_NUMPAD2);
// regularKeyCodesMap.put(0x63, KeyEvent.VK_NUMPAD3);
// regularKeyCodesMap.put(0x64, KeyEvent.VK_NUMPAD4);
// regularKeyCodesMap.put(0x65, KeyEvent.VK_NUMPAD5);
// regularKeyCodesMap.put(0x66, KeyEvent.VK_NUMPAD6);
// regularKeyCodesMap.put(0x67, KeyEvent.VK_NUMPAD7);
// regularKeyCodesMap.put(0x68, KeyEvent.VK_NUMPAD8);
// regularKeyCodesMap.put(0x69, KeyEvent.VK_NUMPAD9);
regularKeyCodesMap.put(0x6A, KeyEvent.VK_MULTIPLY);
regularKeyCodesMap.put(0x6B, KeyEvent.VK_ADD);
regularKeyCodesMap.put(0x6C, KeyEvent.VK_SEPARATER);
regularKeyCodesMap.put(0x6D, KeyEvent.VK_SUBTRACT);
regularKeyCodesMap.put(0x6E, KeyEvent.VK_DECIMAL);
regularKeyCodesMap.put(0x6F, KeyEvent.VK_DIVIDE);
regularKeyCodesMap.put(0x7F, KeyEvent.VK_DELETE);
regularKeyCodesMap.put(0xC0, KeyEvent.VK_BACK_QUOTE);
regularKeyCodesMap.put(0xDE, KeyEvent.VK_QUOTE);
regularKeyCodesMap.put(0x26, KeyEvent.VK_AMPERSAND);
regularKeyCodesMap.put(0x2A, KeyEvent.VK_ASTERISK);
regularKeyCodesMap.put(0x22, KeyEvent.VK_QUOTEDBL);
regularKeyCodesMap.put(0x3C, KeyEvent.VK_LESS);
regularKeyCodesMap.put(0x3E, KeyEvent.VK_GREATER);
regularKeyCodesMap.put(0x5E, KeyEvent.VK_CIRCUMFLEX);
regularKeyCodesMap.put(0x5F, KeyEvent.VK_UNDERSCORE);
regularKeyCodesMap.put(0x60, KeyEvent.VK_BACK_QUOTE);
regularKeyCodesMap.put(0x70, KeyEvent.VK_P);
regularKeyCodesMap.put(0x71, KeyEvent.VK_Q);
regularKeyCodesMap.put(0x72, KeyEvent.VK_R);
regularKeyCodesMap.put(0x73, KeyEvent.VK_S);
regularKeyCodesMap.put(0x74, KeyEvent.VK_T);
regularKeyCodesMap.put(0x75, KeyEvent.VK_U);
regularKeyCodesMap.put(0x76, KeyEvent.VK_V);
regularKeyCodesMap.put(0x77, KeyEvent.VK_W);
regularKeyCodesMap.put(0x78, KeyEvent.VK_X);
regularKeyCodesMap.put(0x79, KeyEvent.VK_Y);
regularKeyCodesMap.put(0x7A, KeyEvent.VK_Z);
regularKeyCodesMap.put(0x7B, KeyEvent.VK_BRACELEFT);
regularKeyCodesMap.put(0x7D, KeyEvent.VK_BRACERIGHT);
regularKeyCodesMap.put(0x40, KeyEvent.VK_AT);
regularKeyCodesMap.put(0x3A, KeyEvent.VK_COLON);
regularKeyCodesMap.put(0x5E, KeyEvent.VK_CIRCUMFLEX);
regularKeyCodesMap.put(0x24, KeyEvent.VK_DOLLAR);
regularKeyCodesMap.put(0x20AC, KeyEvent.VK_EURO_SIGN);
regularKeyCodesMap.put(0x21, KeyEvent.VK_EXCLAMATION_MARK);
regularKeyCodesMap.put(0x7F, KeyEvent.VK_DELETE);
regularKeyCodesMap.put(0xA1, KeyEvent.VK_INVERTED_EXCLAMATION_MARK);
regularKeyCodesMap.put(0x28, KeyEvent.VK_LEFT_PARENTHESIS);
regularKeyCodesMap.put(0x23, KeyEvent.VK_NUMBER_SIGN);
regularKeyCodesMap.put(0x2B, KeyEvent.VK_PLUS);
regularKeyCodesMap.put(0x29, KeyEvent.VK_RIGHT_PARENTHESIS);
regularKeyCodesMap.put(0x5F, KeyEvent.VK_UNDERSCORE);
extendedKeyCodesSet.add(0x01000000+0x0060);
extendedKeyCodesSet.add(0x01000000+0x007C);
......
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -67,6 +67,8 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
private DragGestureEvent trigger;
private Component component;
private Cursor cursor;
private Image dragImage;
private Point dragImageOffset;
private long nativeCtxt;
private DragSourceContext dragSourceContext;
private int sourceActions;
......@@ -120,6 +122,8 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
dragSourceContext = dsc;
cursor = c;
sourceActions = getDragSourceContext().getSourceActions();
dragImage = di;
dragImageOffset = p;
Transferable transferable = getDragSourceContext().getTransferable();
SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable
......@@ -168,6 +172,31 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
return cursor;
}
/**
* Returns the drag image. If there is no image to drag,
* the returned value is {@code null}
*
* @return the reference to the drag image
*/
public Image getDragImage() {
return dragImage;
}
/**
* Returns an anchor offset for the image to drag.
*
* @return a {@code Point} object that corresponds
* to coordinates of an anchor offset of the image
* relative to the upper left corner of the image.
* The point {@code (0,0)} returns by default.
*/
public Point getDragImageOffset() {
if (dragImageOffset == null) {
return new Point(0,0);
}
return new Point(dragImageOffset);
}
/**
* downcall into native code
*/
......@@ -317,6 +346,8 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
startSecondaryEventLoop();
setNativeContext(0);
dragImage = null;
dragImageOffset = null;
}
public static void setDragDropInProgress(boolean b)
......
......@@ -68,38 +68,34 @@ public final class FontManagerFactory {
return instance;
}
String fmClassName = AccessController.doPrivileged(
new GetPropertyAction("sun.font.fontmanager",
DEFAULT_CLASS));
try {
@SuppressWarnings("unchecked")
ClassLoader cl = (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return ClassLoader.getSystemClassLoader();
}
});
@SuppressWarnings("unchecked")
Class fmClass = Class.forName(fmClassName, true, cl);
instance = (FontManager) fmClass.newInstance();
} catch (ClassNotFoundException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
} catch (InstantiationException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
} catch (IllegalAccessException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
}
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
String fmClassName =
System.getProperty("sun.font.fontmanager",
DEFAULT_CLASS);
ClassLoader cl = ClassLoader.getSystemClassLoader();
Class fmClass = Class.forName(fmClassName, true, cl);
instance = (FontManager) fmClass.newInstance();
} catch (ClassNotFoundException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
} catch (InstantiationException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
} catch (IllegalAccessException ex) {
InternalError err = new InternalError();
err.initCause(ex);
throw err;
}
return null;
}
});
return instance;
}
......
......@@ -32,9 +32,9 @@ import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.swing.plaf.FontUIResource;
import sun.security.action.GetPropertyAction;
import sun.util.logging.PlatformLogger;
/**
......@@ -42,79 +42,82 @@ import sun.util.logging.PlatformLogger;
*/
public final class FontUtilities {
public static final boolean isSolaris;
public static boolean isSolaris;
public static final boolean isLinux;
public static boolean isLinux;
public static final boolean isSolaris8;
public static boolean isSolaris8;
public static final boolean isSolaris9;
public static boolean isSolaris9;
public static final boolean isOpenSolaris;
public static boolean isOpenSolaris;
public static final boolean useT2K;
public static boolean useT2K;
public static final boolean isWindows;
public static boolean isWindows;
public static final boolean isOpenJDK;
public static boolean isOpenJDK;
static final String LUCIDA_FILE_NAME = "LucidaSansRegular.ttf";
// This static initializer block figures out the OS constants.
static {
String osName = AccessController.doPrivileged(
new GetPropertyAction("os.name", "unknownOS"));
isSolaris = osName.startsWith("SunOS");
AccessController.doPrivileged(new PrivilegedAction () {
public Object run() {
String osName = System.getProperty("os.name", "unknownOS");
isSolaris = osName.startsWith("SunOS");
isLinux = osName.startsWith("Linux");
isLinux = osName.startsWith("Linux");
String t2kStr = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.font.scaler"));
if (t2kStr != null) {
useT2K = "t2k".equals(t2kStr);
} else {
useT2K = false;
}
if (isSolaris) {
String version = AccessController.doPrivileged(
new GetPropertyAction("os.version", "0.0"));
isSolaris8 = version.startsWith("5.8");
isSolaris9 = version.startsWith("5.9");
float ver = Float.parseFloat(version);
if (ver > 5.10f) {
File f = new File("/etc/release");
String line = null;
try {
FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(
fis, "ISO-8859-1");
BufferedReader br = new BufferedReader(isr);
line = br.readLine();
fis.close();
} catch (Exception ex) {
// Nothing to do here.
String t2kStr = System.getProperty("sun.java2d.font.scaler");
if (t2kStr != null) {
useT2K = "t2k".equals(t2kStr);
} else {
useT2K = false;
}
if (line != null && line.indexOf("OpenSolaris") >= 0) {
isOpenSolaris = true;
if (isSolaris) {
String version = System.getProperty("os.version", "0.0");
isSolaris8 = version.startsWith("5.8");
isSolaris9 = version.startsWith("5.9");
float ver = Float.parseFloat(version);
if (ver > 5.10f) {
File f = new File("/etc/release");
String line = null;
try {
FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(
fis, "ISO-8859-1");
BufferedReader br = new BufferedReader(isr);
line = br.readLine();
fis.close();
} catch (Exception ex) {
// Nothing to do here.
}
if (line != null && line.indexOf("OpenSolaris") >= 0) {
isOpenSolaris = true;
} else {
isOpenSolaris = false;
}
} else {
isOpenSolaris = false;
}
} else {
isSolaris8 = false;
isSolaris9 = false;
isOpenSolaris = false;
}
} else {
isOpenSolaris= false;
isWindows = osName.startsWith("Windows");
String jreLibDirName = System.getProperty("java.home", "")
+ File.separator + "lib";
String jreFontDirName =
jreLibDirName + File.separator + "fonts";
File lucidaFile = new File(jreFontDirName + File.separator
+ LUCIDA_FILE_NAME);
isOpenJDK = !lucidaFile.exists();
return null;
}
} else {
isSolaris8 = false;
isSolaris9 = false;
isOpenSolaris = false;
}
isWindows = osName.startsWith("Windows");
String jreLibDirName = AccessController.doPrivileged(
new GetPropertyAction("java.home","")) + File.separator + "lib";
String jreFontDirName = jreLibDirName + File.separator + "fonts";
File lucidaFile =
new File(jreFontDirName + File.separator + LUCIDA_FILE_NAME);
isOpenJDK = !lucidaFile.exists();
});
}
/**
......
......@@ -535,6 +535,10 @@ public class PlatformLogger {
}
void doLog(int level, String msg, Object... params) {
int paramsNumber = (params != null) ? params.length : 0;
for (int i = 0; i < paramsNumber; i++) {
params[i] = String.valueOf(params[i]);
}
LoggingSupport.log(javaLogger, levelObjects.get(level), msg, params);
}
......
......@@ -189,21 +189,22 @@ public abstract class InfoWindow extends Window {
* WARNING: this method is executed on Toolkit thread!
*/
private void display() {
String tooltipString = liveArguments.getTooltipString();
if (tooltipString == null) {
return;
} else if (tooltipString.length() > TOOLTIP_MAX_LENGTH) {
textLabel.setText(tooltipString.substring(0, TOOLTIP_MAX_LENGTH));
} else {
textLabel.setText(tooltipString);
}
// Execute on EDT to avoid deadlock (see 6280857).
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() {
if (liveArguments.isDisposed()) {
return;
}
String tooltipString = liveArguments.getTooltipString();
if (tooltipString == null) {
return;
} else if (tooltipString.length() > TOOLTIP_MAX_LENGTH) {
textLabel.setText(tooltipString.substring(0, TOOLTIP_MAX_LENGTH));
} else {
textLabel.setText(tooltipString);
}
Point pointer = (Point)AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
if (!isPointerOverTrayIcon(liveArguments.getBounds())) {
......
......@@ -2144,9 +2144,11 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
// Outside this toplevel hierarchy
// According to the specification of UngrabEvent, post it
// when press occurs outside of the window and not on its owned windows
grabLog.fine("Generating UngrabEvent on {0} because not inside of shell", this);
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
return;
if (xbe.get_type() == XConstants.ButtonPress) {
grabLog.fine("Generating UngrabEvent on {0} because not inside of shell", this);
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
return;
}
}
// First, get the toplevel
XWindowPeer toplevel = target.getToplevelXWindow();
......
/*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -56,6 +56,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.File;
import java.net.URL;
......@@ -130,6 +131,10 @@ public class WDataTransferer extends DataTransferer {
public static final long CF_PNG = registerClipboardFormat("PNG");
public static final long CF_JFIF = registerClipboardFormat("JFIF");
public static final long CF_FILEGROUPDESCRIPTORW = registerClipboardFormat("FileGroupDescriptorW");
public static final long CF_FILEGROUPDESCRIPTORA = registerClipboardFormat("FileGroupDescriptor");
//CF_FILECONTENTS supported as mandatory associated clipboard
private static final Long L_CF_LOCALE = (Long)
predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]);
......@@ -203,6 +208,30 @@ public class WDataTransferer extends DataTransferer {
str = new HTMLCodec(str, EHTMLReadMode.HTML_READ_SELECTION);
}
if (format == CF_FILEGROUPDESCRIPTORA || format == CF_FILEGROUPDESCRIPTORW) {
if (null != str ) {
str.close();
}
if (bytes == null || !DataFlavor.javaFileListFlavor.equals(flavor)) {
throw new IOException("data translation failed");
}
String st = new String(bytes, 0, bytes.length, "UTF-16LE");
String[] filenames = st.split("\0");
if( 0 == filenames.length ){
return null;
}
// Convert the strings to File objects
File[] files = new File[filenames.length];
for (int i = 0; i < filenames.length; ++i) {
files[i] = new File(filenames[i]);
//They are temp-files from memory Stream, so they have to be removed on exit
files[i].deleteOnExit();
}
// Turn the list of Files into a List and return
return Arrays.asList(files);
}
if (format == CFSTR_INETURL &&
URL.class.equals(flavor.getRepresentationClass()))
{
......@@ -233,7 +262,7 @@ public class WDataTransferer extends DataTransferer {
}
public boolean isFileFormat(long format) {
return format == CF_HDROP;
return format == CF_HDROP || format == CF_FILEGROUPDESCRIPTORA || format == CF_FILEGROUPDESCRIPTORW;
}
protected Long getFormatForNativeAsLong(String str) {
......
/*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -27,6 +27,10 @@ package sun.awt.windows;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.datatransfer.Transferable;
......@@ -88,11 +92,56 @@ final class WDragSourceContextPeer extends SunDragSourceContextPeer {
throw new InvalidDnDOperationException("failed to create native peer");
}
setNativeContext(nativeCtxtLocal);
int[] imageData = null;
Point op = null;
Image im = getDragImage();
int imageWidth = -1;
int imageHeight = -1;
if (im != null) {
//image is ready (partial images are ok)
try{
imageWidth = im.getWidth(null);
imageHeight = im.getHeight(null);
if (imageWidth < 0 || imageHeight < 0) {
throw new InvalidDnDOperationException("drag image is not ready");
}
//We could get an exception from user code here.
//"im" and "dragImageOffset" are user-defined objects
op = getDragImageOffset(); //op could not be null here
BufferedImage bi = new BufferedImage(
imageWidth,
imageHeight,
BufferedImage.TYPE_INT_ARGB);
bi.getGraphics().drawImage(im, 0, 0, null);
//we can get out-of-memory here
imageData = ((DataBufferInt)bi.getData().getDataBuffer()).getData();
} catch (Throwable ex) {
throw new InvalidDnDOperationException("drag image creation problem: " + ex.getMessage());
}
}
//We shouldn't have user-level exceptions since now.
//Any exception leads to corrupted D'n'D state.
setNativeContext(nativeCtxtLocal);
WDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(trans);
doDragDrop(getNativeContext(), getCursor());
if (imageData != null) {
doDragDrop(
getNativeContext(),
getCursor(),
imageData,
imageWidth, imageHeight,
op.x, op.y);
} else {
doDragDrop(
getNativeContext(),
getCursor(),
null,
-1, -1,
0, 0);
}
}
/**
......@@ -110,7 +159,12 @@ final class WDragSourceContextPeer extends SunDragSourceContextPeer {
* downcall into native code
*/
native void doDragDrop(long nativeCtxt, Cursor cursor);
native void doDragDrop(
long nativeCtxt,
Cursor cursor,
int[] imageData,
int imgWidth, int imgHight,
int offsetX, int offsetY);
protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
......
......@@ -895,6 +895,8 @@ public class WToolkit extends SunToolkit implements Runnable {
Integer.valueOf(50));
desktopProperties.put("DnD.Autoscroll.interval",
Integer.valueOf(50));
desktopProperties.put("DnD.isDragImageSupported",
Boolean.TRUE);
desktopProperties.put("Shell.shellFolderManager",
"sun.awt.shell.Win32ShellFolderManager2");
}
......
......@@ -73,3 +73,5 @@ LOCALE=application/x-java-text-encoding;class="[B"
UniformResourceLocator=application/x-java-url;class=java.net.URL
UniformResourceLocator=text/uri-list;eoln="\r\n";terminators=1
UniformResourceLocator=text/plain;eoln="\r\n";terminators=1
FileGroupDescriptorW=application/x-java-file-list;class=java.util.List
FileGroupDescriptor=application/x-java-file-list;class=java.util.List
/*
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2009 Sun Microsystems, Inc. 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
......@@ -233,4 +233,122 @@ extern JavaVM *jvm;
#define CHECK_ISNOT_TOOLKIT_THREAD()
#endif
struct EnvHolder
{
JavaVM *m_pVM;
JNIEnv *m_env;
bool m_isOwner;
EnvHolder(
JavaVM *pVM,
LPCSTR name = "COM holder",
jint ver = JNI_VERSION_1_2)
: m_pVM(pVM),
m_env((JNIEnv *)JNU_GetEnv(pVM, ver)),
m_isOwner(false)
{
if (NULL == m_env) {
JavaVMAttachArgs attachArgs;
attachArgs.version = ver;
attachArgs.name = const_cast<char *>(name);
attachArgs.group = NULL;
jint status = m_pVM->AttachCurrentThread(
(void**)&m_env,
&attachArgs);
m_isOwner = (NULL!=m_env);
}
}
~EnvHolder() {
if (m_isOwner) {
m_pVM->DetachCurrentThread();
}
}
operator bool() const { return NULL!=m_env; }
bool operator !() const { return NULL==m_env; }
operator JNIEnv*() const { return m_env; }
JNIEnv* operator ->() const { return m_env; }
};
template <class T>
class JLocalRef {
JNIEnv* m_env;
T m_localJRef;
public:
JLocalRef(JNIEnv* env, T localJRef = NULL)
: m_env(env),
m_localJRef(localJRef)
{}
T Detach() {
T ret = m_localJRef;
m_localJRef = NULL;
return ret;
}
void Attach(T newValue) {
if (m_localJRef) {
m_env->DeleteLocalRef((jobject)m_localJRef);
}
m_localJRef = newValue;
}
operator T() { return m_localJRef; }
operator bool() { return NULL!=m_localJRef; }
bool operator !() { return NULL==m_localJRef; }
~JLocalRef() {
if (m_localJRef) {
m_env->DeleteLocalRef((jobject)m_localJRef);
}
}
};
typedef JLocalRef<jobject> JLObject;
typedef JLocalRef<jstring> JLString;
typedef JLocalRef<jclass> JLClass;
/*
* Class to encapsulate the extraction of the java string contents
* into a buffer and the cleanup of the buffer
*/
class JavaStringBuffer
{
protected:
LPWSTR m_pStr;
jsize m_dwSize;
public:
JavaStringBuffer(jsize cbTCharCount) {
m_dwSize = cbTCharCount;
m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
}
JavaStringBuffer(JNIEnv *env, jstring text) {
if (NULL == text) {
m_pStr = L"";
m_dwSize = 0;
} else {
m_dwSize = env->GetStringLength(text);
m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
env->GetStringRegion(text, 0, m_dwSize, reinterpret_cast<jchar *>(m_pStr));
m_pStr[m_dwSize] = 0;
}
}
~JavaStringBuffer() {
free(m_pStr);
}
void Resize(jsize cbTCharCount) {
m_dwSize = cbTCharCount;
m_pStr = (LPWSTR)safe_Realloc(m_pStr, (m_dwSize+1)*sizeof(WCHAR) );
}
//we are in UNICODE now, so LPWSTR:=:LPTSTR
operator LPWSTR() { return m_pStr; }
operator LPARAM() { return (LPARAM)m_pStr; }
void *GetData() { return (void *)m_pStr; }
jsize GetSize() { return m_dwSize; }
};
#endif /* _AWT_H_ */
......@@ -378,7 +378,9 @@ LRESULT CALLBACK AwtComponent::WndProc(HWND hWnd, UINT message,
TRY;
AwtComponent * self = AwtComponent::GetComponentImpl(hWnd);
if (self == NULL || self->GetHWnd() != hWnd) {
if (self == NULL || self->GetHWnd() != hWnd ||
message == WM_UNDOCUMENTED_CLIENTSHUTDOWN) // handle log-off gracefully
{
return ComCtl32Util::GetInstance().DefWindowProc(NULL, hWnd, message, wParam, lParam);
} else {
return self->WindowProc(message, wParam, lParam);
......
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#include "awt.h"
#include "awt_ole.h"
#include "awt_DCHolder.h" // main symbols
////////////////////////
// struct DCHolder
DCHolder::DCHolder()
: m_hMemoryDC(NULL),
m_iWidth(0),
m_iHeight(0),
m_bForImage(FALSE),
m_hBitmap(NULL),
m_hOldBitmap(NULL),
m_pPoints(NULL)
{}
void DCHolder::Create(
HDC hRelDC,
int iWidth,
int iHeght,
BOOL bForImage
){
OLE_DECL
m_iWidth = iWidth;
m_iHeight = iHeght;
m_bForImage = bForImage;
m_hMemoryDC = ::CreateCompatibleDC(hRelDC);
//NB: can not throw an error in non-safe stack!!! Just conversion and logging!
//OLE_WINERROR2HR just set OLE_HR without any throw!
if (!m_hMemoryDC) {
OLE_THROW_LASTERROR(_T("CreateCompatibleDC"))
}
m_hBitmap = m_bForImage
? CreateJavaContextBitmap(hRelDC, m_iWidth, m_iHeight, &m_pPoints)
: ::CreateCompatibleBitmap(hRelDC, m_iWidth, m_iHeight);
if (!m_hBitmap) {
OLE_THROW_LASTERROR(_T("CreateCompatibleBitmap"))
}
m_hOldBitmap = (HBITMAP)::SelectObject(m_hMemoryDC, m_hBitmap);
if (!m_hOldBitmap) {
OLE_THROW_LASTERROR(_T("SelectBMObject"))
}
}
DCHolder::~DCHolder(){
if (m_hOldBitmap) {
::SelectObject(m_hMemoryDC, m_hOldBitmap);
}
if (m_hBitmap) {
::DeleteObject(m_hBitmap);
}
if (m_hMemoryDC) {
::DeleteDC(m_hMemoryDC);
}
};
HBITMAP DCHolder::CreateJavaContextBitmap(
HDC hdc,
int iWidth,
int iHeight,
void **ppPoints)
{
BITMAPINFO bitmapInfo = {0};
bitmapInfo.bmiHeader.biWidth = iWidth;
bitmapInfo.bmiHeader.biHeight = -iHeight;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = 32;
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo.bmiHeader.biCompression = BI_RGB;
return ::CreateDIBSection(
hdc,
(BITMAPINFO *)&bitmapInfo,
DIB_RGB_COLORS,
(void **)ppPoints,
NULL,
0
);
}
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _AWT_DCHolder_H
#define _AWT_DCHolder_H
struct DCHolder
{
HDC m_hMemoryDC;
int m_iWidth;
int m_iHeight;
BOOL m_bForImage;
HBITMAP m_hBitmap;
HBITMAP m_hOldBitmap;
void *m_pPoints;
DCHolder();
~DCHolder();
void Create(
HDC hRelDC,
int iWidth,
int iHeght,
BOOL bForImage);
operator HDC()
{
if (NULL == m_hOldBitmap && NULL != m_hBitmap) {
m_hOldBitmap = (HBITMAP)::SelectObject(m_hMemoryDC, m_hBitmap);
}
return m_hMemoryDC;
}
operator HBITMAP()
{
if (NULL != m_hOldBitmap) {
m_hBitmap = (HBITMAP)::SelectObject(m_hMemoryDC, m_hOldBitmap);
m_hOldBitmap = NULL;
}
return m_hBitmap;
}
static HBITMAP CreateJavaContextBitmap(
HDC hdc,
int iWidth,
int iHeight,
void **ppPoints);
};
#endif //_AWT_DCHolder_H
/*
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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,7 +23,30 @@
* have any questions.
*/
#include "awt.h"
#pragma push_macro("bad_alloc")
//"bad_alloc" would be introduced in STL as "std::zbad_alloc" and discarded by linker
//by this action we avoid the conflict with AWT implementation of "bad_alloc"
//we need <new> inclusion for STL "new" oprators set.
#define bad_alloc zbad_alloc
#include <new>
#pragma pop_macro("bad_alloc")
//"bad_alloc" is undefined from here
//we need to include any STL container before <awt.h> inclusion due to
//"new" re-redefinition that is in conflict with in-place new allocator
//applied in STL.
#if defined(_DEBUG) || defined(DEBUG)
//forward declaration of "new" operator from <awt.h>
extern void * operator new(size_t size, const char * filename, int linenumber);
//"new" operator definition that is consistent with re-defined
//in <awt.h> "delete" operator
void * operator new(size_t size) {return operator new(size, "stl", 1);}
#endif
#include <map>
#include <awt.h>
#include <shlobj.h>
#include "jlong.h"
#include "awt_DataTransferer.h"
#include "awt_DnDDS.h"
......@@ -37,8 +60,14 @@
#include "sun_awt_dnd_SunDragSourceContextPeer.h"
#include "sun_awt_windows_WDragSourceContextPeer.h"
#include <memory.h>
#include <shlobj.h>
#include "awt_ole.h"
#include "awt_DCHolder.h"
bool operator < (const FORMATETC &fr, const FORMATETC &fl) {
return memcmp(&fr, &fl, sizeof(FORMATETC)) < 0;
}
typedef std::map<FORMATETC, STGMEDIUM> CDataMap;
#define GALLOCFLG (GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT)
#define JAVA_BUTTON_MASK (java_awt_event_InputEvent_BUTTON1_DOWN_MASK | \
......@@ -50,19 +79,155 @@ DWORD __cdecl convertActionsToDROPEFFECT(jint actions);
jint __cdecl convertDROPEFFECTToActions(DWORD effects);
}
class PictureDragHelper
{
private:
static CDataMap st;
static IDragSourceHelper *pHelper;
public:
static HRESULT Create(
JNIEnv* env,
jintArray imageData,
int imageWidth,
int imageHeight,
int anchorX,
int anchorY,
IDataObject *pIDataObject)
{
if (NULL == imageData) {
return S_FALSE;
}
OLE_TRY
OLE_HRT( CoCreateInstance(
CLSID_DragDropHelper,
NULL,
CLSCTX_ALL,
IID_IDragSourceHelper,
(LPVOID*)&pHelper))
jintArray ia = imageData;
jsize iPointCoint = env->GetArrayLength(ia);
DCHolder ph;
ph.Create(NULL, imageWidth, imageHeight, TRUE);
env->GetIntArrayRegion(ia, 0, iPointCoint, (jint*)ph.m_pPoints);
SHDRAGIMAGE sdi;
sdi.sizeDragImage.cx = imageWidth;
sdi.sizeDragImage.cy = imageHeight;
sdi.ptOffset.x = anchorX;
sdi.ptOffset.y = anchorY;
sdi.crColorKey = 0xFFFFFFFF;
sdi.hbmpDragImage = ph;
// this call assures that the bitmap will be dragged around
OLE_HR = pHelper->InitializeFromBitmap(
&sdi,
pIDataObject
);
// in case of an error we need to destroy the image, else the helper object takes ownership
if (FAILED(OLE_HR)) {
DeleteObject(sdi.hbmpDragImage);
}
OLE_CATCH
OLE_RETURN_HR
}
static void Destroy()
{
if (NULL!=pHelper) {
CleanFormatMap();
pHelper->Release();
pHelper = NULL;
}
}
static void CleanFormatMap()
{
for (CDataMap::iterator i = st.begin(); st.end() != i; i = st.erase(i)) {
::ReleaseStgMedium(&i->second);
}
}
static void SetData(const FORMATETC &format, const STGMEDIUM &medium)
{
CDataMap::iterator i = st.find(format);
if (st.end() != i) {
::ReleaseStgMedium(&i->second);
i->second = medium;
} else {
st[format] = medium;
}
}
static const FORMATETC *FindFormat(const FORMATETC &format)
{
static FORMATETC fm = {0};
CDataMap::iterator i = st.find(format);
if (st.end() != i) {
return &i->first;
}
for (i = st.begin(); st.end() != i; ++i) {
if (i->first.cfFormat==format.cfFormat) {
return &i->first;
}
}
return NULL;
}
static STGMEDIUM *FindData(const FORMATETC &format)
{
CDataMap::iterator i = st.find(format);
if (st.end() != i) {
return &i->second;
}
for (i = st.begin(); st.end() != i; ++i) {
const FORMATETC &f = i->first;
if (f.cfFormat==format.cfFormat && (f.tymed == (f.tymed & format.tymed))) {
return &i->second;
}
}
return NULL;
}
};
CDataMap PictureDragHelper::st;
IDragSourceHelper *PictureDragHelper::pHelper = NULL;
extern const CLIPFORMAT CF_PERFORMEDDROPEFFECT = ::RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT);
extern const CLIPFORMAT CF_FILEGROUPDESCRIPTORW = ::RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW);
extern const CLIPFORMAT CF_FILEGROUPDESCRIPTORA = ::RegisterClipboardFormat(CFSTR_FILEDESCRIPTORA);
extern const CLIPFORMAT CF_FILECONTENTS = ::RegisterClipboardFormat(CFSTR_FILECONTENTS);
typedef struct {
AwtDragSource* dragSource;
jobject cursor;
jintArray imageData;
jint imageWidth;
jint imageHeight;
jint x;
jint y;
} StartDragRec;
/**
* StartDrag
*/
void AwtDragSource::StartDrag(AwtDragSource* self, jobject cursor) {
void AwtDragSource::StartDrag(
AwtDragSource* self,
jobject cursor,
jintArray imageData,
jint imageWidth,
jint imageHeight,
jint x,
jint y)
{
StartDragRec* sdrp = new StartDragRec;
sdrp->dragSource = self;
sdrp->imageData = imageData;
sdrp->cursor = cursor;
sdrp->imageWidth = imageWidth;
sdrp->imageHeight = imageHeight;
sdrp->x = x;
sdrp->y = y;
AwtToolkit::GetInstance().WaitForSingleObject(self->m_mutex);
......@@ -82,6 +247,17 @@ void AwtDragSource::_DoDragDrop(void* param) {
JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject peer = env->NewLocalRef(dragSource->GetPeer());
if (sdrp->imageData) {
PictureDragHelper::Create(
env,
sdrp->imageData,
sdrp->imageWidth,
sdrp->imageHeight,
sdrp->x,
sdrp->y,
(IDataObject*)dragSource);
env->DeleteGlobalRef(sdrp->imageData);
}
dragSource->SetCursor(sdrp->cursor);
env->DeleteGlobalRef(sdrp->cursor);
delete sdrp;
......@@ -116,6 +292,7 @@ void AwtDragSource::_DoDragDrop(void* param) {
DASSERT(AwtDropTarget::IsCurrentDnDDataObject(dragSource));
AwtDropTarget::SetCurrentDnDDataObject(NULL);
PictureDragHelper::Destroy();
dragSource->Release();
}
......@@ -268,7 +445,10 @@ void AwtDragSource::LoadCache(jlongArray formats) {
idx++;
// now make a copy, but with a TYMED of HGLOBAL
memcpy(m_types + idx, m_types + idx - 1, sizeof(FORMATETC));
m_types[idx] = m_types[idx-1];
m_types[idx].tymed = TYMED_HGLOBAL;
idx++;
break;
case CF_HDROP:
m_types[idx].tymed = TYMED_HGLOBAL;
idx++;
......@@ -348,6 +528,14 @@ AwtDragSource::MatchFormatEtc(FORMATETC __RPC_FAR *pFormatEtcIn,
FORMATETC *cacheEnt) {
TRY;
const FORMATETC *pFormat = PictureDragHelper::FindFormat(*pFormatEtcIn);
if (NULL != pFormat) {
if (NULL != cacheEnt) {
*cacheEnt = *pFormat;
}
return S_OK;
}
if ((pFormatEtcIn->tymed & (TYMED_HGLOBAL | TYMED_ISTREAM | TYMED_ENHMF |
TYMED_MFPICT)) == 0) {
return DV_E_TYMED;
......@@ -357,8 +545,7 @@ AwtDragSource::MatchFormatEtc(FORMATETC __RPC_FAR *pFormatEtcIn,
return DV_E_DVASPECT;
}
FORMATETC tmp;
memcpy(&tmp, pFormatEtcIn, sizeof(FORMATETC));
FORMATETC tmp = *pFormatEtcIn;
static const DWORD supportedTymeds[] =
{ TYMED_ISTREAM, TYMED_HGLOBAL, TYMED_ENHMF, TYMED_MFPICT };
......@@ -367,22 +554,22 @@ AwtDragSource::MatchFormatEtc(FORMATETC __RPC_FAR *pFormatEtcIn,
for (int i = 0; i < nSupportedTymeds; i++) {
/*
* Fix for BugTraq Id 4426805.
* Match only if the tymed is supported by the requestor.
* Match only if the tymed is supported by the requester.
*/
if ((pFormatEtcIn->tymed & supportedTymeds[i]) == 0) {
continue;
}
tmp.tymed = supportedTymeds[i];
FORMATETC *cp = (FORMATETC *)bsearch((const void *)&tmp,
pFormat = (const FORMATETC *)bsearch((const void *)&tmp,
(const void *)m_types,
(size_t) m_ntypes,
(size_t) sizeof(FORMATETC),
_compar
);
if (cp != (FORMATETC *)NULL) {
if (NULL != pFormat) {
if (cacheEnt != (FORMATETC *)NULL) {
memcpy(cacheEnt, cp, sizeof(FORMATETC));
*cacheEnt = *pFormat;
}
return S_OK;
}
......@@ -481,7 +668,7 @@ HRESULT __stdcall AwtDragSource::QueryContinueDrag(BOOL fEscapeKeyPressed, DWOR
//CR 6480706 - MS Bug on hold
HCURSOR hNeedCursor;
if(
if (
m_bRestoreNodropCustomCursor &&
m_cursor != NULL &&
(hNeedCursor = m_cursor->GetHCursor()) != ::GetCursor() )
......@@ -579,6 +766,19 @@ HRESULT __stdcall AwtDragSource::GiveFeedback(DWORD dwEffect) {
HRESULT __stdcall AwtDragSource::GetData(FORMATETC __RPC_FAR *pFormatEtc,
STGMEDIUM __RPC_FAR *pmedium) {
TRY;
STGMEDIUM *pPicMedia = PictureDragHelper::FindData(*pFormatEtc);
if (NULL != pPicMedia) {
*pmedium = *pPicMedia;
//return outside, so AddRef the instance of pstm or hGlobal!
if (pmedium->tymed == TYMED_ISTREAM) {
pmedium->pstm->AddRef();
pmedium->pUnkForRelease = (IUnknown *)NULL;
} else if (pmedium->tymed == TYMED_HGLOBAL) {
AddRef();
pmedium->pUnkForRelease = (IDropSource *)this;
}
return S_OK;
}
HRESULT res = GetProcessId(pFormatEtc, pmedium);
if (res == S_OK) {
......@@ -870,8 +1070,6 @@ HRESULT __stdcall AwtDragSource::GetCanonicalFormatEtc(FORMATETC __RPC_FAR *pFo
*/
HRESULT __stdcall AwtDragSource::SetData(FORMATETC __RPC_FAR *pFormatEtc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease) {
static CLIPFORMAT CF_PERFORMEDDROPEFFECT = ::RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT);
if (pFormatEtc->cfFormat == CF_PERFORMEDDROPEFFECT && pmedium->tymed == TYMED_HGLOBAL) {
m_dwPerformedDropEffect = *(DWORD*)::GlobalLock(pmedium->hGlobal);
::GlobalUnlock(pmedium->hGlobal);
......@@ -880,6 +1078,12 @@ HRESULT __stdcall AwtDragSource::SetData(FORMATETC __RPC_FAR *pFormatEtc, STGMED
}
return S_OK;
}
if (fRelease) {
//we are copying pmedium as a structure for further use, so no any release!
PictureDragHelper::SetData(*pFormatEtc, *pmedium);
return S_OK;
}
return E_UNEXPECTED;
}
......@@ -1538,12 +1742,28 @@ Java_sun_awt_windows_WDragSourceContextPeer_createDragSource(
* doDragDrop
*/
JNIEXPORT void JNICALL Java_sun_awt_windows_WDragSourceContextPeer_doDragDrop(JNIEnv* env, jobject self, jlong nativeCtxt, jobject cursor) {
JNIEXPORT void JNICALL Java_sun_awt_windows_WDragSourceContextPeer_doDragDrop(
JNIEnv* env,
jobject self,
jlong nativeCtxt,
jobject cursor,
jintArray imageData,
jint imageWidth, jint imageHeight,
jint x, jint y)
{
TRY;
cursor = env->NewGlobalRef(cursor);
if (NULL != imageData) {
imageData = (jintArray)env->NewGlobalRef(imageData);
}
AwtDragSource::StartDrag((AwtDragSource*)nativeCtxt, cursor);
AwtDragSource::StartDrag(
(AwtDragSource*)nativeCtxt,
cursor,
imageData,
imageWidth, imageHeight,
x, y);
CATCH_BAD_ALLOC;
}
......
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -84,7 +84,14 @@ class AwtDragSource : virtual public IDropSource, virtual public IDataObject {
// AwtDragSource
static void StartDrag(AwtDragSource* self, jobject cursor);
static void StartDrag(
AwtDragSource* self,
jobject cursor,
jintArray imageData,
jint imageWidth,
jint imageHeight,
jint x,
jint y);
HRESULT ChangeCursor();
void SetCursor(jobject cursor);
......@@ -268,4 +275,9 @@ class AwtDragSource : virtual public IDropSource, virtual public IDataObject {
static jfieldID awtIEmods;
};
extern const CLIPFORMAT CF_PERFORMEDDROPEFFECT;
extern const CLIPFORMAT CF_FILEGROUPDESCRIPTORA;
extern const CLIPFORMAT CF_FILEGROUPDESCRIPTORW;
extern const CLIPFORMAT CF_FILECONTENTS;
#endif /* AWT_DND_DS_H */
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -27,7 +27,7 @@
#define AWT_DND_DT_H
#include <Ole2.h>
#include <shlobj.h>
#include <jni.h>
#include <jni_util.h>
......@@ -106,6 +106,11 @@ class AwtDropTarget : virtual public IDropTarget {
virtual void UnloadCache();
virtual HRESULT ExtractNativeData(jlong fmt, LONG lIndex, STGMEDIUM *pmedium);
virtual HRESULT SaveIndexToFile(LPCTSTR pFileName, UINT lIndex);
virtual jobject ConvertNativeData(JNIEnv* env, jlong fmt, STGMEDIUM *pmedium);
virtual jobject ConvertMemoryMappedData(JNIEnv* env, jlong fmt, STGMEDIUM *pmedium);
private:
typedef struct _RegisterTargetRec {
AwtDropTarget* dropTarget;
......@@ -152,11 +157,12 @@ class AwtDropTarget : virtual public IDropTarget {
// external COM references
IDataObject __RPC_FAR *m_dataObject;
IDataObject *m_dataObject;
IDropTargetHelper *m_pIDropTargetHelper;
// static members
static IDataObject __RPC_FAR *sm_pCurrentDnDDataObject;
static IDataObject *sm_pCurrentDnDDataObject;
// method references
......
......@@ -114,6 +114,7 @@ void AwtMenuItem::Dispose()
if (m_peerObject != NULL) {
JNI_SET_PDATA(m_peerObject, NULL);
env->DeleteGlobalRef(m_peerObject);
m_peerObject = NULL;
}
AwtObject::Dispose();
......
/*
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2009 Sun Microsystems, Inc. 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
......@@ -289,24 +289,6 @@ jmethodID AwtToolkit::getDefaultToolkitMID;
jmethodID AwtToolkit::getFontMetricsMID;
jmethodID AwtToolkit::insetsMID;
/************************************************************************
* JavaStringBuffer method
*/
JavaStringBuffer::JavaStringBuffer(JNIEnv *env, jstring jstr) {
if (jstr != NULL) {
int length = env->GetStringLength(jstr);
buffer = new TCHAR[length + 1];
LPCTSTR tmp = JNU_GetStringPlatformChars(env, jstr, NULL);
_tcscpy(buffer, tmp);
JNU_ReleaseStringPlatformChars(env, jstr, tmp);
} else {
buffer = new TCHAR[1];
buffer[0] = _T('\0');
}
}
/************************************************************************
* AwtToolkit methods
*/
......
/*
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2009 Sun Microsystems, Inc. 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
......@@ -466,20 +466,6 @@ public:
void UninstallMouseLowLevelHook();
};
/*
* Class to encapsulate the extraction of the java string contents
* into a buffer and the cleanup of the buffer
*/
class JavaStringBuffer {
public:
JavaStringBuffer(JNIEnv *env, jstring jstr);
INLINE ~JavaStringBuffer() { delete[] buffer; }
INLINE operator LPTSTR() { return buffer; }
INLINE operator LPARAM() { return (LPARAM)buffer; } /* for SendMessage */
private:
LPTSTR buffer;
};
/* creates an instance of T and assigns it to the argument, but only if
the argument is initially NULL. Supposed to be thread-safe.
......
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#include "awt_ole.h"
#include <time.h>
#include <sys/timeb.h>
namespace SUN_DBG_NS{
//WIN32 debug channel approach
//inline void DbgOut(LPCTSTR lpStr) { ::OutputDebugString(lpStr); }
//Java debug channel approach
inline void DbgOut(LPCTSTR lpStr) { DTRACE_PRINT(_B(lpStr)); }
LPCTSTR CreateTimeStamp(LPTSTR lpBuffer, size_t iBufferSize)
{
struct _timeb tb;
_ftime(&tb);
size_t len = _tcsftime(lpBuffer, iBufferSize, _T("%b %d %H:%M:%S"), localtime(&tb.time));
if (len && len+4 < iBufferSize) {
if (_sntprintf(lpBuffer+len, iBufferSize-len-1, _T(".%03d"), tb.millitm) < 0) {
lpBuffer[iBufferSize-len-1] = 0;
}
}
return lpBuffer;
}
#define DTRACE_BUF_LEN 1024
void snvTrace(LPCTSTR lpszFormat, va_list argList)
{
TCHAR szBuffer[DTRACE_BUF_LEN];
if (_vsntprintf( szBuffer, DTRACE_BUF_LEN, lpszFormat, argList ) < 0) {
szBuffer[DTRACE_BUF_LEN-1] = 0;
}
TCHAR szTime[32];
CreateTimeStamp(szTime, sizeof(szTime));
_tcscat(szTime, _T(" "));
TCHAR szBuffer1[DTRACE_BUF_LEN];
size_t iFormatLen = _tcslen(lpszFormat);
BOOL bErrorReport = iFormatLen>6 && _tcscmp(lpszFormat + iFormatLen - 6, _T("[%08x]"))==0;
size_t iTimeLen = _tcslen(szTime);
if (_sntprintf(
szBuffer1 + iTimeLen,
DTRACE_BUF_LEN - iTimeLen - 1, //reserver for \n
_T("P:%04d T:%04d ") TRACE_SUFFIX _T("%s%s"),
::GetCurrentProcessId(),
::GetCurrentThreadId(),
bErrorReport?_T("Error:"):_T(""),
szBuffer) < 0)
{
_tcscpy(szBuffer1 + DTRACE_BUF_LEN - 5, _T("...")); //reserver for \n
}
memcpy(szBuffer1, szTime, iTimeLen*sizeof(TCHAR));
_tcscat(szBuffer1, _T("\n"));
DbgOut( szBuffer1 );
}
void snTrace(LPCTSTR lpszFormat, ... )
{
va_list argList;
va_start(argList, lpszFormat);
snvTrace(lpszFormat, argList);
va_end(argList);
}
}//SUN_DBG_NS namespace end
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef AWT_OLE_H
#define AWT_OLE_H
#include "awt.h"
#include <ole2.h>
#include <comdef.h>
#include <comutil.h>
#ifdef _DEBUG
#define _SUN_DEBUG
#endif
#ifndef SUN_DBG_NS
#ifdef _LIB
#define SUN_DBG_NS SUN_dbg_lib
#else
#define SUN_DBG_NS SUN_dbg_glb
#endif //_LIB
#endif //SUN_DBG_NS
#ifndef TRACE_SUFFIX
#define TRACE_SUFFIX
#endif
namespace SUN_DBG_NS{
LPCTSTR CreateTimeStamp(LPTSTR lpBuffer, size_t iBufferSize);
inline void snTraceEmp(LPCTSTR, ...) { }
void snvTrace(LPCTSTR lpszFormat, va_list argList);
void snTrace(LPCTSTR lpszFormat, ... );
}//SUN_DBG_NS namespace end
#define STRACE1 SUN_DBG_NS::snTrace
#ifdef _SUN_DEBUG
#define STRACE SUN_DBG_NS::snTrace
#else
#define STRACE SUN_DBG_NS::snTraceEmp
#endif
#define STRACE0 SUN_DBG_NS::snTraceEmp
struct CLogEntryPoint1 {
LPCTSTR m_lpTitle;
CLogEntryPoint1(LPCTSTR lpTitle):m_lpTitle(lpTitle) { STRACE(_T("{%s"), m_lpTitle); }
~CLogEntryPoint1(){ STRACE(_T("}%s"), m_lpTitle); }
};
struct CLogEntryPoint0 {
LPCTSTR m_lpTitle;
CLogEntryPoint0(LPCTSTR lpTitle):m_lpTitle(lpTitle) { STRACE0(_T("{%s"), m_lpTitle); }
~CLogEntryPoint0(){ STRACE0(_T("}%s"), m_lpTitle); }
};
#define SEP1(msg) CLogEntryPoint1 _ep1_(msg);
#define SEP0(msg) CLogEntryPoint0 _ep0_(msg);
#ifdef _SUN_DEBUG
#define SEP(msg) CLogEntryPoint1 _ep1_(msg);
#else
#define SEP(msg) CLogEntryPoint0 _ep0_(msg);
#endif
#define OLE_BAD_COOKIE ((DWORD)-1)
#define OLE_TRACENOTIMPL(msg)\
STRACE(_T("Warning:%s"), msg);\
return E_NOTIMPL;
#define OLE_TRACEOK(msg)\
STRACE0(_T("Info:%s"), msg);\
return S_OK;
#define OLE_DECL\
HRESULT _hr_ = S_OK;
#define OLE_NEXT_TRY\
try {
#define OLE_TRY\
OLE_DECL\
try {
#define OLE_HRT(fnc)\
_hr_ = fnc;\
if (FAILED(_hr_)) {\
STRACE1(_T("Error:%08x in ") _T(#fnc), _hr_);\
_com_raise_error(_hr_);\
}
#define OLE_WINERROR2HR(msg, erCode)\
_hr_ = erCode;\
STRACE1(_T("OSError:%d in ") msg, _hr_);\
_hr_ = HRESULT_FROM_WIN32(_hr_);
#define OLE_THROW_LASTERROR(msg)\
OLE_WINERROR2HR(msg, ::GetLastError())\
_com_raise_error(_hr_);
#define OLE_CHECK_NOTNULL(x)\
if (!(x)) {\
STRACE1(_T("Null pointer:") _T(#x));\
_com_raise_error(_hr_ = E_POINTER);\
}
#define OLE_CHECK_NOTNULLSP(x)\
if (!bool(x)) {\
STRACE1(_T("Null pointer:") _T(#x));\
_com_raise_error(_hr_ = E_POINTER);\
}
#define OLE_HRW32(fnc)\
_hr_ = fnc;\
if (ERROR_SUCCESS != _hr_) {\
STRACE1(_T("OSError:%d in ") _T(#fnc), _hr_);\
_com_raise_error(_hr_ = HRESULT_FROM_WIN32(_hr_));\
}
#define OLE_HRW32_BOOL(fnc)\
if (!fnc) {\
OLE_THROW_LASTERROR(_T(#fnc))\
}
#define OLE_CATCH\
} catch (_com_error &e) {\
_hr_ = e.Error();\
STRACE1(_T("COM Error:%08x %s"), _hr_, e.ErrorMessage());\
}
#define OLE_CATCH_BAD_ALLOC\
} catch (_com_error &e) {\
_hr_ = e.Error();\
STRACE1(_T("COM Error:%08x %s"), _hr_, e.ErrorMessage());\
} catch (std::bad_alloc&) {\
_hr_ = E_OUTOFMEMORY;\
STRACE1(_T("Error: Out of Memory"));\
}
#define OLE_CATCH_ALL\
} catch (_com_error &e) {\
_hr_ = e.Error();\
STRACE1(_T("COM Error:%08x %s"), _hr_, e.ErrorMessage());\
} catch(...) {\
_hr_ = E_FAIL;\
STRACE1(_T("Error: General Pritection Failor"));\
}
#define OLE_RETURN_SUCCESS return SUCCEEDED(_hr_);
#define OLE_RETURN_HR return _hr_;
#define OLE_HR _hr_
#define _B(x) _bstr_t(x)
#define _BT(x) (LPCTSTR)_bstr_t(x)
#define _V(x) _variant_t(x)
#define _VV(vrt) _variant_t(vrt, false)
#define _VE _variant_t()
#define _VB(b) _variant_t(bool(b))
struct OLEHolder
{
OLEHolder()
: m_hr(::OleInitialize(NULL))
{}
~OLEHolder(){}
operator bool() const { return S_OK==SUCCEEDED(m_hr); }
HRESULT m_hr;
};
#endif//AWT_OLE_H
......@@ -253,4 +253,8 @@ enum {
#define WM_UNDOCUMENTED_CLICKMENUBAR 0x0313
#endif
#ifndef WM_UNDOCUMENTED_CLIENTSHUTDOWN
#define WM_UNDOCUMENTED_CLIENTSHUTDOWN 0x003b
#endif
#endif // AWTMSG_H
/*
* Copyright (c) 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 5010310 6319835 6904882
* @summary test fonts can be created in the presence of a security manager
* @run main/othervm/secure=java.lang.SecurityManager FontPrivilege
*/
import java.awt.Font;
public class FontPrivilege {
public static void main(String[] args) throws Exception {
new Font("Helvetica", Font.PLAIN, 12).getFamily();
new Font("foo bar", Font.PLAIN, 12).getFamily();
}
}
/*
* Copyright (c) 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6896335
* @summary Test GraphicsEnvironment.getDefaultScreenDevice() in headless mode
* @run main/othervm -Djava.awt.headless=true TestGetDefScreenDevice
*/
import java.awt.*;
public class TestGetDefScreenDevice {
public static void main(String[] args) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try {
ge.getDefaultScreenDevice();
throw new Exception("Failed. HeadlessException not thrown");
} catch (HeadlessException he) {
// OK, test passed.
}
}
}
此差异已折叠。
/*
* Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* AUTOMATICALLY GENERATED ON Thu Jan 03 15:48:39 PST 2002*/
/* DO NOT EDIT */
grant {
permission java.io.FilePermission "<<ALL FILES>>", "read,write";
permission java.lang.RuntimePermission "queuePrintJob";
permission java.lang.RuntimePermission "setSecurityManager";
};
<html>
<!--
@test
@bug 6242241
@summary Tests basic DnD functionality in an applet
@author Your Name: Alexey Utkin area=dnd
@run applet/manual=yesno DnDFileGroupDescriptor.html
-->
<head>
<title> DnDToWordpadTest </title>
</head>
<body>
<h1>DnDFileGroupDescriptor<br>Bug ID: 6242241</h1>
<p> See the dialog box (usually in upper left corner) for instructions</p>
<APPLET CODE="DnDFileGroupDescriptor.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
此差异已折叠。
此差异已折叠。
此差异已折叠。
<html>
<!--
@test %W% %E%
@bug 4874070
@summary Tests basic DnD functionality
@author Your Name: Alexey Utkin area=dnd
@run applet/manual=yesno ImageDecoratedDnD.html
-->
<head>
<title> ImageDecoratedDnD </title>
</head>
<body>
<h1>ImageDecoratedDnD<br>Bug ID: 4874070</h1>
<p> See the dialog box (usually in upper left corner) for instructions</p>
<APPLET CODE="ImageDecoratedDnD.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
<html>
<!--
@test %W% %E%
@bug 4874070
@summary Tests basic DnD functionality
@author Your Name: Alexey Utkin area=dnd
@run applet ImageDecoratedDnDInOut.html
-->
<head>
<title> ImageDecoratedDnDInOut </title>
</head>
<body>
<h1>ImageDecoratedDnDInOut<br>Bug ID: 4874070</h1>
<p> See the dialog box (usually in upper left corner) for instructions</p>
<APPLET CODE="ImageDecoratedDnDInOut.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册