-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathTestFile.dat.2
305 lines (260 loc) · 11.6 KB
/
TestFile.dat.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
// value of super.getStyleOrigin() is not valid until after the call to set(v) returns,
// by which time invalidated will have been called.
// This value is initialized to USER in case someone calls set on the imageUrlProperty, which
// is possible:
// CssMetaData metaData = ((StyleableProperty)dialogPane.graphicProperty()).getCssMetaData();
// StyleableProperty prop = metaData.getStyleableProperty(dialogPane);
// prop.set(someUrl);
//
// TODO: Note that prop != dialogPane, which violates the contract between StyleableProperty and CssMetaData.
//
StyleOrigin origin = StyleOrigin.USER;
@Override
public void applyStyle(StyleOrigin origin, String v) {
this.origin = origin;
// Don't want applyStyle to throw an exception which would leave this.origin set to the wrong value
if (graphicProperty == null || graphicProperty.isBound() == false) super.applyStyle(origin, v);
// Origin is only valid for this invocation of applyStyle, so reset it to USER in case someone calls set.
this.origin = StyleOrigin.USER;
}
@Override
protected void invalidated() {
// need to call super.get() here since get() is overridden to return the graphicProperty's value
final String url = super.get();
if (url == null) {
((StyleableProperty<Node>)(WritableValue<Node>)graphicProperty()).applyStyle(origin, null);
} else {
// RT-34466 - if graphic's url is the same as this property's value, then don't overwrite.
final Node graphicNode = DialogPane.this.getGraphic();
if (graphicNode instanceof ImageView) {
final ImageView imageView = (ImageView)graphicNode;
final Image image = imageView.getImage();
if (image != null) {
final String imageViewUrl = image.impl_getUrl();
if (url.equals(imageViewUrl)) return;
}
}
final Image img = StyleManager.getInstance().getCachedImage(url);
if (img != null) {
//
// Note that it is tempting to try to re-use existing ImageView simply by setting
// the image on the current ImageView, if there is one. This would effectively change
// the image, but not the ImageView which means that no graphicProperty listeners would
// be notified. This is probably not what we want.
//
//
// Have to call applyStyle on graphicProperty so that the graphicProperty's
// origin matches the imageUrlProperty's origin.
//
((StyleableProperty<Node>)(WritableValue<Node>)graphicProperty()).applyStyle(origin, new ImageView(img));
}
}
}
@Override
public String get() {
//
// The value of the imageUrlProperty is that of the graphicProperty.
// Return the value in a way that doesn't expand the graphicProperty.
//
final Node graphic = getGraphic();
if (graphic instanceof ImageView) {
final Image image = ((ImageView)graphic).getImage();
if (image != null) {
return image.impl_getUrl();
}
}
return null;
}
@Override
public StyleOrigin getStyleOrigin() {
//
// The origin of the imageUrlProperty is that of the graphicProperty.
// Return the origin in a way that doesn't expand the graphicProperty.
//
return graphicProperty != null ? ((StyleableProperty<Node>)(WritableValue<Node>)graphicProperty).getStyleOrigin() : null;
}
@Override
public Object getBean() {
return DialogPane.this;
}
@Override
public String getName() {
return "imageUrl";
}
@Override
public CssMetaData<DialogPane,String> getCssMetaData() {
return StyleableProperties.GRAPHIC;
}
};
}
return imageUrl;
}
// --- header
private final ObjectProperty<Node> header = new SimpleObjectProperty<Node>(null) {
WeakReference<Node> headerRef = new WeakReference<>(null);
@Override protected void invalidated() {
Node oldHeader = headerRef.get();
if (oldHeader != null) {
getChildren().remove(oldHeader);
}
Node newHeader = getHeader();
headerRef = new WeakReference<>(newHeader);
updateHeaderArea();
}
};
/**
* Node which acts as the dialog pane header.
*
* @return the header of the dialog pane.
*/
public final Node getHeader() {
return header.get();
}
/**
* Assigns the dialog pane header. Any Node can be used.
*
* @param header The new header of the DialogPane.
*/
public final void setHeader(Node header) {
this.header.setValue(header);
}
/**
* Property representing the header area of the dialog pane. Note that if this
* header is set to a non-null value, that it will take up the entire top
* area of the DialogPane. It will also result in the DialogPane switching its
* layout to the 'header' layout - as outlined in the {@link DialogPane} class
* javadoc.
*/
public final ObjectProperty<Node> headerProperty() {
return header;
}
// --- header text
private final StringProperty headerText = new SimpleStringProperty(this, "headerText") {
@Override protected void invalidated() {
updateHeaderArea();
requestLayout();
}
};
/**
* Sets the string to show in the dialog header area. Note that the header text
* is lower precedence than the {@link #headerProperty() header node}, meaning
* that if both the header node and the headerText properties are set, the
* header text will not be displayed in a default DialogPane instance.
*
* <p>When headerText is set to a non-null value, this will result in the
* DialogPane switching its layout to the 'header' layout - as outlined in
* the {@link DialogPane} class javadoc.</p>
*/
public final void setHeaderText(String headerText) {
this.headerText.set(headerText);
}
/**
* Returns the currently-set header text for this DialogPane.
*/
public final String getHeaderText() {
return headerText.get();
}
/**
* A property representing the header text for the dialog pane. The header text
* is lower precedence than the {@link #headerProperty() header node}, meaning
* that if both the header node and the headerText properties are set, the
* header text will not be displayed in a default DialogPane instance.
*
* <p>When headerText is set to a non-null value, this will result in the
* DialogPane switching its layout to the 'header' layout - as outlined in
* the {@link DialogPane} class javadoc.</p>
*/
public final StringProperty headerTextProperty() {
return headerText;
}
// --- content
private final ObjectProperty<Node> content = new SimpleObjectProperty<Node>(null) {
WeakReference<Node> contentRef = new WeakReference<>(null);
@Override protected void invalidated() {
Node oldContent = contentRef.get();
if (oldContent != null) {
getChildren().remove(oldContent);
}
Node newContent = getContent();
contentRef = new WeakReference<>(newContent);
updateContentArea();
}
};
/**
* Returns the dialog content as a Node (even if it was set as a String
* using {@link #setContentText(String)} - this was simply transformed into a
* {@link Node} (most probably a {@link Label}).
*
* @return dialog's content
*/
public final Node getContent() {
return content.get();
}
/**
* Assign dialog content. Any Node can be used
*
* @param content
* dialog's content
*/
public final void setContent(Node content) {
this.content.setValue(content);
}
/**
* Property representing the content area of the dialog.
*/
public final ObjectProperty<Node> contentProperty() {
return content;
}
// --- content text
private final StringProperty contentText = new SimpleStringProperty(this, "contentText") {
@Override protected void invalidated() {
updateContentArea();
requestLayout();
}
};
/**
* Sets the string to show in the dialog content area. Note that the content text
* is lower precedence than the {@link #contentProperty() content node}, meaning
* that if both the content node and the contentText properties are set, the
* content text will not be displayed in a default DialogPane instance.
*/
public final void setContentText(String contentText) {
this.contentText.set(contentText);
}
/**
* Returns the currently-set content text for this DialogPane.
*/
public final String getContentText() {
return contentText.get();
}
/**
* A property representing the content text for the dialog pane. The content text
* is lower precedence than the {@link #contentProperty() content node}, meaning
* that if both the content node and the contentText properties are set, the
* content text will not be displayed in a default DialogPane instance.
*/
public final StringProperty contentTextProperty() {
return contentText;
}
// --- expandable content
private final ObjectProperty<Node> expandableContentProperty = new SimpleObjectProperty<Node>(null) {
WeakReference<Node> expandableContentRef = new WeakReference<>(null);
@Override protected void invalidated() {
Node oldExpandableContent = expandableContentRef.get();
if (oldExpandableContent != null) {
getChildren().remove(oldExpandableContent);
}
Node newExpandableContent = getExpandableContent();
expandableContentRef = new WeakReference<Node>(newExpandableContent);
if (newExpandableContent != null) {
newExpandableContent.setVisible(isExpanded());
newExpandableContent.setManaged(isExpanded());
if (!newExpandableContent.getStyleClass().contains("expandable-content")) { //$NON-NLS-1$
newExpandableContent.getStyleClass().add("expandable-content"); //$NON-NLS-1$
}
getChildren().add(newExpandableContent);
}
}
};
/**
*