mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 09:34:38 +02:00
8204496: backout fix for 8203796 which was pushed under another ID
Reviewed-by: serb
This commit is contained in:
parent
24dd5debd4
commit
f6245c499f
12 changed files with 211 additions and 599 deletions
|
@ -25,6 +25,8 @@
|
|||
|
||||
package javax.print;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
|
@ -33,11 +35,11 @@ import java.awt.Window;
|
|||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.AttributeSet;
|
||||
import javax.print.attribute.standard.DialogOwner;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.Destination;
|
||||
import javax.print.attribute.standard.Fidelity;
|
||||
|
||||
import sun.print.DialogOwner;
|
||||
import sun.print.ServiceDialog;
|
||||
import sun.print.SunAlternateMedia;
|
||||
|
||||
|
@ -183,7 +185,6 @@ public class ServiceUI {
|
|||
|
||||
DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class);
|
||||
Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null;
|
||||
boolean setOnTop = (dlgOwner != null) && (owner == null);
|
||||
|
||||
Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice().
|
||||
|
@ -191,17 +192,21 @@ public class ServiceUI {
|
|||
|
||||
x += gcBounds.x;
|
||||
y += gcBounds.y;
|
||||
ServiceDialog dialog = new ServiceDialog(gc,
|
||||
x,
|
||||
y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
owner);
|
||||
if (setOnTop) {
|
||||
try {
|
||||
dialog.setAlwaysOnTop(true);
|
||||
} catch (SecurityException e) {
|
||||
}
|
||||
ServiceDialog dialog;
|
||||
if (owner instanceof Frame) {
|
||||
dialog = new ServiceDialog(gc,
|
||||
x,
|
||||
y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
(Frame)owner);
|
||||
} else {
|
||||
dialog = new ServiceDialog(gc,
|
||||
x,
|
||||
y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
(Dialog)owner);
|
||||
}
|
||||
Rectangle dlgBounds = dialog.getBounds();
|
||||
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.awt.Window;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import sun.print.DialogOwnerAccessor;
|
||||
|
||||
/**
|
||||
* An attribute class used to support requesting a print or page setup dialog
|
||||
* be kept displayed on top of all windows or some specific window.
|
||||
* <p>
|
||||
* Constructed without any arguments it will request that a print or page
|
||||
* setup dialog be configured as if the application directly was to specify
|
||||
* {@code java.awt.Window.setAlwaysOnTop(true)}, subject to permission checks.
|
||||
* <p>
|
||||
* Constructed with a {@link java.awt.Window} parameter, it requests that
|
||||
* the dialog be owned by the specified window.
|
||||
*
|
||||
* @since 11
|
||||
*/
|
||||
public final class DialogOwner implements PrintRequestAttribute {
|
||||
|
||||
private static class Accessor extends DialogOwnerAccessor {
|
||||
|
||||
public long getOwnerID(DialogOwner owner) {
|
||||
return owner.getID();
|
||||
}
|
||||
}
|
||||
|
||||
static private Accessor accessor = new Accessor();
|
||||
static {
|
||||
DialogOwnerAccessor.setAccessor(accessor);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -1901909867156076547L;
|
||||
|
||||
private Window owner;
|
||||
private transient long id;
|
||||
|
||||
/**
|
||||
* Constructs an instance which can be used to request
|
||||
* {@code java.awt.Window.setAlwaysOnTop(true)} behaviour.
|
||||
* This should be used where there is no application preferred owner window.
|
||||
* Whether this has any effect depends on if always on top is supported
|
||||
* for this platform and the particular dialog to be displayed.
|
||||
*/
|
||||
public DialogOwner() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance which can be used to request that the
|
||||
* specified {@link java.awt.Window} be the owner of the dialog.
|
||||
* @param owner window.
|
||||
*/
|
||||
public DialogOwner(Window owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance which requests that the dialog be displayed
|
||||
* as if it were a child of a native platform window, specified
|
||||
* using its opqaue platform identifier or handle.
|
||||
* This is useful mainly for the case where the id represents a window
|
||||
* which may not be an AWT {@code Window}, but instead was created by
|
||||
* another UI toolkit, such as OpenJFX.
|
||||
* Any effect is platform dependent.
|
||||
* @param id a native window identifier or handle
|
||||
*/
|
||||
DialogOwner(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a native platform id or handle, if one was specified,
|
||||
* otherwise, zero.
|
||||
* @return a native platform id.
|
||||
*/
|
||||
long getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code Window owner}, if one was specified,
|
||||
* otherwise {@code null}.
|
||||
* @return an owner window.
|
||||
*/
|
||||
public Window getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <p>
|
||||
* For class {@code DialogOwner}, the category is class
|
||||
* {@code DialogOwner} itself.
|
||||
*
|
||||
* @return printing attribute class (category), an instance of class
|
||||
* {@link Class java.lang.Class}
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return DialogOwner.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <p>
|
||||
* For class {@code DialogOwner}, the category name is
|
||||
* {@code "dialog-owner"}.
|
||||
*
|
||||
*/
|
||||
public final String getName() {
|
||||
return "dialog-owner";
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue