38
38
import java .util .Collections ;
39
39
import java .util .List ;
40
40
import java .util .Objects ;
41
+ import java .util .logging .Level ;
42
+ import java .util .logging .Logger ;
41
43
import javax .swing .JPanel ;
42
44
import javax .swing .SwingUtilities ;
43
45
import org .openide .util .RequestProcessor ;
@@ -53,6 +55,8 @@ class DataSourceWindow extends TopComponent implements PropertyChangeListener {
53
55
private static final RequestProcessor PROCESSOR =
54
56
new RequestProcessor ("DataSourceWindow Processor" , 5 ); // NOI18N
55
57
58
+ private static final Logger LOGGER = Logger .getLogger (DataSourceWindow .class .getName ());
59
+
56
60
private int viewsCount = 0 ;
57
61
private DataSource dataSource ;
58
62
private DataSourceDescriptor dataSourceDescriptor ;
@@ -145,15 +149,18 @@ public void removeView(final DataSourceView view) {
145
149
}
146
150
147
151
PROCESSOR .post (new Runnable () {
148
- public void run () { view .viewRemoved (); }
152
+ public void run () {
153
+ try { view .viewRemoved (); }
154
+ catch (Exception e ) { LOGGER .log (Level .WARNING , "Failed notifying removed view " + view , e ); } // NOI18N
155
+ }
149
156
});
150
157
151
158
DataSourceWindowManager .sharedInstance ().unregisterClosedView (view );
152
159
viewsCount --;
153
160
if (viewsCount == 0 && isOpened ()) close ();
154
161
}
155
162
156
- void clearView (final DataSourceView view ) {
163
+ void clearView (final DataSourceView view , RequestProcessor notificationProcessor ) {
157
164
if (viewsCount == 1 && Objects .equals (singleViewContainer .getName (), view .getName ())) {
158
165
singleViewContainer .removeAll ();
159
166
if (singleViewContainer .getCaption () != null ) singleViewContainer .getCaption ().finish ();
@@ -167,8 +174,11 @@ void clearView(final DataSourceView view) {
167
174
tabbedContainer .clearView (viewIndex );
168
175
}
169
176
170
- PROCESSOR .post (new Runnable () {
171
- public void run () { view .viewRemoved (); }
177
+ notificationProcessor .post (new Runnable () {
178
+ public void run () {
179
+ try { view .viewRemoved (); }
180
+ catch (Exception e ) { LOGGER .log (Level .WARNING , "Failed notifying removed view " + view , e ); } // NOI18N
181
+ }
172
182
});
173
183
}
174
184
@@ -193,7 +203,10 @@ void updateView(final DataSourceView view, int index) {
193
203
}
194
204
195
205
PROCESSOR .post (new Runnable () {
196
- public void run () { view .viewAdded (); }
206
+ public void run () {
207
+ try { view .viewAdded (); }
208
+ catch (Exception e ) { LOGGER .log (Level .WARNING , "Failed post-initialize view " + view , e ); } // NOI18N
209
+ }
197
210
});
198
211
}
199
212
0 commit comments