Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/DialogOwner.java
41171 views
1
/*
2
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package javax.print.attribute.standard;
27
28
import java.awt.Window;
29
import java.io.Serial;
30
31
import javax.print.attribute.Attribute;
32
import javax.print.attribute.PrintRequestAttribute;
33
34
import sun.print.DialogOwnerAccessor;
35
36
/**
37
* An attribute class used to support requesting a print or page setup dialog
38
* be kept displayed on top of all windows or some specific window.
39
* <p>
40
* Constructed without any arguments it will request that a print or page
41
* setup dialog be configured as if the application directly was to specify
42
* {@code java.awt.Window.setAlwaysOnTop(true)}, subject to permission checks.
43
* <p>
44
* Constructed with a {@link java.awt.Window} parameter, it requests that
45
* the dialog be owned by the specified window.
46
*
47
* @since 11
48
*/
49
public final class DialogOwner implements PrintRequestAttribute {
50
51
private static class Accessor extends DialogOwnerAccessor {
52
53
public long getOwnerID(DialogOwner owner) {
54
return owner.getID();
55
}
56
}
57
58
private static Accessor accessor = new Accessor();
59
static {
60
DialogOwnerAccessor.setAccessor(accessor);
61
}
62
63
/**
64
* Use serialVersionUID from JDK 11 for interoperability.
65
*/
66
@Serial
67
private static final long serialVersionUID = -1901909867156076547L;
68
69
/**
70
* The owner of the dialog.
71
*/
72
private Window owner;
73
private transient long id;
74
75
/**
76
* Constructs an instance which can be used to request
77
* {@code java.awt.Window.setAlwaysOnTop(true)} behaviour.
78
* This should be used where there is no application preferred owner window.
79
* Whether this has any effect depends on if always on top is supported
80
* for this platform and the particular dialog to be displayed.
81
*/
82
public DialogOwner() {
83
}
84
85
/**
86
* Constructs an instance which can be used to request that the
87
* specified {@link java.awt.Window} be the owner of the dialog.
88
* @param owner window.
89
*/
90
public DialogOwner(Window owner) {
91
this.owner = owner;
92
}
93
94
/**
95
* Constructs an instance which requests that the dialog be displayed
96
* as if it were a child of a native platform window, specified
97
* using its opqaue platform identifier or handle.
98
* This is useful mainly for the case where the id represents a window
99
* which may not be an AWT {@code Window}, but instead was created by
100
* another UI toolkit, such as OpenJFX.
101
* Any effect is platform dependent.
102
* @param id a native window identifier or handle
103
*/
104
DialogOwner(long id) {
105
this.id = id;
106
}
107
108
/**
109
* Returns a native platform id or handle, if one was specified,
110
* otherwise, zero.
111
* @return a native platform id.
112
*/
113
long getID() {
114
return id;
115
}
116
117
/**
118
* Returns a {@code Window owner}, if one was specified,
119
* otherwise {@code null}.
120
* @return an owner window.
121
*/
122
public Window getOwner() {
123
return owner;
124
}
125
126
/**
127
* Get the printing attribute class which is to be used as the "category"
128
* for this printing attribute value.
129
* <p>
130
* For class {@code DialogOwner}, the category is class
131
* {@code DialogOwner} itself.
132
*
133
* @return printing attribute class (category), an instance of class
134
* {@link Class java.lang.Class}
135
*/
136
public final Class<? extends Attribute> getCategory() {
137
return DialogOwner.class;
138
}
139
140
/**
141
* Get the name of the category of which this attribute value is an
142
* instance.
143
* <p>
144
* For class {@code DialogOwner}, the category name is
145
* {@code "dialog-owner"}.
146
*
147
*/
148
public final String getName() {
149
return "dialog-owner";
150
151
}
152
}
153
154