mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
Merge
This commit is contained in:
commit
bc02d891d1
26 changed files with 958 additions and 504 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -739,6 +739,11 @@ public class JFileChooser extends JComponent implements Accessible {
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
firePropertyChange("JFileChooserDialogIsClosingProperty", dialog, null);
|
firePropertyChange("JFileChooserDialogIsClosingProperty", dialog, null);
|
||||||
|
|
||||||
|
// Remove all components from dialog. The MetalFileChooserUI.installUI() method (and other LAFs)
|
||||||
|
// registers AWT listener for dialogs and produces memory leaks. It happens when
|
||||||
|
// installUI invoked after the showDialog method.
|
||||||
|
dialog.getContentPane().removeAll();
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
dialog = null;
|
dialog = null;
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
|
|
@ -26,13 +26,10 @@
|
||||||
package javax.swing;
|
package javax.swing;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
|
||||||
|
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.EventListener;
|
|
||||||
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
import javax.swing.event.InternalFrameEvent;
|
import javax.swing.event.InternalFrameEvent;
|
||||||
import javax.swing.event.InternalFrameListener;
|
import javax.swing.event.InternalFrameListener;
|
||||||
import javax.swing.plaf.*;
|
import javax.swing.plaf.*;
|
||||||
|
@ -40,7 +37,6 @@ import javax.swing.plaf.*;
|
||||||
import javax.accessibility.*;
|
import javax.accessibility.*;
|
||||||
|
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.StringBuilder;
|
import java.lang.StringBuilder;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
|
@ -1459,19 +1455,22 @@ public class JInternalFrame extends JComponent implements
|
||||||
SwingUtilities2.compositeRequestFocus(getDesktopIcon());
|
SwingUtilities2.compositeRequestFocus(getDesktopIcon());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// FocusPropertyChangeListener will eventually update
|
Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
|
||||||
// lastFocusOwner. As focus requests are asynchronous
|
if ((component == null) || !SwingUtilities.isDescendingFrom(component, this)) {
|
||||||
// lastFocusOwner may be accessed before it has been correctly
|
// FocusPropertyChangeListener will eventually update
|
||||||
// updated. To avoid any problems, lastFocusOwner is immediately
|
// lastFocusOwner. As focus requests are asynchronous
|
||||||
// set, assuming the request will succeed.
|
// lastFocusOwner may be accessed before it has been correctly
|
||||||
lastFocusOwner = getMostRecentFocusOwner();
|
// updated. To avoid any problems, lastFocusOwner is immediately
|
||||||
if (lastFocusOwner == null) {
|
// set, assuming the request will succeed.
|
||||||
// Make sure focus is restored somewhere, so that
|
setLastFocusOwner(getMostRecentFocusOwner());
|
||||||
// we don't leave a focused component in another frame while
|
if (lastFocusOwner == null) {
|
||||||
// this frame is selected.
|
// Make sure focus is restored somewhere, so that
|
||||||
lastFocusOwner = getContentPane();
|
// we don't leave a focused component in another frame while
|
||||||
|
// this frame is selected.
|
||||||
|
setLastFocusOwner(getContentPane());
|
||||||
|
}
|
||||||
|
lastFocusOwner.requestFocus();
|
||||||
}
|
}
|
||||||
lastFocusOwner.requestFocus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -32,9 +32,6 @@ import javax.swing.event.*;
|
||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
import javax.swing.plaf.*;
|
import javax.swing.plaf.*;
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.util.EventListener;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic L&F for a minimized window on a desktop.
|
* Basic L&F for a minimized window on a desktop.
|
||||||
|
@ -47,7 +44,6 @@ public class BasicDesktopIconUI extends DesktopIconUI {
|
||||||
|
|
||||||
protected JInternalFrame.JDesktopIcon desktopIcon;
|
protected JInternalFrame.JDesktopIcon desktopIcon;
|
||||||
protected JInternalFrame frame;
|
protected JInternalFrame frame;
|
||||||
private DesktopIconMover desktopIconMover;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The title pane component used in the desktop icon.
|
* The title pane component used in the desktop icon.
|
||||||
|
@ -128,21 +124,12 @@ public class BasicDesktopIconUI extends DesktopIconUI {
|
||||||
mouseInputListener = createMouseInputListener();
|
mouseInputListener = createMouseInputListener();
|
||||||
desktopIcon.addMouseMotionListener(mouseInputListener);
|
desktopIcon.addMouseMotionListener(mouseInputListener);
|
||||||
desktopIcon.addMouseListener(mouseInputListener);
|
desktopIcon.addMouseListener(mouseInputListener);
|
||||||
getDesktopIconMover().installListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void uninstallListeners() {
|
protected void uninstallListeners() {
|
||||||
desktopIcon.removeMouseMotionListener(mouseInputListener);
|
desktopIcon.removeMouseMotionListener(mouseInputListener);
|
||||||
desktopIcon.removeMouseListener(mouseInputListener);
|
desktopIcon.removeMouseListener(mouseInputListener);
|
||||||
mouseInputListener = null;
|
mouseInputListener = null;
|
||||||
getDesktopIconMover().uninstallListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DesktopIconMover getDesktopIconMover() {
|
|
||||||
if (desktopIconMover == null) {
|
|
||||||
desktopIconMover = new DesktopIconMover(desktopIcon);
|
|
||||||
}
|
|
||||||
return desktopIconMover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -232,6 +232,10 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
|
||||||
public void run0() {
|
public void run0() {
|
||||||
FileSystemView fileSystem = filechooser.getFileSystemView();
|
FileSystemView fileSystem = filechooser.getFileSystemView();
|
||||||
|
|
||||||
|
if (isInterrupted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
|
File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
|
||||||
|
|
||||||
if (isInterrupted()) {
|
if (isInterrupted()) {
|
||||||
|
@ -268,8 +272,8 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
|
||||||
|
|
||||||
// To avoid loads of synchronizations with Invoker and improve performance we
|
// To avoid loads of synchronizations with Invoker and improve performance we
|
||||||
// execute the whole block on the COM thread
|
// execute the whole block on the COM thread
|
||||||
DoChangeContents doChangeContents = ShellFolder.getInvoker().invoke(new Callable<DoChangeContents>() {
|
DoChangeContents doChangeContents = ShellFolder.invoke(new Callable<DoChangeContents>() {
|
||||||
public DoChangeContents call() throws Exception {
|
public DoChangeContents call() {
|
||||||
int newSize = newFileCache.size();
|
int newSize = newFileCache.size();
|
||||||
int oldSize = fileCache.size();
|
int oldSize = fileCache.size();
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,10 @@ package javax.swing.plaf.basic;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.peer.LightweightPeer;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.*;
|
|
||||||
import javax.swing.plaf.*;
|
import javax.swing.plaf.*;
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
|
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import sun.swing.DefaultLookup;
|
import sun.swing.DefaultLookup;
|
||||||
import sun.swing.UIAction;
|
import sun.swing.UIAction;
|
||||||
|
|
||||||
|
@ -55,6 +49,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
protected MouseInputAdapter borderListener;
|
protected MouseInputAdapter borderListener;
|
||||||
protected PropertyChangeListener propertyChangeListener;
|
protected PropertyChangeListener propertyChangeListener;
|
||||||
protected LayoutManager internalFrameLayout;
|
protected LayoutManager internalFrameLayout;
|
||||||
|
protected ComponentListener componentListener;
|
||||||
protected MouseInputListener glassPaneDispatcher;
|
protected MouseInputListener glassPaneDispatcher;
|
||||||
private InternalFrameListener internalFrameListener;
|
private InternalFrameListener internalFrameListener;
|
||||||
|
|
||||||
|
@ -66,9 +61,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
protected BasicInternalFrameTitlePane titlePane; // access needs this
|
protected BasicInternalFrameTitlePane titlePane; // access needs this
|
||||||
|
|
||||||
private static DesktopManager sharedDesktopManager;
|
private static DesktopManager sharedDesktopManager;
|
||||||
|
private boolean componentListenerAdded = false;
|
||||||
|
|
||||||
private Rectangle parentBounds;
|
private Rectangle parentBounds;
|
||||||
private DesktopIconMover desktopIconMover;
|
|
||||||
|
|
||||||
private boolean dragging = false;
|
private boolean dragging = false;
|
||||||
private boolean resizing = false;
|
private boolean resizing = false;
|
||||||
|
@ -209,17 +204,14 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
frame.getGlassPane().addMouseListener(glassPaneDispatcher);
|
frame.getGlassPane().addMouseListener(glassPaneDispatcher);
|
||||||
frame.getGlassPane().addMouseMotionListener(glassPaneDispatcher);
|
frame.getGlassPane().addMouseMotionListener(glassPaneDispatcher);
|
||||||
}
|
}
|
||||||
|
componentListener = createComponentListener();
|
||||||
if (frame.getParent() != null) {
|
if (frame.getParent() != null) {
|
||||||
parentBounds = frame.getParent().getBounds();
|
parentBounds = frame.getParent().getBounds();
|
||||||
}
|
}
|
||||||
getDesktopIconMover().installListeners();
|
if ((frame.getParent() != null) && !componentListenerAdded) {
|
||||||
}
|
frame.getParent().addComponentListener(componentListener);
|
||||||
|
componentListenerAdded = true;
|
||||||
private DesktopIconMover getDesktopIconMover() {
|
|
||||||
if (desktopIconMover == null) {
|
|
||||||
desktopIconMover = new DesktopIconMover(frame);
|
|
||||||
}
|
}
|
||||||
return desktopIconMover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide a FocusListener to listen for a WINDOW_LOST_FOCUS event,
|
// Provide a FocusListener to listen for a WINDOW_LOST_FOCUS event,
|
||||||
|
@ -290,7 +282,11 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
* @since 1.3
|
* @since 1.3
|
||||||
*/
|
*/
|
||||||
protected void uninstallListeners() {
|
protected void uninstallListeners() {
|
||||||
getDesktopIconMover().uninstallListeners();
|
if ((frame.getParent() != null) && componentListenerAdded) {
|
||||||
|
frame.getParent().removeComponentListener(componentListener);
|
||||||
|
componentListenerAdded = false;
|
||||||
|
}
|
||||||
|
componentListener = null;
|
||||||
if (glassPaneDispatcher != null) {
|
if (glassPaneDispatcher != null) {
|
||||||
frame.getGlassPane().removeMouseListener(glassPaneDispatcher);
|
frame.getGlassPane().removeMouseListener(glassPaneDispatcher);
|
||||||
frame.getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
|
frame.getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
|
||||||
|
@ -1228,6 +1224,15 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Relocate the icon base on the new parent bounds.
|
||||||
|
if (icon != null) {
|
||||||
|
Rectangle iconBounds = icon.getBounds();
|
||||||
|
int y = iconBounds.y +
|
||||||
|
(parentNewBounds.height - parentBounds.height);
|
||||||
|
icon.setBounds(iconBounds.x, y,
|
||||||
|
iconBounds.width, iconBounds.height);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the new parent bounds for next resize.
|
// Update the new parent bounds for next resize.
|
||||||
if (!parentBounds.equals(parentNewBounds)) {
|
if (!parentBounds.equals(parentNewBounds)) {
|
||||||
parentBounds = parentNewBounds;
|
parentBounds = parentNewBounds;
|
||||||
|
@ -1399,6 +1404,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
// Cancel a resize in progress if the internal frame
|
// Cancel a resize in progress if the internal frame
|
||||||
// gets a setClosed(true) or dispose().
|
// gets a setClosed(true) or dispose().
|
||||||
cancelResize();
|
cancelResize();
|
||||||
|
if ((frame.getParent() != null) && componentListenerAdded) {
|
||||||
|
frame.getParent().removeComponentListener(componentListener);
|
||||||
|
}
|
||||||
closeFrame(f);
|
closeFrame(f);
|
||||||
}
|
}
|
||||||
} else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {
|
} else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {
|
||||||
|
@ -1431,6 +1439,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||||
} else {
|
} else {
|
||||||
parentBounds = null;
|
parentBounds = null;
|
||||||
}
|
}
|
||||||
|
if ((frame.getParent() != null) && !componentListenerAdded) {
|
||||||
|
f.getParent().addComponentListener(componentListener);
|
||||||
|
componentListenerAdded = true;
|
||||||
|
}
|
||||||
} else if (JInternalFrame.TITLE_PROPERTY == prop ||
|
} else if (JInternalFrame.TITLE_PROPERTY == prop ||
|
||||||
prop == "closable" || prop == "iconable" ||
|
prop == "closable" || prop == "iconable" ||
|
||||||
prop == "maximizable") {
|
prop == "maximizable") {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 1997-2005 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -37,17 +37,12 @@ import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
|
||||||
import java.awt.LayoutManager;
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.ComponentOrientation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A default L&F implementation of ScrollPaneUI.
|
* A default L&F implementation of ScrollPaneUI.
|
||||||
|
@ -63,6 +58,7 @@ public class BasicScrollPaneUI
|
||||||
protected ChangeListener viewportChangeListener;
|
protected ChangeListener viewportChangeListener;
|
||||||
protected PropertyChangeListener spPropertyChangeListener;
|
protected PropertyChangeListener spPropertyChangeListener;
|
||||||
private MouseWheelListener mouseScrollListener;
|
private MouseWheelListener mouseScrollListener;
|
||||||
|
private int oldExtent = Integer.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PropertyChangeListener installed on the vertical scrollbar.
|
* PropertyChangeListener installed on the vertical scrollbar.
|
||||||
|
@ -327,9 +323,13 @@ public class BasicScrollPaneUI
|
||||||
* leave it until someone claims.
|
* leave it until someone claims.
|
||||||
*/
|
*/
|
||||||
value = Math.max(0, Math.min(max - extent, max - extent - viewPosition.x));
|
value = Math.max(0, Math.min(max - extent, max - extent - viewPosition.x));
|
||||||
|
if (oldExtent > extent) {
|
||||||
|
value -= oldExtent - extent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oldExtent = extent;
|
||||||
hsb.setValues(value, extent, 0, max);
|
hsb.setValues(value, extent, 0, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,7 +1020,7 @@ public class BasicScrollPaneUI
|
||||||
|
|
||||||
if (viewport != null) {
|
if (viewport != null) {
|
||||||
if (e.getSource() == viewport) {
|
if (e.getSource() == viewport) {
|
||||||
viewportStateChanged(e);
|
syncScrollPaneWithViewport();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
||||||
|
@ -1077,11 +1077,6 @@ public class BasicScrollPaneUI
|
||||||
viewport.setViewPosition(p);
|
viewport.setViewPosition(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void viewportStateChanged(ChangeEvent e) {
|
|
||||||
syncScrollPaneWithViewport();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PropertyChangeListener: This is installed on both the JScrollPane
|
// PropertyChangeListener: This is installed on both the JScrollPane
|
||||||
// and the horizontal/vertical scrollbars.
|
// and the horizontal/vertical scrollbars.
|
||||||
|
|
|
@ -1,168 +0,0 @@
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package javax.swing.plaf.basic;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.*;
|
|
||||||
import java.beans.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DesktopIconMover is intended to move desktop icon
|
|
||||||
* when parent window is resized.
|
|
||||||
*/
|
|
||||||
class DesktopIconMover implements ComponentListener, PropertyChangeListener {
|
|
||||||
private Component parent;
|
|
||||||
private JInternalFrame frame; // if not null, DesktopIconMover(frame)
|
|
||||||
// constructor was used
|
|
||||||
private JInternalFrame.JDesktopIcon icon;
|
|
||||||
private Rectangle parentBounds;
|
|
||||||
private boolean componentListenerAdded = false;
|
|
||||||
|
|
||||||
public DesktopIconMover(JInternalFrame frame) {
|
|
||||||
if (frame == null) {
|
|
||||||
throw new NullPointerException("Frame cannot be null");
|
|
||||||
}
|
|
||||||
this.frame = frame;
|
|
||||||
this.icon = frame.getDesktopIcon();
|
|
||||||
if (icon == null) {
|
|
||||||
throw new NullPointerException(
|
|
||||||
"frame.getDesktopIcon() cannot be null");
|
|
||||||
}
|
|
||||||
this.parent = frame.getParent();
|
|
||||||
if (this.parent != null) {
|
|
||||||
parentBounds = this.parent.getBounds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DesktopIconMover(JInternalFrame.JDesktopIcon icon) {
|
|
||||||
if (icon == null) {
|
|
||||||
throw new NullPointerException("Icon cannot be null");
|
|
||||||
}
|
|
||||||
this.icon = icon;
|
|
||||||
this.parent = icon.getParent();
|
|
||||||
if (this.parent != null) {
|
|
||||||
parentBounds = this.parent.getBounds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void installListeners() {
|
|
||||||
if (frame != null) {
|
|
||||||
frame.addPropertyChangeListener(this);
|
|
||||||
} else {
|
|
||||||
icon.addPropertyChangeListener(this);
|
|
||||||
}
|
|
||||||
addComponentListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void uninstallListeners() {
|
|
||||||
if (frame != null) {
|
|
||||||
frame.removePropertyChangeListener(this);
|
|
||||||
} else {
|
|
||||||
icon.removePropertyChangeListener(this);
|
|
||||||
}
|
|
||||||
removeComponentListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
|
||||||
String propName = evt.getPropertyName();
|
|
||||||
if ("ancestor".equals(propName)) {
|
|
||||||
Component newAncestor = (Component) evt.getNewValue();
|
|
||||||
|
|
||||||
// Remove component listener if parent is changing
|
|
||||||
Component probablyNewParent = getCurrentParent();
|
|
||||||
if ((probablyNewParent != null) &&
|
|
||||||
(!probablyNewParent.equals(parent))) {
|
|
||||||
removeComponentListener();
|
|
||||||
parent = probablyNewParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newAncestor == null) {
|
|
||||||
removeComponentListener();
|
|
||||||
} else {
|
|
||||||
addComponentListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update parentBounds
|
|
||||||
if (parent != null) {
|
|
||||||
parentBounds = parent.getBounds();
|
|
||||||
} else {
|
|
||||||
parentBounds = null;
|
|
||||||
}
|
|
||||||
} else if (JInternalFrame.IS_CLOSED_PROPERTY.equals(propName)) {
|
|
||||||
removeComponentListener();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addComponentListener() {
|
|
||||||
if (!componentListenerAdded && (parent != null)) {
|
|
||||||
parent.addComponentListener(this);
|
|
||||||
componentListenerAdded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeComponentListener() {
|
|
||||||
if ((parent != null) && componentListenerAdded) {
|
|
||||||
parent.removeComponentListener(this);
|
|
||||||
componentListenerAdded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Component getCurrentParent() {
|
|
||||||
if (frame != null) {
|
|
||||||
return frame.getParent();
|
|
||||||
} else {
|
|
||||||
return icon.getParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
if ((parent == null) || (parentBounds == null)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle parentNewBounds = parent.getBounds();
|
|
||||||
if ((parentNewBounds == null) || parentNewBounds.equals(parentBounds)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move desktop icon only in up-down direction
|
|
||||||
int newIconY = icon.getLocation().y +
|
|
||||||
(parentNewBounds.height - parentBounds.height);
|
|
||||||
icon.setLocation(icon.getLocation().x, newIconY);
|
|
||||||
|
|
||||||
parentBounds = parentNewBounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void componentMoved(ComponentEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void componentShown(ComponentEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void componentHidden(ComponentEvent e) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -227,10 +227,10 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
*
|
*
|
||||||
* @param x an encoded x value (0...1, or 1...2, or 2...3)
|
* @param x an encoded x value (0...1, or 1...2, or 2...3)
|
||||||
* @return the decoded x value
|
* @return the decoded x value
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if {@code x < 0} or {@code x > 3}
|
||||||
*/
|
*/
|
||||||
protected final float decodeX(float x) {
|
protected final float decodeX(float x) {
|
||||||
if (ctx.canvasSize == null) return x;
|
|
||||||
|
|
||||||
if (x >= 0 && x <= 1) {
|
if (x >= 0 && x <= 1) {
|
||||||
return x * leftWidth;
|
return x * leftWidth;
|
||||||
} else if (x > 1 && x < 2) {
|
} else if (x > 1 && x < 2) {
|
||||||
|
@ -238,7 +238,7 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
} else if (x >= 2 && x <= 3) {
|
} else if (x >= 2 && x <= 3) {
|
||||||
return ((x-2) * rightWidth) + leftWidth + centerWidth;
|
return ((x-2) * rightWidth) + leftWidth + centerWidth;
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Invalid x");
|
throw new IllegalArgumentException("Invalid x");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,10 +248,10 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
*
|
*
|
||||||
* @param y an encoded y value (0...1, or 1...2, or 2...3)
|
* @param y an encoded y value (0...1, or 1...2, or 2...3)
|
||||||
* @return the decoded y value
|
* @return the decoded y value
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if {@code y < 0} or {@code y > 3}
|
||||||
*/
|
*/
|
||||||
protected final float decodeY(float y) {
|
protected final float decodeY(float y) {
|
||||||
if (ctx.canvasSize == null) return y;
|
|
||||||
|
|
||||||
if (y >= 0 && y <= 1) {
|
if (y >= 0 && y <= 1) {
|
||||||
return y * topHeight;
|
return y * topHeight;
|
||||||
} else if (y > 1 && y < 2) {
|
} else if (y > 1 && y < 2) {
|
||||||
|
@ -259,7 +259,7 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
} else if (y >= 2 && y <= 3) {
|
} else if (y >= 2 && y <= 3) {
|
||||||
return ((y-2) * bottomHeight) + topHeight + centerHeight;
|
return ((y-2) * bottomHeight) + topHeight + centerHeight;
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Invalid y");
|
throw new IllegalArgumentException("Invalid y");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,10 +271,10 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
* @param x an encoded x value of the bezier control point (0...1, or 1...2, or 2...3)
|
* @param x an encoded x value of the bezier control point (0...1, or 1...2, or 2...3)
|
||||||
* @param dx the offset distance to the anchor from the control point x
|
* @param dx the offset distance to the anchor from the control point x
|
||||||
* @return the decoded x location of the control point
|
* @return the decoded x location of the control point
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if {@code x < 0} or {@code x > 3}
|
||||||
*/
|
*/
|
||||||
protected final float decodeAnchorX(float x, float dx) {
|
protected final float decodeAnchorX(float x, float dx) {
|
||||||
if (ctx.canvasSize == null) return x + dx;
|
|
||||||
|
|
||||||
if (x >= 0 && x <= 1) {
|
if (x >= 0 && x <= 1) {
|
||||||
return decodeX(x) + (dx * leftScale);
|
return decodeX(x) + (dx * leftScale);
|
||||||
} else if (x > 1 && x < 2) {
|
} else if (x > 1 && x < 2) {
|
||||||
|
@ -282,7 +282,7 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
} else if (x >= 2 && x <= 3) {
|
} else if (x >= 2 && x <= 3) {
|
||||||
return decodeX(x) + (dx * rightScale);
|
return decodeX(x) + (dx * rightScale);
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Invalid x");
|
throw new IllegalArgumentException("Invalid x");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,10 +294,10 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
* @param y an encoded y value of the bezier control point (0...1, or 1...2, or 2...3)
|
* @param y an encoded y value of the bezier control point (0...1, or 1...2, or 2...3)
|
||||||
* @param dy the offset distance to the anchor from the control point y
|
* @param dy the offset distance to the anchor from the control point y
|
||||||
* @return the decoded y position of the control point
|
* @return the decoded y position of the control point
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if {@code y < 0} or {@code y > 3}
|
||||||
*/
|
*/
|
||||||
protected final float decodeAnchorY(float y, float dy) {
|
protected final float decodeAnchorY(float y, float dy) {
|
||||||
if (ctx.canvasSize == null) return y + dy;
|
|
||||||
|
|
||||||
if (y >= 0 && y <= 1) {
|
if (y >= 0 && y <= 1) {
|
||||||
return decodeY(y) + (dy * topScale);
|
return decodeY(y) + (dy * topScale);
|
||||||
} else if (y > 1 && y < 2) {
|
} else if (y > 1 && y < 2) {
|
||||||
|
@ -305,7 +305,7 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
} else if (y >= 2 && y <= 3) {
|
} else if (y >= 2 && y <= 3) {
|
||||||
return decodeY(y) + (dy * bottomScale);
|
return decodeY(y) + (dy * bottomScale);
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Invalid y");
|
throw new IllegalArgumentException("Invalid y");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +363,15 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
* @param midpoints
|
* @param midpoints
|
||||||
* @param colors
|
* @param colors
|
||||||
* @return a valid LinearGradientPaint. This method never returns null.
|
* @return a valid LinearGradientPaint. This method never returns null.
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if {@code midpoints} array is null,
|
||||||
|
* or {@code colors} array is null,
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if start and end points are the same points,
|
||||||
|
* or {@code midpoints.length != colors.length},
|
||||||
|
* or {@code colors} is less than 2 in size,
|
||||||
|
* or a {@code midpoints} value is less than 0.0 or greater than 1.0,
|
||||||
|
* or the {@code midpoints} are not provided in strictly increasing order
|
||||||
*/
|
*/
|
||||||
protected final LinearGradientPaint decodeGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors) {
|
protected final LinearGradientPaint decodeGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors) {
|
||||||
if (x1 == x2 && y1 == y2) {
|
if (x1 == x2 && y1 == y2) {
|
||||||
|
@ -384,6 +393,15 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
* @param midpoints
|
* @param midpoints
|
||||||
* @param colors
|
* @param colors
|
||||||
* @return a valid RadialGradientPaint. This method never returns null.
|
* @return a valid RadialGradientPaint. This method never returns null.
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if {@code midpoints} array is null,
|
||||||
|
* or {@code colors} array is null
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* if {@code r} is non-positive,
|
||||||
|
* or {@code midpoints.length != colors.length},
|
||||||
|
* or {@code colors} is less than 2 in size,
|
||||||
|
* or a {@code midpoints} value is less than 0.0 or greater than 1.0,
|
||||||
|
* or the {@code midpoints} are not provided in strictly increasing order
|
||||||
*/
|
*/
|
||||||
protected final RadialGradientPaint decodeRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors) {
|
protected final RadialGradientPaint decodeRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors) {
|
||||||
if (r == 0f) {
|
if (r == 0f) {
|
||||||
|
@ -537,10 +555,10 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
|
||||||
this.maxVerticalScaleFactor = maxV;
|
this.maxVerticalScaleFactor = maxV;
|
||||||
|
|
||||||
if (canvasSize != null) {
|
if (canvasSize != null) {
|
||||||
a = insets.left;
|
a = stretchingInsets.left;
|
||||||
b = canvasSize.width - insets.right;
|
b = canvasSize.width - stretchingInsets.right;
|
||||||
c = insets.top;
|
c = stretchingInsets.top;
|
||||||
d = canvasSize.height - insets.bottom;
|
d = canvasSize.height - stretchingInsets.bottom;
|
||||||
this.canvasSize = canvasSize;
|
this.canvasSize = canvasSize;
|
||||||
this.inverted = inverted;
|
this.inverted = inverted;
|
||||||
if (inverted) {
|
if (inverted) {
|
||||||
|
|
|
@ -84,6 +84,8 @@ class NimbusIcon extends SynthIcon {
|
||||||
translatex = 1;
|
translatex = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (c instanceof JMenu) {
|
||||||
|
flip = ! c.getComponentOrientation().isLeftToRight();
|
||||||
}
|
}
|
||||||
if (g instanceof Graphics2D){
|
if (g instanceof Graphics2D){
|
||||||
Graphics2D gfx = (Graphics2D)g;
|
Graphics2D gfx = (Graphics2D)g;
|
||||||
|
|
|
@ -719,8 +719,9 @@ public class GlyphView extends View implements TabableView, Cloneable {
|
||||||
checkPainter();
|
checkPainter();
|
||||||
int p0 = getStartOffset();
|
int p0 = getStartOffset();
|
||||||
int p1 = painter.getBoundedPosition(this, p0, pos, len);
|
int p1 = painter.getBoundedPosition(this, p0, pos, len);
|
||||||
return ((p1 > p0) && (getBreakSpot(p0, p1) != BreakIterator.DONE)) ?
|
return p1 == p0 ? View.BadBreakWeight :
|
||||||
View.ExcellentBreakWeight : View.BadBreakWeight;
|
getBreakSpot(p0, p1) != BreakIterator.DONE ?
|
||||||
|
View.ExcellentBreakWeight : View.GoodBreakWeight;
|
||||||
}
|
}
|
||||||
return super.getBreakWeight(axis, pos, len);
|
return super.getBreakWeight(axis, pos, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,23 +174,6 @@ public class ParagraphView extends FlowView implements TabExpander {
|
||||||
return layoutPool.getView(index);
|
return layoutPool.getView(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adjusts the given row if possible to fit within the
|
|
||||||
* layout span. By default this will try to find the
|
|
||||||
* highest break weight possible nearest the end of
|
|
||||||
* the row. If a forced break is encountered, the
|
|
||||||
* break will be positioned there.
|
|
||||||
* <p>
|
|
||||||
* This is meant for internal usage, and should not be used directly.
|
|
||||||
*
|
|
||||||
* @param r the row to adjust to the current layout
|
|
||||||
* span
|
|
||||||
* @param desiredSpan the current layout span >= 0
|
|
||||||
* @param x the location r starts at
|
|
||||||
*/
|
|
||||||
protected void adjustRow(Row r, int desiredSpan, int x) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next visual position for the cursor, in
|
* Returns the next visual position for the cursor, in
|
||||||
* either the east or west direction.
|
* either the east or west direction.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -289,8 +289,8 @@ public abstract class ShellFolder extends File {
|
||||||
|
|
||||||
// To avoid loads of synchronizations with Invoker and improve performance we
|
// To avoid loads of synchronizations with Invoker and improve performance we
|
||||||
// synchronize the whole code of the sort method once
|
// synchronize the whole code of the sort method once
|
||||||
getInvoker().invoke(new Callable<Void>() {
|
invoke(new Callable<Void>() {
|
||||||
public Void call() throws Exception {
|
public Void call() {
|
||||||
// Check that we can use the ShellFolder.sortChildren() method:
|
// Check that we can use the ShellFolder.sortChildren() method:
|
||||||
// 1. All files have the same non-null parent
|
// 1. All files have the same non-null parent
|
||||||
// 2. All files is ShellFolders
|
// 2. All files is ShellFolders
|
||||||
|
@ -330,8 +330,8 @@ public abstract class ShellFolder extends File {
|
||||||
public void sortChildren(final List<? extends File> files) {
|
public void sortChildren(final List<? extends File> files) {
|
||||||
// To avoid loads of synchronizations with Invoker and improve performance we
|
// To avoid loads of synchronizations with Invoker and improve performance we
|
||||||
// synchronize the whole code of the sort method once
|
// synchronize the whole code of the sort method once
|
||||||
getInvoker().invoke(new Callable<Void>() {
|
invoke(new Callable<Void>() {
|
||||||
public Void call() throws Exception {
|
public Void call() {
|
||||||
Collections.sort(files, FILE_COMPARATOR);
|
Collections.sort(files, FILE_COMPARATOR);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -501,18 +501,62 @@ public abstract class ShellFolder extends File {
|
||||||
return invoker;
|
return invoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes the {@code task} which doesn't throw checked exceptions
|
||||||
|
* from its {@code call} method. If invokation is interrupted then Thread.currentThread().isInterrupted() will
|
||||||
|
* be set and result will be {@code null}
|
||||||
|
*/
|
||||||
|
public static <T> T invoke(Callable<T> task) {
|
||||||
|
try {
|
||||||
|
return invoke(task, RuntimeException.class);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes the {@code task} which throws checked exceptions from its {@code call} method.
|
||||||
|
* If invokation is interrupted then Thread.currentThread().isInterrupted() will
|
||||||
|
* be set and InterruptedException will be thrown as well.
|
||||||
|
*/
|
||||||
|
public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass)
|
||||||
|
throws InterruptedException, E {
|
||||||
|
try {
|
||||||
|
return getInvoker().invoke(task);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e instanceof RuntimeException) {
|
||||||
|
// Rethrow unchecked exceptions
|
||||||
|
throw (RuntimeException) e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e instanceof InterruptedException) {
|
||||||
|
// Set isInterrupted flag for current thread
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
|
||||||
|
// Rethrow InterruptedException
|
||||||
|
throw (InterruptedException) e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exceptionClass.isInstance(e)) {
|
||||||
|
throw exceptionClass.cast(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Unexpected error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface allowing to invoke tasks in different environments on different platforms.
|
* Interface allowing to invoke tasks in different environments on different platforms.
|
||||||
*/
|
*/
|
||||||
public static interface Invoker {
|
public static interface Invoker {
|
||||||
/**
|
/**
|
||||||
* Invokes a callable task. If the {@code task} throws a checked exception,
|
* Invokes a callable task.
|
||||||
* it will be wrapped into a {@link RuntimeException}
|
|
||||||
*
|
*
|
||||||
* @param task a task to invoke
|
* @param task a task to invoke
|
||||||
|
* @throws Exception {@code InterruptedException} or an exception that was thrown from the {@code task}
|
||||||
* @return the result of {@code task}'s invokation
|
* @return the result of {@code task}'s invokation
|
||||||
*/
|
*/
|
||||||
<T> T invoke(Callable<T> task);
|
<T> T invoke(Callable<T> task) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -108,12 +108,8 @@ class ShellFolderManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DirectInvoker implements ShellFolder.Invoker {
|
private static class DirectInvoker implements ShellFolder.Invoker {
|
||||||
public <T> T invoke(Callable<T> task) {
|
public <T> T invoke(Callable<T> task) throws Exception {
|
||||||
try {
|
return task.call();
|
||||||
return task.call();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -905,8 +904,8 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sort() {
|
public void sort() {
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
ShellFolder.invoke(new Callable<Void>() {
|
||||||
public Void call() throws Exception {
|
public Void call() {
|
||||||
DetailsTableRowSorter.super.sort();
|
DetailsTableRowSorter.super.sort();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,10 +718,10 @@ public class MenuItemLayoutHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alignRect(Rectangle rect, int alignment, int origWidth) {
|
private void alignRect(Rectangle rect, int alignment, int origWidth) {
|
||||||
if (alignment != SwingUtilities.LEFT) {
|
if (alignment == SwingConstants.RIGHT) {
|
||||||
rect.x = rect.x + rect.width - origWidth;
|
rect.x = rect.x + rect.width - origWidth;
|
||||||
rect.width = origWidth;
|
|
||||||
}
|
}
|
||||||
|
rect.width = origWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void layoutIconAndTextInLabelRect(LayoutResult lr) {
|
protected void layoutIconAndTextInLabelRect(LayoutResult lr) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ package sun.awt.X11;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.peer.*;
|
import java.awt.peer.*;
|
||||||
import sun.awt.X11GraphicsConfig;
|
import sun.awt.X11GraphicsConfig;
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
class XRobotPeer implements RobotPeer {
|
class XRobotPeer implements RobotPeer {
|
||||||
private X11GraphicsConfig xgc = null;
|
private X11GraphicsConfig xgc = null;
|
||||||
|
@ -38,7 +39,8 @@ class XRobotPeer implements RobotPeer {
|
||||||
|
|
||||||
XRobotPeer(GraphicsConfiguration gc) {
|
XRobotPeer(GraphicsConfiguration gc) {
|
||||||
this.xgc = (X11GraphicsConfig)gc;
|
this.xgc = (X11GraphicsConfig)gc;
|
||||||
setup();
|
SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
|
||||||
|
setup(tk.getNumberOfButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -81,7 +83,7 @@ class XRobotPeer implements RobotPeer {
|
||||||
return pixelArray;
|
return pixelArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native synchronized void setup();
|
private static native synchronized void setup(int numberOfButtons);
|
||||||
|
|
||||||
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
|
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
|
||||||
private static native synchronized void mousePressImpl(int buttons);
|
private static native synchronized void mousePressImpl(int buttons);
|
||||||
|
|
|
@ -51,9 +51,8 @@
|
||||||
|
|
||||||
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
|
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
|
||||||
|
|
||||||
extern int32_t getNumButtons();
|
|
||||||
|
|
||||||
static jint * masks;
|
static jint * masks;
|
||||||
|
static jint num_buttons;
|
||||||
|
|
||||||
static int32_t isXTestAvailable() {
|
static int32_t isXTestAvailable() {
|
||||||
int32_t major_opcode, first_event, first_error;
|
int32_t major_opcode, first_event, first_error;
|
||||||
|
@ -164,34 +163,34 @@ static XImage *getWindowImage(Display * display, Window window,
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
|
// this should be called from XRobotPeer constructor
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
|
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons) {
|
||||||
int32_t xtestAvailable;
|
int32_t xtestAvailable;
|
||||||
|
|
||||||
// this should be called from XRobotPeer constructor
|
DTRACE_PRINTLN("RobotPeer: setup()");
|
||||||
|
|
||||||
|
num_buttons = numberOfButtons;
|
||||||
|
|
||||||
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
||||||
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
||||||
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
||||||
jsize len = (*env)->GetArrayLength(env, obj);
|
|
||||||
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
||||||
|
|
||||||
masks = (jint *)malloc(sizeof(jint)*len);
|
masks = (jint *)malloc(sizeof(jint) * num_buttons);
|
||||||
if (masks == (jint *) NULL) {
|
if (masks == (jint *) NULL) {
|
||||||
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
|
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < num_buttons; i++) {
|
||||||
masks[i] = tmp[i];
|
masks[i] = tmp[i];
|
||||||
}
|
}
|
||||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
|
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
|
||||||
(*env)->DeleteLocalRef(env, obj);
|
(*env)->DeleteLocalRef(env, obj);
|
||||||
|
|
||||||
DTRACE_PRINTLN("RobotPeer: setup()");
|
|
||||||
|
|
||||||
AWT_LOCK();
|
AWT_LOCK();
|
||||||
|
|
||||||
xtestAvailable = isXTestAvailable();
|
xtestAvailable = isXTestAvailable();
|
||||||
DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
|
DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
|
||||||
if (!xtestAvailable) {
|
if (!xtestAvailable) {
|
||||||
|
@ -338,8 +337,6 @@ void mouseAction(JNIEnv *env,
|
||||||
{
|
{
|
||||||
AWT_LOCK();
|
AWT_LOCK();
|
||||||
|
|
||||||
int32_t num_buttons = getNumButtons(); //from XToolkit.c
|
|
||||||
|
|
||||||
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
|
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
|
||||||
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
|
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -29,7 +29,6 @@ import java.awt.Image;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
@ -185,8 +184,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
boolean disposed;
|
boolean disposed;
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (disposed) return;
|
if (disposed) return;
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
invoke(new Callable<Void>() {
|
||||||
public Void call() throws Exception {
|
public Void call() {
|
||||||
if (relativePIDL != 0) {
|
if (relativePIDL != 0) {
|
||||||
releasePIDL(relativePIDL);
|
releasePIDL(relativePIDL);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +223,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
*/
|
*/
|
||||||
private boolean isPersonal;
|
private boolean isPersonal;
|
||||||
|
|
||||||
private static String composePathForCsidl(int csidl) throws IOException {
|
private static String composePathForCsidl(int csidl) throws IOException, InterruptedException {
|
||||||
String path = getFileSystemPath(csidl);
|
String path = getFileSystemPath(csidl);
|
||||||
return path == null
|
return path == null
|
||||||
? ("ShellFolder: 0x" + Integer.toHexString(csidl))
|
? ("ShellFolder: 0x" + Integer.toHexString(csidl))
|
||||||
|
@ -235,12 +234,13 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
* Create a system special shell folder, such as the
|
* Create a system special shell folder, such as the
|
||||||
* desktop or Network Neighborhood.
|
* desktop or Network Neighborhood.
|
||||||
*/
|
*/
|
||||||
Win32ShellFolder2(final int csidl) throws IOException {
|
Win32ShellFolder2(final int csidl) throws IOException, InterruptedException {
|
||||||
// Desktop is parent of DRIVES and NETWORK, not necessarily
|
// Desktop is parent of DRIVES and NETWORK, not necessarily
|
||||||
// other special shell folders.
|
// other special shell folders.
|
||||||
super(null, composePathForCsidl(csidl));
|
super(null, composePathForCsidl(csidl));
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
|
||||||
public Void call() throws Exception {
|
invoke(new Callable<Void>() {
|
||||||
|
public Void call() throws InterruptedException {
|
||||||
if (csidl == DESKTOP) {
|
if (csidl == DESKTOP) {
|
||||||
initDesktop();
|
initDesktop();
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,7 +276,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
}, InterruptedException.class);
|
||||||
|
|
||||||
sun.java2d.Disposer.addRecord(this, disposer);
|
sun.java2d.Disposer.addRecord(this, disposer);
|
||||||
}
|
}
|
||||||
|
@ -296,13 +296,13 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
/**
|
/**
|
||||||
* Creates a shell folder with a parent and relative PIDL
|
* Creates a shell folder with a parent and relative PIDL
|
||||||
*/
|
*/
|
||||||
Win32ShellFolder2(final Win32ShellFolder2 parent, final long relativePIDL) {
|
Win32ShellFolder2(final Win32ShellFolder2 parent, final long relativePIDL) throws InterruptedException {
|
||||||
super(parent,
|
super(parent,
|
||||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
invoke(new Callable<String>() {
|
||||||
public String call() throws Exception {
|
public String call() {
|
||||||
return getFileSystemPath(parent.getIShellFolder(), relativePIDL);
|
return getFileSystemPath(parent.getIShellFolder(), relativePIDL);
|
||||||
}
|
}
|
||||||
})
|
}, RuntimeException.class)
|
||||||
);
|
);
|
||||||
this.disposer.relativePIDL = relativePIDL;
|
this.disposer.relativePIDL = relativePIDL;
|
||||||
getAbsolutePath();
|
getAbsolutePath();
|
||||||
|
@ -335,8 +335,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
* drive (normally "C:\").
|
* drive (normally "C:\").
|
||||||
*/
|
*/
|
||||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<File>() {
|
return invoke(new Callable<File>() {
|
||||||
public File call() throws Exception {
|
public File call() {
|
||||||
if (isFileSystem()) {
|
if (isFileSystem()) {
|
||||||
return new File(getPath());
|
return new File(getPath());
|
||||||
} else {
|
} else {
|
||||||
|
@ -398,11 +398,11 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
/**
|
/**
|
||||||
* Accessor for IShellFolder
|
* Accessor for IShellFolder
|
||||||
*/
|
*/
|
||||||
public long getIShellFolder() {
|
private long getIShellFolder() {
|
||||||
if (disposer.pIShellFolder == 0) {
|
if (disposer.pIShellFolder == 0) {
|
||||||
disposer.pIShellFolder =
|
try {
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
disposer.pIShellFolder = invoke(new Callable<Long>() {
|
||||||
public Long call() throws Exception {
|
public Long call() {
|
||||||
assert(isDirectory());
|
assert(isDirectory());
|
||||||
assert(parent != null);
|
assert(parent != null);
|
||||||
long parentIShellFolder = getParentIShellFolder();
|
long parentIShellFolder = getParentIShellFolder();
|
||||||
|
@ -421,7 +421,10 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
return pIShellFolder;
|
return pIShellFolder;
|
||||||
}
|
}
|
||||||
});
|
}, RuntimeException.class);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return disposer.pIShellFolder;
|
return disposer.pIShellFolder;
|
||||||
}
|
}
|
||||||
|
@ -505,18 +508,23 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent == rhs.parent || parent.equals(rhs.parent)) {
|
if (parent == rhs.parent || parent.equals(rhs.parent)) {
|
||||||
return pidlsEqual(getParentIShellFolder(), disposer.relativePIDL, rhs.disposer.relativePIDL);
|
try {
|
||||||
|
return pidlsEqual(getParentIShellFolder(), disposer.relativePIDL, rhs.disposer.relativePIDL);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean pidlsEqual(final long pIShellFolder, final long pidl1, final long pidl2) {
|
private static boolean pidlsEqual(final long pIShellFolder, final long pidl1, final long pidl2)
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Boolean>() {
|
throws InterruptedException {
|
||||||
public Boolean call() throws Exception {
|
return invoke(new Callable<Boolean>() {
|
||||||
return (compareIDs(pIShellFolder, pidl1, pidl2) == 0);
|
public Boolean call() {
|
||||||
|
return compareIDs(pIShellFolder, pidl1, pidl2) == 0;
|
||||||
}
|
}
|
||||||
});
|
}, RuntimeException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||||
|
@ -539,14 +547,16 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
* Return whether the given attribute flag is set for this object
|
* Return whether the given attribute flag is set for this object
|
||||||
*/
|
*/
|
||||||
public boolean hasAttribute(final int attribute) {
|
public boolean hasAttribute(final int attribute) {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Boolean>() {
|
Boolean result = invoke(new Callable<Boolean>() {
|
||||||
public Boolean call() throws Exception {
|
public Boolean call() {
|
||||||
// Caching at this point doesn't seem to be cost efficient
|
// Caching at this point doesn't seem to be cost efficient
|
||||||
return (getAttributes0(getParentIShellFolder(),
|
return (getAttributes0(getParentIShellFolder(),
|
||||||
getRelativePIDL(), attribute)
|
getRelativePIDL(), attribute)
|
||||||
& attribute) != 0;
|
& attribute) != 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return result != null && result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -561,32 +571,29 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
private static native int getAttributes0(long pParentIShellFolder, long pIDL, int attrsMask);
|
private static native int getAttributes0(long pParentIShellFolder, long pIDL, int attrsMask);
|
||||||
|
|
||||||
// Return the path to the underlying file system object
|
// Return the path to the underlying file system object
|
||||||
|
// Should be called from the COM thread
|
||||||
private static String getFileSystemPath(final long parentIShellFolder, final long relativePIDL) {
|
private static String getFileSystemPath(final long parentIShellFolder, final long relativePIDL) {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<String>() {
|
int linkedFolder = ATTRIB_LINK | ATTRIB_FOLDER;
|
||||||
public String call() throws Exception {
|
if (parentIShellFolder == Win32ShellFolderManager2.getNetwork().getIShellFolder() &&
|
||||||
int linkedFolder = ATTRIB_LINK | ATTRIB_FOLDER;
|
getAttributes0(parentIShellFolder, relativePIDL, linkedFolder) == linkedFolder) {
|
||||||
if (parentIShellFolder == Win32ShellFolderManager2.getNetwork().getIShellFolder() &&
|
|
||||||
getAttributes0(parentIShellFolder, relativePIDL, linkedFolder) == linkedFolder) {
|
|
||||||
|
|
||||||
String s =
|
String s =
|
||||||
getFileSystemPath(Win32ShellFolderManager2.getDesktop().getIShellFolder(),
|
getFileSystemPath(Win32ShellFolderManager2.getDesktop().getIShellFolder(),
|
||||||
getLinkLocation(parentIShellFolder, relativePIDL, false));
|
getLinkLocation(parentIShellFolder, relativePIDL, false));
|
||||||
if (s != null && s.startsWith("\\\\")) {
|
if (s != null && s.startsWith("\\\\")) {
|
||||||
return s;
|
return s;
|
||||||
}
|
|
||||||
}
|
|
||||||
return getDisplayNameOf(parentIShellFolder, relativePIDL, SHGDN_FORPARSING);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
return getDisplayNameOf(parentIShellFolder, relativePIDL, SHGDN_FORPARSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needs to be accessible to Win32ShellFolderManager2
|
// Needs to be accessible to Win32ShellFolderManager2
|
||||||
static String getFileSystemPath(final int csidl) throws IOException {
|
static String getFileSystemPath(final int csidl) throws IOException, InterruptedException {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<String>() {
|
return invoke(new Callable<String>() {
|
||||||
public String call() throws Exception {
|
public String call() throws IOException {
|
||||||
return getFileSystemPath0(csidl);
|
return getFileSystemPath0(csidl);
|
||||||
}
|
}
|
||||||
});
|
}, IOException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||||
|
@ -630,13 +637,14 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
*/
|
*/
|
||||||
// Returns an IEnumIDList interface for an IShellFolder. The value
|
// Returns an IEnumIDList interface for an IShellFolder. The value
|
||||||
// returned must be released using releaseEnumObjects().
|
// returned must be released using releaseEnumObjects().
|
||||||
private long getEnumObjects(long pIShellFolder, final boolean includeHiddenFiles) {
|
private long getEnumObjects(final boolean includeHiddenFiles) throws InterruptedException {
|
||||||
final boolean isDesktop = (disposer.pIShellFolder == getDesktopIShellFolder());
|
return invoke(new Callable<Long>() {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
public Long call() {
|
||||||
public Long call() throws Exception {
|
boolean isDesktop = disposer.pIShellFolder == getDesktopIShellFolder();
|
||||||
|
|
||||||
return getEnumObjects(disposer.pIShellFolder, isDesktop, includeHiddenFiles);
|
return getEnumObjects(disposer.pIShellFolder, isDesktop, includeHiddenFiles);
|
||||||
}
|
}
|
||||||
});
|
}, RuntimeException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an IEnumIDList interface for an IShellFolder. The value
|
// Returns an IEnumIDList interface for an IShellFolder. The value
|
||||||
|
@ -670,58 +678,62 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
security.checkRead(getPath());
|
security.checkRead(getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<File[]>() {
|
try {
|
||||||
public File[] call() throws Exception {
|
return invoke(new Callable<File[]>() {
|
||||||
if (!isDirectory()) {
|
public File[] call() throws InterruptedException {
|
||||||
return null;
|
if (!isDirectory()) {
|
||||||
}
|
return null;
|
||||||
// Links to directories are not directories and cannot be parents.
|
}
|
||||||
// This does not apply to folders in My Network Places (NetHood)
|
// Links to directories are not directories and cannot be parents.
|
||||||
// because they are both links and real directories!
|
// This does not apply to folders in My Network Places (NetHood)
|
||||||
if (isLink() && !hasAttribute(ATTRIB_FOLDER)) {
|
// because they are both links and real directories!
|
||||||
return new File[0];
|
if (isLink() && !hasAttribute(ATTRIB_FOLDER)) {
|
||||||
}
|
return new File[0];
|
||||||
|
}
|
||||||
|
|
||||||
Win32ShellFolder2 desktop = Win32ShellFolderManager2.getDesktop();
|
Win32ShellFolder2 desktop = Win32ShellFolderManager2.getDesktop();
|
||||||
Win32ShellFolder2 personal = Win32ShellFolderManager2.getPersonal();
|
Win32ShellFolder2 personal = Win32ShellFolderManager2.getPersonal();
|
||||||
|
|
||||||
// If we are a directory, we have a parent and (at least) a
|
// If we are a directory, we have a parent and (at least) a
|
||||||
// relative PIDL. We must first ensure we are bound to the
|
// relative PIDL. We must first ensure we are bound to the
|
||||||
// parent so we have an IShellFolder to query.
|
// parent so we have an IShellFolder to query.
|
||||||
long pIShellFolder = getIShellFolder();
|
long pIShellFolder = getIShellFolder();
|
||||||
// Now we can enumerate the objects in this folder.
|
// Now we can enumerate the objects in this folder.
|
||||||
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
|
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
|
||||||
long pEnumObjects = getEnumObjects(pIShellFolder, includeHiddenFiles);
|
long pEnumObjects = getEnumObjects(includeHiddenFiles);
|
||||||
if (pEnumObjects != 0) {
|
if (pEnumObjects != 0) {
|
||||||
long childPIDL;
|
long childPIDL;
|
||||||
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
|
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
|
||||||
do {
|
do {
|
||||||
childPIDL = getNextChild(pEnumObjects);
|
childPIDL = getNextChild(pEnumObjects);
|
||||||
boolean releasePIDL = true;
|
boolean releasePIDL = true;
|
||||||
if (childPIDL != 0 &&
|
if (childPIDL != 0 &&
|
||||||
(getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
|
(getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
|
||||||
Win32ShellFolder2 childFolder;
|
Win32ShellFolder2 childFolder;
|
||||||
if (Win32ShellFolder2.this.equals(desktop)
|
if (Win32ShellFolder2.this.equals(desktop)
|
||||||
&& personal != null
|
&& personal != null
|
||||||
&& pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
|
&& pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
|
||||||
childFolder = personal;
|
childFolder = personal;
|
||||||
} else {
|
} else {
|
||||||
childFolder = new Win32ShellFolder2(Win32ShellFolder2.this, childPIDL);
|
childFolder = new Win32ShellFolder2(Win32ShellFolder2.this, childPIDL);
|
||||||
releasePIDL = false;
|
releasePIDL = false;
|
||||||
|
}
|
||||||
|
list.add(childFolder);
|
||||||
}
|
}
|
||||||
list.add(childFolder);
|
if (releasePIDL) {
|
||||||
}
|
releasePIDL(childPIDL);
|
||||||
if (releasePIDL) {
|
}
|
||||||
releasePIDL(childPIDL);
|
} while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
|
||||||
}
|
releaseEnumObjects(pEnumObjects);
|
||||||
} while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
|
}
|
||||||
releaseEnumObjects(pEnumObjects);
|
return Thread.currentThread().isInterrupted()
|
||||||
|
? new File[0]
|
||||||
|
: list.toArray(new ShellFolder[list.size()]);
|
||||||
}
|
}
|
||||||
return Thread.currentThread().isInterrupted()
|
}, InterruptedException.class);
|
||||||
? new File[0]
|
} catch (InterruptedException e) {
|
||||||
: list.toArray(new ShellFolder[list.size()]);
|
return new File[0];
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -730,13 +742,13 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
*
|
*
|
||||||
* @return The child shellfolder, or null if not found.
|
* @return The child shellfolder, or null if not found.
|
||||||
*/
|
*/
|
||||||
Win32ShellFolder2 getChildByPath(final String filePath) {
|
Win32ShellFolder2 getChildByPath(final String filePath) throws InterruptedException {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Win32ShellFolder2>() {
|
return invoke(new Callable<Win32ShellFolder2>() {
|
||||||
public Win32ShellFolder2 call() throws Exception {
|
public Win32ShellFolder2 call() throws InterruptedException {
|
||||||
long pIShellFolder = getIShellFolder();
|
long pIShellFolder = getIShellFolder();
|
||||||
long pEnumObjects = getEnumObjects(pIShellFolder, true);
|
long pEnumObjects = getEnumObjects(true);
|
||||||
Win32ShellFolder2 child = null;
|
Win32ShellFolder2 child = null;
|
||||||
long childPIDL = 0;
|
long childPIDL;
|
||||||
|
|
||||||
while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
|
while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
|
||||||
if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
|
if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
|
||||||
|
@ -753,7 +765,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
releaseEnumObjects(pEnumObjects);
|
releaseEnumObjects(pEnumObjects);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
});
|
}, InterruptedException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean cachedIsLink;
|
private Boolean cachedIsLink;
|
||||||
|
@ -791,8 +803,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShellFolder getLinkLocation(final boolean resolve) {
|
private ShellFolder getLinkLocation(final boolean resolve) {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<ShellFolder>() {
|
return invoke(new Callable<ShellFolder>() {
|
||||||
public ShellFolder call() throws Exception {
|
public ShellFolder call() {
|
||||||
if (!isLink()) {
|
if (!isLink()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -805,6 +817,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
location =
|
location =
|
||||||
Win32ShellFolderManager2.createShellFolderFromRelativePIDL(getDesktop(),
|
Win32ShellFolderManager2.createShellFolderFromRelativePIDL(getDesktop(),
|
||||||
linkLocationPIDL);
|
linkLocationPIDL);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Return null
|
||||||
} catch (InternalError e) {
|
} catch (InternalError e) {
|
||||||
// Could be a link to a non-bindable object, such as a network connection
|
// Could be a link to a non-bindable object, such as a network connection
|
||||||
// TODO: getIShellFolder() should throw FileNotFoundException instead
|
// TODO: getIShellFolder() should throw FileNotFoundException instead
|
||||||
|
@ -816,19 +830,12 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a display name into a PIDL relative to the current IShellFolder.
|
// Parse a display name into a PIDL relative to the current IShellFolder.
|
||||||
long parseDisplayName(final String name) throws FileNotFoundException {
|
long parseDisplayName(final String name) throws IOException, InterruptedException {
|
||||||
try {
|
return invoke(new Callable<Long>() {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
public Long call() throws IOException {
|
||||||
public Long call() throws Exception {
|
return parseDisplayName0(getIShellFolder(), name);
|
||||||
return parseDisplayName0(getIShellFolder(), name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
if (e.getCause() instanceof IOException) {
|
|
||||||
throw new FileNotFoundException("Could not find file " + name);
|
|
||||||
}
|
}
|
||||||
throw e;
|
}, IOException.class);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||||
|
@ -846,8 +853,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
if (displayName == null) {
|
if (displayName == null) {
|
||||||
displayName =
|
displayName =
|
||||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
invoke(new Callable<String>() {
|
||||||
public String call() throws Exception {
|
public String call() {
|
||||||
return getDisplayNameOf(getParentIShellFolder(),
|
return getDisplayNameOf(getParentIShellFolder(),
|
||||||
getRelativePIDL(), SHGDN_NORMAL);
|
getRelativePIDL(), SHGDN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -867,8 +874,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
if (folderType == null) {
|
if (folderType == null) {
|
||||||
final long absolutePIDL = getAbsolutePIDL();
|
final long absolutePIDL = getAbsolutePIDL();
|
||||||
folderType =
|
folderType =
|
||||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
invoke(new Callable<String>() {
|
||||||
public String call() throws Exception {
|
public String call() {
|
||||||
return getFolderType(absolutePIDL);
|
return getFolderType(absolutePIDL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -926,15 +933,12 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
|
|
||||||
public static native int[] getFileChooserBitmapBits();
|
public static native int[] getFileChooserBitmapBits();
|
||||||
|
|
||||||
|
// Should be called from the COM thread
|
||||||
private long getIShellIcon() {
|
private long getIShellIcon() {
|
||||||
if (pIShellIcon == -1L) {
|
if (pIShellIcon == -1L) {
|
||||||
pIShellIcon =
|
pIShellIcon = getIShellIcon(getIShellFolder());
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
|
||||||
public Long call() throws Exception {
|
|
||||||
return getIShellIcon(getIShellFolder());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pIShellIcon;
|
return pIShellIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,8 +992,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
Image icon = getLargeIcon ? largeIcon : smallIcon;
|
Image icon = getLargeIcon ? largeIcon : smallIcon;
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
icon =
|
icon =
|
||||||
ShellFolder.getInvoker().invoke(new Callable<Image>() {
|
invoke(new Callable<Image>() {
|
||||||
public Image call() throws Exception {
|
public Image call() {
|
||||||
Image newIcon = null;
|
Image newIcon = null;
|
||||||
if (isFileSystem()) {
|
if (isFileSystem()) {
|
||||||
long parentIShellIcon = (parent != null)
|
long parentIShellIcon = (parent != null)
|
||||||
|
@ -1113,8 +1117,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
private static final int LVCFMT_CENTER = 2;
|
private static final int LVCFMT_CENTER = 2;
|
||||||
|
|
||||||
public ShellFolderColumnInfo[] getFolderColumns() {
|
public ShellFolderColumnInfo[] getFolderColumns() {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<ShellFolderColumnInfo[]>() {
|
return invoke(new Callable<ShellFolderColumnInfo[]>() {
|
||||||
public ShellFolderColumnInfo[] call() throws Exception {
|
public ShellFolderColumnInfo[] call() {
|
||||||
ShellFolderColumnInfo[] columns = doGetColumnInfo(getIShellFolder());
|
ShellFolderColumnInfo[] columns = doGetColumnInfo(getIShellFolder());
|
||||||
|
|
||||||
if (columns != null) {
|
if (columns != null) {
|
||||||
|
@ -1143,8 +1147,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getFolderColumnValue(final int column) {
|
public Object getFolderColumnValue(final int column) {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Object>() {
|
return invoke(new Callable<Object>() {
|
||||||
public Object call() throws Exception {
|
public Object call() {
|
||||||
return doGetColumnValue(getParentIShellFolder(), getRelativePIDL(), column);
|
return doGetColumnValue(getParentIShellFolder(), getRelativePIDL(), column);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1163,8 +1167,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
public void sortChildren(final List<? extends File> files) {
|
public void sortChildren(final List<? extends File> files) {
|
||||||
// To avoid loads of synchronizations with Invoker and improve performance we
|
// To avoid loads of synchronizations with Invoker and improve performance we
|
||||||
// synchronize the whole code of the sort method once
|
// synchronize the whole code of the sort method once
|
||||||
getInvoker().invoke(new Callable<Void>() {
|
invoke(new Callable<Void>() {
|
||||||
public Void call() throws Exception {
|
public Void call() {
|
||||||
Collections.sort(files, new ColumnComparator(getIShellFolder(), 0));
|
Collections.sort(files, new ColumnComparator(getIShellFolder(), 0));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -1184,19 +1188,21 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||||
|
|
||||||
// compares 2 objects within this folder by the specified column
|
// compares 2 objects within this folder by the specified column
|
||||||
public int compare(final File o, final File o1) {
|
public int compare(final File o, final File o1) {
|
||||||
return ShellFolder.getInvoker().invoke(new Callable<Integer>() {
|
Integer result = invoke(new Callable<Integer>() {
|
||||||
public Integer call() throws Exception {
|
public Integer call() {
|
||||||
if (o instanceof Win32ShellFolder2
|
if (o instanceof Win32ShellFolder2
|
||||||
&& o1 instanceof Win32ShellFolder2) {
|
&& o1 instanceof Win32ShellFolder2) {
|
||||||
// delegates comparison to native method
|
// delegates comparison to native method
|
||||||
return compareIDsByColumn(parentIShellFolder,
|
return compareIDsByColumn(parentIShellFolder,
|
||||||
((Win32ShellFolder2) o).getRelativePIDL(),
|
((Win32ShellFolder2) o).getRelativePIDL(),
|
||||||
((Win32ShellFolder2) o1).getRelativePIDL(),
|
((Win32ShellFolder2) o1).getRelativePIDL(),
|
||||||
columnIdx);
|
columnIdx);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return result == null ? 0 : result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -58,10 +58,15 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShellFolder createShellFolder(File file) throws FileNotFoundException {
|
public ShellFolder createShellFolder(File file) throws FileNotFoundException {
|
||||||
return createShellFolder(getDesktop(), file);
|
try {
|
||||||
|
return createShellFolder(getDesktop(), file);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new FileNotFoundException("Execution was interrupted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Win32ShellFolder2 createShellFolder(Win32ShellFolder2 parent, File file) throws FileNotFoundException {
|
static Win32ShellFolder2 createShellFolder(Win32ShellFolder2 parent, File file)
|
||||||
|
throws FileNotFoundException, InterruptedException {
|
||||||
long pIDL;
|
long pIDL;
|
||||||
try {
|
try {
|
||||||
pIDL = parent.parseDisplayName(file.getCanonicalPath());
|
pIDL = parent.parseDisplayName(file.getCanonicalPath());
|
||||||
|
@ -77,7 +82,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL) {
|
static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL)
|
||||||
|
throws InterruptedException {
|
||||||
// Walk down this relative pIDL, creating new nodes for each of the entries
|
// Walk down this relative pIDL, creating new nodes for each of the entries
|
||||||
while (pIDL != 0) {
|
while (pIDL != 0) {
|
||||||
long curPIDL = Win32ShellFolder2.copyFirstPIDLEntry(pIDL);
|
long curPIDL = Win32ShellFolder2.copyFirstPIDLEntry(pIDL);
|
||||||
|
@ -108,7 +114,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
try {
|
try {
|
||||||
desktop = new Win32ShellFolder2(DESKTOP);
|
desktop = new Win32ShellFolder2(DESKTOP);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
desktop = null;
|
// Ignore error
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return desktop;
|
return desktop;
|
||||||
|
@ -119,7 +127,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
try {
|
try {
|
||||||
drives = new Win32ShellFolder2(DRIVES);
|
drives = new Win32ShellFolder2(DRIVES);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
drives = null;
|
// Ignore error
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return drives;
|
return drives;
|
||||||
|
@ -132,8 +142,10 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
recent = createShellFolder(getDesktop(), new File(path));
|
recent = createShellFolder(getDesktop(), new File(path));
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
recent = null;
|
// Ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return recent;
|
return recent;
|
||||||
|
@ -144,7 +156,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
try {
|
try {
|
||||||
network = new Win32ShellFolder2(NETWORK);
|
network = new Win32ShellFolder2(NETWORK);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
network = null;
|
// Ignore error
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return network;
|
return network;
|
||||||
|
@ -164,8 +178,10 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
personal.setIsPersonal();
|
personal.setIsPersonal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore error
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
personal = null;
|
// Ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return personal;
|
return personal;
|
||||||
|
@ -267,6 +283,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Skip this value
|
// Skip this value
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Return empty result
|
||||||
|
return new File[0];
|
||||||
}
|
}
|
||||||
} while (value != null);
|
} while (value != null);
|
||||||
|
|
||||||
|
@ -476,33 +495,39 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||||
return comThread;
|
return comThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T invoke(Callable<T> task) {
|
public <T> T invoke(Callable<T> task) throws Exception {
|
||||||
try {
|
if (Thread.currentThread() == comThread) {
|
||||||
if (Thread.currentThread() == comThread) {
|
// if it's already called from the COM
|
||||||
// if it's already called from the COM
|
// thread, we don't need to delegate the task
|
||||||
// thread, we don't need to delegate the task
|
return task.call();
|
||||||
return task.call();
|
} else {
|
||||||
} else {
|
Future<T> future;
|
||||||
while (true) {
|
|
||||||
Future<T> future = submit(task);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return future.get();
|
future = submit(task);
|
||||||
} catch (InterruptedException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
// Repeat the attempt
|
throw new InterruptedException(e.getMessage());
|
||||||
future.cancel(true);
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
return future.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
future.cancel(true);
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
Throwable cause = e.getCause();
|
||||||
|
|
||||||
|
if (cause instanceof Exception) {
|
||||||
|
throw (Exception) cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cause instanceof Error) {
|
||||||
|
throw (Error) cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Unexpected error", cause);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
Throwable cause = (e instanceof ExecutionException) ? e.getCause() : e;
|
|
||||||
if (cause instanceof RuntimeException) {
|
|
||||||
throw (RuntimeException) cause;
|
|
||||||
}
|
|
||||||
if (cause instanceof Error) {
|
|
||||||
throw (Error) cause;
|
|
||||||
}
|
|
||||||
throw new RuntimeException(cause);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3739,11 +3739,12 @@ void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
|
||||||
|
|
||||||
MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
|
MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
|
||||||
{
|
{
|
||||||
// This message causes native status window shown even it is disabled. So don't
|
// If the Windows input context is disabled, do not let Windows
|
||||||
// let DefWindowProc process this message if this IMC is disabled.
|
// display any UIs.
|
||||||
HIMC hIMC = ImmGetContext();
|
HIMC hIMC = ImmGetContext();
|
||||||
if (hIMC == NULL) {
|
if (hIMC == NULL) {
|
||||||
return mrConsume;
|
*lplParam = 0;
|
||||||
|
return mrDoDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSet) {
|
if (fSet) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
*
|
*
|
||||||
* @bug 6638195
|
* @bug 6638195 6844297
|
||||||
* @author Igor Kushnirskiy
|
* @author Igor Kushnirskiy
|
||||||
* @summary tests if EventQueueDelegate.Delegate is invoked.
|
* @summary tests if EventQueueDelegate.Delegate is invoked.
|
||||||
*/
|
*/
|
||||||
|
@ -47,11 +47,22 @@ public class bug6638195 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runTest(MyEventQueueDelegate delegate) throws Exception {
|
private static void runTest(MyEventQueueDelegate delegate) throws Exception {
|
||||||
|
// We need an empty runnable here, so the next event is
|
||||||
|
// processed with a new EventQueueDelegate. See 6844297
|
||||||
|
// for details
|
||||||
EventQueue.invokeLater(
|
EventQueue.invokeLater(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// The following event is expected to be processed by
|
||||||
|
// the EventQueueDelegate instance
|
||||||
|
EventQueue.invokeLater(
|
||||||
|
new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Finally, proceed on the main thread
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
EventQueue.invokeLater(
|
EventQueue.invokeLater(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
|
@ -60,7 +71,7 @@ public class bug6638195 {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await();
|
latch.await();
|
||||||
if (! delegate.allInvoked()) {
|
if (!delegate.allInvoked()) {
|
||||||
throw new RuntimeException("failed");
|
throw new RuntimeException("failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +136,7 @@ public class bug6638195 {
|
||||||
|
|
||||||
return objectMap;
|
return objectMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MyEventQueueDelegate implements EventQueueDelegate.Delegate {
|
static class MyEventQueueDelegate implements EventQueueDelegate.Delegate {
|
||||||
private volatile boolean getNextEventInvoked = false;
|
private volatile boolean getNextEventInvoked = false;
|
||||||
private volatile boolean beforeDispatchInvoked = false;
|
private volatile boolean beforeDispatchInvoked = false;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009 Red Hat, Inc. All Rights Reserved.
|
* Copyright 2009 Red Hat, Inc. All Rights Reserved.
|
||||||
|
* Portions Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -37,35 +38,62 @@
|
||||||
* Test fails if size of window is wrong
|
* Test fails if size of window is wrong
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.*;
|
||||||
import java.awt.Frame;
|
|
||||||
|
|
||||||
public class TestFrameSize {
|
public class TestFrameSize {
|
||||||
|
|
||||||
static Dimension desiredDimensions = new Dimension(200, 200);
|
static Dimension desiredDimensions = new Dimension(200, 200);
|
||||||
static int ERROR_MARGIN = 15;
|
static Frame mainWindow;
|
||||||
static Frame mainWindow;
|
|
||||||
|
|
||||||
public static void drawGui() {
|
private static Dimension getClientSize(Frame window) {
|
||||||
mainWindow = new Frame("");
|
Dimension size = window.getSize();
|
||||||
mainWindow.setPreferredSize(desiredDimensions);
|
Insets insets = window.getInsets();
|
||||||
mainWindow.pack();
|
|
||||||
|
|
||||||
Dimension actualDimensions = mainWindow.getSize();
|
System.out.println("getClientSize() for " + window);
|
||||||
System.out.println("Desired dimensions: " + desiredDimensions.toString());
|
System.out.println(" size: " + size);
|
||||||
System.out.println("Actual dimensions: " + actualDimensions.toString());
|
System.out.println(" insets: " + insets);
|
||||||
if (Math.abs(actualDimensions.height - desiredDimensions.height) > ERROR_MARGIN) {
|
|
||||||
throw new RuntimeException("Incorrect widow size");
|
return new Dimension(
|
||||||
}
|
size.width - insets.left - insets.right,
|
||||||
|
size.height - insets.top - insets.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawGui() {
|
||||||
|
mainWindow = new Frame("");
|
||||||
|
mainWindow.setPreferredSize(desiredDimensions);
|
||||||
|
mainWindow.pack();
|
||||||
|
|
||||||
|
Dimension actualDimensions = mainWindow.getSize();
|
||||||
|
System.out.println("Desired dimensions: " + desiredDimensions.toString());
|
||||||
|
System.out.println("Actual dimensions: " + actualDimensions.toString());
|
||||||
|
if (!actualDimensions.equals(desiredDimensions)) {
|
||||||
|
throw new RuntimeException("Incorrect widow size");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
// pack() guarantees to preserve the size of the client area after
|
||||||
try {
|
// showing the window.
|
||||||
drawGui();
|
Dimension clientSize1 = getClientSize(mainWindow);
|
||||||
} finally {
|
System.out.println("Client size before showing: " + clientSize1);
|
||||||
if (mainWindow != null) {
|
|
||||||
mainWindow.dispose();
|
mainWindow.setVisible(true);
|
||||||
}
|
|
||||||
}
|
((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||||
|
|
||||||
|
Dimension clientSize2 = getClientSize(mainWindow);
|
||||||
|
System.out.println("Client size after showing: " + clientSize2);
|
||||||
|
|
||||||
|
if (!clientSize2.equals(clientSize1)) {
|
||||||
|
throw new RuntimeException("Incorrect client area size.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
drawGui();
|
||||||
|
} finally {
|
||||||
|
if (mainWindow != null) {
|
||||||
|
mainWindow.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
136
jdk/test/javax/swing/JInternalFrame/Test6505027.java
Normal file
136
jdk/test/javax/swing/JInternalFrame/Test6505027.java
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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 6505027
|
||||||
|
* @summary Tests focus problem inside internal frame
|
||||||
|
* @author Sergey Malenkov
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import javax.swing.DefaultCellEditor;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
|
public class Test6505027 implements Runnable {
|
||||||
|
|
||||||
|
private static final boolean INTERNAL = true;
|
||||||
|
private static final boolean TERMINATE = true;
|
||||||
|
|
||||||
|
private static final int WIDTH = 450;
|
||||||
|
private static final int HEIGHT = 200;
|
||||||
|
private static final int OFFSET = 10;
|
||||||
|
private static final long PAUSE = 2048L;
|
||||||
|
|
||||||
|
private static final String[] COLUMNS = { "Size", "Shape" }; // NON-NLS
|
||||||
|
private static final String[] ITEMS = { "a", "b", "c", "d" }; // NON-NLS
|
||||||
|
private static final String KEY = "terminateEditOnFocusLost"; // NON-NLS
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SwingUtilities.invokeLater(new Test6505027());
|
||||||
|
|
||||||
|
Component component = null;
|
||||||
|
while (component == null) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(PAUSE);
|
||||||
|
}
|
||||||
|
catch (InterruptedException exception) {
|
||||||
|
// ignore interrupted exception
|
||||||
|
}
|
||||||
|
component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||||
|
}
|
||||||
|
if (!component.getClass().equals(JComboBox.class)) {
|
||||||
|
throw new Error("unexpected focus owner: " + component);
|
||||||
|
}
|
||||||
|
SwingUtilities.getWindowAncestor(component).dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private JTable table;
|
||||||
|
private Point point;
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if (this.table == null) {
|
||||||
|
JFrame main = new JFrame();
|
||||||
|
main.setSize(WIDTH + OFFSET * 3, HEIGHT + OFFSET * 5);
|
||||||
|
main.setLocationRelativeTo(null);
|
||||||
|
main.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
main.setVisible(true);
|
||||||
|
|
||||||
|
Container container = main;
|
||||||
|
if (INTERNAL) {
|
||||||
|
JInternalFrame frame = new JInternalFrame();
|
||||||
|
frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
JDesktopPane desktop = new JDesktopPane();
|
||||||
|
desktop.add(frame, new Integer(1));
|
||||||
|
|
||||||
|
container.add(desktop);
|
||||||
|
container = frame;
|
||||||
|
}
|
||||||
|
this.table = new JTable(new DefaultTableModel(COLUMNS, 2));
|
||||||
|
if (TERMINATE) {
|
||||||
|
this.table.putClientProperty(KEY, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
TableColumn column = this.table.getColumn(COLUMNS[1]);
|
||||||
|
column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));
|
||||||
|
|
||||||
|
container.add(BorderLayout.NORTH, new JTextField());
|
||||||
|
container.add(BorderLayout.CENTER, new JScrollPane(this.table));
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(this);
|
||||||
|
}
|
||||||
|
else if (this.point == null) {
|
||||||
|
this.point = this.table.getCellRect(1, 1, false).getLocation();
|
||||||
|
SwingUtilities.convertPointToScreen(this.point, this.table);
|
||||||
|
SwingUtilities.invokeLater(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mouseMove(this.point.x + 1, this.point.y + 1);
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
}
|
||||||
|
catch (AWTException exception) {
|
||||||
|
throw new Error("unexpected exception", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
108
jdk/test/javax/swing/JInternalFrame/Test6802868.java
Normal file
108
jdk/test/javax/swing/JInternalFrame/Test6802868.java
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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 6802868
|
||||||
|
* @summary JInternalFrame is not maximized when maximized parent frame
|
||||||
|
* @author Alexander Potochkin
|
||||||
|
*/
|
||||||
|
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
public class Test6802868 {
|
||||||
|
static JInternalFrame jif;
|
||||||
|
static JFrame frame;
|
||||||
|
static Dimension size;
|
||||||
|
static Point location;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.setAutoDelay(20);
|
||||||
|
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
frame = new JFrame();
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
JDesktopPane jdp = new JDesktopPane();
|
||||||
|
frame.getContentPane().add(jdp);
|
||||||
|
|
||||||
|
jif = new JInternalFrame("Title", true, true, true, true);
|
||||||
|
jdp.add(jif);
|
||||||
|
jif.setVisible(true);
|
||||||
|
|
||||||
|
frame.setSize(200, 200);
|
||||||
|
frame.setLocationRelativeTo(null);
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
jif.setMaximum(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolkit.realSync();
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
size = jif.getSize();
|
||||||
|
frame.setSize(300, 300);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolkit.realSync();
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (jif.getSize().equals(size)) {
|
||||||
|
throw new RuntimeException("InternalFrame hasn't changed its size");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
jif.setIcon(true);
|
||||||
|
} catch (PropertyVetoException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
location = jif.getDesktopIcon().getLocation();
|
||||||
|
frame.setSize(400, 400);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolkit.realSync();
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (jif.getDesktopIcon().getLocation().equals(location)) {
|
||||||
|
throw new RuntimeException("JDesktopIcon hasn't moved");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
102
jdk/test/javax/swing/JScrollPane/Test6526631.java
Normal file
102
jdk/test/javax/swing/JScrollPane/Test6526631.java
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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 6526631
|
||||||
|
* @summary Resizes right-oriented scroll pane
|
||||||
|
* @author Sergey Malenkov
|
||||||
|
* @library ..
|
||||||
|
* @build SwingTest
|
||||||
|
* @run main Test6526631
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JViewport;
|
||||||
|
|
||||||
|
import static java.awt.ComponentOrientation.RIGHT_TO_LEFT;
|
||||||
|
|
||||||
|
public class Test6526631 {
|
||||||
|
|
||||||
|
private static final int COLS = 90;
|
||||||
|
private static final int ROWS = 50;
|
||||||
|
private static final int OFFSET = 10;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SwingTest.start(Test6526631.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final JScrollPane pane;
|
||||||
|
private final JFrame frame;
|
||||||
|
|
||||||
|
public Test6526631(JFrame frame) {
|
||||||
|
this.pane = new JScrollPane(new JTextArea(ROWS, COLS));
|
||||||
|
this.pane.setComponentOrientation(RIGHT_TO_LEFT);
|
||||||
|
this.frame = frame;
|
||||||
|
this.frame.add(this.pane);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update(int offset) {
|
||||||
|
Dimension size = this.frame.getSize();
|
||||||
|
size.width += offset;
|
||||||
|
this.frame.setSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateFirst() {
|
||||||
|
validateThird();
|
||||||
|
update(OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateSecond() {
|
||||||
|
validateThird();
|
||||||
|
update(-OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateThird() {
|
||||||
|
JViewport viewport = this.pane.getViewport();
|
||||||
|
JScrollBar scroller = this.pane.getHorizontalScrollBar();
|
||||||
|
if (!scroller.getComponentOrientation().equals(RIGHT_TO_LEFT)) {
|
||||||
|
throw new IllegalStateException("unexpected component orientation");
|
||||||
|
}
|
||||||
|
int value = scroller.getValue();
|
||||||
|
if (value != 0) {
|
||||||
|
throw new IllegalStateException("unexpected scroll value");
|
||||||
|
}
|
||||||
|
int extent = viewport.getExtentSize().width;
|
||||||
|
if (extent != scroller.getVisibleAmount()) {
|
||||||
|
throw new IllegalStateException("unexpected visible amount");
|
||||||
|
}
|
||||||
|
int size = viewport.getViewSize().width;
|
||||||
|
if (size != scroller.getMaximum()) {
|
||||||
|
throw new IllegalStateException("unexpected maximum");
|
||||||
|
}
|
||||||
|
int pos = size - extent - value;
|
||||||
|
if (pos != viewport.getViewPosition().x) {
|
||||||
|
throw new IllegalStateException("unexpected position");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
160
jdk/test/javax/swing/SwingTest.java
Normal file
160
jdk/test/javax/swing/SwingTest.java
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import static javax.swing.SwingUtilities.invokeLater;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SwingTestHelper is a utility class for writing regression tests
|
||||||
|
* that require interacting with the UI.
|
||||||
|
*
|
||||||
|
* @author Sergey A. Malenkov
|
||||||
|
*/
|
||||||
|
final class SwingTest implements Runnable {
|
||||||
|
|
||||||
|
private static final int WIDTH = 640;
|
||||||
|
private static final int HEIGHT = 480;
|
||||||
|
|
||||||
|
public static void start(Class<?> type) {
|
||||||
|
new SwingTest(type).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final PrintWriter writer = new PrintWriter(System.out, true);
|
||||||
|
|
||||||
|
private Class<?> type;
|
||||||
|
private JFrame frame;
|
||||||
|
private Iterator<Method> methods;
|
||||||
|
private Object object;
|
||||||
|
private Method method;
|
||||||
|
private Throwable error;
|
||||||
|
|
||||||
|
private SwingTest(Class<?> type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
synchronized (this.writer) {
|
||||||
|
if (this.error != null) {
|
||||||
|
this.frame.dispose();
|
||||||
|
this.frame = null;
|
||||||
|
}
|
||||||
|
else if (this.object == null) {
|
||||||
|
invoke();
|
||||||
|
Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() {
|
||||||
|
public int compare(Method first, Method second) {
|
||||||
|
return first.getName().compareTo(second.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (Method method : this.type.getMethods()) {
|
||||||
|
if (method.getDeclaringClass().equals(this.type)) {
|
||||||
|
if (method.getReturnType().equals(void.class)) {
|
||||||
|
if (0 == method.getParameterTypes().length) {
|
||||||
|
methods.add(method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.methods = methods.iterator();
|
||||||
|
}
|
||||||
|
else if (this.method != null) {
|
||||||
|
invoke();
|
||||||
|
}
|
||||||
|
else if (this.methods.hasNext()) {
|
||||||
|
this.method = this.methods.next();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.frame.dispose();
|
||||||
|
this.frame = null;
|
||||||
|
this.type = null;
|
||||||
|
}
|
||||||
|
this.writer.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void start() {
|
||||||
|
synchronized (this.writer) {
|
||||||
|
while (this.type != null) {
|
||||||
|
if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
|
||||||
|
invoke();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
invokeLater(this);
|
||||||
|
try {
|
||||||
|
this.writer.wait();
|
||||||
|
}
|
||||||
|
catch (InterruptedException exception) {
|
||||||
|
exception.printStackTrace(this.writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((this.frame == null) && (this.error != null)) {
|
||||||
|
throw new Error("unexpected error", this.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invoke() {
|
||||||
|
try {
|
||||||
|
if (this.method != null) {
|
||||||
|
this.writer.println(this.method);
|
||||||
|
this.method.invoke(this.object);
|
||||||
|
this.method = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.writer.println(this.type);
|
||||||
|
this.frame = new JFrame(this.type.getSimpleName());
|
||||||
|
this.frame.setSize(WIDTH, HEIGHT);
|
||||||
|
this.frame.setLocationRelativeTo(null);
|
||||||
|
this.object = this.type.getConstructor(JFrame.class).newInstance(this.frame);
|
||||||
|
this.frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException exception) {
|
||||||
|
this.error = exception;
|
||||||
|
}
|
||||||
|
catch (SecurityException exception) {
|
||||||
|
this.error = exception;
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException exception) {
|
||||||
|
this.error = exception;
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException exception) {
|
||||||
|
this.error = exception;
|
||||||
|
}
|
||||||
|
catch (InstantiationException exception) {
|
||||||
|
this.error = exception;
|
||||||
|
}
|
||||||
|
catch (InvocationTargetException exception) {
|
||||||
|
this.error = exception.getTargetException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue