Lines 176-209
Link Here
|
176 |
//EditorCookie.Observable listener |
176 |
//EditorCookie.Observable listener |
177 |
addPropertyChangeListener(new PropertyChangeListener() { |
177 |
addPropertyChangeListener(new PropertyChangeListener() { |
178 |
|
178 |
|
|
|
179 |
@Override |
179 |
public void propertyChange(PropertyChangeEvent evt) { |
180 |
public void propertyChange(PropertyChangeEvent evt) { |
180 |
if (evt.getPropertyName().equals(EditorCookie.Observable.PROP_DOCUMENT)) { |
181 |
if (evt.getPropertyName().equals(EditorCookie.Observable.PROP_DOCUMENT)) { |
181 |
if (evt.getNewValue() != null) { |
182 |
if (evt.getNewValue() != null) { |
182 |
//document loaded |
183 |
//document loaded |
183 |
restartParserTask(); |
184 |
restartParserTask(); |
184 |
((Document)evt.getNewValue()).addDocumentListener(DOCUMENT_LISTENER); |
185 |
((Document)evt.getNewValue()).addDocumentListener(DOCUMENT_LISTENER); |
185 |
} else { |
186 |
} else if (evt.getOldValue() != null) { |
186 |
//document closed |
187 |
//document closed |
187 |
//Issue #172631>>> |
188 |
((Document)evt.getOldValue()).removeDocumentListener(DOCUMENT_LISTENER); |
188 |
Object oldDoc = evt.getOldValue(); |
|
|
189 |
if(oldDoc == null) { |
190 |
Logger.getLogger(getClass().getName()).log(Level.INFO, |
191 |
"property change fired with both new and old value null!", |
192 |
new IllegalStateException()); |
193 |
return ; |
194 |
} |
195 |
//<<< |
196 |
((Document)oldDoc).removeDocumentListener(DOCUMENT_LISTENER); |
197 |
//cancel waiting parsing task if there is any |
189 |
//cancel waiting parsing task if there is any |
198 |
//this is largely a workaround for issue #50926 |
190 |
//this is largely a workaround for issue #50926 |
199 |
TagLibParseSupport sup = (TagLibParseSupport) getDataObject().getCookie(TagLibParseSupport.class); |
191 |
TagLibParseSupport sup = getDataObject().getLookup().lookup(TagLibParseSupport.class); |
200 |
if (sup != null) { |
192 |
if (sup != null) { |
201 |
sup.cancelParsingTask(); |
193 |
sup.cancelParsingTask(); |
202 |
} |
194 |
} |
203 |
} |
195 |
} |
204 |
|
|
|
205 |
} |
196 |
} |
206 |
} |
197 |
} |
|
|
198 |
|
207 |
}); |
199 |
}); |
208 |
} |
200 |
} |
209 |
|
201 |
|