提交 73f83783 编写于 作者: S sherman

Merge

......@@ -2,3 +2,5 @@
75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25
fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26
3e599d98875ddf919c8ea11cff9b3a99ba631a9b jdk7-b27
02e4c5348592a8d7fc2cba28bc5f8e35c0e17277 jdk7-b28
e21f4266466cd1306b176aaa08b2cd8337a9be3d jdk7-b29
......@@ -197,7 +197,6 @@ endif
# Lint Flags:
# -Xa ANSI C plus K&R, favor ANSI rules
# -Xarch=XXX Same as 'cc -xarch=XXX'
# -fd report on old style func defs
# -errchk=structarg report on 64bit struct args by value
# -errchk=longptr64 report on 64bit to 32bit issues (ignores casts)
......@@ -206,6 +205,7 @@ endif
# -x suppress unused externs
# -u suppress extern func/vars used/defined
# -errfmt=simple use one line errors with position info
# $(LINT_XARCH_OPTION) See Compiler-sun.gwk
LINTFLAGS_COMMON = -Xa
LINTFLAGS_COMMON += -fd
......@@ -224,42 +224,12 @@ LINTFLAGS_DBG =
# Tell the compilers to never generate globalized names, all the time.
CFLAGS_COMMON += -W0,-noglobal
# Arch specific settings (determines type of .o files and instruction set)
ifeq ($(ARCH_FAMILY), sparc)
ifdef VIS_NEEDED
XARCH_VALUE/32=v8plusa
XARCH_VALUE/64=v9a
else
# Someday this should change to improve optimization on UltraSPARC
# and abandon the old v8-only machines like the SPARCstation 10.
# Indications with Mustang is that alacrity runs do not show a
# big improvement using v8plus over v8, but other benchmarks might.
XARCH_VALUE/32=v8
XARCH_VALUE/64=v9
endif
endif
ifeq ($(ARCH_FAMILY), i586)
XARCH_VALUE/64=amd64
XARCH_VALUE/32=
endif
# Arch value based on current data model being built
XARCH_VALUE=$(XARCH_VALUE/$(ARCH_DATA_MODEL))
ifneq ($(XARCH_VALUE), )
# The actual compiler -xarch options to use
XARCH_OPTION/32 = -xarch=$(XARCH_VALUE/32)
XARCH_OPTION/64 = -xarch=$(XARCH_VALUE/64)
XARCH_OPTION = $(XARCH_OPTION/$(ARCH_DATA_MODEL))
endif
# If we have a specific -xarch value to use, add it
ifdef XARCH_OPTION
CFLAGS_COMMON += $(XARCH_OPTION)
CXXFLAGS_COMMON += $(XARCH_OPTION)
ASFLAGS_COMMON += $(XARCH_OPTION)
EXTRA_LIBS += $(XARCH_OPTION)
LINTFLAGS_COMMON += -Xarch=$(XARCH_VALUE)
endif
# If we have a specific arch value to use, add it
CFLAGS_COMMON += $(XARCH_OPTION)
CXXFLAGS_COMMON += $(XARCH_OPTION)
ASFLAGS_COMMON += $(AS_XARCH_OPTION)
EXTRA_LIBS += $(XARCH_OPTION)
LINTFLAGS_COMMON += $(LINT_XARCH_OPTION)
#
# uncomment the following to build with PERTURBALOT set
......
......@@ -1240,7 +1240,6 @@ ifeq ($(PLATFORM), windows)
$(RM) $(TEMPDIR)/rebase.input
endif
$(RM) -r $(JDK_IMAGE_DIR)
$(RM) -r $(JDK_DEBUG_IMAGE_DIR)
$(RM) -r $(JRE_IMAGE_DIR)
images images-clobber::
......
......@@ -31,6 +31,9 @@ COMPILER_NAME=Sun Studio
# Sun Studio Compiler settings specific to Solaris
ifeq ($(PLATFORM), solaris)
# FIXUP: Change to SS12 when validated
#COMPILER_VERSION=SS12
#REQUIRED_CC_VER=5.9
COMPILER_VERSION=SS11
REQUIRED_CC_VER=5.8
CC = $(COMPILER_PATH)cc
......@@ -51,8 +54,8 @@ endif
# Sun Studio Compiler settings specific to Linux
ifeq ($(PLATFORM), linux)
# This has not been tested
COMPILER_VERSION=SS11
REQUIRED_CC_VER=5.8
COMPILER_VERSION=SS12
REQUIRED_CC_VER=5.9
CC = $(COMPILER_PATH)cc
CPP = $(COMPILER_PATH)cc -E
CXX = $(COMPILER_PATH)CC
......@@ -74,3 +77,58 @@ endif
_CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1)
CC_VER :=$(call GetVersion,"$(_CC_VER)")
# Arch specific settings (determines type of .o files and instruction set)
# Starting in SS12 (5.9), the arch options changed.
# The assembler /usr/ccs/bin/as wants older SS11 (5.8) style options.
# Note: We need to have both 32 and 64 values at all times for awt Makefiles.
#
XARCH_OPTION_OLD/32 =
XARCH_OPTION_OLD/64 =
XARCH_OPTION_NEW/32 = -m32
XARCH_OPTION_NEW/64 = -m64
# Lint options are slightly different
LINT_XARCH_OPTION_OLD/32 =
LINT_XARCH_OPTION_OLD/64 =
LINT_XARCH_OPTION_NEW/32 = -m32
LINT_XARCH_OPTION_NEW/64 = -m64
ifeq ($(ARCH_FAMILY), sparc)
ifdef VIS_NEEDED
XARCH_OPTION_OLD/32 += -xarch=v8plusa
XARCH_OPTION_OLD/64 += -xarch=v9a
XARCH_OPTION_NEW/32 += -xarch=sparcvis
XARCH_OPTION_NEW/64 += -xarch=sparcvis
else
# Someday this should change to improve optimization on UltraSPARC
# and abandon v8, even change to sparcvis or sparcvis2, this
# abandons machines like the SPARCstation 10.
# Indications with jdk6 is that alacrity runs do not show a
# big improvement using v8plus over v8, but other benchmarks might.
XARCH_OPTION_OLD/32 += -xarch=v8
XARCH_OPTION_OLD/64 += -xarch=v9
# Note that this new option (SS12+) effectively means v8plus
XARCH_OPTION_NEW/32 += -xarch=sparc
XARCH_OPTION_NEW/64 += -xarch=sparc
endif
LINT_XARCH_OPTION_OLD/64 += -Xarch=v9
endif
ifeq ($(ARCH_FAMILY), i586)
XARCH_OPTION_OLD/64 += -xarch=amd64
LINT_XARCH_OPTION_OLD/64 += -Xarch=amd64
endif
# Pick the options we want based on the compiler being used.
ifeq ($(shell expr $(CC_VER) \>= 5.9), 1)
XARCH_OPTION/32 = $(XARCH_OPTION_NEW/32)
XARCH_OPTION/64 = $(XARCH_OPTION_NEW/64)
LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_NEW/32)
LINT_XARCH_OPTION/64 = $(LINT_XARCH_OPTION_NEW/64)
else
XARCH_OPTION/32 = $(XARCH_OPTION_OLD/32)
XARCH_OPTION/64 = $(XARCH_OPTION_OLD/64)
LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_OLD/32)
LINT_XARCH_OPTION/64 = $(LINT_XARCH_OPTION_OLD/64)
endif
XARCH_OPTION = $(XARCH_OPTION/$(ARCH_DATA_MODEL))
LINT_XARCH_OPTION = $(LINT_XARCH_OPTION/$(ARCH_DATA_MODEL))
# The /usr/ccs/bin/as assembler always wants the older SS11 (5.8) options.
AS_XARCH_OPTION = $(XARCH_OPTION_OLD/$(ARCH_DATA_MODEL))
......@@ -119,7 +119,7 @@ if [ "${osname}" = SunOS ] ; then
# System place where JDK installed images are stored?
jdk_instances=/usr/jdk/instances
# Get the SS11 compilers (and latest patches for them too)
# Get the Sun Studio compilers (and latest patches for them too)
if [ "${ALT_COMPILER_PATH}" = "" ] ; then
ALT_COMPILER_PATH=/opt/SUNWspro/bin
export ALT_COMPILER_PATH
......
......@@ -133,9 +133,15 @@ if [ "${osname}" = SunOS ] ; then
solaris_arch=i386
fi
# Get the SS11 compilers into path (make sure it matches ALT setting)
compiler_path=${jdk_devtools}/${solaris_arch}/SUNWspro/SS11/bin
compiler_name=SS11
# Get the compilers into path (make sure it matches ALT setting)
if [ "${JPRT_SOLARIS_COMPILER_NAME}" != "" ] ; then
compiler_name=${JPRT_SOLARIS_COMPILER_NAME}
else
# FIXUP: Change to SS12 when validated
#compiler_name=SS12
compiler_name=SS11
fi
compiler_path=${jdk_devtools}/${solaris_arch}/SUNWspro/${compiler_name}/bin
ALT_COMPILER_PATH="${compiler_path}"
export ALT_COMPILER_PATH
dirMustExist "${compiler_path}" ALT_COMPILER_PATH
......
......@@ -93,7 +93,6 @@ else # PLATFORM
# Other extra flags needed for compiling.
#
CPPFLAGS += -I$(OPENWIN_HOME)/include \
-I$(MOTIF_DIR)/include \
-I$(SHARE_SRC)/native/$(PKGDIR)/debug \
-I$(SHARE_SRC)/native/$(PKGDIR)/image \
-I$(SHARE_SRC)/native/$(PKGDIR)/image/cvutils \
......
......@@ -1222,9 +1222,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel
"FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
"FileChooser.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancelSelection",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"ESCAPE", "cancelSelection"
}),
......
......@@ -825,9 +825,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection",
"F2", "editFileName",
"F5", "refresh",
"BACK_SPACE", "Go Up",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"BACK_SPACE", "Go Up"
}),
"FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
......
......@@ -3057,10 +3057,24 @@ public abstract class Component implements ImageObserver, MenuContainer,
// services. Additionally, the request is restricted to
// the bounds of the component.
if (parent != null) {
int px = this.x + ((x < 0) ? 0 : x);
int py = this.y + ((y < 0) ? 0 : y);
if (x < 0) {
width += x;
x = 0;
}
if (y < 0) {
height += y;
y = 0;
}
int pwidth = (width > this.width) ? this.width : width;
int pheight = (height > this.height) ? this.height : height;
if (pwidth <= 0 || pheight <= 0) {
return;
}
int px = this.x + x;
int py = this.y + y;
parent.repaint(tm, px, py, pwidth, pheight);
}
} else {
......
/*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2008 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
......@@ -485,7 +485,6 @@ public class DragSourceContext
Cursor c = null;
targetAct = DnDConstants.ACTION_NONE;
switch (status) {
case ENTER:
case OVER:
......@@ -507,6 +506,10 @@ public class DragSourceContext
else
c = DragSource.DefaultCopyDrop;
}
break;
default:
targetAct = DnDConstants.ACTION_NONE;
}
setCursorImpl(c);
......
......@@ -636,7 +636,7 @@ public class EventHandler implements InvocationHandler {
* time a mouse button is pressed, one would write:
*<blockquote>
*<pre>
*EventHandler.create(MouseListener.class, "mousePressed", target, "origin", "point");
*EventHandler.create(MouseListener.class, target, "origin", "point", "mousePressed");
*</pre>
*</blockquote>
*
......
......@@ -25,6 +25,7 @@
package java.io;
import java.beans.ConstructorProperties;
import java.net.URI;
import java.net.URL;
import java.net.MalformedURLException;
......@@ -234,6 +235,7 @@ public class File
* @throws NullPointerException
* If the <code>pathname</code> argument is <code>null</code>
*/
@ConstructorProperties("path")
public File(String pathname) {
if (pathname == null) {
throw new NullPointerException();
......
......@@ -770,7 +770,8 @@ public class JFileChooser extends JComponent implements Accessible {
* @since 1.4
*/
protected JDialog createDialog(Component parent) throws HeadlessException {
String title = getUI().getDialogTitle(this);
FileChooserUI ui = getUI();
String title = ui.getDialogTitle(this);
putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
title);
......@@ -794,6 +795,7 @@ public class JFileChooser extends JComponent implements Accessible {
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
}
}
dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
dialog.pack();
dialog.setLocationRelativeTo(parent);
......
......@@ -41,6 +41,7 @@ import javax.swing.plaf.PopupMenuUI;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.event.*;
import sun.security.util.SecurityConstants;
import java.applet.Applet;
......@@ -320,17 +321,67 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
* This adustment may be cancelled by invoking the application with
* -Djavax.swing.adjustPopupLocationToFit=false
*/
Point adjustPopupLocationToFitScreen(int xposition, int yposition) {
Point p = new Point(xposition, yposition);
Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
Point popupLocation = new Point(xPosition, yPosition);
if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless())
return p;
if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
return popupLocation;
}
// Get screen bounds
Rectangle scrBounds;
GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds;
if(gc != null) {
// If we have GraphicsConfiguration use it to get screen bounds
scrBounds = gc.getBounds();
} else {
// If we don't have GraphicsConfiguration use primary screen
scrBounds = new Rectangle(toolkit.getScreenSize());
}
// Calculate the screen size that popup should fit
Dimension popupSize = JPopupMenu.this.getPreferredSize();
int popupRightX = popupLocation.x + popupSize.width;
int popupBottomY = popupLocation.y + popupSize.height;
int scrWidth = scrBounds.width;
int scrHeight = scrBounds.height;
if (!canPopupOverlapTaskBar()) {
// Insets include the task bar. Take them into account.
Insets scrInsets = toolkit.getScreenInsets(gc);
scrBounds.x += scrInsets.left;
scrBounds.y += scrInsets.top;
scrWidth -= scrInsets.left + scrInsets.right;
scrHeight -= scrInsets.top + scrInsets.bottom;
}
int scrRightX = scrBounds.x + scrWidth;
int scrBottomY = scrBounds.y + scrHeight;
// Ensure that popup menu fits the screen
if (popupRightX > scrRightX) {
popupLocation.x = scrRightX - popupSize.width;
if( popupLocation.x < scrBounds.x ) {
popupLocation.x = scrBounds.x ;
}
}
if (popupBottomY > scrBottomY) {
popupLocation.y = scrBottomY - popupSize.height;
if( popupLocation.y < scrBounds.y ) {
popupLocation.y = scrBounds.y;
}
}
return popupLocation;
}
/**
* Tries to find GraphicsConfiguration
* that contains the mouse cursor position.
* Can return null.
*/
private GraphicsConfiguration getCurrentGraphicsConfiguration(
Point popupLocation) {
GraphicsConfiguration gc = null;
// Try to find GraphicsConfiguration, that includes mouse
// pointer position
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
......@@ -338,50 +389,36 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
if(gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration dgc =
gd[i].getDefaultConfiguration();
if(dgc.getBounds().contains(p)) {
if(dgc.getBounds().contains(popupLocation)) {
gc = dgc;
break;
}
}
}
// If not found and we have invoker, ask invoker about his gc
if(gc == null && getInvoker() != null) {
gc = getInvoker().getGraphicsConfiguration();
}
return gc;
}
if(gc != null) {
// If we have GraphicsConfiguration use it to get
// screen bounds
screenBounds = gc.getBounds();
} else {
// If we don't have GraphicsConfiguration use primary screen
screenBounds = new Rectangle(toolkit.getScreenSize());
/**
* Checks that there are enough security permissions
* to make popup "always on top", which allows to show it above the task bar.
*/
static boolean canPopupOverlapTaskBar() {
boolean result = true;
try {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(
SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
}
} catch (SecurityException se) {
// There is no permission to show popups over the task bar
result = false;
}
Dimension size;
size = JPopupMenu.this.getPreferredSize();
// Use long variables to prevent overflow
long pw = (long) p.x + (long) size.width;
long ph = (long) p.y + (long) size.height;
if( pw > screenBounds.x + screenBounds.width )
p.x = screenBounds.x + screenBounds.width - size.width;
if( ph > screenBounds.y + screenBounds.height)
p.y = screenBounds.y + screenBounds.height - size.height;
/* Change is made to the desired (X,Y) values, when the
PopupMenu is too tall OR too wide for the screen
*/
if( p.x < screenBounds.x )
p.x = screenBounds.x ;
if( p.y < screenBounds.y )
p.y = screenBounds.y;
return p;
return result;
}
......
......@@ -25,18 +25,15 @@
package javax.swing;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.accessibility.*;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.awt.Color;
import java.awt.Font;
import java.awt.*;
import java.util.*;
import java.beans.*;
......@@ -409,8 +406,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
* @since 1.4
*/
public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners(
ChangeListener.class);
return listenerList.getListeners(ChangeListener.class);
}
......@@ -642,9 +638,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
/**
* Sets the model's {@code valueIsAdjusting} property. Slider look and
* feel implementations should set this property to {@code true} when
* a knob drag begins, and to {@code false} when the drag ends. The
* slider model will not generate {@code ChangeEvent}s while
* {@code valueIsAdjusting} is {@code true}.
* a knob drag begins, and to {@code false} when the drag ends.
*
* @param b the new value for the {@code valueIsAdjusting} property
* @see #getValueIsAdjusting
......@@ -764,6 +758,33 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
updateLabelSizes();
}
/**
* {@inheritDoc}
* @since 1.7
*/
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
if (!isShowing()) {
return false;
}
// Check that there is a label with such image
Enumeration elements = labelTable.elements();
while (elements.hasMoreElements()) {
Component component = (Component) elements.nextElement();
if (component instanceof JLabel) {
JLabel label = (JLabel) component;
if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) ||
SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) {
return super.imageUpdate(img, infoflags, x, y, w, h);
}
}
}
return false;
}
/**
* Returns the dictionary of what labels to draw at which values.
......@@ -826,17 +847,16 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
* @see JComponent#updateUI
*/
protected void updateLabelUIs() {
if ( getLabelTable() == null ) {
Dictionary labelTable = getLabelTable();
if (labelTable == null) {
return;
}
Enumeration labels = getLabelTable().keys();
Enumeration labels = labelTable.keys();
while ( labels.hasMoreElements() ) {
Object value = getLabelTable().get( labels.nextElement() );
if ( value instanceof JComponent ) {
JComponent component = (JComponent)value;
component.updateUI();
component.setSize( component.getPreferredSize() );
}
JComponent component = (JComponent) labelTable.get(labels.nextElement());
component.updateUI();
component.setSize(component.getPreferredSize());
}
}
......@@ -845,11 +865,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
if (labelTable != null) {
Enumeration labels = labelTable.elements();
while (labels.hasMoreElements()) {
Object value = labels.nextElement();
if (value instanceof JComponent) {
JComponent component = (JComponent)value;
component.setSize(component.getPreferredSize());
}
JComponent component = (JComponent) labels.nextElement();
component.setSize(component.getPreferredSize());
}
}
}
......@@ -960,14 +977,14 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
if ( e.getPropertyName().equals( "minimum" ) ||
e.getPropertyName().equals( "maximum" ) ) {
Enumeration keys = getLabelTable().keys();
Object key = null;
Dictionary labelTable = getLabelTable();
Enumeration keys = labelTable.keys();
Hashtable hashtable = new Hashtable();
// Save the labels that were added by the developer
while ( keys.hasMoreElements() ) {
key = keys.nextElement();
Object value = getLabelTable().get( key );
Object key = keys.nextElement();
Object value = labelTable.get(key);
if ( !(value instanceof LabelUIResource) ) {
hashtable.put( key, value );
}
......@@ -979,7 +996,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
// Add the saved labels
keys = hashtable.keys();
while ( keys.hasMoreElements() ) {
key = keys.nextElement();
Object key = keys.nextElement();
put( key, hashtable.get( key ) );
}
......@@ -996,8 +1013,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
SmartHashtable table = new SmartHashtable( increment, start );
if ( getLabelTable() != null && (getLabelTable() instanceof PropertyChangeListener) ) {
removePropertyChangeListener( (PropertyChangeListener)getLabelTable() );
Dictionary labelTable = getLabelTable();
if (labelTable != null && (labelTable instanceof PropertyChangeListener)) {
removePropertyChangeListener((PropertyChangeListener) labelTable);
}
addPropertyChangeListener( table );
......
......@@ -548,47 +548,46 @@ public class PopupFactory {
}
/**
* Returns true if the Popup can fit on the screen.
* Returns true if popup can fit the screen and the owner's top parent.
* It determines can popup be lightweight or mediumweight.
*/
boolean fitsOnScreen() {
boolean result = false;
Component component = getComponent();
if (owner != null && component != null) {
Container parent;
int width = component.getWidth();
int height = component.getHeight();
for(parent = owner.getParent(); parent != null ;
parent = parent.getParent()) {
if (parent instanceof JFrame ||
parent instanceof JDialog ||
parent instanceof JWindow) {
Rectangle r = parent.getBounds();
Insets i = parent.getInsets();
r.x += i.left;
r.y += i.top;
r.width -= (i.left + i.right);
r.height -= (i.top + i.bottom);
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
Container parent = (Container) SwingUtilities.getRoot(owner);
int popupWidth = component.getWidth();
int popupHeight = component.getHeight();
Rectangle parentBounds = parent.getBounds();
if (parent instanceof JFrame ||
parent instanceof JDialog ||
parent instanceof JWindow) {
Insets i = parent.getInsets();
parentBounds.x += i.left;
parentBounds.y += i.top;
parentBounds.width -= i.left + i.right;
parentBounds.height -= i.top + i.bottom;
if (JPopupMenu.canPopupOverlapTaskBar()) {
GraphicsConfiguration gc =
parent.getGraphicsConfiguration();
Rectangle popupArea = getContainerPopupArea(gc);
return r.intersection(popupArea).contains(x, y, width, height);
} else if (parent instanceof JApplet) {
Rectangle r = parent.getBounds();
Point p = parent.getLocationOnScreen();
r.x = p.x;
r.y = p.y;
return r.contains(x, y, width, height);
} else if (parent instanceof Window ||
parent instanceof Applet) {
// No suitable swing component found
break;
result = parentBounds.intersection(popupArea)
.contains(x, y, popupWidth, popupHeight);
} else {
result = parentBounds
.contains(x, y, popupWidth, popupHeight);
}
} else if (parent instanceof JApplet) {
Point p = parent.getLocationOnScreen();
parentBounds.x = p.x;
parentBounds.y = p.y;
result = parentBounds
.contains(x, y, popupWidth, popupHeight);
}
}
return false;
return result;
}
Rectangle getContainerPopupArea(GraphicsConfiguration gc) {
......
......@@ -25,7 +25,7 @@
package javax.swing.plaf;
import javax.swing.JFileChooser;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileView;
import java.io.File;
......@@ -46,4 +46,15 @@ public abstract class FileChooserUI extends ComponentUI
public abstract void rescanCurrentDirectory(JFileChooser fc);
public abstract void ensureFileIsVisible(JFileChooser fc, File f);
/**
* Returns default button for current <code>LookAndFeel</code>.
* <code>JFileChooser</code> will use this button as default button
* for dialog windows.
*
* @since 1.7
*/
public JButton getDefaultButton(JFileChooser fc) {
return null;
}
}
......@@ -196,7 +196,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
}
protected void sort(Vector<? extends File> v){
ShellFolder.sortFiles(v);
ShellFolder.sort(v);
}
// Obsolete - not used
......
......@@ -384,6 +384,10 @@ public class BasicFileChooserUI extends FileChooserUI {
return null;
}
public JButton getDefaultButton(JFileChooser fc) {
return getApproveButton(fc);
}
public String getApproveButtonToolTipText(JFileChooser fc) {
String tooltipText = fc.getApproveButtonToolTipText();
if(tooltipText != null) {
......
......@@ -25,25 +25,12 @@
package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.Container;
import java.awt.Adjustable;
import java.awt.event.*;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Point;
import java.awt.Insets;
import java.awt.Color;
import java.awt.IllegalComponentStateException;
import java.awt.Polygon;
import java.awt.*;
import java.beans.*;
import java.util.Dictionary;
import java.util.Enumeration;
import javax.swing.border.AbstractBorder;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
......@@ -409,7 +396,7 @@ public class BasicSliderUI extends SliderUI{
Enumeration elements = dictionary.elements();
int baseline = -1;
while (elements.hasMoreElements()) {
Component label = (Component)elements.nextElement();
JComponent label = (JComponent) elements.nextElement();
Dimension pref = label.getPreferredSize();
int labelBaseline = label.getBaseline(pref.width,
pref.height);
......@@ -634,7 +621,7 @@ public class BasicSliderUI extends SliderUI{
protected void calculateTrackRect() {
int centerSpacing = 0; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
centerSpacing = thumbRect.height;
if ( slider.getPaintTicks() ) centerSpacing += getTickLength();
......@@ -764,7 +751,7 @@ public class BasicSliderUI extends SliderUI{
if ( dictionary != null ) {
Enumeration keys = dictionary.keys();
while ( keys.hasMoreElements() ) {
Component label = (Component)dictionary.get( keys.nextElement() );
JComponent label = (JComponent) dictionary.get(keys.nextElement());
widest = Math.max( label.getPreferredSize().width, widest );
}
}
......@@ -777,7 +764,7 @@ public class BasicSliderUI extends SliderUI{
if ( dictionary != null ) {
Enumeration keys = dictionary.keys();
while ( keys.hasMoreElements() ) {
Component label = (Component)dictionary.get( keys.nextElement() );
JComponent label = (JComponent) dictionary.get(keys.nextElement());
tallest = Math.max( label.getPreferredSize().height, tallest );
}
}
......@@ -1001,22 +988,14 @@ public class BasicSliderUI extends SliderUI{
public void paintTicks(Graphics g) {
Rectangle tickBounds = tickRect;
int i;
int maj, min, max;
int w = tickBounds.width;
int h = tickBounds.height;
int centerEffect, tickHeight;
g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
maj = slider.getMajorTickSpacing();
min = slider.getMinorTickSpacing();
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
g.translate( 0, tickBounds.y);
int value = slider.getMinimum();
int xPos = 0;
int xPos;
if ( slider.getMinorTickSpacing() > 0 ) {
while ( value <= slider.getMaximum() ) {
......@@ -1042,7 +1021,7 @@ public class BasicSliderUI extends SliderUI{
g.translate(tickBounds.x, 0);
int value = slider.getMinimum();
int yPos = 0;
int yPos;
if ( slider.getMinorTickSpacing() > 0 ) {
int offset = 0;
......@@ -1111,10 +1090,19 @@ public class BasicSliderUI extends SliderUI{
Integer key = (Integer)keys.nextElement();
int value = key.intValue();
if (value >= minValue && value <= maxValue) {
Component label = (Component)dictionary.get( key );
if (label instanceof JComponent) {
((JComponent)label).setEnabled(enabled);
JComponent label = (JComponent) dictionary.get(key);
label.setEnabled(enabled);
if (label instanceof JLabel) {
Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();
if (icon instanceof ImageIcon) {
// Register Slider as an image observer. It allows to catch notifications about
// image changes (e.g. gif animation)
Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
}
}
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
g.translate( 0, labelBounds.y );
paintHorizontalLabel( g, value, label );
......@@ -1364,7 +1352,7 @@ public class BasicSliderUI extends SliderUI{
int min = slider.getMinimum();
int max = slider.getMaximum();
double valueRange = (double)max - (double)min;
double pixelsPerValue = (double)trackHeight / (double)valueRange;
double pixelsPerValue = (double)trackHeight / valueRange;
int trackBottom = trackY + (trackHeight - 1);
int yPosition;
......@@ -1715,7 +1703,7 @@ public class BasicSliderUI extends SliderUI{
* of the thumb relative to the origin of the track.
*/
public void mouseDragged(MouseEvent e) {
int thumbMiddle = 0;
int thumbMiddle;
if (!slider.isEnabled()) {
return;
......@@ -1841,7 +1829,7 @@ public class BasicSliderUI extends SliderUI{
public void componentResized(ComponentEvent e) {
getHandler().componentResized(e);
}
};
}
/**
* Focus-change listener.
......@@ -1903,7 +1891,7 @@ public class BasicSliderUI extends SliderUI{
return b;
}
};
}
/**
......
......@@ -853,9 +853,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection",
"F2", "editFileName",
"F5", "refresh",
"BACK_SPACE", "Go Up",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"BACK_SPACE", "Go Up"
}),
......
......@@ -25,26 +25,17 @@
package javax.swing.plaf.synth;
import java.awt.Component;
import java.awt.Container;
import java.awt.Adjustable;
import java.awt.event.*;
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.Point;
import java.awt.Insets;
import java.awt.Color;
import java.awt.IllegalComponentStateException;
import java.awt.Polygon;
import java.beans.*;
import java.util.Dictionary;
import java.util.Enumeration;
import javax.swing.border.AbstractBorder;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicSliderUI;
import sun.swing.plaf.synth.SynthUI;
......@@ -203,8 +194,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
centerY += valueHeight + 2;
centerY += trackHeight + trackInsets.top + trackInsets.bottom;
centerY += tickHeight + 2;
Component label = (Component)slider.getLabelTable().
elements().nextElement();
JComponent label = (JComponent) slider.getLabelTable().elements().nextElement();
Dimension pref = label.getPreferredSize();
return centerY + label.getBaseline(pref.width, pref.height);
}
......@@ -226,8 +216,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
int trackHeight = contentHeight - valueHeight;
int yPosition = yPositionForValue(value.intValue(), trackY,
trackHeight);
Component label = (Component)slider.getLabelTable().
get(value);
JComponent label = (JComponent) slider.getLabelTable().get(value);
Dimension pref = label.getPreferredSize();
return yPosition - pref.height / 2 +
label.getBaseline(pref.width, pref.height);
......@@ -434,16 +423,14 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
/**
* Calculates the pad for the label at the specified index.
*
* @param index index of the label to calculate pad for.
* @param i index of the label to calculate pad for.
* @return padding required to keep label visible.
*/
private int getPadForLabel(int i) {
Dictionary dictionary = slider.getLabelTable();
int pad = 0;
Object o = dictionary.get(i);
if (o != null) {
Component c = (Component)o;
JComponent c = (JComponent) slider.getLabelTable().get(i);
if (c != null) {
int centerX = xPositionForValue(i);
int cHalfWidth = c.getPreferredSize().width / 2;
if (centerX - cHalfWidth < insetCache.left) {
......@@ -500,8 +487,6 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
}
}
private static Rectangle unionRect = new Rectangle();
public void setThumbLocation(int x, int y) {
super.setThumbLocation(x, y);
// Value rect is tied to the thumb location. We need to repaint when
......@@ -544,7 +529,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
trackBorder;
int trackLength = trackBottom - trackTop;
double valueRange = (double)max - (double)min;
double pixelsPerValue = (double)trackLength / (double)valueRange;
double pixelsPerValue = (double)trackLength / valueRange;
int yPosition;
if (!drawInverted()) {
......@@ -802,8 +787,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
}
public void mouseDragged(MouseEvent e) {
SynthScrollBarUI ui;
int thumbMiddle = 0;
int thumbMiddle;
if (!slider.isEnabled()) {
return;
......
......@@ -333,17 +333,24 @@ public abstract class FlowView extends BoxView {
* @since 1.3
*/
public static class FlowStrategy {
int damageStart = Integer.MAX_VALUE;
Position damageStart = null;
Vector<View> viewBuffer;
void addDamage(FlowView fv, int offset) {
if (offset >= fv.getStartOffset() && offset < fv.getEndOffset()) {
damageStart = Math.min(damageStart, offset);
if (damageStart == null || offset < damageStart.getOffset()) {
try {
damageStart = fv.getDocument().createPosition(offset);
} catch (BadLocationException e) {
// shouldn't happen since offset is inside view bounds
assert(false);
}
}
}
}
void unsetDamage() {
damageStart = Integer.MAX_VALUE;
damageStart = null;
}
/**
......@@ -438,13 +445,14 @@ public abstract class FlowView extends BoxView {
int p1 = fv.getEndOffset();
if (fv.majorAllocValid) {
if (damageStart == Integer.MAX_VALUE) {
if (damageStart == null) {
return;
}
// In some cases there's no view at position damageStart, so
// step back and search again. See 6452106 for details.
while ((rowIndex = fv.getViewIndexAtPosition(damageStart)) < 0) {
damageStart--;
int offset = damageStart.getOffset();
while ((rowIndex = fv.getViewIndexAtPosition(offset)) < 0) {
offset--;
}
if (rowIndex > 0) {
rowIndex--;
......
......@@ -25,6 +25,7 @@
package sun.awt.shell;
import javax.swing.*;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.*;
......@@ -37,6 +38,10 @@ import java.util.*;
*/
public abstract class ShellFolder extends File {
private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
protected ShellFolder parent;
/**
......@@ -268,8 +273,45 @@ public abstract class ShellFolder extends File {
// Override File methods
public static void sortFiles(List files) {
shellFolderManager.sortFiles(files);
public static void sort(List<? extends File> files) {
if (files == null || files.size() <= 1) {
return;
}
// Check that we can use the ShellFolder.sortChildren() method:
// 1. All files have the same non-null parent
// 2. All files is ShellFolders
File commonParent = null;
for (File file : files) {
File parent = file.getParentFile();
if (parent == null || !(file instanceof ShellFolder)) {
commonParent = null;
break;
}
if (commonParent == null) {
commonParent = parent;
} else {
if (commonParent != parent && !commonParent.equals(parent)) {
commonParent = null;
break;
}
}
}
if (commonParent instanceof ShellFolder) {
((ShellFolder) commonParent).sortChildren(files);
} else {
Collections.sort(files, FILE_COMPARATOR);
}
}
public void sortChildren(List<? extends File> files) {
Collections.sort(files, FILE_COMPARATOR);
}
public boolean isAbsolute() {
......@@ -356,18 +398,131 @@ public abstract class ShellFolder extends File {
}
public static ShellFolderColumnInfo[] getFolderColumns(File dir) {
return shellFolderManager.getFolderColumns(dir);
}
ShellFolderColumnInfo[] columns = null;
public static Object getFolderColumnValue(File file, int column) {
return shellFolderManager.getFolderColumnValue(file, column);
if (dir instanceof ShellFolder) {
columns = ((ShellFolder) dir).getFolderColumns();
}
if (columns == null) {
columns = new ShellFolderColumnInfo[]{
new ShellFolderColumnInfo(COLUMN_NAME, 150,
SwingConstants.LEADING, true, null,
FILE_COMPARATOR),
new ShellFolderColumnInfo(COLUMN_SIZE, 75,
SwingConstants.RIGHT, true, null,
DEFAULT_COMPARATOR, true),
new ShellFolderColumnInfo(COLUMN_DATE, 130,
SwingConstants.LEADING, true, null,
DEFAULT_COMPARATOR, true)
};
}
return columns;
}
public ShellFolderColumnInfo[] getFolderColumns() {
return null;
}
public static Object getFolderColumnValue(File file, int column) {
if (file instanceof ShellFolder) {
Object value = ((ShellFolder)file).getFolderColumnValue(column);
if (value != null) {
return value;
}
}
if (file == null || !file.exists()) {
return null;
}
switch (column) {
case 0:
// By default, file name will be rendered using getSystemDisplayName()
return file;
case 1: // size
return file.isDirectory() ? null : Long.valueOf(file.length());
case 2: // date
if (isFileSystemRoot(file)) {
return null;
}
long time = file.lastModified();
return (time == 0L) ? null : new Date(time);
default:
return null;
}
}
public Object getFolderColumnValue(int column) {
return null;
}
/**
* Provides a default comparator for the default column set
*/
private static final Comparator DEFAULT_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
int gt;
if (o1 == null && o2 == null) {
gt = 0;
} else if (o1 != null && o2 == null) {
gt = 1;
} else if (o1 == null && o2 != null) {
gt = -1;
} else if (o1 instanceof Comparable) {
gt = ((Comparable) o1).compareTo(o2);
} else {
gt = 0;
}
return gt;
}
};
private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() {
public int compare(File f1, File f2) {
ShellFolder sf1 = null;
ShellFolder sf2 = null;
if (f1 instanceof ShellFolder) {
sf1 = (ShellFolder) f1;
if (sf1.isFileSystem()) {
sf1 = null;
}
}
if (f2 instanceof ShellFolder) {
sf2 = (ShellFolder) f2;
if (sf2.isFileSystem()) {
sf2 = null;
}
}
if (sf1 != null && sf2 != null) {
return sf1.compareTo(sf2);
} else if (sf1 != null) {
// Non-file shellfolders sort before files
return -1;
} else if (sf2 != null) {
return 1;
} else {
String name1 = f1.getName();
String name2 = f2.getName();
// First ignore case when comparing
int diff = name1.compareToIgnoreCase(name2);
if (diff != 0) {
return diff;
} else {
// May differ in case (e.g. "mail" vs. "Mail")
// We need this test for consistent sorting
return name1.compareTo(name2);
}
}
}
};
}
......@@ -27,8 +27,6 @@ package sun.awt.shell;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import javax.swing.SwingConstants;
/**
* @author Michael Martak
......@@ -36,10 +34,6 @@ import javax.swing.SwingConstants;
*/
class ShellFolderManager {
private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
/**
* Create a shell folder from a file.
* Override to return machine-dependent behavior.
......@@ -107,142 +101,4 @@ class ShellFolderManager {
}
return (dir.getParentFile() == null);
}
public void sortFiles(List files) {
Collections.sort(files, fileComparator);
}
private Comparator fileComparator = new Comparator() {
public int compare(Object a, Object b) {
return compare((File)a, (File)b);
}
public int compare(File f1, File f2) {
ShellFolder sf1 = null;
ShellFolder sf2 = null;
if (f1 instanceof ShellFolder) {
sf1 = (ShellFolder)f1;
if (sf1.isFileSystem()) {
sf1 = null;
}
}
if (f2 instanceof ShellFolder) {
sf2 = (ShellFolder)f2;
if (sf2.isFileSystem()) {
sf2 = null;
}
}
if (sf1 != null && sf2 != null) {
return sf1.compareTo(sf2);
} else if (sf1 != null) {
return -1; // Non-file shellfolders sort before files
} else if (sf2 != null) {
return 1;
} else {
String name1 = f1.getName();
String name2 = f2.getName();
// First ignore case when comparing
int diff = name1.toLowerCase().compareTo(name2.toLowerCase());
if (diff != 0) {
return diff;
} else {
// May differ in case (e.g. "mail" vs. "Mail")
// We need this test for consistent sorting
return name1.compareTo(name2);
}
}
}
};
public ShellFolderColumnInfo[] getFolderColumns(File dir) {
ShellFolderColumnInfo[] columns = null;
if (dir instanceof ShellFolder) {
columns = ((ShellFolder)dir).getFolderColumns();
}
if (columns == null) {
columns = new ShellFolderColumnInfo[]{
new ShellFolderColumnInfo(COLUMN_NAME, 150,
SwingConstants.LEADING, true, null,
fileComparator),
new ShellFolderColumnInfo(COLUMN_SIZE, 75,
SwingConstants.RIGHT, true, null,
ComparableComparator.getInstance(), true),
new ShellFolderColumnInfo(COLUMN_DATE, 130,
SwingConstants.LEADING, true, null,
ComparableComparator.getInstance(), true)
};
}
return columns;
}
public Object getFolderColumnValue(File file, int column) {
if (file instanceof ShellFolder) {
Object value = ((ShellFolder)file).getFolderColumnValue(column);
if (value != null) {
return value;
}
}
if (file == null || !file.exists()) {
return null;
}
switch (column) {
case 0:
// By default, file name will be rendered using getSystemDisplayName()
return file;
case 1: // size
return file.isDirectory() ? null : new Long(file.length());
case 2: // date
if (isFileSystemRoot(file)) {
return null;
}
long time = file.lastModified();
return (time == 0L) ? null : new Date(time);
default:
return null;
}
}
/**
* This class provides a default comparator for the default column set
*/
private static class ComparableComparator implements Comparator {
private static Comparator instance;
public static Comparator getInstance() {
if (instance == null) {
instance = new ComparableComparator();
}
return instance;
}
public int compare(Object o1, Object o2) {
int gt;
if (o1 == null && o2 == null) {
gt = 0;
} else if (o1 != null && o2 == null) {
gt = 1;
} else if (o1 == null && o2 != null) {
gt = -1;
} else if (o1 instanceof Comparable) {
gt = ((Comparable) o1).compareTo(o2);
} else {
gt = 0;
}
return gt;
}
}
}
......@@ -306,7 +306,7 @@ final class Win32ShellFolder2 extends ShellFolder {
* <code>java.io.File</code> instead. If not, then the object depends
* on native PIDL state and should not be serialized.
*
* @returns a <code>java.io.File</code> replacement object. If the folder
* @return a <code>java.io.File</code> replacement object. If the folder
* is a not a normal directory, then returns the first non-removable
* drive (normally "C:\").
*/
......@@ -605,10 +605,10 @@ final class Win32ShellFolder2 extends ShellFolder {
// parent so we have an IShellFolder to query.
long pIShellFolder = getIShellFolder();
// Now we can enumerate the objects in this folder.
ArrayList list = new ArrayList();
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
long pEnumObjects = getEnumObjects(pIShellFolder, includeHiddenFiles);
if (pEnumObjects != 0) {
long childPIDL = 0;
long childPIDL;
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
do {
if (Thread.currentThread().isInterrupted()) {
......@@ -635,7 +635,7 @@ final class Win32ShellFolder2 extends ShellFolder {
} while (childPIDL != 0);
releaseEnumObjects(pEnumObjects);
}
return (ShellFolder[])list.toArray(new ShellFolder[list.size()]);
return list.toArray(new ShellFolder[list.size()]);
}
......@@ -648,7 +648,7 @@ final class Win32ShellFolder2 extends ShellFolder {
long pIShellFolder = getIShellFolder();
long pEnumObjects = getEnumObjects(pIShellFolder, true);
Win32ShellFolder2 child = null;
long childPIDL = 0;
long childPIDL;
while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
......@@ -983,7 +983,7 @@ final class Win32ShellFolder2 extends ShellFolder {
? SwingConstants.CENTER
: SwingConstants.LEADING);
column.setComparator(new ColumnComparator(i));
column.setComparator(new ColumnComparator(getIShellFolder(), i));
notNullColumns.add(column);
}
......@@ -1002,22 +1002,29 @@ final class Win32ShellFolder2 extends ShellFolder {
private native Object doGetColumnValue(long parentIShellFolder2, long childPIDL, int columnIdx);
private native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx);
private static native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx);
private class ColumnComparator implements Comparator {
public void sortChildren(List<? extends File> files) {
Collections.sort(files, new ColumnComparator(getIShellFolder(), 0));
}
private static class ColumnComparator implements Comparator<File> {
private final long parentIShellFolder;
private final int columnIdx;
public ColumnComparator(int columnIdx) {
public ColumnComparator(long parentIShellFolder, int columnIdx) {
this.parentIShellFolder = parentIShellFolder;
this.columnIdx = columnIdx;
}
// compares 2 objects within this folder by the specified column
public int compare(Object o, Object o1) {
public int compare(File o, File o1) {
if (o instanceof Win32ShellFolder2
&& o1 instanceof Win32ShellFolder2) {
// delegates comparison to native method
return compareIDsByColumn(getIShellFolder(),
return compareIDsByColumn(parentIShellFolder,
((Win32ShellFolder2) o).getRelativePIDL(),
((Win32ShellFolder2) o1).getRelativePIDL(),
columnIdx);
......
......@@ -234,11 +234,11 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
// Add third level for "My Computer"
if (folder.equals(drives)) {
File[] thirdLevelFolders = folder.listFiles();
if (thirdLevelFolders != null) {
Arrays.sort(thirdLevelFolders, driveComparator);
for (File thirdLevelFolder : thirdLevelFolders) {
folders.add(thirdLevelFolder);
}
if (thirdLevelFolders != null && thirdLevelFolders.length > 0) {
List<File> thirdLevelFoldersList = Arrays.asList(thirdLevelFolders);
folder.sortChildren(thirdLevelFoldersList);
folders.addAll(thirdLevelFoldersList);
}
}
}
......@@ -362,27 +362,6 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
return false;
}
private Comparator driveComparator = new Comparator() {
public int compare(Object o1, Object o2) {
Win32ShellFolder2 shellFolder1 = (Win32ShellFolder2) o1;
Win32ShellFolder2 shellFolder2 = (Win32ShellFolder2) o2;
// Put drives at first
boolean isDrive1 = shellFolder1.getPath().endsWith(":\\");
if (isDrive1 ^ shellFolder2.getPath().endsWith(":\\")) {
return isDrive1 ? -1 : 1;
} else {
return shellFolder1.getPath().compareTo(shellFolder2.getPath());
}
}
};
public void sortFiles(List files) {
Collections.sort(files, fileComparator);
}
private static List topFolderList = null;
static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) {
boolean special1 = sf1.isSpecial();
......@@ -418,19 +397,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
return compareNames(sf1.getAbsolutePath(), sf2.getAbsolutePath());
}
static int compareFiles(File f1, File f2) {
if (f1 instanceof Win32ShellFolder2) {
return f1.compareTo(f2);
}
if (f2 instanceof Win32ShellFolder2) {
return -1 * f2.compareTo(f1);
}
return compareNames(f1.getName(), f2.getName());
}
static int compareNames(String name1, String name2) {
// First ignore case when comparing
int diff = name1.toLowerCase().compareTo(name2.toLowerCase());
int diff = name1.compareToIgnoreCase(name2);
if (diff != 0) {
return diff;
} else {
......@@ -439,14 +408,4 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
return name1.compareTo(name2);
}
}
private Comparator fileComparator = new Comparator() {
public int compare(Object a, Object b) {
return compare((File)a, (File)b);
}
public int compare(File f1, File f2) {
return compareFiles(f1, f2);
}
};
}
......@@ -3464,6 +3464,21 @@ UINT AwtComponent::WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers)
return java_awt_event_KeyEvent_VK_UNDEFINED;
}
BOOL AwtComponent::IsNavigationKey(UINT wkey) {
switch (wkey) {
case VK_END:
case VK_PRIOR: // PageUp
case VK_NEXT: // PageDown
case VK_HOME:
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
return TRUE;
}
return FALSE;
}
// determine if a key is a numpad key (distinguishes the numpad
// arrow keys from the non-numpad arrow keys, for example).
BOOL AwtComponent::IsNumPadKey(UINT vkey, BOOL extended)
......@@ -3563,7 +3578,10 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops)
// fix for 4623376,4737679,4501485,4740906,4708221 (4173679/4122715)
// Here we try to resolve a conflict with ::ToAsciiEx's translating
// ALT+number key combinations. kdm@sarc.spb.su
keyboardState[VK_MENU] &= ~KEY_STATE_DOWN;
// yan: Do it for navigation keys only, otherwise some AltGr deadkeys fail.
if( IsNavigationKey(wkey) ) {
keyboardState[VK_MENU] &= ~KEY_STATE_DOWN;
}
if (ctrlIsDown)
{
......
......@@ -823,6 +823,7 @@ public:
private:
AwtComponent* SearchChild(UINT id);
void RemoveChild(UINT id) ;
static BOOL IsNavigationKey(UINT wkey);
ChildListItem* m_childList;
......
/*
* Copyright 2008 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 6708550
* @summary Tests File encoding
* @author Sergey Malenkov
*/
import java.io.File;
public final class java_io_File extends AbstractTest<File> {
public static void main(String[] args) {
new java_io_File().test(true);
}
@Override
protected File getObject() {
return new File("test.txt"); // NON-NLS: local file
}
@Override
protected File getAnotherObject() {
return new File("/pub/demo/"); // NON-NLS: path
}
}
/*
* Copyright 2008 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 6694823
* @summary Checks that popup menu cannot be partially hidden
* by the task bar in applets.
* @author Mikhail Lapshin
* @run main bug6694823
*/
import javax.swing.*;
import java.awt.*;
import sun.awt.SunToolkit;
public class bug6694823 {
private static JFrame frame;
private static JPopupMenu popup;
private static SunToolkit toolkit;
private static Insets screenInsets;
public static void main(String[] args) throws Exception {
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGui();
}
});
// Get screen insets
screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
if (screenInsets.bottom == 0) {
// This test is only for configurations with taskbar on the bottom
return;
}
// Show popup as if from a standalone application
// The popup should be able to overlap the task bar
showPopup(false);
// Emulate applet security restrictions
toolkit.realSync();
System.setSecurityManager(new SecurityManager());
// Show popup as if from an applet
// The popup shouldn't overlap the task bar. It should be shifted up.
showPopup(true);
toolkit.realSync();
System.out.println("Test passed!");
frame.dispose();
}
private static void createGui() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setUndecorated(true);
popup = new JPopupMenu("Menu");
for (int i = 0; i < 7; i++) {
popup.add(new JMenuItem("MenuItem"));
}
JPanel panel = new JPanel();
panel.setComponentPopupMenu(popup);
frame.add(panel);
frame.setSize(200, 200);
}
private static void showPopup(final boolean shouldBeShifted) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Place frame just above the task bar
Dimension screenSize = toolkit.getScreenSize();
frame.setLocation(screenSize.width / 2,
screenSize.height - frame.getHeight() - screenInsets.bottom);
frame.setVisible(true);
// Place popup over the task bar
Point frameLoc = frame.getLocationOnScreen();
int x = 0;
int y = frame.getHeight()
- popup.getPreferredSize().height + screenInsets.bottom;
popup.show(frame, x, y);
if (shouldBeShifted) {
if (popup.getLocationOnScreen()
.equals(new Point(frameLoc.x, frameLoc.y + y))) {
throw new RuntimeException("Popup is not shifted");
}
} else {
if (!popup.getLocationOnScreen()
.equals(new Point(frameLoc.x, frameLoc.y + y))) {
throw new RuntimeException("Popup is unexpectedly shifted");
}
}
popup.setVisible(false);
}
});
}
}
<html>
<body>
<applet code="bug4987336.class" width=600 height=400></applet>
There are four Sliders. Each of them has a label with animated gif (a cup of coffee)
and a label with static image.
Check that for every LAF animation works for all Sliders.
</body>
</html>
/*
* Copyright 2007 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 4987336
@summary JSlider doesn't show label's animated icon.
@author Pavel Porvatov
@run applet/manual=done bug4987336.html
*/
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Hashtable;
public class bug4987336 extends JApplet {
private static final String IMAGE_RES = "box.gif";
private static final String ANIM_IMAGE_RES = "cupanim.gif";
public void init() {
JPanel pnLafs = new JPanel();
pnLafs.setLayout(new BoxLayout(pnLafs, BoxLayout.Y_AXIS));
ButtonGroup group = new ButtonGroup();
pnLafs.setBorder(new TitledBorder("Available Lafs"));
for (UIManager.LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) {
LafRadioButton comp = new LafRadioButton(lafInfo);
pnLafs.add(comp);
group.add(comp);
}
JPanel pnContent = new JPanel();
pnContent.setLayout(new BoxLayout(pnContent, BoxLayout.Y_AXIS));
pnContent.add(pnLafs);
pnContent.add(createSlider(true, IMAGE_RES, IMAGE_RES, ANIM_IMAGE_RES, ANIM_IMAGE_RES));
pnContent.add(createSlider(false, IMAGE_RES, IMAGE_RES, ANIM_IMAGE_RES, ANIM_IMAGE_RES));
pnContent.add(createSlider(true, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
pnContent.add(createSlider(false, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
getContentPane().add(new JScrollPane(pnContent));
}
private static JSlider createSlider(boolean enabled,
String firstEnabledImage, String firstDisabledImage,
String secondEnabledImage, String secondDisabledImage) {
Hashtable<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
dictionary.put(0, createLabel(firstEnabledImage, firstDisabledImage));
dictionary.put(1, createLabel(secondEnabledImage, secondDisabledImage));
JSlider result = new JSlider(0, 1);
result.setLabelTable(dictionary);
result.setPaintLabels(true);
result.setEnabled(enabled);
return result;
}
private static JLabel createLabel(String enabledImage, String disabledImage) {
ImageIcon enabledIcon = enabledImage == null ? null :
new ImageIcon(bug4987336.class.getResource(enabledImage));
ImageIcon disabledIcon = disabledImage == null ? null :
new ImageIcon(bug4987336.class.getResource(disabledImage));
JLabel result = new JLabel(enabledImage == null && disabledImage == null ? "No image" : "Image",
enabledIcon, SwingConstants.LEFT);
result.setDisabledIcon(disabledIcon);
return result;
}
private class LafRadioButton extends JRadioButton {
public LafRadioButton(final UIManager.LookAndFeelInfo lafInfo) {
super(lafInfo.getName(), lafInfo.getName().equals(UIManager.getLookAndFeel().getName()));
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
UIManager.setLookAndFeel(lafInfo.getClassName());
SwingUtilities.updateComponentTreeUI(bug4987336.this);
} catch (Exception ex) {
// Ignore such errors
System.out.println("Cannot set LAF " + lafInfo.getName());
}
}
});
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册