Skip to content

Commit 04b707c

Browse files
committed
Make sure UI code is invoked in the EDT
1 parent 0c6edd5 commit 04b707c

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceCaption.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,28 @@ public DataSourceCaption(X dataSource) {
9999
}
100100

101101

102-
public void propertyChange(PropertyChangeEvent evt) {
103-
String propertyName = evt.getPropertyName();
104-
if (Stateful.PROPERTY_STATE.equals(propertyName)) {
105-
int state = (Integer)evt.getNewValue();
106-
isAvailable = state == Stateful.STATE_AVAILABLE;
107-
if (tracksChanges && !isDirty && isAvailable && (Integer)evt.getOldValue() == Stateful.STATE_UNAVAILABLE) isDirty = true;
108-
updateAvailable();
109-
updateCaption();
110-
} else if (DataSourceDescriptor.PROPERTY_NAME.equals(propertyName)) {
111-
name = (String)evt.getNewValue();
112-
updateCaption();
113-
} else if (DataSourceDescriptor.PROPERTY_DESCRIPTION.equals(propertyName)) {
114-
description = (String)evt.getNewValue();
115-
updateDescription();
116-
} else if (DataSourceDescriptor.PROPERTY_ICON.equals(propertyName)) {
117-
// Could display datasource icon instead of progress icon
118-
// setIcon(new ImageIcon((Image)evt.getNewValue()));
119-
}
102+
public void propertyChange(final PropertyChangeEvent evt) {
103+
SwingUtilities.invokeLater(new Runnable() {
104+
public void run() {
105+
String propertyName = evt.getPropertyName();
106+
if (Stateful.PROPERTY_STATE.equals(propertyName)) {
107+
int state = (Integer)evt.getNewValue();
108+
isAvailable = state == Stateful.STATE_AVAILABLE;
109+
if (tracksChanges && !isDirty && isAvailable && (Integer)evt.getOldValue() == Stateful.STATE_UNAVAILABLE) isDirty = true;
110+
updateAvailable();
111+
updateCaption();
112+
} else if (DataSourceDescriptor.PROPERTY_NAME.equals(propertyName)) {
113+
name = (String)evt.getNewValue();
114+
updateCaption();
115+
} else if (DataSourceDescriptor.PROPERTY_DESCRIPTION.equals(propertyName)) {
116+
description = (String)evt.getNewValue();
117+
updateDescription();
118+
} else if (DataSourceDescriptor.PROPERTY_ICON.equals(propertyName)) {
119+
// Could display datasource icon instead of progress icon
120+
// setIcon(new ImageIcon((Image)evt.getNewValue()));
121+
}
122+
}
123+
});
120124
}
121125

122126

@@ -153,8 +157,6 @@ private void updateAvailable() {
153157
presenter1.setIcon(new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/idle-icon.png"))); // NOI18N
154158
}
155159

156-
if (!SwingUtilities.isEventDispatchThread()) Thread.dumpStack();
157-
158160
if (isDirty && !isOpaque()) {
159161
JLabel l = new JLabel(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_LBL_Reload")) { // NOI18N
160162
public Dimension getMinimumSize() {

0 commit comments

Comments
 (0)